mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
fix: make insertAfter & insertBefore work
This commit is contained in:
parent
d5c3ca1068
commit
70fd3720d0
@ -232,19 +232,39 @@ export class EngineConfig {
|
|||||||
this.config = config || {};
|
this.config = config || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断指定 key 是否有值
|
||||||
|
* @param key
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
has(key: string): boolean {
|
has(key: string): boolean {
|
||||||
return this.config[key] !== undefined;
|
return this.config[key] !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定 key 的值
|
||||||
|
* @param key
|
||||||
|
* @param defaultValue
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
get(key: string, defaultValue?: any): any {
|
get(key: string, defaultValue?: any): any {
|
||||||
return lodashGet(this.config, key, defaultValue);
|
return lodashGet(this.config, key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置指定 key 的值
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
set(key: string, value: any) {
|
set(key: string, value: any) {
|
||||||
this.config[key] = value;
|
this.config[key] = value;
|
||||||
this.notifyGot(key);
|
this.notifyGot(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量设值,set 的对象版本
|
||||||
|
* @param config
|
||||||
|
*/
|
||||||
setConfig(config: { [key: string]: any }) {
|
setConfig(config: { [key: string]: any }) {
|
||||||
if (config) {
|
if (config) {
|
||||||
Object.keys(config).forEach((key) => {
|
Object.keys(config).forEach((key) => {
|
||||||
@ -281,6 +301,12 @@ export class EngineConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定 key 的值,若此时还未赋值,则等待,若已有值,则直接返回值
|
||||||
|
* 注:此函数返回 Promise 实例,只会执行(fullfill)一次
|
||||||
|
* @param key
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
onceGot(key: string): Promise<any> {
|
onceGot(key: string): Promise<any> {
|
||||||
const val = this.config[key];
|
const val = this.config[key];
|
||||||
if (val !== undefined) {
|
if (val !== undefined) {
|
||||||
@ -291,6 +317,12 @@ export class EngineConfig {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定 key 的值,函数回调模式,若多次被赋值,回调会被多次调用
|
||||||
|
* @param key
|
||||||
|
* @param fn
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
onGot(key: string, fn: (data: any) => void): () => void {
|
onGot(key: string, fn: (data: any) => void): () => void {
|
||||||
const val = this.config?.[key];
|
const val = this.config?.[key];
|
||||||
if (val !== undefined) {
|
if (val !== undefined) {
|
||||||
|
|||||||
@ -348,7 +348,7 @@ export default class Node {
|
|||||||
* @param useMutator
|
* @param useMutator
|
||||||
*/
|
*/
|
||||||
insertBefore(node: Node, ref?: Node | undefined, useMutator?: boolean) {
|
insertBefore(node: Node, ref?: Node | undefined, useMutator?: boolean) {
|
||||||
this[nodeSymbol].insertBefore(node[nodeSymbol], ref?.[nodeSymbol], useMutator);
|
this[nodeSymbol].insertBefore(node[nodeSymbol] || node, ref?.[nodeSymbol], useMutator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -358,7 +358,7 @@ export default class Node {
|
|||||||
* @param useMutator
|
* @param useMutator
|
||||||
*/
|
*/
|
||||||
insertAfter(node: Node, ref?: Node | undefined, useMutator?: boolean) {
|
insertAfter(node: Node, ref?: Node | undefined, useMutator?: boolean) {
|
||||||
this[nodeSymbol].insertAfter(node[nodeSymbol], ref?.[nodeSymbol], useMutator);
|
this[nodeSymbol].insertAfter(node[nodeSymbol] || node, ref?.[nodeSymbol], useMutator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user