@mx-space/cli 0.14.1 → 0.15.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/README.md +35 -11
- package/dist/{Lexical.dev-DTxuYHmG.mjs → Lexical.dev-Cck4n26y.mjs} +998 -584
- package/dist/{Lexical.node-BlCLnfA6.mjs → Lexical.node-D6wf2D5M.mjs} +15 -5
- package/dist/Lexical.prod-DCwS1oTq.mjs +7170 -0
- package/dist/{LexicalClipboard.dev-CdFkLR_D.mjs → LexicalClipboard.dev-CMkPHV7O.mjs} +6 -6
- package/dist/{LexicalClipboard.node-ktUajxsv.mjs → LexicalClipboard.node-m4nZ7IYw.mjs} +2 -2
- package/dist/{LexicalClipboard.prod-DliyLofW.mjs → LexicalClipboard.prod-B_rN1vE1.mjs} +10 -8
- package/dist/{LexicalCodeCore.dev-CL9tHWJX.mjs → LexicalCodeCore.dev-DyJw3i8V.mjs} +62 -72
- package/dist/{LexicalCodeCore.prod-BoMSJc29.mjs → LexicalCodeCore.prod-DPXLHQLF.mjs} +212 -213
- package/dist/{LexicalDragon.dev-CqW7Aq5H.mjs → LexicalDragon.dev-ZkNfMwrE.mjs} +3 -3
- package/dist/{LexicalDragon.node-DLXctJyy.mjs → LexicalDragon.node-Ds9oLUFh.mjs} +2 -2
- package/dist/{LexicalDragon.prod-DHI3T6n5.mjs → LexicalDragon.prod-B58ic2av.mjs} +5 -4
- package/dist/{LexicalExtension.dev-BP-18zns.mjs → LexicalExtension.dev-DvwHs1Xv.mjs} +79 -67
- package/dist/{LexicalExtension.node-BWH6xbzG.mjs → LexicalExtension.node-5OymZQfy.mjs} +4 -2
- package/dist/{LexicalExtension.prod-Cs6OgrDn.mjs → LexicalExtension.prod-Ce0T5smQ.mjs} +372 -358
- package/dist/{LexicalHeadless.dev-DJp__UcP.mjs → LexicalHeadless.dev-DA0WldSR.mjs} +2 -2
- package/dist/{LexicalHeadless.prod-o0v9cIu5.mjs → LexicalHeadless.prod-1kQgKB6c.mjs} +2 -2
- package/dist/{LexicalHtml.dev-DoymwFpG.mjs → LexicalHtml.dev-BDB7CUrx.mjs} +14 -12
- package/dist/{LexicalHtml.node-CVkbWtUA.mjs → LexicalHtml.node-DpVNt7It.mjs} +4 -4
- package/dist/{LexicalHtml.prod-C2b3z99k.mjs → LexicalHtml.prod-HkxM5scw.mjs} +331 -300
- package/dist/{LexicalLink.dev-7cgLOLIe.mjs → LexicalLink.dev-C5zNJlrm.mjs} +65 -59
- package/dist/{LexicalLink.prod-DWFgoXHR.mjs → LexicalLink.prod-Bkt9hQAt.mjs} +196 -201
- package/dist/{LexicalList.dev-Ci2iOxFx.mjs → LexicalList.dev-B7VgME-m.mjs} +55 -82
- package/dist/LexicalList.prod-B8c7TDjH.mjs +951 -0
- package/dist/{LexicalMarkdown.dev-C0ZYCyuR.mjs → LexicalMarkdown.dev-B5z9kLbV.mjs} +62 -42
- package/dist/{LexicalMarkdown.prod-0M-Nc-rh.mjs → LexicalMarkdown.prod-wKzw7FFH.mjs} +255 -202
- package/dist/{LexicalRichText.dev-Cnr1kDym.mjs → LexicalRichText.dev-CUd6Li5F.mjs} +399 -120
- package/dist/{LexicalRichText.node-BUJZAiap.mjs → LexicalRichText.node-BKfaQ-CH.mjs} +12 -8
- package/dist/LexicalRichText.prod-SBewjJHx.mjs +708 -0
- package/dist/{LexicalSelection.dev-C4L7l8OB.mjs → LexicalSelection.dev-D27JOCqj.mjs} +48 -17
- package/dist/{LexicalSelection.node-CLKroUMQ.mjs → LexicalSelection.node-DBEwPjBu.mjs} +5 -4
- package/dist/{LexicalSelection.prod-DzFqpTlw.mjs → LexicalSelection.prod-OaYhXHOL.mjs} +101 -92
- package/dist/{LexicalTable.dev-Cc9-zqKa.mjs → LexicalTable.dev-6IFFOAE0.mjs} +590 -259
- package/dist/LexicalTable.prod-2CaLZ7fH.mjs +2524 -0
- package/dist/{LexicalUtils.dev-BRgK0L6G.mjs → LexicalUtils.dev-DJA7J_7v.mjs} +15 -19
- package/dist/{LexicalUtils.node-BVAwOkL4.mjs → LexicalUtils.node-Df9oPTlA.mjs} +6 -6
- package/dist/{LexicalUtils.prod-C1gtvVDP.mjs → LexicalUtils.prod-Bb7V4Ewg.mjs} +155 -159
- package/dist/bin/mxs.mjs +1 -1
- package/dist/esm-CDcJmHkG.mjs +2 -0
- package/dist/{esm-BNu4sUWV.mjs → esm-DLzrv7gD.mjs} +1837 -6015
- package/dist/index.d.mts +57 -62
- package/dist/index.mjs +1 -1
- package/dist/{mxs-CMX2yklg.mjs → mxs-BIRW5Axj.mjs} +13579 -8682
- package/dist/rolldown-runtime-JspESFgx.mjs +35 -0
- package/dist/vendor/litexml/cli.mjs +7043 -6207
- package/dist/vendor/litexml/litexml-html-preview-client.css +80 -47
- package/dist/vendor/litexml/litexml-html-preview-client.js +14422 -10838
- package/dist/vendor/litexml/style.css +6 -2
- package/package.json +23 -23
- package/skills/commands-ai.md +45 -12
- package/skills/overview.md +1 -1
- package/dist/Lexical.prod-CeB9UQuo.mjs +0 -6816
- package/dist/LexicalList.prod-D0xX5d3G.mjs +0 -944
- package/dist/LexicalRichText.prod-BfbMQ9uM.mjs +0 -538
- package/dist/LexicalTable.prod-BgO4nCxy.mjs +0 -2336
- package/dist/esm-jbwcVZth.mjs +0 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { f as namedSignals, l as effect, o as NormalizeInlineElementsExtension, p as signal, s as NormalizeTripleClickSelectionExtension } from "./LexicalExtension.node-
|
|
2
|
-
import { $
|
|
3
|
-
import { c as
|
|
4
|
-
import { i as $shouldOverrideDefaultCharacterSelection, n as $isParentRTL, r as $moveCharacter } from "./LexicalSelection.node-
|
|
5
|
-
import { a as $handleIndentAndOutdent,
|
|
6
|
-
import { a as caretFromPoint, i as $writeDragSourceToDataTransfer, n as $handleRichTextDrop, o as copyToClipboard, r as $insertDataTransferForRichText, s as setLexicalClipboardDataTransfer, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-
|
|
7
|
-
import { t as DragonExtension } from "./LexicalDragon.node-
|
|
8
|
-
//#region ../../node_modules/.pnpm/@lexical+rich-text@0.
|
|
1
|
+
import { f as namedSignals, l as effect, o as NormalizeInlineElementsExtension, p as signal, s as NormalizeTripleClickSelectionExtension } from "./LexicalExtension.node-5OymZQfy.mjs";
|
|
2
|
+
import { $ as $hasAncestor, $r as isHTMLElement, A as $getChildCaret, An as IS_APPLE_WEBKIT, Cn as INSERT_LINE_BREAK_COMMAND, Cr as createState, D as $getCaretRange, Dt as $normalizeSelection__EXPERIMENTAL, Et as $normalizeCaret, Ft as $setSelection, G as $getSelection, Gn as KEY_ARROW_RIGHT_COMMAND, I as $getDocument, In as IS_IOS, It as $setSelectionFromCaretRange, J as $getSlotFrame, Jn as KEY_DELETE_COMMAND, K as $getSiblingCaret, Kn as KEY_ARROW_UP_COMMAND, Kt as CLICK_COMMAND, L as $getEditor, Lt as $setState, Mt as $setDirectionFromDOM, N as $getCollapsedCaretRange, Nt as $setFormatFromDOM, Qn as KEY_TAB_COMMAND, Rn as IS_SAFARI, Rt as $setTextFormat, Sn as INDENT_CONTENT_COMMAND, St as $isTextNode, Tn as INSERT_TAB_COMMAND, Tr as defineExtension, Tt as $needsBlockCursorBeside, Un as KEY_ARROW_DOWN_COMMAND, Ut as CAN_USE_BEFORE_INPUT, W as $getRoot, Wn as KEY_ARROW_LEFT_COMMAND, Xn as KEY_ESCAPE_COMMAND, Yn as KEY_ENTER_COMMAND, Z as $getState, Zn as KEY_SPACE_COMMAND, Zt as COMMAND_PRIORITY_EDITOR, _ as $createTabNode, _i as shallowMergeConfig, _n as FORMAT_ELEMENT_COMMAND, _t as $isSelectionCapturedInDecoratorInput, an as CUT_COMMAND, b as $findMatchingParent, br as configExtension, c as $comparePointCaretNext, ci as mergeRegister, cn as DELETE_CHARACTER_COMMAND, dn as DRAGOVER_COMMAND, dr as SET_TEXT_FORMAT_COMMAND, er as MOVE_TO_END, f as $createNodeSelection, fn as DRAGSTART_COMMAND, ft as $isNodeSelection, gi as setNodeIndentFromDOM, gt as $isRootOrShadowRoot, h as $createRangeSelection, hn as ElementNode, ht as $isRootNode, i as $caretFromPoint, in as COPY_COMMAND, ir as PASTE_TAG, it as $isDecoratorNode, jr as getDOMSelection, jt as $selectAll, ln as DELETE_LINE_COMMAND, mt as $isRangeSelection, n as $applyNodeReplacement, nr as OUTDENT_CONTENT_COMMAND, on as CUT_TAG, or as REMOVE_TEXT_COMMAND, ot as $isElementNode, p as $createParagraphNode, pi as safeCast, pn as DROP_COMMAND, qn as KEY_BACKSPACE_COMMAND, qr as isDOMNode, rn as CONTROLLED_TEXT_INSERTION_COMMAND, rr as PASTE_COMMAND, tr as MOVE_TO_START, tt as $insertNodes, un as DELETE_WORD_COMMAND, ur as SELECT_ALL_COMMAND, vn as FORMAT_TEXT_COMMAND, vr as addClassNamesToElement, vt as $isShadowRootNode, wn as INSERT_PARAGRAPH_COMMAND, x as $formatText, xr as createCommand, y as $extendCaretToRange, yt as $isSiblingCaret, z as $getNearestNodeFromDOMNode } from "./Lexical.node-D6wf2D5M.mjs";
|
|
3
|
+
import { c as CoreImportExtension, g as defineImportRule, l as DOMImportExtension, s as BlockSchema, y as sel } from "./LexicalHtml.node-DpVNt7It.mjs";
|
|
4
|
+
import { i as $shouldOverrideDefaultCharacterSelection, n as $isParentRTL, r as $moveCharacter } from "./LexicalSelection.node-DBEwPjBu.mjs";
|
|
5
|
+
import { a as $handleIndentAndOutdent, m as objectKlassEquals, p as eventFiles, r as $getNearestBlockElementAncestorOrThrow } from "./LexicalUtils.node-Df9oPTlA.mjs";
|
|
6
|
+
import { a as caretFromPoint, i as $writeDragSourceToDataTransfer, n as $handleRichTextDrop, o as copyToClipboard, r as $insertDataTransferForRichText, s as setLexicalClipboardDataTransfer, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-m4nZ7IYw.mjs";
|
|
7
|
+
import { t as DragonExtension } from "./LexicalDragon.node-Ds9oLUFh.mjs";
|
|
8
|
+
//#region ../../node_modules/.pnpm/@lexical+rich-text@0.49.0_typescript@6.0.3/node_modules/@lexical/rich-text/dist/LexicalRichText.dev.mjs
|
|
9
9
|
/**
|
|
10
10
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
11
|
*
|
|
@@ -29,6 +29,58 @@ import { t as DragonExtension } from "./LexicalDragon.node-DLXctJyy.mjs";
|
|
|
29
29
|
function isGoogleDocsTitleSpan(node) {
|
|
30
30
|
return isHTMLElement(node) && node.nodeName === "SPAN" && node.style.fontSize === "26pt";
|
|
31
31
|
}
|
|
32
|
+
const HeadingRule = /* @__PURE__ */ defineImportRule({
|
|
33
|
+
$import: (ctx, el) => {
|
|
34
|
+
const node = $createHeadingNode(el.nodeName.toLowerCase());
|
|
35
|
+
setNodeIndentFromDOM(el, node);
|
|
36
|
+
$setFormatFromDOM(node, el);
|
|
37
|
+
$setDirectionFromDOM(node, el);
|
|
38
|
+
return [node.splice(0, 0, ctx.$importChildren(el))];
|
|
39
|
+
},
|
|
40
|
+
match: sel.tag("h1", "h2", "h3", "h4", "h5", "h6"),
|
|
41
|
+
name: "@lexical/rich-text/heading"
|
|
42
|
+
});
|
|
43
|
+
const QuoteRule = /* @__PURE__ */ defineImportRule({
|
|
44
|
+
$import: (ctx, el) => {
|
|
45
|
+
const node = $createQuoteNode();
|
|
46
|
+
$setFormatFromDOM(node, el);
|
|
47
|
+
setNodeIndentFromDOM(el, node);
|
|
48
|
+
$setDirectionFromDOM(node, el);
|
|
49
|
+
return [node.splice(0, 0, ctx.$importChildren(el))];
|
|
50
|
+
},
|
|
51
|
+
match: sel.tag("blockquote"),
|
|
52
|
+
name: "@lexical/rich-text/blockquote"
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Opt-in replacement for the default `<blockquote>` rule that imports the
|
|
56
|
+
* quote as a shadow root {@link QuoteNode} (see `quoteShadowRootState`).
|
|
57
|
+
* Block-level children such as `<p>` are preserved as blocks and runs of
|
|
58
|
+
* inline content are wrapped in paragraphs (`BlockSchema`), so structured
|
|
59
|
+
* blockquote HTML round-trips faithfully instead of being flattened to
|
|
60
|
+
* inline content.
|
|
61
|
+
*
|
|
62
|
+
* Not part of {@link RichTextImportRules}; without it `<blockquote>`
|
|
63
|
+
* import behavior is unchanged. To opt in, register it with a higher
|
|
64
|
+
* priority than the default rules, e.g.:
|
|
65
|
+
* ```ts
|
|
66
|
+
* configExtension(DOMImportExtension, {rules: [ShadowRootQuoteRule]})
|
|
67
|
+
* ```
|
|
68
|
+
* (rules from later configuration take priority, so this shadows the
|
|
69
|
+
* default `@lexical/rich-text/blockquote` rule).
|
|
70
|
+
*
|
|
71
|
+
* @experimental
|
|
72
|
+
*/
|
|
73
|
+
const ShadowRootQuoteRule = /* @__PURE__ */ defineImportRule({
|
|
74
|
+
$import: (ctx, el) => {
|
|
75
|
+
const node = $createQuoteNode({ shadowRoot: true });
|
|
76
|
+
$setFormatFromDOM(node, el);
|
|
77
|
+
setNodeIndentFromDOM(el, node);
|
|
78
|
+
$setDirectionFromDOM(node, el);
|
|
79
|
+
return [node.splice(0, 0, ctx.$importChildren(el, { schema: BlockSchema }))];
|
|
80
|
+
},
|
|
81
|
+
match: sel.tag("blockquote"),
|
|
82
|
+
name: "@lexical/rich-text/blockquote-shadow-root"
|
|
83
|
+
});
|
|
32
84
|
/**
|
|
33
85
|
* Import rules for {@link HeadingNode} and {@link QuoteNode}, including
|
|
34
86
|
* the Google Docs title heuristic that the legacy `HeadingNode.importDOM`
|
|
@@ -44,28 +96,8 @@ function isGoogleDocsTitleSpan(node) {
|
|
|
44
96
|
* @experimental
|
|
45
97
|
*/
|
|
46
98
|
const RichTextImportRules = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const node = $createHeadingNode(el.nodeName.toLowerCase());
|
|
50
|
-
setNodeIndentFromDOM(el, node);
|
|
51
|
-
$setFormatFromDOM(node, el);
|
|
52
|
-
$setDirectionFromDOM(node, el);
|
|
53
|
-
return [node.splice(0, 0, ctx.$importChildren(el))];
|
|
54
|
-
},
|
|
55
|
-
match: sel.tag("h1", "h2", "h3", "h4", "h5", "h6"),
|
|
56
|
-
name: "@lexical/rich-text/heading"
|
|
57
|
-
}),
|
|
58
|
-
/* @__PURE__ */ defineImportRule({
|
|
59
|
-
$import: (ctx, el) => {
|
|
60
|
-
const node = $createQuoteNode();
|
|
61
|
-
$setFormatFromDOM(node, el);
|
|
62
|
-
setNodeIndentFromDOM(el, node);
|
|
63
|
-
$setDirectionFromDOM(node, el);
|
|
64
|
-
return [node.splice(0, 0, ctx.$importChildren(el))];
|
|
65
|
-
},
|
|
66
|
-
match: sel.tag("blockquote"),
|
|
67
|
-
name: "@lexical/rich-text/blockquote"
|
|
68
|
-
}),
|
|
99
|
+
HeadingRule,
|
|
100
|
+
QuoteRule,
|
|
69
101
|
/* @__PURE__ */ defineImportRule({
|
|
70
102
|
$import: (ctx, el, $next) => {
|
|
71
103
|
const first = el.firstChild;
|
|
@@ -181,32 +213,61 @@ const RichTextImportExtension = /* @__PURE__ */ defineExtension({
|
|
|
181
213
|
*
|
|
182
214
|
*/
|
|
183
215
|
const DRAG_DROP_PASTE = /* @__PURE__ */ createCommand("DRAG_DROP_PASTE_FILE");
|
|
216
|
+
/**
|
|
217
|
+
* Opt-in state for {@link QuoteNode.isShadowRoot}. When `true`, the quote
|
|
218
|
+
* behaves like a multi-block region (similar to a table cell): it holds
|
|
219
|
+
* block-level children (paragraphs, headings, ...) instead of inline
|
|
220
|
+
* content, which allows more faithful HTML and Markdown import/export of
|
|
221
|
+
* `<blockquote>` content. Defaults to `false`, in which case there is no
|
|
222
|
+
* change to the legacy behavior (and nothing extra is serialized).
|
|
223
|
+
*/
|
|
224
|
+
const quoteShadowRootState = /* @__PURE__ */ createState("shadowRoot", { parse: Boolean });
|
|
184
225
|
/** @noInheritDoc */
|
|
185
|
-
var QuoteNode = class
|
|
186
|
-
|
|
187
|
-
return "quote"
|
|
226
|
+
var QuoteNode = class extends ElementNode {
|
|
227
|
+
$config() {
|
|
228
|
+
return this.config("quote", {
|
|
229
|
+
extends: ElementNode,
|
|
230
|
+
importDOM: { blockquote: () => ({
|
|
231
|
+
conversion: $convertBlockquoteElement,
|
|
232
|
+
priority: 0
|
|
233
|
+
}) },
|
|
234
|
+
stateConfigs: [{
|
|
235
|
+
flat: true,
|
|
236
|
+
stateConfig: quoteShadowRootState
|
|
237
|
+
}]
|
|
238
|
+
});
|
|
188
239
|
}
|
|
189
|
-
|
|
190
|
-
|
|
240
|
+
/**
|
|
241
|
+
* `true` when this quote has opted in to shadow root behavior with
|
|
242
|
+
* {@link setIsShadowRoot} or `$createQuoteNode({shadowRoot: true})`,
|
|
243
|
+
* in which case it contains block-level children rather than inline
|
|
244
|
+
* content. `false` (the legacy inline-content behavior) by default.
|
|
245
|
+
*/
|
|
246
|
+
isShadowRoot() {
|
|
247
|
+
return $getState(this, quoteShadowRootState);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Opt this quote in to (or out of) shadow root behavior. See
|
|
251
|
+
* {@link quoteShadowRootState}. Note that this does not restructure any
|
|
252
|
+
* existing children; a shadow root quote is expected to contain
|
|
253
|
+
* block-level children (non-element children will be normalized into
|
|
254
|
+
* paragraphs by the built-in shadow root transform).
|
|
255
|
+
*/
|
|
256
|
+
setIsShadowRoot(isShadowRoot) {
|
|
257
|
+
return $setState(this, quoteShadowRootState, isShadowRoot);
|
|
191
258
|
}
|
|
192
259
|
createDOM(config) {
|
|
193
|
-
const element =
|
|
260
|
+
const element = $getDocument().createElement("blockquote");
|
|
194
261
|
addClassNamesToElement(element, config.theme.quote);
|
|
195
262
|
return element;
|
|
196
263
|
}
|
|
197
|
-
updateDOM(prevNode, dom) {
|
|
264
|
+
updateDOM(prevNode, dom, config) {
|
|
198
265
|
return false;
|
|
199
266
|
}
|
|
200
|
-
static importDOM() {
|
|
201
|
-
return { blockquote: (node) => ({
|
|
202
|
-
conversion: $convertBlockquoteElement,
|
|
203
|
-
priority: 0
|
|
204
|
-
}) };
|
|
205
|
-
}
|
|
206
267
|
exportDOM(editor) {
|
|
207
268
|
const { element } = super.exportDOM(editor);
|
|
208
269
|
if (isHTMLElement(element)) {
|
|
209
|
-
if (this.isEmpty()) element.append(
|
|
270
|
+
if (this.isEmpty()) element.append($getDocument().createElement("br"));
|
|
210
271
|
const formatType = this.getFormatType();
|
|
211
272
|
if (formatType) element.style.textAlign = formatType;
|
|
212
273
|
const direction = this.getDirection();
|
|
@@ -214,6 +275,9 @@ var QuoteNode = class QuoteNode extends ElementNode {
|
|
|
214
275
|
}
|
|
215
276
|
return { element };
|
|
216
277
|
}
|
|
278
|
+
exportJSON() {
|
|
279
|
+
return super.exportJSON();
|
|
280
|
+
}
|
|
217
281
|
static importJSON(serializedNode) {
|
|
218
282
|
return $createQuoteNode().updateFromJSON(serializedNode);
|
|
219
283
|
}
|
|
@@ -225,6 +289,11 @@ var QuoteNode = class QuoteNode extends ElementNode {
|
|
|
225
289
|
return newBlock;
|
|
226
290
|
}
|
|
227
291
|
collapseAtStart() {
|
|
292
|
+
if (this.isShadowRoot()) {
|
|
293
|
+
for (const child of this.getChildren()) this.insertBefore(child);
|
|
294
|
+
this.remove();
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
228
297
|
const paragraph = $createParagraphNode();
|
|
229
298
|
this.getChildren().forEach((child) => paragraph.append(child));
|
|
230
299
|
this.replace(paragraph);
|
|
@@ -234,21 +303,64 @@ var QuoteNode = class QuoteNode extends ElementNode {
|
|
|
234
303
|
return true;
|
|
235
304
|
}
|
|
236
305
|
};
|
|
237
|
-
function $createQuoteNode() {
|
|
238
|
-
|
|
306
|
+
function $createQuoteNode(options) {
|
|
307
|
+
const node = $applyNodeReplacement(new QuoteNode());
|
|
308
|
+
return options && options.shadowRoot ? node.setIsShadowRoot(true) : node;
|
|
239
309
|
}
|
|
240
310
|
function $isQuoteNode(node) {
|
|
241
311
|
return node instanceof QuoteNode;
|
|
242
312
|
}
|
|
243
313
|
/** @noInheritDoc */
|
|
244
|
-
var HeadingNode = class
|
|
314
|
+
var HeadingNode = class extends ElementNode {
|
|
245
315
|
/** @internal */
|
|
246
316
|
__tag;
|
|
247
|
-
|
|
248
|
-
return "heading"
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
317
|
+
$config() {
|
|
318
|
+
return this.config("heading", {
|
|
319
|
+
extends: ElementNode,
|
|
320
|
+
importDOM: {
|
|
321
|
+
h1: () => ({
|
|
322
|
+
conversion: $convertHeadingElement,
|
|
323
|
+
priority: 0
|
|
324
|
+
}),
|
|
325
|
+
h2: () => ({
|
|
326
|
+
conversion: $convertHeadingElement,
|
|
327
|
+
priority: 0
|
|
328
|
+
}),
|
|
329
|
+
h3: () => ({
|
|
330
|
+
conversion: $convertHeadingElement,
|
|
331
|
+
priority: 0
|
|
332
|
+
}),
|
|
333
|
+
h4: () => ({
|
|
334
|
+
conversion: $convertHeadingElement,
|
|
335
|
+
priority: 0
|
|
336
|
+
}),
|
|
337
|
+
h5: () => ({
|
|
338
|
+
conversion: $convertHeadingElement,
|
|
339
|
+
priority: 0
|
|
340
|
+
}),
|
|
341
|
+
h6: () => ({
|
|
342
|
+
conversion: $convertHeadingElement,
|
|
343
|
+
priority: 0
|
|
344
|
+
}),
|
|
345
|
+
p: (node) => {
|
|
346
|
+
const firstChild = node.firstChild;
|
|
347
|
+
if (firstChild !== null && isGoogleDocsTitle(firstChild)) return {
|
|
348
|
+
conversion: () => ({ node: null }),
|
|
349
|
+
priority: 3
|
|
350
|
+
};
|
|
351
|
+
return null;
|
|
352
|
+
},
|
|
353
|
+
span: (node) => {
|
|
354
|
+
if (isGoogleDocsTitle(node)) return {
|
|
355
|
+
conversion: () => {
|
|
356
|
+
return { node: $createHeadingNode("h1") };
|
|
357
|
+
},
|
|
358
|
+
priority: 3
|
|
359
|
+
};
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
252
364
|
}
|
|
253
365
|
afterCloneFrom(prevNode) {
|
|
254
366
|
super.afterCloneFrom(prevNode);
|
|
@@ -268,7 +380,7 @@ var HeadingNode = class HeadingNode extends ElementNode {
|
|
|
268
380
|
}
|
|
269
381
|
createDOM(config) {
|
|
270
382
|
const tag = this.__tag;
|
|
271
|
-
const element =
|
|
383
|
+
const element = $getDocument().createElement(tag);
|
|
272
384
|
const classNames = config.theme.heading;
|
|
273
385
|
if (classNames !== void 0) {
|
|
274
386
|
const className = classNames[tag];
|
|
@@ -279,55 +391,10 @@ var HeadingNode = class HeadingNode extends ElementNode {
|
|
|
279
391
|
updateDOM(prevNode, dom, config) {
|
|
280
392
|
return prevNode.__tag !== this.__tag;
|
|
281
393
|
}
|
|
282
|
-
static importDOM() {
|
|
283
|
-
return {
|
|
284
|
-
h1: (node) => ({
|
|
285
|
-
conversion: $convertHeadingElement,
|
|
286
|
-
priority: 0
|
|
287
|
-
}),
|
|
288
|
-
h2: (node) => ({
|
|
289
|
-
conversion: $convertHeadingElement,
|
|
290
|
-
priority: 0
|
|
291
|
-
}),
|
|
292
|
-
h3: (node) => ({
|
|
293
|
-
conversion: $convertHeadingElement,
|
|
294
|
-
priority: 0
|
|
295
|
-
}),
|
|
296
|
-
h4: (node) => ({
|
|
297
|
-
conversion: $convertHeadingElement,
|
|
298
|
-
priority: 0
|
|
299
|
-
}),
|
|
300
|
-
h5: (node) => ({
|
|
301
|
-
conversion: $convertHeadingElement,
|
|
302
|
-
priority: 0
|
|
303
|
-
}),
|
|
304
|
-
h6: (node) => ({
|
|
305
|
-
conversion: $convertHeadingElement,
|
|
306
|
-
priority: 0
|
|
307
|
-
}),
|
|
308
|
-
p: (node) => {
|
|
309
|
-
const firstChild = node.firstChild;
|
|
310
|
-
if (firstChild !== null && isGoogleDocsTitle(firstChild)) return {
|
|
311
|
-
conversion: () => ({ node: null }),
|
|
312
|
-
priority: 3
|
|
313
|
-
};
|
|
314
|
-
return null;
|
|
315
|
-
},
|
|
316
|
-
span: (node) => {
|
|
317
|
-
if (isGoogleDocsTitle(node)) return {
|
|
318
|
-
conversion: (domNode) => {
|
|
319
|
-
return { node: $createHeadingNode("h1") };
|
|
320
|
-
},
|
|
321
|
-
priority: 3
|
|
322
|
-
};
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
394
|
exportDOM(editor) {
|
|
328
395
|
const { element } = super.exportDOM(editor);
|
|
329
396
|
if (isHTMLElement(element)) {
|
|
330
|
-
if (this.isEmpty()) element.append(
|
|
397
|
+
if (this.isEmpty()) element.append($getDocument().createElement("br"));
|
|
331
398
|
const formatType = this.getFormatType();
|
|
332
399
|
if (formatType) element.style.textAlign = formatType;
|
|
333
400
|
const direction = this.getDirection();
|
|
@@ -335,9 +402,6 @@ var HeadingNode = class HeadingNode extends ElementNode {
|
|
|
335
402
|
}
|
|
336
403
|
return { element };
|
|
337
404
|
}
|
|
338
|
-
static importJSON(serializedNode) {
|
|
339
|
-
return $createHeadingNode(serializedNode.tag).updateFromJSON(serializedNode);
|
|
340
|
-
}
|
|
341
405
|
updateFromJSON(serializedNode) {
|
|
342
406
|
return super.updateFromJSON(serializedNode).setTag(serializedNode.tag);
|
|
343
407
|
}
|
|
@@ -424,6 +488,10 @@ function $isSelectionAtEndOfRoot(selection) {
|
|
|
424
488
|
const focus = selection.focus;
|
|
425
489
|
return focus.key === "root" && focus.offset === $getRoot().getChildrenSize();
|
|
426
490
|
}
|
|
491
|
+
function $isSelectionAtStartOfRoot(selection) {
|
|
492
|
+
const focus = selection.focus;
|
|
493
|
+
return focus.key === "root" && focus.offset === 0;
|
|
494
|
+
}
|
|
427
495
|
function $isSelectionCollapsedAtFrontOfIndentedBlock(selection) {
|
|
428
496
|
if (!selection.isCollapsed()) return false;
|
|
429
497
|
const { anchor } = selection;
|
|
@@ -498,6 +566,185 @@ const DEFAULT_ESCAPE_FORMAT_TRIGGERS = {
|
|
|
498
566
|
tab: true
|
|
499
567
|
}
|
|
500
568
|
};
|
|
569
|
+
function $tryEnterFromBlockCursor(selection, direction) {
|
|
570
|
+
if (!selection.isCollapsed() || selection.anchor.type !== "element") return false;
|
|
571
|
+
const child = $caretFromPoint(selection.anchor, direction).getNodeAtCaret();
|
|
572
|
+
if ($isShadowRootNode(child) && !child.isInline()) {
|
|
573
|
+
$setSelectionFromCaretRange($getCollapsedCaretRange($normalizeCaret($getChildCaret(child, direction))));
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
function $tryBlockCursorShadowRootNavigation(selection, direction) {
|
|
579
|
+
return $tryExitShadowRootToBlockCursor(selection, direction) || $tryEnterFromBlockCursor(selection, direction);
|
|
580
|
+
}
|
|
581
|
+
function $tryExitShadowRootToBlockCursor(selection, direction) {
|
|
582
|
+
if (!selection.isCollapsed()) return false;
|
|
583
|
+
const focusCaret = $caretFromPoint(selection.focus, direction);
|
|
584
|
+
const shadowRoot = $findMatchingParent(focusCaret.origin, $isShadowRootNode);
|
|
585
|
+
if (!shadowRoot) return false;
|
|
586
|
+
const focusNode = selection.focus.getNode();
|
|
587
|
+
if (!shadowRoot.is(focusNode) && !$hasAncestor(focusNode, shadowRoot)) return false;
|
|
588
|
+
const textRange = $getCaretRange(focusCaret, $getSiblingCaret(shadowRoot, direction));
|
|
589
|
+
if (textRange.getTextSlices().some((slice) => slice && slice.getTextContentSize() > 0)) return false;
|
|
590
|
+
const range = $getCaretRange(textRange.anchor.getSiblingCaret(), textRange.focus);
|
|
591
|
+
let prevOrigin = range.anchor.origin;
|
|
592
|
+
for (const caret of range) {
|
|
593
|
+
if (!($isSiblingCaret(caret) && caret.origin.is(prevOrigin.getParent()))) return false;
|
|
594
|
+
prevOrigin = caret.origin;
|
|
595
|
+
}
|
|
596
|
+
let prevShadow = shadowRoot;
|
|
597
|
+
for (const caret of $extendCaretToRange($getSiblingCaret(shadowRoot, direction))) {
|
|
598
|
+
if (caret.origin.is(prevShadow.getParent())) {
|
|
599
|
+
if (!$isShadowRootNode(caret.origin)) break;
|
|
600
|
+
prevShadow = caret.origin;
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
if ($needsBlockCursorBeside(caret.origin)) {
|
|
604
|
+
const sr = $getSiblingCaret(prevShadow, direction);
|
|
605
|
+
$setSelectionFromCaretRange($getCaretRange(sr, sr));
|
|
606
|
+
return true;
|
|
607
|
+
}
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
function $isSelectableBlockDecorator(node) {
|
|
613
|
+
return $isDecoratorNode(node) && !node.isInline() && !node.isIsolated() && node.isKeyboardSelectable();
|
|
614
|
+
}
|
|
615
|
+
function $selectNode(key) {
|
|
616
|
+
const nodeSelection = $createNodeSelection();
|
|
617
|
+
nodeSelection.add(key);
|
|
618
|
+
$setSelection(nodeSelection);
|
|
619
|
+
}
|
|
620
|
+
function $tryDecoratorLineNavigation(selection, isBackward) {
|
|
621
|
+
if (!selection.isCollapsed()) return false;
|
|
622
|
+
const focus = selection.focus;
|
|
623
|
+
const focusNode = focus.getNode();
|
|
624
|
+
const direction = isBackward ? "previous" : "next";
|
|
625
|
+
const focusCaret = $caretFromPoint(focus, direction);
|
|
626
|
+
if (focus.type === "element" && $isElementNode(focusNode) && $isRootOrShadowRoot(focusNode)) {
|
|
627
|
+
const adjacentChild = focusCaret.getNodeAtCaret();
|
|
628
|
+
if (adjacentChild !== null && $isSelectableBlockDecorator(adjacentChild)) {
|
|
629
|
+
$selectNode(adjacentChild.__key);
|
|
630
|
+
return true;
|
|
631
|
+
}
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
634
|
+
const topBlock = $findMatchingParent($isElementNode(focusNode) ? focusNode : focusNode.getParentOrThrow(), (n) => $isElementNode(n) && !n.isInline() && $isRootOrShadowRoot(n.getParent()));
|
|
635
|
+
if (topBlock === null) return false;
|
|
636
|
+
const adjacentSibling = $getSiblingCaret(topBlock, direction).getNodeAtCaret();
|
|
637
|
+
if (adjacentSibling === null || !$isSelectableBlockDecorator(adjacentSibling)) return false;
|
|
638
|
+
if (topBlock.getTextContentSize() === 0) {
|
|
639
|
+
$selectNode(adjacentSibling.__key);
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
const rootElement = $getEditor().getRootElement();
|
|
643
|
+
if (rootElement === null) return false;
|
|
644
|
+
const domSelection = getDOMSelection(rootElement.ownerDocument.defaultView);
|
|
645
|
+
if (domSelection === null || domSelection.rangeCount === 0) return false;
|
|
646
|
+
const savedAnchorNode = domSelection.anchorNode;
|
|
647
|
+
const savedAnchorOffset = domSelection.anchorOffset;
|
|
648
|
+
const savedFocusNode = domSelection.focusNode;
|
|
649
|
+
const savedFocusOffset = domSelection.focusOffset;
|
|
650
|
+
domSelection.modify("move", isBackward ? "backward" : "forward", "line");
|
|
651
|
+
const newAnchorNode = domSelection.anchorNode;
|
|
652
|
+
const newAnchorOffset = domSelection.anchorOffset;
|
|
653
|
+
if (newAnchorNode === null) {
|
|
654
|
+
restoreDOMSelection(domSelection, savedAnchorNode, savedAnchorOffset, savedFocusNode, savedFocusOffset);
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
const movedNode = $getNearestNodeFromDOMNode(newAnchorNode);
|
|
658
|
+
restoreDOMSelection(domSelection, savedAnchorNode, savedAnchorOffset, savedFocusNode, savedFocusOffset);
|
|
659
|
+
if (movedNode === null) return false;
|
|
660
|
+
if (newAnchorNode === savedAnchorNode && newAnchorOffset === savedAnchorOffset) {
|
|
661
|
+
$selectNode(adjacentSibling.__key);
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
if (movedNode.is(topBlock) || $hasAncestor(movedNode, topBlock)) return false;
|
|
665
|
+
$selectNode(adjacentSibling.__key);
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
function restoreDOMSelection(domSelection, anchorNode, anchorOffset, focusNode, focusOffset) {
|
|
669
|
+
if (anchorNode !== null && focusNode !== null) domSelection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
670
|
+
}
|
|
671
|
+
function $tryInlineGridLineNavigation(selection, isBackward) {
|
|
672
|
+
if (!selection.isCollapsed()) return false;
|
|
673
|
+
const focusNode = selection.focus.getNode();
|
|
674
|
+
const parentBlock = $findMatchingParent($isElementNode(focusNode) ? focusNode : focusNode.getParentOrThrow(), (n) => $isElementNode(n) && !n.isInline());
|
|
675
|
+
if (parentBlock === null) return false;
|
|
676
|
+
const editor = $getEditor();
|
|
677
|
+
const rootElement = editor.getRootElement();
|
|
678
|
+
if (rootElement === null) return false;
|
|
679
|
+
const win = rootElement.ownerDocument.defaultView;
|
|
680
|
+
if (win === null) return false;
|
|
681
|
+
let hasGrid = false;
|
|
682
|
+
for (const child of parentBlock.getChildren()) if ($isElementNode(child) && child.isInline()) {
|
|
683
|
+
const dom = editor.getElementByKey(child.getKey());
|
|
684
|
+
if (dom !== null) {
|
|
685
|
+
const d = win.getComputedStyle(dom).display;
|
|
686
|
+
if (d === "inline-grid" || d === "inline-flex") {
|
|
687
|
+
hasGrid = true;
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (!hasGrid) return false;
|
|
693
|
+
const siblingBlock = $getSiblingCaret(parentBlock, isBackward ? "previous" : "next").getNodeAtCaret();
|
|
694
|
+
if (siblingBlock === null || !$isElementNode(siblingBlock)) {
|
|
695
|
+
if (isBackward) {
|
|
696
|
+
const first = parentBlock.getFirstDescendant();
|
|
697
|
+
if ($isTextNode(first)) first.select(0, 0);
|
|
698
|
+
else parentBlock.select(0, 0);
|
|
699
|
+
} else {
|
|
700
|
+
const last = parentBlock.getLastDescendant();
|
|
701
|
+
if ($isTextNode(last)) {
|
|
702
|
+
const len = last.getTextContentSize();
|
|
703
|
+
last.select(len, len);
|
|
704
|
+
} else {
|
|
705
|
+
const count = parentBlock.getChildrenSize();
|
|
706
|
+
parentBlock.select(count, count);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return true;
|
|
710
|
+
}
|
|
711
|
+
const siblingDOM = editor.getElementByKey(siblingBlock.getKey());
|
|
712
|
+
if (siblingDOM === null) return false;
|
|
713
|
+
const domSelection = getDOMSelection(win);
|
|
714
|
+
if (domSelection === null || domSelection.rangeCount === 0) return false;
|
|
715
|
+
const curRange = domSelection.getRangeAt(0).cloneRange();
|
|
716
|
+
curRange.collapse(true);
|
|
717
|
+
const curRect = curRange.getBoundingClientRect();
|
|
718
|
+
const sibRect = siblingDOM.getBoundingClientRect();
|
|
719
|
+
const targetY = sibRect.top + sibRect.height / 2;
|
|
720
|
+
if (curRect.height > 0) {
|
|
721
|
+
const hit = caretFromPoint(curRect.left, targetY, rootElement);
|
|
722
|
+
if (hit !== null && siblingDOM.contains(hit.node)) {
|
|
723
|
+
const hitRange = rootElement.ownerDocument.createRange();
|
|
724
|
+
hitRange.setStart(hit.node, hit.offset);
|
|
725
|
+
hitRange.collapse(true);
|
|
726
|
+
selection.applyDOMRange(hitRange);
|
|
727
|
+
selection.dirty = true;
|
|
728
|
+
return true;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
const targetDesc = isBackward ? siblingBlock.getLastDescendant() : siblingBlock.getFirstDescendant();
|
|
732
|
+
if ($isTextNode(targetDesc)) {
|
|
733
|
+
const offset = isBackward ? targetDesc.getTextContentSize() : 0;
|
|
734
|
+
targetDesc.select(offset, offset);
|
|
735
|
+
} else {
|
|
736
|
+
const childCount = siblingBlock.getChildrenSize();
|
|
737
|
+
siblingBlock.select(isBackward ? childCount : 0, isBackward ? childCount : 0);
|
|
738
|
+
}
|
|
739
|
+
return true;
|
|
740
|
+
}
|
|
741
|
+
function $exitNodeSelectionToward(node, direction) {
|
|
742
|
+
const caret = $getSiblingCaret(node, direction);
|
|
743
|
+
const sibling = caret.getAdjacentCaret();
|
|
744
|
+
if (sibling !== null && $isElementNode(sibling.origin) && !sibling.origin.isInline() && sibling.origin.isShadowRoot()) $setSelectionFromCaretRange($getCollapsedCaretRange(caret));
|
|
745
|
+
else if (direction === "next") node.selectNext(0, 0);
|
|
746
|
+
else node.selectPrevious();
|
|
747
|
+
}
|
|
501
748
|
/**
|
|
502
749
|
* Collapse a NodeSelection to a caret at the surrounding block's edge for
|
|
503
750
|
* MOVE_TO_START / MOVE_TO_END. Picks the document-order first node for
|
|
@@ -594,8 +841,13 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
594
841
|
return true;
|
|
595
842
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(FORMAT_TEXT_COMMAND, (format) => {
|
|
596
843
|
const selection = $getSelection();
|
|
597
|
-
if (!$isRangeSelection(selection)) return false;
|
|
598
|
-
|
|
844
|
+
if (!$isRangeSelection(selection) && !$isNodeSelection(selection)) return false;
|
|
845
|
+
$formatText(selection, format);
|
|
846
|
+
return true;
|
|
847
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(SET_TEXT_FORMAT_COMMAND, (formats) => {
|
|
848
|
+
const selection = $getSelection();
|
|
849
|
+
if (!$isRangeSelection(selection) && !$isNodeSelection(selection)) return false;
|
|
850
|
+
$setTextFormat(selection, formats);
|
|
599
851
|
return true;
|
|
600
852
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(FORMAT_ELEMENT_COMMAND, (format) => {
|
|
601
853
|
const selection = $getSelection();
|
|
@@ -641,13 +893,23 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
641
893
|
const nodes = selection.getNodes();
|
|
642
894
|
if (nodes.length > 0) {
|
|
643
895
|
event.preventDefault();
|
|
644
|
-
nodes[0]
|
|
896
|
+
$exitNodeSelectionToward(nodes[0], "previous");
|
|
645
897
|
return true;
|
|
646
898
|
}
|
|
647
899
|
} else if ($isRangeSelection(selection)) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
900
|
+
if ($isSelectionAtStartOfRoot(selection)) {
|
|
901
|
+
event.preventDefault();
|
|
902
|
+
return true;
|
|
903
|
+
}
|
|
904
|
+
if (!event.shiftKey && $tryBlockCursorShadowRootNavigation(selection, "previous")) {
|
|
905
|
+
event.preventDefault();
|
|
906
|
+
return true;
|
|
907
|
+
}
|
|
908
|
+
if (!event.shiftKey && $tryDecoratorLineNavigation(selection, true)) {
|
|
909
|
+
event.preventDefault();
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
if (!event.shiftKey && $tryInlineGridLineNavigation(selection, true)) {
|
|
651
913
|
event.preventDefault();
|
|
652
914
|
return true;
|
|
653
915
|
}
|
|
@@ -659,7 +921,7 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
659
921
|
const nodes = selection.getNodes();
|
|
660
922
|
if (nodes.length > 0) {
|
|
661
923
|
event.preventDefault();
|
|
662
|
-
nodes[0]
|
|
924
|
+
$exitNodeSelectionToward(nodes[0], "next");
|
|
663
925
|
return true;
|
|
664
926
|
}
|
|
665
927
|
} else if ($isRangeSelection(selection)) {
|
|
@@ -667,9 +929,15 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
667
929
|
event.preventDefault();
|
|
668
930
|
return true;
|
|
669
931
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
932
|
+
if (!event.shiftKey && $tryBlockCursorShadowRootNavigation(selection, "next")) {
|
|
933
|
+
event.preventDefault();
|
|
934
|
+
return true;
|
|
935
|
+
}
|
|
936
|
+
if (!event.shiftKey && $tryDecoratorLineNavigation(selection, false)) {
|
|
937
|
+
event.preventDefault();
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
if (!event.shiftKey && $tryInlineGridLineNavigation(selection, false)) {
|
|
673
941
|
event.preventDefault();
|
|
674
942
|
return true;
|
|
675
943
|
}
|
|
@@ -681,12 +949,15 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
681
949
|
const nodes = selection.getNodes();
|
|
682
950
|
if (nodes.length > 0) {
|
|
683
951
|
event.preventDefault();
|
|
684
|
-
|
|
685
|
-
else nodes[0].selectPrevious();
|
|
952
|
+
$exitNodeSelectionToward(nodes[0], $isParentRTL(nodes[0]) ? "next" : "previous");
|
|
686
953
|
return true;
|
|
687
954
|
}
|
|
688
955
|
}
|
|
689
956
|
if (!$isRangeSelection(selection)) return false;
|
|
957
|
+
if (!event.shiftKey && $tryBlockCursorShadowRootNavigation(selection, $isParentRTL(selection.anchor.getNode()) ? "next" : "previous")) {
|
|
958
|
+
event.preventDefault();
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
690
961
|
if (!event.shiftKey) $escapeFormatsForTrigger(selection, "arrow", "start", escapeFormatTriggers.peek());
|
|
691
962
|
if ($shouldOverrideDefaultCharacterSelection(selection, true)) {
|
|
692
963
|
const isHoldingShift = event.shiftKey;
|
|
@@ -701,12 +972,15 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
701
972
|
const nodes = selection.getNodes();
|
|
702
973
|
if (nodes.length > 0) {
|
|
703
974
|
event.preventDefault();
|
|
704
|
-
|
|
705
|
-
else nodes[0].selectNext(0, 0);
|
|
975
|
+
$exitNodeSelectionToward(nodes[0], $isParentRTL(nodes[0]) ? "previous" : "next");
|
|
706
976
|
return true;
|
|
707
977
|
}
|
|
708
978
|
}
|
|
709
979
|
if (!$isRangeSelection(selection)) return false;
|
|
980
|
+
if (!event.shiftKey && $tryBlockCursorShadowRootNavigation(selection, $isParentRTL(selection.anchor.getNode()) ? "previous" : "next")) {
|
|
981
|
+
event.preventDefault();
|
|
982
|
+
return true;
|
|
983
|
+
}
|
|
710
984
|
if (!event.shiftKey) $escapeFormatsForTrigger(selection, "arrow", "end", escapeFormatTriggers.peek());
|
|
711
985
|
if ($shouldOverrideDefaultCharacterSelection(selection, false)) {
|
|
712
986
|
const isHoldingShift = event.shiftKey;
|
|
@@ -723,7 +997,7 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
723
997
|
if ($isRangeSelection(selection)) {
|
|
724
998
|
if ($isSelectionCollapsedAtFrontOfIndentedBlock(selection)) {
|
|
725
999
|
event.preventDefault();
|
|
726
|
-
return editor.dispatchCommand(OUTDENT_CONTENT_COMMAND
|
|
1000
|
+
return editor.dispatchCommand(OUTDENT_CONTENT_COMMAND);
|
|
727
1001
|
}
|
|
728
1002
|
if (IS_IOS && CAN_USE_BEFORE_INPUT) return false;
|
|
729
1003
|
} else if (!$isNodeSelection(selection)) return false;
|
|
@@ -750,7 +1024,7 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
750
1024
|
event.preventDefault();
|
|
751
1025
|
if (event.shiftKey) return editor.dispatchCommand(INSERT_LINE_BREAK_COMMAND, false);
|
|
752
1026
|
}
|
|
753
|
-
return editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND
|
|
1027
|
+
return editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND);
|
|
754
1028
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ESCAPE_COMMAND, () => {
|
|
755
1029
|
if (!$isRangeSelection($getSelection())) return false;
|
|
756
1030
|
editor.blur();
|
|
@@ -796,7 +1070,12 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
796
1070
|
const [isFileTransfer] = eventFiles(event);
|
|
797
1071
|
const selection = $getSelection();
|
|
798
1072
|
if (isFileTransfer && !$isRangeSelection(selection)) return false;
|
|
799
|
-
event.
|
|
1073
|
+
const x = event.clientX;
|
|
1074
|
+
const y = event.clientY;
|
|
1075
|
+
const eventRange = caretFromPoint(x, y, editor.getRootElement());
|
|
1076
|
+
if (eventRange !== null) {
|
|
1077
|
+
if ($isDecoratorNode($getNearestNodeFromDOMNode(eventRange.node))) event.preventDefault();
|
|
1078
|
+
}
|
|
800
1079
|
return true;
|
|
801
1080
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(SELECT_ALL_COMMAND, () => {
|
|
802
1081
|
const selection = $getSelection();
|
|
@@ -864,4 +1143,4 @@ function registerRichText(editor, escapeFormatTriggers = signal(DEFAULT_ESCAPE_F
|
|
|
864
1143
|
}, COMMAND_PRIORITY_EDITOR));
|
|
865
1144
|
}
|
|
866
1145
|
//#endregion
|
|
867
|
-
export { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, DRAG_DROP_PASTE, HeadingNode, QuoteNode, RichTextExtension, RichTextImportExtension, RichTextImportRules, eventFiles, registerRichText };
|
|
1146
|
+
export { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, DRAG_DROP_PASTE, HeadingNode, QuoteNode, RichTextExtension, RichTextImportExtension, RichTextImportRules, ShadowRootQuoteRule, eventFiles, quoteShadowRootState, registerRichText };
|