@lexical/react 0.1.12 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/DEPRECATED_useLexicalAutoFormatter.dev.js +283 -295
  2. package/DEPRECATED_useLexicalAutoFormatter.prod.js +19 -21
  3. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +3 -72
  4. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +1 -2
  5. package/DEPRECATED_useLexicalCharacterLimit.dev.js +11 -63
  6. package/DEPRECATED_useLexicalCharacterLimit.prod.js +6 -7
  7. package/DEPRECATED_useLexicalPlainText.dev.js +16 -41
  8. package/DEPRECATED_useLexicalPlainText.prod.js +13 -14
  9. package/DEPRECATED_useLexicalRichText.dev.js +24 -49
  10. package/DEPRECATED_useLexicalRichText.prod.js +15 -15
  11. package/LexicalAutoFormatterPlugin.dev.js +283 -295
  12. package/LexicalAutoFormatterPlugin.prod.js +19 -21
  13. package/LexicalAutoLinkPlugin.dev.js +2 -2
  14. package/LexicalAutoLinkPlugin.prod.js +2 -2
  15. package/LexicalCharacterLimitPlugin.dev.js +11 -63
  16. package/LexicalCharacterLimitPlugin.prod.js +8 -9
  17. package/LexicalCollaborationPlugin.d.ts +5 -1
  18. package/LexicalCollaborationPlugin.dev.js +77 -16
  19. package/LexicalCollaborationPlugin.js.flow +7 -2
  20. package/LexicalCollaborationPlugin.prod.js +9 -7
  21. package/LexicalComposer.d.ts +1 -1
  22. package/LexicalComposer.dev.js +1 -1
  23. package/LexicalComposer.js.flow +3 -3
  24. package/LexicalComposer.prod.js +1 -1
  25. package/LexicalHashtagPlugin.dev.js +61 -3
  26. package/LexicalHashtagPlugin.prod.js +7 -4
  27. package/LexicalNestedComposer.d.ts +4 -7
  28. package/LexicalNestedComposer.dev.js +21 -11
  29. package/LexicalNestedComposer.js.flow +3 -6
  30. package/LexicalNestedComposer.prod.js +3 -2
  31. package/LexicalOnChangePlugin.dev.js +15 -2
  32. package/LexicalOnChangePlugin.prod.js +2 -1
  33. package/LexicalPlainTextPlugin.dev.js +20 -113
  34. package/LexicalPlainTextPlugin.prod.js +11 -12
  35. package/LexicalRichTextPlugin.dev.js +28 -121
  36. package/LexicalRichTextPlugin.prod.js +12 -13
  37. package/LexicalTablePlugin.dev.js +9 -5
  38. package/LexicalTablePlugin.prod.js +2 -2
  39. package/package.json +11 -6
  40. package/useLexicalIsTextContentEmpty.dev.js +3 -32
  41. package/useLexicalIsTextContentEmpty.prod.js +1 -2
@@ -10,6 +10,7 @@ var withSubscriptions = require('@lexical/react/withSubscriptions');
10
10
  var lexical = require('lexical');
11
11
  var react = require('react');
12
12
  var clipboard = require('@lexical/clipboard');
13
+ var selection = require('@lexical/selection');
13
14
 
14
15
  /**
15
16
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -339,32 +340,6 @@ function useLexicalHistory(editor, externalHistoryState, delay = 1000) {
339
340
  return useHistory(editor, externalHistoryState, delay);
340
341
  }
341
342
 
342
- /**
343
- * Copyright (c) Meta Platforms, Inc. and affiliates.
344
- *
345
- * This source code is licensed under the MIT license found in the
346
- * LICENSE file in the root directory of this source tree.
347
- *
348
- *
349
- */
350
-
351
- function $moveCaretSelection(selection, isHoldingShift, isBackward, granularity) {
352
- selection.modify(isHoldingShift ? 'extend' : 'move', isBackward, granularity);
353
- }
354
- function $isParentElementRTL(selection) {
355
- const anchorNode = selection.anchor.getNode();
356
- const parent = lexical.$isRootNode(anchorNode) ? anchorNode : anchorNode.getParentOrThrow();
357
- return parent.getDirection() === 'rtl';
358
- }
359
- function $moveCharacter(selection, isHoldingShift, isBackward) {
360
- const isRTL = $isParentElementRTL(selection);
361
- $moveCaretSelection(selection, isHoldingShift, isBackward ? !isRTL : isRTL, 'character');
362
- }
363
- function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
364
- const possibleNode = lexical.$getDecoratorNode(selection.focus, isBackward);
365
- return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
366
- }
367
-
368
343
  /**
369
344
  * Copyright (c) Meta Platforms, Inc. and affiliates.
370
345
  *
@@ -595,14 +570,14 @@ function useLexicalDragonSupport(editor) {
595
570
  function useRichTextSetup(editor, initialEditorState) {
596
571
  useLayoutEffect(() => {
597
572
  const removeListener = editor.addListener('command', (type, payload) => {
598
- const selection = lexical.$getSelection();
573
+ const selection$1 = lexical.$getSelection();
599
574
 
600
- if (type === 'click' && lexical.$isNodeSelection(selection)) {
601
- selection.clear();
575
+ if (type === 'click' && lexical.$isNodeSelection(selection$1)) {
576
+ selection$1.clear();
602
577
  return true;
603
578
  }
604
579
 
605
- if (!lexical.$isRangeSelection(selection)) {
580
+ if (!lexical.$isRangeSelection(selection$1)) {
606
581
  return false;
607
582
  }
608
583
 
@@ -610,21 +585,21 @@ function useRichTextSetup(editor, initialEditorState) {
610
585
  case 'deleteCharacter':
611
586
  {
612
587
  const isBackward = payload;
613
- selection.deleteCharacter(isBackward);
588
+ selection$1.deleteCharacter(isBackward);
614
589
  return true;
615
590
  }
616
591
 
617
592
  case 'deleteWord':
618
593
  {
619
594
  const isBackward = payload;
620
- selection.deleteWord(isBackward);
595
+ selection$1.deleteWord(isBackward);
621
596
  return true;
622
597
  }
623
598
 
624
599
  case 'deleteLine':
625
600
  {
626
601
  const isBackward = payload;
627
- selection.deleteLine(isBackward);
602
+ selection$1.deleteLine(isBackward);
628
603
  return true;
629
604
  }
630
605
 
@@ -633,17 +608,17 @@ function useRichTextSetup(editor, initialEditorState) {
633
608
  const eventOrText = payload;
634
609
 
635
610
  if (typeof eventOrText === 'string') {
636
- selection.insertText(eventOrText);
611
+ selection$1.insertText(eventOrText);
637
612
  } else {
638
613
  const dataTransfer = eventOrText.dataTransfer;
639
614
 
640
615
  if (dataTransfer != null) {
641
- clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor);
616
+ clipboard.$insertDataTransferForRichText(dataTransfer, selection$1, editor);
642
617
  } else {
643
618
  const data = eventOrText.data;
644
619
 
645
620
  if (data) {
646
- selection.insertText(data);
621
+ selection$1.insertText(data);
647
622
  }
648
623
  }
649
624
  }
@@ -652,20 +627,20 @@ function useRichTextSetup(editor, initialEditorState) {
652
627
  }
653
628
 
654
629
  case 'removeText':
655
- selection.removeText();
630
+ selection$1.removeText();
656
631
  return true;
657
632
 
658
633
  case 'formatText':
659
634
  {
660
635
  const format = payload;
661
- selection.formatText(format);
636
+ selection$1.formatText(format);
662
637
  return true;
663
638
  }
664
639
 
665
640
  case 'formatElement':
666
641
  {
667
642
  const format = payload;
668
- const node = selection.anchor.getNode();
643
+ const node = selection$1.anchor.getNode();
669
644
  const element = lexical.$isElementNode(node) ? node : node.getParentOrThrow();
670
645
  element.setFormat(format);
671
646
  return true;
@@ -673,17 +648,17 @@ function useRichTextSetup(editor, initialEditorState) {
673
648
 
674
649
  case 'insertLineBreak':
675
650
  const selectStart = payload;
676
- selection.insertLineBreak(selectStart);
651
+ selection$1.insertLineBreak(selectStart);
677
652
  return true;
678
653
 
679
654
  case 'insertParagraph':
680
- selection.insertParagraph();
655
+ selection$1.insertParagraph();
681
656
  return true;
682
657
 
683
658
  case 'indentContent':
684
659
  {
685
660
  // Handle code blocks
686
- const anchor = selection.anchor;
661
+ const anchor = selection$1.anchor;
687
662
  const parentBlock = anchor.type === 'element' ? anchor.getNode() : anchor.getNode().getParentOrThrow();
688
663
 
689
664
  if (parentBlock.canInsertTab()) {
@@ -700,7 +675,7 @@ function useRichTextSetup(editor, initialEditorState) {
700
675
  case 'outdentContent':
701
676
  {
702
677
  // Handle code blocks
703
- const anchor = selection.anchor;
678
+ const anchor = selection$1.anchor;
704
679
  const anchorNode = anchor.getNode();
705
680
  const parentBlock = anchor.type === 'element' ? anchor.getNode() : anchor.getNode().getParentOrThrow();
706
681
 
@@ -725,9 +700,9 @@ function useRichTextSetup(editor, initialEditorState) {
725
700
  const event = payload;
726
701
  const isHoldingShift = event.shiftKey;
727
702
 
728
- if ($shouldOverrideDefaultCharacterSelection(selection, true)) {
703
+ if (selection.$shouldOverrideDefaultCharacterSelection(selection$1, true)) {
729
704
  event.preventDefault();
730
- $moveCharacter(selection, isHoldingShift, true);
705
+ selection.$moveCharacter(selection$1, isHoldingShift, true);
731
706
  return true;
732
707
  }
733
708
 
@@ -739,9 +714,9 @@ function useRichTextSetup(editor, initialEditorState) {
739
714
  const event = payload;
740
715
  const isHoldingShift = event.shiftKey;
741
716
 
742
- if ($shouldOverrideDefaultCharacterSelection(selection, false)) {
717
+ if (selection.$shouldOverrideDefaultCharacterSelection(selection$1, false)) {
743
718
  event.preventDefault();
744
- $moveCharacter(selection, isHoldingShift, false);
719
+ selection.$moveCharacter(selection$1, isHoldingShift, false);
745
720
  return true;
746
721
  }
747
722
 
@@ -754,9 +729,9 @@ function useRichTextSetup(editor, initialEditorState) {
754
729
  event.preventDefault();
755
730
  const {
756
731
  anchor
757
- } = selection;
732
+ } = selection$1;
758
733
 
759
- if (selection.isCollapsed() && anchor.offset === 0) {
734
+ if (selection$1.isCollapsed() && anchor.offset === 0) {
760
735
  const element = anchor.type === 'element' ? anchor.getNode() : anchor.getNode().getParentOrThrow();
761
736
 
762
737
  if (element.getIndent() > 0) {
@@ -4,20 +4,20 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- var h=require("@lexical/react/withSubscriptions"),u=require("lexical"),v=require("react"),w=require("@lexical/clipboard");
8
- function x(a,e,f,d,c){if(null===a||0===f.size&&0===d.size)return 0;var b=e._selection,g=a._selection;if(c)return 1;if(!(u.$isRangeSelection(b)&&u.$isRangeSelection(g)&&g.isCollapsed()&&b.isCollapsed()))return 0;var k=Array.from(f);d=Array.from(d);f=e._nodeMap;c=[];for(var l=0;l<k.length;l++){const n=f.get(k[l]);void 0!==n&&c.push(n)}for(k=0;k<d.length;k++)d[k][1]&&(l=f.get(d[k][0]),void 0===l||u.$isRootNode(l)||c.push(l));if(0===c.length)return 0;if(1<c.length)return d=e._nodeMap,e=d.get(b.anchor.key),
7
+ var l=require("@lexical/react/withSubscriptions"),u=require("lexical"),v=require("react"),w=require("@lexical/clipboard"),x=require("@lexical/selection");
8
+ function y(a,e,f,d,c){if(null===a||0===f.size&&0===d.size)return 0;var b=e._selection,g=a._selection;if(c)return 1;if(!(u.$isRangeSelection(b)&&u.$isRangeSelection(g)&&g.isCollapsed()&&b.isCollapsed()))return 0;var h=Array.from(f);d=Array.from(d);f=e._nodeMap;c=[];for(var k=0;k<h.length;k++){const n=f.get(h[k]);void 0!==n&&c.push(n)}for(h=0;h<d.length;h++)d[h][1]&&(k=f.get(d[h][0]),void 0===k||u.$isRootNode(k)||c.push(k));if(0===c.length)return 0;if(1<c.length)return d=e._nodeMap,e=d.get(b.anchor.key),
9
9
  g=d.get(g.anchor.key),e&&g&&!a._nodeMap.has(e.__key)&&u.$isTextNode(e)&&1===e.__text.length&&1===b.anchor.offset?2:0;e=c[0];a=a._nodeMap.get(e.__key);if(!u.$isTextNode(a)||!u.$isTextNode(e)||a.__mode!==e.__mode)return 0;a=a.__text;e=e.__text;if(a===e)return 0;b=b.anchor;g=g.anchor;if(b.key!==g.key||"text"!==b.type)return 0;b=b.offset;g=g.offset;a=e.length-a.length;return 1===a&&g===b-1?2:-1===a&&g===b+1?3:-1===a&&g===b?4:0}
10
- function y(a,e){let f=Date.now(),d=0;return(c,b,g,k,l,n)=>{const t=Date.now();if(n.has("historic"))return d=0,f=t,2;const m=x(c,b,k,l,a.isComposing()),r=(()=>{const q=n.has("history-push");if(!q&&n.has("history-merge"))return 0;if(null===c)return 1;var p=b._selection;const D=c._selection;if(!(0<k.size||0<l.size))return null===D&&null!==p?0:2;p=null===g||g.editor===a;return!1===q&&0!==m&&m===d&&t<f+e&&p?0:1})();f=t;d=m;return r}}
11
- function z(a,e,f=1E3){const d=v.useMemo(()=>e||{current:null,redoStack:[],undoStack:[]},[e]),c=v.useCallback(()=>{d.undoStack=[];d.redoStack=[];d.current=null},[d]);v.useEffect(()=>{const b=y(a,f);return h(a.addListener("command",g=>{switch(g){case "undo":g=d.redoStack;var k=d.undoStack;if(0!==k.length){var l=d.current;const n=k.pop();null!==l&&(g.push(l),a.execCommand("canRedo",!0));0===k.length&&a.execCommand("canUndo",!1);d.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection),
12
- {tag:"historic"})}return!0;case "redo":return g=d.redoStack,k=d.undoStack,0!==g.length&&(l=d.current,null!==l&&(k.push(l),a.execCommand("canUndo",!0)),k=g.pop(),0===g.length&&a.execCommand("canRedo",!1),d.current=k,k.editor.setEditorState(k.editorState,{tag:"historic"})),!0;case "clearEditor":return c(),!1;case "clearHistory":return c(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:k,dirtyLeaves:l,dirtyElements:n,tags:t})=>{const m=d.current,r=d.redoStack,q=d.undoStack,
13
- p=null===m?null:m.editorState;if(null===m||g!==p){l=b(k,g,m,l,n,t);if(1===l)0!==r.length&&(d.redoStack=[]),null!==m&&(q.push({...m,undoSelection:k.read(u.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;d.current={editor:a,editorState:g}}}))},[c,f,a,d])}function A(a,e,f=1E3){return z(a,e,f)}function B(a){a=a.anchor.getNode();return"rtl"===(u.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}
14
- function C(a,e){a=u.$getDecoratorNode(a.focus,e);return u.$isDecoratorNode(a)&&!a.isIsolated()}var E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?v.useLayoutEffect:v.useEffect;function F(a,e){G(a,e);e.update(()=>{const f=u.$getSelection();u.$isRangeSelection(f)&&f.removeText()})}
15
- function G(a,e){a.preventDefault();e.update(()=>{const f=a.clipboardData,d=u.$getSelection();if(null!==d&&null!=f){const c=w.getHtmlContent(e),b=w.$getLexicalContent(e);null!==c&&f.setData("text/html",c);null!==b&&f.setData("application/x-lexical-editor",b);f.setData("text/plain",d.getTextContent())}})}function H(a,e){a.preventDefault();e.update(()=>{const f=u.$getSelection(),d=a.clipboardData;null!=d&&u.$isRangeSelection(f)&&w.$insertDataTransferForRichText(d,f,e)})}const I={tag:"history-merge"};
16
- function J(a,e){if(null!==e)if(void 0===e)a.update(()=>{var f=u.$getRoot();if(null===f.getFirstChild()){const d=u.$createParagraphNode();f.append(d);f=document.activeElement;(null!==u.$getSelection()||null!==f&&f===a.getRootElement())&&d.select()}},I);else if(null!==e)switch(typeof e){case "string":e=a.parseEditorState(e);a.setEditorState(e,I);break;case "object":a.setEditorState(e,I);break;case "function":a.update(e,I)}}
17
- function K(a){v.useEffect(()=>{const e=f=>{var d=a.getRootElement();if(document.activeElement===d&&(d=f.data,"string"===typeof d)){try{var c=JSON.parse(d)}catch(b){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [b,g,k,l,n]=c;a.update(()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){var m=t.anchor;let r=m.getNode(),q=0,p=0;u.$isTextNode(r)&&0<=b&&0<=g&&(q=b,p=b+g,t.setTextNodeRange(r,q,r,p));if(q!==p||""!==
18
- k)t.insertRawText(k),r=m.getNode();u.$isTextNode(r)&&(q=l,p=l+n,m=r.getTextContentSize(),q=q>m?m:q,p=p>m?m:p,t.setTextNodeRange(r,q,r,p));f.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
19
- function L(a,e){E(()=>{const f=a.addListener("command",(d,c)=>{var b=u.$getSelection();if("click"===d&&u.$isNodeSelection(b))return b.clear(),!0;if(!u.$isRangeSelection(b))return!1;switch(d){case "deleteCharacter":return b.deleteCharacter(c),!0;case "deleteWord":return b.deleteWord(c),!0;case "deleteLine":return b.deleteLine(c),!0;case "insertText":return"string"===typeof c?b.insertText(c):(d=c.dataTransfer,null!=d?w.$insertDataTransferForRichText(d,b,a):(c=c.data)&&b.insertText(c)),!0;case "removeText":return b.removeText(),
10
+ function z(a,e){let f=Date.now(),d=0;return(c,b,g,h,k,n)=>{const t=Date.now();if(n.has("historic"))return d=0,f=t,2;const m=y(c,b,h,k,a.isComposing()),r=(()=>{const q=n.has("history-push");if(!q&&n.has("history-merge"))return 0;if(null===c)return 1;var p=b._selection;const C=c._selection;if(!(0<h.size||0<k.size))return null===C&&null!==p?0:2;p=null===g||g.editor===a;return!1===q&&0!==m&&m===d&&t<f+e&&p?0:1})();f=t;d=m;return r}}
11
+ function A(a,e,f=1E3){const d=v.useMemo(()=>e||{current:null,redoStack:[],undoStack:[]},[e]),c=v.useCallback(()=>{d.undoStack=[];d.redoStack=[];d.current=null},[d]);v.useEffect(()=>{const b=z(a,f);return l(a.addListener("command",g=>{switch(g){case "undo":g=d.redoStack;var h=d.undoStack;if(0!==h.length){var k=d.current;const n=h.pop();null!==k&&(g.push(k),a.execCommand("canRedo",!0));0===h.length&&a.execCommand("canUndo",!1);d.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection),
12
+ {tag:"historic"})}return!0;case "redo":return g=d.redoStack,h=d.undoStack,0!==g.length&&(k=d.current,null!==k&&(h.push(k),a.execCommand("canUndo",!0)),h=g.pop(),0===g.length&&a.execCommand("canRedo",!1),d.current=h,h.editor.setEditorState(h.editorState,{tag:"historic"})),!0;case "clearEditor":return c(),!1;case "clearHistory":return c(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:h,dirtyLeaves:k,dirtyElements:n,tags:t})=>{const m=d.current,r=d.redoStack,q=d.undoStack,
13
+ p=null===m?null:m.editorState;if(null===m||g!==p){k=b(h,g,m,k,n,t);if(1===k)0!==r.length&&(d.redoStack=[]),null!==m&&(q.push({...m,undoSelection:h.read(u.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;d.current={editor:a,editorState:g}}}))},[c,f,a,d])}function B(a,e,f=1E3){return A(a,e,f)}var D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?v.useLayoutEffect:v.useEffect;
14
+ function E(a,e){F(a,e);e.update(()=>{const f=u.$getSelection();u.$isRangeSelection(f)&&f.removeText()})}function F(a,e){a.preventDefault();e.update(()=>{const f=a.clipboardData,d=u.$getSelection();if(null!==d&&null!=f){const c=w.getHtmlContent(e),b=w.$getLexicalContent(e);null!==c&&f.setData("text/html",c);null!==b&&f.setData("application/x-lexical-editor",b);f.setData("text/plain",d.getTextContent())}})}
15
+ function G(a,e){a.preventDefault();e.update(()=>{const f=u.$getSelection(),d=a.clipboardData;null!=d&&u.$isRangeSelection(f)&&w.$insertDataTransferForRichText(d,f,e)})}const H={tag:"history-merge"};
16
+ function I(a,e){if(null!==e)if(void 0===e)a.update(()=>{var f=u.$getRoot();if(null===f.getFirstChild()){const d=u.$createParagraphNode();f.append(d);f=document.activeElement;(null!==u.$getSelection()||null!==f&&f===a.getRootElement())&&d.select()}},H);else if(null!==e)switch(typeof e){case "string":e=a.parseEditorState(e);a.setEditorState(e,H);break;case "object":a.setEditorState(e,H);break;case "function":a.update(e,H)}}
17
+ function J(a){v.useEffect(()=>{const e=f=>{var d=a.getRootElement();if(document.activeElement===d&&(d=f.data,"string"===typeof d)){try{var c=JSON.parse(d)}catch(b){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [b,g,h,k,n]=c;a.update(()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){var m=t.anchor;let r=m.getNode(),q=0,p=0;u.$isTextNode(r)&&0<=b&&0<=g&&(q=b,p=b+g,t.setTextNodeRange(r,q,r,p));if(q!==p||""!==
18
+ h)t.insertRawText(h),r=m.getNode();u.$isTextNode(r)&&(q=k,p=k+n,m=r.getTextContentSize(),q=q>m?m:q,p=p>m?m:p,t.setTextNodeRange(r,q,r,p));f.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
19
+ function K(a,e){D(()=>{const f=a.addListener("command",(d,c)=>{var b=u.$getSelection();if("click"===d&&u.$isNodeSelection(b))return b.clear(),!0;if(!u.$isRangeSelection(b))return!1;switch(d){case "deleteCharacter":return b.deleteCharacter(c),!0;case "deleteWord":return b.deleteWord(c),!0;case "deleteLine":return b.deleteLine(c),!0;case "insertText":return"string"===typeof c?b.insertText(c):(d=c.dataTransfer,null!=d?w.$insertDataTransferForRichText(d,b,a):(c=c.data)&&b.insertText(c)),!0;case "removeText":return b.removeText(),
20
20
  !0;case "formatText":return b.formatText(c),!0;case "formatElement":return b=b.anchor.getNode(),(u.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(c),!0;case "insertLineBreak":return b.insertLineBreak(c),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor,
21
- c=b.getNode(),d="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),d.canInsertTab()?"\t"===c.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==d.getIndent()&&d.setIndent(d.getIndent()-1),!0;case "keyArrowLeft":d=c.shiftKey;if(C(b,!0))return c.preventDefault(),c=d,d=B(b),b.modify(c?"extend":"move",!d,"character"),!0;break;case "keyArrowRight":d=c.shiftKey;if(C(b,!1))return c.preventDefault(),c=d,d=B(b),b.modify(c?"extend":"move",d,"character"),!0;break;case "keyBackspace":return c.preventDefault(),
22
- {anchor:c}=b,b.isCollapsed()&&0===c.offset&&0<("element"===c.type?c.getNode():c.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return c.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return c.preventDefault(),c.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return c.preventDefault(),a.execCommand(c.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),
23
- !0;case "copy":return G(c,a),!0;case "cut":return F(c,a),!0;case "paste":return H(c,a),!0;case "drop":case "dragstart":return c.preventDefault(),!0}return!1},0);J(a,e);return f},[a]);K(a)}module.exports=function(a,e,f){L(a,f);A(a,e)};
21
+ c=b.getNode(),d="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),d.canInsertTab()?"\t"===c.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==d.getIndent()&&d.setIndent(d.getIndent()-1),!0;case "keyArrowLeft":d=c.shiftKey;if(x.$shouldOverrideDefaultCharacterSelection(b,!0))return c.preventDefault(),x.$moveCharacter(b,d,!0),!0;break;case "keyArrowRight":d=c.shiftKey;if(x.$shouldOverrideDefaultCharacterSelection(b,!1))return c.preventDefault(),x.$moveCharacter(b,d,!1),
22
+ !0;break;case "keyBackspace":return c.preventDefault(),{anchor:c}=b,b.isCollapsed()&&0===c.offset&&0<("element"===c.type?c.getNode():c.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return c.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return c.preventDefault(),c.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return c.preventDefault(),a.execCommand(c.shiftKey?
23
+ "outdentContent":"indentContent");case "keyEscape":return a.blur(),!0;case "copy":return F(c,a),!0;case "cut":return E(c,a),!0;case "paste":return G(c,a),!0;case "drop":case "dragstart":return c.preventDefault(),!0}return!1},0);I(a,e);return f},[a]);J(a)}module.exports=function(a,e,f){K(a,f);B(a,e)};