mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 04:40:32 +00:00
add settingsEntry
This commit is contained in:
parent
f51bd34737
commit
be4a58fc14
@ -21,6 +21,7 @@ import { ComponentMeta } from '../../component-meta';
|
||||
import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group';
|
||||
import { TransformStage } from './transform-stage';
|
||||
import { ReactElement } from 'react';
|
||||
import { SettingTopEntry } from 'designer/src/designer';
|
||||
|
||||
/**
|
||||
* 基础节点
|
||||
@ -142,6 +143,8 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
return this.componentMeta.icon;
|
||||
}
|
||||
|
||||
readonly settingEntry: SettingTopEntry;
|
||||
|
||||
constructor(readonly document: DocumentModel, nodeSchema: Schema) {
|
||||
const { componentName, id, children, props, ...extras } = nodeSchema;
|
||||
this.id = id || `node_${document.nextId()}`;
|
||||
@ -161,6 +164,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
if (this.componentMeta.isModal) {
|
||||
this.getExtraProp('hidden', true)?.setValue(true);
|
||||
}
|
||||
this.settingEntry = this.document.designer.createSettingEntry([ this ]);
|
||||
}
|
||||
|
||||
private transformProps(props: any): any {
|
||||
@ -384,7 +388,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
// todo
|
||||
}
|
||||
|
||||
replaceWith(schema: Schema, migrate = false) {
|
||||
replaceWith(schema: Schema, migrate = false): any {
|
||||
// reuse the same id? or replaceSelection
|
||||
schema = Object.assign({}, migrate ? this.export() : {}, schema);
|
||||
return this.parent?.replaceChild(this, schema);
|
||||
@ -396,7 +400,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
* @param {Node} node
|
||||
* @param {object} data
|
||||
*/
|
||||
replaceChild(node: Node, data: any) {
|
||||
replaceChild(node: Node, data: any): Node {
|
||||
if (this.children?.has(node)) {
|
||||
const selected = this.document.selection.has(node.id);
|
||||
|
||||
|
||||
@ -711,8 +711,7 @@ export function upgradeMetadata(oldConfig: OldPrototypeConfig) {
|
||||
experimental.initialChildren =
|
||||
typeof initialChildren === 'function'
|
||||
? (node: any) => {
|
||||
const props = designer.createSettingEntry(editor, [ node ]);
|
||||
return initialChildren.call(node, props);
|
||||
return initialChildren.call(node, node.settingEntry);
|
||||
}
|
||||
: initialChildren;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ function filterReducer(props: any, node: Node): any {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (item.filter(node.getProp(item.name) as any, props[item.name]) === false) {
|
||||
if (item.filter(node.settingEntry.getProp(item.name), props[item.name]) === false) {
|
||||
delete newProps[item.name];
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@ -67,7 +67,7 @@ export class SettingsMain {
|
||||
this.designer = nodes[0].document.designer;
|
||||
}
|
||||
|
||||
this._settings = this.designer.createSettingEntry(this.editor, nodes);
|
||||
this._settings = this.designer.createSettingEntry(nodes);
|
||||
}
|
||||
|
||||
purge() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user