GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add APIs for plugin-outline-pane which will be splitted in near… · ikvm/lowcode-engine@7b58b6a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • designer/src/designer
      • detecting.ts
      • index.ts
    • engine/src/modules
      • designer-cabin.ts
      • symbols.ts
      • utils.ts
    • plugin-outline-pane/src/views
      • tree.tsx
    • shell/src
      • detecting.ts
      • document-model.ts
      • node.ts
      • project.ts
      • prop.ts
      • selection.ts
      • symbols.ts
    • types/src
      • editor.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/designer/src/designer/detecting.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/designer/detecting.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const DETECTING_CHANGE_EVENT = 'detectingChange';
77
export class Detecting {
88
@obx.ref private _enable = true;
99

10+
/**
11+
* 控制大纲树 hover 时是否出现悬停效果
12+
* TODO: 将该逻辑从设计器中抽离出来
13+
*/
1014
get enable() {
1115
return this._enable;
1216
}
Collapse file

‎packages/designer/src/designer/index.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/designer/index.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * from './location';
88
export * from './offset-observer';
99
export * from './scroller';
1010
export * from './setting';
11+
export * from './active-tracker';
Collapse file

‎packages/engine/src/modules/designer-cabin.ts‎

Copy file name to clipboardExpand all lines: packages/engine/src/modules/designer-cabin.ts
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ import {
55
TransformStage,
66
LiveEditing,
77
isDragNodeDataObject,
8+
isDragNodeObject,
9+
isDragAnyObject,
810
DragObjectType,
911
isNode,
12+
isShaken,
13+
contains,
14+
LocationDetailType,
15+
isLocationChildrenDetail,
16+
ScrollTarget,
1017
} from '@alilc/lowcode-designer';
1118
import { Editor } from '@alilc/lowcode-editor-core';
12-
import { Dragon } from '@alilc/lowcode-shell';
19+
import { designerCabinSymbol, Dragon } from '@alilc/lowcode-shell';
1320

1421
export default function getDesignerCabin(editor: Editor) {
1522
const designer = editor.get('designer') as Designer;
@@ -23,5 +30,21 @@ export default function getDesignerCabin(editor: Editor) {
2330
DragObjectType,
2431
isDragNodeDataObject,
2532
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+
},
2649
};
2750
}
Collapse file

‎packages/engine/src/modules/symbols.ts‎

Copy file name to clipboardExpand all lines: packages/engine/src/modules/symbols.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
editorSymbol,
99
settingPropEntrySymbol,
1010
settingTopEntrySymbol,
11+
designerCabinSymbol,
1112
} from '@alilc/lowcode-shell';
1213

1314
export default {
@@ -20,4 +21,5 @@ export default {
2021
designerSymbol,
2122
settingPropEntrySymbol,
2223
settingTopEntrySymbol,
24+
designerCabinSymbol,
2325
};
Collapse file

‎packages/engine/src/modules/utils.ts‎

Copy file name to clipboardExpand all lines: packages/engine/src/modules/utils.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById } from '@alilc/lowcode-utils';
22
import { isNodeSchema } from '@alilc/lowcode-types';
3-
import { getConvertedExtraKey, getOriginalExtraKey } from '@alilc/lowcode-designer';
3+
import { getConvertedExtraKey, getOriginalExtraKey, isNode, isSettingField } from '@alilc/lowcode-designer';
44

55
const utils = {
66
isNodeSchema,
Collapse file

‎packages/plugin-outline-pane/src/views/tree.tsx‎

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 numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, MouseEvent as ReactMouseEvent } from 'react';
22
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';
44
import { isFormEvent, canClickNode } from '@alilc/lowcode-utils';
55
import { Tree } from '../tree';
66
import RootTreeNodeView from './root-tree-node';
Collapse file

‎packages/shell/src/detecting.ts‎

Copy file name to clipboardExpand all lines: packages/shell/src/detecting.ts
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Node from './node';
12
import {
23
Detecting as InnerDetecting,
34
DocumentModel as InnerDocumentModel,
@@ -13,6 +14,13 @@ export default class Detecting {
1314
this[detectingSymbol] = document.designer.detecting;
1415
}
1516

17+
/**
18+
* 当前 hover 的节点
19+
*/
20+
get current() {
21+
return Node.create(this[detectingSymbol].current);
22+
}
23+
1624
/**
1725
* hover 指定节点
1826
* @param id 节点 id
Collapse file

‎packages/shell/src/document-model.ts‎

Copy file name to clipboardExpand all lines: packages/shell/src/document-model.ts
+30-6Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { Editor } from '@alilc/lowcode-editor-core';
22
import {
33
DocumentModel as InnerDocumentModel,
44
Node as InnerNode,
5-
ParentalNode,
65
IOnChangeOptions as InnerIOnChangeOptions,
7-
PropChangeOptions as InnerPropChangeOptions,
6+
DragObject as InnerDragObject,
7+
DragNodeObject,
8+
DragNodeDataObject,
9+
isDragNodeObject,
810
} from '@alilc/lowcode-designer';
911
import {
1012
TransformStage,
1113
RootSchema,
12-
NodeSchema,
13-
NodeData,
1414
GlobalEvent,
1515
} from '@alilc/lowcode-types';
1616
import Node from './node';
@@ -40,6 +40,8 @@ const Events = {
4040
IMPORT_SCHEMA: 'shell.document.importSchema',
4141
};
4242

43+
const shellDocSymbol = Symbol('shellDocSymbol');
44+
4345
export default class DocumentModel {
4446
private readonly [documentSymbol]: InnerDocumentModel;
4547
private readonly [editorSymbol]: Editor;
@@ -61,8 +63,13 @@ export default class DocumentModel {
6163
}
6264

6365
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;
6673
}
6774

6875
/**
@@ -200,6 +207,23 @@ export default class DocumentModel {
200207
return this[documentSymbol].getComponentsMap(extraComps);
201208
}
202209

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+
203227
/**
204228
* 当前 document 新增节点事件
205229
*/
Collapse file

‎packages/shell/src/node.ts‎

Copy file name to clipboardExpand all lines: packages/shell/src/node.ts
+22-2Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ export default class Node {
128128
return true;
129129
}
130130

131+
/**
132+
* 获取当前节点的锁定状态
133+
*/
134+
get isLocked() {
135+
return this[nodeSymbol].isLocked;
136+
}
137+
131138
/**
132139
* 下标
133140
*/
@@ -314,6 +321,14 @@ export default class Node {
314321
return this[nodeSymbol].isConditionalVisible();
315322
}
316323

324+
/**
325+
* 设置节点锁定状态
326+
* @param flag
327+
*/
328+
lock(flag?: boolean) {
329+
this[nodeSymbol].lock(flag);
330+
}
331+
317332
/**
318333
* @deprecated use .props instead
319334
*/
@@ -347,10 +362,11 @@ export default class Node {
347362
* 获取指定 path 的属性模型实例,
348363
* 注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级
349364
* @param path 属性路径,支持 a / a.b / a.0 等格式
365+
* @param createIfNone 当没有属性的时候,是否创建一个属性
350366
* @returns
351367
*/
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));
354370
}
355371

356372
/**
@@ -460,4 +476,8 @@ export default class Node {
460476
remove() {
461477
this[nodeSymbol].remove();
462478
}
479+
480+
internalToShellNode() {
481+
return this;
482+
}
463483
}
Collapse file

‎packages/shell/src/project.ts‎

Copy file name to clipboardExpand all lines: packages/shell/src/project.ts
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ import {
44
PropsReducer as PropsTransducer,
55
TransformStage,
66
} from '@alilc/lowcode-designer';
7-
import { RootSchema, ProjectSchema } from '@alilc/lowcode-types';
7+
import { RootSchema, ProjectSchema, IEditor } from '@alilc/lowcode-types';
88
import DocumentModel from './document-model';
99
import SimulatorHost from './simulator-host';
10-
import { projectSymbol, simulatorHostSymbol, simulatorRendererSymbol, documentSymbol } from './symbols';
10+
import { editorSymbol, projectSymbol, simulatorHostSymbol, simulatorRendererSymbol, documentSymbol } from './symbols';
1111

1212
export default class Project {
1313
private readonly [projectSymbol]: InnerProject;
14+
private readonly [editorSymbol]: IEditor;
1415
private [simulatorHostSymbol]: BuiltinSimulatorHost;
1516
private [simulatorRendererSymbol]: any;
1617

1718
constructor(project: InnerProject) {
1819
this[projectSymbol] = project;
20+
this[editorSymbol] = project?.designer.editor;
1921
}
2022

2123
static create(project: InnerProject) {
@@ -132,6 +134,15 @@ export default class Project {
132134
this[projectSymbol].designer.addPropsReducer(transducer, stage);
133135
}
134136

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+
135146
/**
136147
* 当前 project 内的 document 变更事件
137148
*/

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.