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 getDOMNode api definition in node module · EsonSu2000/lowcode-engine@9648331

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs/docs/api/model
    • node.md
  • packages
    • designer
      • jest.config.js
      • src
        • designer
          • designer.ts
          • setting
            • setting-top-entry.ts
        • document
          • document-model.ts
          • node
            • exclusive-group.ts
            • node-children.ts
            • node.ts
            • props
              • prop.ts
              • props.ts
      • tests/document
        • document-model
          • document-model.test.ts
        • node
          • node.add.test.ts
    • shell/src
      • model
        • condition-group.ts
        • node.ts
      • symbols.ts
    • types/src/shell
      • model
        • exclusive-group.ts
        • node.ts
        • prop.ts
      • type
        • metadata.ts
    • utils/src/check-types
      • is-dom-text.ts
      • is-node-schema.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/docs/api/model/node.md‎

Copy file name to clipboardExpand all lines: docs/docs/api/model/node.md
+11Lines changed: 11 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,14 @@ setConditionalVisible(): void;
645645
```
646646

647647
**@since v1.1.0**
648+
649+
### getDOMNode
650+
获取节点实例对应的 dom 节点
651+
652+
```typescript
653+
/**
654+
* 获取节点实例对应的 dom 节点
655+
*/
656+
getDOMNode(): HTMLElement;
657+
658+
```
Collapse file

‎packages/designer/jest.config.js‎

Copy file name to clipboardExpand all lines: packages/designer/jest.config.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const jestConfig = {
1515
// testMatch: ['**/document-model.test.ts'],
1616
// testMatch: ['**/prop.test.ts'],
1717
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
18+
// testMatch: ['**/document/node/node.add.test.ts'],
1819
transformIgnorePatterns: [
1920
`/node_modules/(?!${esModules})/`,
2021
],
Collapse file

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

Copy file name to clipboardExpand all lines: packages/designer/src/designer/designer.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export interface IDesigner {
7171

7272
get editor(): IPublicModelEditor;
7373

74+
get detecting(): Detecting;
75+
7476
createScroller(scrollable: IPublicTypeScrollable): IPublicModelScroller;
7577

7678
/**
Collapse file

‎packages/designer/src/designer/setting/setting-top-entry.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/designer/setting/setting-top-entry.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function generateSessionId(nodes: INode[]) {
1717
}
1818

1919
export interface ISettingTopEntry extends ISettingEntry {
20+
purge(): void;
2021
}
2122

2223
export class SettingTopEntry implements ISettingTopEntry {
Collapse file

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

Copy file name to clipboardExpand all lines: packages/designer/src/document/document-model.ts
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export interface IDocumentModel extends Omit< IPublicModelDocumentModel<
8787

8888
get active(): boolean;
8989

90+
get nodesMap(): Map<string, INode>;
91+
9092
/**
9193
* 根据 id 获取节点
9294
*/
@@ -114,6 +116,12 @@ export interface IDocumentModel extends Omit< IPublicModelDocumentModel<
114116
onChangeNodeVisible(fn: (node: INode, visible: boolean) => void): IPublicTypeDisposable;
115117

116118
addWillPurge(node: INode): void;
119+
120+
removeWillPurge(node: INode): void;
121+
122+
getComponentMeta(componentName: string): IComponentMeta;
123+
124+
insertNodes(parent: INode, thing: INode[] | IPublicTypeNodeData[], at?: number | null, copy?: boolean): INode[];
117125
}
118126

119127
export class DocumentModel implements IDocumentModel {
@@ -379,7 +387,7 @@ export class DocumentModel implements IDocumentModel {
379387
* 根据 schema 创建一个节点
380388
*/
381389
@action
382-
createNode<T extends INode = INode, C = undefined>(data: GetDataType<C, T>, checkId: boolean = true): T {
390+
createNode<T extends INode = INode, C = undefined>(data: GetDataType<C, T>): T {
383391
let schema: any;
384392
if (isDOMText(data) || isJSExpression(data)) {
385393
schema = {
@@ -410,7 +418,7 @@ export class DocumentModel implements IDocumentModel {
410418
}
411419
}
412420
if (!node) {
413-
node = new Node(this, schema, { checkId });
421+
node = new Node(this, schema);
414422
// will add
415423
// todo: this.activeNodes?.push(node);
416424
}
@@ -429,7 +437,7 @@ export class DocumentModel implements IDocumentModel {
429437
/**
430438
* 插入一个节点
431439
*/
432-
insertNode(parent: INode, thing: INode | IPublicTypeNodeData, at?: number | null, copy?: boolean): INode {
440+
insertNode(parent: INode, thing: INode | IPublicTypeNodeData, at?: number | null, copy?: boolean): INode | null {
433441
return insertChild(parent, thing, at, copy);
434442
}
435443

@@ -445,7 +453,7 @@ export class DocumentModel implements IDocumentModel {
445453
*/
446454
removeNode(idOrNode: string | INode) {
447455
let id: string;
448-
let node: INode | null;
456+
let node: INode | null = null;
449457
if (typeof idOrNode === 'string') {
450458
id = idOrNode;
451459
node = this.getNode(id);
@@ -859,7 +867,7 @@ export class DocumentModel implements IDocumentModel {
859867
onReady(fn: Function) {
860868
this.designer.editor.eventBus.on('document-open', fn);
861869
return () => {
862-
this.designer.editor.removeListener('document-open', fn);
870+
this.designer.editor.eventBus.off('document-open', fn);
863871
};
864872
}
865873

Collapse file

‎packages/designer/src/document/node/exclusive-group.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/document/node/exclusive-group.ts
+30-20Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core';
22
import { uniqueId } from '@alilc/lowcode-utils';
33
import { IPublicTypeTitleContent, IPublicModelExclusiveGroup } from '@alilc/lowcode-types';
4-
import { Node } from './node';
4+
import { INode } from './node';
55
import { intl } from '../../locale';
66

7+
export interface IExclusiveGroup extends IPublicModelExclusiveGroup<INode> {
8+
readonly name: string;
9+
10+
remove(node: INode): void;
11+
12+
add(node: INode): void;
13+
14+
isVisible(node: INode): boolean;
15+
}
16+
717
// modals assoc x-hide value, initial: check is Modal, yes will put it in modals, cross levels
818
// if-else-if assoc conditionGroup value, should be the same level,
919
// and siblings, need renderEngine support
10-
export class ExclusiveGroup implements IPublicModelExclusiveGroup {
20+
export class ExclusiveGroup implements IExclusiveGroup {
1121
readonly isExclusiveGroup = true;
1222

1323
readonly id = uniqueId('exclusive');
1424

15-
@obx.shallow readonly children: Node[] = [];
25+
readonly title: IPublicTypeTitleContent;
26+
27+
@obx.shallow readonly children: INode[] = [];
1628

1729
@obx private visibleIndex = 0;
1830

@@ -28,28 +40,36 @@ export class ExclusiveGroup implements IPublicModelExclusiveGroup {
2840
return this.children.length;
2941
}
3042

31-
@computed get visibleNode(): Node {
43+
@computed get visibleNode(): INode {
3244
return this.children[this.visibleIndex];
3345
}
3446

35-
@computed get firstNode(): Node {
47+
@computed get firstNode(): INode {
3648
return this.children[0]!;
3749
}
3850

3951
get index() {
4052
return this.firstNode.index;
4153
}
4254

43-
add(node: Node) {
44-
if (node.nextSibling && node.nextSibling.conditionGroup === this) {
55+
constructor(readonly name: string, title?: IPublicTypeTitleContent) {
56+
makeObservable(this);
57+
this.title = title || {
58+
type: 'i18n',
59+
intl: intl('Condition Group'),
60+
};
61+
}
62+
63+
add(node: INode) {
64+
if (node.nextSibling && node.nextSibling.conditionGroup?.id === this.id) {
4565
const i = this.children.indexOf(node.nextSibling);
4666
this.children.splice(i, 0, node);
4767
} else {
4868
this.children.push(node);
4969
}
5070
}
5171

52-
remove(node: Node) {
72+
remove(node: INode) {
5373
const i = this.children.indexOf(node);
5474
if (i > -1) {
5575
this.children.splice(i, 1);
@@ -61,27 +81,17 @@ export class ExclusiveGroup implements IPublicModelExclusiveGroup {
6181
}
6282
}
6383

64-
setVisible(node: Node) {
84+
setVisible(node: INode) {
6585
const i = this.children.indexOf(node);
6686
if (i > -1) {
6787
this.visibleIndex = i;
6888
}
6989
}
7090

71-
isVisible(node: Node) {
91+
isVisible(node: INode) {
7292
const i = this.children.indexOf(node);
7393
return i === this.visibleIndex;
7494
}
75-
76-
readonly title: IPublicTypeTitleContent;
77-
78-
constructor(readonly name: string, title?: IPublicTypeTitleContent) {
79-
makeObservable(this);
80-
this.title = title || {
81-
type: 'i18n',
82-
intl: intl('Condition Group'),
83-
};
84-
}
8595
}
8696

8797
export function isExclusiveGroup(obj: any): obj is ExclusiveGroup {
Collapse file

‎packages/designer/src/document/node/node-children.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/document/node/node-children.ts
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { obx, computed, globalContext, makeObservable, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
22
import { Node, INode } from './node';
3-
import { IPublicTypeNodeData, IPublicModelNodeChildren, IPublicEnumTransformStage } from '@alilc/lowcode-types';
3+
import { IPublicTypeNodeData, IPublicModelNodeChildren, IPublicEnumTransformStage, IPublicTypeDisposable } from '@alilc/lowcode-types';
44
import { shallowEqual, compatStage, isNodeSchema } from '@alilc/lowcode-utils';
55
import { foreachReverse } from '../../utils/tree';
66
import { NodeRemoveOptions } from '../../types';
@@ -18,6 +18,8 @@ export interface INodeChildren extends Omit<IPublicModelNodeChildren<INode>,
1818
> {
1919
get owner(): INode;
2020

21+
get length(): number;
22+
2123
unlinkChild(node: INode): void;
2224

2325
/**
@@ -58,6 +60,8 @@ export interface INodeChildren extends Omit<IPublicModelNodeChildren<INode>,
5860

5961
internalInitParent(): void;
6062

63+
onChange(fn: (info?: IOnChangeOptions) => void): IPublicTypeDisposable;
64+
6165
/** overriding methods end */
6266
}
6367
export class NodeChildren implements INodeChildren {
@@ -478,7 +482,7 @@ export class NodeChildren implements INodeChildren {
478482
}
479483
}
480484

481-
onChange(fn: (info?: IOnChangeOptions) => void): () => void {
485+
onChange(fn: (info?: IOnChangeOptions) => void): IPublicTypeDisposable {
482486
this.emitter.on('change', fn);
483487
return () => {
484488
this.emitter.removeListener('change', fn);

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.