This commit is contained in:
trevrdspcdev 2024-01-28 08:12:06 -08:00 committed by GitHub
commit 3cba6b7f2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View file

@ -749,7 +749,9 @@ export default class Block extends EventsDispatcher<BlockEvents> {
*/
this.toolRenderedElement = pluginsContent;
contentNode.appendChild(this.toolRenderedElement);
if (this.toolRenderedElement !== null) {
contentNode.appendChild(this.toolRenderedElement);
}
/**
* Block Tunes might wrap Block's content node to provide any UI changes

View file

@ -22,14 +22,14 @@ export function isMutationBelongsToElement(mutationRecord: MutationRecord, eleme
if (['characterData', 'attributes'].includes(type)) {
const targetElement = target.nodeType === Node.TEXT_NODE ? target.parentNode : target;
return element.contains(targetElement);
return element && element.contains(targetElement);
}
/**
* Check new/removed nodes
*/
const addedNodesBelongsToBlock = Array.from(addedNodes).some(node => element.contains(node));
const removedNodesBelongsToBlock = Array.from(removedNodes).some(node => element.contains(node));
const addedNodesBelongsToBlock = Array.from(addedNodes).some(node => element && element.contains(node));
const removedNodesBelongsToBlock = Array.from(removedNodes).some(node => element && element.contains(node));
return addedNodesBelongsToBlock || removedNodesBelongsToBlock;
}

View file

@ -17,6 +17,12 @@ export interface BlockTool extends BaseTool {
*/
sanitize?: SanitizerConfig;
/**
* Block Tool's render method
* Returns tool's wrapper or null
*/
render(): HTMLElement | null;
/**
* Process Tool's element in DOM and return raw data
* @param {HTMLElement} block - element created by {@link BlockTool#render} function