Fix layout on try

This commit is contained in:
Paulo Gustavo Veiga 2022-02-25 07:33:37 -08:00
parent 0ddbb4d8e5
commit 9149e5888a
6 changed files with 77 additions and 90 deletions

View File

@ -1,9 +1,9 @@
{ {
"editor.try-welcome": { "editor.try-welcome": {
"defaultMessage": "Здесь можно ознакомиться с возможностями нашего редактора майнд-карт на примерах и практике!" "defaultMessage": "Это демо-версия редактора, можно попробовать его в деле!"
}, },
"editor.try-welcome-description": { "editor.try-welcome-description": {
"defaultMessage": "Зарегистрируйтесь чтобы начать создавать, публиковать и делиться майнд-картами бесплатно и без ограничений." "defaultMessage": "Чтобы получить бесплатный неограниченный доступ — нужна только регистрация."
}, },
"login.signup": { "login.signup": {
"defaultMessage": "Регистрация" "defaultMessage": "Регистрация"

View File

@ -0,0 +1,26 @@
import FR from './../../compiled-lang/fr.json';
import ES from './../../compiled-lang/es.json';
import EN from './../../compiled-lang/en.json';
import DE from './../../compiled-lang/de.json';
import RU from './../../compiled-lang/ru.json';
class I18nMsg {
static loadLocaleData(locale: string) {
switch (locale) {
case 'fr':
return FR;
case 'en':
return EN;
case 'es':
return ES;
case 'de':
return DE;
case 'ru':
return RU;
default:
return EN;
}
}
}
export default I18nMsg;

View File

@ -217,9 +217,8 @@ div#tryInfoPanel {
margin: auto; margin: auto;
text-align: center; text-align: center;
top: 80px; top: 80px;
right: 20px; left: 20px;
width: 200px; width: 200px;
height: 300px;
padding: 20px; padding: 20px;
font-size: 15px; font-size: 15px;
border-radius: 9px; border-radius: 9px;

View File

@ -10,14 +10,9 @@ import {
Designer, Designer,
DesignerKeyboard, DesignerKeyboard,
} from '@wisemapping/mindplot'; } from '@wisemapping/mindplot';
import FR from './compiled-lang/fr.json';
import ES from './compiled-lang/es.json';
import EN from './compiled-lang/en.json';
import DE from './compiled-lang/de.json';
import RU from './compiled-lang/ru.json';
import './global-styled.css'; import './global-styled.css';
import { EditorModeType } from '@wisemapping/mindplot/src/components/DesignerOptionsBuilder'; import { EditorModeType } from '@wisemapping/mindplot/src/components/DesignerOptionsBuilder';
import I18nMsg from './classes/i18n-msg';
declare global { declare global {
// used in mindplot // used in mindplot
@ -38,45 +33,31 @@ export type EditorOptions = {
export type EditorProps = { export type EditorProps = {
mapId: string; mapId: string;
options: EditorOptions; options: EditorOptions;
onAction: (action: ToolbarActionType) => void;
persistenceManager: PersistenceManager; persistenceManager: PersistenceManager;
initCallback?: (mapId: string, options: EditorOptions, persistenceManager: PersistenceManager) => void; onAction: (action: ToolbarActionType) => void;
onLoad?: (designer: Designer) => void;
}; };
const loadLocaleData = (locale: string) => { const Editor = ({
switch (locale) { mapId,
case 'fr': options,
return FR; persistenceManager,
case 'en': onAction,
return EN; onLoad,
case 'es': }: EditorProps) => {
return ES;
case 'de':
return DE;
case 'ru':
return RU;
default:
return EN;
}
}
const defaultCallback = (mapId: string, options: EditorOptions, persistenceManager: PersistenceManager) => { useEffect(() => {
// Change page title ... // Change page title ...
document.title = `${options.mapTitle} | WiseMapping `; document.title = `${options.mapTitle} | WiseMapping `;
const buildOptions = DesignerOptionsBuilder.buildOptions({ // Load mindmap ...
persistenceManager, const designer = onLoadDesigner(mapId, options, persistenceManager);
mode: options.mode, // Has extended actions been customized ...
mapId: mapId, if (onLoad) {
container: 'mindplot', onLoad(designer);
zoom: options.zoom, }
locale: options.locale,
});
// Build designer ... // Load mindmap ...
const designer = buildDesigner(buildOptions);
// Load map from XML file persisted on disk...
const instance = PersistenceManager.getInstance(); const instance = PersistenceManager.getInstance();
const mindmap = instance.load(mapId); const mindmap = instance.load(mapId);
designer.loadMap(mindmap); designer.loadMap(mindmap);
@ -84,17 +65,7 @@ const defaultCallback = (mapId: string, options: EditorOptions, persistenceManag
if (options.locked) { if (options.locked) {
$notify(options.lockedMsg); $notify(options.lockedMsg);
} }
};
const Editor = ({
mapId,
options,
persistenceManager,
initCallback = defaultCallback,
onAction,
}: EditorProps) => {
useEffect(() => {
initCallback(mapId, options, persistenceManager);
}, []); }, []);
useEffect(() => { useEffect(() => {
@ -105,8 +76,25 @@ const Editor = ({
} }
}, [options.enableKeyboardEvents]); }, [options.enableKeyboardEvents]);
const onLoadDesigner = (mapId: string, options: EditorOptions, persistenceManager: PersistenceManager): Designer => {
const buildOptions = DesignerOptionsBuilder.buildOptions({
persistenceManager,
mode: options.mode,
mapId: mapId,
container: 'mindplot',
zoom: options.zoom,
locale: options.locale,
});
// Build designer ...
return buildDesigner(buildOptions);
};
const locale = options.locale;
const msg = I18nMsg.loadLocaleData(locale);
return ( return (
<IntlProvider locale={options.locale} messages={loadLocaleData(options.locale)}> <IntlProvider locale={locale} messages={msg}>
<Toolbar <Toolbar
isTryMode={options.mode === 'showcase'} isTryMode={options.mode === 'showcase'}
onAction={onAction} onAction={onAction}

View File

@ -1,29 +1,16 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import Editor, { EditorOptions } from '../../../../src/index'; import Editor, { EditorOptions } from '../../../../src/index';
import { buildDesigner, LocalStorageManager, PersistenceManager, DesignerOptionsBuilder } from '@wisemapping/mindplot'; import { LocalStorageManager, Designer } from '@wisemapping/mindplot';
const initialization = (mapId: string, options: EditorOptions, persistenceManager: PersistenceManager) => { const initialization = (designer: Designer) => {
const designerOptions = DesignerOptionsBuilder.buildOptions({
persistenceManager: persistenceManager,
zoom: options.zoom ? options.zoom : 0.8,
mode: options.mode,
container: 'mindplot'
});
const designer = buildDesigner(designerOptions);
designer.addEvent('loadSuccess', () => { designer.addEvent('loadSuccess', () => {
const elem = document.getElementById('mindplot'); const elem = document.getElementById('mindplot');
if (elem) { if (elem) {
elem.classList.add('ready'); elem.classList.add('ready');
} }
}); });
// Load map from XML file persisted on disk...
const persistence = PersistenceManager.getInstance();
const mindmap = persistence.load(mapId);
designer.loadMap(mindmap);
}; };
const persistence = new LocalStorageManager('samples/{id}.wxml', false); const persistence = new LocalStorageManager('samples/{id}.wxml', false);
@ -43,7 +30,7 @@ ReactDOM.render(
options={options} options={options}
persistenceManager={persistence} persistenceManager={persistence}
onAction={(action) => console.log('action called:', action)} onAction={(action) => console.log('action called:', action)}
initCallback={initialization} onLoad={initialization}
/>, />,
document.getElementById('root'), document.getElementById('root'),
); );

View File

@ -2,18 +2,10 @@ import '../css/viewmode.css';
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import Editor, { EditorOptions } from '../../../../src/index'; import Editor, { EditorOptions } from '../../../../src/index';
import { buildDesigner, LocalStorageManager, PersistenceManager, DesignerOptionsBuilder } from '@wisemapping/mindplot'; import { LocalStorageManager, Designer } from '@wisemapping/mindplot';
const initialization = (mapId: string, options: EditorOptions, persistenceManager: PersistenceManager) => { const initialization = (designer: Designer) => {
const designerOptions = DesignerOptionsBuilder.buildOptions({
persistenceManager: persistenceManager,
zoom: options.zoom ? options.zoom : 0.8,
mode: options.mode,
container: 'mindplot'
});
const designer = buildDesigner(designerOptions);
designer.addEvent('loadSuccess', () => { designer.addEvent('loadSuccess', () => {
const elem = document.getElementById('mindplot'); const elem = document.getElementById('mindplot');
if (elem) { if (elem) {
@ -35,11 +27,6 @@ const initialization = (mapId: string, options: EditorOptions, persistenceManage
} }
}); });
// Load map from XML file persisted on disk...
const persistence = PersistenceManager.getInstance();
const mindmap = persistence.load(mapId);
designer.loadMap(mindmap);
}; };
// Obtain map id from query param // Obtain map id from query param
@ -61,7 +48,7 @@ ReactDOM.render(
options={options} options={options}
persistenceManager={persistence} persistenceManager={persistence}
onAction={(action) => console.log('action called:', action)} onAction={(action) => console.log('action called:', action)}
initCallback={initialization} onLoad={initialization}
/>, />,
document.getElementById('root'), document.getElementById('root'),
); );