2022-02-22 19:43:16 +01:00
|
|
|
import { EditorOptions } from '@wisemapping/editor';
|
2022-08-26 03:35:59 +02:00
|
|
|
import { EditorRenderMode } from '@wisemapping/editor';
|
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-07-13 03:45:36 +02:00
|
|
|
static build(locale: string, mode: EditorRenderMode, hotkeys: boolean): EditorOptions {
|
|
|
|
let options: EditorOptions = {
|
|
|
|
enableKeyboardEvents: hotkeys,
|
|
|
|
locale: locale,
|
|
|
|
mode: mode,
|
|
|
|
};
|
2022-02-22 06:37:00 +01:00
|
|
|
|
2022-07-13 03:45:36 +02:00
|
|
|
if (!AppConfig.isDevelopEnv()) {
|
|
|
|
options = {
|
|
|
|
zoom:
|
2022-10-31 07:10:39 +01:00
|
|
|
globalThis.userOptions?.zoom != undefined
|
|
|
|
? Number.parseFloat(globalThis?.userOptions?.zoom as string)
|
2022-07-13 03:45:36 +02:00
|
|
|
: 0.8,
|
2022-10-31 07:10:39 +01:00
|
|
|
locked: globalThis.mindmapLocked,
|
|
|
|
lockedMsg: globalThis.mindmapLockedMsg,
|
|
|
|
mapTitle: globalThis.mapTitle,
|
2022-07-13 03:45:36 +02:00
|
|
|
...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
|
|
|
}
|
2022-07-13 03:45:36 +02:00
|
|
|
return options;
|
|
|
|
}
|
2022-03-05 17:10:03 +01:00
|
|
|
|
2022-07-13 03:45:36 +02:00
|
|
|
static loadMapId(): number {
|
2022-10-31 07:10:39 +01:00
|
|
|
const result = !AppConfig.isDevelopEnv() ? globalThis.mapId : 11;
|
2022-07-13 03:45:36 +02:00
|
|
|
if (result === undefined) {
|
|
|
|
throw Error(
|
2022-10-31 07:10:39 +01:00
|
|
|
`Could not resolve mapId. Map Id: globalThis.mapId: ${result} , globalThis.mapTitle: ${globalThis.mapTitle}, globalThis.lockSession: ${globalThis.lockSession}`,
|
2022-07-13 03:45:36 +02:00
|
|
|
);
|
2022-02-22 06:37:00 +01:00
|
|
|
}
|
2022-07-13 03:45:36 +02:00
|
|
|
return result;
|
|
|
|
}
|
2022-03-14 18:57:07 +01:00
|
|
|
}
|
|
|
|
export default EditorOptionsBuilder;
|