diff --git a/packages/editor/src/@types/index.d.ts b/packages/editor/src/@types/index.d.ts new file mode 100644 index 00000000..79579dba --- /dev/null +++ b/packages/editor/src/@types/index.d.ts @@ -0,0 +1,4 @@ +declare module "*.svg" { + const content: any; + export default content; +} \ No newline at end of file diff --git a/packages/editor/src/custom.d.ts b/packages/editor/src/custom.d.ts deleted file mode 100644 index 61232ee5..00000000 --- a/packages/editor/src/custom.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -declare module "*.svg" { - const content: any; - export default content; -} - -declare module "@wisemapping/mindplot" { - const mindplot: { - Mindmap: any, - PersistenceManager: any, - Designer: any, - LocalStorageManager: any, - Menu: any, - DesignerBuilder: any, - RESTPersistenceManager: any, - DesignerOptionsBuilder: any, - buildDesigner: any, - $notify: any - }; - export var Mindmap: any; - export var PersistenceManager: any; - export var Designer: any; - export var LocalStorageManager: any; - export var Menu: any; - export var DesignerBuilder: any; - export var RESTPersistenceManager: any; - export var DesignerOptionsBuilder: any; - export var buildDesigner: any; - export var $notify: any; - export default mindplot; -} \ No newline at end of file diff --git a/packages/editor/src/index.tsx b/packages/editor/src/index.tsx index 3e57c7cb..102e6a67 100644 --- a/packages/editor/src/index.tsx +++ b/packages/editor/src/index.tsx @@ -2,7 +2,8 @@ import React from 'react'; import Toolbar, { ToolbarActionType } from './components/toolbar'; import Footer from './components/footer'; import { IntlProvider } from 'react-intl'; -import * as mindplot from '@wisemapping/mindplot'; +import { $notify, buildDesigner, LocalStorageManager, PersistenceManager, RESTPersistenceManager, DesignerOptionsBuilder } from '@wisemapping/mindplot'; + declare global { var memoryPersistence: boolean; var readOnly: boolean; @@ -18,7 +19,7 @@ declare global { } export type EditorPropsType = { - initCallback?: (m: typeof mindplot) => () => void; + initCallback?: () => void; mapId: number; memoryPersistence: boolean; readOnlyMode: boolean; @@ -26,15 +27,13 @@ export type EditorPropsType = { onAction: (action: ToolbarActionType) => void; }; -const initMindplot = ({ - PersistenceManager, - RESTPersistenceManager, - LocalStorageManager, - DesignerOptionsBuilder, - buildDesigner, - $notify, -}: typeof mindplot) => () => { - let persistence: typeof PersistenceManager; +const initMindplot = () => { + + // Change page title ... + document.title = `${global.mapTitle} | WiseMapping ` + + // Configure persistence manager ... + let persistence; if (!global.memoryPersistence && !global.readOnly) { persistence = new RESTPersistenceManager({ documentUrl: '/c/restful/maps/{id}/document', @@ -45,8 +44,7 @@ const initMindplot = ({ }); } else { persistence = new LocalStorageManager( - `/c/restful/maps/{id}/${global.historyId ? `${global.historyId}/` : ''}document/xml${ - !global.isAuth ? '-pub' : '' + `/c/restful/maps/{id}/${global.historyId ? `${global.historyId}/` : ''}document/xml${!global.isAuth ? '-pub' : '' }`, true ); @@ -58,9 +56,9 @@ const initMindplot = ({ const options = DesignerOptionsBuilder.buildOptions({ persistenceManager: persistence, readOnly: Boolean(global.readOnly || false), - mapId: global.mapId, + mapId: String(global.mapId), container: 'mindplot', - zoom: zoomParam || global.userOptions ? global.userOptions.zoom : 1, + zoom: zoomParam | (global.userOptions != undefined ? Number.parseFloat(global.userOptions.zoom as string) : 1), locale: global.locale, }); @@ -85,8 +83,8 @@ export default function Editor({ locale = 'en', onAction, }: EditorPropsType): React.ReactElement { - - React.useEffect(initCallback(mindplot), []); + + React.useEffect(initCallback, []); return ( @@ -101,4 +99,4 @@ export default function Editor({