Skip to content

Commit

Permalink
chore(core): update note
Browse files Browse the repository at this point in the history
  • Loading branch information
pubuzhixing8 committed Mar 20, 2023
1 parent 61e66e6 commit ecc665f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/src/components/editable/editable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ export class SlateEditableComponent implements OnInit, OnChanges, OnDestroy, Aft
if (type === 'deleteContentBackward') {
let [nativeTargetRange] = event.getTargetRanges();
const targetRange = AngularEditor.toSlateRange(editor, nativeTargetRange);
// Gboard can not prevent default action, so must use restoreDom, Sougou Keyboard can prevent default action.
// gboard can not prevent default action, so must use restoreDom,
// sougou Keyboard can prevent default action(only in Chinese input mode).
// In order to avoid weird action in Sougou Keyboard, use resotreDom only range's isCollapsed is false (recognize gboard)
if (!Range.isCollapsed(targetRange)) {
restoreDom(editor, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/src/utils/restore-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export function restoreDom(editor: Editor, execute: () => void) {
disconnect();
execute();
});
observer.observe(editable, { subtree: true, childList: true, characterData: true, characterDataOldValue: true });
const disconnect = () => {
observer.disconnect();
observer = null;
};
observer.observe(editable, { subtree: true, childList: true, characterData: true, characterDataOldValue: true });
setTimeout(() => {
if (observer) {
disconnect();
Expand Down

0 comments on commit ecc665f

Please sign in to comment.