lexical 0.30.1-nightly.20250414.0 → 0.30.1-nightly.20250416.0
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/Lexical.dev.js +306 -188
- package/Lexical.dev.mjs +304 -189
- package/Lexical.mjs +3 -0
- package/Lexical.node.mjs +3 -0
- package/Lexical.prod.js +1 -1
- package/Lexical.prod.mjs +1 -1
- package/LexicalCommands.d.ts +91 -0
- package/LexicalUtils.d.ts +69 -30
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/Lexical.dev.js
CHANGED
|
@@ -1786,29 +1786,108 @@ function createCommand(type) {
|
|
|
1786
1786
|
const SELECTION_CHANGE_COMMAND = createCommand('SELECTION_CHANGE_COMMAND');
|
|
1787
1787
|
const SELECTION_INSERT_CLIPBOARD_NODES_COMMAND = createCommand('SELECTION_INSERT_CLIPBOARD_NODES_COMMAND');
|
|
1788
1788
|
const CLICK_COMMAND = createCommand('CLICK_COMMAND');
|
|
1789
|
+
/**
|
|
1790
|
+
* Dispatched to delete a character, the payload will be `true` if the deletion
|
|
1791
|
+
* is backwards (backspace or delete on macOS) and `false` if forwards
|
|
1792
|
+
* (delete or Fn+Delete on macOS).
|
|
1793
|
+
*/
|
|
1789
1794
|
const DELETE_CHARACTER_COMMAND = createCommand('DELETE_CHARACTER_COMMAND');
|
|
1795
|
+
/**
|
|
1796
|
+
* Dispatched to insert a line break. With a false payload the
|
|
1797
|
+
* cursor moves to the new line (Shift+Enter), with a true payload the cursor
|
|
1798
|
+
* does not move (Ctrl+O on macOS).
|
|
1799
|
+
*/
|
|
1790
1800
|
const INSERT_LINE_BREAK_COMMAND = createCommand('INSERT_LINE_BREAK_COMMAND');
|
|
1791
1801
|
const INSERT_PARAGRAPH_COMMAND = createCommand('INSERT_PARAGRAPH_COMMAND');
|
|
1792
1802
|
const CONTROLLED_TEXT_INSERTION_COMMAND = createCommand('CONTROLLED_TEXT_INSERTION_COMMAND');
|
|
1793
1803
|
const PASTE_COMMAND = createCommand('PASTE_COMMAND');
|
|
1794
1804
|
const REMOVE_TEXT_COMMAND = createCommand('REMOVE_TEXT_COMMAND');
|
|
1805
|
+
/**
|
|
1806
|
+
* Dispatched to delete a word, the payload will be `true` if the deletion is
|
|
1807
|
+
* backwards (Ctrl+Backspace or Opt+Delete on macOS), and `false` if
|
|
1808
|
+
* forwards (Ctrl+Delete or Fn+Opt+Delete on macOS).
|
|
1809
|
+
*/
|
|
1795
1810
|
const DELETE_WORD_COMMAND = createCommand('DELETE_WORD_COMMAND');
|
|
1811
|
+
/**
|
|
1812
|
+
* Dispatched to delete a line, the payload will be `true` if the deletion is
|
|
1813
|
+
* backwards (Cmd+Delete on macOS), and `false` if forwards
|
|
1814
|
+
* (Fn+Cmd+Delete on macOS).
|
|
1815
|
+
*/
|
|
1796
1816
|
const DELETE_LINE_COMMAND = createCommand('DELETE_LINE_COMMAND');
|
|
1817
|
+
/**
|
|
1818
|
+
* Dispatched to format the selected text.
|
|
1819
|
+
*/
|
|
1797
1820
|
const FORMAT_TEXT_COMMAND = createCommand('FORMAT_TEXT_COMMAND');
|
|
1821
|
+
/**
|
|
1822
|
+
* Dispatched on undo (Cmd+Z on macOS, Ctrl+Z elsewhere).
|
|
1823
|
+
*/
|
|
1798
1824
|
const UNDO_COMMAND = createCommand('UNDO_COMMAND');
|
|
1825
|
+
/**
|
|
1826
|
+
* Dispatched on redo (Shift+Cmd+Z on macOS, Shift+Ctrl+Z or Ctrl+Y elsewhere).
|
|
1827
|
+
*/
|
|
1799
1828
|
const REDO_COMMAND = createCommand('REDO_COMMAND');
|
|
1829
|
+
/**
|
|
1830
|
+
* Dispatched when any key is pressed.
|
|
1831
|
+
*/
|
|
1800
1832
|
const KEY_DOWN_COMMAND = createCommand('KEYDOWN_COMMAND');
|
|
1833
|
+
/**
|
|
1834
|
+
* Dispatched when the `'ArrowRight'` key is pressed.
|
|
1835
|
+
* The shift modifier key may also be down.
|
|
1836
|
+
*/
|
|
1801
1837
|
const KEY_ARROW_RIGHT_COMMAND = createCommand('KEY_ARROW_RIGHT_COMMAND');
|
|
1838
|
+
/**
|
|
1839
|
+
* Dispatched when the move to end keyboard shortcut is pressed,
|
|
1840
|
+
* (Cmd+Right on macOS; Ctrl+Right elsewhere).
|
|
1841
|
+
*/
|
|
1802
1842
|
const MOVE_TO_END = createCommand('MOVE_TO_END');
|
|
1843
|
+
/**
|
|
1844
|
+
* Dispatched when the `'ArrowLeft'` key is pressed.
|
|
1845
|
+
* The shift modifier key may also be down.
|
|
1846
|
+
*/
|
|
1803
1847
|
const KEY_ARROW_LEFT_COMMAND = createCommand('KEY_ARROW_LEFT_COMMAND');
|
|
1848
|
+
/**
|
|
1849
|
+
* Dispatched when the move to start keyboard shortcut is pressed,
|
|
1850
|
+
* (Cmd+Left on macOS; Ctrl+Left elsewhere).
|
|
1851
|
+
*/
|
|
1804
1852
|
const MOVE_TO_START = createCommand('MOVE_TO_START');
|
|
1853
|
+
/**
|
|
1854
|
+
* Dispatched when the `'ArrowUp'` key is pressed.
|
|
1855
|
+
* The shift and/or alt (option) modifier keys may also be down.
|
|
1856
|
+
*/
|
|
1805
1857
|
const KEY_ARROW_UP_COMMAND = createCommand('KEY_ARROW_UP_COMMAND');
|
|
1858
|
+
/**
|
|
1859
|
+
* Dispatched when the `'ArrowUp'` key is pressed.
|
|
1860
|
+
* The shift and/or alt (option) modifier keys may also be down.
|
|
1861
|
+
*/
|
|
1806
1862
|
const KEY_ARROW_DOWN_COMMAND = createCommand('KEY_ARROW_DOWN_COMMAND');
|
|
1863
|
+
/**
|
|
1864
|
+
* Dispatched when the enter key is pressed, may also be called with a null
|
|
1865
|
+
* payload when the intent is to insert a newline.
|
|
1866
|
+
*/
|
|
1807
1867
|
const KEY_ENTER_COMMAND = createCommand('KEY_ENTER_COMMAND');
|
|
1868
|
+
/**
|
|
1869
|
+
* Dispatched whenever the space (`' '`) key is pressed, any modifier
|
|
1870
|
+
* keys may be down.
|
|
1871
|
+
*/
|
|
1808
1872
|
const KEY_SPACE_COMMAND = createCommand('KEY_SPACE_COMMAND');
|
|
1873
|
+
/**
|
|
1874
|
+
* Dispatched whenever the `'Backspace'` key is pressed, the shift
|
|
1875
|
+
* modifier key may be down.
|
|
1876
|
+
*/
|
|
1809
1877
|
const KEY_BACKSPACE_COMMAND = createCommand('KEY_BACKSPACE_COMMAND');
|
|
1878
|
+
/**
|
|
1879
|
+
* Dispatched whenever the `'Escape'` key is pressed, any modifier
|
|
1880
|
+
* keys may be down.
|
|
1881
|
+
*/
|
|
1810
1882
|
const KEY_ESCAPE_COMMAND = createCommand('KEY_ESCAPE_COMMAND');
|
|
1883
|
+
/**
|
|
1884
|
+
* Dispatched whenever the `'Delete'` key is pressed (Fn+Delete on macOS).
|
|
1885
|
+
*/
|
|
1811
1886
|
const KEY_DELETE_COMMAND = createCommand('KEY_DELETE_COMMAND');
|
|
1887
|
+
/**
|
|
1888
|
+
* Dispatched whenever the `'Tab'` key is pressed. The shift modifier key
|
|
1889
|
+
* may be down.
|
|
1890
|
+
*/
|
|
1812
1891
|
const KEY_TAB_COMMAND = createCommand('KEY_TAB_COMMAND');
|
|
1813
1892
|
const INSERT_TAB_COMMAND = createCommand('INSERT_TAB_COMMAND');
|
|
1814
1893
|
const INDENT_CONTENT_COMMAND = createCommand('INDENT_CONTENT_COMMAND');
|
|
@@ -1818,8 +1897,20 @@ const FORMAT_ELEMENT_COMMAND = createCommand('FORMAT_ELEMENT_COMMAND');
|
|
|
1818
1897
|
const DRAGSTART_COMMAND = createCommand('DRAGSTART_COMMAND');
|
|
1819
1898
|
const DRAGOVER_COMMAND = createCommand('DRAGOVER_COMMAND');
|
|
1820
1899
|
const DRAGEND_COMMAND = createCommand('DRAGEND_COMMAND');
|
|
1900
|
+
/**
|
|
1901
|
+
* Dispatched on a copy event, either via the clipboard or a KeyboardEvent
|
|
1902
|
+
* (Cmd+C on macOS, Ctrl+C elsewhere).
|
|
1903
|
+
*/
|
|
1821
1904
|
const COPY_COMMAND = createCommand('COPY_COMMAND');
|
|
1905
|
+
/**
|
|
1906
|
+
* Dispatched on a cut event, either via the clipboard or a KeyboardEvent
|
|
1907
|
+
* (Cmd+X on macOS, Ctrl+X elsewhere).
|
|
1908
|
+
*/
|
|
1822
1909
|
const CUT_COMMAND = createCommand('CUT_COMMAND');
|
|
1910
|
+
/**
|
|
1911
|
+
* Dispatched on the select all keyboard shortcut
|
|
1912
|
+
* (Cmd+A on macOS, Ctrl+A elsehwere).
|
|
1913
|
+
*/
|
|
1823
1914
|
const SELECT_ALL_COMMAND = createCommand('SELECT_ALL_COMMAND');
|
|
1824
1915
|
const CLEAR_EDITOR_COMMAND = createCommand('CLEAR_EDITOR_COMMAND');
|
|
1825
1916
|
const CLEAR_HISTORY_COMMAND = createCommand('CLEAR_HISTORY_COMMAND');
|
|
@@ -2520,20 +2611,13 @@ function onKeyDown(event, editor) {
|
|
|
2520
2611
|
if (editor.isComposing()) {
|
|
2521
2612
|
return;
|
|
2522
2613
|
}
|
|
2523
|
-
const {
|
|
2524
|
-
key,
|
|
2525
|
-
shiftKey,
|
|
2526
|
-
ctrlKey,
|
|
2527
|
-
metaKey,
|
|
2528
|
-
altKey
|
|
2529
|
-
} = event;
|
|
2530
2614
|
if (dispatchCommand(editor, KEY_DOWN_COMMAND, event)) {
|
|
2531
2615
|
return;
|
|
2532
2616
|
}
|
|
2533
|
-
if (key == null) {
|
|
2617
|
+
if (event.key == null) {
|
|
2534
2618
|
return;
|
|
2535
2619
|
}
|
|
2536
|
-
if (isSafariEndingComposition && isBackspace(
|
|
2620
|
+
if (isSafariEndingComposition && isBackspace(event)) {
|
|
2537
2621
|
updateEditorSync(editor, () => {
|
|
2538
2622
|
$onCompositionEndImpl(editor, safariEndCompositionEventData);
|
|
2539
2623
|
});
|
|
@@ -2541,96 +2625,95 @@ function onKeyDown(event, editor) {
|
|
|
2541
2625
|
safariEndCompositionEventData = '';
|
|
2542
2626
|
return;
|
|
2543
2627
|
}
|
|
2544
|
-
if (isMoveForward(
|
|
2628
|
+
if (isMoveForward(event)) {
|
|
2545
2629
|
dispatchCommand(editor, KEY_ARROW_RIGHT_COMMAND, event);
|
|
2546
|
-
} else if (isMoveToEnd(
|
|
2630
|
+
} else if (isMoveToEnd(event)) {
|
|
2547
2631
|
dispatchCommand(editor, MOVE_TO_END, event);
|
|
2548
|
-
} else if (isMoveBackward(
|
|
2632
|
+
} else if (isMoveBackward(event)) {
|
|
2549
2633
|
dispatchCommand(editor, KEY_ARROW_LEFT_COMMAND, event);
|
|
2550
|
-
} else if (isMoveToStart(
|
|
2634
|
+
} else if (isMoveToStart(event)) {
|
|
2551
2635
|
dispatchCommand(editor, MOVE_TO_START, event);
|
|
2552
|
-
} else if (isMoveUp(
|
|
2636
|
+
} else if (isMoveUp(event)) {
|
|
2553
2637
|
dispatchCommand(editor, KEY_ARROW_UP_COMMAND, event);
|
|
2554
|
-
} else if (isMoveDown(
|
|
2638
|
+
} else if (isMoveDown(event)) {
|
|
2555
2639
|
dispatchCommand(editor, KEY_ARROW_DOWN_COMMAND, event);
|
|
2556
|
-
} else if (isLineBreak(
|
|
2640
|
+
} else if (isLineBreak(event)) {
|
|
2557
2641
|
isInsertLineBreak = true;
|
|
2558
2642
|
dispatchCommand(editor, KEY_ENTER_COMMAND, event);
|
|
2559
|
-
} else if (isSpace(
|
|
2643
|
+
} else if (isSpace(event)) {
|
|
2560
2644
|
dispatchCommand(editor, KEY_SPACE_COMMAND, event);
|
|
2561
|
-
} else if (isOpenLineBreak(
|
|
2645
|
+
} else if (isOpenLineBreak(event)) {
|
|
2562
2646
|
event.preventDefault();
|
|
2563
2647
|
isInsertLineBreak = true;
|
|
2564
2648
|
dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, true);
|
|
2565
|
-
} else if (isParagraph(
|
|
2649
|
+
} else if (isParagraph(event)) {
|
|
2566
2650
|
isInsertLineBreak = false;
|
|
2567
2651
|
dispatchCommand(editor, KEY_ENTER_COMMAND, event);
|
|
2568
|
-
} else if (isDeleteBackward(
|
|
2569
|
-
if (isBackspace(
|
|
2652
|
+
} else if (isDeleteBackward(event)) {
|
|
2653
|
+
if (isBackspace(event)) {
|
|
2570
2654
|
dispatchCommand(editor, KEY_BACKSPACE_COMMAND, event);
|
|
2571
2655
|
} else {
|
|
2572
2656
|
event.preventDefault();
|
|
2573
2657
|
dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true);
|
|
2574
2658
|
}
|
|
2575
|
-
} else if (isEscape(
|
|
2659
|
+
} else if (isEscape(event)) {
|
|
2576
2660
|
dispatchCommand(editor, KEY_ESCAPE_COMMAND, event);
|
|
2577
|
-
} else if (isDeleteForward(
|
|
2578
|
-
if (isDelete(
|
|
2661
|
+
} else if (isDeleteForward(event)) {
|
|
2662
|
+
if (isDelete(event)) {
|
|
2579
2663
|
dispatchCommand(editor, KEY_DELETE_COMMAND, event);
|
|
2580
2664
|
} else {
|
|
2581
2665
|
event.preventDefault();
|
|
2582
2666
|
dispatchCommand(editor, DELETE_CHARACTER_COMMAND, false);
|
|
2583
2667
|
}
|
|
2584
|
-
} else if (isDeleteWordBackward(
|
|
2668
|
+
} else if (isDeleteWordBackward(event)) {
|
|
2585
2669
|
event.preventDefault();
|
|
2586
2670
|
dispatchCommand(editor, DELETE_WORD_COMMAND, true);
|
|
2587
|
-
} else if (isDeleteWordForward(
|
|
2671
|
+
} else if (isDeleteWordForward(event)) {
|
|
2588
2672
|
event.preventDefault();
|
|
2589
2673
|
dispatchCommand(editor, DELETE_WORD_COMMAND, false);
|
|
2590
|
-
} else if (isDeleteLineBackward(
|
|
2674
|
+
} else if (isDeleteLineBackward(event)) {
|
|
2591
2675
|
event.preventDefault();
|
|
2592
2676
|
dispatchCommand(editor, DELETE_LINE_COMMAND, true);
|
|
2593
|
-
} else if (isDeleteLineForward(
|
|
2677
|
+
} else if (isDeleteLineForward(event)) {
|
|
2594
2678
|
event.preventDefault();
|
|
2595
2679
|
dispatchCommand(editor, DELETE_LINE_COMMAND, false);
|
|
2596
|
-
} else if (isBold(
|
|
2680
|
+
} else if (isBold(event)) {
|
|
2597
2681
|
event.preventDefault();
|
|
2598
2682
|
dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'bold');
|
|
2599
|
-
} else if (isUnderline(
|
|
2683
|
+
} else if (isUnderline(event)) {
|
|
2600
2684
|
event.preventDefault();
|
|
2601
2685
|
dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'underline');
|
|
2602
|
-
} else if (isItalic(
|
|
2686
|
+
} else if (isItalic(event)) {
|
|
2603
2687
|
event.preventDefault();
|
|
2604
2688
|
dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'italic');
|
|
2605
|
-
} else if (isTab(
|
|
2689
|
+
} else if (isTab(event)) {
|
|
2606
2690
|
dispatchCommand(editor, KEY_TAB_COMMAND, event);
|
|
2607
|
-
} else if (isUndo(
|
|
2691
|
+
} else if (isUndo(event)) {
|
|
2608
2692
|
event.preventDefault();
|
|
2609
2693
|
dispatchCommand(editor, UNDO_COMMAND, undefined);
|
|
2610
|
-
} else if (isRedo(
|
|
2694
|
+
} else if (isRedo(event)) {
|
|
2611
2695
|
event.preventDefault();
|
|
2612
2696
|
dispatchCommand(editor, REDO_COMMAND, undefined);
|
|
2613
2697
|
} else {
|
|
2614
2698
|
const prevSelection = editor._editorState._selection;
|
|
2615
2699
|
if (prevSelection !== null && !$isRangeSelection(prevSelection)) {
|
|
2616
2700
|
// Only RangeSelection can use the native cut/copy/select all
|
|
2617
|
-
if (isCopy(
|
|
2701
|
+
if (isCopy(event)) {
|
|
2618
2702
|
event.preventDefault();
|
|
2619
2703
|
dispatchCommand(editor, COPY_COMMAND, event);
|
|
2620
|
-
} else if (isCut(
|
|
2704
|
+
} else if (isCut(event)) {
|
|
2621
2705
|
event.preventDefault();
|
|
2622
2706
|
dispatchCommand(editor, CUT_COMMAND, event);
|
|
2623
|
-
} else if (isSelectAll(
|
|
2707
|
+
} else if (isSelectAll(event)) {
|
|
2624
2708
|
event.preventDefault();
|
|
2625
2709
|
dispatchCommand(editor, SELECT_ALL_COMMAND, event);
|
|
2626
2710
|
}
|
|
2627
|
-
|
|
2628
|
-
} else if (!IS_FIREFOX && isSelectAll(key, metaKey, ctrlKey)) {
|
|
2711
|
+
} else if (!IS_FIREFOX && isSelectAll(event)) {
|
|
2629
2712
|
event.preventDefault();
|
|
2630
2713
|
dispatchCommand(editor, SELECT_ALL_COMMAND, event);
|
|
2631
2714
|
}
|
|
2632
2715
|
}
|
|
2633
|
-
if (isModifier(
|
|
2716
|
+
if (isModifier(event)) {
|
|
2634
2717
|
dispatchCommand(editor, KEY_MODIFIER_COMMAND, event);
|
|
2635
2718
|
}
|
|
2636
2719
|
}
|
|
@@ -10355,7 +10438,7 @@ class LexicalEditor {
|
|
|
10355
10438
|
};
|
|
10356
10439
|
}
|
|
10357
10440
|
}
|
|
10358
|
-
LexicalEditor.version = "0.30.1-nightly.
|
|
10441
|
+
LexicalEditor.version = "0.30.1-nightly.20250416.0+dev.cjs";
|
|
10359
10442
|
|
|
10360
10443
|
let keyCounter = 1;
|
|
10361
10444
|
function resetRandomKey() {
|
|
@@ -10546,6 +10629,13 @@ function internalMarkParentElementsAsDirty(parentKey, nodeMap, dirtyElements) {
|
|
|
10546
10629
|
}
|
|
10547
10630
|
|
|
10548
10631
|
// TODO #6031 this function or their callers have to adjust selection (i.e. insertBefore)
|
|
10632
|
+
/**
|
|
10633
|
+
* Removes a node from its parent, updating all necessary pointers and links.
|
|
10634
|
+
* @internal
|
|
10635
|
+
*
|
|
10636
|
+
* This function is for internal use of the library.
|
|
10637
|
+
* Please do not use it as it may change in the future.
|
|
10638
|
+
*/
|
|
10549
10639
|
function removeFromParent(node) {
|
|
10550
10640
|
const oldParent = node.getParent();
|
|
10551
10641
|
if (oldParent !== null) {
|
|
@@ -10553,47 +10643,38 @@ function removeFromParent(node) {
|
|
|
10553
10643
|
const writableParent = oldParent.getWritable();
|
|
10554
10644
|
const prevSibling = node.getPreviousSibling();
|
|
10555
10645
|
const nextSibling = node.getNextSibling();
|
|
10556
|
-
|
|
10646
|
+
|
|
10647
|
+
// Store sibling keys
|
|
10648
|
+
const nextSiblingKey = nextSibling !== null ? nextSibling.__key : null;
|
|
10649
|
+
const prevSiblingKey = prevSibling !== null ? prevSibling.__key : null;
|
|
10650
|
+
|
|
10651
|
+
// Get writable siblings once
|
|
10652
|
+
const writablePrevSibling = prevSibling !== null ? prevSibling.getWritable() : null;
|
|
10653
|
+
const writableNextSibling = nextSibling !== null ? nextSibling.getWritable() : null;
|
|
10654
|
+
|
|
10655
|
+
// Update parent's first/last pointers
|
|
10557
10656
|
if (prevSibling === null) {
|
|
10558
|
-
|
|
10559
|
-
const writableNextSibling = nextSibling.getWritable();
|
|
10560
|
-
writableParent.__first = nextSibling.__key;
|
|
10561
|
-
writableNextSibling.__prev = null;
|
|
10562
|
-
} else {
|
|
10563
|
-
writableParent.__first = null;
|
|
10564
|
-
}
|
|
10565
|
-
} else {
|
|
10566
|
-
const writablePrevSibling = prevSibling.getWritable();
|
|
10567
|
-
if (nextSibling !== null) {
|
|
10568
|
-
const writableNextSibling = nextSibling.getWritable();
|
|
10569
|
-
writableNextSibling.__prev = writablePrevSibling.__key;
|
|
10570
|
-
writablePrevSibling.__next = writableNextSibling.__key;
|
|
10571
|
-
} else {
|
|
10572
|
-
writablePrevSibling.__next = null;
|
|
10573
|
-
}
|
|
10574
|
-
writableNode.__prev = null;
|
|
10657
|
+
writableParent.__first = nextSiblingKey;
|
|
10575
10658
|
}
|
|
10576
10659
|
if (nextSibling === null) {
|
|
10577
|
-
|
|
10578
|
-
const writablePrevSibling = prevSibling.getWritable();
|
|
10579
|
-
writableParent.__last = prevSibling.__key;
|
|
10580
|
-
writablePrevSibling.__next = null;
|
|
10581
|
-
} else {
|
|
10582
|
-
writableParent.__last = null;
|
|
10583
|
-
}
|
|
10584
|
-
} else {
|
|
10585
|
-
const writableNextSibling = nextSibling.getWritable();
|
|
10586
|
-
if (prevSibling !== null) {
|
|
10587
|
-
const writablePrevSibling = prevSibling.getWritable();
|
|
10588
|
-
writablePrevSibling.__next = writableNextSibling.__key;
|
|
10589
|
-
writableNextSibling.__prev = writablePrevSibling.__key;
|
|
10590
|
-
} else {
|
|
10591
|
-
writableNextSibling.__prev = null;
|
|
10592
|
-
}
|
|
10593
|
-
writableNode.__next = null;
|
|
10660
|
+
writableParent.__last = prevSiblingKey;
|
|
10594
10661
|
}
|
|
10595
|
-
|
|
10662
|
+
|
|
10663
|
+
// Update sibling links
|
|
10664
|
+
if (writablePrevSibling !== null) {
|
|
10665
|
+
writablePrevSibling.__next = nextSiblingKey;
|
|
10666
|
+
}
|
|
10667
|
+
if (writableNextSibling !== null) {
|
|
10668
|
+
writableNextSibling.__prev = prevSiblingKey;
|
|
10669
|
+
}
|
|
10670
|
+
|
|
10671
|
+
// Clear node's links
|
|
10672
|
+
writableNode.__prev = null;
|
|
10673
|
+
writableNode.__next = null;
|
|
10596
10674
|
writableNode.__parent = null;
|
|
10675
|
+
|
|
10676
|
+
// Update parent size
|
|
10677
|
+
writableParent.__size--;
|
|
10597
10678
|
}
|
|
10598
10679
|
}
|
|
10599
10680
|
|
|
@@ -10919,150 +11000,184 @@ function $shouldInsertTextAfterOrBeforeTextNode(selection, node) {
|
|
|
10919
11000
|
return false;
|
|
10920
11001
|
}
|
|
10921
11002
|
}
|
|
10922
|
-
|
|
10923
|
-
|
|
11003
|
+
|
|
11004
|
+
/**
|
|
11005
|
+
* A KeyboardEvent or structurally similar object with a string `key` as well
|
|
11006
|
+
* as `altKey`, `ctrlKey`, `metaKey`, and `shiftKey` boolean properties.
|
|
11007
|
+
*/
|
|
11008
|
+
|
|
11009
|
+
/**
|
|
11010
|
+
* A record of keyboard modifiers that must be enabled.
|
|
11011
|
+
* If the value is `'any'` then the modifier key's state is ignored.
|
|
11012
|
+
* If the value is `true` then the modifier key must be pressed.
|
|
11013
|
+
* If the value is `false` or the property is omitted then the modifier key must
|
|
11014
|
+
* not be pressed.
|
|
11015
|
+
*/
|
|
11016
|
+
|
|
11017
|
+
function matchModifier(event, mask, prop) {
|
|
11018
|
+
const expected = mask[prop] || false;
|
|
11019
|
+
return expected === 'any' || expected === event[prop];
|
|
10924
11020
|
}
|
|
10925
|
-
|
|
10926
|
-
|
|
11021
|
+
|
|
11022
|
+
/**
|
|
11023
|
+
* Match a KeyboardEvent with its expected modifier state
|
|
11024
|
+
*
|
|
11025
|
+
* @param event A KeyboardEvent, or structurally similar object
|
|
11026
|
+
* @param mask An object specifying the expected state of the modifiers
|
|
11027
|
+
* @returns true if the event matches
|
|
11028
|
+
*/
|
|
11029
|
+
function isModifierMatch(event, mask) {
|
|
11030
|
+
return matchModifier(event, mask, 'altKey') && matchModifier(event, mask, 'ctrlKey') && matchModifier(event, mask, 'shiftKey') && matchModifier(event, mask, 'metaKey');
|
|
10927
11031
|
}
|
|
10928
|
-
|
|
10929
|
-
|
|
11032
|
+
|
|
11033
|
+
/**
|
|
11034
|
+
* Match a KeyboardEvent with its expected state
|
|
11035
|
+
*
|
|
11036
|
+
* @param event A KeyboardEvent, or structurally similar object
|
|
11037
|
+
* @param expectedKey The string to compare with event.key (case insensitive)
|
|
11038
|
+
* @param mask An object specifying the expected state of the modifiers
|
|
11039
|
+
* @returns true if the event matches
|
|
11040
|
+
*/
|
|
11041
|
+
function isExactShortcutMatch(event, expectedKey, mask) {
|
|
11042
|
+
return isModifierMatch(event, mask) && event.key.toLowerCase() === expectedKey.toLowerCase();
|
|
10930
11043
|
}
|
|
10931
|
-
|
|
10932
|
-
|
|
11044
|
+
const CONTROL_OR_META = {
|
|
11045
|
+
ctrlKey: !IS_APPLE,
|
|
11046
|
+
metaKey: IS_APPLE
|
|
11047
|
+
};
|
|
11048
|
+
const CONTROL_OR_ALT = {
|
|
11049
|
+
altKey: IS_APPLE,
|
|
11050
|
+
ctrlKey: !IS_APPLE
|
|
11051
|
+
};
|
|
11052
|
+
function isTab(event) {
|
|
11053
|
+
return isExactShortcutMatch(event, 'Tab', {
|
|
11054
|
+
shiftKey: 'any'
|
|
11055
|
+
});
|
|
10933
11056
|
}
|
|
10934
|
-
function
|
|
10935
|
-
return
|
|
11057
|
+
function isBold(event) {
|
|
11058
|
+
return isExactShortcutMatch(event, 'b', CONTROL_OR_META);
|
|
10936
11059
|
}
|
|
10937
|
-
function
|
|
10938
|
-
return
|
|
11060
|
+
function isItalic(event) {
|
|
11061
|
+
return isExactShortcutMatch(event, 'i', CONTROL_OR_META);
|
|
11062
|
+
}
|
|
11063
|
+
function isUnderline(event) {
|
|
11064
|
+
return isExactShortcutMatch(event, 'u', CONTROL_OR_META);
|
|
11065
|
+
}
|
|
11066
|
+
function isParagraph(event) {
|
|
11067
|
+
return isExactShortcutMatch(event, 'Enter', {});
|
|
11068
|
+
}
|
|
11069
|
+
function isLineBreak(event) {
|
|
11070
|
+
return isExactShortcutMatch(event, 'Enter', {
|
|
11071
|
+
shiftKey: true
|
|
11072
|
+
});
|
|
10939
11073
|
}
|
|
10940
11074
|
|
|
10941
11075
|
// Inserts a new line after the selection
|
|
10942
11076
|
|
|
10943
|
-
function isOpenLineBreak(
|
|
11077
|
+
function isOpenLineBreak(event) {
|
|
10944
11078
|
// 79 = KeyO
|
|
10945
|
-
return IS_APPLE &&
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
return isBackspace(key) && (IS_APPLE ? altKey : ctrlKey);
|
|
11079
|
+
return IS_APPLE && isExactShortcutMatch(event, 'o', {
|
|
11080
|
+
ctrlKey: true
|
|
11081
|
+
});
|
|
10949
11082
|
}
|
|
10950
|
-
function
|
|
10951
|
-
return
|
|
11083
|
+
function isDeleteWordBackward(event) {
|
|
11084
|
+
return isExactShortcutMatch(event, 'Backspace', CONTROL_OR_ALT);
|
|
10952
11085
|
}
|
|
10953
|
-
function
|
|
10954
|
-
return
|
|
11086
|
+
function isDeleteWordForward(event) {
|
|
11087
|
+
return isExactShortcutMatch(event, 'Delete', CONTROL_OR_ALT);
|
|
10955
11088
|
}
|
|
10956
|
-
function
|
|
10957
|
-
return IS_APPLE && (
|
|
11089
|
+
function isDeleteLineBackward(event) {
|
|
11090
|
+
return IS_APPLE && isExactShortcutMatch(event, 'Backspace', {
|
|
11091
|
+
metaKey: true
|
|
11092
|
+
});
|
|
10958
11093
|
}
|
|
10959
|
-
function
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
11094
|
+
function isDeleteLineForward(event) {
|
|
11095
|
+
return IS_APPLE && (isExactShortcutMatch(event, 'Delete', {
|
|
11096
|
+
metaKey: true
|
|
11097
|
+
}) || isExactShortcutMatch(event, 'k', {
|
|
11098
|
+
ctrlKey: true
|
|
11099
|
+
}));
|
|
11100
|
+
}
|
|
11101
|
+
function isDeleteBackward(event) {
|
|
11102
|
+
return isExactShortcutMatch(event, 'Backspace', {
|
|
11103
|
+
shiftKey: 'any'
|
|
11104
|
+
}) || IS_APPLE && isExactShortcutMatch(event, 'h', {
|
|
11105
|
+
ctrlKey: true
|
|
11106
|
+
});
|
|
10970
11107
|
}
|
|
10971
|
-
function isDeleteForward(
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
}
|
|
10976
|
-
return isDelete(key) || key.toLowerCase() === 'd' && ctrlKey;
|
|
10977
|
-
}
|
|
10978
|
-
if (ctrlKey || altKey || metaKey) {
|
|
10979
|
-
return false;
|
|
10980
|
-
}
|
|
10981
|
-
return isDelete(key);
|
|
11108
|
+
function isDeleteForward(event) {
|
|
11109
|
+
return isExactShortcutMatch(event, 'Delete', {}) || IS_APPLE && isExactShortcutMatch(event, 'd', {
|
|
11110
|
+
ctrlKey: true
|
|
11111
|
+
});
|
|
10982
11112
|
}
|
|
10983
|
-
function isUndo(
|
|
10984
|
-
return
|
|
11113
|
+
function isUndo(event) {
|
|
11114
|
+
return isExactShortcutMatch(event, 'z', CONTROL_OR_META);
|
|
10985
11115
|
}
|
|
10986
|
-
function isRedo(
|
|
11116
|
+
function isRedo(event) {
|
|
10987
11117
|
if (IS_APPLE) {
|
|
10988
|
-
return
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
}
|
|
10992
|
-
function isCopy(key, shiftKey, metaKey, ctrlKey) {
|
|
10993
|
-
if (shiftKey) {
|
|
10994
|
-
return false;
|
|
10995
|
-
}
|
|
10996
|
-
if (key.toLowerCase() === 'c') {
|
|
10997
|
-
return IS_APPLE ? metaKey : ctrlKey;
|
|
10998
|
-
}
|
|
10999
|
-
return false;
|
|
11000
|
-
}
|
|
11001
|
-
function isCut(key, shiftKey, metaKey, ctrlKey) {
|
|
11002
|
-
if (shiftKey) {
|
|
11003
|
-
return false;
|
|
11004
|
-
}
|
|
11005
|
-
if (key.toLowerCase() === 'x') {
|
|
11006
|
-
return IS_APPLE ? metaKey : ctrlKey;
|
|
11118
|
+
return isExactShortcutMatch(event, 'z', {
|
|
11119
|
+
metaKey: true,
|
|
11120
|
+
shiftKey: true
|
|
11121
|
+
});
|
|
11007
11122
|
}
|
|
11008
|
-
return
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
return key === 'ArrowRight';
|
|
11015
|
-
}
|
|
11016
|
-
function isArrowUp(key) {
|
|
11017
|
-
return key === 'ArrowUp';
|
|
11018
|
-
}
|
|
11019
|
-
function isArrowDown(key) {
|
|
11020
|
-
return key === 'ArrowDown';
|
|
11123
|
+
return isExactShortcutMatch(event, 'y', {
|
|
11124
|
+
ctrlKey: true
|
|
11125
|
+
}) || isExactShortcutMatch(event, 'z', {
|
|
11126
|
+
ctrlKey: true,
|
|
11127
|
+
shiftKey: true
|
|
11128
|
+
});
|
|
11021
11129
|
}
|
|
11022
|
-
function
|
|
11023
|
-
return
|
|
11130
|
+
function isCopy(event) {
|
|
11131
|
+
return isExactShortcutMatch(event, 'c', CONTROL_OR_META);
|
|
11024
11132
|
}
|
|
11025
|
-
function
|
|
11026
|
-
return
|
|
11133
|
+
function isCut(event) {
|
|
11134
|
+
return isExactShortcutMatch(event, 'x', CONTROL_OR_META);
|
|
11027
11135
|
}
|
|
11028
|
-
function
|
|
11029
|
-
return
|
|
11136
|
+
function isMoveBackward(event) {
|
|
11137
|
+
return isExactShortcutMatch(event, 'ArrowLeft', {
|
|
11138
|
+
shiftKey: 'any'
|
|
11139
|
+
});
|
|
11030
11140
|
}
|
|
11031
|
-
function
|
|
11032
|
-
return
|
|
11141
|
+
function isMoveToStart(event) {
|
|
11142
|
+
return isExactShortcutMatch(event, 'ArrowLeft', CONTROL_OR_META);
|
|
11033
11143
|
}
|
|
11034
|
-
function
|
|
11035
|
-
return
|
|
11144
|
+
function isMoveForward(event) {
|
|
11145
|
+
return isExactShortcutMatch(event, 'ArrowRight', {
|
|
11146
|
+
shiftKey: 'any'
|
|
11147
|
+
});
|
|
11036
11148
|
}
|
|
11037
|
-
function
|
|
11038
|
-
return
|
|
11149
|
+
function isMoveToEnd(event) {
|
|
11150
|
+
return isExactShortcutMatch(event, 'ArrowRight', CONTROL_OR_META);
|
|
11039
11151
|
}
|
|
11040
|
-
function
|
|
11041
|
-
return
|
|
11152
|
+
function isMoveUp(event) {
|
|
11153
|
+
return isExactShortcutMatch(event, 'ArrowUp', {
|
|
11154
|
+
altKey: 'any',
|
|
11155
|
+
shiftKey: 'any'
|
|
11156
|
+
});
|
|
11042
11157
|
}
|
|
11043
|
-
function
|
|
11044
|
-
return
|
|
11158
|
+
function isMoveDown(event) {
|
|
11159
|
+
return isExactShortcutMatch(event, 'ArrowDown', {
|
|
11160
|
+
altKey: 'any',
|
|
11161
|
+
shiftKey: 'any'
|
|
11162
|
+
});
|
|
11045
11163
|
}
|
|
11046
|
-
function
|
|
11047
|
-
|
|
11048
|
-
return metaKey;
|
|
11049
|
-
}
|
|
11050
|
-
return ctrlKey;
|
|
11164
|
+
function isModifier(event) {
|
|
11165
|
+
return event.ctrlKey || event.shiftKey || event.altKey || event.metaKey;
|
|
11051
11166
|
}
|
|
11052
|
-
function
|
|
11053
|
-
return key === '
|
|
11167
|
+
function isSpace(event) {
|
|
11168
|
+
return event.key === ' ';
|
|
11054
11169
|
}
|
|
11055
|
-
function isBackspace(
|
|
11056
|
-
return key === 'Backspace';
|
|
11170
|
+
function isBackspace(event) {
|
|
11171
|
+
return event.key === 'Backspace';
|
|
11057
11172
|
}
|
|
11058
|
-
function isEscape(
|
|
11059
|
-
return key === 'Escape';
|
|
11173
|
+
function isEscape(event) {
|
|
11174
|
+
return event.key === 'Escape';
|
|
11060
11175
|
}
|
|
11061
|
-
function isDelete(
|
|
11062
|
-
return key === 'Delete';
|
|
11176
|
+
function isDelete(event) {
|
|
11177
|
+
return event.key === 'Delete';
|
|
11063
11178
|
}
|
|
11064
|
-
function isSelectAll(
|
|
11065
|
-
return
|
|
11179
|
+
function isSelectAll(event) {
|
|
11180
|
+
return isExactShortcutMatch(event, 'a', CONTROL_OR_META);
|
|
11066
11181
|
}
|
|
11067
11182
|
function $selectAll(selection) {
|
|
11068
11183
|
const root = $getRoot();
|
|
@@ -13242,13 +13357,16 @@ exports.isDOMNode = isDOMNode;
|
|
|
13242
13357
|
exports.isDOMTextNode = isDOMTextNode;
|
|
13243
13358
|
exports.isDOMUnmanaged = isDOMUnmanaged;
|
|
13244
13359
|
exports.isDocumentFragment = isDocumentFragment;
|
|
13360
|
+
exports.isExactShortcutMatch = isExactShortcutMatch;
|
|
13245
13361
|
exports.isHTMLAnchorElement = isHTMLAnchorElement;
|
|
13246
13362
|
exports.isHTMLElement = isHTMLElement;
|
|
13247
13363
|
exports.isInlineDomNode = isInlineDomNode;
|
|
13248
13364
|
exports.isLexicalEditor = isLexicalEditor;
|
|
13365
|
+
exports.isModifierMatch = isModifierMatch;
|
|
13249
13366
|
exports.isSelectionCapturedInDecoratorInput = isSelectionCapturedInDecoratorInput;
|
|
13250
13367
|
exports.isSelectionWithinEditor = isSelectionWithinEditor;
|
|
13251
13368
|
exports.makeStepwiseIterator = makeStepwiseIterator;
|
|
13369
|
+
exports.removeFromParent = removeFromParent;
|
|
13252
13370
|
exports.resetRandomKey = resetRandomKey;
|
|
13253
13371
|
exports.setDOMUnmanaged = setDOMUnmanaged;
|
|
13254
13372
|
exports.setNodeIndentFromDOM = setNodeIndentFromDOM;
|