2022-10-09 21:33:26 -07:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2022-10-06 22:16:21 -07:00
|
|
|
import React from 'react';
|
2022-10-05 21:54:23 +00:00
|
|
|
import BrushOutlinedIcon from '@mui/icons-material/BrushOutlined';
|
|
|
|
import FontDownloadOutlinedIcon from '@mui/icons-material/FontDownloadOutlined';
|
|
|
|
import TextIncreaseOutlinedIcon from '@mui/icons-material/TextIncreaseOutlined';
|
|
|
|
import TextDecreaseOutlinedIcon from '@mui/icons-material/TextDecreaseOutlined';
|
|
|
|
import FormatBoldOutlinedIcon from '@mui/icons-material/FormatBoldOutlined';
|
|
|
|
import SettingsEthernetIcon from '@mui/icons-material/SettingsEthernet';
|
|
|
|
import FormatItalicIcon from '@mui/icons-material/FormatItalic';
|
|
|
|
import NoteOutlinedIcon from '@mui/icons-material/NoteOutlined';
|
|
|
|
import LinkOutlinedIcon from '@mui/icons-material/LinkOutlined';
|
|
|
|
import SentimentSatisfiedAltIcon from '@mui/icons-material/SentimentSatisfiedAlt';
|
|
|
|
import CircleOutlinedIcon from '@mui/icons-material/CircleOutlined';
|
|
|
|
import SquareOutlinedIcon from '@mui/icons-material/SquareOutlined';
|
|
|
|
import CheckBoxOutlineBlankOutlinedIcon from '@mui/icons-material/CheckBoxOutlineBlankOutlined';
|
|
|
|
import HorizontalRuleOutlinedIcon from '@mui/icons-material/HorizontalRuleOutlined';
|
|
|
|
import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
|
|
|
|
import AddCircleOutlineOutlinedIcon from '@mui/icons-material/AddCircleOutlineOutlined';
|
|
|
|
|
|
|
|
import Palette from '@mui/icons-material/Square';
|
|
|
|
import SquareOutlined from '@mui/icons-material/SquareOutlined';
|
2022-10-23 08:18:41 -07:00
|
|
|
import ActionConfig from '../../classes/action/action-config';
|
|
|
|
import { SwitchValueDirection } from '../toolbar/ToolbarValueModelBuilder';
|
|
|
|
import NodePropertyValueModelBuilder from '../../classes/model/node-property-builder';
|
|
|
|
import ColorPicker from '../action-widget/pane/color-picker';
|
|
|
|
import TopicLink from '../action-widget/pane/topic-link';
|
|
|
|
import TopicNote from '../action-widget/pane/topic-note';
|
|
|
|
import IconPicker from '../action-widget/pane/icon-picker';
|
|
|
|
import FontFamilySelector from '../action-widget/button/font-family-selector';
|
|
|
|
import Editor from '../../classes/model/editor';
|
2022-11-02 19:56:37 -07:00
|
|
|
import { IntlShape } from 'react-intl';
|
2022-10-23 00:15:44 -07:00
|
|
|
|
|
|
|
const keyTooltip = (msg: string, key: string): string => {
|
|
|
|
const isMac = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
|
|
return `${msg} (${isMac ? '⌘' : 'Ctrl'} + ${key})`;
|
|
|
|
};
|
2022-10-05 21:54:23 +00:00
|
|
|
|
2022-11-02 19:56:37 -07:00
|
|
|
export function buildEditorPanelConfig(model: Editor, intl: IntlShape): ActionConfig[] {
|
2022-10-09 21:06:57 -07:00
|
|
|
const toolbarValueModelBuilder = new NodePropertyValueModelBuilder(model.getDesigner());
|
2022-11-02 19:56:37 -07:00
|
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
2022-10-06 20:30:27 -07:00
|
|
|
const colorAndShapeToolbarConfiguration: ActionConfig = {
|
2022-10-05 21:54:23 +00:00
|
|
|
icon: <BrushOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-style',
|
|
|
|
defaultMessage: 'Topic Style',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
icon: <SquareOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
2022-10-31 08:32:51 -07:00
|
|
|
id: 'editor-panel.tooltip-topic-share-rectangle',
|
|
|
|
defaultMessage: 'Rectangle shape',
|
2022-10-23 00:15:44 -07:00
|
|
|
}),
|
2022-10-31 08:32:51 -07:00
|
|
|
onClick: () => toolbarValueModelBuilder.getTopicShapeModel().setValue('rectangle'),
|
|
|
|
selected: () => toolbarValueModelBuilder.getTopicShapeModel().getValue() === 'rectangle',
|
2022-10-05 21:54:23 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: <CheckBoxOutlineBlankOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-share-rounded',
|
|
|
|
defaultMessage: 'Rounded shape',
|
|
|
|
}),
|
2022-10-31 08:32:51 -07:00
|
|
|
onClick: () => toolbarValueModelBuilder.getTopicShapeModel().setValue('rounded rectangle'),
|
2022-10-05 21:54:23 +00:00
|
|
|
selected: () =>
|
2022-10-31 08:32:51 -07:00
|
|
|
toolbarValueModelBuilder.getTopicShapeModel().getValue() === 'rounded rectangle',
|
2022-10-05 21:54:23 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: <HorizontalRuleOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-share-line',
|
|
|
|
defaultMessage: 'Line shape',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
onClick: () => toolbarValueModelBuilder.getTopicShapeModel().setValue('line'),
|
|
|
|
selected: () => toolbarValueModelBuilder.getTopicShapeModel().getValue() === 'line',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: <CircleOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-share-ellipse',
|
|
|
|
defaultMessage: 'Ellipse shape',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
onClick: () => toolbarValueModelBuilder.getTopicShapeModel().setValue('elipse'),
|
|
|
|
selected: () => toolbarValueModelBuilder.getTopicShapeModel().getValue() === 'elipse',
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
{
|
|
|
|
icon: () => (
|
|
|
|
<Palette
|
2022-11-02 19:56:37 -07:00
|
|
|
htmlColor={toolbarValueModelBuilder.getSelectedTopicColorModel().getValue() as string}
|
2022-10-05 21:54:23 +00:00
|
|
|
></Palette>
|
|
|
|
),
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-fill-color',
|
|
|
|
defaultMessage: 'Fill color',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
render: (closeModal) => {
|
|
|
|
return (
|
|
|
|
<ColorPicker
|
|
|
|
closeModal={closeModal}
|
|
|
|
colorModel={toolbarValueModelBuilder.getSelectedTopicColorModel()}
|
|
|
|
></ColorPicker>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: () => (
|
|
|
|
<SquareOutlined
|
2022-11-02 19:56:37 -07:00
|
|
|
htmlColor={toolbarValueModelBuilder.getColorBorderModel().getValue() as string}
|
2022-10-05 21:54:23 +00:00
|
|
|
></SquareOutlined>
|
|
|
|
),
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-border-color',
|
|
|
|
defaultMessage: 'Border color',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
render: (closeModal) => {
|
|
|
|
return (
|
|
|
|
<ColorPicker
|
|
|
|
closeModal={closeModal}
|
|
|
|
colorModel={toolbarValueModelBuilder.getColorBorderModel()}
|
|
|
|
></ColorPicker>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-10-31 05:17:01 +00:00
|
|
|
disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* submenu to manipulate node font
|
|
|
|
*/
|
2022-10-06 20:30:27 -07:00
|
|
|
const fontFormatToolbarConfiguration: ActionConfig = {
|
2022-10-05 21:54:23 +00:00
|
|
|
icon: <FontDownloadOutlinedIcon></FontDownloadOutlinedIcon>,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-font-style',
|
|
|
|
defaultMessage: 'Font Style',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
render: () => (
|
2022-10-07 19:18:34 -07:00
|
|
|
<FontFamilySelector fontFamilyModel={toolbarValueModelBuilder.getFontFamilyModel()} />
|
2022-10-05 21:54:23 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
{
|
|
|
|
icon: <TextIncreaseOutlinedIcon></TextIncreaseOutlinedIcon>,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-font-bigger',
|
|
|
|
defaultMessage: 'Bigger',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
onClick: () =>
|
|
|
|
toolbarValueModelBuilder.getFontSizeModel().switchValue(SwitchValueDirection.up),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: <TextDecreaseOutlinedIcon></TextDecreaseOutlinedIcon>,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-font-smaller',
|
|
|
|
defaultMessage: 'Smaller',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
onClick: () =>
|
|
|
|
toolbarValueModelBuilder.getFontSizeModel().switchValue(SwitchValueDirection.down),
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
{
|
|
|
|
icon: <FormatBoldOutlinedIcon></FormatBoldOutlinedIcon>,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: keyTooltip(
|
|
|
|
intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-font-bold',
|
|
|
|
defaultMessage: 'Bold',
|
|
|
|
}),
|
|
|
|
'B',
|
|
|
|
),
|
2022-10-05 21:54:23 +00:00
|
|
|
onClick: toolbarValueModelBuilder.fontWeigthModel().switchValue,
|
|
|
|
selected: () => toolbarValueModelBuilder.fontWeigthModel().getValue() === 'bold',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: <FormatItalicIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: keyTooltip(
|
|
|
|
intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-font-italic',
|
|
|
|
defaultMessage: 'Italic',
|
|
|
|
}),
|
|
|
|
'I',
|
|
|
|
),
|
2022-10-05 21:54:23 +00:00
|
|
|
onClick: toolbarValueModelBuilder.getFontStyleModel().switchValue,
|
|
|
|
selected: () => toolbarValueModelBuilder.getFontStyleModel().getValue() === 'italic',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: () => (
|
2022-11-02 19:56:37 -07:00
|
|
|
<Palette htmlColor={toolbarValueModelBuilder.getFontColorModel().getValue() as string} />
|
2022-10-05 21:54:23 +00:00
|
|
|
),
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-topic-font-color',
|
|
|
|
defaultMessage: 'Color',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
render: (closeModal) => {
|
|
|
|
return (
|
|
|
|
<ColorPicker
|
|
|
|
closeModal={closeModal}
|
|
|
|
colorModel={toolbarValueModelBuilder.getFontColorModel()}
|
|
|
|
></ColorPicker>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-10-31 05:17:01 +00:00
|
|
|
disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* button to show relation pivot
|
|
|
|
*/
|
2022-10-06 20:30:27 -07:00
|
|
|
const addRelationConfiguration: ActionConfig = {
|
2022-10-05 21:54:23 +00:00
|
|
|
icon: <SettingsEthernetIcon></SettingsEthernetIcon>,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-add-relationship',
|
|
|
|
defaultMessage: 'Add Relationship',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
onClick: (e) => {
|
2022-10-31 05:17:01 +00:00
|
|
|
model.getDesigner().showRelPivot(e);
|
2022-10-05 21:54:23 +00:00
|
|
|
},
|
2022-10-31 05:17:01 +00:00
|
|
|
disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tool for node link edition
|
|
|
|
*/
|
2022-10-06 20:30:27 -07:00
|
|
|
const editLinkUrlConfiguration: ActionConfig = {
|
2022-10-05 21:54:23 +00:00
|
|
|
icon: <LinkOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: keyTooltip(
|
|
|
|
intl.formatMessage({ id: 'editor-panel.tooltip-add-link', defaultMessage: 'Add Link' }),
|
|
|
|
'L',
|
|
|
|
),
|
2022-10-05 21:54:23 +00:00
|
|
|
useClickToClose: true,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
render: (closeModal) => (
|
2022-10-07 19:18:34 -07:00
|
|
|
<TopicLink
|
2022-10-05 21:54:23 +00:00
|
|
|
closeModal={closeModal}
|
|
|
|
urlModel={toolbarValueModelBuilder.getLinkModel()}
|
2022-10-07 19:18:34 -07:00
|
|
|
></TopicLink>
|
2022-10-05 21:54:23 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-10-31 05:17:01 +00:00
|
|
|
disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tool for node note edition
|
|
|
|
*/
|
2022-10-06 20:30:27 -07:00
|
|
|
const editNoteConfiguration: ActionConfig = {
|
2022-10-05 21:54:23 +00:00
|
|
|
icon: <NoteOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: keyTooltip(
|
|
|
|
intl.formatMessage({ id: 'editor-panel.tooltip-add-note', defaultMessage: 'Add Note' }),
|
|
|
|
'K',
|
|
|
|
),
|
2022-10-05 21:54:23 +00:00
|
|
|
useClickToClose: true,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
tooltip: 'Node note',
|
|
|
|
render: (closeModal) => (
|
2022-10-07 19:18:34 -07:00
|
|
|
<TopicNote
|
2022-10-05 21:54:23 +00:00
|
|
|
closeModal={closeModal}
|
|
|
|
noteModel={toolbarValueModelBuilder.getNoteModel()}
|
2022-10-07 19:18:34 -07:00
|
|
|
></TopicNote>
|
2022-10-05 21:54:23 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-10-31 05:17:01 +00:00
|
|
|
disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tool for emoji selection
|
|
|
|
*/
|
2022-10-06 20:30:27 -07:00
|
|
|
const editIconConfiguration: ActionConfig = {
|
2022-10-05 21:54:23 +00:00
|
|
|
icon: <SentimentSatisfiedAltIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-add-icon',
|
|
|
|
defaultMessage: 'Add Icon',
|
|
|
|
}),
|
2022-10-31 05:17:01 +00:00
|
|
|
useClickToClose: true,
|
2022-10-05 21:54:23 +00:00
|
|
|
options: [
|
|
|
|
{
|
2022-10-31 20:36:21 -07:00
|
|
|
tooltip: intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-add-icon',
|
|
|
|
defaultMessage: 'Add Icon',
|
|
|
|
}),
|
2022-10-05 21:54:23 +00:00
|
|
|
render: (closeModal) => (
|
2022-10-07 19:18:34 -07:00
|
|
|
<IconPicker
|
2022-10-31 20:36:21 -07:00
|
|
|
triggerClose={closeModal}
|
2022-10-05 21:54:23 +00:00
|
|
|
iconModel={toolbarValueModelBuilder.getTopicIconModel()}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-10-31 05:17:01 +00:00
|
|
|
disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const addNodeToolbarConfiguration = {
|
|
|
|
icon: <AddCircleOutlineOutlinedIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip:
|
|
|
|
intl.formatMessage({ id: 'editor-panel.tooltip-add-topic', defaultMessage: 'Add Topic' }) +
|
|
|
|
' (Enter)',
|
2022-10-31 05:17:01 +00:00
|
|
|
onClick: () => model.getDesigner().createSiblingForSelectedNode(),
|
|
|
|
disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
2022-10-31 05:17:01 +00:00
|
|
|
|
2022-10-05 21:54:23 +00:00
|
|
|
const deleteNodeToolbarConfiguration = {
|
|
|
|
icon: <RemoveCircleOutlineIcon />,
|
2022-10-23 00:15:44 -07:00
|
|
|
tooltip:
|
|
|
|
intl.formatMessage({
|
|
|
|
id: 'editor-panel.tooltip-delete-topic',
|
|
|
|
defaultMessage: 'Delete Topic',
|
|
|
|
}) + ' (Delete)',
|
2022-10-31 05:17:01 +00:00
|
|
|
onClick: () => model.getDesigner().deleteSelectedEntities(),
|
|
|
|
disabled: () => model.getDesigner().getModel().filterSelectedTopics().length === 0,
|
2022-10-05 21:54:23 +00:00
|
|
|
};
|
2022-10-31 05:17:01 +00:00
|
|
|
|
2022-10-05 21:54:23 +00:00
|
|
|
return [
|
|
|
|
addNodeToolbarConfiguration,
|
|
|
|
deleteNodeToolbarConfiguration,
|
|
|
|
colorAndShapeToolbarConfiguration,
|
|
|
|
fontFormatToolbarConfiguration,
|
|
|
|
editIconConfiguration,
|
|
|
|
editNoteConfiguration,
|
|
|
|
editLinkUrlConfiguration,
|
|
|
|
addRelationConfiguration,
|
|
|
|
];
|
|
|
|
}
|