mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 14:47:56 +01:00
Fix type problems.
This commit is contained in:
parent
926eb51405
commit
e60ed49478
1
packages/editor/src/@types/index.d.ts
vendored
1
packages/editor/src/@types/index.d.ts
vendored
@ -1,4 +1,5 @@
|
|||||||
declare module '*.svg' {
|
declare module '*.svg' {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const content: any;
|
const content: any;
|
||||||
export default content;
|
export default content;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ interface ActionConfig {
|
|||||||
/**
|
/**
|
||||||
* the event handler for a common button
|
* the event handler for a common button
|
||||||
*/
|
*/
|
||||||
onClick?: (event: object) => void;
|
onClick?: (event) => void;
|
||||||
/**
|
/**
|
||||||
* custom element for a menu entry
|
* custom element for a menu entry
|
||||||
*/
|
*/
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/rules-of-hooks */
|
||||||
/*
|
/*
|
||||||
* Copyright [2021] [wisemapping]
|
* Copyright [2021] [wisemapping]
|
||||||
*
|
*
|
||||||
@ -16,14 +17,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import {
|
import { WidgetManager, Topic } from '@wisemapping/mindplot';
|
||||||
WidgetManager,
|
|
||||||
Topic,
|
|
||||||
LinkModel,
|
|
||||||
LinkIcon,
|
|
||||||
NoteModel,
|
|
||||||
NoteIcon,
|
|
||||||
} from '@wisemapping/mindplot';
|
|
||||||
import { linkContent, noteContent } from './react-component';
|
import { linkContent, noteContent } from './react-component';
|
||||||
|
|
||||||
export class DefaultWidgetManager extends WidgetManager {
|
export class DefaultWidgetManager extends WidgetManager {
|
||||||
@ -41,8 +35,8 @@ export class DefaultWidgetManager extends WidgetManager {
|
|||||||
this.setPopoverTarget = setPopoverTarget;
|
this.setPopoverTarget = setPopoverTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
showEditorForLink(topic: Topic, linkModel: LinkModel, linkIcon: LinkIcon): void {
|
showEditorForLink(topic: Topic): void {
|
||||||
const model: any = {
|
const model = {
|
||||||
getValue: () => topic.getLinkValue(),
|
getValue: () => topic.getLinkValue(),
|
||||||
setValue: (value: string) => topic.setLinkValue(value),
|
setValue: (value: string) => topic.setLinkValue(value),
|
||||||
};
|
};
|
||||||
@ -60,13 +54,13 @@ export class DefaultWidgetManager extends WidgetManager {
|
|||||||
return this.editorContent;
|
return this.editorContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClose: (event: {}, reason: 'backdropClick' | 'escapeKeyDown') => void = () => {
|
handleClose: (event, reason: 'backdropClick' | 'escapeKeyDown') => void = () => {
|
||||||
this.setPopoverOpen(false);
|
this.setPopoverOpen(false);
|
||||||
this.editorContent = undefined;
|
this.editorContent = undefined;
|
||||||
this.setPopoverTarget(undefined);
|
this.setPopoverTarget(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
showEditorForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon) {
|
showEditorForNote(topic: Topic): void {
|
||||||
const model = {
|
const model = {
|
||||||
getValue(): string {
|
getValue(): string {
|
||||||
return topic.getNoteValue();
|
return topic.getNoteValue();
|
||||||
@ -82,7 +76,7 @@ export class DefaultWidgetManager extends WidgetManager {
|
|||||||
topic.closeEditors();
|
topic.closeEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(): [boolean, Element | undefined, DefaultWidgetManager] {
|
static useCreate(): [boolean, Element | undefined, DefaultWidgetManager] {
|
||||||
const [popoverOpen, setPopoverOpen] = useState(false);
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
||||||
const [popoverTarget, setPopoverTarget] = useState(undefined);
|
const [popoverTarget, setPopoverTarget] = useState(undefined);
|
||||||
const widgetManager = useRef(new DefaultWidgetManager(setPopoverOpen, setPopoverTarget));
|
const widgetManager = useRef(new DefaultWidgetManager(setPopoverOpen, setPopoverTarget));
|
||||||
|
@ -20,11 +20,17 @@ import TopicLink from '../../components/action-widget/pane/topic-link';
|
|||||||
import TopicNote from '../../components/action-widget/pane/topic-note';
|
import TopicNote from '../../components/action-widget/pane/topic-note';
|
||||||
import NodeProperty from '../model/node-property';
|
import NodeProperty from '../model/node-property';
|
||||||
|
|
||||||
const linkContent = (linkModel: NodeProperty, closeModal: () => void): React.ReactElement => {
|
const linkContent = (
|
||||||
|
linkModel: NodeProperty<string>,
|
||||||
|
closeModal: () => void,
|
||||||
|
): React.ReactElement => {
|
||||||
return <TopicLink closeModal={closeModal} urlModel={linkModel}></TopicLink>;
|
return <TopicLink closeModal={closeModal} urlModel={linkModel}></TopicLink>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const noteContent = (noteModel: NodeProperty, closeModal: () => void): React.ReactElement => {
|
const noteContent = (
|
||||||
|
noteModel: NodeProperty<string>,
|
||||||
|
closeModal: () => void,
|
||||||
|
): React.ReactElement => {
|
||||||
return <TopicNote closeModal={closeModal} noteModel={noteModel}></TopicNote>;
|
return <TopicNote closeModal={closeModal} noteModel={noteModel}></TopicNote>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class Events {
|
|||||||
return string.replace(/^on([A-Z])/, (_full, first) => first.toLowerCase());
|
return string.replace(/^on([A-Z])/, (_full, first) => first.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
addEvent(typeName: string, fn: any, internal?: boolean): Events {
|
addEvent(typeName: string, fn: () => void, internal?: boolean): Events {
|
||||||
const type = Events._normalizeEventName(typeName);
|
const type = Events._normalizeEventName(typeName);
|
||||||
|
|
||||||
// Add function had not been added yet
|
// Add function had not been added yet
|
||||||
@ -38,10 +38,13 @@ class Events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark reference ...
|
// Mark reference ...
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
fn.internal = Boolean(internal);
|
fn.internal = Boolean(internal);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
fireEvent(typeName: string, eventArgs?): Events {
|
fireEvent(typeName: string, eventArgs?): Events {
|
||||||
const type = Events._normalizeEventName(typeName);
|
const type = Events._normalizeEventName(typeName);
|
||||||
const events = this._handlerByType[type];
|
const events = this._handlerByType[type];
|
||||||
@ -54,9 +57,12 @@ class Events {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEvent(typeName: string, fn?): Events {
|
removeEvent(typeName: string, fn?: () => void): Events {
|
||||||
const type = Events._normalizeEventName(typeName);
|
const type = Events._normalizeEventName(typeName);
|
||||||
const events = this._handlerByType[type];
|
const events = this._handlerByType[type];
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
if (events && !fn.internal) {
|
if (events && !fn.internal) {
|
||||||
const index = events.indexOf(fn);
|
const index = events.indexOf(fn);
|
||||||
if (index !== -1) events.splice(index, 1);
|
if (index !== -1) events.splice(index, 1);
|
||||||
|
@ -20,6 +20,7 @@ import {
|
|||||||
MindplotWebComponent,
|
MindplotWebComponent,
|
||||||
PersistenceManager,
|
PersistenceManager,
|
||||||
DesignerModel,
|
DesignerModel,
|
||||||
|
WidgetManager,
|
||||||
} from '@wisemapping/mindplot';
|
} from '@wisemapping/mindplot';
|
||||||
import Capability from '../../action/capability';
|
import Capability from '../../action/capability';
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ class Editor {
|
|||||||
return this.component?.getDesigner()?.getMindmap() != null;
|
return this.component?.getDesigner()?.getMindmap() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
save(minor: boolean) {
|
save(minor: boolean): void {
|
||||||
if (!this.component) {
|
if (!this.component) {
|
||||||
throw new Error('Designer object has not been initialized.');
|
throw new Error('Designer object has not been initialized.');
|
||||||
}
|
}
|
||||||
@ -52,12 +53,16 @@ class Editor {
|
|||||||
return this.getDesigner().getModel();
|
return this.getDesigner().getModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMindmap(mapId: string, persistenceManager: PersistenceManager, widgetManager): void {
|
loadMindmap(
|
||||||
|
mapId: string,
|
||||||
|
persistenceManager: PersistenceManager,
|
||||||
|
widgetManager: WidgetManager,
|
||||||
|
): void {
|
||||||
this.component.buildDesigner(persistenceManager, widgetManager);
|
this.component.buildDesigner(persistenceManager, widgetManager);
|
||||||
this.component.loadMap(mapId);
|
this.component.loadMap(mapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEvents(canvasUpdate: (timestamp: number) => void, capability: Capability) {
|
registerEvents(canvasUpdate: (timestamp: number) => void, capability: Capability): void {
|
||||||
const designer = this.component.getDesigner();
|
const designer = this.component.getDesigner();
|
||||||
const onNodeBlurHandler = () => {
|
const onNodeBlurHandler = () => {
|
||||||
if (!designer.getModel().selectedTopic()) {
|
if (!designer.getModel().selectedTopic()) {
|
||||||
|
@ -11,16 +11,16 @@ import {
|
|||||||
class NodePropertyBuilder {
|
class NodePropertyBuilder {
|
||||||
designer: Designer;
|
designer: Designer;
|
||||||
|
|
||||||
fontSizeModel: NodeProperty;
|
fontSizeModel: NodeProperty<number>;
|
||||||
selectedTopicColorModel: NodeProperty;
|
selectedTopicColorModel: NodeProperty<string>;
|
||||||
fontFamilyModel: NodeProperty;
|
fontFamilyModel: NodeProperty<string>;
|
||||||
fontStyleModel: NodeProperty;
|
fontStyleModel: NodeProperty<string>;
|
||||||
borderColorModel: NodeProperty;
|
borderColorModel: NodeProperty<string>;
|
||||||
fontColorModel: NodeProperty;
|
fontColorModel: NodeProperty<string>;
|
||||||
topicShapeModel: NodeProperty;
|
topicShapeModel: NodeProperty<string>;
|
||||||
topicIconModel: NodeProperty;
|
topicIconModel: NodeProperty<string>;
|
||||||
noteModel: NodeProperty;
|
noteModel: NodeProperty<string>;
|
||||||
linkModel: NodeProperty;
|
linkModel: NodeProperty<string>;
|
||||||
|
|
||||||
constructor(designer: Designer) {
|
constructor(designer: Designer) {
|
||||||
this.designer = designer;
|
this.designer = designer;
|
||||||
@ -34,7 +34,7 @@ class NodePropertyBuilder {
|
|||||||
return this.designer.getModel().selectedTopic()?.getFontSize();
|
return this.designer.getModel().selectedTopic()?.getFontSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private uniqueOrNull(propertyGetter: (Topic: Topic) => any | null) {
|
private uniqueOrNull(propertyGetter: (Topic: Topic) => string | number | null) {
|
||||||
const nodes = this.designer.getModel().filterSelectedTopics();
|
const nodes = this.designer.getModel().filterSelectedTopics();
|
||||||
return getTheUniqueValueOrNull(nodes, propertyGetter);
|
return getTheUniqueValueOrNull(nodes, propertyGetter);
|
||||||
}
|
}
|
||||||
@ -43,9 +43,9 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to and switch font weigth
|
* @returns model to and switch font weigth
|
||||||
*/
|
*/
|
||||||
fontWeigthModel(): NodeProperty {
|
fontWeigthModel(): NodeProperty<string> {
|
||||||
return {
|
return {
|
||||||
getValue: () => this.designer.getModel().selectedTopic()?.getFontWeight(),
|
getValue: () => String(this.designer.getModel().selectedTopic()?.getFontWeight()),
|
||||||
switchValue: () => this.designer.changeFontWeight(),
|
switchValue: () => this.designer.changeFontWeight(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to and switch font size in both directions. Font sizes used to iterate: [6, 8, 10, 15]
|
* @returns model to and switch font size in both directions. Font sizes used to iterate: [6, 8, 10, 15]
|
||||||
*/
|
*/
|
||||||
getFontSizeModel(): NodeProperty {
|
getFontSizeModel(): NodeProperty<number> {
|
||||||
if (!this.fontSizeModel)
|
if (!this.fontSizeModel)
|
||||||
this.fontSizeModel = {
|
this.fontSizeModel = {
|
||||||
getValue: () => this.getFontSize(),
|
getValue: () => this.getFontSize(),
|
||||||
@ -76,7 +76,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set topic color
|
* @returns model to get and set topic color
|
||||||
*/
|
*/
|
||||||
getSelectedTopicColorModel(): NodeProperty {
|
getSelectedTopicColorModel(): NodeProperty<string> {
|
||||||
if (!this.selectedTopicColorModel)
|
if (!this.selectedTopicColorModel)
|
||||||
this.selectedTopicColorModel = {
|
this.selectedTopicColorModel = {
|
||||||
getValue: () => this.designer.getModel().selectedTopic()?.getBackgroundColor(),
|
getValue: () => this.designer.getModel().selectedTopic()?.getBackgroundColor(),
|
||||||
@ -90,7 +90,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set the node link
|
* @returns model to get and set the node link
|
||||||
*/
|
*/
|
||||||
getLinkModel(): NodeProperty {
|
getLinkModel(): NodeProperty<string> {
|
||||||
// const selected = this.selectedTopic();
|
// const selected = this.selectedTopic();
|
||||||
if (!this.linkModel)
|
if (!this.linkModel)
|
||||||
this.linkModel = {
|
this.linkModel = {
|
||||||
@ -110,7 +110,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set topic border color
|
* @returns model to get and set topic border color
|
||||||
*/
|
*/
|
||||||
getColorBorderModel(): NodeProperty {
|
getColorBorderModel(): NodeProperty<string> {
|
||||||
if (!this.borderColorModel)
|
if (!this.borderColorModel)
|
||||||
this.borderColorModel = {
|
this.borderColorModel = {
|
||||||
getValue: () => this.uniqueOrNull((node) => node.getBorderColor()),
|
getValue: () => this.uniqueOrNull((node) => node.getBorderColor()),
|
||||||
@ -123,7 +123,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set topic font color
|
* @returns model to get and set topic font color
|
||||||
*/
|
*/
|
||||||
getFontColorModel(): NodeProperty {
|
getFontColorModel(): NodeProperty<string> {
|
||||||
if (!this.fontColorModel)
|
if (!this.fontColorModel)
|
||||||
this.fontColorModel = {
|
this.fontColorModel = {
|
||||||
getValue: () => this.uniqueOrNull((node) => node.getFontColor()),
|
getValue: () => this.uniqueOrNull((node) => node.getFontColor()),
|
||||||
@ -136,7 +136,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set topic icon
|
* @returns model to get and set topic icon
|
||||||
*/
|
*/
|
||||||
getTopicIconModel(): NodeProperty {
|
getTopicIconModel(): NodeProperty<string> {
|
||||||
if (!this.topicIconModel)
|
if (!this.topicIconModel)
|
||||||
this.topicIconModel = {
|
this.topicIconModel = {
|
||||||
getValue: () => null,
|
getValue: () => null,
|
||||||
@ -152,7 +152,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set topic note
|
* @returns model to get and set topic note
|
||||||
*/
|
*/
|
||||||
getNoteModel(): NodeProperty {
|
getNoteModel(): NodeProperty<string> {
|
||||||
if (!this.noteModel)
|
if (!this.noteModel)
|
||||||
this.noteModel = {
|
this.noteModel = {
|
||||||
getValue: (): string => this.selectedTopic()?.getNoteValue(),
|
getValue: (): string => this.selectedTopic()?.getNoteValue(),
|
||||||
@ -168,7 +168,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set topic font family
|
* @returns model to get and set topic font family
|
||||||
*/
|
*/
|
||||||
getFontFamilyModel(): NodeProperty {
|
getFontFamilyModel(): NodeProperty<string> {
|
||||||
if (!this.fontFamilyModel)
|
if (!this.fontFamilyModel)
|
||||||
this.fontFamilyModel = {
|
this.fontFamilyModel = {
|
||||||
getValue: () => this.uniqueOrNull((node) => node.getFontFamily()),
|
getValue: () => this.uniqueOrNull((node) => node.getFontFamily()),
|
||||||
@ -181,7 +181,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and switch topic style
|
* @returns model to get and switch topic style
|
||||||
*/
|
*/
|
||||||
getFontStyleModel(): NodeProperty {
|
getFontStyleModel(): NodeProperty<string> {
|
||||||
if (!this.fontStyleModel)
|
if (!this.fontStyleModel)
|
||||||
this.fontStyleModel = {
|
this.fontStyleModel = {
|
||||||
getValue: () => this.selectedTopic()?.getFontStyle(),
|
getValue: () => this.selectedTopic()?.getFontStyle(),
|
||||||
@ -194,7 +194,7 @@ class NodePropertyBuilder {
|
|||||||
*
|
*
|
||||||
* @returns model to get and set topic shape
|
* @returns model to get and set topic shape
|
||||||
*/
|
*/
|
||||||
getTopicShapeModel(): NodeProperty {
|
getTopicShapeModel(): NodeProperty<string> {
|
||||||
if (!this.topicShapeModel)
|
if (!this.topicShapeModel)
|
||||||
this.topicShapeModel = {
|
this.topicShapeModel = {
|
||||||
getValue: () => this.uniqueOrNull((node) => node.getShapeType()),
|
getValue: () => this.uniqueOrNull((node) => node.getShapeType()),
|
||||||
|
@ -4,15 +4,15 @@ import { SwitchValueDirection } from '../../../components/toolbar/ToolbarValueMo
|
|||||||
* Interface to get and set a property of the mindplot selected node
|
* Interface to get and set a property of the mindplot selected node
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface NodeProperty {
|
interface NodeProperty<Type> {
|
||||||
/**
|
/**
|
||||||
* get the property value
|
* get the property value
|
||||||
*/
|
*/
|
||||||
getValue: () => any;
|
getValue: () => Type;
|
||||||
/**
|
/**
|
||||||
* set the property value
|
* set the property value
|
||||||
*/
|
*/
|
||||||
setValue?: (value: any) => void;
|
setValue?: (value: Type) => void;
|
||||||
/**
|
/**
|
||||||
* toogle boolean values or change for next/previous in reduced lists of values
|
* toogle boolean values or change for next/previous in reduced lists of values
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React, { ReactElement } from 'react';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import FormControl from '@mui/material/FormControl';
|
import FormControl from '@mui/material/FormControl';
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
import MenuItem from '@mui/material/MenuItem';
|
||||||
@ -27,7 +27,7 @@ import NodeProperty from '../../../../classes/model/node-property';
|
|||||||
/**
|
/**
|
||||||
* Font family selector for editor toolbar
|
* Font family selector for editor toolbar
|
||||||
*/
|
*/
|
||||||
const FontFamilySelect = (props: { fontFamilyModel: NodeProperty }) => {
|
const FontFamilySelect = (props: { fontFamilyModel: NodeProperty<string> }): ReactElement => {
|
||||||
const [font, setFont] = React.useState(props.fontFamilyModel.getValue());
|
const [font, setFont] = React.useState(props.fontFamilyModel.getValue());
|
||||||
|
|
||||||
const handleChange = (event: SelectChangeEvent) => {
|
const handleChange = (event: SelectChangeEvent) => {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { ReactElement, useEffect, useState } from 'react';
|
||||||
import ActionConfig from '../../../../classes/action/action-config';
|
import ActionConfig from '../../../../classes/action/action-config';
|
||||||
import Editor from '../../../../classes/model/editor';
|
import Editor from '../../../../classes/model/editor';
|
||||||
import { ToolbarMenuItem } from '../../../toolbar';
|
import { ToolbarMenuItem } from '../../../toolbar';
|
||||||
@ -26,12 +26,12 @@ type UndoAndRedo = {
|
|||||||
model: Editor;
|
model: Editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
const UndoAndRedo = ({ configuration, disabledCondition, model }: UndoAndRedo) => {
|
const UndoAndRedo = ({ configuration, disabledCondition, model }: UndoAndRedo): ReactElement => {
|
||||||
const [disabled, setDisabled] = useState(true);
|
const [disabled, setDisabled] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (model?.isMapLoadded()) {
|
if (model?.isMapLoadded()) {
|
||||||
const handleUpdate: any = (event) => {
|
const handleUpdate = (event) => {
|
||||||
const isDisabled = disabledCondition(event);
|
const isDisabled = disabledCondition(event);
|
||||||
setDisabled(!isDisabled);
|
setDisabled(!isDisabled);
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@ import colors from './colors.json';
|
|||||||
/**
|
/**
|
||||||
* Color picker for toolbar
|
* Color picker for toolbar
|
||||||
*/
|
*/
|
||||||
const ColorPicker = (props: { closeModal: () => void; colorModel: NodeProperty }): ReactElement => {
|
const ColorPicker = (props: {
|
||||||
|
closeModal: () => void;
|
||||||
|
colorModel: NodeProperty<string>;
|
||||||
|
}): ReactElement => {
|
||||||
return (
|
return (
|
||||||
<Box component="div" sx={{ m: 2 }}>
|
<Box component="div" sx={{ m: 2 }}>
|
||||||
<ReactColorPicker
|
<ReactColorPicker
|
||||||
|
@ -5,15 +5,15 @@ import { SvgImageIcon } from '@wisemapping/mindplot';
|
|||||||
import NodeProperty from '../../../../../classes/model/node-property';
|
import NodeProperty from '../../../../../classes/model/node-property';
|
||||||
|
|
||||||
type IconImageTab = {
|
type IconImageTab = {
|
||||||
iconModel: NodeProperty;
|
iconModel: NodeProperty<string>;
|
||||||
triggerClose: () => void;
|
triggerClose: () => void;
|
||||||
};
|
};
|
||||||
const IconImageTab = ({ iconModel, triggerClose }: IconImageTab): ReactElement => {
|
const IconImageTab = ({ iconModel, triggerClose }: IconImageTab): ReactElement => {
|
||||||
return (
|
return (
|
||||||
<Box sx={{ width: '350px' }}>
|
<Box sx={{ width: '350px' }}>
|
||||||
{iconGroups.map((family) => (
|
{iconGroups.map((family, i) => (
|
||||||
<span>
|
<span key={i}>
|
||||||
{family.icons.map((icon) => (
|
{family.icons.map((icon: string) => (
|
||||||
<img
|
<img
|
||||||
className="panelIcon"
|
className="panelIcon"
|
||||||
key={icon}
|
key={icon}
|
||||||
|
@ -26,7 +26,7 @@ import FormControlLabel from '@mui/material/FormControlLabel';
|
|||||||
|
|
||||||
type IconPickerProp = {
|
type IconPickerProp = {
|
||||||
triggerClose: () => void;
|
triggerClose: () => void;
|
||||||
iconModel: NodeProperty;
|
iconModel: NodeProperty<string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const IconPicker = ({ triggerClose, iconModel }: IconPickerProp): ReactElement => {
|
const IconPicker = ({ triggerClose, iconModel }: IconPickerProp): ReactElement => {
|
||||||
|
@ -24,7 +24,7 @@ import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined
|
|||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
const SaveAndDelete = (props: {
|
const SaveAndDelete = (props: {
|
||||||
model: NodeProperty;
|
model: NodeProperty<string>;
|
||||||
closeModal: () => void;
|
closeModal: () => void;
|
||||||
submitHandler: () => void;
|
submitHandler: () => void;
|
||||||
}): ReactElement => {
|
}): ReactElement => {
|
||||||
|
@ -29,8 +29,11 @@ import { useIntl } from 'react-intl';
|
|||||||
/**
|
/**
|
||||||
* Url form for toolbar and node contextual editor
|
* Url form for toolbar and node contextual editor
|
||||||
*/
|
*/
|
||||||
const TopicLink = (props: { closeModal: () => void; urlModel: NodeProperty }): ReactElement => {
|
const TopicLink = (props: {
|
||||||
const [url, setUrl] = useState(props.urlModel.getValue());
|
closeModal: () => void;
|
||||||
|
urlModel: NodeProperty<string>;
|
||||||
|
}): ReactElement => {
|
||||||
|
const [url, setUrl] = useState<string>(props.urlModel.getValue());
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const submitHandler = () => {
|
const submitHandler = () => {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import React, { useState } from 'react';
|
import React, { ReactElement, useState } from 'react';
|
||||||
import NodeProperty from '../../../../classes/model/node-property';
|
import NodeProperty from '../../../../classes/model/node-property';
|
||||||
import Input from '../../input';
|
import Input from '../../input';
|
||||||
import SaveAndDelete from '../save-and-delete';
|
import SaveAndDelete from '../save-and-delete';
|
||||||
@ -25,7 +25,10 @@ import { useIntl } from 'react-intl';
|
|||||||
/**
|
/**
|
||||||
* Note form for toolbar and node contextual editor
|
* Note form for toolbar and node contextual editor
|
||||||
*/
|
*/
|
||||||
const TopicNote = (props: { closeModal: () => void; noteModel: NodeProperty | null }) => {
|
const TopicNote = (props: {
|
||||||
|
closeModal: () => void;
|
||||||
|
noteModel: NodeProperty<string> | null;
|
||||||
|
}): ReactElement => {
|
||||||
const [note, setNote] = useState(props.noteModel.getValue());
|
const [note, setNote] = useState(props.noteModel.getValue());
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React, { ReactElement, ReactElement, useEffect, useState } from 'react';
|
import React, { ReactElement, useEffect, useState } from 'react';
|
||||||
import MaterialToolbar from '@mui/material/Toolbar';
|
import MaterialToolbar from '@mui/material/Toolbar';
|
||||||
import MaterialAppBar from '@mui/material/AppBar';
|
import MaterialAppBar from '@mui/material/AppBar';
|
||||||
import { ToolbarMenuItem } from '../toolbar';
|
import { ToolbarMenuItem } from '../toolbar';
|
||||||
|
@ -44,16 +44,16 @@ import TopicNote from '../action-widget/pane/topic-note';
|
|||||||
import IconPicker from '../action-widget/pane/icon-picker';
|
import IconPicker from '../action-widget/pane/icon-picker';
|
||||||
import FontFamilySelector from '../action-widget/button/font-family-selector';
|
import FontFamilySelector from '../action-widget/button/font-family-selector';
|
||||||
import Editor from '../../classes/model/editor';
|
import Editor from '../../classes/model/editor';
|
||||||
import { useIntl } from 'react-intl';
|
import { IntlShape } from 'react-intl';
|
||||||
|
|
||||||
const keyTooltip = (msg: string, key: string): string => {
|
const keyTooltip = (msg: string, key: string): string => {
|
||||||
const isMac = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
const isMac = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
||||||
return `${msg} (${isMac ? '⌘' : 'Ctrl'} + ${key})`;
|
return `${msg} (${isMac ? '⌘' : 'Ctrl'} + ${key})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function buildEditorPanelConfig(model: Editor): ActionConfig[] {
|
export function buildEditorPanelConfig(model: Editor, intl: IntlShape): ActionConfig[] {
|
||||||
const toolbarValueModelBuilder = new NodePropertyValueModelBuilder(model.getDesigner());
|
const toolbarValueModelBuilder = new NodePropertyValueModelBuilder(model.getDesigner());
|
||||||
const intl = useIntl();
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const colorAndShapeToolbarConfiguration: ActionConfig = {
|
const colorAndShapeToolbarConfiguration: ActionConfig = {
|
||||||
icon: <BrushOutlinedIcon />,
|
icon: <BrushOutlinedIcon />,
|
||||||
tooltip: intl.formatMessage({
|
tooltip: intl.formatMessage({
|
||||||
@ -102,7 +102,7 @@ export function buildEditorPanelConfig(model: Editor): ActionConfig[] {
|
|||||||
{
|
{
|
||||||
icon: () => (
|
icon: () => (
|
||||||
<Palette
|
<Palette
|
||||||
htmlColor={toolbarValueModelBuilder.getSelectedTopicColorModel().getValue()}
|
htmlColor={toolbarValueModelBuilder.getSelectedTopicColorModel().getValue() as string}
|
||||||
></Palette>
|
></Palette>
|
||||||
),
|
),
|
||||||
tooltip: intl.formatMessage({
|
tooltip: intl.formatMessage({
|
||||||
@ -125,7 +125,7 @@ export function buildEditorPanelConfig(model: Editor): ActionConfig[] {
|
|||||||
{
|
{
|
||||||
icon: () => (
|
icon: () => (
|
||||||
<SquareOutlined
|
<SquareOutlined
|
||||||
htmlColor={toolbarValueModelBuilder.getColorBorderModel().getValue()}
|
htmlColor={toolbarValueModelBuilder.getColorBorderModel().getValue() as string}
|
||||||
></SquareOutlined>
|
></SquareOutlined>
|
||||||
),
|
),
|
||||||
tooltip: intl.formatMessage({
|
tooltip: intl.formatMessage({
|
||||||
@ -210,7 +210,7 @@ export function buildEditorPanelConfig(model: Editor): ActionConfig[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: () => (
|
icon: () => (
|
||||||
<Palette htmlColor={toolbarValueModelBuilder.getFontColorModel().getValue()}></Palette>
|
<Palette htmlColor={toolbarValueModelBuilder.getFontColorModel().getValue() as string} />
|
||||||
),
|
),
|
||||||
tooltip: intl.formatMessage({
|
tooltip: intl.formatMessage({
|
||||||
id: 'editor-panel.tooltip-topic-font-color',
|
id: 'editor-panel.tooltip-topic-font-color',
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React, { ReactElement } from 'react';
|
import React, { ReactElement } from 'react';
|
||||||
|
import { useIntl } from 'react-intl';
|
||||||
import ActionConfig from '../../classes/action/action-config';
|
import ActionConfig from '../../classes/action/action-config';
|
||||||
import Capability from '../../classes/action/capability';
|
import Capability from '../../classes/action/capability';
|
||||||
import Model from '../../classes/model/editor';
|
import Model from '../../classes/model/editor';
|
||||||
@ -29,9 +30,10 @@ type EditorToolbarProps = {
|
|||||||
|
|
||||||
const EditorToolbar = ({ model, capability }: EditorToolbarProps): ReactElement => {
|
const EditorToolbar = ({ model, capability }: EditorToolbarProps): ReactElement => {
|
||||||
let config: ActionConfig[] | undefined;
|
let config: ActionConfig[] | undefined;
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
if (!capability.isHidden('edition-toolbar') && model?.isMapLoadded()) {
|
if (!capability.isHidden('edition-toolbar') && model?.isMapLoadded()) {
|
||||||
config = buildEditorPanelConfig(model);
|
config = buildEditorPanelConfig(model, intl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <span>{config ? <Toolbar configurations={config} /> : <></>}</span>;
|
return <span>{config ? <Toolbar configurations={config} /> : <></>}</span>;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { ReactElement, useCallback, useEffect, useState } from 'react';
|
||||||
import Popover from '@mui/material/Popover';
|
import Popover from '@mui/material/Popover';
|
||||||
import Model from '../classes/model/editor';
|
import Model from '../classes/model/editor';
|
||||||
|
|
||||||
@ -30,6 +30,7 @@ import {
|
|||||||
|
|
||||||
import I18nMsg from '../classes/i18n-msg';
|
import I18nMsg from '../classes/i18n-msg';
|
||||||
import { theme as defaultEditorTheme } from '../theme';
|
import { theme as defaultEditorTheme } from '../theme';
|
||||||
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import ThemeProvider from '@mui/material/styles/ThemeProvider';
|
import ThemeProvider from '@mui/material/styles/ThemeProvider';
|
||||||
import { Theme } from '@mui/material/styles';
|
import { Theme } from '@mui/material/styles';
|
||||||
import { Notifier } from './warning-dialog/styled';
|
import { Notifier } from './warning-dialog/styled';
|
||||||
@ -65,13 +66,14 @@ const Editor = ({
|
|||||||
onAction,
|
onAction,
|
||||||
theme,
|
theme,
|
||||||
accountConfiguration,
|
accountConfiguration,
|
||||||
}: EditorProps) => {
|
}: EditorProps): ReactElement => {
|
||||||
const [model, setModel] = useState<Model | undefined>();
|
const [model, setModel] = useState<Model | undefined>();
|
||||||
|
|
||||||
// This is required to redraw in case of chansges in the canvas...
|
// This is required to redraw in case of chansges in the canvas...
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const [canvasUpdate, setCanvasUpdate] = useState<number>();
|
const [canvasUpdate, setCanvasUpdate] = useState<number>();
|
||||||
const editorTheme: Theme = theme ? theme : defaultEditorTheme;
|
const editorTheme: Theme = theme ? theme : defaultEditorTheme;
|
||||||
const [popoverOpen, popoverTarget, widgetManager] = DefaultWidgetManager.create();
|
const [popoverOpen, popoverTarget, widgetManager] = DefaultWidgetManager.useCreate();
|
||||||
const capability = new Capability(options.mode, mapInfo.isLocked());
|
const capability = new Capability(options.mode, mapInfo.isLocked());
|
||||||
|
|
||||||
const mindplotRef = useCallback((component: MindplotWebComponent) => {
|
const mindplotRef = useCallback((component: MindplotWebComponent) => {
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
import KeyboardOutlined from '@mui/icons-material/KeyboardOutlined';
|
import KeyboardOutlined from '@mui/icons-material/KeyboardOutlined';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import React from 'react';
|
import React, { ReactElement } from 'react';
|
||||||
import { useIntl } from 'react-intl';
|
import { IntlShape, useIntl } from 'react-intl';
|
||||||
import ActionConfig from '../../classes/action/action-config';
|
import ActionConfig from '../../classes/action/action-config';
|
||||||
import Capability from '../../classes/action/capability';
|
import Capability from '../../classes/action/capability';
|
||||||
import Editor from '../../classes/model/editor';
|
import Editor from '../../classes/model/editor';
|
||||||
@ -30,9 +30,11 @@ import ZoomInOutlinedIcon from '@mui/icons-material/ZoomInOutlined';
|
|||||||
import CenterFocusStrongOutlinedIcon from '@mui/icons-material/CenterFocusStrongOutlined';
|
import CenterFocusStrongOutlinedIcon from '@mui/icons-material/CenterFocusStrongOutlined';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
|
|
||||||
export function buildZoomToolbarConfig(model: Editor, capability: Capability): ActionConfig[] {
|
export function buildZoomToolbarConfig(
|
||||||
const intl = useIntl();
|
model: Editor,
|
||||||
|
capability: Capability,
|
||||||
|
intl: IntlShape,
|
||||||
|
): ActionConfig[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
icon: <CenterFocusStrongOutlinedIcon />,
|
icon: <CenterFocusStrongOutlinedIcon />,
|
||||||
@ -99,8 +101,9 @@ type ZoomPanelProps = {
|
|||||||
capability: Capability;
|
capability: Capability;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ZoomPanel = ({ model, capability }: ZoomPanelProps) => {
|
const ZoomPanel = ({ model, capability }: ZoomPanelProps): ReactElement => {
|
||||||
const config = buildZoomToolbarConfig(model, capability);
|
const intl = useIntl();
|
||||||
|
const config = buildZoomToolbarConfig(model, capability, intl);
|
||||||
return (
|
return (
|
||||||
<Toolbar
|
<Toolbar
|
||||||
configurations={config}
|
configurations={config}
|
||||||
|
Loading…
Reference in New Issue
Block a user