@lexical/react 0.1.9 → 0.1.10

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 (34) hide show
  1. package/DEPRECATED_useLexical.dev.js +3 -38
  2. package/DEPRECATED_useLexical.prod.js +1 -2
  3. package/DEPRECATED_useLexicalAutoFormatter.dev.js +4 -4
  4. package/DEPRECATED_useLexicalAutoFormatter.prod.js +8 -7
  5. package/DEPRECATED_useLexicalCharacterLimit.dev.js +2 -2
  6. package/DEPRECATED_useLexicalCharacterLimit.prod.js +3 -3
  7. package/DEPRECATED_useLexicalEditor.dev.js +1 -25
  8. package/DEPRECATED_useLexicalEditor.prod.js +1 -1
  9. package/DEPRECATED_useLexicalHistory.dev.js +1 -1
  10. package/DEPRECATED_useLexicalHistory.prod.js +2 -2
  11. package/DEPRECATED_useLexicalPlainText.dev.js +15 -32
  12. package/DEPRECATED_useLexicalPlainText.prod.js +14 -15
  13. package/DEPRECATED_useLexicalRichText.dev.js +57 -209
  14. package/DEPRECATED_useLexicalRichText.prod.js +26 -29
  15. package/LexicalAutoFormatterPlugin.dev.js +4 -4
  16. package/LexicalAutoFormatterPlugin.prod.js +8 -7
  17. package/LexicalCharacterLimitPlugin.dev.js +2 -2
  18. package/LexicalCharacterLimitPlugin.prod.js +3 -3
  19. package/LexicalComposer.dev.js +1 -6
  20. package/LexicalComposer.prod.js +2 -3
  21. package/LexicalHistoryPlugin.dev.js +1 -1
  22. package/LexicalHistoryPlugin.prod.js +2 -2
  23. package/LexicalPlainTextPlugin.dev.js +12 -8
  24. package/LexicalPlainTextPlugin.prod.js +7 -7
  25. package/LexicalRichTextPlugin.dev.js +54 -185
  26. package/LexicalRichTextPlugin.prod.js +22 -25
  27. package/LexicalTablePlugin.dev.js +1 -1
  28. package/LexicalTablePlugin.prod.js +1 -1
  29. package/LexicalTreeView.dev.js +10 -2
  30. package/LexicalTreeView.prod.js +9 -8
  31. package/package.json +5 -5
  32. package/useLexicalNodeSelection.dev.js +70 -0
  33. package/useLexicalNodeSelection.js +9 -0
  34. package/useLexicalNodeSelection.prod.js +8 -0
@@ -9,10 +9,6 @@
9
9
  var withSubscriptions = require('@lexical/react/withSubscriptions');
10
10
  var lexical = require('lexical');
11
11
  var react = require('react');
12
- var list = require('@lexical/list');
13
- var CodeNode = require('lexical/CodeNode');
14
- var HeadingNode = require('lexical/HeadingNode');
15
- var LinkNode = require('lexical/LinkNode');
16
12
 
17
13
  /**
18
14
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -30,7 +26,7 @@ const COMPOSING_CHARACTER = 1;
30
26
  const INSERT_CHARACTER_AFTER_SELECTION = 2;
31
27
  const DELETE_CHARACTER_BEFORE_SELECTION = 3;
32
28
  const DELETE_CHARACTER_AFTER_SELECTION = 4;
33
- const EditorPriority$1 = 0;
29
+ const EditorPriority = 0;
34
30
 
35
31
  function getDirtyNodes(editorState, dirtyLeavesSet, dirtyElementsSet) {
36
32
  const dirtyLeaves = Array.from(dirtyLeavesSet);
@@ -77,7 +73,7 @@ function getChangeType(prevEditorState, nextEditorState, dirtyLeavesSet, dirtyEl
77
73
  return COMPOSING_CHARACTER;
78
74
  }
79
75
 
80
- if (nextSelection === null || prevSelection === null || !prevSelection.isCollapsed() || !nextSelection.isCollapsed()) {
76
+ if (!lexical.$isRangeSelection(nextSelection) || !lexical.$isRangeSelection(prevSelection) || !prevSelection.isCollapsed() || !nextSelection.isCollapsed()) {
81
77
  return OTHER;
82
78
  }
83
79
 
@@ -319,7 +315,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
319
315
  }
320
316
  };
321
317
 
322
- return withSubscriptions(editor.addListener('command', applyCommand, EditorPriority$1), editor.addListener('update', applyChange));
318
+ return withSubscriptions(editor.addListener('command', applyCommand, EditorPriority), editor.addListener('update', applyChange));
323
319
  }, [clearHistory, delay, editor, historyState]);
324
320
  }
325
321
  function createEmptyHistoryState() {
@@ -439,6 +435,12 @@ function $copyLeafNodeBranchToRoot(leaf, startingOffset, isLeftSide, range, node
439
435
  }
440
436
 
441
437
  function $cloneContents(selection) {
438
+ if (!lexical.$isRangeSelection(selection)) {
439
+ {
440
+ throw Error(`TODO`);
441
+ }
442
+ }
443
+
442
444
  const anchor = selection.anchor;
443
445
  const focus = selection.focus;
444
446
  const anchorOffset = anchor.getCharacterOffset();
@@ -598,170 +600,6 @@ function getPossibleDecoratorNode(focus, isBackward) {
598
600
  *
599
601
  */
600
602
 
601
- const isCodeElement = div => {
602
- return div.style.fontFamily.match('monospace') !== null;
603
- };
604
-
605
- const DOM_NODE_NAME_TO_LEXICAL_NODE = {
606
- '#text': domNode => ({
607
- node: lexical.$createTextNode(domNode.textContent)
608
- }),
609
- a: domNode => {
610
- let node;
611
-
612
- if (domNode instanceof HTMLAnchorElement) {
613
- node = LinkNode.$createLinkNode(domNode.href);
614
- } else {
615
- node = lexical.$createTextNode(domNode.textContent);
616
- }
617
-
618
- return {
619
- node
620
- };
621
- },
622
- b: domNode => {
623
- // $FlowFixMe[incompatible-type] domNode is a <b> since we matched it by nodeName
624
- const b = domNode; // Google Docs wraps all copied HTML in a <b> with font-weight normal
625
-
626
- const hasNormalFontWeight = b.style.fontWeight === 'normal';
627
- return {
628
- forChild: lexicalNode => {
629
- if (lexical.$isTextNode(lexicalNode) && !hasNormalFontWeight) {
630
- lexicalNode.toggleFormat('bold');
631
- }
632
- },
633
- node: null
634
- };
635
- },
636
- br: () => ({
637
- node: lexical.$createLineBreakNode()
638
- }),
639
- div: domNode => {
640
- // $FlowFixMe[incompatible-type] domNode is a <div> since we matched it by nodeName
641
- const div = domNode;
642
- return {
643
- after: childLexicalNodes => {
644
- const domParent = domNode.parentNode;
645
-
646
- if (domParent != null && domNode !== domParent.lastChild) {
647
- childLexicalNodes.push(lexical.$createLineBreakNode());
648
- }
649
-
650
- return childLexicalNodes;
651
- },
652
- node: isCodeElement(div) ? CodeNode.$createCodeNode() : null
653
- };
654
- },
655
- em: domNode => {
656
- return {
657
- forChild: lexicalNode => {
658
- if (lexical.$isTextNode(lexicalNode)) {
659
- lexicalNode.toggleFormat('italic');
660
- }
661
- },
662
- node: null
663
- };
664
- },
665
- h1: () => ({
666
- node: HeadingNode.$createHeadingNode('h1')
667
- }),
668
- h2: () => ({
669
- node: HeadingNode.$createHeadingNode('h2')
670
- }),
671
- h3: () => ({
672
- node: HeadingNode.$createHeadingNode('h3')
673
- }),
674
- h4: () => ({
675
- node: HeadingNode.$createHeadingNode('h4')
676
- }),
677
- h5: () => ({
678
- node: HeadingNode.$createHeadingNode('h5')
679
- }),
680
- i: domNode => {
681
- return {
682
- forChild: lexicalNode => {
683
- if (lexical.$isTextNode(lexicalNode)) {
684
- lexicalNode.toggleFormat('italic');
685
- }
686
- },
687
- node: null
688
- };
689
- },
690
- li: () => ({
691
- node: list.$createListItemNode()
692
- }),
693
- ol: () => ({
694
- node: list.$createListNode('ol')
695
- }),
696
- p: () => ({
697
- node: lexical.$createParagraphNode()
698
- }),
699
- pre: domNode => ({
700
- node: CodeNode.$createCodeNode()
701
- }),
702
- span: domNode => {
703
- // $FlowFixMe[incompatible-type] domNode is a <span> since we matched it by nodeName
704
- const span = domNode; // Google Docs uses span tags + font-weight for bold text
705
-
706
- const hasBoldFontWeight = span.style.fontWeight === '700';
707
- return {
708
- forChild: lexicalNode => {
709
- if (lexical.$isTextNode(lexicalNode) && hasBoldFontWeight) {
710
- lexicalNode.toggleFormat('bold');
711
- }
712
- },
713
- node: null
714
- };
715
- },
716
- strong: domNode => {
717
- return {
718
- forChild: lexicalNode => {
719
- if (lexical.$isTextNode(lexicalNode)) {
720
- lexicalNode.toggleFormat('bold');
721
- }
722
- },
723
- node: null
724
- };
725
- },
726
- table: domNode => {
727
- // $FlowFixMe[incompatible-type] domNode is a <table> since we matched it by nodeName
728
- const table = domNode;
729
- const isGitHubCodeTable = table.classList.contains('js-file-line-container');
730
- return {
731
- node: isGitHubCodeTable ? CodeNode.$createCodeNode() : null
732
- };
733
- },
734
- td: domNode => {
735
- // $FlowFixMe[incompatible-type] domNode is a <table> since we matched it by nodeName
736
- const cell = domNode;
737
- const isGitHubCodeCell = cell.classList.contains('js-file-line');
738
- return {
739
- after: childLexicalNodes => {
740
- if (isGitHubCodeCell && cell.parentNode && cell.parentNode.nextSibling) {
741
- // Append newline between code lines
742
- childLexicalNodes.push(lexical.$createLineBreakNode());
743
- }
744
-
745
- return childLexicalNodes;
746
- },
747
- node: null
748
- };
749
- },
750
- u: domNode => {
751
- return {
752
- forChild: lexicalNode => {
753
- if (lexical.$isTextNode(lexicalNode)) {
754
- lexicalNode.toggleFormat('underline');
755
- }
756
- },
757
- node: null
758
- };
759
- },
760
- ul: () => ({
761
- node: list.$createListNode('ul')
762
- })
763
- };
764
-
765
603
  function $generateNodes(nodeRange) {
766
604
  const {
767
605
  range,
@@ -783,12 +621,34 @@ function $generateNodes(nodeRange) {
783
621
  return nodes;
784
622
  }
785
623
 
786
- function $createNodesFromDOM(node, conversionMap, editor, forChildMap = new Map()) {
624
+ function getConversionFunction(domNode, editor) {
625
+ const {
626
+ nodeName
627
+ } = domNode;
628
+
629
+ const cachedConversions = editor._htmlConversions.get(nodeName.toLowerCase());
630
+
631
+ let currentConversion = null;
632
+
633
+ if (cachedConversions !== undefined) {
634
+ cachedConversions.forEach(cachedConversion => {
635
+ const domConversion = cachedConversion(domNode);
636
+
637
+ if (domConversion !== null) {
638
+ if (currentConversion === null || currentConversion.priority < domConversion.priority) {
639
+ currentConversion = domConversion;
640
+ }
641
+ }
642
+ });
643
+ }
644
+
645
+ return currentConversion !== null ? currentConversion.conversion : null;
646
+ }
647
+
648
+ function $createNodesFromDOM(node, editor, forChildMap = new Map()) {
787
649
  let lexicalNodes = [];
788
650
  let currentLexicalNode = null;
789
- const nodeName = node.nodeName.toLowerCase();
790
- const customHtmlTransforms = editor._config.htmlTransforms || {};
791
- const transformFunction = customHtmlTransforms[nodeName] || conversionMap[nodeName];
651
+ const transformFunction = getConversionFunction(node, editor);
792
652
  const transformOutput = transformFunction ? transformFunction(node) : null;
793
653
  let postTransform = null;
794
654
 
@@ -806,7 +666,7 @@ function $createNodesFromDOM(node, conversionMap, editor, forChildMap = new Map(
806
666
  }
807
667
 
808
668
  if (transformOutput.forChild != null) {
809
- forChildMap.set(nodeName, transformOutput.forChild);
669
+ forChildMap.set(node.nodeName, transformOutput.forChild);
810
670
  }
811
671
  } // If the DOM node doesn't have a transformer, we don't know what
812
672
  // to do with it but we still need to process any childNodes.
@@ -816,7 +676,7 @@ function $createNodesFromDOM(node, conversionMap, editor, forChildMap = new Map(
816
676
  let childLexicalNodes = [];
817
677
 
818
678
  for (let i = 0; i < children.length; i++) {
819
- childLexicalNodes.push(...$createNodesFromDOM(children[i], conversionMap, editor, forChildMap));
679
+ childLexicalNodes.push(...$createNodesFromDOM(children[i], editor, forChildMap));
820
680
  }
821
681
 
822
682
  if (postTransform != null) {
@@ -838,13 +698,13 @@ function $createNodesFromDOM(node, conversionMap, editor, forChildMap = new Map(
838
698
  return lexicalNodes;
839
699
  }
840
700
 
841
- function $generateNodesFromDOM(dom, conversionMap, editor) {
701
+ function $generateNodesFromDOM(dom, editor) {
842
702
  let lexicalNodes = [];
843
703
  const elements = dom.body ? Array.from(dom.body.childNodes) : [];
844
704
  const elementsLength = elements.length;
845
705
 
846
706
  for (let i = 0; i < elementsLength; i++) {
847
- const lexicalNode = $createNodesFromDOM(elements[i], conversionMap, editor);
707
+ const lexicalNode = $createNodesFromDOM(elements[i], editor);
848
708
 
849
709
  if (lexicalNode !== null) {
850
710
  lexicalNodes = lexicalNodes.concat(lexicalNode);
@@ -879,7 +739,7 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
879
739
  if (htmlString) {
880
740
  const parser = new DOMParser();
881
741
  const dom = parser.parseFromString(htmlString, textHtmlMimeType);
882
- const nodes = $generateNodesFromDOM(dom, DOM_NODE_NAME_TO_LEXICAL_NODE, editor); // Wrap text and inline nodes in paragraph nodes so we have all blocks at the top-level
742
+ const nodes = $generateNodesFromDOM(dom, editor); // Wrap text and inline nodes in paragraph nodes so we have all blocks at the top-level
883
743
 
884
744
  const topLevelBlocks = [];
885
745
  let currentBlock = null;
@@ -925,7 +785,7 @@ function onPasteForRichText(event, editor) {
925
785
  const selection = lexical.$getSelection();
926
786
  const clipboardData = event.clipboardData;
927
787
 
928
- if (clipboardData != null && selection !== null) {
788
+ if (clipboardData != null && lexical.$isRangeSelection(selection)) {
929
789
  $insertDataTransferForRichText(clipboardData, selection, editor);
930
790
  }
931
791
  });
@@ -935,7 +795,7 @@ function onCutForRichText(event, editor) {
935
795
  editor.update(() => {
936
796
  const selection = lexical.$getSelection();
937
797
 
938
- if (selection !== null) {
798
+ if (lexical.$isRangeSelection(selection)) {
939
799
  selection.removeText();
940
800
  }
941
801
  });
@@ -974,27 +834,6 @@ function onCopyForRichText(event, editor) {
974
834
  });
975
835
  }
976
836
 
977
- /**
978
- * Copyright (c) Meta Platforms, Inc. and affiliates.
979
- *
980
- * This source code is licensed under the MIT license found in the
981
- * LICENSE file in the root directory of this source tree.
982
- *
983
- *
984
- */
985
- const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
986
-
987
- /**
988
- * Copyright (c) Meta Platforms, Inc. and affiliates.
989
- *
990
- * This source code is licensed under the MIT license found in the
991
- * LICENSE file in the root directory of this source tree.
992
- *
993
- *
994
- */
995
- const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
996
- var useLayoutEffect = useLayoutEffectImpl;
997
-
998
837
  /**
999
838
  * Copyright (c) Meta Platforms, Inc. and affiliates.
1000
839
  *
@@ -1034,7 +873,7 @@ function useLexicalDragonSupport(editor) {
1034
873
  editor.update(() => {
1035
874
  const selection = lexical.$getSelection();
1036
875
 
1037
- if (selection !== null) {
876
+ if (lexical.$isRangeSelection(selection)) {
1038
877
  const anchor = selection.anchor;
1039
878
  let anchorNode = anchor.getNode();
1040
879
  let setSelStart = 0;
@@ -1091,13 +930,17 @@ function useLexicalDragonSupport(editor) {
1091
930
  *
1092
931
  *
1093
932
  */
1094
- const EditorPriority = 0;
1095
933
  function useRichTextSetup(editor) {
1096
- useLayoutEffect(() => {
934
+ react.useEffect(() => {
1097
935
  const removeListener = editor.addListener('command', (type, payload) => {
1098
936
  const selection = lexical.$getSelection();
1099
937
 
1100
- if (selection === null) {
938
+ if (type === 'click' && lexical.$isNodeSelection(selection)) {
939
+ selection.clear();
940
+ return true;
941
+ }
942
+
943
+ if (!lexical.$isRangeSelection(selection)) {
1101
944
  return false;
1102
945
  }
1103
946
 
@@ -1326,8 +1169,13 @@ function useRichTextSetup(editor) {
1326
1169
  }
1327
1170
 
1328
1171
  return false;
1329
- }, EditorPriority);
1330
- editor.execCommand('bootstrapEditor');
1172
+ }, 0);
1173
+ const bootstrapCommandHandled = editor.execCommand('bootstrapEditor');
1174
+
1175
+ if (!bootstrapCommandHandled) {
1176
+ console.warn('bootstrapEditor command was not handled. Did you forget to add <BootstrapPlugin />?');
1177
+ }
1178
+
1331
1179
  return removeListener;
1332
1180
  }, [editor]);
1333
1181
  useLexicalDragonSupport(editor);
@@ -4,32 +4,29 @@
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 l=require("@lexical/react/withSubscriptions"),w=require("lexical"),x=require("react"),z=require("@lexical/list"),A=require("lexical/CodeNode"),B=require("lexical/HeadingNode"),C=require("lexical/LinkNode");
8
- function D(a,c,e,b,d){if(null===a||0===e.size&&0===b.size)return 0;var f=c._selection,h=a._selection;if(d)return 1;if(null===f||null===h||!h.isCollapsed()||!f.isCollapsed())return 0;var g=Array.from(e);b=Array.from(b);e=c._nodeMap;d=[];for(var k=0;k<g.length;k++){const m=e.get(g[k]);void 0!==m&&d.push(m)}for(g=0;g<b.length;g++)b[g][1]&&(k=e.get(b[g][0]),void 0===k||w.$isRootNode(k)||d.push(k));if(0===d.length)return 0;if(1<d.length)return b=c._nodeMap,c=b.get(f.anchor.key),h=b.get(h.anchor.key),c&&
9
- h&&!a._nodeMap.has(c.__key)&&w.$isTextNode(c)&&1===c.__text.length&&1===f.anchor.offset?2:0;c=d[0];a=a._nodeMap.get(c.__key);if(!w.$isTextNode(a)||!w.$isTextNode(c)||a.__mode!==c.__mode)return 0;a=a.__text;c=c.__text;if(a===c)return 0;f=f.anchor;h=h.anchor;if(f.key!==h.key||"text"!==f.type)return 0;f=f.offset;h=h.offset;a=c.length-a.length;return 1===a&&h===f-1?2:-1===a&&h===f+1?3:-1===a&&h===f?4:0}
10
- function E(a,c){let e=Date.now(),b=0;return(d,f,h,g,k,m)=>{const p=Date.now();if(m.has("historic"))return b=0,e=p,2;const n=D(d,f,g,k,a.isComposing()),t=(()=>{const q=m.has("history-push");if(!q&&m.has("history-merge"))return 0;if(null===d)return 1;var r=f._selection;const u=d._selection;if(!(0<g.size||0<k.size))return null===u&&null!==r?0:2;r=null===h||h.editor===a;return!1===q&&0!==n&&n===b&&p<e+c&&r?0:1})();e=p;b=n;return t}}
11
- function F(a,c,e=1E3){const b=x.useMemo(()=>c||{current:null,redoStack:[],undoStack:[]},[c]),d=x.useCallback(()=>{b.undoStack=[];b.redoStack=[];b.current=null},[b]);x.useEffect(()=>{const f=E(a,e);return l(a.addListener("command",h=>{switch(h){case "undo":h=b.redoStack;var g=b.undoStack;if(0!==g.length){var k=b.current;const m=g.pop();null!==k&&(h.push(k),a.execCommand("canRedo",!0));0===g.length&&a.execCommand("canUndo",!1);b.current=m;m.editor.setEditorState(m.editorState.clone(m.undoSelection),
12
- {tag:"historic"})}return!0;case "redo":return h=b.redoStack,g=b.undoStack,0!==h.length&&(k=b.current,null!==k&&(g.push(k),a.execCommand("canUndo",!0)),g=h.pop(),0===h.length&&a.execCommand("canRedo",!1),b.current=g,g.editor.setEditorState(g.editorState,{tag:"historic"})),!0;case "clearEditor":return d(),!1;case "clearHistory":return d(),!0;default:return!1}},0),a.addListener("update",({editorState:h,prevEditorState:g,dirtyLeaves:k,dirtyElements:m,tags:p})=>{const n=b.current,t=b.redoStack,q=b.undoStack,
13
- r=null===n?null:n.editorState;if(null===n||h!==r){k=f(g,h,n,k,m,p);if(1===k)0!==t.length&&(b.redoStack=[]),null!==n&&(q.push({...n,undoSelection:g.read(w.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;b.current={editor:a,editorState:h}}}))},[d,e,a,b])}function G(a,c,e=1E3){return F(a,c,e)}
14
- function H(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;w.$isElementNode(a)&&w.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):w.$isTextNode(a)&&w.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):w.$isDecoratorNode(a)&&w.$isDecoratorNode(c)&&(c.__state=a.__state);return c}
15
- function I(a,c,e,b,d){for(var f=c;null!==a;){for(c=a.getParent();null!==c&&c.excludeFromCopy();)c=c.getParent();if(null===c)break;if(!w.$isElementNode(a)||!a.excludeFromCopy()){const h=a.getKey();let g=d.get(h);const k=void 0===g;k&&(g=H(a),d.set(h,g));!w.$isTextNode(g)||g.isSegmented()||g.isToken()?w.$isElementNode(g)&&(g.__children=g.__children.slice(e?f:0,e?void 0:f+1)):g.__text=g.__text.slice(e?f:0,e?void 0:f);if(w.$isRootNode(c)){k&&b.push(h);break}}f=d.get(c.getKey());f=w.$isElementNode(f)?
16
- f.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=c}}function J(a){a=a.anchor.getNode();return"rtl"===(w.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}function K(a,c,e){const b=a.getParent();let d=e;null!==b&&(c&&0===e?(d=a.getIndexWithinParent(),a=b):c||e!==a.getChildrenSize()||(d=a.getIndexWithinParent()+1,a=b));return a.getChildAtIndex(c?d-1:d)}
17
- const L={"#text":a=>({node:w.$createTextNode(a.textContent)}),a:a=>({node:a instanceof HTMLAnchorElement?C.$createLinkNode(a.href):w.$createTextNode(a.textContent)}),b:a=>{const c="normal"===a.style.fontWeight;return{forChild:e=>{w.$isTextNode(e)&&!c&&e.toggleFormat("bold")},node:null}},br:()=>({node:w.$createLineBreakNode()}),div:a=>({after:c=>{const e=a.parentNode;null!=e&&a!==e.lastChild&&c.push(w.$createLineBreakNode());return c},node:null!==a.style.fontFamily.match("monospace")?A.$createCodeNode():
18
- null}),em:()=>({forChild:a=>{w.$isTextNode(a)&&a.toggleFormat("italic")},node:null}),h1:()=>({node:B.$createHeadingNode("h1")}),h2:()=>({node:B.$createHeadingNode("h2")}),h3:()=>({node:B.$createHeadingNode("h3")}),h4:()=>({node:B.$createHeadingNode("h4")}),h5:()=>({node:B.$createHeadingNode("h5")}),i:()=>({forChild:a=>{w.$isTextNode(a)&&a.toggleFormat("italic")},node:null}),li:()=>({node:z.$createListItemNode()}),ol:()=>({node:z.$createListNode("ol")}),p:()=>({node:w.$createParagraphNode()}),pre:()=>
19
- ({node:A.$createCodeNode()}),span:a=>{const c="700"===a.style.fontWeight;return{forChild:e=>{w.$isTextNode(e)&&c&&e.toggleFormat("bold")},node:null}},strong:()=>({forChild:a=>{w.$isTextNode(a)&&a.toggleFormat("bold")},node:null}),table:a=>({node:a.classList.contains("js-file-line-container")?A.$createCodeNode():null}),td:a=>{const c=a.classList.contains("js-file-line");return{after:e=>{c&&a.parentNode&&a.parentNode.nextSibling&&e.push(w.$createLineBreakNode());return e},node:null}},u:()=>({forChild:a=>
20
- {w.$isTextNode(a)&&a.toggleFormat("underline")},node:null}),ul:()=>({node:z.$createListNode("ul")})};
21
- function M(a,c,e,b=new Map){let d=[],f=null;var h=a.nodeName.toLowerCase(),g=(e._config.htmlTransforms||{})[h]||c[h],k=g?g(a):null;g=null;if(null!==k){g=k.after;f=k.node;if(null!==f){d.push(f);const m=Array.from(b.values());for(let p=0;p<m.length;p++)m[p](f)}null!=k.forChild&&b.set(h,k.forChild)}a=a.childNodes;h=[];for(k=0;k<a.length;k++)h.push(...M(a[k],c,e,b));null!=g&&(h=g(h));null==f?d=d.concat(h):w.$isElementNode(f)&&f.append(...h);return d}
22
- function N(a,c,e){var b=a.getData("application/x-lexical-editor");if(b){var d=e._config.namespace;try{const k=JSON.parse(b);if(k.namespace===d){const {range:m,nodeMap:p}=k.state;var f=new Map(p);b=[];for(d=0;d<m.length;d++){var h=f.get(m[d]);if(void 0!==h){var g=w.$createNodeFromParse(h,f);b.push(g)}}c.insertNodes(b);return}}catch(k){}}if(f=a.getData("text/html")){f=(new DOMParser).parseFromString(f,"text/html");a=[];f=f.body?Array.from(f.body.childNodes):[];h=f.length;for(g=0;g<h;g++)b=M(f[g],L,
23
- e),null!==b&&(a=a.concat(b));e=a;a=[];f=null;for(h=0;h<e.length;h++)g=e[h],!w.$isElementNode(g)||g.isInline()?(null===f&&(f=w.$createParagraphNode(),a.push(f)),null!==f&&f.append(g)):(a.push(g),f=null);c.insertNodes(a)}else e=a.getData("text/plain"),null!=e&&c.insertRawText(e)}
24
- function O(a,c){var e=a.focus;a=e.offset;"element"===e.type?(e=e.getNode(),c=K(e,c,a)):(e=e.getNode(),c&&0===a||!c&&a===e.getTextContentSize()?(a=c?e.getPreviousSibling():e.getNextSibling(),c=null===a?K(e.getParentOrThrow(),c,e.getIndexWithinParent()+(c?0:1)):a):c=null);return w.$isDecoratorNode(c)&&!c.isIsolated()}function P(a,c){a.preventDefault();c.update(()=>{const e=w.$getSelection(),b=a.clipboardData;null!=b&&null!==e&&N(b,e,c)})}
25
- function Q(a,c){R(a,c);c.update(()=>{const e=w.$getSelection();null!==e&&e.removeText()})}
26
- function R(a,c){a.preventDefault();c.update(()=>{const e=a.clipboardData;var b=w.$getSelection();if(null!==b&&null!=e){var d=window.getSelection();if(!d.isCollapsed){var f=d.getRangeAt(0);f&&(d=document.createElement("div"),f=f.cloneContents(),d.appendChild(f),e.setData("text/html",d.innerHTML));e.setData("text/plain",b.getTextContent());d=c._config.namespace;f=e.setData;var h=JSON,g=h.stringify;{var k=b.anchor,m=b.focus;var p=k.getCharacterOffset();const y=m.getCharacterOffset();var n=k.getNode(),
27
- t=m.getNode(),q=n.getParentOrThrow();if(n===t&&w.$isTextNode(n)&&(q.canBeEmpty()||1<q.getChildrenSize()))b=H(n),n=y>p,b.__text=b.__text.slice(n?p:y,n?y:p),p=b.getKey(),p={nodeMap:[[p,b]],range:[p]};else if(b=b.getNodes(),0===b.length)p={nodeMap:[],range:[]};else{n=b.length;t=b[0];q=t.getParent();if(null!==q&&(!q.canBeEmpty()||w.$isRootNode(q))){var r=q.__children;if(r.length===n){var u=!0;for(var v=0;v<r.length;v++)if(r[v]!==b[v].__key){u=!1;break}u&&(n++,b.push(q))}}q=b[n-1];k=k.isBefore(m);m=new Map;
28
- r=[];I(t,k?p:y,!0,r,m);for(t=0;t<n;t++)if(u=b[t],v=u.getKey(),!(m.has(v)||w.$isElementNode(u)&&u.excludeFromCopy())){const S=H(u);w.$isRootNode(u.getParent())&&r.push(u.getKey());m.set(v,S)}I(q,k?y:p,!1,r,m);p={nodeMap:Array.from(m.entries()),range:r}}}f.call(e,"application/x-lexical-editor",g.call(h,{namespace:d,state:p}))}}})}var T="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?x.useLayoutEffect:x.useEffect;
29
- function U(a){x.useEffect(()=>{const c=e=>{var b=a.getRootElement();if(document.activeElement===b&&(b=e.data,"string"===typeof b)){try{var d=JSON.parse(b)}catch(f){return}if(d&&"nuanria_messaging"===d.protocol&&"request"===d.type&&(d=d.payload)&&"makeChanges"===d.functionId&&(d=d.args)){const [f,h,g,k,m]=d;a.update(()=>{const p=w.$getSelection();if(null!==p){var n=p.anchor;let t=n.getNode(),q=0,r=0;w.$isTextNode(t)&&0<=f&&0<=h&&(q=f,r=f+h,p.setTextNodeRange(t,q,t,r));if(q!==r||""!==g)p.insertRawText(g),
30
- t=n.getNode();w.$isTextNode(t)&&(q=k,r=k+m,n=t.getTextContentSize(),q=q>n?n:q,r=r>n?n:r,p.setTextNodeRange(t,q,t,r));e.stopImmediatePropagation()}})}}};window.addEventListener("message",c,!0);return()=>{window.removeEventListener("message",c,!0)}},[a])}
31
- function V(a){T(()=>{const c=a.addListener("command",(e,b)=>{var d=w.$getSelection();if(null===d)return!1;switch(e){case "deleteCharacter":return d.deleteCharacter(b),!0;case "deleteWord":return d.deleteWord(b),!0;case "deleteLine":return d.deleteLine(b),!0;case "insertText":return"string"===typeof b?d.insertText(b):(e=b.dataTransfer,null!=e?N(e,d,a):(b=b.data)&&d.insertText(b)),!0;case "removeText":return d.removeText(),!0;case "formatText":return d.formatText(b),!0;case "formatElement":return d=
32
- d.anchor.getNode(),(w.$isElementNode(d)?d:d.getParentOrThrow()).setFormat(b),!0;case "insertLineBreak":return d.insertLineBreak(b),!0;case "insertParagraph":return d.insertParagraph(),!0;case "indentContent":return d=d.anchor,d="element"===d.type?d.getNode():d.getNode().getParentOrThrow(),d.canInsertTab()?a.execCommand("insertText","\t"):10!==d.getIndent()&&d.setIndent(d.getIndent()+1),!0;case "outdentContent":return d=d.anchor,b=d.getNode(),e="element"===d.type?d.getNode():d.getNode().getParentOrThrow(),
33
- e.canInsertTab()?"\t"===b.getTextContent()[d.offset-1]&&a.execCommand("deleteCharacter",!0):0!==e.getIndent()&&e.setIndent(e.getIndent()-1),!0;case "keyArrowLeft":e=b.shiftKey;if(O(d,!0))return b.preventDefault(),b=e,e=J(d),d.modify(b?"extend":"move",!e,"character"),!0;break;case "keyArrowRight":e=b.shiftKey;if(O(d,!1))return b.preventDefault(),b=e,e=J(d),d.modify(b?"extend":"move",e,"character"),!0;break;case "keyBackspace":return b.preventDefault(),{anchor:b}=d,d.isCollapsed()&&0===b.offset&&0<
34
- ("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),b.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return b.preventDefault(),a.execCommand(b.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),!0;case "copy":return R(b,a),
35
- !0;case "cut":return Q(b,a),!0;case "paste":return P(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0);a.execCommand("bootstrapEditor");return c},[a]);U(a)}module.exports=function(a,c){V(a);G(a,c)};
7
+ var k=require("@lexical/react/withSubscriptions"),w=require("lexical"),y=require("react");
8
+ function z(a,d,e,b,c){if(null===a||0===e.size&&0===b.size)return 0;var f=d._selection,g=a._selection;if(c)return 1;if(!(w.$isRangeSelection(f)&&w.$isRangeSelection(g)&&g.isCollapsed()&&f.isCollapsed()))return 0;var h=Array.from(e);b=Array.from(b);e=d._nodeMap;c=[];for(var l=0;l<h.length;l++){const n=e.get(h[l]);void 0!==n&&c.push(n)}for(h=0;h<b.length;h++)b[h][1]&&(l=e.get(b[h][0]),void 0===l||w.$isRootNode(l)||c.push(l));if(0===c.length)return 0;if(1<c.length)return b=d._nodeMap,d=b.get(f.anchor.key),
9
+ g=b.get(g.anchor.key),d&&g&&!a._nodeMap.has(d.__key)&&w.$isTextNode(d)&&1===d.__text.length&&1===f.anchor.offset?2:0;d=c[0];a=a._nodeMap.get(d.__key);if(!w.$isTextNode(a)||!w.$isTextNode(d)||a.__mode!==d.__mode)return 0;a=a.__text;d=d.__text;if(a===d)return 0;f=f.anchor;g=g.anchor;if(f.key!==g.key||"text"!==f.type)return 0;f=f.offset;g=g.offset;a=d.length-a.length;return 1===a&&g===f-1?2:-1===a&&g===f+1?3:-1===a&&g===f?4:0}
10
+ function A(a,d){let e=Date.now(),b=0;return(c,f,g,h,l,n)=>{const p=Date.now();if(n.has("historic"))return b=0,e=p,2;const m=z(c,f,h,l,a.isComposing()),t=(()=>{const q=n.has("history-push");if(!q&&n.has("history-merge"))return 0;if(null===c)return 1;var r=f._selection;const u=c._selection;if(!(0<h.size||0<l.size))return null===u&&null!==r?0:2;r=null===g||g.editor===a;return!1===q&&0!==m&&m===b&&p<e+d&&r?0:1})();e=p;b=m;return t}}
11
+ function B(a,d,e=1E3){const b=y.useMemo(()=>d||{current:null,redoStack:[],undoStack:[]},[d]),c=y.useCallback(()=>{b.undoStack=[];b.redoStack=[];b.current=null},[b]);y.useEffect(()=>{const f=A(a,e);return k(a.addListener("command",g=>{switch(g){case "undo":g=b.redoStack;var h=b.undoStack;if(0!==h.length){var l=b.current;const n=h.pop();null!==l&&(g.push(l),a.execCommand("canRedo",!0));0===h.length&&a.execCommand("canUndo",!1);b.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection),
12
+ {tag:"historic"})}return!0;case "redo":return g=b.redoStack,h=b.undoStack,0!==g.length&&(l=b.current,null!==l&&(h.push(l),a.execCommand("canUndo",!0)),h=g.pop(),0===g.length&&a.execCommand("canRedo",!1),b.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:l,dirtyElements:n,tags:p})=>{const m=b.current,t=b.redoStack,q=b.undoStack,
13
+ r=null===m?null:m.editorState;if(null===m||g!==r){l=f(h,g,m,l,n,p);if(1===l)0!==t.length&&(b.redoStack=[]),null!==m&&(q.push({...m,undoSelection:h.read(w.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;b.current={editor:a,editorState:g}}}))},[c,e,a,b])}function C(a,d,e=1E3){return B(a,d,e)}
14
+ function D(a){a=a.getLatest();const d=a.constructor.clone(a);d.__parent=a.__parent;w.$isElementNode(a)&&w.$isElementNode(d)?(d.__children=Array.from(a.__children),d.__format=a.__format,d.__indent=a.__indent,d.__dir=a.__dir):w.$isTextNode(a)&&w.$isTextNode(d)?(d.__format=a.__format,d.__style=a.__style,d.__mode=a.__mode,d.__detail=a.__detail):w.$isDecoratorNode(a)&&w.$isDecoratorNode(d)&&(d.__state=a.__state);return d}
15
+ function E(a,d,e,b,c){for(var f=d;null!==a;){for(d=a.getParent();null!==d&&d.excludeFromCopy();)d=d.getParent();if(null===d)break;if(!w.$isElementNode(a)||!a.excludeFromCopy()){const g=a.getKey();let h=c.get(g);const l=void 0===h;l&&(h=D(a),c.set(g,h));!w.$isTextNode(h)||h.isSegmented()||h.isToken()?w.$isElementNode(h)&&(h.__children=h.__children.slice(e?f:0,e?void 0:f+1)):h.__text=h.__text.slice(e?f:0,e?void 0:f);if(w.$isRootNode(d)){l&&b.push(g);break}}f=c.get(d.getKey());f=w.$isElementNode(f)?
16
+ f.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=d}}function F(a){a=a.anchor.getNode();return"rtl"===(w.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}function G(a,d,e){const b=a.getParent();let c=e;null!==b&&(d&&0===e?(c=a.getIndexWithinParent(),a=b):d||e!==a.getChildrenSize()||(c=a.getIndexWithinParent()+1,a=b));return a.getChildAtIndex(d?c-1:c)}
17
+ function H(a,d){const {nodeName:e}=a;d=d._htmlConversions.get(e.toLowerCase());let b=null;void 0!==d&&d.forEach(c=>{c=c(a);null!==c&&(null===b||b.priority<c.priority)&&(b=c)});return null!==b?b.conversion:null}
18
+ function I(a,d,e=new Map){let b=[],c=null;var f=H(a,d),g=f?f(a):null;f=null;if(null!==g){f=g.after;c=g.node;if(null!==c){b.push(c);var h=Array.from(e.values());for(let l=0;l<h.length;l++)h[l](c)}null!=g.forChild&&e.set(a.nodeName,g.forChild)}a=a.childNodes;g=[];for(h=0;h<a.length;h++)g.push(...I(a[h],d,e));null!=f&&(g=f(g));null==c?b=b.concat(g):w.$isElementNode(c)&&c.append(...g);return b}
19
+ function J(a,d,e){var b=a.getData("application/x-lexical-editor");if(b){var c=e._config.namespace;try{const l=JSON.parse(b);if(l.namespace===c){const {range:n,nodeMap:p}=l.state;var f=new Map(p);b=[];for(c=0;c<n.length;c++){var g=f.get(n[c]);if(void 0!==g){var h=w.$createNodeFromParse(g,f);b.push(h)}}d.insertNodes(b);return}}catch(l){}}if(f=a.getData("text/html")){f=(new DOMParser).parseFromString(f,"text/html");a=[];f=f.body?Array.from(f.body.childNodes):[];g=f.length;for(h=0;h<g;h++)b=I(f[h],e),
20
+ null!==b&&(a=a.concat(b));e=a;a=[];f=null;for(g=0;g<e.length;g++)h=e[g],!w.$isElementNode(h)||h.isInline()?(null===f&&(f=w.$createParagraphNode(),a.push(f)),null!==f&&f.append(h)):(a.push(h),f=null);d.insertNodes(a)}else e=a.getData("text/plain"),null!=e&&d.insertRawText(e)}
21
+ function K(a,d){var e=a.focus;a=e.offset;"element"===e.type?(e=e.getNode(),d=G(e,d,a)):(e=e.getNode(),d&&0===a||!d&&a===e.getTextContentSize()?(a=d?e.getPreviousSibling():e.getNextSibling(),d=null===a?G(e.getParentOrThrow(),d,e.getIndexWithinParent()+(d?0:1)):a):d=null);return w.$isDecoratorNode(d)&&!d.isIsolated()}function L(a,d){a.preventDefault();d.update(()=>{const e=w.$getSelection(),b=a.clipboardData;null!=b&&w.$isRangeSelection(e)&&J(b,e,d)})}
22
+ function M(a,d){N(a,d);d.update(()=>{const e=w.$getSelection();w.$isRangeSelection(e)&&e.removeText()})}
23
+ function N(a,d){a.preventDefault();d.update(()=>{const e=a.clipboardData;var b=w.$getSelection();if(null!==b&&null!=e){var c=window.getSelection();if(!c.isCollapsed){var f=c.getRangeAt(0);f&&(c=document.createElement("div"),f=f.cloneContents(),c.appendChild(f),e.setData("text/html",c.innerHTML));e.setData("text/plain",b.getTextContent());c=d._config.namespace;f=e.setData;var g=JSON,h=g.stringify;{if(!w.$isRangeSelection(b))throw Error("Minified Lexical error #68; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");
24
+ var l=b.anchor,n=b.focus;var p=l.getCharacterOffset();const x=n.getCharacterOffset();var m=l.getNode(),t=n.getNode(),q=m.getParentOrThrow();if(m===t&&w.$isTextNode(m)&&(q.canBeEmpty()||1<q.getChildrenSize()))b=D(m),m=x>p,b.__text=b.__text.slice(m?p:x,m?x:p),p=b.getKey(),p={nodeMap:[[p,b]],range:[p]};else if(b=b.getNodes(),0===b.length)p={nodeMap:[],range:[]};else{m=b.length;t=b[0];q=t.getParent();if(null!==q&&(!q.canBeEmpty()||w.$isRootNode(q))){var r=q.__children;if(r.length===m){var u=!0;for(var v=
25
+ 0;v<r.length;v++)if(r[v]!==b[v].__key){u=!1;break}u&&(m++,b.push(q))}}q=b[m-1];l=l.isBefore(n);n=new Map;r=[];E(t,l?p:x,!0,r,n);for(t=0;t<m;t++)if(u=b[t],v=u.getKey(),!(n.has(v)||w.$isElementNode(u)&&u.excludeFromCopy())){const O=D(u);w.$isRootNode(u.getParent())&&r.push(u.getKey());n.set(v,O)}E(q,l?x:p,!1,r,n);p={nodeMap:Array.from(n.entries()),range:r}}}f.call(e,"application/x-lexical-editor",h.call(g,{namespace:c,state:p}))}}})}
26
+ function P(a){y.useEffect(()=>{const d=e=>{var b=a.getRootElement();if(document.activeElement===b&&(b=e.data,"string"===typeof b)){try{var c=JSON.parse(b)}catch(f){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [f,g,h,l,n]=c;a.update(()=>{const p=w.$getSelection();if(w.$isRangeSelection(p)){var m=p.anchor;let t=m.getNode(),q=0,r=0;w.$isTextNode(t)&&0<=f&&0<=g&&(q=f,r=f+g,p.setTextNodeRange(t,q,t,r));if(q!==r||""!==
27
+ h)p.insertRawText(h),t=m.getNode();w.$isTextNode(t)&&(q=l,r=l+n,m=t.getTextContentSize(),q=q>m?m:q,r=r>m?m:r,p.setTextNodeRange(t,q,t,r));e.stopImmediatePropagation()}})}}};window.addEventListener("message",d,!0);return()=>{window.removeEventListener("message",d,!0)}},[a])}
28
+ function Q(a){y.useEffect(()=>{const d=a.addListener("command",(e,b)=>{var c=w.$getSelection();if("click"===e&&w.$isNodeSelection(c))return c.clear(),!0;if(!w.$isRangeSelection(c))return!1;switch(e){case "deleteCharacter":return c.deleteCharacter(b),!0;case "deleteWord":return c.deleteWord(b),!0;case "deleteLine":return c.deleteLine(b),!0;case "insertText":return"string"===typeof b?c.insertText(b):(e=b.dataTransfer,null!=e?J(e,c,a):(b=b.data)&&c.insertText(b)),!0;case "removeText":return c.removeText(),
29
+ !0;case "formatText":return c.formatText(b),!0;case "formatElement":return c=c.anchor.getNode(),(w.$isElementNode(c)?c:c.getParentOrThrow()).setFormat(b),!0;case "insertLineBreak":return c.insertLineBreak(b),!0;case "insertParagraph":return c.insertParagraph(),!0;case "indentContent":return c=c.anchor,c="element"===c.type?c.getNode():c.getNode().getParentOrThrow(),c.canInsertTab()?a.execCommand("insertText","\t"):10!==c.getIndent()&&c.setIndent(c.getIndent()+1),!0;case "outdentContent":return c=c.anchor,
30
+ b=c.getNode(),e="element"===c.type?c.getNode():c.getNode().getParentOrThrow(),e.canInsertTab()?"\t"===b.getTextContent()[c.offset-1]&&a.execCommand("deleteCharacter",!0):0!==e.getIndent()&&e.setIndent(e.getIndent()-1),!0;case "keyArrowLeft":e=b.shiftKey;if(K(c,!0))return b.preventDefault(),b=e,e=F(c),c.modify(b?"extend":"move",!e,"character"),!0;break;case "keyArrowRight":e=b.shiftKey;if(K(c,!1))return b.preventDefault(),b=e,e=F(c),c.modify(b?"extend":"move",e,"character"),!0;break;case "keyBackspace":return b.preventDefault(),
31
+ {anchor:b}=c,c.isCollapsed()&&0===b.offset&&0<("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),b.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return b.preventDefault(),a.execCommand(b.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),
32
+ !0;case "copy":return N(b,a),!0;case "cut":return M(b,a),!0;case "paste":return L(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0);a.execCommand("bootstrapEditor");return d},[a]);P(a)}module.exports=function(a,d){Q(a);C(a,d)};
@@ -469,7 +469,7 @@ function removeTextInCaptureGroups(regExCaptureGroupsToDelete, matchResultContex
469
469
  lexical.$setSelection(newSelection);
470
470
  const currentSelection = lexical.$getSelection();
471
471
 
472
- if (currentSelection != null) {
472
+ if (lexical.$isRangeSelection(currentSelection)) {
473
473
  currentSelection.removeText(); // Shift offsets for capture groups which are within the same node
474
474
 
475
475
  if (anchorTextNodeWithOffset.node.getKey() === focusTextNodeWithOffset.node.getKey()) {
@@ -535,7 +535,7 @@ function formatTextInCaptureGroupIndex(formatType, captureGroupIndex, matchResul
535
535
  lexical.$setSelection(newSelection);
536
536
  const currentSelection = lexical.$getSelection();
537
537
 
538
- if (currentSelection != null) {
538
+ if (lexical.$isRangeSelection(currentSelection)) {
539
539
  currentSelection.formatText(formatType);
540
540
  const finalSelection = lexical.$createRangeSelection();
541
541
  finalSelection.anchor.set(focusTextNodeWithOffset.node.getKey(), focusTextNodeWithOffset.offset + 1, 'text');
@@ -591,7 +591,7 @@ function getCriteriaWithMatchResultContext(autoFormatCriteriaArray, scanningCont
591
591
  }
592
592
 
593
593
  function getTextNodeForAutoFormatting(selection) {
594
- if (selection == null) {
594
+ if (!lexical.$isRangeSelection(selection)) {
595
595
  return null;
596
596
  }
597
597
 
@@ -665,7 +665,7 @@ function getTriggerState(editorState) {
665
665
  editorState.read(() => {
666
666
  const selection = lexical.$getSelection();
667
667
 
668
- if (selection == null || !selection.isCollapsed()) {
668
+ if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed()) {
669
669
  return;
670
670
  }
671
671
 
@@ -14,12 +14,13 @@ function L(g,f){g.update(()=>{if(f.autoFormatCriteria.requiresParagraphStart){va
14
14
  A.$createHeadingNode("h2");a.append(...d);break;case "paragraphH3":a=A.$createHeadingNode("h3");a.append(...d);break;case "paragraphBlockQuote":a=B.$createQuoteNode();a.append(...d);break;case "paragraphUnorderedList":a=p.$createListNode("ul");c=p.$createListItemNode();c.append(...d);a.append(c);break;case "paragraphOrderedList":a=parseInt(1<k.regExCaptureGroups.length?k.regExCaptureGroups[k.regExCaptureGroups.length-1].text:"1",10);a=p.$createListNode("ol",a);c=p.$createListItemNode();c.append(...d);
15
15
  a.append(c);break;case "paragraphCodeBlock":a=null!=f.triggerState&&f.triggerState.isCodeBlock?q.$createParagraphNode():r.$createCodeNode();a.append(...d);break;case "horizontalRule":d=w.$createHorizontalRuleNode(),c.insertBefore(d)}null!==a&&b.replace(a)}else if(a=f.autoFormatCriteria,b=f.matchResultContext,null!=a.nodeTransformationKind)switch(a.nodeTransformationKind){case "textBold":if(6===b.regExCaptureGroups.length){a=f.autoFormatCriteria;d=f.matchResultContext.regExCaptureGroups;c=d.length;
16
16
  e=f.textNodeWithOffset.node.getParentOrThrow();null==f.joinedText&&C(62);k=f.joinedText.length;for(var n=1;n<c;n++){var h=d[n];h.anchorTextNodeWithOffset=D(e,k,h.offsetInParent,1);h.focusTextNodeWithOffset=D(e,k,h.offsetInParent+h.textLength,1);0>h.textLength&&C(63,a.nodeTransformationKind)}b.regExCaptureGroups=d;a=[1,5];d=b.regExCaptureGroups;c=d.length;for(e=a.length-1;0<=e;e--)if(e<c){k=a[e];var m=d[k];h=m.anchorTextNodeWithOffset;n=m.focusTextNodeWithOffset;null!=h&&null!=n&&0<m.textLength&&(m=
17
- q.$createRangeSelection(),m.anchor.set(h.node.getKey(),h.offset,"text"),m.focus.set(n.node.getKey(),n.offset,"text"),q.$setSelection(m),m=q.$getSelection(),null!=m&&(m.removeText(),h.node.getKey()===n.node.getKey()?(m=n.offset-h.offset,0<m||C(64),K(-m,n.offset,h.node,k,b)):(h=n.offset,0<h&&K(-h,h,n.node,k,b))))}a=b.regExCaptureGroups;3<a.length||C(65);c=a[3];d=c.anchorTextNodeWithOffset;a=c.focusTextNodeWithOffset;null!=d&&null!=a&&0<c.textLength&&(c=q.$createRangeSelection(),c.anchor.set(d.node.getKey(),
18
- d.offset,"text"),c.focus.set(a.node.getKey(),a.offset,"text"),q.$setSelection(c),d=q.$getSelection(),null!=d&&(d.formatText("bold"),d=q.$createRangeSelection(),d.anchor.set(a.node.getKey(),a.offset+1,"text"),d.focus.set(a.node.getKey(),a.offset+1,"text"),q.$setSelection(d)));a=f.textNodeWithOffset.node.getParentOrThrow();b=D(a,b.offsetInJoinedTextForCollapsedSelection+1,b.offsetInJoinedTextForCollapsedSelection,1);null!=b&&(a=q.$createRangeSelection(),a.anchor.set(b.node.getKey(),b.offset,"text"),
19
- a.focus.set(b.node.getKey(),b.offset,"text"),q.$setSelection(a))}}},{tag:"history-push"})}
20
- function M(g,f){let a=null;g.read(()=>{var b=q.$getSelection();if(null==b)b=null;else{var c=b.anchor.getNode();b=q.$isTextNode(c)?{node:c,offset:b.anchor.offset}:null}if(null!==b){b={autoFormatCriteria:{nodeTransformationKind:"noTransformation",regEx:/(?:)/,requiresParagraphStart:null},joinedText:null,matchResultContext:{offsetInJoinedTextForCollapsedSelection:0,regExCaptureGroups:[]},textNodeWithOffset:b,triggerState:f};a:{c=!1===f.isParentAListItemNode?I:H;const m=b.triggerState,N=c.length;for(let x=
21
- 0;x<N;x++){const y=c[x];if(null!=m&&!1===m.isCodeBlock||"paragraphCodeBlock"===y.nodeTransformationKind){var d=y,e=b;if(null!==d.requiresParagraphStart&&!0===d.requiresParagraphStart)null===e.textNodeWithOffset.node.getPreviousSibling()?(e=e.textNodeWithOffset.node.getTextContent(),d=J(e,!0,!1,d.regEx)):d=null;else b:{if(null==e.joinedText){var k=e.textNodeWithOffset.node.getParentOrThrow();if(q.$isElementNode(k)){if(null==e.joinedText){var n=e,h=e.textNodeWithOffset;let u="";k=k.getChildren();const O=
22
- k.length;for(let z=0;z<O;++z){const t=k[z];if(q.$isTextNode(t)){const F=t.getTextContent();if(t.is(h.node)){h.offset>F.length&&C(50,t.__key);u+=t.getTextContent().substr(0,h.offset);break}else u+=F}else u+="\u0004"}n.joinedText=u}d=J(e.joinedText,!1,!0,d.regEx);break b}C(52,k.__key)}d=null}if(null!=d){c={autoFormatCriteria:y,matchResultContext:d};break a}}}c={autoFormatCriteria:null,matchResultContext:null}}null!==c.autoFormatCriteria&&null!==c.matchResultContext&&(a=b,a.autoFormatCriteria=c.autoFormatCriteria,
23
- a.matchResultContext=c.matchResultContext)}});return a}function P(g){let f=null;g.read(()=>{const a=q.$getSelection();if(null!=a&&a.isCollapsed()){var b=a.anchor.getNode(),c=b.getParent(),d=null!==c&&p.$isListItemNode(c);f={anchorOffset:a.anchor.offset,hasParentNode:null!==c,isCodeBlock:r.$isCodeNode(b),isParentAListItemNode:d,isSelectionCollapsed:a.isCollapsed(),isSimpleText:q.$isTextNode(b)&&b.isSimpleText(),nodeKey:b.getKey(),textContent:b.getTextContent()}}});return f}
17
+ q.$createRangeSelection(),m.anchor.set(h.node.getKey(),h.offset,"text"),m.focus.set(n.node.getKey(),n.offset,"text"),q.$setSelection(m),m=q.$getSelection(),q.$isRangeSelection(m)&&(m.removeText(),h.node.getKey()===n.node.getKey()?(m=n.offset-h.offset,0<m||C(64),K(-m,n.offset,h.node,k,b)):(h=n.offset,0<h&&K(-h,h,n.node,k,b))))}a=b.regExCaptureGroups;3<a.length||C(65);c=a[3];d=c.anchorTextNodeWithOffset;a=c.focusTextNodeWithOffset;null!=d&&null!=a&&0<c.textLength&&(c=q.$createRangeSelection(),c.anchor.set(d.node.getKey(),
18
+ d.offset,"text"),c.focus.set(a.node.getKey(),a.offset,"text"),q.$setSelection(c),d=q.$getSelection(),q.$isRangeSelection(d)&&(d.formatText("bold"),d=q.$createRangeSelection(),d.anchor.set(a.node.getKey(),a.offset+1,"text"),d.focus.set(a.node.getKey(),a.offset+1,"text"),q.$setSelection(d)));a=f.textNodeWithOffset.node.getParentOrThrow();b=D(a,b.offsetInJoinedTextForCollapsedSelection+1,b.offsetInJoinedTextForCollapsedSelection,1);null!=b&&(a=q.$createRangeSelection(),a.anchor.set(b.node.getKey(),b.offset,
19
+ "text"),a.focus.set(b.node.getKey(),b.offset,"text"),q.$setSelection(a))}}},{tag:"history-push"})}
20
+ function M(g,f){let a=null;g.read(()=>{var b=q.$getSelection();if(q.$isRangeSelection(b)){var c=b.anchor.getNode();b=q.$isTextNode(c)?{node:c,offset:b.anchor.offset}:null}else b=null;if(null!==b){b={autoFormatCriteria:{nodeTransformationKind:"noTransformation",regEx:/(?:)/,requiresParagraphStart:null},joinedText:null,matchResultContext:{offsetInJoinedTextForCollapsedSelection:0,regExCaptureGroups:[]},textNodeWithOffset:b,triggerState:f};a:{c=!1===f.isParentAListItemNode?I:H;const m=b.triggerState,
21
+ N=c.length;for(let x=0;x<N;x++){const y=c[x];if(null!=m&&!1===m.isCodeBlock||"paragraphCodeBlock"===y.nodeTransformationKind){var d=y,e=b;if(null!==d.requiresParagraphStart&&!0===d.requiresParagraphStart)null===e.textNodeWithOffset.node.getPreviousSibling()?(e=e.textNodeWithOffset.node.getTextContent(),d=J(e,!0,!1,d.regEx)):d=null;else b:{if(null==e.joinedText){var k=e.textNodeWithOffset.node.getParentOrThrow();if(q.$isElementNode(k)){if(null==e.joinedText){var n=e,h=e.textNodeWithOffset;let u="";
22
+ k=k.getChildren();const O=k.length;for(let z=0;z<O;++z){const t=k[z];if(q.$isTextNode(t)){const F=t.getTextContent();if(t.is(h.node)){h.offset>F.length&&C(50,t.__key);u+=t.getTextContent().substr(0,h.offset);break}else u+=F}else u+="\u0004"}n.joinedText=u}d=J(e.joinedText,!1,!0,d.regEx);break b}C(52,k.__key)}d=null}if(null!=d){c={autoFormatCriteria:y,matchResultContext:d};break a}}}c={autoFormatCriteria:null,matchResultContext:null}}null!==c.autoFormatCriteria&&null!==c.matchResultContext&&(a=b,a.autoFormatCriteria=
23
+ c.autoFormatCriteria,a.matchResultContext=c.matchResultContext)}});return a}
24
+ function P(g){let f=null;g.read(()=>{const a=q.$getSelection();if(q.$isRangeSelection(a)&&a.isCollapsed()){var b=a.anchor.getNode(),c=b.getParent(),d=null!==c&&p.$isListItemNode(c);f={anchorOffset:a.anchor.offset,hasParentNode:null!==c,isCodeBlock:r.$isCodeNode(b),isParentAListItemNode:d,isSelectionCollapsed:a.isCollapsed(),isSimpleText:q.$isTextNode(b)&&b.isSimpleText(),nodeKey:b.getKey(),textContent:b.getTextContent()}}});return f}
24
25
  function Q(g){v.useEffect(()=>{let f=null;return g.addListener("update",({tags:a})=>{if(!1===a.has("historic")){var b=g.getEditorState();a=P(b);if(null==a)b=null;else{var c=a,d=f;if(null==c||null==d)b=null;else{var e=c.textContent.length,k=c.anchorOffset-1;b=!1===(!0===c.hasParentNode&&c.isSimpleText&&c.isSelectionCollapsed&&c.nodeKey===d.nodeKey&&c.anchorOffset!==d.anchorOffset&&0<=k&&k+1<=e&&" "===c.textContent.substr(k,1)&&c.textContent!==d.textContent)?null:M(b,c)}}null!=b&&L(g,b);f=a}else f=
25
26
  null})},[g])}module.exports=function(){const [g]=l.useLexicalComposerContext();Q(g);return null};
@@ -174,7 +174,7 @@ function $wrapOverflowedNodes(offset) {
174
174
  $unwrapNode(node);
175
175
  const selection = lexical.$getSelection(); // Restore selection when the overflow children are removed
176
176
 
177
- if (selection !== null && (!selection.anchor.getNode().isAttached() || !selection.focus.getNode().isAttached())) {
177
+ if (lexical.$isRangeSelection(selection) && (!selection.anchor.getNode().isAttached() || !selection.focus.getNode().isAttached())) {
178
178
  if (lexical.$isTextNode(previousSibling)) {
179
179
  previousSibling.select();
180
180
  } else if (lexical.$isTextNode(nextSibling)) {
@@ -268,7 +268,7 @@ function mergePrevious(overflowNode) {
268
268
 
269
269
  const selection = lexical.$getSelection();
270
270
 
271
- if (selection !== null) {
271
+ if (lexical.$isRangeSelection(selection)) {
272
272
  const anchor = selection.anchor;
273
273
  const anchorNode = anchor.getNode();
274
274
  const focus = selection.focus;
@@ -7,8 +7,8 @@
7
7
  var l=require("@lexical/react/LexicalComposerContext"),p=require("react"),q=require("lexical"),r=require("@lexical/react/withSubscriptions"),t=require("lexical/OverflowNode");function u(a,e){for(e(a);null!==a;){if(q.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let f=null;for(;null===f&&null!==a;)f=a.getNextSibling(),a=null===f?a.getParent():f}null!==a&&(a=e(a))}}function w(){return q.$getRoot().getTextContent()}
8
8
  function x(a,e,f=Object.freeze({})){const {strlen:h=c=>c.length,remainingCharacters:d=()=>{}}=f;p.useEffect(()=>{if(!a.hasNodes([t.OverflowNode]))throw Error("Minified Lexical error #58; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[a]);p.useEffect(()=>{let c=a.getEditorState().read(w),b=0;return r(a.addListener("textcontent",g=>{c=g}),a.addListener("update",({dirtyLeaves:g})=>{var k=a.isComposing();g=0<g.size;if(!k&&
9
9
  g){k=h(c);g=k>e||null!==b&&b>e;d(e-k);if(null===b||g){const n=y(c,e,h);a.update(()=>{z(n)},{tag:"history-merge"})}b=k}}))},[a,e,d,h])}function y(a,e,f){var h=Intl.Segmenter;let d=0;var c=0;if("function"===typeof h){a=(new h).segment(a);for(var {segment:b}of a){c+=f(b);if(c>e)break;d+=b.length}}else for(b=Array.from(a),a=b.length,h=0;h<a;h++){const g=b[h];c+=f(g);if(c>e)break;d+=g.length}return d}
10
- function z(a){const e=q.$getRoot();let f=0,h=e;u(e,d=>{if(t.$isOverflowNode(d)){var c=f;if(f+d.getTextContentSize()<=a){var b=d.getParent();c=d.getPreviousSibling();var g=d.getNextSibling();A(d);d=q.$getSelection();null===d||d.anchor.getNode().isAttached()&&d.focus.getNode().isAttached()||(q.$isTextNode(c)?c.select():q.$isTextNode(g)?g.select():null!==b&&b.select());return h}if(c<a&&(b=d.getFirstDescendant(),g=null!==b?b.getTextContentSize():0,c+=g,b=q.$isTextNode(b)&&b.isSimpleText(),c=c<=a,b||c))return A(d),
11
- h}else if(q.$isLeafNode(d)&&(c=f,f+=d.getTextContentSize(),f>a&&!t.$isOverflowNode(d.getParent())&&(b=q.$getSelection(),c<a&&q.$isTextNode(d)&&d.isSimpleText()?([,c]=d.splitText(a-c),c=B(c)):c=B(d),null!==b&&q.$setSelection(b),b=c,g=b.getPreviousSibling(),t.$isOverflowNode(g)))){var k=b.getFirstChild(),n=g.getChildren();c=n.length;if(null===k)b.append(...n);else for(var m=0;m<c;m++)k.insertBefore(n[m]);m=q.$getSelection();if(null!==m){k=m.anchor;n=k.getNode();m=m.focus;const v=k.getNode();n.is(g)?
12
- k.set(b.getKey(),k.offset,"element"):n.is(b)&&k.set(b.getKey(),c+k.offset,"element");v.is(g)?m.set(b.getKey(),m.offset,"element"):v.is(b)&&m.set(b.getKey(),c+m.offset,"element")}g.remove()}return h=d})}function B(a){const e=t.$createOverflowNode();a.insertBefore(e);e.append(a);return e}function A(a){const e=a.getChildren(),f=e.length;for(let h=0;h<f;h++)a.insertBefore(e[h]);a.remove();return 0<f?e[f-1]:null}let C=null;
10
+ function z(a){const e=q.$getRoot();let f=0,h=e;u(e,d=>{if(t.$isOverflowNode(d)){var c=f;if(f+d.getTextContentSize()<=a){var b=d.getParent();c=d.getPreviousSibling();var g=d.getNextSibling();A(d);d=q.$getSelection();!q.$isRangeSelection(d)||d.anchor.getNode().isAttached()&&d.focus.getNode().isAttached()||(q.$isTextNode(c)?c.select():q.$isTextNode(g)?g.select():null!==b&&b.select());return h}if(c<a&&(b=d.getFirstDescendant(),g=null!==b?b.getTextContentSize():0,c+=g,b=q.$isTextNode(b)&&b.isSimpleText(),
11
+ c=c<=a,b||c))return A(d),h}else if(q.$isLeafNode(d)&&(c=f,f+=d.getTextContentSize(),f>a&&!t.$isOverflowNode(d.getParent())&&(b=q.$getSelection(),c<a&&q.$isTextNode(d)&&d.isSimpleText()?([,c]=d.splitText(a-c),c=B(c)):c=B(d),null!==b&&q.$setSelection(b),b=c,g=b.getPreviousSibling(),t.$isOverflowNode(g)))){var k=b.getFirstChild(),n=g.getChildren();c=n.length;if(null===k)b.append(...n);else for(var m=0;m<c;m++)k.insertBefore(n[m]);m=q.$getSelection();if(q.$isRangeSelection(m)){k=m.anchor;n=k.getNode();
12
+ m=m.focus;const v=k.getNode();n.is(g)?k.set(b.getKey(),k.offset,"element"):n.is(b)&&k.set(b.getKey(),c+k.offset,"element");v.is(g)?m.set(b.getKey(),m.offset,"element"):v.is(b)&&m.set(b.getKey(),c+m.offset,"element")}g.remove()}return h=d})}function B(a){const e=t.$createOverflowNode();a.insertBefore(e);e.append(a);return e}function A(a){const e=a.getChildren(),f=e.length;for(let h=0;h<f;h++)a.insertBefore(e[h]);a.remove();return 0<f?e[f-1]:null}let C=null;
13
13
  module.exports=function({charset:a="UTF-16"}){const [e]=l.useLexicalComposerContext(),[f,h]=p.useState(0),d=p.useMemo(()=>({remainingCharacters:h,strlen:c=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var b=null;else null===C&&(C=new window.TextEncoder),b=C;null===b?(b=encodeURIComponent(c).match(/%[89ABab]/g),c=c.length+(b?b.length:0)):c=b.encode(c).length;return c}if("UTF-16"===a)return c.length;throw Error("Unrecognized charset");}}),[a]);x(e,5,d);return p.createElement("span",{className:`characters-limit ${0>
14
14
  f?"characters-limit-exceeded":""}`},f)};