diff --git a/packages/designer/jest.config.js b/packages/designer/jest.config.js index 3684a48ac..0d0f7f8f8 100644 --- a/packages/designer/jest.config.js +++ b/packages/designer/jest.config.js @@ -22,6 +22,7 @@ const jestConfig = { // testMatch: ['**/selection.test.ts'], // testMatch: ['**/plugin/sequencify.test.ts'], // testMatch: ['**/builtin-simulator/utils/parse-metadata.test.ts'], + // testMatch: ['**/setting/setting-top-entry.test.ts'], transformIgnorePatterns: [ `/node_modules/(?!${esModules})/`, ], diff --git a/packages/designer/src/designer/dragon.ts b/packages/designer/src/designer/dragon.ts index 5c4d0648d..f96b667b1 100644 --- a/packages/designer/src/designer/dragon.ts +++ b/packages/designer/src/designer/dragon.ts @@ -13,7 +13,7 @@ import { import { setNativeSelection, cursor } from '@alilc/lowcode-utils'; import { INode, Node } from '../document'; import { ISimulatorHost, isSimulatorHost } from '../simulator'; -import { IDesigner } from './designer'; +import type { IDesigner } from './designer'; import { makeEventsHandler } from '../utils/misc'; export interface ILocateEvent extends IPublicModelLocateEvent { diff --git a/packages/designer/src/designer/setting/setting-entry-type.ts b/packages/designer/src/designer/setting/setting-entry-type.ts index 1aee9016e..5cbe232ab 100644 --- a/packages/designer/src/designer/setting/setting-entry-type.ts +++ b/packages/designer/src/designer/setting/setting-entry-type.ts @@ -1,7 +1,7 @@ -import { IPublicApiSetters, IPublicModelEditor } from '@alilc/lowcode-types'; -import { IDesigner } from '../designer'; -import { INode } from '../../document'; -import { ISettingField } from './setting-field'; +import type { IPublicApiSetters, IPublicModelEditor } from '@alilc/lowcode-types'; +import type { IDesigner } from '../designer'; +import type { INode } from '../../document'; +import type { ISettingField } from './setting-field'; export interface ISettingEntry { readonly designer: IDesigner | undefined; diff --git a/packages/designer/src/designer/setting/setting-field.ts b/packages/designer/src/designer/setting/setting-field.ts index 1a63fb7a4..87415dd98 100644 --- a/packages/designer/src/designer/setting/setting-field.ts +++ b/packages/designer/src/designer/setting/setting-field.ts @@ -1,4 +1,3 @@ -import { ReactNode } from 'react'; import { IPublicTypeTitleContent, IPublicTypeSetterType, @@ -7,18 +6,15 @@ import { IPublicTypeFieldConfig, IPublicTypeCustomView, IPublicTypeDisposable, - IPublicModelSettingField, - IBaseModelSettingField, } from '@alilc/lowcode-types'; import type { IPublicTypeSetValueOptions, } from '@alilc/lowcode-types'; import { Transducer } from './utils'; -import { ISettingPropEntry, SettingPropEntry } from './setting-prop-entry'; +import { SettingPropEntry } from './setting-prop-entry'; import { computed, obx, makeObservable, action, untracked, intl } from '@alilc/lowcode-editor-core'; import { cloneDeep, isCustomView, isDynamicSetter, isJSExpression } from '@alilc/lowcode-utils'; -import { ISettingTopEntry } from './setting-top-entry'; -import { IComponentMeta, INode } from '@alilc/lowcode-designer'; +import type { ISettingTopEntry } from './setting-top-entry'; function getSettingFieldCollectorKey(parent: ISettingTopEntry | ISettingField, config: IPublicTypeFieldConfig) { let cur = parent; @@ -32,53 +28,7 @@ function getSettingFieldCollectorKey(parent: ISettingTopEntry | ISettingField, c return path.join('.'); } -export interface ISettingField extends ISettingPropEntry, Omit, 'setValue' | 'key' | 'node'> { - readonly isSettingField: true; - - readonly isRequired: boolean; - - readonly isGroup: boolean; - - extraProps: IPublicTypeFieldExtraProps; - - get items(): Array; - - get title(): string | ReactNode | undefined; - - get setter(): IPublicTypeSetterType | null; - - get expanded(): boolean; - - get valueState(): number; - - setExpanded(value: boolean): void; - - purge(): void; - - setValue( - val: any, - isHotValue?: boolean, - force?: boolean, - extraOptions?: IPublicTypeSetValueOptions, - ): void; - - clearValue(): void; - - valueChange(options: IPublicTypeSetValueOptions): void; - - createField(config: IPublicTypeFieldConfig): ISettingField; - - onEffect(action: () => void): IPublicTypeDisposable; - - internalToShellField(): IPublicModelSettingField; -} - -export class SettingField extends SettingPropEntry implements ISettingField { +export class SettingField extends SettingPropEntry { readonly isSettingField = true; readonly isRequired: boolean; @@ -321,3 +271,5 @@ export class SettingField extends SettingPropEntry implements ISettingField { export function isSettingField(obj: any): obj is ISettingField { return obj && obj.isSettingField; } + +export type ISettingField = typeof SettingField; diff --git a/packages/designer/src/designer/setting/setting-prop-entry.ts b/packages/designer/src/designer/setting/setting-prop-entry.ts index d6904f0c8..6cce4cddc 100644 --- a/packages/designer/src/designer/setting/setting-prop-entry.ts +++ b/packages/designer/src/designer/setting/setting-prop-entry.ts @@ -1,12 +1,12 @@ import { obx, computed, makeObservable, runInAction, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core'; import { GlobalEvent, IPublicApiSetters, IPublicModelEditor, IPublicModelSettingField, IPublicTypeFieldExtraProps, IPublicTypeSetValueOptions } from '@alilc/lowcode-types'; -import { uniqueId, isJSExpression } from '@alilc/lowcode-utils'; -import { ISettingEntry } from './setting-entry-type'; -import { INode } from '../../document'; +import { uniqueId, isJSExpression, isSettingField } from '@alilc/lowcode-utils'; +import type { ISettingEntry } from './setting-entry-type'; +import type { INode } from '../../document'; import type { IComponentMeta } from '../../component-meta'; -import { IDesigner } from '../designer'; -import { ISettingTopEntry } from './setting-top-entry'; -import { ISettingField, isSettingField } from './setting-field'; +import type { IDesigner } from '../designer'; +import type { ISettingTopEntry } from './setting-top-entry'; +import type { ISettingField } from './setting-field'; export interface ISettingPropEntry extends ISettingEntry { readonly isGroup: boolean; diff --git a/packages/designer/src/designer/setting/setting-top-entry.ts b/packages/designer/src/designer/setting/setting-top-entry.ts index 85be74b7f..3a1739788 100644 --- a/packages/designer/src/designer/setting/setting-top-entry.ts +++ b/packages/designer/src/designer/setting/setting-top-entry.ts @@ -1,11 +1,12 @@ import { IPublicTypeCustomView, IPublicModelEditor, IPublicModelSettingTopEntry, IPublicApiSetters } from '@alilc/lowcode-types'; import { isCustomView } from '@alilc/lowcode-utils'; -import { computed, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core'; -import { ISettingEntry } from './setting-entry-type'; -import { ISettingField, SettingField } from './setting-field'; -import { INode } from '../../document'; +import { computed, IEventBus, createModuleEventBus, obx, makeObservable } from '@alilc/lowcode-editor-core'; +import { SettingField } from './setting-field'; +import type { ISettingEntry } from './setting-entry-type'; +import type { ISettingField } from './setting-field'; +import type { INode } from '../../document'; import type { IComponentMeta } from '../../component-meta'; -import { IDesigner } from '../designer'; +import type { IDesigner } from '../designer'; function generateSessionId(nodes: INode[]) { return nodes @@ -14,33 +15,17 @@ function generateSessionId(nodes: INode[]) { .join(','); } -export interface ISettingTopEntry extends ISettingEntry, IPublicModelSettingTopEntry< +export interface ISettingTopEntry extends SettingTopEntry {} + +export class SettingTopEntry implements ISettingEntry, IPublicModelSettingTopEntry< INode, ISettingField > { - readonly top: ISettingTopEntry; - - readonly parent: ISettingTopEntry; - - readonly path: never[]; - - items: Array; - - componentMeta: IComponentMeta | null; - - purge(): void; - - getExtraPropValue(propName: string): void; - - setExtraPropValue(propName: string, value: any): void; -} - -export class SettingTopEntry implements ISettingTopEntry { private emitter: IEventBus = createModuleEventBus('SettingTopEntry'); - private _items: Array = []; + private _items: Array = []; - private _componentMeta: IComponentMeta | null = null; + private _componentMeta: IComponentMeta | null | undefined = null; private _isSame = true; @@ -75,7 +60,7 @@ export class SettingTopEntry implements ISettingTopEntry { } get isLocked(): boolean { - return this.first.isLocked; + return this.first?.isLocked ?? false; } /** @@ -87,7 +72,11 @@ export class SettingTopEntry implements ISettingTopEntry { readonly id: string; - readonly first: INode; + @computed get first(): INode | null { + return this._first; + } + + @obx.ref _first: INode | null; readonly designer: IDesigner | undefined; @@ -96,12 +85,14 @@ export class SettingTopEntry implements ISettingTopEntry { disposeFunctions: any[] = []; constructor(readonly editor: IPublicModelEditor, readonly nodes: INode[]) { + makeObservable(this); + if (!Array.isArray(nodes) || nodes.length < 1) { throw new ReferenceError('nodes should not be empty'); } this.id = generateSessionId(nodes); - this.first = nodes[0]; - this.designer = this.first.document?.designer; + this._first = nodes[0]; + this.designer = this._first.document?.designer; this.setters = editor.get('setters') as IPublicApiSetters; // setups @@ -116,7 +107,7 @@ export class SettingTopEntry implements ISettingTopEntry { private setupComponentMeta() { // todo: enhance compile a temp configure.compiled const { first } = this; - const meta = first.componentMeta; + const meta = first?.componentMeta; const l = this.nodes.length; let theSame = true; for (let i = 1; i < l; i++) { @@ -160,7 +151,7 @@ export class SettingTopEntry implements ISettingTopEntry { /** * 获取当前属性值 */ - @computed getValue(): any { + getValue(): any { return this.first?.propsData; } @@ -202,14 +193,14 @@ export class SettingTopEntry implements ISettingTopEntry { * 获取子级属性值 */ getPropValue(propName: string | number): any { - return this.first.getProp(propName.toString(), true)?.getValue(); + return this.first?.getProp(propName.toString(), true)?.getValue(); } /** * 获取顶层附属属性值 */ getExtraPropValue(propName: string) { - return this.first.getExtraProp(propName, false)?.getValue(); + return this.first?.getExtraProp(propName, false)?.getValue(); } /** @@ -244,8 +235,9 @@ export class SettingTopEntry implements ISettingTopEntry { this.disposeItems(); this._settingFieldMap = {}; this.emitter.removeAllListeners(); - this.disposeFunctions.forEach(f => f()); + this.disposeFunctions.forEach(f => f?.()); this.disposeFunctions = []; + this._first = null; } getProp(propName: string | number) { @@ -274,7 +266,7 @@ export class SettingTopEntry implements ISettingTopEntry { } getPage() { - return this.first.document; + return this.first?.document; } /** @@ -292,6 +284,7 @@ export class SettingTopEntry implements ISettingTopEntry { interface Purgeable { purge(): void; } + function isPurgeable(obj: any): obj is Purgeable { return obj && obj.purge; } diff --git a/packages/designer/src/document/document-model.ts b/packages/designer/src/document/document-model.ts index 2938395a9..dd9258fc1 100644 --- a/packages/designer/src/document/document-model.ts +++ b/packages/designer/src/document/document-model.ts @@ -37,10 +37,10 @@ import { isDragNodeDataObject, isNode, } from '@alilc/lowcode-utils'; -import { IProject } from '../project'; -import { ISimulatorHost } from '../simulator'; +import type { IProject } from '../project'; +import type { ISimulatorHost } from '../simulator'; import type { IComponentMeta } from '../component-meta'; -import { IDesigner, IHistory } from '../designer'; +import type { IDesigner, IHistory } from '../designer'; import { insertChildren, insertChild, IRootNode } from './node/node'; import type { INode } from './node/node'; import { Selection, ISelection } from './selection'; diff --git a/packages/designer/src/document/document-view.tsx b/packages/designer/src/document/document-view.tsx index c6dbe76a8..ec588e223 100644 --- a/packages/designer/src/document/document-view.tsx +++ b/packages/designer/src/document/document-view.tsx @@ -1,7 +1,7 @@ import { Component } from 'react'; import classNames from 'classnames'; import { observer } from '@alilc/lowcode-editor-core'; -import { DocumentModel, IDocumentModel } from './document-model'; +import type { IDocumentModel } from './document-model'; import { BuiltinSimulatorHostView } from '../builtin-simulator'; @observer diff --git a/packages/designer/src/document/history.ts b/packages/designer/src/document/history.ts index ca288c03a..10695e235 100644 --- a/packages/designer/src/document/history.ts +++ b/packages/designer/src/document/history.ts @@ -1,7 +1,7 @@ import { reaction, untracked, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core'; import { IPublicTypeNodeSchema, IPublicModelHistory, IPublicTypeDisposable } from '@alilc/lowcode-types'; import { Logger } from '@alilc/lowcode-utils'; -import { IDocumentModel } from '../designer'; +import type { IDocumentModel } from '../designer'; const logger = new Logger({ level: 'warn', bizName: 'history' }); diff --git a/packages/designer/src/document/node/node-children.ts b/packages/designer/src/document/node/node-children.ts index b7f03d9fe..0f0c4a459 100644 --- a/packages/designer/src/document/node/node-children.ts +++ b/packages/designer/src/document/node/node-children.ts @@ -1,5 +1,5 @@ import { obx, computed, makeObservable, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core'; -import { Node, INode } from './node'; +import type { INode } from './node'; import { IPublicTypeNodeData, IPublicModelNodeChildren, IPublicEnumTransformStage, IPublicTypeDisposable } from '@alilc/lowcode-types'; import { shallowEqual, compatStage, isNodeSchema } from '@alilc/lowcode-utils'; import { foreachReverse } from '../../utils/tree'; @@ -7,7 +7,7 @@ import { NodeRemoveOptions } from '../../types'; export interface IOnChangeOptions { type: string; - node: Node; + node: INode; } export class NodeChildren implements Omit, @@ -80,7 +80,7 @@ export class NodeChildren implements Omit, const originChildren = this.children.slice(); this.children.forEach((child) => child.internalSetParent(null)); - const children = new Array(data.length); + const children = new Array(data.length); for (let i = 0, l = data.length; i < l; i++) { const child = originChildren[i]; const item = data[i]; @@ -91,6 +91,7 @@ export class NodeChildren implements Omit, node.import(item); } else { node = this.owner.document?.createNode(item); + child?.purge(); } if (node) { @@ -98,6 +99,10 @@ export class NodeChildren implements Omit, } } + for (let i = data.length; i < originChildren.length; i++) { + originChildren[i].purge(); + } + this.children = children; this.internalInitParent(); if (!shallowEqual(children, originChildren)) { @@ -164,14 +169,14 @@ export class NodeChildren implements Omit, if (node.isParentalNode) { foreachReverse( node.children!, - (subNode: Node) => { + (subNode: INode) => { subNode.remove(useMutator, purge, options); }, (iterable, idx) => (iterable as NodeChildren).get(idx), ); foreachReverse( node.slots, - (slotNode: Node) => { + (slotNode: INode) => { slotNode.remove(useMutator, purge); }, (iterable, idx) => (iterable as [])[idx], @@ -302,10 +307,17 @@ export class NodeChildren implements Omit, * */ splice(start: number, deleteCount: number, node?: INode): INode[] { + let removedNode; if (node) { - return this.children.splice(start, deleteCount, node); + removedNode = this.children.splice(start, deleteCount, node); + node.internalSetParent(this.owner); + } else { + removedNode = this.children.splice(start, deleteCount); } - return this.children.splice(start, deleteCount); + + removedNode.forEach(d => d?.purge()); + + return removedNode; } /** diff --git a/packages/designer/src/document/node/node.ts b/packages/designer/src/document/node/node.ts index 0b698831e..5a43fc15c 100644 --- a/packages/designer/src/document/node/node.ts +++ b/packages/designer/src/document/node/node.ts @@ -18,11 +18,11 @@ import { IBaseModelNode, } from '@alilc/lowcode-types'; import { compatStage, isDOMText, isJSExpression, isNode, isNodeSchema } from '@alilc/lowcode-utils'; -import { ISettingTopEntry } from '@alilc/lowcode-designer'; +import type { ISettingTopEntry } from '@alilc/lowcode-designer'; import { Props, getConvertedExtraKey, IProps } from './props/props'; import type { IDocumentModel } from '../document-model'; import { NodeChildren, INodeChildren } from './node-children'; -import { IProp, Prop } from './props/prop'; +import type { IProp } from './props/prop'; import type { IComponentMeta } from '../../component-meta'; import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group'; import type { IExclusiveGroup } from './exclusive-group'; @@ -197,7 +197,7 @@ export class Node isInited = false; - _settingEntry: ISettingTopEntry; + _settingEntry?: ISettingTopEntry; get settingEntry(): ISettingTopEntry { if (this._settingEntry) return this._settingEntry; @@ -495,7 +495,7 @@ export class Node } } - internalSetSlotFor(slotFor: Prop | null | undefined) { + internalSetSlotFor(slotFor: IProp | null | undefined) { this._slotFor = slotFor; } @@ -987,7 +987,8 @@ export class Node this.autoruns?.forEach((dispose) => dispose()); this.props.purge(); this.settingEntry?.purge(); - // this.document.destroyNode(this); + this.children?.purge(); + this._settingEntry = undefined; } internalPurgeStart() { diff --git a/packages/designer/tests/designer/setting/setting-top-entry.test.ts b/packages/designer/tests/designer/setting/setting-top-entry.test.ts index 23a42c2af..e5234690c 100644 --- a/packages/designer/tests/designer/setting/setting-top-entry.test.ts +++ b/packages/designer/tests/designer/setting/setting-top-entry.test.ts @@ -1,8 +1,9 @@ import '../../fixtures/window'; -import { Editor, Setters } from '@alilc/lowcode-editor-core'; +import { Editor, Setters, reaction } from '@alilc/lowcode-editor-core'; import { Node } from '../../../src/document/node/node'; import { Designer } from '../../../src/designer/designer'; import settingSchema from '../../fixtures/schema/setting'; +import { SettingTopEntry } from '../../../src/designer/setting/setting-top-entry'; import divMeta from '../../fixtures/component-metadata/div'; import { shellModelFactory } from '../../../../engine/src/modules/shell-model-factory'; @@ -109,6 +110,26 @@ describe('setting-top-entry 测试', () => { expect(settingEntry.items).toHaveLength(0); }); + it('should notify when _first is set to null', (done) => { + // 创建一个简单的INode数组用于初始化SettingTopEntry实例 + const nodes = [{ id: '1', propsData: {} }, { id: '2', propsData: {} }]; + const entry = new SettingTopEntry(editor as any, nodes as any); + + // 使用MobX的reaction来观察_first属性的变化 + const dispose = reaction( + () => entry.first, + (first) => { + if (first === null) { + dispose(); // 清理reaction监听 + done(); // 结束测试 + } + } + ); + + // 执行purge方法,期望_first被设置为null,触发reaction回调 + entry.purge(); + }); + it('vision 兼容测试', () => { designer.createComponentMeta(divMeta); designer.project.open(settingSchema); diff --git a/packages/designer/tests/document/node/node-children.test.ts b/packages/designer/tests/document/node/node-children.test.ts index 1aa7e3ccb..b5b2744ff 100644 --- a/packages/designer/tests/document/node/node-children.test.ts +++ b/packages/designer/tests/document/node/node-children.test.ts @@ -111,6 +111,16 @@ describe('NodeChildren 方法测试', () => { expect(children.length).toBe(2); }); + it('split add node and update node parent', () => { + const firstBtn = doc.getNode('node_k1ow3cbn')!; + const { children } = firstBtn.parent!; + const node = doc.createNode({ componentName: 'Button' }); + + children.splice(0, 0, node); + + expect(node.parent).toBe(firstBtn.parent); + }) + it('map', () => { const firstBtn = doc.getNode('node_k1ow3cbn')!; const { children } = firstBtn.parent!; diff --git a/packages/editor-core/src/hotkey.ts b/packages/editor-core/src/hotkey.ts index 496cec251..e3482ab4d 100644 --- a/packages/editor-core/src/hotkey.ts +++ b/packages/editor-core/src/hotkey.ts @@ -541,8 +541,6 @@ export class Hotkey implements Omit { } private handleKeyEvent(e: KeyboardEvent): void { - console.log(e); - // debugger; if (!this.isActivate) { return; } diff --git a/packages/editor-skeleton/src/components/settings/main.ts b/packages/editor-skeleton/src/components/settings/main.ts index 6cc672c90..3cca2c861 100644 --- a/packages/editor-skeleton/src/components/settings/main.ts +++ b/packages/editor-skeleton/src/components/settings/main.ts @@ -1,7 +1,7 @@ -import { Node, Designer, Selection, SettingTopEntry } from '@alilc/lowcode-designer'; +import { INode, IDesigner, Selection, SettingTopEntry } from '@alilc/lowcode-designer'; import { Editor, obx, computed, makeObservable, action, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core'; -function generateSessionId(nodes: Node[]) { +function generateSessionId(nodes: INode[]) { return nodes .map((node) => node.id) .sort() @@ -29,7 +29,11 @@ export class SettingsMain { private disposeListener: () => void; - private designer?: Designer; + private _designer?: IDesigner; + + get designer(): IDesigner | undefined { + return this._designer; + } constructor(readonly editor: Editor) { makeObservable(this); @@ -49,12 +53,12 @@ export class SettingsMain { this.editor.removeListener('designer.selection.change', setupSelection); }; const designer = await this.editor.onceGot('designer'); - this.designer = designer; + this._designer = designer; setupSelection(designer.currentSelection); } @action - private setup(nodes: Node[]) { + private setup(nodes: INode[]) { // check nodes change const sessionId = generateSessionId(nodes); if (sessionId === this._sessionId) { @@ -66,15 +70,15 @@ export class SettingsMain { return; } - if (!this.designer) { - this.designer = nodes[0].document.designer; + if (!this._designer) { + this._designer = nodes[0].document.designer; } // 当节点只有一个时,复用 node 上挂载的 settingEntry,不会产生平行的两个实例,这样在整个系统中对 // 某个节点操作的 SettingTopEntry 只有一个实例,后续的 getProp() 也会拿到相同的 SettingField 实例 if (nodes.length === 1) { this._settings = nodes[0].settingEntry; } else { - this._settings = this.designer.createSettingEntry(nodes); + this._settings = this._designer.createSettingEntry(nodes); } } diff --git a/packages/editor-skeleton/src/components/settings/settings-pane.tsx b/packages/editor-skeleton/src/components/settings/settings-pane.tsx index 1561bf8bb..4bb23d292 100644 --- a/packages/editor-skeleton/src/components/settings/settings-pane.tsx +++ b/packages/editor-skeleton/src/components/settings/settings-pane.tsx @@ -1,9 +1,9 @@ import { Component, MouseEvent, Fragment, ReactNode } from 'react'; import { shallowIntl, observer, obx, engineConfig, runInAction } from '@alilc/lowcode-editor-core'; -import { createContent, isJSSlot, isSetterConfig, shouldUseVariableSetter } from '@alilc/lowcode-utils'; +import { createContent, isJSSlot, isSetterConfig, shouldUseVariableSetter, isSettingField } from '@alilc/lowcode-utils'; import { Skeleton, Stage } from '@alilc/lowcode-editor-skeleton'; import { IPublicApiSetters, IPublicTypeCustomView, IPublicTypeDynamicProps } from '@alilc/lowcode-types'; -import { ISettingEntry, IComponentMeta, ISettingField, isSettingField, ISettingTopEntry } from '@alilc/lowcode-designer'; +import type { ISettingEntry, IComponentMeta, ISettingField, ISettingTopEntry } from '@alilc/lowcode-designer'; import { createField } from '../field'; import PopupService, { PopupPipe } from '../popup'; import { SkeletonContext } from '../../context'; diff --git a/packages/editor-skeleton/src/components/settings/settings-primary-pane.tsx b/packages/editor-skeleton/src/components/settings/settings-primary-pane.tsx index 747a2ea1d..5231d9f20 100644 --- a/packages/editor-skeleton/src/components/settings/settings-primary-pane.tsx +++ b/packages/editor-skeleton/src/components/settings/settings-primary-pane.tsx @@ -1,14 +1,14 @@ import React, { Component } from 'react'; import { Tab, Breadcrumb } from '@alifd/next'; import { Title, observer, Editor, obx, globalContext, engineConfig, makeObservable } from '@alilc/lowcode-editor-core'; -import { Node, SettingField, isSettingField, INode } from '@alilc/lowcode-designer'; +import type { ISettingField, INode } from '@alilc/lowcode-designer'; import classNames from 'classnames'; import { SettingsMain } from './main'; import { SettingsPane } from './settings-pane'; import { StageBox } from '../stage-box'; import { SkeletonContext } from '../../context'; import { intl } from '../../locale'; -import { createIcon } from '@alilc/lowcode-utils'; +import { createIcon, isSettingField } from '@alilc/lowcode-utils'; interface ISettingsPrimaryPaneProps { engineEditor: Editor; @@ -53,8 +53,7 @@ export class SettingsPrimaryPane extends Component @@ -202,7 +200,7 @@ export class SettingsPrimaryPane extends Component { + const tabs = (items as ISettingField[]).map((field) => { if (this._activeKey === field.name) { matched = true; } @@ -235,7 +233,7 @@ export class SettingsPrimaryPane extends Component ); }); - const activeKey = matched ? this._activeKey : (items[0] as SettingField).name; + const activeKey = matched ? this._activeKey : (items[0] as ISettingField).name; const className = classNames('lc-settings-main', { 'lc-settings-hide-tabs': @@ -261,9 +259,10 @@ export class SettingsPrimaryPane extends Component ShellNode.create(item)!); } /** diff --git a/packages/types/src/shell/model/node-children.ts b/packages/types/src/shell/model/node-children.ts index f2be13250..207db5672 100644 --- a/packages/types/src/shell/model/node-children.ts +++ b/packages/types/src/shell/model/node-children.ts @@ -78,7 +78,7 @@ export interface IPublicModelNodeChildren< * @param deleteCount * @param node */ - splice(start: number, deleteCount: number, node?: Node): any; + splice(start: number, deleteCount: number, node?: Node): Node[]; /** * 返回指定下标的节点