diff --git a/packages/editor/src/classes/action-config/index.ts b/packages/editor/src/classes/action-config/index.ts index 37ea3c36..70e39fc3 100644 --- a/packages/editor/src/classes/action-config/index.ts +++ b/packages/editor/src/classes/action-config/index.ts @@ -1,3 +1,21 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * Interface for menu configuration. * One of these properties must be set: onClick, render or options. diff --git a/packages/editor/src/classes/default-widget-manager/index.ts b/packages/editor/src/classes/default-widget-manager/index.ts index 6187b0f2..95123221 100644 --- a/packages/editor/src/classes/default-widget-manager/index.ts +++ b/packages/editor/src/classes/default-widget-manager/index.ts @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React, { useRef, useState } from 'react'; import { WidgetManager, diff --git a/packages/editor/src/classes/default-widget-manager/react-component.tsx b/packages/editor/src/classes/default-widget-manager/react-component.tsx index 3e1c4f05..01abce7d 100644 --- a/packages/editor/src/classes/default-widget-manager/react-component.tsx +++ b/packages/editor/src/classes/default-widget-manager/react-component.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React from 'react'; import TopicLink from '../../components/action-widget/pane/topic-link'; import TopicNote from '../../components/action-widget/pane/topic-note'; diff --git a/packages/editor/src/classes/i18n-msg/index.ts b/packages/editor/src/classes/i18n-msg/index.ts index 029678ae..4f7fbc35 100644 --- a/packages/editor/src/classes/i18n-msg/index.ts +++ b/packages/editor/src/classes/i18n-msg/index.ts @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import FR from './../../compiled-lang/fr.json'; import ES from './../../compiled-lang/es.json'; import EN from './../../compiled-lang/en.json'; diff --git a/packages/editor/src/classes/model/node-property-builder/index.ts b/packages/editor/src/classes/model/node-property-builder/index.ts new file mode 100644 index 00000000..a6590ede --- /dev/null +++ b/packages/editor/src/classes/model/node-property-builder/index.ts @@ -0,0 +1,211 @@ +import { Designer } from '@wisemapping/mindplot'; +import NodeProperty from '../node-property'; +import { + getTheUniqueValueOrNull, + SwitchValueDirection, + getPreviousValue, + fontSizes, + getNextValue, +} from '../../../components/toolbar/ToolbarValueModelBuilder'; + +/** + * Given a designer build NodePropertyValueModel instances for the mindplot node properties + */ + +class NodePropertyBuilder { + designer: Designer; + + fontSizeModel: NodeProperty; + selectedTopicColorModel: NodeProperty; + fontFamilyModel: NodeProperty; + fontStyleModel: NodeProperty; + borderColorModel: NodeProperty; + fontColorModel: NodeProperty; + topicShapeModel: NodeProperty; + topicIconModel: NodeProperty; + noteModel: NodeProperty; + linkModel: NodeProperty; + + /** + * + * @param designer designer to change node properties values + */ + constructor(designer: Designer) { + this.designer = designer; + } + + private selectedTopic() { + return designer.getModel().selectedTopic(); + } + + private getFontSize() { + return designer.getModel().selectedTopic()?.getFontSize(); + } + + private uniqueOrNull(propertyGetter: (Topic) => any | null) { + const nodes = designer.getModel().filterSelectedTopics(); + return getTheUniqueValueOrNull(nodes, propertyGetter); + } + + /** + * + * @returns model to and switch font weigth + */ + fontWeigthModel(): NodeProperty { + return { + getValue: () => designer.getModel().selectedTopic()?.getFontWeight(), + switchValue: () => designer.changeFontWeight(), + }; + } + + /** + * + * @returns model to and switch font size in both directions. Font sizes used to iterate: [6, 8, 10, 15] + */ + getFontSizeModel(): NodeProperty { + if (!this.fontSizeModel) + this.fontSizeModel = { + getValue: () => this.getFontSize(), + switchValue: (direction?) => { + let newValue = undefined; + if (direction === SwitchValueDirection.down) { + newValue = getPreviousValue(fontSizes, this.getFontSize()); + } + if (direction === SwitchValueDirection.up) { + newValue = getNextValue(fontSizes, this.getFontSize()); + } + designer.changeFontSize(newValue); + }, + }; + return this.fontSizeModel; + } + + /** + * + * @returns model to get and set topic color + */ + getSelectedTopicColorModel(): NodeProperty { + if (!this.selectedTopicColorModel) + this.selectedTopicColorModel = { + getValue: () => designer.getModel().selectedTopic()?.getBackgroundColor(), + setValue: (color) => designer.changeBackgroundColor(color), + }; + + return this.selectedTopicColorModel; + } + + /** + * + * @returns model to get and set the node link + */ + getLinkModel(): NodeProperty { + // const selected = this.selectedTopic(); + if (!this.linkModel) + this.linkModel = { + getValue: (): string => this.selectedTopic()?.getLinkValue(), + setValue: (value: string) => { + if (value && value.trim() !== '') { + this.selectedTopic().setLinkValue(value); + } else { + this.selectedTopic().setLinkValue(undefined); + } + }, + }; + return this.linkModel; + } + + /** + * + * @returns model to get and set topic border color + */ + getColorBorderModel(): NodeProperty { + if (!this.borderColorModel) + this.borderColorModel = { + getValue: () => this.uniqueOrNull((node) => node.getBorderColor()), + setValue: (hex: string) => designer.changeBorderColor(hex), + }; + return this.borderColorModel; + } + + /** + * + * @returns model to get and set topic font color + */ + getFontColorModel(): NodeProperty { + if (!this.fontColorModel) + this.fontColorModel = { + getValue: () => this.uniqueOrNull((node) => node.getFontColor()), + setValue: (hex: string) => designer.changeFontColor(hex), + }; + return this.fontColorModel; + } + + /** + * + * @returns model to get and set topic icon + */ + getTopicIconModel(): NodeProperty { + if (!this.topicIconModel) + this.topicIconModel = { + getValue: () => null, + setValue: (value: string) => designer.addIconType(value), + }; + return this.topicIconModel; + } + + /** + * + * @returns model to get and set topic note + */ + getNoteModel(): NodeProperty { + if (!this.noteModel) + this.noteModel = { + getValue: (): string => this.selectedTopic()?.getNoteValue(), + setValue: (value: string) => { + const note = value && value.trim() !== '' ? value : undefined; + this.selectedTopic()?.setNoteValue(note); + }, + }; + return this.noteModel; + } + + /** + * + * @returns model to get and set topic font family + */ + getFontFamilyModel(): NodeProperty { + if (!this.fontFamilyModel) + this.fontFamilyModel = { + getValue: () => this.uniqueOrNull((node) => node.getFontFamily()), + setValue: (value: string) => designer.changeFontFamily(value), + }; + return this.fontFamilyModel; + } + + /** + * + * @returns model to get and switch topic style + */ + getFontStyleModel(): NodeProperty { + if (!this.fontStyleModel) + this.fontStyleModel = { + getValue: () => this.selectedTopic()?.getFontStyle(), + switchValue: () => designer.changeFontStyle(), + }; + return this.fontStyleModel; + } + + /** + * + * @returns model to get and set topic shape + */ + getTopicShapeModel(): NodeProperty { + if (!this.topicShapeModel) + this.topicShapeModel = { + getValue: () => this.uniqueOrNull((node) => node.getShapeType()), + setValue: (value: string) => designer.changeTopicShape(value), + }; + return this.topicShapeModel; + } +} +export default NodePropertyBuilder; diff --git a/packages/editor/src/classes/model/node-property/index.ts b/packages/editor/src/classes/model/node-property/index.ts new file mode 100644 index 00000000..45cf6627 --- /dev/null +++ b/packages/editor/src/classes/model/node-property/index.ts @@ -0,0 +1,21 @@ +import { SwitchValueDirection } from '../../../components/toolbar/ToolbarValueModelBuilder'; + +/** + * Interface to get and set a property of the mindplot selected node + */ + +interface NodeProperty { + /** + * get the property value + */ + getValue: () => any; + /** + * set the property value + */ + setValue?: (value: any) => void; + /** + * toogle boolean values or change for next/previous in reduced lists of values + */ + switchValue?: (direction?: SwitchValueDirection) => void; +} +export default NodeProperty; diff --git a/packages/editor/src/components/action-widget/button/font-family-selector/index.tsx b/packages/editor/src/components/action-widget/button/font-family-selector/index.tsx index ee9cf6b4..9a75449a 100644 --- a/packages/editor/src/components/action-widget/button/font-family-selector/index.tsx +++ b/packages/editor/src/components/action-widget/button/font-family-selector/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React from 'react'; import Box from '@mui/material/Box'; import FormControl from '@mui/material/FormControl'; @@ -5,12 +22,12 @@ import MenuItem from '@mui/material/MenuItem'; import Select, { SelectChangeEvent } from '@mui/material/Select'; import Typography from '@mui/material/Typography'; -import { NodePropertyValueModel } from '../../../toolbar/ToolbarValueModelBuilder'; +import NodeProperty from '../../../../classes/model/node-property'; /** * Font family selector for editor toolbar */ -const FontFamilySelect = (props: { fontFamilyModel: NodePropertyValueModel }) => { +const FontFamilySelect = (props: { fontFamilyModel: NodeProperty }) => { const [font, setFont] = React.useState(props.fontFamilyModel.getValue()); const handleChange = (event: SelectChangeEvent) => { diff --git a/packages/editor/src/components/action-widget/button/undo-and-redo/index.tsx b/packages/editor/src/components/action-widget/button/undo-and-redo/index.tsx index 81f4d67b..8b023a5e 100644 --- a/packages/editor/src/components/action-widget/button/undo-and-redo/index.tsx +++ b/packages/editor/src/components/action-widget/button/undo-and-redo/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React, { useEffect, useState } from 'react'; import ActionConfig from '../../../../classes/action-config'; import { ToolbarMenuItem } from '../../../toolbar/Toolbar'; diff --git a/packages/editor/src/components/action-widget/input/index.tsx b/packages/editor/src/components/action-widget/input/index.tsx index c2d55d73..7d24eb4c 100644 --- a/packages/editor/src/components/action-widget/input/index.tsx +++ b/packages/editor/src/components/action-widget/input/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import TextField, { TextFieldProps } from '@mui/material/TextField'; import DesignerKeyboard from '@wisemapping/mindplot/src/components/DesignerKeyboard'; import React, { useEffect } from 'react'; diff --git a/packages/editor/src/components/action-widget/pane/color-picker/index.tsx b/packages/editor/src/components/action-widget/pane/color-picker/index.tsx index d4ba1d6c..ec62c71f 100644 --- a/packages/editor/src/components/action-widget/pane/color-picker/index.tsx +++ b/packages/editor/src/components/action-widget/pane/color-picker/index.tsx @@ -1,13 +1,30 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import Box from '@mui/material/Box'; import React from 'react'; -import { NodePropertyValueModel } from '../../../toolbar/ToolbarValueModelBuilder'; +import NodeProperty from '../../../../classes/model/node-property'; import { CirclePicker as ReactColorPicker } from 'react-color'; import colors from './colors.json'; /** * Color picker for toolbar */ -const ColorPicker = (props: { closeModal: () => void; colorModel: NodePropertyValueModel }) => { +const ColorPicker = (props: { closeModal: () => void; colorModel: NodeProperty }) => { return ( void; iconModel: NodePropertyValueModel }) => { +const IconPicker = (props: { closeModal: () => void; iconModel: NodeProperty }) => { const [value, setValue] = React.useState(0); const handleChange = (event: React.SyntheticEvent, newValue: number) => { diff --git a/packages/editor/src/components/action-widget/pane/keyboard-shortcut-help/index.tsx b/packages/editor/src/components/action-widget/pane/keyboard-shortcut-help/index.tsx index 6a9ba3ba..db1098e0 100644 --- a/packages/editor/src/components/action-widget/pane/keyboard-shortcut-help/index.tsx +++ b/packages/editor/src/components/action-widget/pane/keyboard-shortcut-help/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { $msg } from '@wisemapping/mindplot'; import React from 'react'; diff --git a/packages/editor/src/components/action-widget/pane/save-and-delete/index.tsx b/packages/editor/src/components/action-widget/pane/save-and-delete/index.tsx index 3489e196..455938ec 100644 --- a/packages/editor/src/components/action-widget/pane/save-and-delete/index.tsx +++ b/packages/editor/src/components/action-widget/pane/save-and-delete/index.tsx @@ -1,13 +1,30 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import IconButton from '@mui/material/IconButton'; import { $msg } from '@wisemapping/mindplot'; import React from 'react'; -import { NodePropertyValueModel } from '../../../toolbar/ToolbarValueModelBuilder'; +import NodeProperty from '../../../../classes/model/node-property'; import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined'; const SaveAndDelete = (props: { - model: NodePropertyValueModel; + model: NodeProperty; closeModal: () => void; submitHandler: () => void; }) => { diff --git a/packages/editor/src/components/action-widget/pane/topic-link/index.tsx b/packages/editor/src/components/action-widget/pane/topic-link/index.tsx index ced20bc6..6f681812 100644 --- a/packages/editor/src/components/action-widget/pane/topic-link/index.tsx +++ b/packages/editor/src/components/action-widget/pane/topic-link/index.tsx @@ -1,6 +1,23 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { useState } from 'react'; import { $msg } from '@wisemapping/mindplot'; -import { NodePropertyValueModel } from '../../../toolbar/ToolbarValueModelBuilder'; +import NodeProperty from '../../../../classes/model/node-property'; import Box from '@mui/material/Box'; import React from 'react'; import Input from '../../input'; @@ -12,7 +29,7 @@ import OpenInNewOutlinedIcon from '@mui/icons-material/OpenInNewOutlined'; /** * Url form for toolbar and node contextual editor */ -const TopicLink = (props: { closeModal: () => void; urlModel: NodePropertyValueModel }) => { +const TopicLink = (props: { closeModal: () => void; urlModel: NodeProperty }) => { const [url, setUrl] = useState(props.urlModel.getValue()); /** diff --git a/packages/editor/src/components/action-widget/pane/topic-note/index.tsx b/packages/editor/src/components/action-widget/pane/topic-note/index.tsx index eace456f..4432ac42 100644 --- a/packages/editor/src/components/action-widget/pane/topic-note/index.tsx +++ b/packages/editor/src/components/action-widget/pane/topic-note/index.tsx @@ -1,14 +1,31 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import Box from '@mui/material/Box'; import { $msg } from '@wisemapping/mindplot'; import React, { useState } from 'react'; -import { NodePropertyValueModel } from '../../../toolbar/ToolbarValueModelBuilder'; +import NodeProperty from '../../../../classes/model/node-property'; import Input from '../../input'; import SaveAndDelete from '../save-and-delete'; /** * Note form for toolbar and node contextual editor */ -const TopicNote = (props: { closeModal: () => void; noteModel: NodePropertyValueModel | null }) => { +const TopicNote = (props: { closeModal: () => void; noteModel: NodeProperty | null }) => { const [note, setNote] = useState(props.noteModel.getValue()); const submitHandler = () => { diff --git a/packages/editor/src/components/app-bar/index.tsx b/packages/editor/src/components/app-bar/index.tsx index 417d07b4..e699dab1 100644 --- a/packages/editor/src/components/app-bar/index.tsx +++ b/packages/editor/src/components/app-bar/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React from 'react'; import ActionConfig from '../../classes/action-config'; import MaterialToolbar from '@mui/material/Toolbar'; diff --git a/packages/editor/src/components/footer/index.tsx b/packages/editor/src/components/footer/index.tsx index b20d0c1b..636586b3 100644 --- a/packages/editor/src/components/footer/index.tsx +++ b/packages/editor/src/components/footer/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React, { useState } from 'react'; import { Notifier } from './styled'; import { useIntl } from 'react-intl'; diff --git a/packages/editor/src/components/footer/styled.ts b/packages/editor/src/components/footer/styled.ts index 6dbfd947..8f1ca71b 100644 --- a/packages/editor/src/components/footer/styled.ts +++ b/packages/editor/src/components/footer/styled.ts @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import styled from 'styled-components'; import { times } from '../size'; import LogoTextBlackSvg from '../../../images/logo-text-black.svg'; diff --git a/packages/editor/src/components/index.tsx b/packages/editor/src/components/index.tsx index b761cc97..5e8f4b34 100644 --- a/packages/editor/src/components/index.tsx +++ b/packages/editor/src/components/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React, { useCallback, useEffect, useRef, useState } from 'react'; import Popover from '@mui/material/Popover'; diff --git a/packages/editor/src/components/toolbar/Toolbar.tsx b/packages/editor/src/components/toolbar/Toolbar.tsx index 55172355..a4149417 100644 --- a/packages/editor/src/components/toolbar/Toolbar.tsx +++ b/packages/editor/src/components/toolbar/Toolbar.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React, { useRef, useState } from 'react'; import AppBar from '@mui/material/AppBar'; import Divider from '@mui/material/Divider'; diff --git a/packages/editor/src/components/toolbar/ToolbarPositionInterface.ts b/packages/editor/src/components/toolbar/ToolbarPositionInterface.ts index 6c809d80..194857de 100644 --- a/packages/editor/src/components/toolbar/ToolbarPositionInterface.ts +++ b/packages/editor/src/components/toolbar/ToolbarPositionInterface.ts @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /** * Configure position of a toolbar */ diff --git a/packages/editor/src/components/toolbar/ToolbarValueModelBuilder.ts b/packages/editor/src/components/toolbar/ToolbarValueModelBuilder.ts index 6cbb1dcc..152457d7 100644 --- a/packages/editor/src/components/toolbar/ToolbarValueModelBuilder.ts +++ b/packages/editor/src/components/toolbar/ToolbarValueModelBuilder.ts @@ -1,29 +1,9 @@ -import { Designer } from '@wisemapping/mindplot'; - export enum SwitchValueDirection { 'up', 'down', } -const fontSizes = [6, 8, 10, 15]; - -/** - * Interface to get and set a property of the mindplot selected node - */ -export interface NodePropertyValueModel { - /** - * get the property value - */ - getValue: () => any; - /** - * set the property value - */ - setValue?: (value: any) => void; - /** - * toogle boolean values or change for next/previous in reduced lists of values - */ - switchValue?: (direction?: SwitchValueDirection) => void; -} +export const fontSizes = [6, 8, 10, 15]; /** * Given an array and the current value it return the next posible value @@ -68,203 +48,3 @@ export function getTheUniqueValueOrNull( } return result; } - -/** - * Given a designer build NodePropertyValueModel instances for the mindplot node properties - */ -export class NodePropertyValueModelBuilder { - designer: Designer; - - fontSizeModel: NodePropertyValueModel; - selectedTopicColorModel: NodePropertyValueModel; - fontFamilyModel: NodePropertyValueModel; - fontStyleModel: NodePropertyValueModel; - borderColorModel: NodePropertyValueModel; - fontColorModel: NodePropertyValueModel; - topicShapeModel: NodePropertyValueModel; - topicIconModel: NodePropertyValueModel; - noteModel: NodePropertyValueModel; - linkModel: NodePropertyValueModel; - - /** - * - * @param designer designer to change node properties values - */ - constructor(designer: Designer) { - this.designer = designer; - } - - private selectedTopic() { - return designer.getModel().selectedTopic(); - } - - private getFontSize() { - return designer.getModel().selectedTopic()?.getFontSize(); - } - - private uniqueOrNull(propertyGetter: (Topic) => any | null) { - const nodes = designer.getModel().filterSelectedTopics(); - return getTheUniqueValueOrNull(nodes, propertyGetter); - } - - /** - * - * @returns model to and switch font weigth - */ - fontWeigthModel(): NodePropertyValueModel { - return { - getValue: () => designer.getModel().selectedTopic()?.getFontWeight(), - switchValue: () => designer.changeFontWeight(), - }; - } - - /** - * - * @returns model to and switch font size in both directions. Font sizes used to iterate: [6, 8, 10, 15] - */ - getFontSizeModel(): NodePropertyValueModel { - if (!this.fontSizeModel) - this.fontSizeModel = { - getValue: () => this.getFontSize(), - switchValue: (direction?) => { - let newValue = undefined; - if (direction === SwitchValueDirection.down) { - newValue = getPreviousValue(fontSizes, this.getFontSize()); - } - if (direction === SwitchValueDirection.up) { - newValue = getNextValue(fontSizes, this.getFontSize()); - } - designer.changeFontSize(newValue); - }, - }; - return this.fontSizeModel; - } - - /** - * - * @returns model to get and set topic color - */ - getSelectedTopicColorModel(): NodePropertyValueModel { - if (!this.selectedTopicColorModel) - this.selectedTopicColorModel = { - getValue: () => designer.getModel().selectedTopic()?.getBackgroundColor(), - setValue: (color) => designer.changeBackgroundColor(color), - }; - - return this.selectedTopicColorModel; - } - - /** - * - * @returns model to get and set the node link - */ - getLinkModel(): NodePropertyValueModel { - // const selected = this.selectedTopic(); - if (!this.linkModel) - this.linkModel = { - getValue: (): string => this.selectedTopic()?.getLinkValue(), - setValue: (value: string) => { - if (value && value.trim() !== '') { - this.selectedTopic().setLinkValue(value); - } else { - this.selectedTopic().setLinkValue(undefined); - } - }, - }; - return this.linkModel; - } - - /** - * - * @returns model to get and set topic border color - */ - getColorBorderModel(): NodePropertyValueModel { - if (!this.borderColorModel) - this.borderColorModel = { - getValue: () => this.uniqueOrNull((node) => node.getBorderColor()), - setValue: (hex: string) => designer.changeBorderColor(hex), - }; - return this.borderColorModel; - } - - /** - * - * @returns model to get and set topic font color - */ - getFontColorModel(): NodePropertyValueModel { - if (!this.fontColorModel) - this.fontColorModel = { - getValue: () => this.uniqueOrNull((node) => node.getFontColor()), - setValue: (hex: string) => designer.changeFontColor(hex), - }; - return this.fontColorModel; - } - - /** - * - * @returns model to get and set topic icon - */ - getTopicIconModel(): NodePropertyValueModel { - if (!this.topicIconModel) - this.topicIconModel = { - getValue: () => null, - setValue: (value: string) => designer.addIconType(value), - }; - return this.topicIconModel; - } - - /** - * - * @returns model to get and set topic note - */ - getNoteModel(): NodePropertyValueModel { - if (!this.noteModel) - this.noteModel = { - getValue: (): string => this.selectedTopic()?.getNoteValue(), - setValue: (value: string) => { - const note = value && value.trim() !== '' ? value : undefined; - this.selectedTopic()?.setNoteValue(note); - }, - }; - return this.noteModel; - } - - /** - * - * @returns model to get and set topic font family - */ - getFontFamilyModel(): NodePropertyValueModel { - if (!this.fontFamilyModel) - this.fontFamilyModel = { - getValue: () => this.uniqueOrNull((node) => node.getFontFamily()), - setValue: (value: string) => designer.changeFontFamily(value), - }; - return this.fontFamilyModel; - } - - /** - * - * @returns model to get and switch topic style - */ - getFontStyleModel(): NodePropertyValueModel { - if (!this.fontStyleModel) - this.fontStyleModel = { - getValue: () => this.selectedTopic()?.getFontStyle(), - switchValue: () => designer.changeFontStyle(), - }; - return this.fontStyleModel; - } - - /** - * - * @returns model to get and set topic shape - */ - getTopicShapeModel(): NodePropertyValueModel { - if (!this.topicShapeModel) - this.topicShapeModel = { - getValue: () => this.uniqueOrNull((node) => node.getShapeType()), - setValue: (value: string) => designer.changeTopicShape(value), - }; - return this.topicShapeModel; - } -} diff --git a/packages/editor/src/components/toolbar/index.ts b/packages/editor/src/components/toolbar/index.ts index 50f7758b..4df07aee 100644 --- a/packages/editor/src/components/toolbar/index.ts +++ b/packages/editor/src/components/toolbar/index.ts @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import Toolbar from './Toolbar'; import { horizontalPosition } from './ToolbarPositionInterface'; import Header from '../app-bar'; diff --git a/packages/editor/src/components/toolbar/styled.ts b/packages/editor/src/components/toolbar/styled.ts index 28167d7c..8442a34c 100644 --- a/packages/editor/src/components/toolbar/styled.ts +++ b/packages/editor/src/components/toolbar/styled.ts @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import styled from 'styled-components'; export const HeaderContainer = styled.div` diff --git a/packages/editor/src/components/toolbar/toolbarConfigurationBuilder.tsx b/packages/editor/src/components/toolbar/toolbarConfigurationBuilder.tsx index 5f0b324d..dd4e8e42 100644 --- a/packages/editor/src/components/toolbar/toolbarConfigurationBuilder.tsx +++ b/packages/editor/src/components/toolbar/toolbarConfigurationBuilder.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React from 'react'; import BrushOutlinedIcon from '@mui/icons-material/BrushOutlined'; import FontDownloadOutlinedIcon from '@mui/icons-material/FontDownloadOutlined'; @@ -35,7 +52,8 @@ import Palette from '@mui/icons-material/Square'; import SquareOutlined from '@mui/icons-material/SquareOutlined'; import { $msg, Designer } from '@wisemapping/mindplot'; import ActionConfig from '../../classes/action-config'; -import { SwitchValueDirection, NodePropertyValueModelBuilder } from './ToolbarValueModelBuilder'; +import { SwitchValueDirection } from './ToolbarValueModelBuilder'; +import NodePropertyBuilder from '../../classes/model/node-property-builder'; import Typography from '@mui/material/Typography'; import { ToolbarActionType } from '.'; import KeyboardOutlined from '@mui/icons-material/KeyboardOutlined'; @@ -59,7 +77,7 @@ export function buildToolbarCongiruation(designer: Designer): ActionConfig[] { /** * model builder */ - const toolbarValueModelBuilder = new NodePropertyValueModelBuilder(designer); + const toolbarValueModelBuilder = new NodePropertyBuilder(designer); //
Rectangle
//
Rounded Rectangle
diff --git a/packages/editor/src/index.tsx b/packages/editor/src/index.tsx index 79875c4e..2d008bee 100644 --- a/packages/editor/src/index.tsx +++ b/packages/editor/src/index.tsx @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import React from 'react'; import { diff --git a/packages/editor/src/theme/index.ts b/packages/editor/src/theme/index.ts index e439d3fb..61ad5706 100644 --- a/packages/editor/src/theme/index.ts +++ b/packages/editor/src/theme/index.ts @@ -1,3 +1,20 @@ +/* + * Copyright [2021] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { createTheme, Theme } from '@mui/material/styles'; const theme: Theme = createTheme({