@mx-space/cli 0.1.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/LICENSE +33 -0
- package/README.md +375 -0
- package/ROADMAP.md +42 -0
- package/bin/mxs.cjs +40 -0
- package/dist/Lexical.dev-DpU35QTu.mjs +10992 -0
- package/dist/Lexical.dev-DpU35QTu.mjs.map +1 -0
- package/dist/Lexical.node-gYNDt_p9.mjs +247 -0
- package/dist/Lexical.node-gYNDt_p9.mjs.map +1 -0
- package/dist/Lexical.prod-t4c3bHV3.mjs +5579 -0
- package/dist/Lexical.prod-t4c3bHV3.mjs.map +1 -0
- package/dist/LexicalClipboard.dev-CdeeWCIq.mjs +496 -0
- package/dist/LexicalClipboard.dev-CdeeWCIq.mjs.map +1 -0
- package/dist/LexicalClipboard.node-0e9GBL1g.mjs +26 -0
- package/dist/LexicalClipboard.node-0e9GBL1g.mjs.map +1 -0
- package/dist/LexicalClipboard.prod-CsCWYmV7.mjs +293 -0
- package/dist/LexicalClipboard.prod-CsCWYmV7.mjs.map +1 -0
- package/dist/LexicalCodeCore.dev-haI2cqH8.mjs +539 -0
- package/dist/LexicalCodeCore.dev-haI2cqH8.mjs.map +1 -0
- package/dist/LexicalCodeCore.prod-D_k7zuE5.mjs +383 -0
- package/dist/LexicalCodeCore.prod-D_k7zuE5.mjs.map +1 -0
- package/dist/LexicalDragon.dev-CAggdFh_.mjs +90 -0
- package/dist/LexicalDragon.dev-CAggdFh_.mjs.map +1 -0
- package/dist/LexicalDragon.node-QMR_wqJg.mjs +15 -0
- package/dist/LexicalDragon.node-QMR_wqJg.mjs.map +1 -0
- package/dist/LexicalDragon.prod-OssQhwS-.mjs +61 -0
- package/dist/LexicalDragon.prod-OssQhwS-.mjs.map +1 -0
- package/dist/LexicalExtension.dev-CtDZiMCU.mjs +1665 -0
- package/dist/LexicalExtension.dev-CtDZiMCU.mjs.map +1 -0
- package/dist/LexicalExtension.node-BM0gh8zu.mjs +51 -0
- package/dist/LexicalExtension.node-BM0gh8zu.mjs.map +1 -0
- package/dist/LexicalExtension.prod-Ug6emhEO.mjs +971 -0
- package/dist/LexicalExtension.prod-Ug6emhEO.mjs.map +1 -0
- package/dist/LexicalHeadless.dev-D4yQpl_s.mjs +45 -0
- package/dist/LexicalHeadless.dev-D4yQpl_s.mjs.map +1 -0
- package/dist/LexicalHeadless.prod-jeN65B3k.mjs +31 -0
- package/dist/LexicalHeadless.prod-jeN65B3k.mjs.map +1 -0
- package/dist/LexicalHtml.dev-BdU1_ITQ.mjs +686 -0
- package/dist/LexicalHtml.dev-BdU1_ITQ.mjs.map +1 -0
- package/dist/LexicalHtml.node-DLtAh00E.mjs +26 -0
- package/dist/LexicalHtml.node-DLtAh00E.mjs.map +1 -0
- package/dist/LexicalHtml.prod-DdLE1HHT.mjs +432 -0
- package/dist/LexicalHtml.prod-DdLE1HHT.mjs.map +1 -0
- package/dist/LexicalLink.dev-DK87Biuy.mjs +1084 -0
- package/dist/LexicalLink.dev-DK87Biuy.mjs.map +1 -0
- package/dist/LexicalLink.prod-fssuv6Sf.mjs +717 -0
- package/dist/LexicalLink.prod-fssuv6Sf.mjs.map +1 -0
- package/dist/LexicalList.dev-BJ4dr_rk.mjs +1352 -0
- package/dist/LexicalList.dev-BJ4dr_rk.mjs.map +1 -0
- package/dist/LexicalList.prod-jWBbaWfi.mjs +841 -0
- package/dist/LexicalList.prod-jWBbaWfi.mjs.map +1 -0
- package/dist/LexicalMarkdown.dev-C8e-eh6y.mjs +1207 -0
- package/dist/LexicalMarkdown.dev-C8e-eh6y.mjs.map +1 -0
- package/dist/LexicalMarkdown.prod-k73tZVb2.mjs +756 -0
- package/dist/LexicalMarkdown.prod-k73tZVb2.mjs.map +1 -0
- package/dist/LexicalRichText.dev-CrSqq3K-.mjs +645 -0
- package/dist/LexicalRichText.dev-CrSqq3K-.mjs.map +1 -0
- package/dist/LexicalRichText.node-B7k7wlQz.mjs +106 -0
- package/dist/LexicalRichText.node-B7k7wlQz.mjs.map +1 -0
- package/dist/LexicalRichText.prod-CqvyxQ9m.mjs +429 -0
- package/dist/LexicalRichText.prod-CqvyxQ9m.mjs.map +1 -0
- package/dist/LexicalSelection.dev-sNOHKHe_.mjs +725 -0
- package/dist/LexicalSelection.dev-sNOHKHe_.mjs.map +1 -0
- package/dist/LexicalSelection.node-Di7GwBCZ.mjs +38 -0
- package/dist/LexicalSelection.node-Di7GwBCZ.mjs.map +1 -0
- package/dist/LexicalSelection.prod-SWllPJop.mjs +388 -0
- package/dist/LexicalSelection.prod-SWllPJop.mjs.map +1 -0
- package/dist/LexicalTable.dev-CQkLHXJx.mjs +3262 -0
- package/dist/LexicalTable.dev-CQkLHXJx.mjs.map +1 -0
- package/dist/LexicalTable.prod-BtqCwKSi.mjs +2218 -0
- package/dist/LexicalTable.prod-BtqCwKSi.mjs.map +1 -0
- package/dist/LexicalUtils.dev-DiUpsXE8.mjs +850 -0
- package/dist/LexicalUtils.dev-DiUpsXE8.mjs.map +1 -0
- package/dist/LexicalUtils.node-CmK462d1.mjs +66 -0
- package/dist/LexicalUtils.node-CmK462d1.mjs.map +1 -0
- package/dist/LexicalUtils.prod-bWwV4GAF.mjs +377 -0
- package/dist/LexicalUtils.prod-bWwV4GAF.mjs.map +1 -0
- package/dist/auth-DIFZzoMm.mjs +211 -0
- package/dist/auth-DIFZzoMm.mjs.map +1 -0
- package/dist/bin/mxs.d.mts +927 -0
- package/dist/bin/mxs.mjs +3249 -0
- package/dist/bin/mxs.mjs.map +1 -0
- package/dist/chunk-hT5z_Zn9.mjs +35 -0
- package/dist/config-store-DIu7x0ao.mjs +121 -0
- package/dist/config-store-DIu7x0ao.mjs.map +1 -0
- package/dist/create-B2AOQL1e.mjs +24 -0
- package/dist/create-B2AOQL1e.mjs.map +1 -0
- package/dist/create-CwjGcv2n.mjs +23 -0
- package/dist/create-CwjGcv2n.mjs.map +1 -0
- package/dist/create-DT1l2hue.mjs +23 -0
- package/dist/create-DT1l2hue.mjs.map +1 -0
- package/dist/create-DjlRHPXy.mjs +23 -0
- package/dist/create-DjlRHPXy.mjs.map +1 -0
- package/dist/create-Dz6rJJSS.mjs +19 -0
- package/dist/create-Dz6rJJSS.mjs.map +1 -0
- package/dist/delete-B4dGrrus.mjs +22 -0
- package/dist/delete-B4dGrrus.mjs.map +1 -0
- package/dist/delete-BH6ZngTz.mjs +22 -0
- package/dist/delete-BH6ZngTz.mjs.map +1 -0
- package/dist/delete-BrY5zJ6S.mjs +22 -0
- package/dist/delete-BrY5zJ6S.mjs.map +1 -0
- package/dist/delete-CaG2d_xt.mjs +31 -0
- package/dist/delete-CaG2d_xt.mjs.map +1 -0
- package/dist/delete-YzRliRn8.mjs +31 -0
- package/dist/delete-YzRliRn8.mjs.map +1 -0
- package/dist/document-output-BVB8emLt.mjs +145 -0
- package/dist/document-output-BVB8emLt.mjs.map +1 -0
- package/dist/edit-Bb0Ze4w6.mjs +79 -0
- package/dist/edit-Bb0Ze4w6.mjs.map +1 -0
- package/dist/edit-BeFmC3XD.mjs +80 -0
- package/dist/edit-BeFmC3XD.mjs.map +1 -0
- package/dist/edit-DLDw_ZWX.mjs +86 -0
- package/dist/edit-DLDw_ZWX.mjs.map +1 -0
- package/dist/edit-z55ofr1S.mjs +40 -0
- package/dist/edit-z55ofr1S.mjs.map +1 -0
- package/dist/editor-xrF-j3UE.mjs +42 -0
- package/dist/editor-xrF-j3UE.mjs.map +1 -0
- package/dist/envelope-overlays-DPAlMNW1.mjs +26 -0
- package/dist/envelope-overlays-DPAlMNW1.mjs.map +1 -0
- package/dist/get-2qjq0wgG.mjs +28 -0
- package/dist/get-2qjq0wgG.mjs.map +1 -0
- package/dist/get-BGAk1Zmv.mjs +14 -0
- package/dist/get-BGAk1Zmv.mjs.map +1 -0
- package/dist/get-CRR13lgj.mjs +10 -0
- package/dist/get-CRR13lgj.mjs.map +1 -0
- package/dist/get-ClkpDBTL.mjs +13 -0
- package/dist/get-ClkpDBTL.mjs.map +1 -0
- package/dist/get-DJfUJ3sP.mjs +10 -0
- package/dist/get-DJfUJ3sP.mjs.map +1 -0
- package/dist/get-DiqaQvoS.mjs +14 -0
- package/dist/get-DiqaQvoS.mjs.map +1 -0
- package/dist/index.d.mts +338 -0
- package/dist/index.mjs +10 -0
- package/dist/list-BYzhflDg.mjs +14 -0
- package/dist/list-BYzhflDg.mjs.map +1 -0
- package/dist/list-DY-tPNG-.mjs +10 -0
- package/dist/list-DY-tPNG-.mjs.map +1 -0
- package/dist/list-DlQSkbqx.mjs +10 -0
- package/dist/list-DlQSkbqx.mjs.map +1 -0
- package/dist/list-DsrA5wIz.mjs +15 -0
- package/dist/list-DsrA5wIz.mjs.map +1 -0
- package/dist/list-Fp4nKfQb.mjs +10 -0
- package/dist/list-Fp4nKfQb.mjs.map +1 -0
- package/dist/list-s_tloiEX.mjs +10 -0
- package/dist/list-s_tloiEX.mjs.map +1 -0
- package/dist/litexml-codec-CDoRloiR.mjs +13451 -0
- package/dist/litexml-codec-CDoRloiR.mjs.map +1 -0
- package/dist/login-CLOJ-fTJ.mjs +579 -0
- package/dist/login-CLOJ-fTJ.mjs.map +1 -0
- package/dist/logout-v8ihxsim.mjs +11 -0
- package/dist/logout-v8ihxsim.mjs.map +1 -0
- package/dist/onboarding-640IldLz.mjs +888 -0
- package/dist/onboarding-640IldLz.mjs.map +1 -0
- package/dist/output-BM7aBFwt.mjs +120 -0
- package/dist/output-BM7aBFwt.mjs.map +1 -0
- package/dist/output-CTnO1lYt.d.mts +16 -0
- package/dist/payload-CN11pUto.mjs +547 -0
- package/dist/payload-CN11pUto.mjs.map +1 -0
- package/dist/publish-DkTYB-eK.mjs +23 -0
- package/dist/publish-DkTYB-eK.mjs.map +1 -0
- package/dist/publish-pRBfTJfe.mjs +23 -0
- package/dist/publish-pRBfTJfe.mjs.map +1 -0
- package/dist/resolve-BogJOR7R.mjs +119 -0
- package/dist/resolve-BogJOR7R.mjs.map +1 -0
- package/dist/resolve-Bp1AfBmM.mjs +26 -0
- package/dist/resolve-Bp1AfBmM.mjs.map +1 -0
- package/dist/resolve-Bw5Po9yK.mjs +16 -0
- package/dist/resolve-Bw5Po9yK.mjs.map +1 -0
- package/dist/resolve-CyjMlaoJ.mjs +23 -0
- package/dist/resolve-CyjMlaoJ.mjs.map +1 -0
- package/dist/resolve-helpers-CahPoJ0Y.mjs +30 -0
- package/dist/resolve-helpers-CahPoJ0Y.mjs.map +1 -0
- package/dist/set-BEGQz2si.mjs +43 -0
- package/dist/set-BEGQz2si.mjs.map +1 -0
- package/dist/shared-D0HVBDHI.mjs +39 -0
- package/dist/shared-D0HVBDHI.mjs.map +1 -0
- package/dist/status-LXrN9fI-.mjs +22 -0
- package/dist/status-LXrN9fI-.mjs.map +1 -0
- package/dist/update-B9ynFCdZ.mjs +30 -0
- package/dist/update-B9ynFCdZ.mjs.map +1 -0
- package/dist/update-BMZQPOvR.mjs +28 -0
- package/dist/update-BMZQPOvR.mjs.map +1 -0
- package/dist/update-BXz0l7Lz.mjs +36 -0
- package/dist/update-BXz0l7Lz.mjs.map +1 -0
- package/dist/update-Dx6AF8tf.mjs +30 -0
- package/dist/update-Dx6AF8tf.mjs.map +1 -0
- package/dist/update-q66TLS38.mjs +37 -0
- package/dist/update-q66TLS38.mjs.map +1 -0
- package/dist/whoami-CTkctOEd.mjs +22 -0
- package/dist/whoami-CTkctOEd.mjs.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
import { Bt as DROP_COMMAND, Ft as DELETE_CHARACTER_COMMAND, Gt as FORMAT_TEXT_COMMAND, Hn as isDOMNode, Ht as ElementNode, It as DELETE_LINE_COMMAND, Lt as DELETE_WORD_COMMAND, Mn as defineExtension, Mt as COPY_COMMAND, N as $getNearestNodeFromDOMNode, Nt as CUT_COMMAND, On as createCommand, Ot as COMMAND_PRIORITY_EDITOR, Qt as INSERT_TAB_COMMAND, R as $getRoot, Rt as DRAGOVER_COMMAND, Tt as CLICK_COMMAND, W as $insertNodes, Wt as FORMAT_ELEMENT_COMMAND, Xt as INSERT_LINE_BREAK_COMMAND, Y as $isElementNode, Yt as INDENT_CONTENT_COMMAND, Zt as INSERT_PARAGRAPH_COMMAND, an as KEY_DELETE_COMMAND, cn as KEY_SPACE_COMMAND, ct as $isTextNode, dn as OUTDENT_CONTENT_COMMAND, en as KEY_ARROW_DOWN_COMMAND, f as $createParagraphNode, fn as PASTE_COMMAND, ft as $normalizeSelection__EXPERIMENTAL, g as $createTabNode, gt as $selectAll, hn as REMOVE_TEXT_COMMAND, in as KEY_BACKSPACE_COMMAND, it as $isRootNode, jt as CONTROLLED_TEXT_INSERTION_COMMAND, ln as KEY_TAB_COMMAND, m as $createRangeSelection, n as $applyNodeReplacement, nn as KEY_ARROW_RIGHT_COMMAND, nr as setNodeIndentFromDOM, on as KEY_ENTER_COMMAND, pn as PASTE_TAG, q as $isDecoratorNode, qn as isSelectionCapturedInDecoratorInput, rn as KEY_ARROW_UP_COMMAND, rt as $isRangeSelection, sn as KEY_ESCAPE_COMMAND, tn as KEY_ARROW_LEFT_COMMAND, tt as $isNodeSelection, vt as $setSelection, x as $getAdjacentNode, yn as SELECT_ALL_COMMAND, z as $getSelection, zt as DRAGSTART_COMMAND } from "./Lexical.node-gYNDt_p9.mjs";
|
|
2
|
+
import { i as $shouldOverrideDefaultCharacterSelection, n as $isParentRTL, r as $moveCharacter } from "./LexicalSelection.node-Di7GwBCZ.mjs";
|
|
3
|
+
import { d as addClassNamesToElement, g as objectKlassEquals, h as mergeRegister, i as $getNearestBlockElementAncestorOrThrow, m as isHTMLElement, o as $handleIndentAndOutdent, r as $findMatchingParent } from "./LexicalUtils.node-CmK462d1.mjs";
|
|
4
|
+
import { a as copyToClipboard, i as $writeDragSourceToDataTransfer, n as $handleRichTextDrop, o as setLexicalClipboardDataTransfer, r as $insertDataTransferForRichText, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-0e9GBL1g.mjs";
|
|
5
|
+
import { t as DragonExtension } from "./LexicalDragon.node-QMR_wqJg.mjs";
|
|
6
|
+
//#region ../../node_modules/.pnpm/@lexical+rich-text@0.44.0/node_modules/@lexical/rich-text/LexicalRichText.dev.mjs
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the MIT license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
function caretFromPoint(x, y) {
|
|
22
|
+
if (typeof document.caretRangeFromPoint !== "undefined") {
|
|
23
|
+
const range = document.caretRangeFromPoint(x, y);
|
|
24
|
+
if (range === null) return null;
|
|
25
|
+
return {
|
|
26
|
+
node: range.startContainer,
|
|
27
|
+
offset: range.startOffset
|
|
28
|
+
};
|
|
29
|
+
} else if (document.caretPositionFromPoint !== "undefined") {
|
|
30
|
+
const range = document.caretPositionFromPoint(x, y);
|
|
31
|
+
if (range === null) return null;
|
|
32
|
+
return {
|
|
33
|
+
node: range.offsetNode,
|
|
34
|
+
offset: range.offset
|
|
35
|
+
};
|
|
36
|
+
} else return null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
const CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
46
|
+
/**
|
|
47
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the MIT license found in the
|
|
50
|
+
* LICENSE file in the root directory of this source tree.
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
const documentMode = CAN_USE_DOM && "documentMode" in document ? document.documentMode : null;
|
|
54
|
+
const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
55
|
+
const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && "InputEvent" in window && !documentMode ? "getTargetRanges" in new window.InputEvent("input") : false;
|
|
56
|
+
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
57
|
+
const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
|
|
58
|
+
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent) && !IS_ANDROID;
|
|
59
|
+
const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
|
|
60
|
+
const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && IS_APPLE && !IS_CHROME;
|
|
61
|
+
/**
|
|
62
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the MIT license found in the
|
|
65
|
+
* LICENSE file in the root directory of this source tree.
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
const DRAG_DROP_PASTE = createCommand("DRAG_DROP_PASTE_FILE");
|
|
69
|
+
/** @noInheritDoc */
|
|
70
|
+
var QuoteNode = class QuoteNode extends ElementNode {
|
|
71
|
+
static getType() {
|
|
72
|
+
return "quote";
|
|
73
|
+
}
|
|
74
|
+
static clone(node) {
|
|
75
|
+
return new QuoteNode(node.__key);
|
|
76
|
+
}
|
|
77
|
+
createDOM(config) {
|
|
78
|
+
const element = document.createElement("blockquote");
|
|
79
|
+
addClassNamesToElement(element, config.theme.quote);
|
|
80
|
+
return element;
|
|
81
|
+
}
|
|
82
|
+
updateDOM(prevNode, dom) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
static importDOM() {
|
|
86
|
+
return { blockquote: (node) => ({
|
|
87
|
+
conversion: $convertBlockquoteElement,
|
|
88
|
+
priority: 0
|
|
89
|
+
}) };
|
|
90
|
+
}
|
|
91
|
+
exportDOM(editor) {
|
|
92
|
+
const { element } = super.exportDOM(editor);
|
|
93
|
+
if (isHTMLElement(element)) {
|
|
94
|
+
if (this.isEmpty()) element.append(document.createElement("br"));
|
|
95
|
+
const formatType = this.getFormatType();
|
|
96
|
+
if (formatType) element.style.textAlign = formatType;
|
|
97
|
+
const direction = this.getDirection();
|
|
98
|
+
if (direction) element.dir = direction;
|
|
99
|
+
}
|
|
100
|
+
return { element };
|
|
101
|
+
}
|
|
102
|
+
static importJSON(serializedNode) {
|
|
103
|
+
return $createQuoteNode().updateFromJSON(serializedNode);
|
|
104
|
+
}
|
|
105
|
+
insertNewAfter(_, restoreSelection) {
|
|
106
|
+
const newBlock = $createParagraphNode();
|
|
107
|
+
const direction = this.getDirection();
|
|
108
|
+
newBlock.setDirection(direction);
|
|
109
|
+
this.insertAfter(newBlock, restoreSelection);
|
|
110
|
+
return newBlock;
|
|
111
|
+
}
|
|
112
|
+
collapseAtStart() {
|
|
113
|
+
const paragraph = $createParagraphNode();
|
|
114
|
+
this.getChildren().forEach((child) => paragraph.append(child));
|
|
115
|
+
this.replace(paragraph);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
canMergeWhenEmpty() {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
function $createQuoteNode() {
|
|
123
|
+
return $applyNodeReplacement(new QuoteNode());
|
|
124
|
+
}
|
|
125
|
+
function $isQuoteNode(node) {
|
|
126
|
+
return node instanceof QuoteNode;
|
|
127
|
+
}
|
|
128
|
+
/** @noInheritDoc */
|
|
129
|
+
var HeadingNode = class HeadingNode extends ElementNode {
|
|
130
|
+
/** @internal */
|
|
131
|
+
__tag;
|
|
132
|
+
static getType() {
|
|
133
|
+
return "heading";
|
|
134
|
+
}
|
|
135
|
+
static clone(node) {
|
|
136
|
+
return new HeadingNode(node.__tag, node.__key);
|
|
137
|
+
}
|
|
138
|
+
afterCloneFrom(prevNode) {
|
|
139
|
+
super.afterCloneFrom(prevNode);
|
|
140
|
+
this.__tag = prevNode.__tag;
|
|
141
|
+
}
|
|
142
|
+
constructor(tag = "h1", key) {
|
|
143
|
+
super(key);
|
|
144
|
+
this.__tag = tag;
|
|
145
|
+
}
|
|
146
|
+
getTag() {
|
|
147
|
+
return this.getLatest().__tag;
|
|
148
|
+
}
|
|
149
|
+
setTag(tag) {
|
|
150
|
+
const self = this.getWritable();
|
|
151
|
+
self.__tag = tag;
|
|
152
|
+
return self;
|
|
153
|
+
}
|
|
154
|
+
createDOM(config) {
|
|
155
|
+
const tag = this.__tag;
|
|
156
|
+
const element = document.createElement(tag);
|
|
157
|
+
const classNames = config.theme.heading;
|
|
158
|
+
if (classNames !== void 0) {
|
|
159
|
+
const className = classNames[tag];
|
|
160
|
+
addClassNamesToElement(element, className);
|
|
161
|
+
}
|
|
162
|
+
return element;
|
|
163
|
+
}
|
|
164
|
+
updateDOM(prevNode, dom, config) {
|
|
165
|
+
return prevNode.__tag !== this.__tag;
|
|
166
|
+
}
|
|
167
|
+
static importDOM() {
|
|
168
|
+
return {
|
|
169
|
+
h1: (node) => ({
|
|
170
|
+
conversion: $convertHeadingElement,
|
|
171
|
+
priority: 0
|
|
172
|
+
}),
|
|
173
|
+
h2: (node) => ({
|
|
174
|
+
conversion: $convertHeadingElement,
|
|
175
|
+
priority: 0
|
|
176
|
+
}),
|
|
177
|
+
h3: (node) => ({
|
|
178
|
+
conversion: $convertHeadingElement,
|
|
179
|
+
priority: 0
|
|
180
|
+
}),
|
|
181
|
+
h4: (node) => ({
|
|
182
|
+
conversion: $convertHeadingElement,
|
|
183
|
+
priority: 0
|
|
184
|
+
}),
|
|
185
|
+
h5: (node) => ({
|
|
186
|
+
conversion: $convertHeadingElement,
|
|
187
|
+
priority: 0
|
|
188
|
+
}),
|
|
189
|
+
h6: (node) => ({
|
|
190
|
+
conversion: $convertHeadingElement,
|
|
191
|
+
priority: 0
|
|
192
|
+
}),
|
|
193
|
+
p: (node) => {
|
|
194
|
+
const firstChild = node.firstChild;
|
|
195
|
+
if (firstChild !== null && isGoogleDocsTitle(firstChild)) return {
|
|
196
|
+
conversion: () => ({ node: null }),
|
|
197
|
+
priority: 3
|
|
198
|
+
};
|
|
199
|
+
return null;
|
|
200
|
+
},
|
|
201
|
+
span: (node) => {
|
|
202
|
+
if (isGoogleDocsTitle(node)) return {
|
|
203
|
+
conversion: (domNode) => {
|
|
204
|
+
return { node: $createHeadingNode("h1") };
|
|
205
|
+
},
|
|
206
|
+
priority: 3
|
|
207
|
+
};
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
exportDOM(editor) {
|
|
213
|
+
const { element } = super.exportDOM(editor);
|
|
214
|
+
if (isHTMLElement(element)) {
|
|
215
|
+
if (this.isEmpty()) element.append(document.createElement("br"));
|
|
216
|
+
const formatType = this.getFormatType();
|
|
217
|
+
if (formatType) element.style.textAlign = formatType;
|
|
218
|
+
const direction = this.getDirection();
|
|
219
|
+
if (direction) element.dir = direction;
|
|
220
|
+
}
|
|
221
|
+
return { element };
|
|
222
|
+
}
|
|
223
|
+
static importJSON(serializedNode) {
|
|
224
|
+
return $createHeadingNode(serializedNode.tag).updateFromJSON(serializedNode);
|
|
225
|
+
}
|
|
226
|
+
updateFromJSON(serializedNode) {
|
|
227
|
+
return super.updateFromJSON(serializedNode).setTag(serializedNode.tag);
|
|
228
|
+
}
|
|
229
|
+
exportJSON() {
|
|
230
|
+
return {
|
|
231
|
+
...super.exportJSON(),
|
|
232
|
+
tag: this.getTag()
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
insertNewAfter(selection, restoreSelection = true) {
|
|
236
|
+
const anchorOffet = selection ? selection.anchor.offset : 0;
|
|
237
|
+
const lastDesc = this.getLastDescendant();
|
|
238
|
+
const newElement = !lastDesc || selection && selection.anchor.key === lastDesc.getKey() && anchorOffet === lastDesc.getTextContentSize() || !selection ? $createParagraphNode() : $createHeadingNode(this.getTag());
|
|
239
|
+
const direction = this.getDirection();
|
|
240
|
+
newElement.setDirection(direction);
|
|
241
|
+
this.insertAfter(newElement, restoreSelection);
|
|
242
|
+
if (anchorOffet === 0 && !this.isEmpty() && selection) {
|
|
243
|
+
const paragraph = $createParagraphNode();
|
|
244
|
+
paragraph.select();
|
|
245
|
+
this.replace(paragraph, true);
|
|
246
|
+
}
|
|
247
|
+
return newElement;
|
|
248
|
+
}
|
|
249
|
+
collapseAtStart() {
|
|
250
|
+
const newElement = !this.isEmpty() ? $createHeadingNode(this.getTag()) : $createParagraphNode();
|
|
251
|
+
this.getChildren().forEach((child) => newElement.append(child));
|
|
252
|
+
this.replace(newElement);
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
extractWithChild() {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
function isGoogleDocsTitle(domNode) {
|
|
260
|
+
if (domNode.nodeName.toLowerCase() === "span") return domNode.style.fontSize === "26pt";
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
function $convertHeadingElement(element) {
|
|
264
|
+
const nodeName = element.nodeName.toLowerCase();
|
|
265
|
+
let node = null;
|
|
266
|
+
if (nodeName === "h1" || nodeName === "h2" || nodeName === "h3" || nodeName === "h4" || nodeName === "h5" || nodeName === "h6") {
|
|
267
|
+
node = $createHeadingNode(nodeName);
|
|
268
|
+
if (element.style !== null) {
|
|
269
|
+
setNodeIndentFromDOM(element, node);
|
|
270
|
+
node.setFormat(element.style.textAlign);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return { node };
|
|
274
|
+
}
|
|
275
|
+
function $convertBlockquoteElement(element) {
|
|
276
|
+
const node = $createQuoteNode();
|
|
277
|
+
if (element.style !== null) {
|
|
278
|
+
node.setFormat(element.style.textAlign);
|
|
279
|
+
setNodeIndentFromDOM(element, node);
|
|
280
|
+
}
|
|
281
|
+
return { node };
|
|
282
|
+
}
|
|
283
|
+
function $createHeadingNode(headingTag = "h1") {
|
|
284
|
+
return $applyNodeReplacement(new HeadingNode(headingTag));
|
|
285
|
+
}
|
|
286
|
+
function $isHeadingNode(node) {
|
|
287
|
+
return node instanceof HeadingNode;
|
|
288
|
+
}
|
|
289
|
+
function onPasteForRichText(event, editor) {
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
editor.update(() => {
|
|
292
|
+
const selection = $getSelection();
|
|
293
|
+
const clipboardData = objectKlassEquals(event, InputEvent) || objectKlassEquals(event, KeyboardEvent) ? null : event.clipboardData;
|
|
294
|
+
if (clipboardData != null && selection !== null) $insertDataTransferForRichText(clipboardData, selection, editor);
|
|
295
|
+
}, { tag: PASTE_TAG });
|
|
296
|
+
}
|
|
297
|
+
async function onCutForRichText(event, editor) {
|
|
298
|
+
await copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null);
|
|
299
|
+
editor.update(() => {
|
|
300
|
+
const selection = $getSelection();
|
|
301
|
+
if ($isRangeSelection(selection)) selection.removeText();
|
|
302
|
+
else if ($isNodeSelection(selection)) selection.getNodes().forEach((node) => node.remove());
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function eventFiles(event) {
|
|
306
|
+
let dataTransfer = null;
|
|
307
|
+
if (objectKlassEquals(event, DragEvent)) dataTransfer = event.dataTransfer;
|
|
308
|
+
else if (objectKlassEquals(event, ClipboardEvent)) dataTransfer = event.clipboardData;
|
|
309
|
+
if (dataTransfer === null) return [
|
|
310
|
+
false,
|
|
311
|
+
[],
|
|
312
|
+
false
|
|
313
|
+
];
|
|
314
|
+
const types = dataTransfer.types;
|
|
315
|
+
const hasFiles = types.includes("Files");
|
|
316
|
+
const hasContent = types.includes("text/html") || types.includes("text/plain");
|
|
317
|
+
return [
|
|
318
|
+
hasFiles,
|
|
319
|
+
Array.from(dataTransfer.files),
|
|
320
|
+
hasContent
|
|
321
|
+
];
|
|
322
|
+
}
|
|
323
|
+
function $isTargetWithinDecorator(target) {
|
|
324
|
+
return $isDecoratorNode($getNearestNodeFromDOMNode(target));
|
|
325
|
+
}
|
|
326
|
+
function $isSelectionAtEndOfRoot(selection) {
|
|
327
|
+
const focus = selection.focus;
|
|
328
|
+
return focus.key === "root" && focus.offset === $getRoot().getChildrenSize();
|
|
329
|
+
}
|
|
330
|
+
function $isSelectionCollapsedAtFrontOfIndentedBlock(selection) {
|
|
331
|
+
if (!selection.isCollapsed()) return false;
|
|
332
|
+
const { anchor } = selection;
|
|
333
|
+
if (anchor.offset !== 0) return false;
|
|
334
|
+
const anchorNode = anchor.getNode();
|
|
335
|
+
if ($isRootNode(anchorNode)) return false;
|
|
336
|
+
const element = $getNearestBlockElementAncestorOrThrow(anchorNode);
|
|
337
|
+
return element.getIndent() > 0 && (element.is(anchorNode) || anchorNode.is(element.getFirstDescendant()));
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Resets the capitalization of the selection to default.
|
|
341
|
+
* Called when the user presses space, tab, or enter key.
|
|
342
|
+
* @param selection The selection to reset the capitalization of.
|
|
343
|
+
*/
|
|
344
|
+
function $resetCapitalization(selection) {
|
|
345
|
+
for (const format of [
|
|
346
|
+
"lowercase",
|
|
347
|
+
"uppercase",
|
|
348
|
+
"capitalize"
|
|
349
|
+
]) if (selection.hasFormat(format)) selection.toggleFormat(format);
|
|
350
|
+
}
|
|
351
|
+
function registerRichText(editor) {
|
|
352
|
+
return mergeRegister(editor.registerCommand(CLICK_COMMAND, (payload) => {
|
|
353
|
+
const selection = $getSelection();
|
|
354
|
+
if ($isNodeSelection(selection)) {
|
|
355
|
+
selection.clear();
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
359
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DELETE_CHARACTER_COMMAND, (isBackward) => {
|
|
360
|
+
const selection = $getSelection();
|
|
361
|
+
if ($isRangeSelection(selection)) {
|
|
362
|
+
selection.deleteCharacter(isBackward);
|
|
363
|
+
return true;
|
|
364
|
+
} else if ($isNodeSelection(selection)) {
|
|
365
|
+
selection.deleteNodes();
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
return false;
|
|
369
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DELETE_WORD_COMMAND, (isBackward) => {
|
|
370
|
+
const selection = $getSelection();
|
|
371
|
+
if (!$isRangeSelection(selection)) return false;
|
|
372
|
+
selection.deleteWord(isBackward);
|
|
373
|
+
return true;
|
|
374
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DELETE_LINE_COMMAND, (isBackward) => {
|
|
375
|
+
const selection = $getSelection();
|
|
376
|
+
if (!$isRangeSelection(selection)) return false;
|
|
377
|
+
selection.deleteLine(isBackward);
|
|
378
|
+
return true;
|
|
379
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND, (eventOrText) => {
|
|
380
|
+
const selection = $getSelection();
|
|
381
|
+
if (typeof eventOrText === "string") {
|
|
382
|
+
if (selection !== null) selection.insertText(eventOrText);
|
|
383
|
+
} else {
|
|
384
|
+
if (selection === null) return false;
|
|
385
|
+
const dataTransfer = eventOrText.dataTransfer;
|
|
386
|
+
if (dataTransfer != null) $insertDataTransferForRichText(dataTransfer, selection, editor);
|
|
387
|
+
else if ($isRangeSelection(selection)) {
|
|
388
|
+
const data = eventOrText.data;
|
|
389
|
+
if (data) selection.insertText(data);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return true;
|
|
394
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(REMOVE_TEXT_COMMAND, () => {
|
|
395
|
+
const selection = $getSelection();
|
|
396
|
+
if (!$isRangeSelection(selection)) return false;
|
|
397
|
+
selection.removeText();
|
|
398
|
+
return true;
|
|
399
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(FORMAT_TEXT_COMMAND, (format) => {
|
|
400
|
+
const selection = $getSelection();
|
|
401
|
+
if (!$isRangeSelection(selection)) return false;
|
|
402
|
+
selection.formatText(format);
|
|
403
|
+
return true;
|
|
404
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(FORMAT_ELEMENT_COMMAND, (format) => {
|
|
405
|
+
const selection = $getSelection();
|
|
406
|
+
if (!$isRangeSelection(selection) && !$isNodeSelection(selection)) return false;
|
|
407
|
+
const nodes = selection.getNodes();
|
|
408
|
+
for (const node of nodes) {
|
|
409
|
+
const element = $findMatchingParent(node, (parentNode) => $isElementNode(parentNode) && !parentNode.isInline());
|
|
410
|
+
if (element !== null) element.setFormat(format);
|
|
411
|
+
}
|
|
412
|
+
return true;
|
|
413
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(INSERT_LINE_BREAK_COMMAND, (selectStart) => {
|
|
414
|
+
const selection = $getSelection();
|
|
415
|
+
if (!$isRangeSelection(selection)) return false;
|
|
416
|
+
selection.insertLineBreak(selectStart);
|
|
417
|
+
return true;
|
|
418
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(INSERT_PARAGRAPH_COMMAND, () => {
|
|
419
|
+
const selection = $getSelection();
|
|
420
|
+
if (!$isRangeSelection(selection)) return false;
|
|
421
|
+
selection.insertParagraph();
|
|
422
|
+
return true;
|
|
423
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(INSERT_TAB_COMMAND, () => {
|
|
424
|
+
const tabNode = $createTabNode();
|
|
425
|
+
const selection = $getSelection();
|
|
426
|
+
if ($isRangeSelection(selection)) {
|
|
427
|
+
tabNode.setFormat(selection.format);
|
|
428
|
+
tabNode.setStyle(selection.style);
|
|
429
|
+
}
|
|
430
|
+
$insertNodes([tabNode]);
|
|
431
|
+
return true;
|
|
432
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(INDENT_CONTENT_COMMAND, () => {
|
|
433
|
+
return $handleIndentAndOutdent((block) => {
|
|
434
|
+
const indent = block.getIndent();
|
|
435
|
+
block.setIndent(indent + 1);
|
|
436
|
+
});
|
|
437
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(OUTDENT_CONTENT_COMMAND, () => {
|
|
438
|
+
return $handleIndentAndOutdent((block) => {
|
|
439
|
+
const indent = block.getIndent();
|
|
440
|
+
if (indent > 0) block.setIndent(Math.max(0, indent - 1));
|
|
441
|
+
});
|
|
442
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ARROW_UP_COMMAND, (event) => {
|
|
443
|
+
const selection = $getSelection();
|
|
444
|
+
if ($isNodeSelection(selection)) {
|
|
445
|
+
const nodes = selection.getNodes();
|
|
446
|
+
if (nodes.length > 0) {
|
|
447
|
+
event.preventDefault();
|
|
448
|
+
nodes[0].selectPrevious();
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
} else if ($isRangeSelection(selection)) {
|
|
452
|
+
const possibleNode = $getAdjacentNode(selection.focus, true);
|
|
453
|
+
if (!event.shiftKey && $isDecoratorNode(possibleNode) && !possibleNode.isIsolated() && !possibleNode.isInline()) {
|
|
454
|
+
possibleNode.selectPrevious();
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return false;
|
|
460
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ARROW_DOWN_COMMAND, (event) => {
|
|
461
|
+
const selection = $getSelection();
|
|
462
|
+
if ($isNodeSelection(selection)) {
|
|
463
|
+
const nodes = selection.getNodes();
|
|
464
|
+
if (nodes.length > 0) {
|
|
465
|
+
event.preventDefault();
|
|
466
|
+
nodes[0].selectNext(0, 0);
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
} else if ($isRangeSelection(selection)) {
|
|
470
|
+
if ($isSelectionAtEndOfRoot(selection)) {
|
|
471
|
+
event.preventDefault();
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
474
|
+
const possibleNode = $getAdjacentNode(selection.focus, false);
|
|
475
|
+
if (!event.shiftKey && $isDecoratorNode(possibleNode) && !possibleNode.isIsolated() && !possibleNode.isInline()) {
|
|
476
|
+
possibleNode.selectNext();
|
|
477
|
+
event.preventDefault();
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return false;
|
|
482
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ARROW_LEFT_COMMAND, (event) => {
|
|
483
|
+
const selection = $getSelection();
|
|
484
|
+
if ($isNodeSelection(selection)) {
|
|
485
|
+
const nodes = selection.getNodes();
|
|
486
|
+
if (nodes.length > 0) {
|
|
487
|
+
event.preventDefault();
|
|
488
|
+
if ($isParentRTL(nodes[0])) nodes[0].selectNext(0, 0);
|
|
489
|
+
else nodes[0].selectPrevious();
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (!$isRangeSelection(selection)) return false;
|
|
494
|
+
if ($shouldOverrideDefaultCharacterSelection(selection, true)) {
|
|
495
|
+
const isHoldingShift = event.shiftKey;
|
|
496
|
+
event.preventDefault();
|
|
497
|
+
$moveCharacter(selection, isHoldingShift, true);
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
return false;
|
|
501
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ARROW_RIGHT_COMMAND, (event) => {
|
|
502
|
+
const selection = $getSelection();
|
|
503
|
+
if ($isNodeSelection(selection)) {
|
|
504
|
+
const nodes = selection.getNodes();
|
|
505
|
+
if (nodes.length > 0) {
|
|
506
|
+
event.preventDefault();
|
|
507
|
+
if ($isParentRTL(nodes[0])) nodes[0].selectPrevious();
|
|
508
|
+
else nodes[0].selectNext(0, 0);
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (!$isRangeSelection(selection)) return false;
|
|
513
|
+
const isHoldingShift = event.shiftKey;
|
|
514
|
+
if ($shouldOverrideDefaultCharacterSelection(selection, false)) {
|
|
515
|
+
event.preventDefault();
|
|
516
|
+
$moveCharacter(selection, isHoldingShift, false);
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_BACKSPACE_COMMAND, (event) => {
|
|
521
|
+
if ($isTargetWithinDecorator(event.target)) return false;
|
|
522
|
+
const selection = $getSelection();
|
|
523
|
+
if ($isRangeSelection(selection)) {
|
|
524
|
+
if ($isSelectionCollapsedAtFrontOfIndentedBlock(selection)) {
|
|
525
|
+
event.preventDefault();
|
|
526
|
+
return editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, void 0);
|
|
527
|
+
}
|
|
528
|
+
if (IS_IOS && navigator.language === "ko-KR") return false;
|
|
529
|
+
} else if (!$isNodeSelection(selection)) return false;
|
|
530
|
+
event.preventDefault();
|
|
531
|
+
return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true);
|
|
532
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_DELETE_COMMAND, (event) => {
|
|
533
|
+
if ($isTargetWithinDecorator(event.target)) return false;
|
|
534
|
+
const selection = $getSelection();
|
|
535
|
+
if (!($isRangeSelection(selection) || $isNodeSelection(selection))) return false;
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, false);
|
|
538
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ENTER_COMMAND, (event) => {
|
|
539
|
+
const selection = $getSelection();
|
|
540
|
+
if (!$isRangeSelection(selection)) return false;
|
|
541
|
+
$resetCapitalization(selection);
|
|
542
|
+
if (event !== null) {
|
|
543
|
+
if ((IS_IOS || IS_SAFARI || IS_APPLE_WEBKIT) && CAN_USE_BEFORE_INPUT) return false;
|
|
544
|
+
event.preventDefault();
|
|
545
|
+
if (event.shiftKey) return editor.dispatchCommand(INSERT_LINE_BREAK_COMMAND, false);
|
|
546
|
+
}
|
|
547
|
+
return editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, void 0);
|
|
548
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ESCAPE_COMMAND, () => {
|
|
549
|
+
if (!$isRangeSelection($getSelection())) return false;
|
|
550
|
+
editor.blur();
|
|
551
|
+
return true;
|
|
552
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DROP_COMMAND, (event) => {
|
|
553
|
+
const [, files] = eventFiles(event);
|
|
554
|
+
if (files.length > 0) {
|
|
555
|
+
const x = event.clientX;
|
|
556
|
+
const y = event.clientY;
|
|
557
|
+
const eventRange = caretFromPoint(x, y);
|
|
558
|
+
if (eventRange !== null) {
|
|
559
|
+
const { offset: domOffset, node: domNode } = eventRange;
|
|
560
|
+
const node = $getNearestNodeFromDOMNode(domNode);
|
|
561
|
+
if (node !== null) {
|
|
562
|
+
const selection = $createRangeSelection();
|
|
563
|
+
if ($isTextNode(node)) {
|
|
564
|
+
selection.anchor.set(node.getKey(), domOffset, "text");
|
|
565
|
+
selection.focus.set(node.getKey(), domOffset, "text");
|
|
566
|
+
} else {
|
|
567
|
+
const parentKey = node.getParentOrThrow().getKey();
|
|
568
|
+
const offset = node.getIndexWithinParent() + 1;
|
|
569
|
+
selection.anchor.set(parentKey, offset, "element");
|
|
570
|
+
selection.focus.set(parentKey, offset, "element");
|
|
571
|
+
}
|
|
572
|
+
$setSelection($normalizeSelection__EXPERIMENTAL(selection));
|
|
573
|
+
}
|
|
574
|
+
editor.dispatchCommand(DRAG_DROP_PASTE, files);
|
|
575
|
+
}
|
|
576
|
+
event.preventDefault();
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
return $handleRichTextDrop(event, editor);
|
|
580
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DRAGSTART_COMMAND, (event) => {
|
|
581
|
+
const [isFileTransfer] = eventFiles(event);
|
|
582
|
+
const selection = $getSelection();
|
|
583
|
+
if (isFileTransfer && !$isRangeSelection(selection)) return false;
|
|
584
|
+
if ($isRangeSelection(selection) && !selection.isCollapsed() && event.dataTransfer !== null) {
|
|
585
|
+
setLexicalClipboardDataTransfer(event.dataTransfer, $getClipboardDataFromSelection(selection));
|
|
586
|
+
$writeDragSourceToDataTransfer(event.dataTransfer, editor);
|
|
587
|
+
}
|
|
588
|
+
return true;
|
|
589
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DRAGOVER_COMMAND, (event) => {
|
|
590
|
+
const [isFileTransfer] = eventFiles(event);
|
|
591
|
+
const selection = $getSelection();
|
|
592
|
+
if (isFileTransfer && !$isRangeSelection(selection)) return false;
|
|
593
|
+
const x = event.clientX;
|
|
594
|
+
const y = event.clientY;
|
|
595
|
+
const eventRange = caretFromPoint(x, y);
|
|
596
|
+
if (eventRange !== null) {
|
|
597
|
+
if ($isDecoratorNode($getNearestNodeFromDOMNode(eventRange.node))) event.preventDefault();
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(SELECT_ALL_COMMAND, () => {
|
|
601
|
+
$selectAll();
|
|
602
|
+
return true;
|
|
603
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(COPY_COMMAND, (event) => {
|
|
604
|
+
copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null);
|
|
605
|
+
return true;
|
|
606
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(CUT_COMMAND, (event) => {
|
|
607
|
+
onCutForRichText(event, editor);
|
|
608
|
+
return true;
|
|
609
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(PASTE_COMMAND, (event) => {
|
|
610
|
+
const [, files, hasTextContent] = eventFiles(event);
|
|
611
|
+
if (files.length > 0 && !hasTextContent) {
|
|
612
|
+
editor.dispatchCommand(DRAG_DROP_PASTE, files);
|
|
613
|
+
return true;
|
|
614
|
+
}
|
|
615
|
+
if (isDOMNode(event.target) && isSelectionCapturedInDecoratorInput(event.target)) return false;
|
|
616
|
+
if ($getSelection() !== null) {
|
|
617
|
+
onPasteForRichText(event, editor);
|
|
618
|
+
return true;
|
|
619
|
+
}
|
|
620
|
+
return false;
|
|
621
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_SPACE_COMMAND, (_) => {
|
|
622
|
+
const selection = $getSelection();
|
|
623
|
+
if ($isRangeSelection(selection)) $resetCapitalization(selection);
|
|
624
|
+
return false;
|
|
625
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_TAB_COMMAND, (_) => {
|
|
626
|
+
const selection = $getSelection();
|
|
627
|
+
if ($isRangeSelection(selection)) $resetCapitalization(selection);
|
|
628
|
+
return false;
|
|
629
|
+
}, COMMAND_PRIORITY_EDITOR));
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* An extension to register \@lexical/rich-text behavior and nodes
|
|
633
|
+
* ({@link HeadingNode}, {@link QuoteNode})
|
|
634
|
+
*/
|
|
635
|
+
const RichTextExtension = defineExtension({
|
|
636
|
+
conflictsWith: ["@lexical/plain-text"],
|
|
637
|
+
dependencies: [DragonExtension],
|
|
638
|
+
name: "@lexical/rich-text",
|
|
639
|
+
nodes: () => [HeadingNode, QuoteNode],
|
|
640
|
+
register: registerRichText
|
|
641
|
+
});
|
|
642
|
+
//#endregion
|
|
643
|
+
export { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, DRAG_DROP_PASTE, HeadingNode, QuoteNode, RichTextExtension, eventFiles, registerRichText };
|
|
644
|
+
|
|
645
|
+
//# sourceMappingURL=LexicalRichText.dev-CrSqq3K-.mjs.map
|