From 49bd6767ff12513b5146bc1913c58a4c9b229033 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 07:35:08 -0800 Subject: [PATCH 01/21] Manage empty returns --- packages/webapp/src/components/editor-page/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webapp/src/components/editor-page/index.tsx b/packages/webapp/src/components/editor-page/index.tsx index 5e521c86..89d9306d 100644 --- a/packages/webapp/src/components/editor-page/index.tsx +++ b/packages/webapp/src/components/editor-page/index.tsx @@ -38,7 +38,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { if (fetchResult.error) { throw new Error(`User coild not be loaded: ${JSON.stringify(fetchResult.error)}`); } - result = fetchResult.map.role === 'owner' ? 'edition-owner' : 'edition-editor'; + result = fetchResult?.map?.role === 'owner' ? 'edition-owner' : 'edition-editor'; } } return result; From bf944c31692bbd4de682c891ee5423e00fab7fc2 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 12:32:54 -0800 Subject: [PATCH 02/21] Fix problem on nodes marked as collapted. --- .../mindplot/src/components/persistence/XMLSerializerTango.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mindplot/src/components/persistence/XMLSerializerTango.ts b/packages/mindplot/src/components/persistence/XMLSerializerTango.ts index b7551016..fbd98485 100644 --- a/packages/mindplot/src/components/persistence/XMLSerializerTango.ts +++ b/packages/mindplot/src/components/persistence/XMLSerializerTango.ts @@ -106,7 +106,7 @@ class XMLSerializerTango implements XMLMindmapSerializer { } } - if (topic.areChildrenShrunken() && topic.getType() !== 'CentralTopic') { + if ((topic.areChildrenShrunken() && topic.getChildren().length > 0) && topic.getType() !== 'CentralTopic') { parentTopic.setAttribute('shrink', 'true'); } From ae3db5063ba357c9447950aa58d665cb81e71589 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 12:39:15 -0800 Subject: [PATCH 03/21] Mark node as non collapsed if the last node. --- packages/mindplot/src/components/Topic.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mindplot/src/components/Topic.ts b/packages/mindplot/src/components/Topic.ts index f646ce1d..f51a4fa0 100644 --- a/packages/mindplot/src/components/Topic.ts +++ b/packages/mindplot/src/components/Topic.ts @@ -1093,6 +1093,7 @@ abstract class Topic extends NodeGraph { const connector = targetTopic.getShrinkConnector(); if ($defined(connector)) { connector.setVisibility(false); + targetTopic.isCollapsed(false); } } } From ab88adad4d1db64b661e7513831746559f5b70f9 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 18:33:46 -0800 Subject: [PATCH 04/21] Fix icon without family --- .../mindplot/assets/icons/appsgoogle_maps.svg | 21 +++++++++++++++++++ packages/mindplot/src/components/ImageIcon.js | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 packages/mindplot/assets/icons/appsgoogle_maps.svg diff --git a/packages/mindplot/assets/icons/appsgoogle_maps.svg b/packages/mindplot/assets/icons/appsgoogle_maps.svg new file mode 100644 index 00000000..774b1054 --- /dev/null +++ b/packages/mindplot/assets/icons/appsgoogle_maps.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/mindplot/src/components/ImageIcon.js b/packages/mindplot/src/components/ImageIcon.js index dfacded4..d5880742 100644 --- a/packages/mindplot/src/components/ImageIcon.js +++ b/packages/mindplot/src/components/ImageIcon.js @@ -206,7 +206,7 @@ ImageIcon.prototype.ICON_FAMILIES = [{ }, { id: 'appsgoogle', - icons: ['appsgoogle_youtube', 'appsgoogle_gmail', 'appsgoogle-maps'], + icons: ['appsgoogle_youtube', 'appsgoogle_gmail', 'appsgoogle_maps'], }, { id: 'tag', From 375ff5941c581c9a491053be522968690ac56d16 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 18:37:30 -0800 Subject: [PATCH 05/21] Add more details to error loading for users. --- .../mindplot/assets/icons/appsgoogle-maps.svg | 21 ------------------- .../src/components/editor-page/index.tsx | 2 +- 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 packages/mindplot/assets/icons/appsgoogle-maps.svg diff --git a/packages/mindplot/assets/icons/appsgoogle-maps.svg b/packages/mindplot/assets/icons/appsgoogle-maps.svg deleted file mode 100644 index 774b1054..00000000 --- a/packages/mindplot/assets/icons/appsgoogle-maps.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/webapp/src/components/editor-page/index.tsx b/packages/webapp/src/components/editor-page/index.tsx index 89d9306d..29d494a9 100644 --- a/packages/webapp/src/components/editor-page/index.tsx +++ b/packages/webapp/src/components/editor-page/index.tsx @@ -36,7 +36,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { const fetchResult = fetchMapById(mapId); if (!fetchResult.isLoading) { if (fetchResult.error) { - throw new Error(`User coild not be loaded: ${JSON.stringify(fetchResult.error)}`); + throw new Error(`User could not be loaded: ${JSON.stringify(fetchResult.error)} - ${fetchResult.error}`); } result = fetchResult?.map?.role === 'owner' ? 'edition-owner' : 'edition-editor'; } From 27f580b4fa666a1a40b324af36126e66f5233041 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 19:10:09 -0800 Subject: [PATCH 06/21] Add debug on user loading error.Add debug on user loading error.Add debug on user loading error.Add debug on user loading error.Add debug on user loading error.Add debug on user loading error.Add debug on user loading error.Add debug on user loading error.Add debug on user loading error. --- packages/webapp/src/components/editor-page/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webapp/src/components/editor-page/index.tsx b/packages/webapp/src/components/editor-page/index.tsx index 29d494a9..c21dac84 100644 --- a/packages/webapp/src/components/editor-page/index.tsx +++ b/packages/webapp/src/components/editor-page/index.tsx @@ -36,7 +36,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { const fetchResult = fetchMapById(mapId); if (!fetchResult.isLoading) { if (fetchResult.error) { - throw new Error(`User could not be loaded: ${JSON.stringify(fetchResult.error)} - ${fetchResult.error}`); + throw new Error(`User could not be loaded: ${JSON.stringify(fetchResult)}`); } result = fetchResult?.map?.role === 'owner' ? 'edition-owner' : 'edition-editor'; } From e83cd3e9fa66ad5de639a7eee1a7f4574350dc23 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 19:43:04 -0800 Subject: [PATCH 07/21] Remove relatioship on focus. --- .../mindplot/src/components/ConnectionLine.ts | 2 +- .../mindplot/src/components/Relationship.ts | 44 ++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/packages/mindplot/src/components/ConnectionLine.ts b/packages/mindplot/src/components/ConnectionLine.ts index 8edd38d6..40bdf7b3 100644 --- a/packages/mindplot/src/components/ConnectionLine.ts +++ b/packages/mindplot/src/components/ConnectionLine.ts @@ -97,7 +97,7 @@ class ConnectionLine { this._line2d.setVisibility(value, fade); } - isVisible() { + isVisible(): boolean { return this._line2d.isVisible(); } diff --git a/packages/mindplot/src/components/Relationship.ts b/packages/mindplot/src/components/Relationship.ts index 8b6cd4d7..624b67d6 100644 --- a/packages/mindplot/src/components/Relationship.ts +++ b/packages/mindplot/src/components/Relationship.ts @@ -20,8 +20,10 @@ import { Arrow, Point, ElementClass } from '@wisemapping/web2d'; import ConnectionLine from './ConnectionLine'; import ControlPoint from './ControlPoint'; import RelationshipModel from './model/RelationshipModel'; +import PositionType from './PositionType'; import Topic from './Topic'; import Shape from './util/Shape'; +import Workspace from './Workspace'; class Relationship extends ConnectionLine { private _focusShape: ElementClass; @@ -187,7 +189,7 @@ class Relationship extends ConnectionLine { this._startArrow.setVisibility(this.isVisible() && this._showStartArrow); } - addToWorkspace(workspace) { + addToWorkspace(workspace: Workspace): void { workspace.append(this._focusShape); workspace.append(this._controlPointsController); @@ -207,11 +209,11 @@ class Relationship extends ConnectionLine { this.redraw(); } - _initializeControlPointController(): void { + private _initializeControlPointController(): void { this.setOnFocus(true); } - removeFromWorkspace(workspace) { + removeFromWorkspace(workspace: Workspace): void { workspace.removeChild(this._focusShape); workspace.removeChild(this._controlPointsController); if (!workspace.isReadOnly) { @@ -243,7 +245,7 @@ class Relationship extends ConnectionLine { } } - private _refreshShape() { + private _refreshShape(): void { const sPos = this._line2d.getFrom(); const tPos = this._line2d.getTo(); const ctrlPoints = this._line2d.getControlPoints(); @@ -279,19 +281,31 @@ class Relationship extends ConnectionLine { setVisibility(value: boolean, fade = 0) { super.setVisibility(value, fade); - if (this._showEndArrow) this._endArrow.setVisibility(this._showEndArrow); + + // If visibility change, remove the on focus. + this.setOnFocus(false); + + if (this._showEndArrow) { + this._endArrow.setVisibility(this._showEndArrow); + } this._startArrow.setVisibility(this._showStartArrow && value, fade); } - setOpacity(opacity: number) { + setOpacity(opacity: number): void { super.setOpacity(opacity); - if (this._showEndArrow) this._endArrow.setOpacity(opacity); - if (this._showStartArrow) this._startArrow.setOpacity(opacity); + if (this._showEndArrow) { + this._endArrow.setOpacity(opacity); + } + if (this._showStartArrow) { + this._startArrow.setOpacity(opacity); + } } setShowEndArrow(visible: boolean) { this._showEndArrow = visible; - if (this._isInWorkspace) this.redraw(); + if (this._isInWorkspace) { + this.redraw(); + } } setShowStartArrow(visible: boolean) { @@ -315,25 +329,25 @@ class Relationship extends ConnectionLine { if (this._endArrow) this._endArrow.setFrom(x, y); } - setSrcControlPoint(control) { + setSrcControlPoint(control: PositionType): void { this._line2d.setSrcControlPoint(control); this._startArrow.setControlPoint(control); } - setDestControlPoint(control) { + setDestControlPoint(control: PositionType) { this._line2d.setDestControlPoint(control); if (this._showEndArrow) this._endArrow.setControlPoint(control); } - getControlPoints() { + getControlPoints(): PositionType { return this._line2d.getControlPoints(); } - isSrcControlPointCustom() { + isSrcControlPointCustom(): boolean { return this._line2d.isSrcControlPointCustom(); } - isDestControlPointCustom() { + isDestControlPointCustom(): boolean { return this._line2d.isDestControlPointCustom(); } @@ -345,7 +359,7 @@ class Relationship extends ConnectionLine { this._line2d.setIsDestControlPointCustom(isCustom); } - getId() { + getId(): number { return this._model.getId(); } From 5dc6fb37d78b2484aa3e1bf1d37ebd3b60acbe88 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 19:49:27 -0800 Subject: [PATCH 08/21] Add missing types to commands. --- packages/mindplot/src/components/Topic.ts | 3 --- .../commands/AddRelationshipCommand.ts | 16 +++++----------- .../src/components/commands/AddTopicCommand.ts | 7 ------- .../commands/ChangeFeatureToTopicCommand.ts | 7 ------- .../src/components/commands/DragTopicCommand.ts | 3 --- .../commands/MoveControlPointCommand.ts | 16 +++++----------- 6 files changed, 10 insertions(+), 42 deletions(-) diff --git a/packages/mindplot/src/components/Topic.ts b/packages/mindplot/src/components/Topic.ts index f51a4fa0..7e56bd3e 100644 --- a/packages/mindplot/src/components/Topic.ts +++ b/packages/mindplot/src/components/Topic.ts @@ -375,17 +375,14 @@ abstract class Topic extends NodeGraph { this.adjustShapes(); } - /** */ addRelationship(relationship: Relationship) { this._relationships.push(relationship); } - /** */ deleteRelationship(relationship: Rect) { this._relationships = this._relationships.filter((r) => r !== relationship); } - /** */ getRelationships(): Relationship[] { return this._relationships; } diff --git a/packages/mindplot/src/components/commands/AddRelationshipCommand.ts b/packages/mindplot/src/components/commands/AddRelationshipCommand.ts index f16df219..b32273d7 100644 --- a/packages/mindplot/src/components/commands/AddRelationshipCommand.ts +++ b/packages/mindplot/src/components/commands/AddRelationshipCommand.ts @@ -17,6 +17,7 @@ */ import { $assert } from '@wisemapping/core-js'; import Command from '../Command'; +import CommandContext from '../CommandContext'; import RelationshipModel from '../model/RelationshipModel'; class AddRelationshipCommand extends Command { @@ -25,27 +26,20 @@ class AddRelationshipCommand extends Command { /** * @classdesc This command class handles do/undo of adding a relationship to a topic. */ - constructor(model:RelationshipModel) { + constructor(model: RelationshipModel) { $assert(model, 'Relationship model can not be null'); super(); this._model = model; } - /** - * Overrides abstract parent method - */ - execute(commandContext) { + execute(commandContext: CommandContext) { const relationship = commandContext.addRelationship(this._model); relationship.setOnFocus(true); } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ - undoExecute(commandContext) { - const rel = commandContext.findRelationships(this._model.getId()); + undoExecute(commandContext: CommandContext) { + const rel = commandContext.findRelationships([this._model.getId()]); commandContext.deleteRelationship(rel[0]); } } diff --git a/packages/mindplot/src/components/commands/AddTopicCommand.ts b/packages/mindplot/src/components/commands/AddTopicCommand.ts index ce273552..2208a495 100644 --- a/packages/mindplot/src/components/commands/AddTopicCommand.ts +++ b/packages/mindplot/src/components/commands/AddTopicCommand.ts @@ -38,9 +38,6 @@ class AddTopicCommand extends Command { this._parentsIds = parentTopicsId; } - /** - * Overrides abstract parent method - */ execute(commandContext: CommandContext) { const me = this; this._models.forEach((model, index) => { @@ -68,10 +65,6 @@ class AddTopicCommand extends Command { }); } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ undoExecute(commandContext: CommandContext) { // Delete disconnected the nodes. Create a copy of the topics ... const clonedModel = []; diff --git a/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts b/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts index 07253e15..573a2923 100644 --- a/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts +++ b/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts @@ -37,9 +37,6 @@ class ChangeFeatureToTopicCommand extends Command { this._attributes = attributes; } - /** - * Overrides abstract parent method - */ execute(commandContext: CommandContext) { const topic = commandContext.findTopics([this._topicId])[0]; const feature = topic.findFeatureById(this._featureId); @@ -49,10 +46,6 @@ class ChangeFeatureToTopicCommand extends Command { this._attributes = oldAttributes; } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ undoExecute(commandContext: CommandContext) { this.execute(commandContext); } diff --git a/packages/mindplot/src/components/commands/DragTopicCommand.ts b/packages/mindplot/src/components/commands/DragTopicCommand.ts index d550a378..d8cf4d38 100644 --- a/packages/mindplot/src/components/commands/DragTopicCommand.ts +++ b/packages/mindplot/src/components/commands/DragTopicCommand.ts @@ -47,9 +47,6 @@ class DragTopicCommand extends Command { this._order = order; } - /** - * Overrides abstract parent method - */ execute(commandContext: CommandContext): void { const topic = commandContext.findTopics([this._topicsId])[0]; topic.setVisibility(false); diff --git a/packages/mindplot/src/components/commands/MoveControlPointCommand.ts b/packages/mindplot/src/components/commands/MoveControlPointCommand.ts index 85f9868a..2856c6e5 100644 --- a/packages/mindplot/src/components/commands/MoveControlPointCommand.ts +++ b/packages/mindplot/src/components/commands/MoveControlPointCommand.ts @@ -19,19 +19,20 @@ import { $assert, $defined } from '@wisemapping/core-js'; import { Line } from '@wisemapping/web2d'; import Command from '../Command'; import ControlPoint from '../ControlPoint'; +import PositionType from '../PositionType'; class MoveControlPointCommand extends Command { private _ctrlPointControler: ControlPoint; private _line: Line; - private _controlPoint: any; + private _controlPoint: Line; - private _oldControlPoint: any; + private _oldControlPoint: Line; - private _originalEndPoint: any; + private _originalEndPoint: PositionType; - private _wasCustom: any; + private _wasCustom: boolean; private _endPoint: any; @@ -68,9 +69,6 @@ class MoveControlPointCommand extends Command { this._point = point; } - /** - * Overrides abstract parent method - */ execute() { const model = this._line.getModel(); switch (this._point) { @@ -97,10 +95,6 @@ class MoveControlPointCommand extends Command { this._line.getLine().updateLine(this._point); } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ undoExecute() { const line = this._line; const model = line.getModel(); From 7c03d04a19924840dc28df4ac4b8005cf732fecd Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 8 Mar 2022 10:05:24 -0800 Subject: [PATCH 09/21] Improve error handling --- packages/webapp/src/redux/clientSlice.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/webapp/src/redux/clientSlice.ts b/packages/webapp/src/redux/clientSlice.ts index ef7329df..6cc61b22 100644 --- a/packages/webapp/src/redux/clientSlice.ts +++ b/packages/webapp/src/redux/clientSlice.ts @@ -47,9 +47,18 @@ export const fetchMapById = (id: number): MapLoadResult => { return client.fetchAllMaps(); }); - const result = data?.find((m) => m.id == id); - const map = result || null; - return { isLoading: isLoading, error: error, map: map }; + let errorMsg: ErrorInfo = Object.keys(error).length !== 0 ? error : null; + let map: MapInfo; + if (!isLoading) { + // Sanitize error structure ... + + // If the map can not be loaded, create an error object. + map = data?.find((m) => m.id == id); + if (map === null && !errorMsg) { + errorMsg = { msg: `Map with id ${id} could not be found. Please, reflesh the page` } + } + } + return { isLoading: isLoading, error: errorMsg, map: map }; }; export const fetchAccount = (): AccountInfo | undefined => { From d32eaf63cf59fb598c5ec4650070c361394e826d Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 8 Mar 2022 10:19:02 -0800 Subject: [PATCH 10/21] Disable local storage on embedded view --- .../src/components/LocalStorageManager.ts | 19 +++++++++++++++---- packages/webapp/src/redux/clientSlice.ts | 6 +++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/mindplot/src/components/LocalStorageManager.ts b/packages/mindplot/src/components/LocalStorageManager.ts index 6c266e56..ae35abe3 100644 --- a/packages/mindplot/src/components/LocalStorageManager.ts +++ b/packages/mindplot/src/components/LocalStorageManager.ts @@ -23,23 +23,34 @@ class LocalStorageManager extends PersistenceManager { private forceLoad: boolean; - constructor(documentUrl: string, forceLoad: boolean) { + private readOnly: boolean; + + constructor(documentUrl: string, forceLoad: boolean, readOnly = true) { super(); this.documentUrl = documentUrl; this.forceLoad = forceLoad; + this.readOnly = readOnly; } saveMapXml(mapId: string, mapDoc: Document): void { const mapXml = new XMLSerializer().serializeToString(mapDoc); - localStorage.setItem(`${mapId}-xml`, mapXml); + if (!this.readOnly) { + localStorage.setItem(`${mapId}-xml`, mapXml); + } + console.log(`Map XML to save => ${this.saveMapXml}`); } discardChanges(mapId: string) { - localStorage.removeItem(`${mapId}-xml`); + if (!this.readOnly) { + localStorage.removeItem(`${mapId}-xml`); + } } loadMapDom(mapId: string) { - let xml = localStorage.getItem(`${mapId}-xml`); + let xml; + if (!this.readOnly) { + xml = localStorage.getItem(`${mapId}-xml`); + } if (xml == null || this.forceLoad) { $.ajax({ url: this.documentUrl.replace('{id}', mapId), diff --git a/packages/webapp/src/redux/clientSlice.ts b/packages/webapp/src/redux/clientSlice.ts index 6cc61b22..1fe4f199 100644 --- a/packages/webapp/src/redux/clientSlice.ts +++ b/packages/webapp/src/redux/clientSlice.ts @@ -47,12 +47,12 @@ export const fetchMapById = (id: number): MapLoadResult => { return client.fetchAllMaps(); }); + // Sanitize error structure ... let errorMsg: ErrorInfo = Object.keys(error).length !== 0 ? error : null; + + // If the map can not be loaded, create an error object. let map: MapInfo; if (!isLoading) { - // Sanitize error structure ... - - // If the map can not be loaded, create an error object. map = data?.find((m) => m.id == id); if (map === null && !errorMsg) { errorMsg = { msg: `Map with id ${id} could not be found. Please, reflesh the page` } From 5cb09c86dd1db6eeeb25714efb3adf081fea28dd Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 8 Mar 2022 10:23:43 -0800 Subject: [PATCH 11/21] Fix NPE error --- packages/webapp/src/redux/clientSlice.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/webapp/src/redux/clientSlice.ts b/packages/webapp/src/redux/clientSlice.ts index 1fe4f199..40e45fb8 100644 --- a/packages/webapp/src/redux/clientSlice.ts +++ b/packages/webapp/src/redux/clientSlice.ts @@ -47,12 +47,15 @@ export const fetchMapById = (id: number): MapLoadResult => { return client.fetchAllMaps(); }); - // Sanitize error structure ... - let errorMsg: ErrorInfo = Object.keys(error).length !== 0 ? error : null; - // If the map can not be loaded, create an error object. let map: MapInfo; + let errorMsg: ErrorInfo; if (!isLoading) { + // Sanitize error structure ... + if (error) { + errorMsg = Object.keys(error).length !== 0 ? error : null; + } + // Seach for object... map = data?.find((m) => m.id == id); if (map === null && !errorMsg) { errorMsg = { msg: `Map with id ${id} could not be found. Please, reflesh the page` } From 926ab3ed55a316e408c4cf3e3e2d201370d1ea1c Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 8 Mar 2022 10:25:09 -0800 Subject: [PATCH 12/21] Fix error assignmenmt --- packages/webapp/src/redux/clientSlice.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webapp/src/redux/clientSlice.ts b/packages/webapp/src/redux/clientSlice.ts index 40e45fb8..b15a765b 100644 --- a/packages/webapp/src/redux/clientSlice.ts +++ b/packages/webapp/src/redux/clientSlice.ts @@ -49,10 +49,10 @@ export const fetchMapById = (id: number): MapLoadResult => { // If the map can not be loaded, create an error object. let map: MapInfo; - let errorMsg: ErrorInfo; + let errorMsg: ErrorInfo = error; if (!isLoading) { // Sanitize error structure ... - if (error) { + if (errorMsg) { errorMsg = Object.keys(error).length !== 0 ? error : null; } // Seach for object... From 259ae2d8cba5397723af4a61fc794ea5d3ba9c43 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 8 Mar 2022 10:36:41 -0800 Subject: [PATCH 13/21] Add additional debug session for nul sessions --- packages/webapp/src/classes/client/rest-client/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/webapp/src/classes/client/rest-client/index.ts b/packages/webapp/src/classes/client/rest-client/index.ts index eb7f7fa3..d68f75ae 100644 --- a/packages/webapp/src/classes/client/rest-client/index.ts +++ b/packages/webapp/src/classes/client/rest-client/index.ts @@ -615,8 +615,14 @@ export default class RestClient implements Client { if (this.persistenceManager) { return this.persistenceManager; } + let persistence: PersistenceManager; if (editorMode === 'edition-owner' || editorMode === 'edition-editor') { + + if (!global.lockSession) { + throw new Error(`Session could not be found: global.lockSession ${global.lockSession} - global.lockTimestamp: ${global.lockTimestamp} - ${global.mindmapLocked} - ${global.mindmapLockedMsg}`) + } + persistence = new RESTPersistenceManager({ documentUrl: '/c/restful/maps/{id}/document', revertUrl: '/c/restful/maps/{id}/history/latest', From 748c1aa45fd1cc1f6d0e7dc1117b94b7f544fb73 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 8 Mar 2022 11:03:45 -0800 Subject: [PATCH 14/21] Improve message. --- packages/webapp/src/components/editor-page/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webapp/src/components/editor-page/index.tsx b/packages/webapp/src/components/editor-page/index.tsx index c21dac84..c3a1b00d 100644 --- a/packages/webapp/src/components/editor-page/index.tsx +++ b/packages/webapp/src/components/editor-page/index.tsx @@ -36,7 +36,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { const fetchResult = fetchMapById(mapId); if (!fetchResult.isLoading) { if (fetchResult.error) { - throw new Error(`User could not be loaded: ${JSON.stringify(fetchResult)}`); + throw new Error(`Map information could not be loaded: ${JSON.stringify(fetchResult)}`); } result = fetchResult?.map?.role === 'owner' ? 'edition-owner' : 'edition-editor'; } From 16be3acbdfe9b5ec47a895d1eb9425c02d6b6f12 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 9 Mar 2022 10:54:48 -0800 Subject: [PATCH 15/21] Fix issue when map is shared for view --- packages/webapp/src/components/editor-page/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webapp/src/components/editor-page/index.tsx b/packages/webapp/src/components/editor-page/index.tsx index c3a1b00d..4fa8c7bb 100644 --- a/packages/webapp/src/components/editor-page/index.tsx +++ b/packages/webapp/src/components/editor-page/index.tsx @@ -38,7 +38,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { if (fetchResult.error) { throw new Error(`Map information could not be loaded: ${JSON.stringify(fetchResult)}`); } - result = fetchResult?.map?.role === 'owner' ? 'edition-owner' : 'edition-editor'; + result = `edition-${fetchResult?.map?.role}`; } } return result; From 842a91dbc79cd0ba198bc17afe4f89394e0e9689 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 9 Mar 2022 10:55:33 -0800 Subject: [PATCH 16/21] Improve error message. --- packages/webapp/src/classes/client/rest-client/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webapp/src/classes/client/rest-client/index.ts b/packages/webapp/src/classes/client/rest-client/index.ts index d68f75ae..a0ace132 100644 --- a/packages/webapp/src/classes/client/rest-client/index.ts +++ b/packages/webapp/src/classes/client/rest-client/index.ts @@ -620,7 +620,7 @@ export default class RestClient implements Client { if (editorMode === 'edition-owner' || editorMode === 'edition-editor') { if (!global.lockSession) { - throw new Error(`Session could not be found: global.lockSession ${global.lockSession} - global.lockTimestamp: ${global.lockTimestamp} - ${global.mindmapLocked} - ${global.mindmapLockedMsg}`) + throw new Error(`Session could not be found: global.lockSession: '${global.lockSession}' - global.lockTimestamp: '${global.lockTimestamp}' - ${global.mindmapLocked} - ${global.mindmapLockedMsg}`) } persistence = new RESTPersistenceManager({ From 1d7db72ae521028ae8ff5b60e8482942672aab19 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 9 Mar 2022 11:16:15 -0800 Subject: [PATCH 17/21] Viewer must have view only view --- packages/mindplot/src/components/Designer.ts | 4 ++-- packages/mindplot/src/components/DesignerOptionsBuilder.ts | 1 - .../{EditorOptionsBuider.ts => EditorOptionsBuilder.ts} | 2 +- packages/webapp/src/components/editor-page/index.tsx | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) rename packages/webapp/src/components/editor-page/{EditorOptionsBuider.ts => EditorOptionsBuilder.ts} (96%) diff --git a/packages/mindplot/src/components/Designer.ts b/packages/mindplot/src/components/Designer.ts index b1ab5dae..a17b0189 100644 --- a/packages/mindplot/src/components/Designer.ts +++ b/packages/mindplot/src/components/Designer.ts @@ -110,7 +110,7 @@ class Designer extends Events { // Init Screen manager.. const screenManager = new ScreenManager(divElement); - this._workspace = new Workspace(screenManager, this._model.getZoom(), options.mode === 'viewonly'); + this._workspace = new Workspace(screenManager, this._model.getZoom(), this.isReadOnly()); // Init layout manager ... this._eventBussDispatcher = new EventBusDispatcher(); @@ -623,7 +623,7 @@ class Designer extends Events { } isReadOnly(): boolean { - return Boolean(this._options?.mode === 'viewonly'); + return this._options.mode === 'viewonly' || this._options.mode === 'edition-viewer'; } nodeModelToTopic(nodeModel: NodeModel): Topic { diff --git a/packages/mindplot/src/components/DesignerOptionsBuilder.ts b/packages/mindplot/src/components/DesignerOptionsBuilder.ts index 02a1a2e1..a4e0ac53 100644 --- a/packages/mindplot/src/components/DesignerOptionsBuilder.ts +++ b/packages/mindplot/src/components/DesignerOptionsBuilder.ts @@ -42,7 +42,6 @@ class OptionsBuilder { width: window.screen.width, height: window.screen.height, }; - console.log(`height:${containerSize.height}`); } const defaultOptions: DesignerOptions = { diff --git a/packages/webapp/src/components/editor-page/EditorOptionsBuider.ts b/packages/webapp/src/components/editor-page/EditorOptionsBuilder.ts similarity index 96% rename from packages/webapp/src/components/editor-page/EditorOptionsBuider.ts rename to packages/webapp/src/components/editor-page/EditorOptionsBuilder.ts index 7342bb0e..cf6a2ff7 100644 --- a/packages/webapp/src/components/editor-page/EditorOptionsBuider.ts +++ b/packages/webapp/src/components/editor-page/EditorOptionsBuilder.ts @@ -2,7 +2,7 @@ import { EditorOptions } from '@wisemapping/editor'; import { EditorRenderMode } from '@wisemapping/mindplot'; import AppConfig from '../../classes/app-config'; -export default class EditorOptionsBulder { +export default class EditorOptionsBuilder { static build(locale: string, mode: EditorRenderMode, hotkeys: boolean): EditorOptions { let options: EditorOptions = { diff --git a/packages/webapp/src/components/editor-page/index.tsx b/packages/webapp/src/components/editor-page/index.tsx index 4fa8c7bb..56f47682 100644 --- a/packages/webapp/src/components/editor-page/index.tsx +++ b/packages/webapp/src/components/editor-page/index.tsx @@ -10,7 +10,7 @@ import { hotkeysEnabled } from '../../redux/editorSlice'; import ReactGA from 'react-ga'; import Client from '../../classes/client'; import { activeInstance, fetchAccount, fetchMapById } from '../../redux/clientSlice'; -import EditorOptionsBulder from './EditorOptionsBuider'; +import EditorOptionsBuilder from './EditorOptionsBuilder'; export type EditorPropsType = { isTryMode: boolean; @@ -45,7 +45,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { } // What is the role ? - const mapId = EditorOptionsBulder.loadMapId(); + const mapId = EditorOptionsBuilder.loadMapId(); const mode = findEditorMode(isTryMode, mapId); // Account settings can be null and editor cannot be initilized multiple times. This creates problems @@ -55,7 +55,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { let options, persistence: PersistenceManager; if (loadCompleted) { - options = EditorOptionsBulder.build(userLocale.code, mode, hotkey); + options = EditorOptionsBuilder.build(userLocale.code, mode, hotkey); persistence = client.buildPersistenceManager(mode); } From d8cdb5055848d9ee8687bd08a2c4ce83a40f8bfa Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 9 Mar 2022 11:39:02 -0800 Subject: [PATCH 18/21] Fix clean up code. --- packages/editor/src/classes/menu/Menu.ts | 468 +++++++++--------- .../editor/src/components/toolbar/index.tsx | 118 ++--- 2 files changed, 290 insertions(+), 296 deletions(-) diff --git a/packages/editor/src/classes/menu/Menu.ts b/packages/editor/src/classes/menu/Menu.ts index 0cd63062..aa821462 100644 --- a/packages/editor/src/classes/menu/Menu.ts +++ b/packages/editor/src/classes/menu/Menu.ts @@ -38,258 +38,256 @@ class Menu extends IMenu { const widgetsBaseUrl = `${baseUrl}css/widget`; // Create panels ... + const designerModel = designer.getModel(); - const fontFamilyModel = { - getValue() { - const nodes = designerModel.filterSelectedTopics(); - let result = null; - for (let i = 0; i < nodes.length; i++) { - const fontFamily = nodes[i].getFontFamily(); - if (result != null && result !== fontFamily) { - result = null; - break; + const backTolist = $('#backToList'); + backTolist.bind('click', (event) => { + event.stopPropagation(); + window.location.href = '/c/maps/'; + return false; + }); + Menu._registerTooltip('backToList', $msg('BACK_TO_MAP_LIST')); + + + if (!readOnly) { + const fontFamilyModel = { + getValue() { + const nodes = designerModel.filterSelectedTopics(); + let result = null; + for (let i = 0; i < nodes.length; i++) { + const fontFamily = nodes[i].getFontFamily(); + if (result != null && result !== fontFamily) { + result = null; + break; + } + result = fontFamily; } - result = fontFamily; - } - return result; - }, + return result; + }, - setValue(value: string) { - designer.changeFontFamily(value); - }, - }; - this._toolbarElems.push(new FontFamilyPanel('fontFamily', fontFamilyModel)); - Menu._registerTooltip('fontFamily', $msg('FONT_FAMILY')); + setValue(value: string) { + designer.changeFontFamily(value); + }, + }; + this._toolbarElems.push(new FontFamilyPanel('fontFamily', fontFamilyModel)); + Menu._registerTooltip('fontFamily', $msg('FONT_FAMILY')); - const fontSizeModel = { - getValue(): number { - const nodes = designerModel.filterSelectedTopics(); + const fontSizeModel = { + getValue(): number { + const nodes = designerModel.filterSelectedTopics(); - let result = null; - for (let i = 0; i < nodes.length; i++) { - const fontSize = nodes[i].getFontSize(); - if (result != null && result !== fontSize) { - result = null; - break; + let result = null; + for (let i = 0; i < nodes.length; i++) { + const fontSize = nodes[i].getFontSize(); + if (result != null && result !== fontSize) { + result = null; + break; + } + result = fontSize; } - result = fontSize; - } - return result; - }, - setValue(value: number) { - designer.changeFontSize(value); - }, - }; - this._toolbarElems.push(new FontSizePanel('fontSize', fontSizeModel)); - Menu._registerTooltip('fontSize', $msg('FONT_SIZE')); + return result; + }, + setValue(value: number) { + designer.changeFontSize(value); + }, + }; + this._toolbarElems.push(new FontSizePanel('fontSize', fontSizeModel)); + Menu._registerTooltip('fontSize', $msg('FONT_SIZE')); - const topicShapeModel = { - getValue() { - const nodes = designerModel.filterSelectedTopics(); - let result = null; - for (let i = 0; i < nodes.length; i++) { - const shapeType = nodes[i].getShapeType(); - if (result != null && result !== shapeType) { - result = null; - break; + const topicShapeModel = { + getValue() { + const nodes = designerModel.filterSelectedTopics(); + let result = null; + for (let i = 0; i < nodes.length; i++) { + const shapeType = nodes[i].getShapeType(); + if (result != null && result !== shapeType) { + result = null; + break; + } + result = shapeType; } - result = shapeType; - } - return result; - }, - setValue(value: string) { - designer.changeTopicShape(value); - }, - }; - this._toolbarElems.push(new TopicShapePanel('topicShape', topicShapeModel)); - Menu._registerTooltip('topicShape', $msg('TOPIC_SHAPE')); + return result; + }, + setValue(value: string) { + designer.changeTopicShape(value); + }, + }; + this._toolbarElems.push(new TopicShapePanel('topicShape', topicShapeModel)); + Menu._registerTooltip('topicShape', $msg('TOPIC_SHAPE')); - // Create icon panel dialog ... - const topicIconModel = { - getValue() { - return null; - }, - setValue(value: string) { - designer.addIconType(value); - }, - }; - this._toolbarElems.push(new IconPanel('topicIcon', topicIconModel)); - Menu._registerTooltip('topicIcon', $msg('TOPIC_ICON')); + // Create icon panel dialog ... + const topicIconModel = { + getValue() { + return null; + }, + setValue(value: string) { + designer.addIconType(value); + }, + }; + this._toolbarElems.push(new IconPanel('topicIcon', topicIconModel)); + Menu._registerTooltip('topicIcon', $msg('TOPIC_ICON')); - const topicColorModel = { - getValue() { - const nodes = designerModel.filterSelectedTopics(); - let result = null; - for (let i = 0; i < nodes.length; i++) { - const color = nodes[i].getBackgroundColor(); - if (result != null && result !== color) { - result = null; - break; + const topicColorModel = { + getValue() { + const nodes = designerModel.filterSelectedTopics(); + let result = null; + for (let i = 0; i < nodes.length; i++) { + const color = nodes[i].getBackgroundColor(); + if (result != null && result !== color) { + result = null; + break; + } + result = color; } - result = color; - } - return result; - }, - setValue(hex: string) { - designer.changeBackgroundColor(hex); - }, - }; - this._toolbarElems.push(new ColorPalettePanel('topicColor', topicColorModel, widgetsBaseUrl)); - Menu._registerTooltip('topicColor', $msg('TOPIC_COLOR')); + return result; + }, + setValue(hex: string) { + designer.changeBackgroundColor(hex); + }, + }; + this._toolbarElems.push(new ColorPalettePanel('topicColor', topicColorModel, widgetsBaseUrl)); + Menu._registerTooltip('topicColor', $msg('TOPIC_COLOR')); - const borderColorModel = { - getValue() { - const nodes = designerModel.filterSelectedTopics(); - let result = null; - for (let i = 0; i < nodes.length; i++) { - const color = nodes[i].getBorderColor(); - if (result != null && result !== color) { - result = null; - break; + const borderColorModel = { + getValue() { + const nodes = designerModel.filterSelectedTopics(); + let result = null; + for (let i = 0; i < nodes.length; i++) { + const color = nodes[i].getBorderColor(); + if (result != null && result !== color) { + result = null; + break; + } + result = color; } - result = color; - } - return result; - }, - setValue(hex: string) { - designer.changeBorderColor(hex); - }, - }; - this._toolbarElems.push(new ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl)); - Menu._registerTooltip('topicBorder', $msg('TOPIC_BORDER_COLOR')); + return result; + }, + setValue(hex: string) { + designer.changeBorderColor(hex); + }, + }; + this._toolbarElems.push(new ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl)); + Menu._registerTooltip('topicBorder', $msg('TOPIC_BORDER_COLOR')); - const fontColorModel = { - getValue() { - let result = null; - const nodes = designerModel.filterSelectedTopics(); - for (let i = 0; i < nodes.length; i++) { - const color = nodes[i].getFontColor(); - if (result != null && result !== color) { - result = null; - break; + const fontColorModel = { + getValue() { + let result = null; + const nodes = designerModel.filterSelectedTopics(); + for (let i = 0; i < nodes.length; i++) { + const color = nodes[i].getFontColor(); + if (result != null && result !== color) { + result = null; + break; + } + result = color; } - result = color; + return result; + }, + setValue(hex) { + designer.changeFontColor(hex); + }, + }; + this._toolbarElems.push(new ColorPalettePanel('fontColor', fontColorModel, baseUrl)); + Menu._registerTooltip('fontColor', $msg('FONT_COLOR')); + + const undoButton = this._addButton('undoEdition', false, false, () => { + designer.undo(); + }); + if (undoButton) { + undoButton.disable(); + } + Menu._registerTooltip('undoEdition', $msg('UNDO'), 'meta+Z'); + + const redoButton = this._addButton('redoEdition', false, false, () => { + designer.redo(); + }); + if (redoButton) { + redoButton.disable(); + } + Menu._registerTooltip('redoEdition', $msg('REDO'), 'meta+shift+Z'); + + if (redoButton && undoButton) { + designer.addEvent('modelUpdate', (event) => { + if (event.undoSteps > 0) { + undoButton.enable(); + } else { + undoButton.disable(); + } + if (event.redoSteps > 0) { + redoButton.enable(); + } else { + redoButton.disable(); + } + }); + } + + this._addButton('addTopic', true, false, () => { + designer.createSiblingForSelectedNode(); + }); + Menu._registerTooltip('addTopic', $msg('ADD_TOPIC'), 'Enter'); + + this._addButton('deleteTopic', true, true, () => { + designer.deleteSelectedEntities(); + }); + Menu._registerTooltip('deleteTopic', $msg('TOPIC_DELETE'), 'Delete'); + + this._addButton('topicLink', true, false, () => { + designer.addLink(); + }); + Menu._registerTooltip('topicLink', $msg('TOPIC_LINK')); + + this._addButton('topicRelation', true, false, (event) => { + designer.showRelPivot(event); + }); + Menu._registerTooltip('topicRelation', $msg('TOPIC_RELATIONSHIP')); + + this._addButton('topicNote', true, false, () => { + designer.addNote(); + }); + Menu._registerTooltip('topicNote', $msg('TOPIC_NOTE')); + + this._addButton('fontBold', true, false, () => { + designer.changeFontWeight(); + }); + Menu._registerTooltip('fontBold', $msg('FONT_BOLD'), 'meta+B'); + + this._addButton('fontItalic', true, false, () => { + designer.changeFontStyle(); + }); + Menu._registerTooltip('fontItalic', $msg('FONT_ITALIC'), 'meta+I'); + + + if (saveElem) { + this._addButton('save', false, false, + () => { + this.save(saveElem, designer, true); + }); + Menu._registerTooltip('save', $msg('SAVE'), 'meta+S'); + + if (!readOnly) { + window.addEventListener('beforeunload', () => { + if (this.isSaveRequired()) { + this.save(saveElem, designer, false); + } + this.unlockMap(designer); + }); + + // Autosave on a fixed period of time ... + setInterval( + () => { + if (this.isSaveRequired()) { + this.save(saveElem, designer, false); + } + }, 10000, + ); } - return result; - }, - setValue(hex) { - designer.changeFontColor(hex); - }, - }; - this._toolbarElems.push(new ColorPalettePanel('fontColor', fontColorModel, baseUrl)); - Menu._registerTooltip('fontColor', $msg('FONT_COLOR')); + } + } Menu._registerTooltip('export', $msg('EXPORT')); Menu._registerTooltip('print', $msg('PRINT')); - this._addButton('zoom-plus', false, false, () => { - designer.zoomIn(); - }); - Menu._registerTooltip('zoom-plus', $msg('ZOOM_IN')); - - this._addButton('zoom-minus', false, false, () => { - designer.zoomOut(); - }); - Menu._registerTooltip('zoom-minus', $msg('ZOOM_OUT')); - - this._addButton('position', false, false, () => { - designer.zoomToFit(); - }); - Menu._registerTooltip('position', $msg('CENTER_POSITION')); - - const undoButton = this._addButton('undoEdition', false, false, () => { - designer.undo(); - }); - if (undoButton) { - undoButton.disable(); - } - Menu._registerTooltip('undoEdition', $msg('UNDO'), 'meta+Z'); - - const redoButton = this._addButton('redoEdition', false, false, () => { - designer.redo(); - }); - if (redoButton) { - redoButton.disable(); - } - Menu._registerTooltip('redoEdition', $msg('REDO'), 'meta+shift+Z'); - - if (redoButton && undoButton) { - designer.addEvent('modelUpdate', (event) => { - if (event.undoSteps > 0) { - undoButton.enable(); - } else { - undoButton.disable(); - } - if (event.redoSteps > 0) { - redoButton.enable(); - } else { - redoButton.disable(); - } - }); - } - - this._addButton('addTopic', true, false, () => { - designer.createSiblingForSelectedNode(); - }); - Menu._registerTooltip('addTopic', $msg('ADD_TOPIC'), 'Enter'); - - this._addButton('deleteTopic', true, true, () => { - designer.deleteSelectedEntities(); - }); - Menu._registerTooltip('deleteTopic', $msg('TOPIC_DELETE'), 'Delete'); - - this._addButton('topicLink', true, false, () => { - designer.addLink(); - }); - Menu._registerTooltip('topicLink', $msg('TOPIC_LINK')); - - this._addButton('topicRelation', true, false, (event) => { - designer.showRelPivot(event); - }); - Menu._registerTooltip('topicRelation', $msg('TOPIC_RELATIONSHIP')); - - this._addButton('topicNote', true, false, () => { - designer.addNote(); - }); - Menu._registerTooltip('topicNote', $msg('TOPIC_NOTE')); - - this._addButton('fontBold', true, false, () => { - designer.changeFontWeight(); - }); - Menu._registerTooltip('fontBold', $msg('FONT_BOLD'), 'meta+B'); - - this._addButton('fontItalic', true, false, () => { - designer.changeFontStyle(); - }); - Menu._registerTooltip('fontItalic', $msg('FONT_ITALIC'), 'meta+I'); - - if (saveElem) { - this._addButton('save', false, false, - () => { - this.save(saveElem, designer, true); - }); - Menu._registerTooltip('save', $msg('SAVE'), 'meta+S'); - - if (!readOnly) { - window.addEventListener('beforeunload', () => { - if (this.isSaveRequired()) { - this.save(saveElem, designer, false); - } - this.unlockMap(designer); - }); - - // Autosave on a fixed period of time ... - setInterval( - () => { - if (this.isSaveRequired()) { - this.save(saveElem, designer, false); - } - }, 10000, - ); - } - } - const shareElem = $('#shareIt'); if (shareElem.length !== 0) { Menu._registerTooltip('shareIt', $msg('COLLABORATE')); @@ -316,14 +314,6 @@ class Menu extends IMenu { Menu._registerTooltip('keyboardShortcuts', $msg('KEYBOARD_SHOTCUTS')); } - const backTolist = $('#backToList'); - backTolist.bind('click', (event) => { - event.stopPropagation(); - window.location.href = '/c/maps/'; - return false; - }); - Menu._registerTooltip('backToList', $msg('BACK_TO_MAP_LIST')); - // Account dialog ... const accountSettings = $('#account'); if (accountSettings.length !== 0) { diff --git a/packages/editor/src/components/toolbar/index.tsx b/packages/editor/src/components/toolbar/index.tsx index 9a08ea4f..22803507 100644 --- a/packages/editor/src/components/toolbar/index.tsx +++ b/packages/editor/src/components/toolbar/index.tsx @@ -55,63 +55,67 @@ export default function Toolbar({ )} -
- - - - - - -
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - -
-
+ {(editorMode === 'edition-editor' || editorMode === 'edition-owner' || editorMode === 'showcase') && ( + <> +
+ + + + + + +
+
+ + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+
+ + )} Date: Wed, 9 Mar 2022 12:49:44 -0800 Subject: [PATCH 19/21] Fix zoom on editor --- packages/editor/src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor/src/index.tsx b/packages/editor/src/index.tsx index c4808abd..eed9732f 100644 --- a/packages/editor/src/index.tsx +++ b/packages/editor/src/index.tsx @@ -90,7 +90,7 @@ const Editor = ({ const result = buildDesigner(buildOptions); // Register toolbar event ... - if (options.mode === 'edition-owner' || options.mode === 'edition-editor' || options.mode === 'showcase') { + if (options.mode === 'edition-owner' || options.mode === 'edition-editor' || options.mode === 'edition-viewer' || options.mode === 'showcase') { const menu = new Menu(designer, 'toolbar'); // If a node has focus, focus can be move to another node using the keys. From 6eafdf47196f166f69ce81a7a232add1a9e1e251 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 9 Mar 2022 13:01:55 -0800 Subject: [PATCH 20/21] Revert zoom removal --- packages/editor/src/classes/menu/Menu.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/editor/src/classes/menu/Menu.ts b/packages/editor/src/classes/menu/Menu.ts index aa821462..21f1a556 100644 --- a/packages/editor/src/classes/menu/Menu.ts +++ b/packages/editor/src/classes/menu/Menu.ts @@ -40,6 +40,8 @@ class Menu extends IMenu { // Create panels ... const designerModel = designer.getModel(); + + // Common actions .... const backTolist = $('#backToList'); backTolist.bind('click', (event) => { event.stopPropagation(); @@ -48,7 +50,22 @@ class Menu extends IMenu { }); Menu._registerTooltip('backToList', $msg('BACK_TO_MAP_LIST')); + this._addButton('zoom-plus', false, false, () => { + designer.zoomIn(); + }); + Menu._registerTooltip('zoom-plus', $msg('ZOOM_IN')); + this._addButton('zoom-minus', false, false, () => { + designer.zoomOut(); + }); + Menu._registerTooltip('zoom-minus', $msg('ZOOM_OUT')); + + this._addButton('position', false, false, () => { + designer.zoomToFit(); + }); + Menu._registerTooltip('position', $msg('CENTER_POSITION')); + + // Edition actions ... if (!readOnly) { const fontFamilyModel = { getValue() { From eaaf3c5d44692417e93c34739ba2967c3c35bf95 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 9 Mar 2022 21:36:27 -0800 Subject: [PATCH 21/21] Initialize page document --- packages/webapp/src/components/editor-page/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/webapp/src/components/editor-page/index.tsx b/packages/webapp/src/components/editor-page/index.tsx index 56f47682..2651230f 100644 --- a/packages/webapp/src/components/editor-page/index.tsx +++ b/packages/webapp/src/components/editor-page/index.tsx @@ -23,6 +23,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => { const client: Client = useSelector(activeInstance); useEffect(() => { + document.title = `${global.mapTitle ? global.mapTitle : 'unknown'} | WiseMapping `; ReactGA.pageview(window.location.pathname + window.location.search); }, []);