mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-18 21:38:14 +00:00
support addon to props
This commit is contained in:
parent
c0ecaa6d60
commit
e666853b1e
@ -101,7 +101,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
private _addons: { [key: string]: any } = {};
|
private _addons: { [key: string]: { exportData: () => any; isProp: boolean; } } = {};
|
||||||
@obx.ref private _parent: ParentalNode | null = null;
|
@obx.ref private _parent: ParentalNode | null = null;
|
||||||
/**
|
/**
|
||||||
* 父级节点
|
* 父级节点
|
||||||
@ -544,7 +544,11 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
Object.keys(this._addons).forEach((key) => {
|
Object.keys(this._addons).forEach((key) => {
|
||||||
const addon = this._addons[key];
|
const addon = this._addons[key];
|
||||||
if (addon) {
|
if (addon) {
|
||||||
_extras_[key] = addon();
|
if (addon.isProp) {
|
||||||
|
(props as any)[key] = addon.exportData();
|
||||||
|
} else {
|
||||||
|
_extras_[key] = addon.exportData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -752,19 +756,19 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
getAddonData(key: string) {
|
getAddonData(key: string) {
|
||||||
const addon = this._addons[key];
|
const addon = this._addons[key];
|
||||||
if (addon) {
|
if (addon) {
|
||||||
return addon();
|
return addon.exportData();
|
||||||
}
|
}
|
||||||
return this.getExtraProp(key)?.value;
|
return this.getExtraProp(key)?.value;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
registerAddon(key: string, exportData: any) {
|
registerAddon(key: string, exportData: () => any, isProp: boolean = false) {
|
||||||
if (this._addons[key]) {
|
if (this._addons[key]) {
|
||||||
throw new Error(`node addon ${key} exist`);
|
throw new Error(`node addon ${key} exist`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._addons[key] = exportData;
|
this._addons[key] = { exportData, isProp };
|
||||||
}
|
}
|
||||||
|
|
||||||
getRect(): DOMRect | null {
|
getRect(): DOMRect | null {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user