From eb3b5709c597276075ac928a1f0f2e82e6adad38 Mon Sep 17 00:00:00 2001 From: liangzr <1668890395@qq.com> Date: Fri, 7 Jul 2023 11:28:02 +0800 Subject: [PATCH 1/9] feat: listen for the logic of requestHandlersMap config update --- packages/plugin-designer/src/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/plugin-designer/src/index.tsx b/packages/plugin-designer/src/index.tsx index 54eda1365..90eefaaba 100644 --- a/packages/plugin-designer/src/index.tsx +++ b/packages/plugin-designer/src/index.tsx @@ -67,6 +67,11 @@ export default class DesignerPlugin extends PureComponent { + this.setState({ + requestHandlersMap, + }); + }); const { components, packages, extraEnvironment, utils } = assets; const state = { componentMetadatas: components || [], From 7b6181719e28b3b56e71f84266a550d14f8d9bba Mon Sep 17 00:00:00 2001 From: liujuping Date: Mon, 10 Jul 2023 15:36:34 +0800 Subject: [PATCH 2/9] feat(workspace): add multi foces-tracker in workspace mode --- packages/designer/src/builtin-simulator/host.ts | 4 ++-- .../designer/tests/builtin-simulator/host.test.ts | 5 +++++ packages/editor-core/src/utils/focus-tracker.ts | 12 ++++-------- .../editor-skeleton/src/layouts/left-float-pane.tsx | 4 ++-- packages/editor-skeleton/src/skeleton.ts | 7 ++++++- packages/workspace/src/layouts/left-float-pane.tsx | 4 ++-- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index cdb7642a5..5e6fc06a6 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -4,7 +4,6 @@ import { reaction, computed, getPublicPath, - focusTracker, engineConfig, globalLocale, IReactionPublic, @@ -519,7 +518,8 @@ export class BuiltinSimulatorHost implements ISimulatorHost { let editor: Editor; @@ -45,6 +48,8 @@ describe('Host 测试', () => { const innerPlugins = new LowCodePluginManager(pluginContextApiAssembler); const innerWorkspace = new InnerWorkspace(() => {}, {}); const workspace = new Workspace(innerWorkspace); + const innerSkeleton = new InnerSkeleton(editor); + editor.set('skeleton' as any, innerSkeleton); editor.set('innerHotkey', new InnerHotkey()) editor.set('setters', new Setters(new InnerSetters())); editor.set('innerPlugins' as any, innerPlugins); diff --git a/packages/editor-core/src/utils/focus-tracker.ts b/packages/editor-core/src/utils/focus-tracker.ts index cb88dfc56..23d509053 100644 --- a/packages/editor-core/src/utils/focus-tracker.ts +++ b/packages/editor-core/src/utils/focus-tracker.ts @@ -1,4 +1,8 @@ export class FocusTracker { + private actives: Focusable[] = []; + + private modals: Array<{ checkDown: (e: MouseEvent) => boolean; checkOpen: () => boolean }> = []; + mount(win: Window) { const checkDown = (e: MouseEvent) => { if (this.checkModalDown(e)) { @@ -16,14 +20,10 @@ export class FocusTracker { }; } - private actives: Focusable[] = []; - get first() { return this.actives[0]; } - private modals: Array<{ checkDown: (e: MouseEvent) => boolean; checkOpen: () => boolean }> = []; - addModal(checkDown: (e: MouseEvent) => boolean, checkOpen: () => boolean) { this.modals.push({ checkDown, @@ -154,7 +154,3 @@ export class Focusable { } } } - -export const focusTracker = new FocusTracker(); - -focusTracker.mount(window); diff --git a/packages/editor-skeleton/src/layouts/left-float-pane.tsx b/packages/editor-skeleton/src/layouts/left-float-pane.tsx index 0be5ea6c3..7df6993bb 100644 --- a/packages/editor-skeleton/src/layouts/left-float-pane.tsx +++ b/packages/editor-skeleton/src/layouts/left-float-pane.tsx @@ -1,6 +1,6 @@ import { Component, Fragment } from 'react'; import classNames from 'classnames'; -import { observer, Focusable, focusTracker } from '@alilc/lowcode-editor-core'; +import { observer, Focusable } from '@alilc/lowcode-editor-core'; import { Area } from '../area'; import { Panel } from '../widget/panel'; import { PanelConfig } from '../types'; @@ -31,7 +31,7 @@ export default class LeftFloatPane extends Component<{ area: Area { const target = e.target as HTMLElement; if (!target) { diff --git a/packages/editor-skeleton/src/skeleton.ts b/packages/editor-skeleton/src/skeleton.ts index 616e7f017..883643404 100644 --- a/packages/editor-skeleton/src/skeleton.ts +++ b/packages/editor-skeleton/src/skeleton.ts @@ -1,4 +1,4 @@ -import { action, makeObservable, obx, engineConfig, IEditor } from '@alilc/lowcode-editor-core'; +import { action, makeObservable, obx, engineConfig, IEditor, FocusTracker } from '@alilc/lowcode-editor-core'; import { DockConfig, PanelConfig, @@ -83,6 +83,8 @@ export interface ISkeleton extends Omit }> area.skeleton.editor.removeListener('designer.drag', triggerClose); }; - this.focusing = focusTracker.create({ + this.focusing = area.skeleton.focusTracker.create({ range: (e) => { const target = e.target as HTMLElement; if (!target) { From 7d7042f79921283e8d04aa5ff8d9aebe622bcc26 Mon Sep 17 00:00:00 2001 From: JackLian Date: Mon, 10 Jul 2023 16:51:39 +0800 Subject: [PATCH 3/9] chore(docs): publish 1.0.33 --- docs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/package.json b/docs/package.json index f8617eac0..269bd2df6 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-engine-docs", - "version": "1.0.32", + "version": "1.0.33", "description": "低代码引擎版本化文档", "license": "MIT", "files": [ From 38dc561b6a04e3267a5f20c175923f41765bd2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E6=9E=97?= Date: Tue, 11 Jul 2023 11:06:21 +0800 Subject: [PATCH 4/9] chore(code-gen): replace deprecated api --- .../src/cli/solutions/example-solution.ts | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/modules/code-generator/src/cli/solutions/example-solution.ts b/modules/code-generator/src/cli/solutions/example-solution.ts index 0314151c6..fd34c3678 100644 --- a/modules/code-generator/src/cli/solutions/example-solution.ts +++ b/modules/code-generator/src/cli/solutions/example-solution.ts @@ -635,18 +635,18 @@ export default function createHelloWorldProjectBuilder() { template: CodeGen.solutionParts.icejs.template, plugins: { components: [ - CodeGen.plugins.react.reactCommonDeps(), - CodeGen.plugins.common.esmodule({ fileType: 'jsx' }), - CodeGen.plugins.react.containerClass(), - CodeGen.plugins.react.containerInjectContext(), - CodeGen.plugins.react.containerInjectUtils(), - CodeGen.plugins.react.containerInjectDataSourceEngine(), - CodeGen.plugins.react.containerInjectI18n(), - CodeGen.plugins.react.containerInitState(), - CodeGen.plugins.react.containerLifeCycle(), - CodeGen.plugins.react.containerMethod(), + CodeGen.plugins.icejs.reactCommonDeps(), + CodeGen.plugins.common.esModule({ fileType: 'jsx' }), + CodeGen.plugins.icejs.containerClass(), + CodeGen.plugins.icejs.containerInjectContext(), + CodeGen.plugins.icejs.containerInjectUtils(), + CodeGen.plugins.icejs.containerInjectDataSourceEngine(), + CodeGen.plugins.icejs.containerInjectI18n(), + CodeGen.plugins.icejs.containerInitState(), + CodeGen.plugins.icejs.containerLifeCycle(), + CodeGen.plugins.icejs.containerMethod(), examplePlugin(), - CodeGen.plugins.react.jsx({ + CodeGen.plugins.icejs.jsx({ nodeTypeMapping: { Div: 'div', Component: 'div', @@ -657,18 +657,18 @@ export default function createHelloWorldProjectBuilder() { CodeGen.plugins.style.css(), ], pages: [ - CodeGen.plugins.react.reactCommonDeps(), - CodeGen.plugins.common.esmodule({ fileType: 'jsx' }), - CodeGen.plugins.react.containerClass(), - CodeGen.plugins.react.containerInjectContext(), - CodeGen.plugins.react.containerInjectUtils(), - CodeGen.plugins.react.containerInjectDataSourceEngine(), - CodeGen.plugins.react.containerInjectI18n(), - CodeGen.plugins.react.containerInitState(), - CodeGen.plugins.react.containerLifeCycle(), - CodeGen.plugins.react.containerMethod(), + CodeGen.plugins.icejs.reactCommonDeps(), + CodeGen.plugins.common.esModule({ fileType: 'jsx' }), + CodeGen.plugins.icejs.containerClass(), + CodeGen.plugins.icejs.containerInjectContext(), + CodeGen.plugins.icejs.containerInjectUtils(), + CodeGen.plugins.icejs.containerInjectDataSourceEngine(), + CodeGen.plugins.icejs.containerInjectI18n(), + CodeGen.plugins.icejs.containerInitState(), + CodeGen.plugins.icejs.containerLifeCycle(), + CodeGen.plugins.icejs.containerMethod(), examplePlugin(), - CodeGen.plugins.react.jsx({ + CodeGen.plugins.icejs.jsx({ nodeTypeMapping: { Div: 'div', Component: 'div', @@ -679,13 +679,13 @@ export default function createHelloWorldProjectBuilder() { CodeGen.plugins.style.css(), ], router: [ - CodeGen.plugins.common.esmodule(), + CodeGen.plugins.common.esModule(), CodeGen.solutionParts.icejs.plugins.router(), ], entry: [CodeGen.solutionParts.icejs.plugins.entry()], constants: [CodeGen.plugins.project.constants()], utils: [ - CodeGen.plugins.common.esmodule(), + CodeGen.plugins.common.esModule(), CodeGen.plugins.project.utils('react'), ], i18n: [CodeGen.plugins.project.i18n()], From 4e24d512d12f8f9aa77261ba63d4345d43d6d31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E6=9E=97?= Date: Tue, 11 Jul 2023 11:15:52 +0800 Subject: [PATCH 5/9] =?UTF-8?q?chore(code-gen):=20icejs=E3=80=81icejs3=20s?= =?UTF-8?q?olutions=20plugins.components=20add=20containerInjectConstants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/code-generator/src/solutions/icejs.ts | 1 + modules/code-generator/src/solutions/icejs3.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/code-generator/src/solutions/icejs.ts b/modules/code-generator/src/solutions/icejs.ts index 7dc44f4be..1149098ec 100644 --- a/modules/code-generator/src/solutions/icejs.ts +++ b/modules/code-generator/src/solutions/icejs.ts @@ -45,6 +45,7 @@ export default function createIceJsProjectBuilder( containerInjectUtils(), containerInjectDataSourceEngine(), containerInjectI18n(), + containerInjectConstants(), containerInitState(), containerLifeCycle(), containerMethod(), diff --git a/modules/code-generator/src/solutions/icejs3.ts b/modules/code-generator/src/solutions/icejs3.ts index c6870dfd0..a8622e74a 100644 --- a/modules/code-generator/src/solutions/icejs3.ts +++ b/modules/code-generator/src/solutions/icejs3.ts @@ -45,6 +45,7 @@ export default function createIceJsProjectBuilder( containerInjectUtils(), containerInjectDataSourceEngine(), containerInjectI18n(), + containerInjectConstants(), containerInitState(), containerLifeCycle(), containerMethod(), From 7decc3a8db1bd81b09a51c36e50c3099b9f394d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E6=9E=97?= Date: Tue, 11 Jul 2023 11:16:28 +0800 Subject: [PATCH 6/9] chore(code-gen): template sync icejs --- modules/code-generator/src/cli/solutions/example-solution.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/code-generator/src/cli/solutions/example-solution.ts b/modules/code-generator/src/cli/solutions/example-solution.ts index fd34c3678..bfb9d079b 100644 --- a/modules/code-generator/src/cli/solutions/example-solution.ts +++ b/modules/code-generator/src/cli/solutions/example-solution.ts @@ -637,11 +637,13 @@ export default function createHelloWorldProjectBuilder() { components: [ CodeGen.plugins.icejs.reactCommonDeps(), CodeGen.plugins.common.esModule({ fileType: 'jsx' }), + CodeGen.plugins.common.styleImport(), CodeGen.plugins.icejs.containerClass(), CodeGen.plugins.icejs.containerInjectContext(), CodeGen.plugins.icejs.containerInjectUtils(), CodeGen.plugins.icejs.containerInjectDataSourceEngine(), CodeGen.plugins.icejs.containerInjectI18n(), + CodeGen.plugins.icejs.containerInjectConstants(), CodeGen.plugins.icejs.containerInitState(), CodeGen.plugins.icejs.containerLifeCycle(), CodeGen.plugins.icejs.containerMethod(), @@ -659,11 +661,13 @@ export default function createHelloWorldProjectBuilder() { pages: [ CodeGen.plugins.icejs.reactCommonDeps(), CodeGen.plugins.common.esModule({ fileType: 'jsx' }), + CodeGen.plugins.common.styleImport(), CodeGen.plugins.icejs.containerClass(), CodeGen.plugins.icejs.containerInjectContext(), CodeGen.plugins.icejs.containerInjectUtils(), CodeGen.plugins.icejs.containerInjectDataSourceEngine(), CodeGen.plugins.icejs.containerInjectI18n(), + CodeGen.plugins.icejs.containerInjectConstants(), CodeGen.plugins.icejs.containerInitState(), CodeGen.plugins.icejs.containerLifeCycle(), CodeGen.plugins.icejs.containerMethod(), From 19935cfc93de111e82691502eaf4f186a84cae37 Mon Sep 17 00:00:00 2001 From: liujuping Date: Tue, 11 Jul 2023 16:14:55 +0800 Subject: [PATCH 7/9] feat: add new cache from diff origin component --- packages/renderer-core/src/hoc/leaf.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/renderer-core/src/hoc/leaf.tsx b/packages/renderer-core/src/hoc/leaf.tsx index bb81e88e3..1ff91cb14 100644 --- a/packages/renderer-core/src/hoc/leaf.tsx +++ b/packages/renderer-core/src/hoc/leaf.tsx @@ -193,8 +193,8 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, { getNode, }); - if (curDocumentId && cache.component.has(componentCacheId)) { - return cache.component.get(componentCacheId); + if (curDocumentId && cache.component.has(componentCacheId) && (cache.component.get(componentCacheId).Comp === Comp)) { + return cache.component.get(componentCacheId).LeafWrapper; } class LeafHoc extends Component { @@ -590,7 +590,10 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, { LeafWrapper.displayName = (Comp as any).displayName; - cache.component.set(componentCacheId, LeafWrapper); + cache.component.set(componentCacheId, { + LeafWrapper, + Comp, + }); return LeafWrapper; } \ No newline at end of file From 2d98f1c9b5d8c8bbda5100ddecb83ceb08943b36 Mon Sep 17 00:00:00 2001 From: AndyJin Date: Wed, 12 Jul 2023 11:27:37 +0800 Subject: [PATCH 8/9] fix: the action of history would not update outline tree --- packages/plugin-outline-pane/src/controllers/tree.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/plugin-outline-pane/src/controllers/tree.ts b/packages/plugin-outline-pane/src/controllers/tree.ts index 463c7919f..ca5a43c55 100644 --- a/packages/plugin-outline-pane/src/controllers/tree.ts +++ b/packages/plugin-outline-pane/src/controllers/tree.ts @@ -30,6 +30,10 @@ export class Tree { treeNode?.notifyExpandableChanged(); }); + doc?.history.onChangeCursor(() => { + this.root?.notifyExpandableChanged(); + }); + doc?.onChangeNodeProp((info: IPublicTypePropChangeOptions) => { const { node, key } = info; if (key === '___title___') { From aa1bb1c0d720d972e64049f92358456b14069310 Mon Sep 17 00:00:00 2001 From: liujuping Date: Wed, 12 Jul 2023 18:01:45 +0800 Subject: [PATCH 9/9] feat: add config.workspaceEmptyComponent --- packages/editor-core/src/config.ts | 4 ++++ packages/workspace/src/layouts/workbench.tsx | 18 +++++++++++++++++- packages/workspace/src/workspace.ts | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/editor-core/src/config.ts b/packages/editor-core/src/config.ts index c325c2bb8..85e609780 100644 --- a/packages/editor-core/src/config.ts +++ b/packages/editor-core/src/config.ts @@ -155,6 +155,10 @@ const VALID_ENGINE_OPTIONS = { description: '是否开启应用级设计模式', default: false, }, + workspaceEmptyComponent: { + type: 'function', + description: '应用级设计模式下,窗口为空时展示的占位组件', + }, }; const getStrictModeValue = (engineOptions: IPublicTypeEngineOptions, defaultValue: boolean): boolean => { diff --git a/packages/workspace/src/layouts/workbench.tsx b/packages/workspace/src/layouts/workbench.tsx index 0c69f9717..08d6dc1a9 100644 --- a/packages/workspace/src/layouts/workbench.tsx +++ b/packages/workspace/src/layouts/workbench.tsx @@ -1,5 +1,5 @@ import { Component } from 'react'; -import { TipContainer, observer } from '@alilc/lowcode-editor-core'; +import { TipContainer, engineConfig, observer } from '@alilc/lowcode-editor-core'; import { WindowView } from '../view/window-view'; import classNames from 'classnames'; import TopArea from './top-area'; @@ -21,17 +21,29 @@ export class Workbench extends Component<{ components?: PluginClassSet; className?: string; topAreaItemClassName?: string; +}, { + workspaceEmptyComponent: any; }> { constructor(props: any) { super(props); const { config, components, workspace } = this.props; const { skeleton } = workspace; skeleton.buildFromConfig(config, components); + engineConfig.onGot('workspaceEmptyComponent', (workspaceEmptyComponent) => { + this.setState({ + workspaceEmptyComponent, + }); + }); + this.state = { + workspaceEmptyComponent: engineConfig.get('workspaceEmptyComponent'), + }; } render() { const { workspace, className, topAreaItemClassName } = this.props; const { skeleton } = workspace; + const WorkspaceEmptyComponent = this.state.workspaceEmptyComponent; + return (
@@ -53,6 +65,10 @@ export class Workbench extends Component<{ /> )) } + + { + !workspace.windows.length && WorkspaceEmptyComponent ? : null + }
diff --git a/packages/workspace/src/workspace.ts b/packages/workspace/src/workspace.ts index bedae8680..6c35d8b35 100644 --- a/packages/workspace/src/workspace.ts +++ b/packages/workspace/src/workspace.ts @@ -199,7 +199,7 @@ export class Workspace implements IWorkspace { this.windows.splice(index, 1); if (this.window === window) { this.window = this.windows[index] || this.windows[index + 1] || this.windows[index - 1]; - if (this.window.sleep) { + if (this.window?.sleep) { this.window.init(); } this.emitChangeActiveWindow();