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