delete layout element

This commit is contained in:
Niels Lyngsø
2024-05-28 01:08:00 +02:00
parent cc72365f92
commit 0e5e2e9bb3
2 changed files with 25 additions and 0 deletions

View File

@@ -115,5 +115,6 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
async delete(contentUdi: string) {
// TODO: Loop through children and delete them as well?
await super.delete(contentUdi);
this._manager?.deleteLayoutElement(contentUdi);
}
}

View File

@@ -19,6 +19,18 @@ export class UmbBlockRteManagerContext<
this.#editor = editor;
}
getTinyMceEditor() {
return this.#editor;
}
removeOneLayout(contentUdi: string) {
this._layouts.removeOne(contentUdi);
}
getLayouts(): Array<BlockLayoutType> {
return this._layouts.getValue();
}
create(
contentElementTypeKey: string,
partialLayoutEntry?: Omit<BlockLayoutType, 'contentUdi'>,
@@ -65,4 +77,16 @@ export class UmbBlockRteManagerContext<
return true;
}
/** @internal */
public deleteLayoutElement(contentUdi: string) {
if (!this.#editor) return;
const blockElementsOfThisUdi = this.#editor.dom.select(
`umb-rte-block[data-content-udi='${contentUdi}'], umb-rte-block-inline[data-content-udi='${contentUdi}']`,
);
blockElementsOfThisUdi.forEach((blockElement) => {
this.#editor?.dom.remove(blockElement);
});
}
}