refactor: get Editor -> editor

This commit is contained in:
lihao.ylh 2021-10-25 14:14:24 +08:00
parent f2c3d6cc03
commit 2546a45382
10 changed files with 14 additions and 13 deletions

View File

@ -180,7 +180,7 @@ export class BoxResizingInstance extends Component<{
metaData.experimental.callbacks.onResizeEnd(e, node);
}
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
const npm = node?.componentMeta?.npm;
const selected =
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') ||

View File

@ -52,7 +52,7 @@ export class LiveEditing {
const targetElement = event.target as HTMLElement;
const { liveTextEditing } = node.componentMeta;
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
const npm = node?.componentMeta?.npm;
const selected =
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') || node?.componentMeta?.componentName || '';

View File

@ -62,7 +62,7 @@ export default class InstanceNodeSelector extends React.Component<IProps, IState
if (canClick && typeof node.select === 'function') {
node.select();
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
const npm = node?.componentMeta?.npm;
const selected =
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') ||

View File

@ -7,7 +7,7 @@ import clipboard from './clipboard';
function isInLiveEditing() {
if (globalContext.has(Editor)) {
return Boolean(
globalContext.get(Editor).get('designer')?.project?.simulator?.liveEditing?.editing,
globalContext.get('editor').get('designer')?.project?.simulator?.liveEditing?.editing,
);
}
}

View File

@ -115,7 +115,7 @@ export class History {
}
const cursor = this.session.cursor - 1;
this.go(cursor);
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
if (!editor) {
return;
}
@ -128,7 +128,7 @@ export class History {
}
const cursor = this.session.cursor + 1;
this.go(cursor);
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
if (!editor) {
return;
}

View File

@ -330,6 +330,7 @@ function getKeyInfo(combination: string, action?: string): KeyInfo {
*/
function fireCallback(callback: HotkeyCallback, e: KeyboardEvent, combo?: string, sequence?: string): void {
try {
// 这里不能简化成 editor单测时没有注册
const editor = globalContext.get(Editor);
const designer = editor.get('designer');
const node = designer?.currentSelection?.getNodes()?.[0];

View File

@ -116,12 +116,12 @@ export class DraggableLineView extends Component<{ panel: Panel }> {
}
// 抛出事件,对于有些需要 panel 插件随着 度变化进行再次渲染的由panel插件内部监听事件实现
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
editor?.emit('dockpane.drag', width);
}
onDragChange(type: 'start' | 'end') {
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
editor?.emit('dockpane.dragchange', type);
// builtinSimulator 屏蔽掉 鼠标事件
editor?.emit('designer.builtinSimulator.disabledEvents', type === 'start');
@ -185,7 +185,7 @@ export class TitledPanelView extends Component<{ panel: Panel; area?: string }>
if (!panel.inited) {
return null;
}
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
const panelName = area ? `${area}-${panel.name}` : panel.name;
editor?.emit('skeleton.panel.toggle', {
name: panelName || '',
@ -247,7 +247,7 @@ export class PanelView extends Component<{
if (!panel.inited) {
return null;
}
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
const panelName = area ? `${area}-${panel.name}` : panel.name;
editor?.emit('skeleton.panel.toggle', {
name: panelName || '',

View File

@ -23,7 +23,7 @@ export class Workbench extends Component<{ skeleton: Skeleton; config?: EditorCo
}
// componentDidCatch(error: any) {
// globalContext.get(Editor).emit('editor.skeleton.workbench.error', error);
// globalContext.get('editor').emit('editor.skeleton.workbench.error', error);
// }
render() {

View File

@ -16,7 +16,7 @@ import { IconLock, IconUnlock } from '../icons';
function emitOutlineEvent(type: string, treeNode: TreeNode, rest?: Record<string, unknown>) {
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
const node = treeNode?.node;
const npm = node?.componentMeta?.npm;
const selected =

View File

@ -66,7 +66,7 @@ export default class TreeView extends Component<{ tree: Tree }> {
}
} else {
selection.select(id);
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
const selectedNode = designer.currentSelection?.getNodes()?.[0];
const npm = selectedNode?.componentMeta?.npm;
const selected =