2022-02-22 19:43:16 +01:00
|
|
|
import { EditorOptions } from '@wisemapping/editor';
|
2022-03-05 17:10:03 +01:00
|
|
|
import { EditorRenderMode } from '@wisemapping/mindplot';
|
2022-02-22 06:37:00 +01:00
|
|
|
import AppConfig from '../../classes/app-config';
|
|
|
|
|
2022-03-14 18:57:07 +01:00
|
|
|
class EditorOptionsBuilder {
|
2022-03-05 17:10:03 +01:00
|
|
|
static build(locale: string, mode: EditorRenderMode, hotkeys: boolean): EditorOptions {
|
2022-02-22 06:37:00 +01:00
|
|
|
|
|
|
|
let options: EditorOptions = {
|
2022-02-22 19:43:16 +01:00
|
|
|
enableKeyboardEvents: hotkeys,
|
2022-02-22 06:37:00 +01:00
|
|
|
locale: locale,
|
2022-03-05 17:10:03 +01:00
|
|
|
mode: mode,
|
2022-02-22 06:37:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!AppConfig.isDevelopEnv()) {
|
|
|
|
options = {
|
|
|
|
zoom: (global.userOptions?.zoom != undefined
|
|
|
|
? Number.parseFloat(global?.userOptions?.zoom as string)
|
|
|
|
: 0.8),
|
|
|
|
locked: global.mindmapLocked,
|
|
|
|
lockedMsg: global.mindmapLockedMsg,
|
|
|
|
mapTitle: global.mapTitle,
|
|
|
|
...options
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Running in a development mode.
|
|
|
|
console.log('Running editor in development mode');
|
|
|
|
options = {
|
|
|
|
zoom: 0.8,
|
|
|
|
locked: false,
|
|
|
|
mapTitle: "Develop Mindnap",
|
|
|
|
...options
|
|
|
|
}
|
|
|
|
}
|
2022-03-05 17:10:03 +01:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
static loadMapId(): number {
|
2022-03-22 04:15:27 +01:00
|
|
|
const result = !AppConfig.isDevelopEnv() ? global.mapId : 11;
|
|
|
|
if (result === undefined) {
|
|
|
|
throw Error(`Could not resolve mapId. Map Id: global.mapId: ${result} , global.mapTitle: ${global.mapTitle}, global.lockSession: ${global.lockSession}`);
|
|
|
|
}
|
|
|
|
return result;
|
2022-02-22 06:37:00 +01:00
|
|
|
}
|
2022-03-14 18:57:07 +01:00
|
|
|
}
|
|
|
|
export default EditorOptionsBuilder;
|