@lexical/react 0.1.8 → 0.1.9

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 (53) hide show
  1. package/DEPRECATED_useLexical.prod.js +1 -1
  2. package/DEPRECATED_useLexicalAutoFormatter.dev.js +142 -55
  3. package/DEPRECATED_useLexicalAutoFormatter.prod.js +19 -16
  4. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +1 -1
  5. package/DEPRECATED_useLexicalCharacterLimit.dev.js +1 -2
  6. package/DEPRECATED_useLexicalCharacterLimit.prod.js +3 -3
  7. package/DEPRECATED_useLexicalDecorators.prod.js +1 -1
  8. package/DEPRECATED_useLexicalEditor.prod.js +1 -1
  9. package/DEPRECATED_useLexicalEditorEvents.prod.js +1 -1
  10. package/DEPRECATED_useLexicalHistory.dev.js +17 -14
  11. package/DEPRECATED_useLexicalHistory.prod.js +7 -7
  12. package/DEPRECATED_useLexicalList.prod.js +1 -1
  13. package/DEPRECATED_useLexicalPlainText.dev.js +46 -23
  14. package/DEPRECATED_useLexicalPlainText.prod.js +16 -16
  15. package/DEPRECATED_useLexicalRichText.dev.js +47 -24
  16. package/DEPRECATED_useLexicalRichText.prod.js +27 -27
  17. package/LexicalAutoFormatterPlugin.dev.js +142 -55
  18. package/LexicalAutoFormatterPlugin.prod.js +19 -17
  19. package/LexicalAutoLinkPlugin.prod.js +4 -4
  20. package/LexicalBootstrapPlugin.dev.js +0 -2
  21. package/LexicalBootstrapPlugin.prod.js +2 -2
  22. package/LexicalCharacterLimitPlugin.dev.js +1 -2
  23. package/LexicalCharacterLimitPlugin.prod.js +3 -3
  24. package/LexicalCollaborationPlugin.dev.js +11 -26
  25. package/LexicalCollaborationPlugin.prod.js +7 -8
  26. package/LexicalComposer.prod.js +1 -1
  27. package/LexicalComposerContext.prod.js +1 -1
  28. package/LexicalContentEditable.prod.js +1 -1
  29. package/LexicalHashtagPlugin.prod.js +1 -1
  30. package/LexicalHistoryPlugin.dev.js +17 -14
  31. package/LexicalHistoryPlugin.prod.js +6 -6
  32. package/LexicalHorizontalRuleNode.dev.js +66 -0
  33. package/LexicalHorizontalRuleNode.js +9 -0
  34. package/LexicalHorizontalRuleNode.prod.js +8 -0
  35. package/LexicalLinkPlugin.dev.js +0 -1
  36. package/LexicalLinkPlugin.prod.js +3 -3
  37. package/LexicalListPlugin.prod.js +1 -1
  38. package/LexicalNestedComposer.prod.js +1 -1
  39. package/LexicalOnChangePlugin.prod.js +1 -1
  40. package/LexicalPlainTextPlugin.dev.js +29 -9
  41. package/LexicalPlainTextPlugin.prod.js +12 -11
  42. package/LexicalRichTextPlugin.dev.js +30 -10
  43. package/LexicalRichTextPlugin.prod.js +16 -16
  44. package/LexicalTablePlugin.dev.js +20 -38
  45. package/LexicalTablePlugin.prod.js +3 -3
  46. package/LexicalTreeView.prod.js +1 -1
  47. package/package.json +5 -4
  48. package/useLexicalDecoratorMap.prod.js +1 -1
  49. package/useLexicalIsTextContentEmpty.prod.js +1 -1
  50. package/withSubscriptions.prod.js +1 -1
  51. package/LexicalHorizontalRulePlugin.dev.js +0 -51
  52. package/LexicalHorizontalRulePlugin.js +0 -9
  53. package/LexicalHorizontalRulePlugin.prod.js +0 -7
@@ -18,9 +18,9 @@ var react = require('react');
18
18
  *
19
19
  *
20
20
  */
21
- const MERGE = 0;
22
- const NO_MERGE = 1;
23
- const DISCARD = 2;
21
+ const HISTORY_MERGE = 0;
22
+ const HISTORY_PUSH = 1;
23
+ const DISCARD_HISTORY_CANDIDATE = 2;
24
24
  const OTHER = 0;
25
25
  const COMPOSING_CHARACTER = 1;
26
26
  const INSERT_CHARACTER_AFTER_SELECTION = 2;
@@ -148,18 +148,21 @@ function createMergeActionGetter(editor, delay) {
148
148
  if (tags.has('historic')) {
149
149
  prevChangeType = OTHER;
150
150
  prevChangeTime = changeTime;
151
- return DISCARD;
151
+ return DISCARD_HISTORY_CANDIDATE;
152
152
  }
153
153
 
154
154
  const changeType = getChangeType(prevEditorState, nextEditorState, dirtyLeaves, dirtyElements, editor.isComposing());
155
155
 
156
156
  const mergeAction = (() => {
157
- if (tags.has('without-history')) {
158
- return MERGE;
157
+ const shouldPushHistory = tags.has('history-push');
158
+ const shouldMergeHistory = !shouldPushHistory && tags.has('history-merge');
159
+
160
+ if (shouldMergeHistory) {
161
+ return HISTORY_MERGE;
159
162
  }
160
163
 
161
164
  if (prevEditorState === null) {
162
- return NO_MERGE;
165
+ return HISTORY_PUSH;
163
166
  }
164
167
 
165
168
  const selection = nextEditorState._selection;
@@ -168,19 +171,19 @@ function createMergeActionGetter(editor, delay) {
168
171
 
169
172
  if (!hasDirtyNodes) {
170
173
  if (prevSelection === null && selection !== null) {
171
- return MERGE;
174
+ return HISTORY_MERGE;
172
175
  }
173
176
 
174
- return DISCARD;
177
+ return DISCARD_HISTORY_CANDIDATE;
175
178
  }
176
179
 
177
180
  const isSameEditor = currentHistoryEntry === null || currentHistoryEntry.editor === editor;
178
181
 
179
- if (changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
180
- return MERGE;
182
+ if (shouldPushHistory === false && changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
183
+ return HISTORY_MERGE;
181
184
  }
182
185
 
183
- return NO_MERGE;
186
+ return HISTORY_PUSH;
184
187
  })();
185
188
 
186
189
  prevChangeTime = changeTime;
@@ -217,7 +220,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
217
220
 
218
221
  const mergeAction = getMergeAction(prevEditorState, editorState, current, dirtyLeaves, dirtyElements, tags);
219
222
 
220
- if (mergeAction === NO_MERGE) {
223
+ if (mergeAction === HISTORY_PUSH) {
221
224
  if (redoStack.length !== 0) {
222
225
  historyState.redoStack = [];
223
226
  }
@@ -228,7 +231,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
228
231
  });
229
232
  editor.execCommand('canUndo', true);
230
233
  }
231
- } else if (mergeAction === DISCARD) {
234
+ } else if (mergeAction === DISCARD_HISTORY_CANDIDATE) {
232
235
  return;
233
236
  } // Else we merge
234
237
 
@@ -4,10 +4,10 @@
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
- 'use strict';var n=require("@lexical/react/withSubscriptions"),r=require("lexical"),v=require("react");
8
- function w(b,d,k,a,h){if(null===b||0===k.size&&0===a.size)return 0;var g=d._selection,c=b._selection;if(h)return 1;if(null===g||null===c||!c.isCollapsed()||!g.isCollapsed())return 0;var e=Array.from(k);a=Array.from(a);k=d._nodeMap;h=[];for(var f=0;f<e.length;f++){const l=k.get(e[f]);void 0!==l&&h.push(l)}for(e=0;e<a.length;e++)a[e][1]&&(f=k.get(a[e][0]),void 0===f||r.$isRootNode(f)||h.push(f));if(0===h.length)return 0;if(1<h.length)return a=d._nodeMap,d=a.get(g.anchor.key),c=a.get(c.anchor.key),d&&
9
- c&&!b._nodeMap.has(d.__key)&&r.$isTextNode(d)&&1===d.__text.length&&1===g.anchor.offset?2:0;d=h[0];b=b._nodeMap.get(d.__key);if(!r.$isTextNode(b)||!r.$isTextNode(d)||b.__mode!==d.__mode)return 0;b=b.__text;d=d.__text;if(b===d)return 0;g=g.anchor;c=c.anchor;if(g.key!==c.key||"text"!==g.type)return 0;g=g.offset;c=c.offset;b=d.length-b.length;return 1===b&&c===g-1?2:-1===b&&c===g+1?3:-1===b&&c===g?4:0}
10
- function x(b,d){let k=Date.now(),a=0;return(h,g,c,e,f,l)=>{const p=Date.now();if(l.has("historic"))return a=0,k=p,2;const m=w(h,g,e,f,b.isComposing()),u=(()=>{if(l.has("without-history"))return 0;if(null===h)return 1;var q=g._selection;const t=h._selection;if(!(0<e.size||0<f.size))return null===t&&null!==q?0:2;q=null===c||c.editor===b;return 0!==m&&m===a&&p<k+d&&q?0:1})();k=p;a=m;return u}}
11
- function y(b,d,k=1E3){const a=v.useMemo(()=>d||z(),[d]),h=v.useCallback(()=>{a.undoStack=[];a.redoStack=[];a.current=null},[a]);v.useEffect(()=>{const g=x(b,k);return n(b.addListener("command",c=>{switch(c){case "undo":c=a.redoStack;var e=a.undoStack;if(0!==e.length){var f=a.current;const l=e.pop();null!==f&&(c.push(f),b.execCommand("canRedo",!0));0===e.length&&b.execCommand("canUndo",!1);a.current=l;l.editor.setEditorState(l.editorState.clone(l.undoSelection),{tag:"historic"})}return!0;case "redo":return c=
12
- a.redoStack,e=a.undoStack,0!==c.length&&(f=a.current,null!==f&&(e.push(f),b.execCommand("canUndo",!0)),e=c.pop(),0===c.length&&b.execCommand("canRedo",!1),a.current=e,e.editor.setEditorState(e.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),b.addListener("update",({editorState:c,prevEditorState:e,dirtyLeaves:f,dirtyElements:l,tags:p})=>{const m=a.current,u=a.redoStack,q=a.undoStack,t=null===m?null:m.editorState;if(null===m||
13
- c!==t){f=g(e,c,m,f,l,p);if(1===f)0!==u.length&&(a.redoStack=[]),null!==m&&(q.push({...m,undoSelection:e.read(r.$getSelection)}),b.execCommand("canUndo",!0));else if(2===f)return;a.current={editor:b,editorState:c}}}))},[h,k,b,a])}function z(){return{current:null,redoStack:[],undoStack:[]}}exports.createEmptyHistoryState=z;exports.useLexicalHistory=function(b,d,k=1E3){return y(b,d,k)};
7
+ var n=require("@lexical/react/withSubscriptions"),t=require("lexical"),v=require("react");
8
+ function w(b,d,k,a,h){if(null===b||0===k.size&&0===a.size)return 0;var g=d._selection,c=b._selection;if(h)return 1;if(null===g||null===c||!c.isCollapsed()||!g.isCollapsed())return 0;var e=Array.from(k);a=Array.from(a);k=d._nodeMap;h=[];for(var f=0;f<e.length;f++){const l=k.get(e[f]);void 0!==l&&h.push(l)}for(e=0;e<a.length;e++)a[e][1]&&(f=k.get(a[e][0]),void 0===f||t.$isRootNode(f)||h.push(f));if(0===h.length)return 0;if(1<h.length)return a=d._nodeMap,d=a.get(g.anchor.key),c=a.get(c.anchor.key),d&&
9
+ c&&!b._nodeMap.has(d.__key)&&t.$isTextNode(d)&&1===d.__text.length&&1===g.anchor.offset?2:0;d=h[0];b=b._nodeMap.get(d.__key);if(!t.$isTextNode(b)||!t.$isTextNode(d)||b.__mode!==d.__mode)return 0;b=b.__text;d=d.__text;if(b===d)return 0;g=g.anchor;c=c.anchor;if(g.key!==c.key||"text"!==g.type)return 0;g=g.offset;c=c.offset;b=d.length-b.length;return 1===b&&c===g-1?2:-1===b&&c===g+1?3:-1===b&&c===g?4:0}
10
+ function x(b,d){let k=Date.now(),a=0;return(h,g,c,e,f,l)=>{const p=Date.now();if(l.has("historic"))return a=0,k=p,2;const m=w(h,g,e,f,b.isComposing()),u=(()=>{const r=l.has("history-push");if(!r&&l.has("history-merge"))return 0;if(null===h)return 1;var q=g._selection;const z=h._selection;if(!(0<e.size||0<f.size))return null===z&&null!==q?0:2;q=null===c||c.editor===b;return!1===r&&0!==m&&m===a&&p<k+d&&q?0:1})();k=p;a=m;return u}}
11
+ function y(b,d,k=1E3){const a=v.useMemo(()=>d||A(),[d]),h=v.useCallback(()=>{a.undoStack=[];a.redoStack=[];a.current=null},[a]);v.useEffect(()=>{const g=x(b,k);return n(b.addListener("command",c=>{switch(c){case "undo":c=a.redoStack;var e=a.undoStack;if(0!==e.length){var f=a.current;const l=e.pop();null!==f&&(c.push(f),b.execCommand("canRedo",!0));0===e.length&&b.execCommand("canUndo",!1);a.current=l;l.editor.setEditorState(l.editorState.clone(l.undoSelection),{tag:"historic"})}return!0;case "redo":return c=
12
+ a.redoStack,e=a.undoStack,0!==c.length&&(f=a.current,null!==f&&(e.push(f),b.execCommand("canUndo",!0)),e=c.pop(),0===c.length&&b.execCommand("canRedo",!1),a.current=e,e.editor.setEditorState(e.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),b.addListener("update",({editorState:c,prevEditorState:e,dirtyLeaves:f,dirtyElements:l,tags:p})=>{const m=a.current,u=a.redoStack,r=a.undoStack,q=null===m?null:m.editorState;if(null===m||
13
+ c!==q){f=g(e,c,m,f,l,p);if(1===f)0!==u.length&&(a.redoStack=[]),null!==m&&(r.push({...m,undoSelection:e.read(t.$getSelection)}),b.execCommand("canUndo",!0));else if(2===f)return;a.current={editor:b,editorState:c}}}))},[h,k,b,a])}function A(){return{current:null,redoStack:[],undoStack:[]}}exports.createEmptyHistoryState=A;exports.useLexicalHistory=function(b,d,k=1E3){return y(b,d,k)};
@@ -4,4 +4,4 @@
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
- 'use strict';var b=require("@lexical/list"),d=require("react");function e(a){d.useEffect(()=>a.addListener("command",c=>{if("indentContent"===c){if(b.indentList())return!0}else if("outdentContent"===c){if(b.outdentList())return!0}else{if("insertOrderedList"===c)return b.insertList(a,"ol"),!0;if("insertUnorderedList"===c)return b.insertList(a,"ul"),!0;if("removeList"===c)return b.removeList(a),!0}return!1},1),[a])}module.exports=function(a){e(a)};
7
+ var b=require("@lexical/list"),d=require("react");function e(a){d.useEffect(()=>a.addListener("command",c=>{if("indentContent"===c){if(b.indentList())return!0}else if("outdentContent"===c){if(b.outdentList())return!0}else{if("insertOrderedList"===c)return b.insertList(a,"ol"),!0;if("insertUnorderedList"===c)return b.insertList(a,"ul"),!0;if("removeList"===c)return b.removeList(a),!0}return!1},1),[a])}module.exports=function(a){e(a)};
@@ -18,9 +18,9 @@ var react = require('react');
18
18
  *
19
19
  *
20
20
  */
21
- const MERGE = 0;
22
- const NO_MERGE = 1;
23
- const DISCARD = 2;
21
+ const HISTORY_MERGE = 0;
22
+ const HISTORY_PUSH = 1;
23
+ const DISCARD_HISTORY_CANDIDATE = 2;
24
24
  const OTHER = 0;
25
25
  const COMPOSING_CHARACTER = 1;
26
26
  const INSERT_CHARACTER_AFTER_SELECTION = 2;
@@ -148,18 +148,21 @@ function createMergeActionGetter(editor, delay) {
148
148
  if (tags.has('historic')) {
149
149
  prevChangeType = OTHER;
150
150
  prevChangeTime = changeTime;
151
- return DISCARD;
151
+ return DISCARD_HISTORY_CANDIDATE;
152
152
  }
153
153
 
154
154
  const changeType = getChangeType(prevEditorState, nextEditorState, dirtyLeaves, dirtyElements, editor.isComposing());
155
155
 
156
156
  const mergeAction = (() => {
157
- if (tags.has('without-history')) {
158
- return MERGE;
157
+ const shouldPushHistory = tags.has('history-push');
158
+ const shouldMergeHistory = !shouldPushHistory && tags.has('history-merge');
159
+
160
+ if (shouldMergeHistory) {
161
+ return HISTORY_MERGE;
159
162
  }
160
163
 
161
164
  if (prevEditorState === null) {
162
- return NO_MERGE;
165
+ return HISTORY_PUSH;
163
166
  }
164
167
 
165
168
  const selection = nextEditorState._selection;
@@ -168,19 +171,19 @@ function createMergeActionGetter(editor, delay) {
168
171
 
169
172
  if (!hasDirtyNodes) {
170
173
  if (prevSelection === null && selection !== null) {
171
- return MERGE;
174
+ return HISTORY_MERGE;
172
175
  }
173
176
 
174
- return DISCARD;
177
+ return DISCARD_HISTORY_CANDIDATE;
175
178
  }
176
179
 
177
180
  const isSameEditor = currentHistoryEntry === null || currentHistoryEntry.editor === editor;
178
181
 
179
- if (changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
180
- return MERGE;
182
+ if (shouldPushHistory === false && changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
183
+ return HISTORY_MERGE;
181
184
  }
182
185
 
183
- return NO_MERGE;
186
+ return HISTORY_PUSH;
184
187
  })();
185
188
 
186
189
  prevChangeTime = changeTime;
@@ -217,7 +220,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
217
220
 
218
221
  const mergeAction = getMergeAction(prevEditorState, editorState, current, dirtyLeaves, dirtyElements, tags);
219
222
 
220
- if (mergeAction === NO_MERGE) {
223
+ if (mergeAction === HISTORY_PUSH) {
221
224
  if (redoStack.length !== 0) {
222
225
  historyState.redoStack = [];
223
226
  }
@@ -228,7 +231,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
228
231
  });
229
232
  editor.execCommand('canUndo', true);
230
233
  }
231
- } else if (mergeAction === DISCARD) {
234
+ } else if (mergeAction === DISCARD_HISTORY_CANDIDATE) {
232
235
  return;
233
236
  } // Else we merge
234
237
 
@@ -349,7 +352,7 @@ function $moveCaretSelection(selection, isHoldingShift, isBackward, granularity)
349
352
  }
350
353
  function $isParentElementRTL(selection) {
351
354
  const anchorNode = selection.anchor.getNode();
352
- const parent = anchorNode.getParentOrThrow();
355
+ const parent = lexical.$isRootNode(anchorNode) ? anchorNode : anchorNode.getParentOrThrow();
353
356
  return parent.getDirection() === 'rtl';
354
357
  }
355
358
  function $moveCharacter(selection, isHoldingShift, isBackward) {
@@ -365,17 +368,41 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
365
368
  *
366
369
  *
367
370
  */
371
+ function resolveElement(element, isBackward, focusOffset) {
372
+ const parent = element.getParent();
373
+ let offset = focusOffset;
374
+ let block = element;
375
+
376
+ if (parent !== null) {
377
+ if (isBackward && focusOffset === 0) {
378
+ offset = block.getIndexWithinParent();
379
+ block = parent;
380
+ } else if (!isBackward && focusOffset === block.getChildrenSize()) {
381
+ offset = block.getIndexWithinParent() + 1;
382
+ block = parent;
383
+ }
384
+ }
385
+
386
+ return block.getChildAtIndex(isBackward ? offset - 1 : offset);
387
+ }
388
+
368
389
  function getPossibleDecoratorNode(focus, isBackward) {
369
390
  const focusOffset = focus.offset;
370
391
 
371
392
  if (focus.type === 'element') {
372
393
  const block = focus.getNode();
373
- return block.getChildAtIndex(isBackward ? focusOffset - 1 : focusOffset);
394
+ return resolveElement(block, isBackward, focusOffset);
374
395
  } else {
375
396
  const focusNode = focus.getNode();
376
397
 
377
398
  if (isBackward && focusOffset === 0 || !isBackward && focusOffset === focusNode.getTextContentSize()) {
378
- return isBackward ? focusNode.getPreviousSibling() : focusNode.getNextSibling();
399
+ const possibleNode = isBackward ? focusNode.getPreviousSibling() : focusNode.getNextSibling();
400
+
401
+ if (possibleNode === null) {
402
+ return resolveElement(focusNode.getParentOrThrow(), isBackward, focusNode.getIndexWithinParent() + (isBackward ? 0 : 1));
403
+ }
404
+
405
+ return possibleNode;
379
406
  }
380
407
  }
381
408
 
@@ -398,13 +425,12 @@ function $insertDataTransferForPlainText(dataTransfer, selection) {
398
425
  }
399
426
  }
400
427
  function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
401
- const possibleDecoratorNode = getPossibleDecoratorNode(selection.focus, isBackward);
402
- return lexical.$isDecoratorNode(possibleDecoratorNode);
428
+ const possibleNode = getPossibleDecoratorNode(selection.focus, isBackward);
429
+ return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
403
430
  }
404
431
  function onPasteForPlainText(event, editor) {
405
432
  event.preventDefault();
406
433
  editor.update(() => {
407
- lexical.$log('onPasteForPlainText');
408
434
  const selection = lexical.$getSelection();
409
435
  const clipboardData = event.clipboardData;
410
436
 
@@ -416,7 +442,6 @@ function onPasteForPlainText(event, editor) {
416
442
  function onCutForPlainText(event, editor) {
417
443
  onCopyForPlainText(event, editor);
418
444
  editor.update(() => {
419
- lexical.$log('onCutForPlainText');
420
445
  const selection = lexical.$getSelection();
421
446
 
422
447
  if (selection !== null) {
@@ -427,7 +452,6 @@ function onCutForPlainText(event, editor) {
427
452
  function onCopyForPlainText(event, editor) {
428
453
  event.preventDefault();
429
454
  editor.update(() => {
430
- lexical.$log('onCopyForPlainText');
431
455
  const clipboardData = event.clipboardData;
432
456
  const selection = lexical.$getSelection();
433
457
 
@@ -512,7 +536,6 @@ function useLexicalDragonSupport(editor) {
512
536
  if (args) {
513
537
  const [elementStart, elementLength, text, selStart, selLength, formatCommand] = args; // TODO: we should probably handle formatCommand somehow?
514
538
  editor.update(() => {
515
- lexical.$log('useLexicalDragonSupport');
516
539
  const selection = lexical.$getSelection();
517
540
 
518
541
  if (selection !== null) {
@@ -4,19 +4,19 @@
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
- 'use strict';var m=require("@lexical/react/withSubscriptions"),u=require("lexical"),v=require("react");
8
- function w(a,e,c,b,d){if(null===a||0===c.size&&0===b.size)return 0;var g=e._selection,f=a._selection;if(d)return 1;if(null===g||null===f||!f.isCollapsed()||!g.isCollapsed())return 0;var h=Array.from(c);b=Array.from(b);c=e._nodeMap;d=[];for(var k=0;k<h.length;k++){const n=c.get(h[k]);void 0!==n&&d.push(n)}for(h=0;h<b.length;h++)b[h][1]&&(k=c.get(b[h][0]),void 0===k||u.$isRootNode(k)||d.push(k));if(0===d.length)return 0;if(1<d.length)return b=e._nodeMap,e=b.get(g.anchor.key),f=b.get(f.anchor.key),e&&
9
- f&&!a._nodeMap.has(e.__key)&&u.$isTextNode(e)&&1===e.__text.length&&1===g.anchor.offset?2:0;e=d[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;g=g.anchor;f=f.anchor;if(g.key!==f.key||"text"!==g.type)return 0;g=g.offset;f=f.offset;a=e.length-a.length;return 1===a&&f===g-1?2:-1===a&&f===g+1?3:-1===a&&f===g?4:0}
10
- function x(a,e){let c=Date.now(),b=0;return(d,g,f,h,k,n)=>{const t=Date.now();if(n.has("historic"))return b=0,c=t,2;const l=w(d,g,h,k,a.isComposing()),r=(()=>{if(n.has("without-history"))return 0;if(null===d)return 1;var p=g._selection;const q=d._selection;if(!(0<h.size||0<k.size))return null===q&&null!==p?0:2;p=null===f||f.editor===a;return 0!==l&&l===b&&t<c+e&&p?0:1})();c=t;b=l;return r}}
11
- function y(a,e,c=1E3){const b=v.useMemo(()=>e||{current:null,redoStack:[],undoStack:[]},[e]),d=v.useCallback(()=>{b.undoStack=[];b.redoStack=[];b.current=null},[b]);v.useEffect(()=>{const g=x(a,c);return m(a.addListener("command",f=>{switch(f){case "undo":f=b.redoStack;var h=b.undoStack;if(0!==h.length){var k=b.current;const n=h.pop();null!==k&&(f.push(k),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 f=b.redoStack,h=b.undoStack,0!==f.length&&(k=b.current,null!==k&&(h.push(k),a.execCommand("canUndo",!0)),h=f.pop(),0===f.length&&a.execCommand("canRedo",!1),b.current=h,h.editor.setEditorState(h.editorState,{tag:"historic"})),!0;case "clearEditor":return d(),!1;case "clearHistory":return d(),!0;default:return!1}},0),a.addListener("update",({editorState:f,prevEditorState:h,dirtyLeaves:k,dirtyElements:n,tags:t})=>{const l=b.current,r=b.redoStack,p=b.undoStack,
13
- q=null===l?null:l.editorState;if(null===l||f!==q){k=g(h,f,l,k,n,t);if(1===k)0!==r.length&&(b.redoStack=[]),null!==l&&(p.push({...l,undoSelection:h.read(u.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;b.current={editor:a,editorState:f}}}))},[d,c,a,b])}function z(a,e,c=1E3){return y(a,e,c)}function A(a,e){a=a.getData("text/plain");null!=a&&e.insertRawText(a)}
14
- function B(a,e){var c=a.focus;a=c.offset;"element"===c.type?e=c.getNode().getChildAtIndex(e?a-1:a):(c=c.getNode(),e=e&&0===a||!e&&a===c.getTextContentSize()?e?c.getPreviousSibling():c.getNextSibling():null);return u.$isDecoratorNode(e)}function C(a,e){a.preventDefault();e.update(()=>{u.$log("onPasteForPlainText");const c=u.$getSelection(),b=a.clipboardData;null!=b&&null!==c&&A(b,c)})}
15
- function D(a,e){E(a,e);e.update(()=>{u.$log("onCutForPlainText");const c=u.$getSelection();null!==c&&c.removeText()})}function E(a,e){a.preventDefault();e.update(()=>{u.$log("onCopyForPlainText");const c=a.clipboardData,b=u.$getSelection();if(null!==b&&null!=c){var d=window.getSelection();if(!d.isCollapsed){var g=d.getRangeAt(0);g&&(d=document.createElement("div"),g=g.cloneContents(),d.appendChild(g),c.setData("text/html",d.innerHTML));c.setData("text/plain",b.getTextContent())}}})}
16
- var F="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?v.useLayoutEffect:v.useEffect;
17
- function G(a){v.useEffect(()=>{const e=c=>{var b=a.getRootElement();if(document.activeElement===b&&(b=c.data,"string"===typeof b)){try{var d=JSON.parse(b)}catch(g){return}if(d&&"nuanria_messaging"===d.protocol&&"request"===d.type&&(d=d.payload)&&"makeChanges"===d.functionId&&(d=d.args)){const [g,f,h,k,n]=d;a.update(()=>{u.$log("useLexicalDragonSupport");const t=u.$getSelection();if(null!==t){var l=t.anchor;let r=l.getNode(),p=0,q=0;u.$isTextNode(r)&&0<=g&&0<=f&&(p=g,q=g+f,t.setTextNodeRange(r,p,r,
18
- q));if(p!==q||""!==h)t.insertRawText(h),r=l.getNode();u.$isTextNode(r)&&(p=k,q=k+n,l=r.getTextContentSize(),p=p>l?l:p,q=q>l?l:q,t.setTextNodeRange(r,p,r,q));c.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
19
- function H(a){F(()=>{const e=a.addListener("command",(c,b)=>{const d=u.$getSelection();if(null===d)return!1;switch(c){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):(c=b.dataTransfer,null!=c?A(c,d):(b=b.data)&&d.insertText(b)),!0;case "removeText":return d.removeText(),!0;case "insertLineBreak":return d.insertLineBreak(b),!0;case "insertParagraph":return d.insertLineBreak(),
20
- !0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c=b.shiftKey;if(B(d,!0))return b.preventDefault(),b=c,c="rtl"===d.anchor.getNode().getParentOrThrow().getDirection(),d.modify(b?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=b.shiftKey;if(B(d,!1))return b.preventDefault(),b=c,c="rtl"===d.anchor.getNode().getParentOrThrow().getDirection(),d.modify(b?"extend":
21
- "move",c,"character"),!0;break;case "keyBackspace":return b.preventDefault(),a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),a.execCommand("insertLineBreak");case "copy":return E(b,a),!0;case "cut":return D(b,a),!0;case "paste":return C(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0);a.execCommand("bootstrapEditor");return e},[a]);G(a)}
22
- module.exports=function(a,e){H(a);z(a,e)};
7
+ var n=require("@lexical/react/withSubscriptions"),u=require("lexical"),v=require("react");
8
+ function w(a,d,c,b,e){if(null===a||0===c.size&&0===b.size)return 0;var g=d._selection,f=a._selection;if(e)return 1;if(null===g||null===f||!f.isCollapsed()||!g.isCollapsed())return 0;var h=Array.from(c);b=Array.from(b);c=d._nodeMap;e=[];for(var k=0;k<h.length;k++){const m=c.get(h[k]);void 0!==m&&e.push(m)}for(h=0;h<b.length;h++)b[h][1]&&(k=c.get(b[h][0]),void 0===k||u.$isRootNode(k)||e.push(k));if(0===e.length)return 0;if(1<e.length)return b=d._nodeMap,d=b.get(g.anchor.key),f=b.get(f.anchor.key),d&&
9
+ f&&!a._nodeMap.has(d.__key)&&u.$isTextNode(d)&&1===d.__text.length&&1===g.anchor.offset?2:0;d=e[0];a=a._nodeMap.get(d.__key);if(!u.$isTextNode(a)||!u.$isTextNode(d)||a.__mode!==d.__mode)return 0;a=a.__text;d=d.__text;if(a===d)return 0;g=g.anchor;f=f.anchor;if(g.key!==f.key||"text"!==g.type)return 0;g=g.offset;f=f.offset;a=d.length-a.length;return 1===a&&f===g-1?2:-1===a&&f===g+1?3:-1===a&&f===g?4:0}
10
+ function x(a,d){let c=Date.now(),b=0;return(e,g,f,h,k,m)=>{const t=Date.now();if(m.has("historic"))return b=0,c=t,2;const l=w(e,g,h,k,a.isComposing()),r=(()=>{const q=m.has("history-push");if(!q&&m.has("history-merge"))return 0;if(null===e)return 1;var p=g._selection;const D=e._selection;if(!(0<h.size||0<k.size))return null===D&&null!==p?0:2;p=null===f||f.editor===a;return!1===q&&0!==l&&l===b&&t<c+d&&p?0:1})();c=t;b=l;return r}}
11
+ function y(a,d,c=1E3){const b=v.useMemo(()=>d||{current:null,redoStack:[],undoStack:[]},[d]),e=v.useCallback(()=>{b.undoStack=[];b.redoStack=[];b.current=null},[b]);v.useEffect(()=>{const g=x(a,c);return n(a.addListener("command",f=>{switch(f){case "undo":f=b.redoStack;var h=b.undoStack;if(0!==h.length){var k=b.current;const m=h.pop();null!==k&&(f.push(k),a.execCommand("canRedo",!0));0===h.length&&a.execCommand("canUndo",!1);b.current=m;m.editor.setEditorState(m.editorState.clone(m.undoSelection),
12
+ {tag:"historic"})}return!0;case "redo":return f=b.redoStack,h=b.undoStack,0!==f.length&&(k=b.current,null!==k&&(h.push(k),a.execCommand("canUndo",!0)),h=f.pop(),0===f.length&&a.execCommand("canRedo",!1),b.current=h,h.editor.setEditorState(h.editorState,{tag:"historic"})),!0;case "clearEditor":return e(),!1;case "clearHistory":return e(),!0;default:return!1}},0),a.addListener("update",({editorState:f,prevEditorState:h,dirtyLeaves:k,dirtyElements:m,tags:t})=>{const l=b.current,r=b.redoStack,q=b.undoStack,
13
+ p=null===l?null:l.editorState;if(null===l||f!==p){k=g(h,f,l,k,m,t);if(1===k)0!==r.length&&(b.redoStack=[]),null!==l&&(q.push({...l,undoSelection:h.read(u.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;b.current={editor:a,editorState:f}}}))},[e,c,a,b])}function z(a,d,c=1E3){return y(a,d,c)}function A(a){a=a.anchor.getNode();return"rtl"===(u.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}
14
+ function B(a,d,c){const b=a.getParent();let e=c;null!==b&&(d&&0===c?(e=a.getIndexWithinParent(),a=b):d||c!==a.getChildrenSize()||(e=a.getIndexWithinParent()+1,a=b));return a.getChildAtIndex(d?e-1:e)}function C(a,d){a=a.getData("text/plain");null!=a&&d.insertRawText(a)}
15
+ function E(a,d){var c=a.focus;a=c.offset;"element"===c.type?(c=c.getNode(),d=B(c,d,a)):(c=c.getNode(),d&&0===a||!d&&a===c.getTextContentSize()?(a=d?c.getPreviousSibling():c.getNextSibling(),d=null===a?B(c.getParentOrThrow(),d,c.getIndexWithinParent()+(d?0:1)):a):d=null);return u.$isDecoratorNode(d)&&!d.isIsolated()}function F(a,d){a.preventDefault();d.update(()=>{const c=u.$getSelection(),b=a.clipboardData;null!=b&&null!==c&&C(b,c)})}
16
+ function G(a,d){H(a,d);d.update(()=>{const c=u.$getSelection();null!==c&&c.removeText()})}function H(a,d){a.preventDefault();d.update(()=>{const c=a.clipboardData,b=u.$getSelection();if(null!==b&&null!=c){var e=window.getSelection();if(!e.isCollapsed){var g=e.getRangeAt(0);g&&(e=document.createElement("div"),g=g.cloneContents(),e.appendChild(g),c.setData("text/html",e.innerHTML));c.setData("text/plain",b.getTextContent())}}})}
17
+ var I="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?v.useLayoutEffect:v.useEffect;
18
+ function J(a){v.useEffect(()=>{const d=c=>{var b=a.getRootElement();if(document.activeElement===b&&(b=c.data,"string"===typeof b)){try{var e=JSON.parse(b)}catch(g){return}if(e&&"nuanria_messaging"===e.protocol&&"request"===e.type&&(e=e.payload)&&"makeChanges"===e.functionId&&(e=e.args)){const [g,f,h,k,m]=e;a.update(()=>{const t=u.$getSelection();if(null!==t){var l=t.anchor;let r=l.getNode(),q=0,p=0;u.$isTextNode(r)&&0<=g&&0<=f&&(q=g,p=g+f,t.setTextNodeRange(r,q,r,p));if(q!==p||""!==h)t.insertRawText(h),
19
+ r=l.getNode();u.$isTextNode(r)&&(q=k,p=k+m,l=r.getTextContentSize(),q=q>l?l:q,p=p>l?l:p,t.setTextNodeRange(r,q,r,p));c.stopImmediatePropagation()}})}}};window.addEventListener("message",d,!0);return()=>{window.removeEventListener("message",d,!0)}},[a])}
20
+ function K(a){I(()=>{const d=a.addListener("command",(c,b)=>{const e=u.$getSelection();if(null===e)return!1;switch(c){case "deleteCharacter":return e.deleteCharacter(b),!0;case "deleteWord":return e.deleteWord(b),!0;case "deleteLine":return e.deleteLine(b),!0;case "insertText":return"string"===typeof b?e.insertText(b):(c=b.dataTransfer,null!=c?C(c,e):(b=b.data)&&e.insertText(b)),!0;case "removeText":return e.removeText(),!0;case "insertLineBreak":return e.insertLineBreak(b),!0;case "insertParagraph":return e.insertLineBreak(),
21
+ !0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c=b.shiftKey;if(E(e,!0))return b.preventDefault(),b=c,c=A(e),e.modify(b?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=b.shiftKey;if(E(e,!1))return b.preventDefault(),b=c,c=A(e),e.modify(b?"extend":"move",c,"character"),!0;break;case "keyBackspace":return b.preventDefault(),a.execCommand("deleteCharacter",
22
+ !0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),a.execCommand("insertLineBreak");case "copy":return H(b,a),!0;case "cut":return G(b,a),!0;case "paste":return F(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0);a.execCommand("bootstrapEditor");return d},[a]);J(a)}module.exports=function(a,d){K(a);z(a,d)};
@@ -22,9 +22,9 @@ var LinkNode = require('lexical/LinkNode');
22
22
  *
23
23
  *
24
24
  */
25
- const MERGE = 0;
26
- const NO_MERGE = 1;
27
- const DISCARD = 2;
25
+ const HISTORY_MERGE = 0;
26
+ const HISTORY_PUSH = 1;
27
+ const DISCARD_HISTORY_CANDIDATE = 2;
28
28
  const OTHER = 0;
29
29
  const COMPOSING_CHARACTER = 1;
30
30
  const INSERT_CHARACTER_AFTER_SELECTION = 2;
@@ -152,18 +152,21 @@ function createMergeActionGetter(editor, delay) {
152
152
  if (tags.has('historic')) {
153
153
  prevChangeType = OTHER;
154
154
  prevChangeTime = changeTime;
155
- return DISCARD;
155
+ return DISCARD_HISTORY_CANDIDATE;
156
156
  }
157
157
 
158
158
  const changeType = getChangeType(prevEditorState, nextEditorState, dirtyLeaves, dirtyElements, editor.isComposing());
159
159
 
160
160
  const mergeAction = (() => {
161
- if (tags.has('without-history')) {
162
- return MERGE;
161
+ const shouldPushHistory = tags.has('history-push');
162
+ const shouldMergeHistory = !shouldPushHistory && tags.has('history-merge');
163
+
164
+ if (shouldMergeHistory) {
165
+ return HISTORY_MERGE;
163
166
  }
164
167
 
165
168
  if (prevEditorState === null) {
166
- return NO_MERGE;
169
+ return HISTORY_PUSH;
167
170
  }
168
171
 
169
172
  const selection = nextEditorState._selection;
@@ -172,19 +175,19 @@ function createMergeActionGetter(editor, delay) {
172
175
 
173
176
  if (!hasDirtyNodes) {
174
177
  if (prevSelection === null && selection !== null) {
175
- return MERGE;
178
+ return HISTORY_MERGE;
176
179
  }
177
180
 
178
- return DISCARD;
181
+ return DISCARD_HISTORY_CANDIDATE;
179
182
  }
180
183
 
181
184
  const isSameEditor = currentHistoryEntry === null || currentHistoryEntry.editor === editor;
182
185
 
183
- if (changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
184
- return MERGE;
186
+ if (shouldPushHistory === false && changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
187
+ return HISTORY_MERGE;
185
188
  }
186
189
 
187
- return NO_MERGE;
190
+ return HISTORY_PUSH;
188
191
  })();
189
192
 
190
193
  prevChangeTime = changeTime;
@@ -221,7 +224,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
221
224
 
222
225
  const mergeAction = getMergeAction(prevEditorState, editorState, current, dirtyLeaves, dirtyElements, tags);
223
226
 
224
- if (mergeAction === NO_MERGE) {
227
+ if (mergeAction === HISTORY_PUSH) {
225
228
  if (redoStack.length !== 0) {
226
229
  historyState.redoStack = [];
227
230
  }
@@ -232,7 +235,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
232
235
  });
233
236
  editor.execCommand('canUndo', true);
234
237
  }
235
- } else if (mergeAction === DISCARD) {
238
+ } else if (mergeAction === DISCARD_HISTORY_CANDIDATE) {
236
239
  return;
237
240
  } // Else we merge
238
241
 
@@ -473,7 +476,7 @@ function $cloneContents(selection) {
473
476
  const firstNode = nodes[0];
474
477
  const firstNodeParent = firstNode.getParent();
475
478
 
476
- if (firstNodeParent !== null && !firstNodeParent.canBeEmpty()) {
479
+ if (firstNodeParent !== null && (!firstNodeParent.canBeEmpty() || lexical.$isRootNode(firstNodeParent))) {
477
480
  const parentChildren = firstNodeParent.__children;
478
481
  const parentChildrenLength = parentChildren.length;
479
482
 
@@ -529,7 +532,7 @@ function $moveCaretSelection(selection, isHoldingShift, isBackward, granularity)
529
532
  }
530
533
  function $isParentElementRTL(selection) {
531
534
  const anchorNode = selection.anchor.getNode();
532
- const parent = anchorNode.getParentOrThrow();
535
+ const parent = lexical.$isRootNode(anchorNode) ? anchorNode : anchorNode.getParentOrThrow();
533
536
  return parent.getDirection() === 'rtl';
534
537
  }
535
538
  function $moveCharacter(selection, isHoldingShift, isBackward) {
@@ -545,17 +548,41 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
545
548
  *
546
549
  *
547
550
  */
551
+ function resolveElement(element, isBackward, focusOffset) {
552
+ const parent = element.getParent();
553
+ let offset = focusOffset;
554
+ let block = element;
555
+
556
+ if (parent !== null) {
557
+ if (isBackward && focusOffset === 0) {
558
+ offset = block.getIndexWithinParent();
559
+ block = parent;
560
+ } else if (!isBackward && focusOffset === block.getChildrenSize()) {
561
+ offset = block.getIndexWithinParent() + 1;
562
+ block = parent;
563
+ }
564
+ }
565
+
566
+ return block.getChildAtIndex(isBackward ? offset - 1 : offset);
567
+ }
568
+
548
569
  function getPossibleDecoratorNode(focus, isBackward) {
549
570
  const focusOffset = focus.offset;
550
571
 
551
572
  if (focus.type === 'element') {
552
573
  const block = focus.getNode();
553
- return block.getChildAtIndex(isBackward ? focusOffset - 1 : focusOffset);
574
+ return resolveElement(block, isBackward, focusOffset);
554
575
  } else {
555
576
  const focusNode = focus.getNode();
556
577
 
557
578
  if (isBackward && focusOffset === 0 || !isBackward && focusOffset === focusNode.getTextContentSize()) {
558
- return isBackward ? focusNode.getPreviousSibling() : focusNode.getNextSibling();
579
+ const possibleNode = isBackward ? focusNode.getPreviousSibling() : focusNode.getNextSibling();
580
+
581
+ if (possibleNode === null) {
582
+ return resolveElement(focusNode.getParentOrThrow(), isBackward, focusNode.getIndexWithinParent() + (isBackward ? 0 : 1));
583
+ }
584
+
585
+ return possibleNode;
559
586
  }
560
587
  }
561
588
 
@@ -889,13 +916,12 @@ function $insertDataTransferForPlainText(dataTransfer, selection) {
889
916
  }
890
917
  }
891
918
  function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
892
- const possibleDecoratorNode = getPossibleDecoratorNode(selection.focus, isBackward);
893
- return lexical.$isDecoratorNode(possibleDecoratorNode);
919
+ const possibleNode = getPossibleDecoratorNode(selection.focus, isBackward);
920
+ return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
894
921
  }
895
922
  function onPasteForRichText(event, editor) {
896
923
  event.preventDefault();
897
924
  editor.update(() => {
898
- lexical.$log('onPasteForRichText');
899
925
  const selection = lexical.$getSelection();
900
926
  const clipboardData = event.clipboardData;
901
927
 
@@ -907,7 +933,6 @@ function onPasteForRichText(event, editor) {
907
933
  function onCutForRichText(event, editor) {
908
934
  onCopyForRichText(event, editor);
909
935
  editor.update(() => {
910
- lexical.$log('onCutForRichText');
911
936
  const selection = lexical.$getSelection();
912
937
 
913
938
  if (selection !== null) {
@@ -918,7 +943,6 @@ function onCutForRichText(event, editor) {
918
943
  function onCopyForRichText(event, editor) {
919
944
  event.preventDefault();
920
945
  editor.update(() => {
921
- lexical.$log('onCopyForRichText');
922
946
  const clipboardData = event.clipboardData;
923
947
  const selection = lexical.$getSelection();
924
948
 
@@ -1008,7 +1032,6 @@ function useLexicalDragonSupport(editor) {
1008
1032
  if (args) {
1009
1033
  const [elementStart, elementLength, text, selStart, selLength, formatCommand] = args; // TODO: we should probably handle formatCommand somehow?
1010
1034
  editor.update(() => {
1011
- lexical.$log('useLexicalDragonSupport');
1012
1035
  const selection = lexical.$getSelection();
1013
1036
 
1014
1037
  if (selection !== null) {