feat: export nodeChildrenSymbol && remove some unnecessary editor.set

This commit is contained in:
LeoYuan 袁力皓 2022-05-10 13:39:37 +08:00
parent 85704c3694
commit e83adcee81
5 changed files with 24 additions and 6 deletions

View File

@ -20,6 +20,15 @@ import { AssetsJson, AssetLoader } from '@alilc/lowcode-utils';
EventEmitter.defaultMaxListeners = 100; EventEmitter.defaultMaxListeners = 100;
// inner instance keys which should not be stored in config
const keyBlacklist = [
'designer',
'skeleton',
'currentDocument',
'simulator',
'plugins',
];
export declare interface Editor extends StrictEventEmitter<EventEmitter, GlobalEvent.EventConfig> { export declare interface Editor extends StrictEventEmitter<EventEmitter, GlobalEvent.EventConfig> {
addListener(event: string | symbol, listener: (...args: any[]) => void): this; addListener(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this; once(event: string | symbol, listener: (...args: any[]) => void): this;
@ -73,7 +82,9 @@ export class Editor extends (EventEmitter as any) implements IEditor {
return; return;
} }
// store the data to engineConfig while invoking editor.set() // store the data to engineConfig while invoking editor.set()
engineConfig.set(key as any, data); if (!keyBlacklist.includes(key as string)) {
engineConfig.set(key as any, data);
}
this.context.set(key, data); this.context.set(key, data);
this.notifyGot(key); this.notifyGot(key);
} }

View File

@ -37,14 +37,10 @@ globalContext.register(editor, Editor);
globalContext.register(editor, 'editor'); globalContext.register(editor, 'editor');
const innerSkeleton = new InnerSkeleton(editor); const innerSkeleton = new InnerSkeleton(editor);
editor.set(Skeleton, innerSkeleton);
editor.set('skeleton' as any, innerSkeleton); editor.set('skeleton' as any, innerSkeleton);
engineConfig.set('skeleton' as any, innerSkeleton);
const designer = new Designer({ editor }); const designer = new Designer({ editor });
editor.set(Designer, designer);
editor.set('designer' as any, designer); editor.set('designer' as any, designer);
engineConfig.set('designer' as any, designer);
const plugins = new LowCodePluginManager(editor).toProxy(); const plugins = new LowCodePluginManager(editor).toProxy();
editor.set('plugins' as any, plugins); editor.set('plugins' as any, plugins);

View File

@ -2,6 +2,7 @@ import {
projectSymbol, projectSymbol,
documentSymbol, documentSymbol,
nodeSymbol, nodeSymbol,
nodeChildrenSymbol,
designerSymbol, designerSymbol,
skeletonSymbol, skeletonSymbol,
editorSymbol, editorSymbol,
@ -13,6 +14,7 @@ export default {
projectSymbol, projectSymbol,
documentSymbol, documentSymbol,
nodeSymbol, nodeSymbol,
nodeChildrenSymbol,
skeletonSymbol, skeletonSymbol,
editorSymbol, editorSymbol,
designerSymbol, designerSymbol,

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer/'; import renderer from 'react-test-renderer';
import schema from '../fixtures/schema/basic'; import schema from '../fixtures/schema/basic';
import '../utils/react-env-init'; import '../utils/react-env-init';
import rendererFactory from '../../src/renderer/renderer'; import rendererFactory from '../../src/renderer/renderer';

View File

@ -2,6 +2,15 @@ import { hotkey, HotkeyCallback } from '@alilc/lowcode-editor-core';
import { Disposable } from '@alilc/lowcode-types'; import { Disposable } from '@alilc/lowcode-types';
export default class Hotkey { export default class Hotkey {
get callbacks() {
return hotkey.callBacks;
}
/**
* @deprecated
*/
get callBacks() {
return this.callbacks;
}
/** /**
* *
* @param combos ['command + s'] ['ctrl + shift + s'] * @param combos ['command + s'] ['ctrl + shift + s']