editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Bug: editor.onChange is not triggered in case of removing the whole text inside block, if the contenteditable element is not the root node of a block

Open VikhorKonstantin opened this issue 2 years ago • 0 comments

https://github.com/codex-team/editor.js/blob/ee188bfe5de9c99592396250f6fce90f63b2957e/src/components/utils/mutations.ts#L15 - this check won't help if the change happened within some descendant of the 'element'.

For example, if we remove the text inside one of the 'li' items of '@editorjs/nested-list' block, onChange won't be triggered.

This implementation of the isMutationBelongsToElement function might help:

export function isMutationBelongsToElement(mutationRecord: MutationRecord, element: Element): boolean {
    return element.contains(mutationRecord.target);
}

VikhorKonstantin avatar Oct 27 '23 12:10 VikhorKonstantin