feat(editor-core): async block support remove property
This commit is contained in:
@@ -453,6 +453,18 @@ export class AsyncBlock {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removeProperty<
|
||||||
|
T extends keyof DefaultColumnsValue = keyof DefaultColumnsValue
|
||||||
|
>(key: T) {
|
||||||
|
return this.services.update({
|
||||||
|
id: this.id,
|
||||||
|
workspace: this.raw_data.workspace,
|
||||||
|
properties: {
|
||||||
|
[key]: undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private async load_node(id: string): Promise<AsyncBlock | null> {
|
private async load_node(id: string): Promise<AsyncBlock | null> {
|
||||||
return await this.services.load({
|
return await this.services.load({
|
||||||
workspace: this.raw_data.workspace,
|
workspace: this.raw_data.workspace,
|
||||||
|
|||||||
@@ -143,8 +143,13 @@ export class EditorBlock extends ServiceBaseClass {
|
|||||||
const decorations = db_block.getDecorations();
|
const decorations = db_block.getDecorations();
|
||||||
Object.entries(businessBlock.properties || {}).forEach(
|
Object.entries(businessBlock.properties || {}).forEach(
|
||||||
([key, value]) => {
|
([key, value]) => {
|
||||||
|
if (value === undefined) {
|
||||||
|
db_block.removeDecoration(key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (decorations[key] !== value) {
|
if (decorations[key] !== value) {
|
||||||
db_block.setDecoration(key, value);
|
db_block.setDecoration(key, value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user