GeezerVison is showing github.com — feat: add APIs for plugin-outline-pane which will be splitted in near… · ikvm/lowcode-engine@7b58b6a
File treeExpand file treeCollapse file tree Open diff view settings plugin-outline-pane/src/views
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/designer/detecting.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,6 +7,10 @@ const DETECTING_CHANGE_EVENT = 'detectingChange'; | 7 | 7 | export class Detecting { | 8 | 8 | @obx.ref private _enable = true; | 9 | 9 |
| | 10 | + /** | | 11 | + * 控制大纲树 hover 时是否出现悬停效果 | | 12 | + * TODO: 将该逻辑从设计器中抽离出来 | | 13 | + */ | 10 | 14 | get enable() { | 11 | 15 | return this._enable; | 12 | 16 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/designer/index.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,3 +8,4 @@ export * from './location'; | 8 | 8 | export * from './offset-observer'; | 9 | 9 | export * from './scroller'; | 10 | 10 | export * from './setting'; | | 11 | +export * from './active-tracker'; |
Collapse file Copy file name to clipboardExpand all lines: packages/engine/src/modules/designer-cabin.ts +24-1Lines changed: 24 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,11 +5,18 @@ import { | 5 | 5 | TransformStage, | 6 | 6 | LiveEditing, | 7 | 7 | isDragNodeDataObject, | | 8 | + isDragNodeObject, | | 9 | + isDragAnyObject, | 8 | 10 | DragObjectType, | 9 | 11 | isNode, | | 12 | + isShaken, | | 13 | + contains, | | 14 | + LocationDetailType, | | 15 | + isLocationChildrenDetail, | | 16 | + ScrollTarget, | 10 | 17 | } from '@alilc/lowcode-designer'; | 11 | 18 | import { Editor } from '@alilc/lowcode-editor-core'; | 12 | | -import { Dragon } from '@alilc/lowcode-shell'; | | 19 | +import { designerCabinSymbol, Dragon } from '@alilc/lowcode-shell'; | 13 | 20 |
| 14 | 21 | export default function getDesignerCabin(editor: Editor) { | 15 | 22 | const designer = editor.get('designer') as Designer; | @@ -23,5 +30,21 @@ export default function getDesignerCabin(editor: Editor) { | 23 | 30 | DragObjectType, | 24 | 31 | isDragNodeDataObject, | 25 | 32 | isNode, | | 33 | + [designerCabinSymbol]: { | | 34 | + isDragNodeObject, | | 35 | + isDragAnyObject, | | 36 | + isShaken, | | 37 | + contains, | | 38 | + LocationDetailType, | | 39 | + isLocationChildrenDetail, | | 40 | + ScrollTarget, | | 41 | + isSettingField, | | 42 | + TransformStage, | | 43 | + SettingField, | | 44 | + LiveEditing, | | 45 | + DragObjectType, | | 46 | + isDragNodeDataObject, | | 47 | + isNode, | | 48 | + }, | 26 | 49 | }; | 27 | 50 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/engine/src/modules/symbols.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | editorSymbol, | 9 | 9 | settingPropEntrySymbol, | 10 | 10 | settingTopEntrySymbol, | | 11 | + designerCabinSymbol, | 11 | 12 | } from '@alilc/lowcode-shell'; | 12 | 13 |
| 13 | 14 | export default { | @@ -20,4 +21,5 @@ export default { | 20 | 21 | designerSymbol, | 21 | 22 | settingPropEntrySymbol, | 22 | 23 | settingTopEntrySymbol, | | 24 | + designerCabinSymbol, | 23 | 25 | }; |
Collapse file Copy file name to clipboardExpand all lines: packages/engine/src/modules/utils.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById } from '@alilc/lowcode-utils'; | 2 | 2 | import { isNodeSchema } from '@alilc/lowcode-types'; | 3 | | -import { getConvertedExtraKey, getOriginalExtraKey } from '@alilc/lowcode-designer'; | | 3 | +import { getConvertedExtraKey, getOriginalExtraKey, isNode, isSettingField } from '@alilc/lowcode-designer'; | 4 | 4 |
| 5 | 5 | const utils = { | 6 | 6 | isNodeSchema, | |
Collapse file Copy file name to clipboardExpand all lines: packages/plugin-outline-pane/src/views/tree.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { Component, MouseEvent as ReactMouseEvent } from 'react'; | 2 | 2 | import { observer, Editor, globalContext } from '@alilc/lowcode-editor-core'; | 3 | | -import { isRootNode, Node, DragObjectType, isShaken } from '@alilc/lowcode-designer'; | | 3 | +import { Node, DragObjectType, isShaken } from '@alilc/lowcode-designer'; | 4 | 4 | import { isFormEvent, canClickNode } from '@alilc/lowcode-utils'; | 5 | 5 | import { Tree } from '../tree'; | 6 | 6 | import RootTreeNodeView from './root-tree-node'; | |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/detecting.ts +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import Node from './node'; | 1 | 2 | import { | 2 | 3 | Detecting as InnerDetecting, | 3 | 4 | DocumentModel as InnerDocumentModel, | @@ -13,6 +14,13 @@ export default class Detecting { | 13 | 14 | this[detectingSymbol] = document.designer.detecting; | 14 | 15 | } | 15 | 16 |
| | 17 | + /** | | 18 | + * 当前 hover 的节点 | | 19 | + */ | | 20 | + get current() { | | 21 | + return Node.create(this[detectingSymbol].current); | | 22 | + } | | 23 | + | 16 | 24 | /** | 17 | 25 | * hover 指定节点 | 18 | 26 | * @param id 节点 id | |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/document-model.ts +30-6Lines changed: 30 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,15 +2,15 @@ import { Editor } from '@alilc/lowcode-editor-core'; | 2 | 2 | import { | 3 | 3 | DocumentModel as InnerDocumentModel, | 4 | 4 | Node as InnerNode, | 5 | | - ParentalNode, | 6 | 5 | IOnChangeOptions as InnerIOnChangeOptions, | 7 | | - PropChangeOptions as InnerPropChangeOptions, | | 6 | + DragObject as InnerDragObject, | | 7 | + DragNodeObject, | | 8 | + DragNodeDataObject, | | 9 | + isDragNodeObject, | 8 | 10 | } from '@alilc/lowcode-designer'; | 9 | 11 | import { | 10 | 12 | TransformStage, | 11 | 13 | RootSchema, | 12 | | - NodeSchema, | 13 | | - NodeData, | 14 | 14 | GlobalEvent, | 15 | 15 | } from '@alilc/lowcode-types'; | 16 | 16 | import Node from './node'; | @@ -40,6 +40,8 @@ const Events = { | 40 | 40 | IMPORT_SCHEMA: 'shell.document.importSchema', | 41 | 41 | }; | 42 | 42 |
| | 43 | +const shellDocSymbol = Symbol('shellDocSymbol'); | | 44 | + | 43 | 45 | export default class DocumentModel { | 44 | 46 | private readonly [documentSymbol]: InnerDocumentModel; | 45 | 47 | private readonly [editorSymbol]: Editor; | @@ -61,8 +63,13 @@ export default class DocumentModel { | 61 | 63 | } | 62 | 64 |
| 63 | 65 | static create(document: InnerDocumentModel | undefined | null) { | 64 | | - if (document == undefined) return null; | 65 | | - return new DocumentModel(document); | | 66 | + if (!document) return null; | | 67 | + // @ts-ignore 直接返回已挂载的 shell doc 实例 | | 68 | + if (document[shellDocSymbol]) return document[shellDocSymbol]; | | 69 | + const shellDoc = new DocumentModel(document); | | 70 | + // @ts-ignore 直接返回已挂载的 shell doc 实例 | | 71 | + document[shellDocSymbol] = shellDoc; | | 72 | + return shellDoc; | 66 | 73 | } | 67 | 74 |
| 68 | 75 | /** | @@ -200,6 +207,23 @@ export default class DocumentModel { | 200 | 207 | return this[documentSymbol].getComponentsMap(extraComps); | 201 | 208 | } | 202 | 209 |
| | 210 | + /** | | 211 | + * 检查拖拽放置的目标节点是否可以放置该拖拽对象 | | 212 | + * @param dropTarget 拖拽放置的目标节点 | | 213 | + * @param dragObject 拖拽的对象 | | 214 | + * @returns boolean 是否可以放置 | | 215 | + */ | | 216 | + checkNesting(dropTarget: Node, dragObject: DragNodeObject | DragNodeDataObject): boolean { | | 217 | + let innerDragObject: InnerDragObject = dragObject; | | 218 | + if (isDragNodeObject(dragObject)) { | | 219 | + innerDragObject.nodes = innerDragObject.nodes.map((node: Node) => (node[nodeSymbol] || node)); | | 220 | + } | | 221 | + return this[documentSymbol].checkNesting( | | 222 | + (dropTarget[nodeSymbol] || dropTarget) as any, | | 223 | + innerDragObject as any, | | 224 | + ); | | 225 | + } | | 226 | + | 203 | 227 | /** | 204 | 228 | * 当前 document 新增节点事件 | 205 | 229 | */ | |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/node.ts +22-2Lines changed: 22 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -128,6 +128,13 @@ export default class Node { | 128 | 128 | return true; | 129 | 129 | } | 130 | 130 |
| | 131 | + /** | | 132 | + * 获取当前节点的锁定状态 | | 133 | + */ | | 134 | + get isLocked() { | | 135 | + return this[nodeSymbol].isLocked; | | 136 | + } | | 137 | + | 131 | 138 | /** | 132 | 139 | * 下标 | 133 | 140 | */ | @@ -314,6 +321,14 @@ export default class Node { | 314 | 321 | return this[nodeSymbol].isConditionalVisible(); | 315 | 322 | } | 316 | 323 |
| | 324 | + /** | | 325 | + * 设置节点锁定状态 | | 326 | + * @param flag | | 327 | + */ | | 328 | + lock(flag?: boolean) { | | 329 | + this[nodeSymbol].lock(flag); | | 330 | + } | | 331 | + | 317 | 332 | /** | 318 | 333 | * @deprecated use .props instead | 319 | 334 | */ | @@ -347,10 +362,11 @@ export default class Node { | 347 | 362 | * 获取指定 path 的属性模型实例, | 348 | 363 | * 注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级 | 349 | 364 | * @param path 属性路径,支持 a / a.b / a.0 等格式 | | 365 | + * @param createIfNone 当没有属性的时候,是否创建一个属性 | 350 | 366 | * @returns | 351 | 367 | */ | 352 | | - getExtraProp(path: string): Prop | null { | 353 | | - return Prop.create(this[nodeSymbol].getProp(getConvertedExtraKey(path))); | | 368 | + getExtraProp(path: string, createIfNone?: boolean): Prop | null { | | 369 | + return Prop.create(this[nodeSymbol].getExtraProp(path, createIfNone)); | 354 | 370 | } | 355 | 371 |
| 356 | 372 | /** | @@ -460,4 +476,8 @@ export default class Node { | 460 | 476 | remove() { | 461 | 477 | this[nodeSymbol].remove(); | 462 | 478 | } | | 479 | + | | 480 | + internalToShellNode() { | | 481 | + return this; | | 482 | + } | 463 | 483 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/project.ts +13-2Lines changed: 13 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,18 +4,20 @@ import { | 4 | 4 | PropsReducer as PropsTransducer, | 5 | 5 | TransformStage, | 6 | 6 | } from '@alilc/lowcode-designer'; | 7 | | -import { RootSchema, ProjectSchema } from '@alilc/lowcode-types'; | | 7 | +import { RootSchema, ProjectSchema, IEditor } from '@alilc/lowcode-types'; | 8 | 8 | import DocumentModel from './document-model'; | 9 | 9 | import SimulatorHost from './simulator-host'; | 10 | | -import { projectSymbol, simulatorHostSymbol, simulatorRendererSymbol, documentSymbol } from './symbols'; | | 10 | +import { editorSymbol, projectSymbol, simulatorHostSymbol, simulatorRendererSymbol, documentSymbol } from './symbols'; | 11 | 11 |
| 12 | 12 | export default class Project { | 13 | 13 | private readonly [projectSymbol]: InnerProject; | | 14 | + private readonly [editorSymbol]: IEditor; | 14 | 15 | private [simulatorHostSymbol]: BuiltinSimulatorHost; | 15 | 16 | private [simulatorRendererSymbol]: any; | 16 | 17 |
| 17 | 18 | constructor(project: InnerProject) { | 18 | 19 | this[projectSymbol] = project; | | 20 | + this[editorSymbol] = project?.designer.editor; | 19 | 21 | } | 20 | 22 |
| 21 | 23 | static create(project: InnerProject) { | @@ -132,6 +134,15 @@ export default class Project { | 132 | 134 | this[projectSymbol].designer.addPropsReducer(transducer, stage); | 133 | 135 | } | 134 | 136 |
| | 137 | + /** | | 138 | + * 绑定删除文档事件 | | 139 | + * @param fn | | 140 | + * @returns | | 141 | + */ | | 142 | + onRemoveDocument(fn: (data: { id: string}) => void) { | | 143 | + return this[editorSymbol].on('designer.document.remove', (data: { id: string }) => fn(data)); | | 144 | + } | | 145 | + | 135 | 146 | /** | 136 | 147 | * 当前 project 内的 document 变更事件 | 137 | 148 | */ | |
|