Fix map load.

This commit is contained in:
Paulo Gustavo Veiga 2024-02-09 00:03:34 -08:00
parent e3d6f5dad5
commit e7355bc2fe
6 changed files with 50 additions and 11 deletions

View File

@ -1,3 +1,20 @@
/*
* Copyright [2021] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DesignerKeyboard, EditorRenderMode, PersistenceManager } from '@wisemapping/mindplot';
import { useState, useRef, useEffect } from 'react';
import Capability from '../../classes/action/capability';
@ -65,13 +82,11 @@ export const useEditor = ({
}, [mindplotRef, options]);
useEffect(() => {
if (options) {
if (options.enableKeyboardEvents) {
if (options && options.enableKeyboardEvents) {
DesignerKeyboard.resume();
} else {
DesignerKeyboard.pause();
}
}
}, [options, options?.enableKeyboardEvents]);
return { model, mindplotRef, mapInfo, capability, options };

View File

@ -1,3 +1,20 @@
/*
* Copyright [2021] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DefaultWidgetManager from '../../classes/default-widget-manager';
export const useWidgetManager = (): {

View File

@ -46,7 +46,7 @@
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="<%=PUBLIC_URL%>/manifest.json" />
<!-- <link rel="manifest" href="<%=PUBLIC_URL%>/manifest.json" /> -->
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.

View File

@ -64,7 +64,7 @@ export type MapMetadata = {
title: string;
isLocked: boolean;
isLockedBy?: string;
zoom: number;
jsonProps: string;
};
export type ChangeHistory = {

View File

@ -134,7 +134,7 @@ class MockClient implements Client {
title: 'my map',
id: id,
isLocked: false,
zoom: 0.8,
jsonProps: '{ "zoom": 0.8 }',
});
}

View File

@ -109,6 +109,7 @@ type EditorMetadata = {
mode: EditorRenderMode;
title: string;
isLocked: boolean;
isLockedBy?: string;
zoom: number;
};
@ -138,6 +139,8 @@ const EditorPage = ({ mapId, isTryMode }: EditorPropsType): React.ReactElement =
let mode: EditorRenderMode = null;
let title = '';
let isLocked = false;
let zoom = 0.8;
let isLockedBy;
if (isTryMode) {
mode = 'showcase';
@ -173,11 +176,14 @@ const EditorPage = ({ mapId, isTryMode }: EditorPropsType): React.ReactElement =
} else {
mode = `edition-${fetchMapInfoResult.data.role}`;
}
isLocked = fetchMetadataResult.data.isLocked;
isLockedBy = fetchMetadataResult.data.isLockedBy;
title = fetchMetadataResult.data.title;
zoom = JSON.parse(fetchMetadataResult.data.jsonProps).zoom;
}
}
return mode ? { mode: mode, isLocked: isLocked, title: title, zoom: 0.8 } : undefined;
return mode ? { mode, isLocked, isLockedBy, title, zoom } : undefined;
};
// What is the role ?
@ -192,11 +198,12 @@ const EditorPage = ({ mapId, isTryMode }: EditorPropsType): React.ReactElement =
let mapInfo: MapInfo;
let options: EditorOptions;
if (loadCompleted) {
// Configure de
// Configure
options = {
enableKeyboardEvents: hotkey,
locale: userLocale.code,
mode: mapMetadata.mode,
enableAppBar: true,
};
persistence = buildPersistenceManagerForEditor(mapMetadata.mode);