2022-02-22 06:37:00 +01:00
|
|
|
import '../css/viewmode.css';
|
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import Editor, { EditorOptions } from '../../../../src/index';
|
2022-02-25 16:33:37 +01:00
|
|
|
import { LocalStorageManager, Designer } from '@wisemapping/mindplot';
|
2022-02-22 06:37:00 +01:00
|
|
|
|
2022-02-25 16:33:37 +01:00
|
|
|
const initialization = (designer: Designer) => {
|
2022-02-22 06:37:00 +01:00
|
|
|
designer.addEvent('loadSuccess', () => {
|
2022-09-06 21:02:47 +02:00
|
|
|
const elem = document.getElementById('mindmap-comp');
|
2022-02-22 06:37:00 +01:00
|
|
|
if (elem) {
|
|
|
|
elem.classList.add('ready');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Code for selector of map.
|
|
|
|
const mapSelectElem = document.getElementById('map-select') as HTMLSelectElement;
|
|
|
|
if (mapSelectElem) {
|
|
|
|
mapSelectElem.addEventListener('change', (e) => {
|
|
|
|
// @ts-ignore
|
|
|
|
const selectMap = e.target?.value;
|
|
|
|
window.location.href = `${window.location.pathname}?id=${selectMap}`;
|
|
|
|
});
|
|
|
|
|
|
|
|
Array.from(mapSelectElem.options).forEach((option) => {
|
|
|
|
option.selected = option.value === mapId;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Obtain map id from query param
|
|
|
|
const params = new URLSearchParams(window.location.search.substring(1));
|
|
|
|
const mapId = params.get('id') || 'welcome';
|
|
|
|
const persistence = new LocalStorageManager('samples/{id}.wxml', false);
|
|
|
|
const options: EditorOptions = {
|
|
|
|
zoom: 0.8,
|
|
|
|
locked: false,
|
2022-07-10 05:56:01 +02:00
|
|
|
mapTitle: 'Develop WiseMapping',
|
2022-02-22 06:37:00 +01:00
|
|
|
mode: 'viewonly',
|
|
|
|
locale: 'en',
|
2022-07-10 05:56:01 +02:00
|
|
|
enableKeyboardEvents: true,
|
2022-02-22 06:37:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<Editor
|
|
|
|
mapId={mapId}
|
|
|
|
options={options}
|
|
|
|
persistenceManager={persistence}
|
|
|
|
onAction={(action) => console.log('action called:', action)}
|
2022-02-25 16:33:37 +01:00
|
|
|
onLoad={initialization}
|
2022-02-22 06:37:00 +01:00
|
|
|
/>,
|
|
|
|
document.getElementById('root'),
|
|
|
|
);
|