Skip to content

Commit 4fd7f27

Browse files
committed
feat: add some necessary methods and attributes
1 parent 98ececa commit 4fd7f27

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

packages/designer/src/designer/designer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export class Designer {
550550

551551
return reducers.reduce((xprops, reducer) => {
552552
try {
553-
return reducer(xprops, node, { stage });
553+
return reducer(xprops, node.internalToShellNode() as any, { stage });
554554
} catch (e) {
555555
// todo: add log
556556
console.warn(e);

packages/shell/src/document-model.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ export default class DocumentModel {
6161
return new DocumentModel(document);
6262
}
6363

64+
/**
65+
* id
66+
*/
67+
get id() {
68+
return this[documentSymbol].id;
69+
}
70+
6471
/**
6572
* 获取当前文档所属的 project
6673
* @returns

packages/shell/src/node.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Props from './props';
99
import DocumentModel from './document-model';
1010
import NodeChildren from './node-children';
1111
import ComponentMeta from './component-meta';
12+
import SettingTopEntry from './setting-top-entry';
1213
import { documentSymbol, nodeSymbol } from './symbols';
1314

1415
const shellNodeSymbol = Symbol('shellNodeSymbol');
@@ -237,6 +238,10 @@ export default class Node {
237238
return this[nodeSymbol].schema;
238239
}
239240

241+
get settingEntry(): any {
242+
return SettingTopEntry.create(this[nodeSymbol].settingEntry as any);
243+
}
244+
240245
/**
241246
* @deprecated use .children instead
242247
*/

packages/shell/src/props.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,23 @@ export default class Props {
9494
setExtraPropValue(path: string, value: CompositeValue) {
9595
return this.getExtraProp(path)?.setValue(value);
9696
}
97+
98+
/**
99+
* test if the specified key is existing or not.
100+
* @param key
101+
* @returns
102+
*/
103+
has(key: string) {
104+
return this[propsSymbol].has(key);
105+
}
106+
107+
/**
108+
* add a key with given value
109+
* @param value
110+
* @param key
111+
* @returns
112+
*/
113+
add(value: CompositeValue, key?: string | number | undefined) {
114+
return this[propsSymbol].add(value, key);
115+
}
97116
}

packages/shell/src/setting-prop-entry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export default class SettingPropEntry {
6464
return this[settingPropEntrySymbol].extraProps;
6565
}
6666

67+
get props() {
68+
return SettingTopEntry.create(this[settingPropEntrySymbol].props);
69+
}
70+
6771
/**
6872
* 获取设置属性对应的节点实例
6973
*/

0 commit comments

Comments
 (0)