@lexical/react 0.1.10 → 0.1.13
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.
- package/DEPRECATED_useLexical.dev.js +3 -7
- package/DEPRECATED_useLexical.prod.js +1 -1
- package/DEPRECATED_useLexicalAutoFormatter.dev.js +83 -37
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +20 -19
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +20 -17
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +8 -8
- package/DEPRECATED_useLexicalList.dev.js +6 -0
- package/DEPRECATED_useLexicalList.prod.js +1 -1
- package/DEPRECATED_useLexicalPlainText.dev.js +84 -75
- package/DEPRECATED_useLexicalPlainText.prod.js +15 -15
- package/DEPRECATED_useLexicalRichText.dev.js +96 -438
- package/DEPRECATED_useLexicalRichText.prod.js +17 -26
- package/LexicalAutoFormatterPlugin.d.ts +9 -0
- package/LexicalAutoFormatterPlugin.dev.js +83 -37
- package/LexicalAutoFormatterPlugin.js.flow +10 -0
- package/LexicalAutoFormatterPlugin.prod.js +21 -20
- package/LexicalAutoLinkPlugin.d.ts +20 -0
- package/LexicalAutoLinkPlugin.js.flow +23 -0
- package/LexicalCharacterLimitPlugin.d.ts +11 -0
- package/LexicalCharacterLimitPlugin.dev.js +20 -17
- package/LexicalCharacterLimitPlugin.js.flow +12 -0
- package/LexicalCharacterLimitPlugin.prod.js +9 -8
- package/LexicalClearEditorPlugin.d.ts +14 -0
- package/LexicalClearEditorPlugin.dev.js +73 -0
- package/LexicalClearEditorPlugin.js +9 -0
- package/LexicalClearEditorPlugin.js.flow +14 -0
- package/LexicalClearEditorPlugin.prod.js +8 -0
- package/LexicalCollaborationPlugin.d.ts +49 -0
- package/LexicalCollaborationPlugin.dev.js +21 -13
- package/LexicalCollaborationPlugin.js.flow +55 -0
- package/LexicalCollaborationPlugin.prod.js +7 -7
- package/LexicalComposer.d.ts +22 -0
- package/LexicalComposer.dev.js +32 -3
- package/LexicalComposer.js.flow +24 -0
- package/LexicalComposer.prod.js +3 -2
- package/LexicalComposerContext.d.ts +24 -0
- package/LexicalComposerContext.js.flow +27 -0
- package/LexicalContentEditable.d.ts +32 -0
- package/LexicalContentEditable.dev.js +35 -8
- package/LexicalContentEditable.js.flow +35 -0
- package/LexicalContentEditable.prod.js +3 -3
- package/LexicalHashtagPlugin.d.ts +9 -0
- package/LexicalHashtagPlugin.js.flow +10 -0
- package/LexicalHistoryPlugin.d.ts +29 -0
- package/LexicalHistoryPlugin.js.flow +34 -0
- package/LexicalHorizontalRuleNode.d.ts +23 -0
- package/LexicalHorizontalRuleNode.js.flow +25 -0
- package/LexicalLinkPlugin.d.ts +9 -0
- package/LexicalLinkPlugin.js.flow +10 -0
- package/LexicalListPlugin.d.ts +9 -0
- package/LexicalListPlugin.dev.js +6 -0
- package/LexicalListPlugin.js.flow +10 -0
- package/LexicalListPlugin.prod.js +2 -2
- package/LexicalNestedComposer.d.ts +17 -0
- package/LexicalNestedComposer.dev.js +21 -11
- package/LexicalNestedComposer.js.flow +18 -0
- package/LexicalNestedComposer.prod.js +3 -2
- package/LexicalOnChangePlugin.d.ts +12 -0
- package/LexicalOnChangePlugin.js.flow +14 -0
- package/LexicalPlainTextPlugin.d.ts +15 -0
- package/LexicalPlainTextPlugin.dev.js +73 -84
- package/LexicalPlainTextPlugin.js.flow +18 -0
- package/LexicalPlainTextPlugin.prod.js +12 -12
- package/LexicalRichTextPlugin.d.ts +15 -0
- package/LexicalRichTextPlugin.dev.js +85 -447
- package/LexicalRichTextPlugin.js.flow +18 -0
- package/LexicalRichTextPlugin.prod.js +13 -22
- package/LexicalTablePlugin.d.ts +9 -0
- package/LexicalTablePlugin.dev.js +22 -0
- package/LexicalTablePlugin.js.flow +10 -0
- package/LexicalTablePlugin.prod.js +4 -3
- package/LexicalTreeView.d.ts +17 -0
- package/LexicalTreeView.js.flow +19 -0
- package/README.md +0 -1
- package/package.json +9 -5
- package/useLexicalDecoratorMap.d.ts +14 -0
- package/useLexicalDecoratorMap.js.flow +16 -0
- package/useLexicalIsTextContentEmpty.d.ts +13 -0
- package/useLexicalIsTextContentEmpty.js.flow +15 -0
- package/useLexicalNodeSelection.d.ts +12 -0
- package/useLexicalNodeSelection.js.flow +14 -0
- package/withSubscriptions.d.ts +12 -0
- package/withSubscriptions.js.flow +13 -0
- package/LexicalBootstrapPlugin.dev.js +0 -122
- package/LexicalBootstrapPlugin.js +0 -9
- package/LexicalBootstrapPlugin.prod.js +0 -8
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
var withSubscriptions = require('@lexical/react/withSubscriptions');
|
|
10
10
|
var lexical = require('lexical');
|
|
11
11
|
var react = require('react');
|
|
12
|
+
var clipboard = require('@lexical/clipboard');
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -359,6 +360,10 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
|
|
|
359
360
|
const isRTL = $isParentElementRTL(selection);
|
|
360
361
|
$moveCaretSelection(selection, isHoldingShift, isBackward ? !isRTL : isRTL, 'character');
|
|
361
362
|
}
|
|
363
|
+
function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
|
|
364
|
+
const possibleNode = lexical.$getDecoratorNode(selection.focus, isBackward);
|
|
365
|
+
return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
|
|
366
|
+
}
|
|
362
367
|
|
|
363
368
|
/**
|
|
364
369
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -368,46 +373,7 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
|
|
|
368
373
|
*
|
|
369
374
|
*
|
|
370
375
|
*/
|
|
371
|
-
|
|
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
|
-
|
|
389
|
-
function getPossibleDecoratorNode(focus, isBackward) {
|
|
390
|
-
const focusOffset = focus.offset;
|
|
391
|
-
|
|
392
|
-
if (focus.type === 'element') {
|
|
393
|
-
const block = focus.getNode();
|
|
394
|
-
return resolveElement(block, isBackward, focusOffset);
|
|
395
|
-
} else {
|
|
396
|
-
const focusNode = focus.getNode();
|
|
397
|
-
|
|
398
|
-
if (isBackward && focusOffset === 0 || !isBackward && focusOffset === focusNode.getTextContentSize()) {
|
|
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;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return null;
|
|
410
|
-
}
|
|
376
|
+
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
411
377
|
|
|
412
378
|
/**
|
|
413
379
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -417,17 +383,17 @@ function getPossibleDecoratorNode(focus, isBackward) {
|
|
|
417
383
|
*
|
|
418
384
|
*
|
|
419
385
|
*/
|
|
420
|
-
|
|
421
|
-
|
|
386
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
387
|
+
var useLayoutEffect = useLayoutEffectImpl;
|
|
422
388
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
389
|
+
/**
|
|
390
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
391
|
+
*
|
|
392
|
+
* This source code is licensed under the MIT license found in the
|
|
393
|
+
* LICENSE file in the root directory of this source tree.
|
|
394
|
+
*
|
|
395
|
+
*
|
|
396
|
+
*/
|
|
431
397
|
function onPasteForPlainText(event, editor) {
|
|
432
398
|
event.preventDefault();
|
|
433
399
|
editor.update(() => {
|
|
@@ -435,7 +401,7 @@ function onPasteForPlainText(event, editor) {
|
|
|
435
401
|
const clipboardData = event.clipboardData;
|
|
436
402
|
|
|
437
403
|
if (clipboardData != null && lexical.$isRangeSelection(selection)) {
|
|
438
|
-
|
|
404
|
+
clipboard.$insertDataTransferForPlainText(clipboardData, selection);
|
|
439
405
|
}
|
|
440
406
|
});
|
|
441
407
|
}
|
|
@@ -457,19 +423,10 @@ function onCopyForPlainText(event, editor) {
|
|
|
457
423
|
|
|
458
424
|
if (selection !== null) {
|
|
459
425
|
if (clipboardData != null) {
|
|
460
|
-
const
|
|
426
|
+
const htmlString = clipboard.getHtmlContent(editor);
|
|
461
427
|
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
const range = domSelection.getRangeAt(0);
|
|
467
|
-
|
|
468
|
-
if (range) {
|
|
469
|
-
const container = document.createElement('div');
|
|
470
|
-
const frag = range.cloneContents();
|
|
471
|
-
container.appendChild(frag);
|
|
472
|
-
clipboardData.setData('text/html', container.innerHTML);
|
|
428
|
+
if (htmlString !== null) {
|
|
429
|
+
clipboardData.setData('text/html', htmlString);
|
|
473
430
|
}
|
|
474
431
|
|
|
475
432
|
clipboardData.setData('text/plain', selection.getTextContent());
|
|
@@ -478,6 +435,62 @@ function onCopyForPlainText(event, editor) {
|
|
|
478
435
|
});
|
|
479
436
|
}
|
|
480
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
440
|
+
*
|
|
441
|
+
* This source code is licensed under the MIT license found in the
|
|
442
|
+
* LICENSE file in the root directory of this source tree.
|
|
443
|
+
*
|
|
444
|
+
*
|
|
445
|
+
*/
|
|
446
|
+
// Convoluted logic to make this work with Flow. Order matters.
|
|
447
|
+
const options = {
|
|
448
|
+
tag: 'history-merge'
|
|
449
|
+
};
|
|
450
|
+
const setEditorOptions = options;
|
|
451
|
+
const updateOptions = options;
|
|
452
|
+
function initializeEditor(editor, initialEditorState) {
|
|
453
|
+
if (initialEditorState === null) {
|
|
454
|
+
return;
|
|
455
|
+
} else if (initialEditorState === undefined) {
|
|
456
|
+
editor.update(() => {
|
|
457
|
+
const root = lexical.$getRoot();
|
|
458
|
+
const firstChild = root.getFirstChild();
|
|
459
|
+
|
|
460
|
+
if (firstChild === null) {
|
|
461
|
+
const paragraph = lexical.$createParagraphNode();
|
|
462
|
+
root.append(paragraph);
|
|
463
|
+
const activeElement = document.activeElement;
|
|
464
|
+
|
|
465
|
+
if (lexical.$getSelection() !== null || activeElement !== null && activeElement === editor.getRootElement()) {
|
|
466
|
+
paragraph.select();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}, updateOptions);
|
|
470
|
+
} else if (initialEditorState !== null) {
|
|
471
|
+
switch (typeof initialEditorState) {
|
|
472
|
+
case 'string':
|
|
473
|
+
{
|
|
474
|
+
const parsedEditorState = editor.parseEditorState(initialEditorState);
|
|
475
|
+
editor.setEditorState(parsedEditorState, setEditorOptions);
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
case 'object':
|
|
480
|
+
{
|
|
481
|
+
editor.setEditorState(initialEditorState, setEditorOptions);
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
case 'function':
|
|
486
|
+
{
|
|
487
|
+
editor.update(initialEditorState, updateOptions);
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
481
494
|
/**
|
|
482
495
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
483
496
|
*
|
|
@@ -574,8 +587,8 @@ function useLexicalDragonSupport(editor) {
|
|
|
574
587
|
*
|
|
575
588
|
*
|
|
576
589
|
*/
|
|
577
|
-
function usePlainTextSetup(editor) {
|
|
578
|
-
|
|
590
|
+
function usePlainTextSetup(editor, initialEditorState) {
|
|
591
|
+
useLayoutEffect(() => {
|
|
579
592
|
const removeListener = editor.addListener('command', (type, payload) => {
|
|
580
593
|
const selection = lexical.$getSelection();
|
|
581
594
|
|
|
@@ -615,7 +628,7 @@ function usePlainTextSetup(editor) {
|
|
|
615
628
|
const dataTransfer = eventOrText.dataTransfer;
|
|
616
629
|
|
|
617
630
|
if (dataTransfer != null) {
|
|
618
|
-
|
|
631
|
+
clipboard.$insertDataTransferForPlainText(dataTransfer, selection);
|
|
619
632
|
} else {
|
|
620
633
|
const data = eventOrText.data;
|
|
621
634
|
|
|
@@ -734,13 +747,9 @@ function usePlainTextSetup(editor) {
|
|
|
734
747
|
|
|
735
748
|
return false;
|
|
736
749
|
}, 0);
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
console.warn('bootstrapEditor command was not handled. Did you forget to add <BootstrapPlugin />?');
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
return removeListener;
|
|
750
|
+
initializeEditor(editor, initialEditorState);
|
|
751
|
+
return removeListener; // We only do this for init
|
|
752
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
744
753
|
}, [editor]);
|
|
745
754
|
useLexicalDragonSupport(editor);
|
|
746
755
|
}
|
|
@@ -753,8 +762,8 @@ function usePlainTextSetup(editor) {
|
|
|
753
762
|
*
|
|
754
763
|
*
|
|
755
764
|
*/
|
|
756
|
-
function useLexicalPlainText(editor, externalHistoryState) {
|
|
757
|
-
usePlainTextSetup(editor);
|
|
765
|
+
function useLexicalPlainText(editor, externalHistoryState, initialEditorState) {
|
|
766
|
+
usePlainTextSetup(editor, initialEditorState);
|
|
758
767
|
useLexicalHistory(editor, externalHistoryState);
|
|
759
768
|
}
|
|
760
769
|
|
|
@@ -4,18 +4,18 @@
|
|
|
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
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
{tag:"historic"})}return!0;case "redo":return
|
|
13
|
-
p=null===m?null:m.editorState;if(null===m||
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
h)t.insertRawText(h),r=m.getNode();u.$isTextNode(r)&&(q=
|
|
19
|
-
function
|
|
20
|
-
!0;case "insertParagraph":return e.insertLineBreak(),!0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c
|
|
21
|
-
a.execCommand("deleteCharacter",!0);case "keyDelete":return
|
|
7
|
+
var k=require("@lexical/react/withSubscriptions"),u=require("lexical"),v=require("react"),w=require("@lexical/clipboard");
|
|
8
|
+
function x(a,d,f,b,c){if(null===a||0===f.size&&0===b.size)return 0;var e=d._selection,g=a._selection;if(c)return 1;if(!(u.$isRangeSelection(e)&&u.$isRangeSelection(g)&&g.isCollapsed()&&e.isCollapsed()))return 0;var h=Array.from(f);b=Array.from(b);f=d._nodeMap;c=[];for(var l=0;l<h.length;l++){const n=f.get(h[l]);void 0!==n&&c.push(n)}for(h=0;h<b.length;h++)b[h][1]&&(l=f.get(b[h][0]),void 0===l||u.$isRootNode(l)||c.push(l));if(0===c.length)return 0;if(1<c.length)return b=d._nodeMap,d=b.get(e.anchor.key),
|
|
9
|
+
g=b.get(g.anchor.key),d&&g&&!a._nodeMap.has(d.__key)&&u.$isTextNode(d)&&1===d.__text.length&&1===e.anchor.offset?2:0;d=c[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;e=e.anchor;g=g.anchor;if(e.key!==g.key||"text"!==e.type)return 0;e=e.offset;g=g.offset;a=d.length-a.length;return 1===a&&g===e-1?2:-1===a&&g===e+1?3:-1===a&&g===e?4:0}
|
|
10
|
+
function y(a,d){let f=Date.now(),b=0;return(c,e,g,h,l,n)=>{const t=Date.now();if(n.has("historic"))return b=0,f=t,2;const m=x(c,e,h,l,a.isComposing()),r=(()=>{const q=n.has("history-push");if(!q&&n.has("history-merge"))return 0;if(null===c)return 1;var p=e._selection;const D=c._selection;if(!(0<h.size||0<l.size))return null===D&&null!==p?0:2;p=null===g||g.editor===a;return!1===q&&0!==m&&m===b&&t<f+d&&p?0:1})();f=t;b=m;return r}}
|
|
11
|
+
function z(a,d,f=1E3){const b=v.useMemo(()=>d||{current:null,redoStack:[],undoStack:[]},[d]),c=v.useCallback(()=>{b.undoStack=[];b.redoStack=[];b.current=null},[b]);v.useEffect(()=>{const e=y(a,f);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:t})=>{const m=b.current,r=b.redoStack,q=b.undoStack,
|
|
13
|
+
p=null===m?null:m.editorState;if(null===m||g!==p){l=e(h,g,m,l,n,t);if(1===l)0!==r.length&&(b.redoStack=[]),null!==m&&(q.push({...m,undoSelection:h.read(u.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;b.current={editor:a,editorState:g}}}))},[c,f,a,b])}function A(a,d,f=1E3){return z(a,d,f)}function B(a){a=a.anchor.getNode();return"rtl"===(u.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}
|
|
14
|
+
function C(a,d){a=u.$getDecoratorNode(a.focus,d);return u.$isDecoratorNode(a)&&!a.isIsolated()}var E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?v.useLayoutEffect:v.useEffect;function F(a,d){a.preventDefault();d.update(()=>{const f=u.$getSelection(),b=a.clipboardData;null!=b&&u.$isRangeSelection(f)&&w.$insertDataTransferForPlainText(b,f)})}
|
|
15
|
+
function G(a,d){H(a,d);d.update(()=>{const f=u.$getSelection();u.$isRangeSelection(f)&&f.removeText()})}function H(a,d){a.preventDefault();d.update(()=>{const f=a.clipboardData,b=u.$getSelection();if(null!==b&&null!=f){const c=w.getHtmlContent(d);null!==c&&f.setData("text/html",c);f.setData("text/plain",b.getTextContent())}})}const I={tag:"history-merge"};
|
|
16
|
+
function J(a,d){if(null!==d)if(void 0===d)a.update(()=>{var f=u.$getRoot();if(null===f.getFirstChild()){const b=u.$createParagraphNode();f.append(b);f=document.activeElement;(null!==u.$getSelection()||null!==f&&f===a.getRootElement())&&b.select()}},I);else if(null!==d)switch(typeof d){case "string":d=a.parseEditorState(d);a.setEditorState(d,I);break;case "object":a.setEditorState(d,I);break;case "function":a.update(d,I)}}
|
|
17
|
+
function K(a){v.useEffect(()=>{const d=f=>{var b=a.getRootElement();if(document.activeElement===b&&(b=f.data,"string"===typeof b)){try{var c=JSON.parse(b)}catch(e){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [e,g,h,l,n]=c;a.update(()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){var m=t.anchor;let r=m.getNode(),q=0,p=0;u.$isTextNode(r)&&0<=e&&0<=g&&(q=e,p=e+g,t.setTextNodeRange(r,q,r,p));if(q!==p||""!==
|
|
18
|
+
h)t.insertRawText(h),r=m.getNode();u.$isTextNode(r)&&(q=l,p=l+n,m=r.getTextContentSize(),q=q>m?m:q,p=p>m?m:p,t.setTextNodeRange(r,q,r,p));f.stopImmediatePropagation()}})}}};window.addEventListener("message",d,!0);return()=>{window.removeEventListener("message",d,!0)}},[a])}
|
|
19
|
+
function L(a,d){E(()=>{const f=a.addListener("command",(b,c)=>{const e=u.$getSelection();if(!u.$isRangeSelection(e))return!1;switch(b){case "deleteCharacter":return e.deleteCharacter(c),!0;case "deleteWord":return e.deleteWord(c),!0;case "deleteLine":return e.deleteLine(c),!0;case "insertText":return"string"===typeof c?e.insertText(c):(b=c.dataTransfer,null!=b?w.$insertDataTransferForPlainText(b,e):(c=c.data)&&e.insertText(c)),!0;case "removeText":return e.removeText(),!0;case "insertLineBreak":return e.insertLineBreak(c),
|
|
20
|
+
!0;case "insertParagraph":return e.insertLineBreak(),!0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":b=c.shiftKey;if(C(e,!0))return c.preventDefault(),c=b,b=B(e),e.modify(c?"extend":"move",!b,"character"),!0;break;case "keyArrowRight":b=c.shiftKey;if(C(e,!1))return c.preventDefault(),c=b,b=B(e),e.modify(c?"extend":"move",b,"character"),!0;break;case "keyBackspace":return c.preventDefault(),
|
|
21
|
+
a.execCommand("deleteCharacter",!0);case "keyDelete":return c.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return c.preventDefault(),a.execCommand("insertLineBreak");case "copy":return H(c,a),!0;case "cut":return G(c,a),!0;case "paste":return F(c,a),!0;case "drop":case "dragstart":return c.preventDefault(),!0}return!1},0);J(a,d);return f},[a]);K(a)}module.exports=function(a,d,f){L(a,f);A(a,d)};
|