feat: add some necessary methods and attributes

This commit is contained in:
LeoYuan 袁力皓 2022-05-09 20:38:38 +08:00
parent 98ececa9c1
commit 4fd7f27f8e
5 changed files with 36 additions and 1 deletions

View File

@ -550,7 +550,7 @@ export class Designer {
return reducers.reduce((xprops, reducer) => {
try {
return reducer(xprops, node, { stage });
return reducer(xprops, node.internalToShellNode() as any, { stage });
} catch (e) {
// todo: add log
console.warn(e);

View File

@ -61,6 +61,13 @@ export default class DocumentModel {
return new DocumentModel(document);
}
/**
* id
*/
get id() {
return this[documentSymbol].id;
}
/**
* project
* @returns

View File

@ -9,6 +9,7 @@ import Props from './props';
import DocumentModel from './document-model';
import NodeChildren from './node-children';
import ComponentMeta from './component-meta';
import SettingTopEntry from './setting-top-entry';
import { documentSymbol, nodeSymbol } from './symbols';
const shellNodeSymbol = Symbol('shellNodeSymbol');
@ -237,6 +238,10 @@ export default class Node {
return this[nodeSymbol].schema;
}
get settingEntry(): any {
return SettingTopEntry.create(this[nodeSymbol].settingEntry as any);
}
/**
* @deprecated use .children instead
*/

View File

@ -94,4 +94,23 @@ export default class Props {
setExtraPropValue(path: string, value: CompositeValue) {
return this.getExtraProp(path)?.setValue(value);
}
/**
* test if the specified key is existing or not.
* @param key
* @returns
*/
has(key: string) {
return this[propsSymbol].has(key);
}
/**
* add a key with given value
* @param value
* @param key
* @returns
*/
add(value: CompositeValue, key?: string | number | undefined) {
return this[propsSymbol].add(value, key);
}
}

View File

@ -64,6 +64,10 @@ export default class SettingPropEntry {
return this[settingPropEntrySymbol].extraProps;
}
get props() {
return SettingTopEntry.create(this[settingPropEntrySymbol].props);
}
/**
*
*/