mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Migrate global to globalThis
This commit is contained in:
parent
e639dd7202
commit
dbfed09f3a
10
packages/mindplot/src/@types/custom.d.ts
vendored
10
packages/mindplot/src/@types/custom.d.ts
vendored
@ -2,3 +2,13 @@ declare module '*.svg' {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
||||
// @Hack: This should not be here ....
|
||||
declare global {
|
||||
const isAuth: boolean;
|
||||
const mapId: number;
|
||||
const historyId: number;
|
||||
const userOptions: { zoom: string | number } | null;
|
||||
const mindmapLocked: boolean;
|
||||
const mindmapLockedMsg: string;
|
||||
const mapTitle: string;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class Designer extends Events {
|
||||
this._clipboard = [];
|
||||
|
||||
// Hack: There are static reference to designer variable. Needs to be reviewed.
|
||||
global.designer = this;
|
||||
globalThis.designer = this;
|
||||
}
|
||||
|
||||
private _registerWheelEvents(): void {
|
||||
|
@ -29,9 +29,9 @@ globalAny.jQuery = jquery;
|
||||
// WebComponent registration
|
||||
customElements.define('mindplot-component', MindplotWebComponent);
|
||||
// Configure designer options ...
|
||||
const historyId = global.historyId ? `${global.historyId}/` : '';
|
||||
const historyId = globalThis.historyId ? `${globalThis.historyId}/` : '';
|
||||
const persistence: PersistenceManager = new LocalStorageManager(
|
||||
`/c/restful/maps/{id}/${historyId}document/xml${!global.isAuth ? '-pub' : ''}`,
|
||||
`/c/restful/maps/{id}/${historyId}document/xml${!globalThis.isAuth ? '-pub' : ''}`,
|
||||
true,
|
||||
);
|
||||
|
||||
@ -39,4 +39,4 @@ const webComponent: MindplotWebComponent = document.getElementById(
|
||||
'mindmap-comp',
|
||||
) as MindplotWebComponent;
|
||||
webComponent.buildDesigner(persistence);
|
||||
webComponent.loadMap(global.mapId);
|
||||
webComponent.loadMap(globalThis.mapId);
|
||||
|
@ -13,12 +13,12 @@ class EditorOptionsBuilder {
|
||||
if (!AppConfig.isDevelopEnv()) {
|
||||
options = {
|
||||
zoom:
|
||||
global.userOptions?.zoom != undefined
|
||||
? Number.parseFloat(global?.userOptions?.zoom as string)
|
||||
globalThis.userOptions?.zoom != undefined
|
||||
? Number.parseFloat(globalThis?.userOptions?.zoom as string)
|
||||
: 0.8,
|
||||
locked: global.mindmapLocked,
|
||||
lockedMsg: global.mindmapLockedMsg,
|
||||
mapTitle: global.mapTitle,
|
||||
locked: globalThis.mindmapLocked,
|
||||
lockedMsg: globalThis.mindmapLockedMsg,
|
||||
mapTitle: globalThis.mapTitle,
|
||||
...options,
|
||||
};
|
||||
} else {
|
||||
@ -35,10 +35,10 @@ class EditorOptionsBuilder {
|
||||
}
|
||||
|
||||
static loadMapId(): number {
|
||||
const result = !AppConfig.isDevelopEnv() ? global.mapId : 11;
|
||||
const result = !AppConfig.isDevelopEnv() ? globalThis.mapId : 11;
|
||||
if (result === undefined) {
|
||||
throw Error(
|
||||
`Could not resolve mapId. Map Id: global.mapId: ${result} , global.mapTitle: ${global.mapTitle}, global.lockSession: ${global.lockSession}`,
|
||||
`Could not resolve mapId. Map Id: globalThis.mapId: ${result} , globalThis.mapTitle: ${globalThis.mapTitle}, globalThis.lockSession: ${globalThis.lockSession}`,
|
||||
);
|
||||
}
|
||||
return result;
|
||||
|
@ -20,9 +20,9 @@ export const buildPersistenceManagerForEditor = (mode: string): PersistenceManag
|
||||
});
|
||||
} else {
|
||||
persistenceManager = new LocalStorageManager(
|
||||
`/c/restful/maps/{id}/${global.historyId ? `${global.historyId}/` : ''}document/xml${
|
||||
mode === 'showcase' ? '-pub' : ''
|
||||
}`,
|
||||
`/c/restful/maps/{id}/${
|
||||
globalThis.historyId ? `${globalThis.historyId}/` : ''
|
||||
}document/xml${mode === 'showcase' ? '-pub' : ''}`,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => {
|
||||
let result: EditorRenderMode = null;
|
||||
if (isTryMode) {
|
||||
result = 'showcase';
|
||||
} else if (global.mindmapLocked) {
|
||||
} else if (globalThis.mindmapLocked) {
|
||||
result = 'viewonly';
|
||||
} else {
|
||||
const fetchResult = useFetchMapById(mapId);
|
||||
|
@ -92,7 +92,7 @@ const ExportDialog = ({
|
||||
let size: SizeType;
|
||||
let mindmap: Mindmap;
|
||||
|
||||
const designer: Designer = global.designer;
|
||||
const designer: Designer = globalThis.designer;
|
||||
// exporting from editor toolbar action
|
||||
if (designer != null) {
|
||||
// Depending on the type of export. It will require differt POST.
|
||||
|
Loading…
Reference in New Issue
Block a user