Skip to content

Commit

Permalink
Fixed empty ranges sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Nov 21, 2023
1 parent f1ab8c5 commit f89e1ec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ function findParentByClassNames(element: HTMLElement, classNames: Array<string>)
export function sanitizeEditableContent(element: any) {
if (window.getSelection && document.createRange && element.childNodes.length > 0) {
const selection = document.getSelection();
if (selection.rangeCount == 0) {
return;
}

let range = selection.getRangeAt(0);
range.setStart(range.endContainer, range.endOffset);
Expand Down

0 comments on commit f89e1ec

Please sign in to comment.