From 14db85ec5a5aee0cbe074d25144816af73ab1957 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 27 Jan 2022 19:07:43 -0800 Subject: [PATCH 01/69] Fix history render --- .../src/classes/client/rest-client/index.ts | 28 +++++++++++++++++-- .../history-dialog/index.tsx | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/webapp/src/classes/client/rest-client/index.ts b/packages/webapp/src/classes/client/rest-client/index.ts index 7632ebe6..9b79a148 100644 --- a/packages/webapp/src/classes/client/rest-client/index.ts +++ b/packages/webapp/src/classes/client/rest-client/index.ts @@ -252,7 +252,7 @@ export default class RestClient implements Client { revertHistory(id: number, hid: number): Promise { const handler = (success: () => void, reject: (error: ErrorInfo) => void) => { axios - .post(`${this.baseUrl}/maps/${id}/history/${hid}`, null, { + .post(`${this.baseUrl}/c/restful/maps/${id}/history/${hid}`, null, { headers: { 'Content-Type': 'text/pain' }, }) .then(() => { @@ -267,7 +267,31 @@ export default class RestClient implements Client { } fetchHistory(id: number): Promise { - throw new Error(`Method not implemented. ${id}`); + const handler = ( + success: (historyList: ChangeHistory[]) => void, + reject: (error: ErrorInfo) => void + ) => { + axios + .get(`${this.baseUrl}/c/restful/maps/${id}/history/`, { + headers: { 'Content-Type': 'application/json' }, + }) + .then((response) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const historyList: ChangeHistory[] = (response.data.changes as any[]).map((h) => { + return { + id: h.id, + lastModificationBy: h.creator, + lastModificationTime: h.creationTime, + }; + }); + success(historyList); + }) + .catch((error) => { + const errorInfo = this.parseResponseOnError(error.response); + reject(errorInfo); + }); + }; + return new Promise(handler); } renameMap(id: number, basicInfo: BasicMapInfo): Promise { diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx index 0993ebc4..11c9ebd3 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx @@ -99,7 +99,7 @@ const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen Date: Thu, 27 Jan 2022 19:41:29 -0800 Subject: [PATCH 02/69] Remove discard button --- packages/editor/src/components/toolbar/index.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/editor/src/components/toolbar/index.tsx b/packages/editor/src/components/toolbar/index.tsx index fe9dbc56..27bdf37a 100644 --- a/packages/editor/src/components/toolbar/index.tsx +++ b/packages/editor/src/components/toolbar/index.tsx @@ -3,7 +3,6 @@ import { useIntl } from 'react-intl'; import BackIconSvg from '../../../images/back-icon.svg'; import SaveSvg from '../../../images/save.svg'; -import DiscardSvg from '../../../images/discard.svg'; import UndoSvg from '../../../images/undo.svg'; import RedoSvg from '../../../images/redo.svg'; import TopicAddSvg from '../../../images/topic-add.svg'; @@ -50,9 +49,6 @@ export default function Toolbar({
-
- -
)} {!readOnlyMode && ( From 41fd68a338740bc01ac76203c8795cbf777fff75 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 30 Jan 2022 02:37:14 -0800 Subject: [PATCH 03/69] Fix module resolution --- packages/editor/src/@types/index.d.ts | 4 + packages/editor/src/custom.d.ts | 30 ------ packages/editor/src/index.tsx | 34 ++++--- .../test/playground/map-render/js/editor.jsx | 8 +- .../playground/map-render/js/embedded.jsx | 32 +++---- .../playground/map-render/js/viewmode.jsx | 9 +- packages/editor/tsconfig.json | 25 +++-- packages/editor/webpack.common.js | 6 +- packages/mindplot/jsconfig.json | 2 - packages/mindplot/mindplot.d.ts | 12 --- packages/mindplot/package.json | 2 +- .../src/components/MultilineTextEditor.js | 5 +- packages/mindplot/src/index.ts | 2 +- packages/mindplot/src/indexLoader.ts | 2 +- packages/mindplot/tsconfig.json | 13 ++- packages/mindplot/webpack.common.js | 3 + .../action-dispatcher/export-dialog/index.tsx | 8 +- packages/webapp/src/tsconfig.json | 13 ++- yarn.lock | 96 +++++++------------ 19 files changed, 128 insertions(+), 178 deletions(-) create mode 100644 packages/editor/src/@types/index.d.ts delete mode 100644 packages/editor/src/custom.d.ts delete mode 100644 packages/mindplot/mindplot.d.ts 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({