@notectl/core 1.0.3 → 1.0.5
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 +51 -148
- package/dist/chunks/AttrRegistry-DTsHyDVA.mjs +16 -0
- package/dist/chunks/AttrRegistry-DTsHyDVA.mjs.map +1 -0
- package/dist/chunks/Commands-DLP85Mp5.mjs +461 -0
- package/dist/chunks/Commands-DLP85Mp5.mjs.map +1 -0
- package/dist/chunks/Document-CI3iCwEP.mjs +177 -0
- package/dist/chunks/Document-CI3iCwEP.mjs.map +1 -0
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +7 -0
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +1 -0
- package/dist/chunks/NodeResolver-D68ZLXti.mjs +81 -0
- package/dist/chunks/NodeResolver-D68ZLXti.mjs.map +1 -0
- package/dist/chunks/NodeSpec-NZVvcCuH.mjs +8 -0
- package/dist/chunks/NodeSpec-NZVvcCuH.mjs.map +1 -0
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs +15 -0
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +1 -0
- package/dist/chunks/Selection-D5ZjXoB7.mjs +44 -0
- package/dist/chunks/Selection-D5ZjXoB7.mjs.map +1 -0
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs +7 -0
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs +398 -0
- package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +1 -0
- package/dist/chunks/TypeBrands-C09nE2qO.mjs +27 -0
- package/dist/chunks/TypeBrands-C09nE2qO.mjs.map +1 -0
- package/dist/chunks/color-picker-Csf0wx5a.mjs +5 -0
- package/dist/chunks/color-picker-Csf0wx5a.mjs.map +1 -0
- package/dist/chunks/index-CPPb-Jah.mjs +569 -0
- package/dist/chunks/index-CPPb-Jah.mjs.map +1 -0
- package/dist/commands/Commands.d.ts +71 -0
- package/dist/commands/Commands.d.ts.map +1 -0
- package/dist/commands/PasteCommand.d.ts +9 -0
- package/dist/commands/PasteCommand.d.ts.map +1 -0
- package/dist/decorations/Decoration.d.ts +76 -0
- package/dist/decorations/Decoration.d.ts.map +1 -0
- package/dist/decorations/PositionMapping.d.ts +9 -0
- package/dist/decorations/PositionMapping.d.ts.map +1 -0
- package/dist/editor/Announcer.d.ts +12 -0
- package/dist/editor/Announcer.d.ts.map +1 -0
- package/dist/editor/DocumentParser.d.ts +5 -0
- package/dist/editor/DocumentParser.d.ts.map +1 -0
- package/dist/editor/DocumentSerializer.d.ts +5 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -0
- package/dist/editor/EditorDOM.d.ts +18 -0
- package/dist/editor/EditorDOM.d.ts.map +1 -0
- package/dist/editor/EditorThemeController.d.ts +21 -0
- package/dist/editor/EditorThemeController.d.ts.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +131 -0
- package/dist/editor/NotectlEditor.d.ts.map +1 -0
- package/dist/editor/styles/base.d.ts +3 -0
- package/dist/editor/styles/base.d.ts.map +1 -0
- package/dist/editor/styles/code-block.d.ts +3 -0
- package/dist/editor/styles/code-block.d.ts.map +1 -0
- package/dist/editor/styles/color-picker.d.ts +3 -0
- package/dist/editor/styles/color-picker.d.ts.map +1 -0
- package/dist/editor/styles/font-select.d.ts +3 -0
- package/dist/editor/styles/font-select.d.ts.map +1 -0
- package/dist/editor/styles/font-size-select.d.ts +3 -0
- package/dist/editor/styles/font-size-select.d.ts.map +1 -0
- package/dist/editor/styles/heading-select.d.ts +3 -0
- package/dist/editor/styles/heading-select.d.ts.map +1 -0
- package/dist/editor/styles/image.d.ts +3 -0
- package/dist/editor/styles/image.d.ts.map +1 -0
- package/dist/editor/styles/list.d.ts +3 -0
- package/dist/editor/styles/list.d.ts.map +1 -0
- package/dist/editor/styles/reduced-motion.d.ts +3 -0
- package/dist/editor/styles/reduced-motion.d.ts.map +1 -0
- package/dist/editor/styles/table.d.ts +3 -0
- package/dist/editor/styles/table.d.ts.map +1 -0
- package/dist/editor/styles/toolbar.d.ts +3 -0
- package/dist/editor/styles/toolbar.d.ts.map +1 -0
- package/dist/editor/styles.d.ts +12 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/theme/ThemeEngine.d.ts +6 -0
- package/dist/editor/theme/ThemeEngine.d.ts.map +1 -0
- package/dist/editor/theme/ThemeTokens.d.ts +73 -0
- package/dist/editor/theme/ThemeTokens.d.ts.map +1 -0
- package/dist/fonts.d.ts +17 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.mjs +7 -0
- package/dist/fonts.mjs.map +1 -0
- package/dist/index.d.ts +81 -2360
- package/dist/index.d.ts.map +1 -0
- package/dist/input/ClipboardHandler.d.ts +29 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -0
- package/dist/input/InputHandler.d.ts +32 -0
- package/dist/input/InputHandler.d.ts.map +1 -0
- package/dist/input/InputRule.d.ts +9 -0
- package/dist/input/InputRule.d.ts.map +1 -0
- package/dist/input/InternalClipboard.d.ts +23 -0
- package/dist/input/InternalClipboard.d.ts.map +1 -0
- package/dist/input/KeyboardHandler.d.ts +42 -0
- package/dist/input/KeyboardHandler.d.ts.map +1 -0
- package/dist/input/Keymap.d.ts +11 -0
- package/dist/input/Keymap.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +38 -0
- package/dist/input/PasteHandler.d.ts.map +1 -0
- package/dist/input/SourceNormalizer.d.ts +7 -0
- package/dist/input/SourceNormalizer.d.ts.map +1 -0
- package/dist/model/AttrRegistry.d.ts +39 -0
- package/dist/model/AttrRegistry.d.ts.map +1 -0
- package/dist/model/BuiltinSpecs.d.ts +4 -0
- package/dist/model/BuiltinSpecs.d.ts.map +1 -0
- package/dist/model/ContentModel.d.ts +12 -0
- package/dist/model/ContentModel.d.ts.map +1 -0
- package/dist/model/ContentSlice.d.ts +17 -0
- package/dist/model/ContentSlice.d.ts.map +1 -0
- package/dist/model/Document.d.ts +127 -0
- package/dist/model/Document.d.ts.map +1 -0
- package/dist/model/HTMLParser.d.ts +36 -0
- package/dist/model/HTMLParser.d.ts.map +1 -0
- package/dist/model/HTMLUtils.d.ts +6 -0
- package/dist/model/HTMLUtils.d.ts.map +1 -0
- package/dist/model/InlineNodeSpec.d.ts +20 -0
- package/dist/model/InlineNodeSpec.d.ts.map +1 -0
- package/dist/model/MarkSpec.d.ts +22 -0
- package/dist/model/MarkSpec.d.ts.map +1 -0
- package/dist/model/NodeResolver.d.ts +36 -0
- package/dist/model/NodeResolver.d.ts.map +1 -0
- package/dist/model/NodeSpec.d.ts +67 -0
- package/dist/model/NodeSpec.d.ts.map +1 -0
- package/dist/model/ParseRule.d.ts +11 -0
- package/dist/model/ParseRule.d.ts.map +1 -0
- package/dist/model/SanitizeConfig.d.ts +9 -0
- package/dist/model/SanitizeConfig.d.ts.map +1 -0
- package/dist/model/Schema.d.ts +17 -0
- package/dist/model/Schema.d.ts.map +1 -0
- package/dist/model/SchemaRegistry.d.ts +81 -0
- package/dist/model/SchemaRegistry.d.ts.map +1 -0
- package/dist/model/Selection.d.ts +52 -0
- package/dist/model/Selection.d.ts.map +1 -0
- package/dist/model/TypeBrands.d.ts +28 -0
- package/dist/model/TypeBrands.d.ts.map +1 -0
- package/dist/notectl-core.mjs +2576 -11104
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +6810 -0
- package/dist/notectl-core.umd.js.map +1 -0
- package/dist/plugins/EventBus.d.ts +13 -0
- package/dist/plugins/EventBus.d.ts.map +1 -0
- package/dist/plugins/Plugin.d.ts +85 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/PluginManager.d.ts +66 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +48 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -0
- package/dist/plugins/alignment/index.d.ts +2 -0
- package/dist/plugins/alignment/index.d.ts.map +1 -0
- package/dist/plugins/alignment.mjs +92 -0
- package/dist/plugins/alignment.mjs.map +1 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +30 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -0
- package/dist/plugins/blockquote/index.d.ts +2 -0
- package/dist/plugins/blockquote/index.d.ts.map +1 -0
- package/dist/plugins/blockquote.mjs +58 -0
- package/dist/plugins/blockquote.mjs.map +1 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +135 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -0
- package/dist/plugins/code-block/index.d.ts +2 -0
- package/dist/plugins/code-block/index.d.ts.map +1 -0
- package/dist/plugins/code-block.mjs +6 -0
- package/dist/plugins/code-block.mjs.map +1 -0
- package/dist/plugins/font/FontPlugin.d.ts +85 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -0
- package/dist/plugins/font/StarterFonts.d.ts +10 -0
- package/dist/plugins/font/StarterFonts.d.ts.map +1 -0
- package/dist/plugins/font/index.d.ts +2 -0
- package/dist/plugins/font/index.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +65 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -0
- package/dist/plugins/font-size/index.d.ts +2 -0
- package/dist/plugins/font-size/index.d.ts.map +1 -0
- package/dist/plugins/font-size.mjs +220 -0
- package/dist/plugins/font-size.mjs.map +1 -0
- package/dist/plugins/font.mjs +186 -0
- package/dist/plugins/font.mjs.map +1 -0
- package/dist/plugins/hard-break/HardBreakPlugin.d.ts +16 -0
- package/dist/plugins/hard-break/HardBreakPlugin.d.ts.map +1 -0
- package/dist/plugins/hard-break/index.d.ts +2 -0
- package/dist/plugins/hard-break/index.d.ts.map +1 -0
- package/dist/plugins/hard-break.mjs +28 -0
- package/dist/plugins/hard-break.mjs.map +1 -0
- package/dist/plugins/heading/BlockTypePickerEntry.d.ts +20 -0
- package/dist/plugins/heading/BlockTypePickerEntry.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +78 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -0
- package/dist/plugins/heading/index.d.ts +3 -0
- package/dist/plugins/heading/index.d.ts.map +1 -0
- package/dist/plugins/heading.mjs +188 -0
- package/dist/plugins/heading.mjs.map +1 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts +37 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -0
- package/dist/plugins/highlight/index.d.ts +2 -0
- package/dist/plugins/highlight/index.d.ts.map +1 -0
- package/dist/plugins/highlight.mjs +126 -0
- package/dist/plugins/highlight.mjs.map +1 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +29 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule/index.d.ts +2 -0
- package/dist/plugins/horizontal-rule/index.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule.mjs +59 -0
- package/dist/plugins/horizontal-rule.mjs.map +1 -0
- package/dist/plugins/image/ImageCommands.d.ts +26 -0
- package/dist/plugins/image/ImageCommands.d.ts.map +1 -0
- package/dist/plugins/image/ImageNodeView.d.ts +6 -0
- package/dist/plugins/image/ImageNodeView.d.ts.map +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts +43 -0
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -0
- package/dist/plugins/image/ImageUpload.d.ts +48 -0
- package/dist/plugins/image/ImageUpload.d.ts.map +1 -0
- package/dist/plugins/image/index.d.ts +3 -0
- package/dist/plugins/image/index.d.ts.map +1 -0
- package/dist/plugins/image.mjs +381 -0
- package/dist/plugins/image.mjs.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +32 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -0
- package/dist/plugins/link/index.d.ts +2 -0
- package/dist/plugins/link/index.d.ts.map +1 -0
- package/dist/plugins/link.mjs +127 -0
- package/dist/plugins/link.mjs.map +1 -0
- package/dist/plugins/list/ListPlugin.d.ts +51 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -0
- package/dist/plugins/list/index.d.ts +2 -0
- package/dist/plugins/list/index.d.ts.map +1 -0
- package/dist/plugins/list.mjs +193 -0
- package/dist/plugins/list.mjs.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +23 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -0
- package/dist/plugins/strikethrough/index.d.ts +2 -0
- package/dist/plugins/strikethrough/index.d.ts.map +1 -0
- package/dist/plugins/strikethrough.mjs +35 -0
- package/dist/plugins/strikethrough.mjs.map +1 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts +44 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -0
- package/dist/plugins/super-sub/index.d.ts +2 -0
- package/dist/plugins/super-sub/index.d.ts.map +1 -0
- package/dist/plugins/super-sub.mjs +81 -0
- package/dist/plugins/super-sub.mjs.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts +50 -0
- package/dist/plugins/table/TableCommands.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts +10 -0
- package/dist/plugins/table/TableControls.d.ts.map +1 -0
- package/dist/plugins/table/TableControlsDOM.d.ts +18 -0
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -0
- package/dist/plugins/table/TableControlsLayout.d.ts +34 -0
- package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -0
- package/dist/plugins/table/TableHelpers.d.ts +39 -0
- package/dist/plugins/table/TableHelpers.d.ts.map +1 -0
- package/dist/plugins/table/TableNavigation.d.ts +4 -0
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -0
- package/dist/plugins/table/TableNodeViews.d.ts +18 -0
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -0
- package/dist/plugins/table/TablePlugin.d.ts +39 -0
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -0
- package/dist/plugins/table/TableSelection.d.ts +26 -0
- package/dist/plugins/table/TableSelection.d.ts.map +1 -0
- package/dist/plugins/table/TableTestUtils.d.ts +45 -0
- package/dist/plugins/table/TableTestUtils.d.ts.map +1 -0
- package/dist/plugins/table/index.d.ts +4 -0
- package/dist/plugins/table/index.d.ts.map +1 -0
- package/dist/plugins/table.mjs +663 -0
- package/dist/plugins/table.mjs.map +1 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts +37 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -0
- package/dist/plugins/text-color/index.d.ts +2 -0
- package/dist/plugins/text-color/index.d.ts.map +1 -0
- package/dist/plugins/text-color.mjs +126 -0
- package/dist/plugins/text-color.mjs.map +1 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +34 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -0
- package/dist/plugins/text-formatting/index.d.ts +2 -0
- package/dist/plugins/text-formatting/index.d.ts.map +1 -0
- package/dist/plugins/text-formatting.mjs +52 -0
- package/dist/plugins/text-formatting.mjs.map +1 -0
- package/dist/plugins/toolbar/ToolbarItem.d.ts +66 -0
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts +25 -0
- package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +47 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +25 -0
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts +19 -0
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts +17 -0
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -0
- package/dist/plugins/toolbar/index.d.ts +4 -0
- package/dist/plugins/toolbar/index.d.ts.map +1 -0
- package/dist/plugins/toolbar.mjs +8 -0
- package/dist/plugins/toolbar.mjs.map +1 -0
- package/dist/state/EditorState.d.ts +40 -0
- package/dist/state/EditorState.d.ts.map +1 -0
- package/dist/state/History.d.ts +38 -0
- package/dist/state/History.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts +5 -0
- package/dist/state/StepApplication.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +185 -0
- package/dist/state/Transaction.d.ts.map +1 -0
- package/dist/test/PluginTestUtils.d.ts +127 -0
- package/dist/test/PluginTestUtils.d.ts.map +1 -0
- package/dist/test/TestUtils.d.ts +153 -0
- package/dist/test/TestUtils.d.ts.map +1 -0
- package/dist/view/EditorView.d.ts +74 -0
- package/dist/view/EditorView.d.ts.map +1 -0
- package/dist/view/NodeView.d.ts +18 -0
- package/dist/view/NodeView.d.ts.map +1 -0
- package/dist/view/Reconciler.d.ts +23 -0
- package/dist/view/Reconciler.d.ts.map +1 -0
- package/dist/view/SelectionSync.d.ts +8 -0
- package/dist/view/SelectionSync.d.ts.map +1 -0
- package/package.json +112 -11
- package/dist/notectl-core.js +0 -1463
- package/dist/notectl-core.js.map +0 -1
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { g as t, b as n, c as e, d as o, a as r, h as c, e as i, f as s, j as l, k as f, l as u } from "./Document-CI3iCwEP.mjs";
|
|
2
|
+
import { f as d } from "./NodeResolver-D68ZLXti.mjs";
|
|
3
|
+
import { i as a, a as k, c as h, s as b, b as g, d as m } from "./Selection-D5ZjXoB7.mjs";
|
|
4
|
+
import { m as p, i as I } from "./TypeBrands-C09nE2qO.mjs";
|
|
5
|
+
function B() {
|
|
6
|
+
return { nodeTypes: ["paragraph"], markTypes: ["bold", "italic", "underline"], getNodeSpec: () => {
|
|
7
|
+
} };
|
|
8
|
+
}
|
|
9
|
+
function S(t2) {
|
|
10
|
+
return { nodeTypes: t2.getNodeTypes(), markTypes: t2.getMarkTypes(), getNodeSpec: (n2) => t2.getNodeSpec(n2) };
|
|
11
|
+
}
|
|
12
|
+
function x(t2, n2) {
|
|
13
|
+
return t2.markTypes.includes(n2);
|
|
14
|
+
}
|
|
15
|
+
function O(t2, n2) {
|
|
16
|
+
return t2.nodeTypes.includes(n2);
|
|
17
|
+
}
|
|
18
|
+
const T = { bold: true, italic: true, underline: true };
|
|
19
|
+
function N(t2, n2) {
|
|
20
|
+
const e2 = t2.getBlock(n2);
|
|
21
|
+
if (!e2) return false;
|
|
22
|
+
const o2 = t2.schema.getNodeSpec;
|
|
23
|
+
return !!o2 && true === o2(e2.type)?.isVoid;
|
|
24
|
+
}
|
|
25
|
+
function y(c2, i2) {
|
|
26
|
+
const s2 = d(c2.doc, i2.nodeId);
|
|
27
|
+
if (!s2) return null;
|
|
28
|
+
const l2 = s2.length > 1 ? s2.slice(0, -1) : [], f2 = 0 === l2.length ? c2.doc.children : (() => {
|
|
29
|
+
const t2 = c2.getBlock(l2[l2.length - 1]);
|
|
30
|
+
return t2 ? t2.children : [];
|
|
31
|
+
})(), u2 = f2.findIndex((t2) => "id" in t2 && t2.id === i2.nodeId);
|
|
32
|
+
if (u2 < 0) return null;
|
|
33
|
+
const a2 = c2.transaction("input");
|
|
34
|
+
if (1 === f2.length && 0 === l2.length) {
|
|
35
|
+
const t2 = n();
|
|
36
|
+
return a2.insertNode(l2, 0, e("paragraph", [o("")], t2)), a2.removeNode(l2, 1), a2.setSelection(h(t2, 0)), a2.build();
|
|
37
|
+
}
|
|
38
|
+
a2.removeNode(l2, u2);
|
|
39
|
+
const k2 = f2[u2 - 1];
|
|
40
|
+
if (k2 && r(k2)) {
|
|
41
|
+
const n2 = (function(t2) {
|
|
42
|
+
let n3 = t2;
|
|
43
|
+
for (; ; ) {
|
|
44
|
+
let t3;
|
|
45
|
+
for (let e2 = n3.children.length - 1; e2 >= 0; e2--) {
|
|
46
|
+
const o2 = n3.children[e2];
|
|
47
|
+
if (o2 && r(o2)) {
|
|
48
|
+
t3 = o2;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!t3) return n3.id;
|
|
53
|
+
n3 = t3;
|
|
54
|
+
}
|
|
55
|
+
})(k2);
|
|
56
|
+
if (n2) {
|
|
57
|
+
const e2 = c2.getBlock(n2), o2 = e2 ? t(e2) : 0;
|
|
58
|
+
a2.setSelection(h(n2, o2));
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
const t2 = f2[u2 + 1];
|
|
62
|
+
if (t2 && r(t2)) {
|
|
63
|
+
const n2 = (function(t3) {
|
|
64
|
+
let n3 = t3;
|
|
65
|
+
for (; ; ) {
|
|
66
|
+
const t4 = n3.children.find((t5) => r(t5));
|
|
67
|
+
if (!t4) return n3.id;
|
|
68
|
+
n3 = t4;
|
|
69
|
+
}
|
|
70
|
+
})(t2);
|
|
71
|
+
n2 && a2.setSelection(h(n2, 0));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return a2.build();
|
|
75
|
+
}
|
|
76
|
+
function A(n2, e2, o2) {
|
|
77
|
+
const r2 = n2.getBlockOrder(), c2 = r2.indexOf(e2.from.blockId), i2 = r2.indexOf(e2.to.blockId);
|
|
78
|
+
for (let s2 = c2; s2 <= i2; s2++) {
|
|
79
|
+
const l2 = r2[s2];
|
|
80
|
+
if (!l2) continue;
|
|
81
|
+
const f2 = n2.getBlock(l2);
|
|
82
|
+
if (!f2) continue;
|
|
83
|
+
const u2 = s2 === c2 ? e2.from.offset : 0, d2 = s2 === i2 ? e2.to.offset : t(f2);
|
|
84
|
+
u2 !== d2 && o2(l2, u2, d2);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function M(t2, n2, e2 = T) {
|
|
88
|
+
if ((function(t3, n3) {
|
|
89
|
+
const e3 = t3;
|
|
90
|
+
return "bold" === e3 ? !n3.bold : "italic" === e3 ? !n3.italic : "underline" === e3 && !n3.underline;
|
|
91
|
+
})(n2, e2)) return null;
|
|
92
|
+
if (!x(t2.schema, n2)) return null;
|
|
93
|
+
if (a(t2.selection)) return null;
|
|
94
|
+
const o2 = { type: n2 }, r2 = t2.selection;
|
|
95
|
+
if (k(r2)) {
|
|
96
|
+
const e3 = t2.getBlock(r2.anchor.blockId);
|
|
97
|
+
if (!e3) return null;
|
|
98
|
+
const s3 = t2.storedMarks ?? i(e3, r2.anchor.offset), l3 = c(s3, n2) ? s3.filter((t3) => t3.type !== n2) : [...s3, o2];
|
|
99
|
+
return t2.transaction("command").setStoredMarks(l3, t2.storedMarks).setSelection(r2).build();
|
|
100
|
+
}
|
|
101
|
+
const s2 = b(r2, t2.getBlockOrder()), l2 = t2.transaction("command"), f2 = j(t2, n2);
|
|
102
|
+
return A(t2, s2, (t3, n3, e3) => {
|
|
103
|
+
f2 ? l2.removeMark(t3, n3, e3, o2) : l2.addMark(t3, n3, e3, o2);
|
|
104
|
+
}), l2.setSelection(r2), l2.build();
|
|
105
|
+
}
|
|
106
|
+
function j(n2, e2) {
|
|
107
|
+
const o2 = n2.selection;
|
|
108
|
+
if (a(o2)) return false;
|
|
109
|
+
const r2 = n2.getBlockOrder(), c2 = b(o2, r2), i2 = r2.indexOf(c2.from.blockId), s2 = r2.indexOf(c2.to.blockId);
|
|
110
|
+
for (let o3 = i2; o3 <= s2; o3++) {
|
|
111
|
+
const l2 = r2[o3];
|
|
112
|
+
if (!l2) continue;
|
|
113
|
+
const f2 = n2.getBlock(l2);
|
|
114
|
+
if (!f2) continue;
|
|
115
|
+
const u2 = t(f2);
|
|
116
|
+
if (!v(f2, o3 === i2 ? c2.from.offset : 0, o3 === s2 ? c2.to.offset : u2, e2)) return false;
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
function v(t2, n2, e2, o2) {
|
|
121
|
+
if (n2 === e2) return false;
|
|
122
|
+
let r2 = 0;
|
|
123
|
+
for (const i2 of l(t2)) if (f(i2)) {
|
|
124
|
+
const t3 = r2 + i2.text.length;
|
|
125
|
+
if (t3 > n2 && r2 < e2 && !c(i2.marks, o2)) return false;
|
|
126
|
+
r2 = t3;
|
|
127
|
+
} else r2 += 1;
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
function P(t2, n2) {
|
|
131
|
+
return M(t2, p("bold"), n2);
|
|
132
|
+
}
|
|
133
|
+
function w(t2, n2) {
|
|
134
|
+
return M(t2, p("italic"), n2);
|
|
135
|
+
}
|
|
136
|
+
function q(t2, n2) {
|
|
137
|
+
return M(t2, p("underline"), n2);
|
|
138
|
+
}
|
|
139
|
+
function z(t2, r2, c2 = "input") {
|
|
140
|
+
const s2 = t2.selection;
|
|
141
|
+
if (a(s2)) return (function(t3, r3, c3, i2) {
|
|
142
|
+
const s3 = d(t3.doc, r3.nodeId), l3 = s3 && s3.length > 1 ? s3.slice(0, -1) : [], f3 = 0 === l3.length ? t3.doc.children : (() => {
|
|
143
|
+
const n2 = t3.getBlock(l3[l3.length - 1]);
|
|
144
|
+
return n2 ? n2.children : [];
|
|
145
|
+
})(), u3 = f3.findIndex((t4) => "id" in t4 && t4.id === r3.nodeId), a2 = n(), k2 = t3.transaction(i2), b2 = u3 >= 0 ? u3 + 1 : f3.length;
|
|
146
|
+
return k2.insertNode(l3, b2, e("paragraph", [o("")], a2)), k2.insertText(a2, 0, c3, []), k2.setSelection(h(a2, c3.length)), k2.build();
|
|
147
|
+
})(t2, s2, r2, c2);
|
|
148
|
+
const l2 = t2.transaction(c2), f2 = (function(t3) {
|
|
149
|
+
if (t3.storedMarks) return t3.storedMarks;
|
|
150
|
+
if (a(t3.selection)) return [];
|
|
151
|
+
const n2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
152
|
+
return n2 ? i(n2, t3.selection.anchor.offset) : [];
|
|
153
|
+
})(t2);
|
|
154
|
+
k(s2) || Y(t2, l2);
|
|
155
|
+
const u2 = k(s2) ? null : b(s2, t2.getBlockOrder()), g2 = u2 ? u2.from.blockId : s2.anchor.blockId, m2 = u2 ? u2.from.offset : s2.anchor.offset;
|
|
156
|
+
return l2.insertText(g2, m2, r2, f2), l2.setSelection(h(g2, m2 + r2.length)), l2.build();
|
|
157
|
+
}
|
|
158
|
+
function D(t2) {
|
|
159
|
+
if (a(t2.selection)) return y(t2, t2.selection);
|
|
160
|
+
if (k(t2.selection)) return null;
|
|
161
|
+
const n2 = t2.transaction("input");
|
|
162
|
+
Y(t2, n2);
|
|
163
|
+
const e2 = b(t2.selection, t2.getBlockOrder());
|
|
164
|
+
return n2.setSelection(h(e2.from.blockId, e2.from.offset)), n2.build();
|
|
165
|
+
}
|
|
166
|
+
function R(t2) {
|
|
167
|
+
const n2 = t2.selection;
|
|
168
|
+
if (a(n2)) return y(t2, n2);
|
|
169
|
+
if (!k(n2)) return D(t2);
|
|
170
|
+
const e2 = t2.getBlock(n2.anchor.blockId);
|
|
171
|
+
return e2 ? n2.anchor.offset > 0 ? t2.transaction("input").deleteTextAt(e2.id, n2.anchor.offset - 1, n2.anchor.offset).setSelection(h(e2.id, n2.anchor.offset - 1)).build() : Q(t2) : null;
|
|
172
|
+
}
|
|
173
|
+
function V(n2) {
|
|
174
|
+
const e2 = n2.selection;
|
|
175
|
+
if (a(e2)) return y(n2, e2);
|
|
176
|
+
if (!k(e2)) return D(n2);
|
|
177
|
+
const o2 = n2.getBlock(e2.anchor.blockId);
|
|
178
|
+
if (!o2) return null;
|
|
179
|
+
const r2 = t(o2);
|
|
180
|
+
return e2.anchor.offset < r2 ? n2.transaction("input").deleteTextAt(o2.id, e2.anchor.offset, e2.anchor.offset + 1).setSelection(h(o2.id, e2.anchor.offset)).build() : U(n2);
|
|
181
|
+
}
|
|
182
|
+
function _(t2) {
|
|
183
|
+
const n2 = t2.selection;
|
|
184
|
+
if (a(n2)) return y(t2, n2);
|
|
185
|
+
if (!k(n2)) return D(t2);
|
|
186
|
+
const e2 = t2.getBlock(n2.anchor.blockId);
|
|
187
|
+
if (!e2) return null;
|
|
188
|
+
if (0 === n2.anchor.offset) return Q(t2);
|
|
189
|
+
const o2 = (function(t3, n3) {
|
|
190
|
+
let e3 = n3 - 1;
|
|
191
|
+
for (; e3 >= 0; ) {
|
|
192
|
+
const n4 = u(t3, e3);
|
|
193
|
+
if (!n4 || "inline" === n4.kind) break;
|
|
194
|
+
if (!/\s/.test(n4.char)) break;
|
|
195
|
+
e3--;
|
|
196
|
+
}
|
|
197
|
+
if (e3 >= 0) {
|
|
198
|
+
const n4 = u(t3, e3);
|
|
199
|
+
if ("inline" === n4?.kind) return e3;
|
|
200
|
+
}
|
|
201
|
+
for (; e3 >= 0; ) {
|
|
202
|
+
const n4 = u(t3, e3);
|
|
203
|
+
if (!n4 || "inline" === n4.kind) break;
|
|
204
|
+
if (/\s/.test(n4.char)) break;
|
|
205
|
+
e3--;
|
|
206
|
+
}
|
|
207
|
+
return e3 + 1;
|
|
208
|
+
})(e2, n2.anchor.offset);
|
|
209
|
+
return t2.transaction("input").deleteTextAt(e2.id, o2, n2.anchor.offset).setSelection(h(e2.id, o2)).build();
|
|
210
|
+
}
|
|
211
|
+
function C(n2) {
|
|
212
|
+
const e2 = n2.selection;
|
|
213
|
+
if (a(e2)) return y(n2, e2);
|
|
214
|
+
if (!k(e2)) return D(n2);
|
|
215
|
+
const o2 = n2.getBlock(e2.anchor.blockId);
|
|
216
|
+
if (!o2) return null;
|
|
217
|
+
const r2 = t(o2);
|
|
218
|
+
if (e2.anchor.offset === r2) return U(n2);
|
|
219
|
+
const c2 = (function(n3, e3) {
|
|
220
|
+
const o3 = t(n3);
|
|
221
|
+
let r3 = e3;
|
|
222
|
+
for (; r3 < o3; ) {
|
|
223
|
+
const t2 = u(n3, r3);
|
|
224
|
+
if (!t2 || "inline" === t2.kind) break;
|
|
225
|
+
if (/\s/.test(t2.char)) break;
|
|
226
|
+
r3++;
|
|
227
|
+
}
|
|
228
|
+
if (r3 === e3 && r3 < o3) {
|
|
229
|
+
const t2 = u(n3, r3);
|
|
230
|
+
if ("inline" === t2?.kind) return r3 + 1;
|
|
231
|
+
}
|
|
232
|
+
for (; r3 < o3; ) {
|
|
233
|
+
const t2 = u(n3, r3);
|
|
234
|
+
if (!t2 || "inline" === t2.kind) break;
|
|
235
|
+
if (!/\s/.test(t2.char)) break;
|
|
236
|
+
r3++;
|
|
237
|
+
}
|
|
238
|
+
return r3;
|
|
239
|
+
})(o2, e2.anchor.offset);
|
|
240
|
+
return n2.transaction("input").deleteTextAt(o2.id, e2.anchor.offset, c2).setSelection(h(o2.id, e2.anchor.offset)).build();
|
|
241
|
+
}
|
|
242
|
+
function E(t2) {
|
|
243
|
+
const n2 = t2.selection;
|
|
244
|
+
if (a(n2)) return y(t2, n2);
|
|
245
|
+
if (!k(n2)) return D(t2);
|
|
246
|
+
const e2 = t2.getBlock(n2.anchor.blockId);
|
|
247
|
+
return e2 ? 0 === n2.anchor.offset ? Q(t2) : t2.transaction("input").deleteTextAt(e2.id, 0, n2.anchor.offset).setSelection(h(e2.id, 0)).build() : null;
|
|
248
|
+
}
|
|
249
|
+
function F(n2) {
|
|
250
|
+
const e2 = n2.selection;
|
|
251
|
+
if (a(e2)) return y(n2, e2);
|
|
252
|
+
if (!k(e2)) return D(n2);
|
|
253
|
+
const o2 = n2.getBlock(e2.anchor.blockId);
|
|
254
|
+
if (!o2) return null;
|
|
255
|
+
const r2 = t(o2);
|
|
256
|
+
return e2.anchor.offset === r2 ? U(n2) : n2.transaction("input").deleteTextAt(o2.id, e2.anchor.offset, r2).setSelection(h(o2.id, e2.anchor.offset)).build();
|
|
257
|
+
}
|
|
258
|
+
function G(t2) {
|
|
259
|
+
const r2 = t2.selection;
|
|
260
|
+
if (a(r2)) return (function(t3, r3) {
|
|
261
|
+
const c3 = d(t3.doc, r3.nodeId);
|
|
262
|
+
if (!c3) return null;
|
|
263
|
+
const i3 = c3.length > 1 ? c3.slice(0, -1) : [], s3 = (0 === i3.length ? t3.doc.children : (() => {
|
|
264
|
+
const n2 = t3.getBlock(i3[i3.length - 1]);
|
|
265
|
+
return n2 ? n2.children : [];
|
|
266
|
+
})()).findIndex((t4) => "id" in t4 && t4.id === r3.nodeId);
|
|
267
|
+
if (s3 < 0) return null;
|
|
268
|
+
const l3 = n(), f2 = t3.transaction("input");
|
|
269
|
+
return f2.insertNode(i3, s3 + 1, e("paragraph", [o("")], l3)), f2.setSelection(h(l3, 0)), f2.build();
|
|
270
|
+
})(t2, r2);
|
|
271
|
+
const c2 = t2.transaction("input");
|
|
272
|
+
k(r2) || Y(t2, c2);
|
|
273
|
+
const i2 = k(r2) ? r2.anchor.blockId : b(r2, t2.getBlockOrder()).from.blockId, s2 = k(r2) ? r2.anchor.offset : b(r2, t2.getBlockOrder()).from.offset, l2 = n();
|
|
274
|
+
return c2.splitBlock(i2, s2, l2), c2.setSelection(h(l2, 0)), c2.build();
|
|
275
|
+
}
|
|
276
|
+
function H(t2) {
|
|
277
|
+
const n2 = t2.selection;
|
|
278
|
+
if (a(n2)) return null;
|
|
279
|
+
const e2 = t2.transaction("input");
|
|
280
|
+
k(n2) || Y(t2, e2);
|
|
281
|
+
const o2 = k(n2) ? null : b(n2, t2.getBlockOrder()), r2 = o2 ? o2.from.blockId : n2.anchor.blockId, c2 = o2 ? o2.from.offset : n2.anchor.offset, i2 = s(I("hard_break"));
|
|
282
|
+
return e2.insertInlineNode(r2, c2, i2), e2.setSelection(h(r2, c2 + 1)), e2.build();
|
|
283
|
+
}
|
|
284
|
+
function J(t2, n2, e2) {
|
|
285
|
+
const o2 = t2.getNodePath(n2), r2 = t2.getNodePath(e2);
|
|
286
|
+
if (!o2 || !r2) return false;
|
|
287
|
+
if (o2.length !== r2.length) return false;
|
|
288
|
+
for (let t3 = 0; t3 < o2.length - 1; t3++) if (o2[t3] !== r2[t3]) return false;
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
function K(t2, n2) {
|
|
292
|
+
const e2 = t2.schema.getNodeSpec;
|
|
293
|
+
if (!e2) return false;
|
|
294
|
+
const o2 = t2.getNodePath(n2);
|
|
295
|
+
if (!o2 || o2.length <= 1) return false;
|
|
296
|
+
for (let n3 = 0; n3 < o2.length - 1; n3++) {
|
|
297
|
+
const r2 = o2[n3];
|
|
298
|
+
if (!r2) continue;
|
|
299
|
+
const c2 = t2.getBlock(r2);
|
|
300
|
+
if (!c2) continue;
|
|
301
|
+
const i2 = e2(c2.type);
|
|
302
|
+
if (i2?.isolating) return true;
|
|
303
|
+
}
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
function L(t2, n2) {
|
|
307
|
+
const e2 = t2.schema.getNodeSpec;
|
|
308
|
+
if (!e2) return false;
|
|
309
|
+
const o2 = t2.getBlock(n2);
|
|
310
|
+
return !!o2 && true === e2(o2.type)?.isolating;
|
|
311
|
+
}
|
|
312
|
+
function Q(n2) {
|
|
313
|
+
const e2 = n2.selection;
|
|
314
|
+
if (a(e2)) return null;
|
|
315
|
+
const o2 = n2.getBlockOrder(), r2 = o2.indexOf(e2.anchor.blockId);
|
|
316
|
+
if (r2 <= 0) return null;
|
|
317
|
+
const c2 = o2[r2 - 1];
|
|
318
|
+
if (!c2) return null;
|
|
319
|
+
if (L(n2, e2.anchor.blockId) || L(n2, c2)) return null;
|
|
320
|
+
if (!J(n2, e2.anchor.blockId, c2) && K(n2, e2.anchor.blockId)) return null;
|
|
321
|
+
if (N(n2, c2)) {
|
|
322
|
+
const t2 = d(n2.doc, c2) ?? [];
|
|
323
|
+
return n2.transaction("input").setSelection(g(c2, t2)).build();
|
|
324
|
+
}
|
|
325
|
+
const i2 = n2.getBlock(c2);
|
|
326
|
+
if (!i2) return null;
|
|
327
|
+
const s2 = t(i2);
|
|
328
|
+
return n2.transaction("input").mergeBlocksAt(c2, e2.anchor.blockId).setSelection(h(c2, s2)).build();
|
|
329
|
+
}
|
|
330
|
+
function U(t2) {
|
|
331
|
+
const n2 = t2.selection;
|
|
332
|
+
if (a(n2)) return null;
|
|
333
|
+
const e2 = t2.getBlockOrder(), o2 = e2.indexOf(n2.anchor.blockId);
|
|
334
|
+
if (o2 >= e2.length - 1) return null;
|
|
335
|
+
const r2 = e2[o2 + 1];
|
|
336
|
+
if (!r2) return null;
|
|
337
|
+
if (L(t2, n2.anchor.blockId) || L(t2, r2)) return null;
|
|
338
|
+
if (!J(t2, n2.anchor.blockId, r2) && K(t2, n2.anchor.blockId)) return null;
|
|
339
|
+
if (N(t2, r2)) {
|
|
340
|
+
const n3 = d(t2.doc, r2) ?? [];
|
|
341
|
+
return t2.transaction("input").setSelection(g(r2, n3)).build();
|
|
342
|
+
}
|
|
343
|
+
return t2.transaction("input").mergeBlocksAt(n2.anchor.blockId, r2).setSelection(h(n2.anchor.blockId, n2.anchor.offset)).build();
|
|
344
|
+
}
|
|
345
|
+
function W(n2) {
|
|
346
|
+
const e2 = n2.doc.children, o2 = e2[0], r2 = e2[e2.length - 1];
|
|
347
|
+
if (!o2 || !r2) return n2.transaction("command").setSelection(n2.selection).build();
|
|
348
|
+
const c2 = t(r2);
|
|
349
|
+
return n2.transaction("command").setSelection(m({ blockId: o2.id, offset: 0 }, { blockId: r2.id, offset: c2 })).build();
|
|
350
|
+
}
|
|
351
|
+
function X(t2, n2) {
|
|
352
|
+
const e2 = t2.selection;
|
|
353
|
+
if (a(e2)) return false;
|
|
354
|
+
if (k(e2)) {
|
|
355
|
+
if (t2.storedMarks) return c(t2.storedMarks, n2);
|
|
356
|
+
const o2 = t2.getBlock(e2.anchor.blockId);
|
|
357
|
+
if (!o2) return false;
|
|
358
|
+
const r2 = i(o2, e2.anchor.offset);
|
|
359
|
+
return c(r2, n2);
|
|
360
|
+
}
|
|
361
|
+
return j(t2, n2);
|
|
362
|
+
}
|
|
363
|
+
function Y(n2, e2) {
|
|
364
|
+
if (a(n2.selection)) return;
|
|
365
|
+
const o2 = n2.getBlockOrder(), r2 = b(n2.selection, o2), c2 = o2.indexOf(r2.from.blockId), i2 = o2.indexOf(r2.to.blockId);
|
|
366
|
+
if (c2 === i2) e2.deleteTextAt(r2.from.blockId, r2.from.offset, r2.to.offset);
|
|
367
|
+
else {
|
|
368
|
+
const s2 = n2.getBlock(r2.from.blockId);
|
|
369
|
+
if (!s2) return;
|
|
370
|
+
const l2 = t(s2);
|
|
371
|
+
r2.from.offset < l2 && e2.deleteTextAt(r2.from.blockId, r2.from.offset, l2), r2.to.offset > 0 && e2.deleteTextAt(r2.to.blockId, 0, r2.to.offset);
|
|
372
|
+
for (let s3 = c2 + 1; s3 < i2; s3++) {
|
|
373
|
+
const c3 = o2[s3];
|
|
374
|
+
if (!c3) continue;
|
|
375
|
+
const i3 = n2.getBlock(c3);
|
|
376
|
+
if (!i3) continue;
|
|
377
|
+
const l3 = t(i3);
|
|
378
|
+
l3 > 0 && e2.deleteTextAt(c3, 0, l3), e2.mergeBlocksAt(r2.from.blockId, c3);
|
|
379
|
+
}
|
|
380
|
+
e2.mergeBlocksAt(r2.from.blockId, r2.to.blockId);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function Z(n2, e2) {
|
|
384
|
+
const o2 = n2.selection, r2 = n2.getBlockOrder();
|
|
385
|
+
if (a(o2)) {
|
|
386
|
+
const c3 = r2.indexOf(o2.nodeId);
|
|
387
|
+
if ("left" === e2 || "up" === e2) {
|
|
388
|
+
if (c3 > 0) {
|
|
389
|
+
const e3 = r2[c3 - 1];
|
|
390
|
+
if (!e3) return null;
|
|
391
|
+
if (N(n2, e3)) {
|
|
392
|
+
const t2 = d(n2.doc, e3) ?? [];
|
|
393
|
+
return n2.transaction("input").setSelection(g(e3, t2)).build();
|
|
394
|
+
}
|
|
395
|
+
const o3 = n2.getBlock(e3), i3 = o3 ? t(o3) : 0;
|
|
396
|
+
return n2.transaction("input").setSelection(h(e3, i3)).build();
|
|
397
|
+
}
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
if (c3 < r2.length - 1) {
|
|
401
|
+
const t2 = r2[c3 + 1];
|
|
402
|
+
if (!t2) return null;
|
|
403
|
+
if (N(n2, t2)) {
|
|
404
|
+
const e3 = d(n2.doc, t2) ?? [];
|
|
405
|
+
return n2.transaction("input").setSelection(g(t2, e3)).build();
|
|
406
|
+
}
|
|
407
|
+
return n2.transaction("input").setSelection(h(t2, 0)).build();
|
|
408
|
+
}
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
if (!k(o2)) return null;
|
|
412
|
+
const c2 = r2.indexOf(o2.anchor.blockId), i2 = n2.getBlock(o2.anchor.blockId);
|
|
413
|
+
if (!i2) return null;
|
|
414
|
+
const s2 = t(i2);
|
|
415
|
+
if (("right" === e2 || "down" === e2) && o2.anchor.offset === s2 && c2 < r2.length - 1) {
|
|
416
|
+
const t2 = r2[c2 + 1];
|
|
417
|
+
if (t2 && N(n2, t2)) {
|
|
418
|
+
const e3 = d(n2.doc, t2) ?? [];
|
|
419
|
+
return n2.transaction("input").setSelection(g(t2, e3)).build();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (("left" === e2 || "up" === e2) && 0 === o2.anchor.offset && c2 > 0) {
|
|
423
|
+
const t2 = r2[c2 - 1];
|
|
424
|
+
if (t2 && N(n2, t2)) {
|
|
425
|
+
const e3 = d(n2.doc, t2) ?? [];
|
|
426
|
+
return n2.transaction("input").setSelection(g(t2, e3)).build();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
export {
|
|
432
|
+
M as A,
|
|
433
|
+
q as B,
|
|
434
|
+
y as a,
|
|
435
|
+
G as b,
|
|
436
|
+
D as c,
|
|
437
|
+
B as d,
|
|
438
|
+
R as e,
|
|
439
|
+
F as f,
|
|
440
|
+
E as g,
|
|
441
|
+
C as h,
|
|
442
|
+
z as i,
|
|
443
|
+
_ as j,
|
|
444
|
+
V as k,
|
|
445
|
+
H as l,
|
|
446
|
+
Y as m,
|
|
447
|
+
Z as n,
|
|
448
|
+
x as o,
|
|
449
|
+
O as p,
|
|
450
|
+
S as q,
|
|
451
|
+
X as r,
|
|
452
|
+
W as s,
|
|
453
|
+
A as t,
|
|
454
|
+
K as u,
|
|
455
|
+
N as v,
|
|
456
|
+
Q as w,
|
|
457
|
+
J as x,
|
|
458
|
+
P as y,
|
|
459
|
+
w as z
|
|
460
|
+
};
|
|
461
|
+
//# sourceMappingURL=Commands-DLP85Mp5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Commands-DLP85Mp5.mjs","sources":["../../src/model/Schema.ts","../../src/commands/Commands.ts"],"sourcesContent":["/**\n * Schema definition for the Notectl editor.\n * Defines which node types and marks are allowed.\n */\n\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { SchemaRegistry } from './SchemaRegistry.js';\n\nexport interface Schema {\n\treadonly nodeTypes: readonly string[];\n\treadonly markTypes: readonly string[];\n\t/** Looks up the full NodeSpec for a given type. Available when created via schemaFromRegistry. */\n\treadonly getNodeSpec?: (type: string) => NodeSpec | undefined;\n}\n\n/** Creates the default schema with paragraph nodes and bold/italic/underline marks. */\nexport function defaultSchema(): Schema {\n\treturn {\n\t\tnodeTypes: ['paragraph'],\n\t\tmarkTypes: ['bold', 'italic', 'underline'],\n\t\tgetNodeSpec: () => undefined,\n\t};\n}\n\n/** Derives a Schema from a SchemaRegistry's registered specs. */\nexport function schemaFromRegistry(registry: SchemaRegistry): Schema {\n\treturn {\n\t\tnodeTypes: registry.getNodeTypes(),\n\t\tmarkTypes: registry.getMarkTypes(),\n\t\tgetNodeSpec: (type: string) => registry.getNodeSpec(type),\n\t};\n}\n\n/** Checks whether the given mark type is allowed by the schema. */\nexport function isMarkAllowed(schema: Schema, markType: string): boolean {\n\treturn schema.markTypes.includes(markType);\n}\n\n/** Checks whether the given node type is allowed by the schema. */\nexport function isNodeTypeAllowed(schema: Schema, nodeType: string): boolean {\n\treturn schema.nodeTypes.includes(nodeType);\n}\n","/**\n * Editor commands for formatting, text manipulation, and history.\n */\n\nimport {\n\ttype BlockNode,\n\ttype Mark,\n\ttype MarkType,\n\tcreateBlockNode,\n\tcreateInlineNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n\tgetContentAtOffset,\n\tgetInlineChildren,\n\thasMark,\n\tisBlockNode,\n\tisTextNode,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport { isMarkAllowed } from '../model/Schema.js';\nimport type { NodeSelection, SelectionRange } from '../model/Selection.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisNodeSelection,\n\tselectionRange,\n} from '../model/Selection.js';\nimport { type BlockId, inlineType, markType as mkType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\n\n// --- Feature Configuration ---\n\nexport interface FeatureConfig {\n\treadonly bold: boolean;\n\treadonly italic: boolean;\n\treadonly underline: boolean;\n}\n\nconst defaultFeatures: FeatureConfig = { bold: true, italic: true, underline: true };\n\n// --- Void Block Helpers ---\n\n/** Returns true if the block with the given ID is a void block (e.g. image, HR). */\nexport function isVoidBlock(state: EditorState, bid: BlockId): boolean {\n\tconst block = state.getBlock(bid);\n\tif (!block) return false;\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\treturn getNodeSpec(block.type)?.isVoid === true;\n}\n\n/**\n * Deletes the void block targeted by a NodeSelection and places cursor\n * on the adjacent block. If it's the only block, replaces with empty paragraph.\n */\nexport function deleteNodeSelection(state: EditorState, sel: NodeSelection): Transaction | null {\n\tconst path = findNodePath(state.doc, sel.nodeId);\n\tif (!path) return null;\n\n\t// Determine parent path (all elements except the last)\n\tconst parentPath: BlockId[] = path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\n\t// Determine index among siblings\n\tconst siblings =\n\t\tparentPath.length === 0\n\t\t\t? state.doc.children\n\t\t\t: (() => {\n\t\t\t\t\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\t\t\t\t\treturn parent ? parent.children : [];\n\t\t\t\t})();\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.nodeId);\n\tif (index < 0) return null;\n\n\tconst builder = state.transaction('input');\n\n\t// If this is the only block in the document, insert empty paragraph first\n\tif (siblings.length === 1 && parentPath.length === 0) {\n\t\tconst newId = generateBlockId();\n\t\tbuilder.insertNode(\n\t\t\tparentPath,\n\t\t\t0,\n\t\t\tcreateBlockNode(\n\t\t\t\t'paragraph' as import('../model/TypeBrands.js').NodeTypeName,\n\t\t\t\t[createTextNode('')],\n\t\t\t\tnewId,\n\t\t\t),\n\t\t);\n\t\tbuilder.removeNode(parentPath, 1);\n\t\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\t\treturn builder.build();\n\t}\n\n\tbuilder.removeNode(parentPath, index);\n\n\t// Find where to place cursor: prefer previous sibling leaf, else next sibling leaf.\n\tconst prevSibling = siblings[index - 1];\n\tif (prevSibling && isBlockNode(prevSibling)) {\n\t\tconst prevLeafId = findLastLeafBlockId(prevSibling);\n\t\tif (prevLeafId) {\n\t\t\tconst prevLeaf = state.getBlock(prevLeafId);\n\t\t\tconst prevLen = prevLeaf ? getBlockLength(prevLeaf) : 0;\n\t\t\tbuilder.setSelection(createCollapsedSelection(prevLeafId, prevLen));\n\t\t}\n\t} else {\n\t\tconst nextSibling = siblings[index + 1];\n\t\tif (nextSibling && isBlockNode(nextSibling)) {\n\t\t\tconst nextLeafId = findFirstLeafBlockId(nextSibling);\n\t\t\tif (nextLeafId) {\n\t\t\t\tbuilder.setSelection(createCollapsedSelection(nextLeafId, 0));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn builder.build();\n}\n\nfunction findFirstLeafBlockId(node: BlockNode): BlockId {\n\tlet current: BlockNode = node;\n\twhile (true) {\n\t\tconst firstBlockChild = current.children.find((child): child is BlockNode =>\n\t\t\tisBlockNode(child),\n\t\t);\n\t\tif (!firstBlockChild) return current.id;\n\t\tcurrent = firstBlockChild;\n\t}\n}\n\nfunction findLastLeafBlockId(node: BlockNode): BlockId {\n\tlet current: BlockNode = node;\n\twhile (true) {\n\t\tlet lastBlockChild: BlockNode | undefined;\n\t\tfor (let i = current.children.length - 1; i >= 0; i--) {\n\t\t\tconst child = current.children[i];\n\t\t\tif (child && isBlockNode(child)) {\n\t\t\t\tlastBlockChild = child;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!lastBlockChild) return current.id;\n\t\tcurrent = lastBlockChild;\n\t}\n}\n\n// --- Range Iteration ---\n\n/**\n * Iterates over each block in the given selection range, invoking the callback\n * with the block ID, per-block start offset, and per-block end offset.\n * Blocks where `from === to` are skipped automatically.\n */\nexport function forEachBlockInRange(\n\tstate: EditorState,\n\trange: SelectionRange,\n\tcallback: (blockId: BlockId, from: number, to: number) => void,\n): void {\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst fromIdx: number = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx: number = blockOrder.indexOf(range.to.blockId);\n\n\tfor (let i: number = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId: BlockId | undefined = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\n\t\tconst from: number = i === fromIdx ? range.from.offset : 0;\n\t\tconst to: number = i === toIdx ? range.to.offset : getBlockLength(block);\n\n\t\tif (from === to) continue;\n\t\tcallback(blockId, from, to);\n\t}\n}\n\n// --- Mark Commands ---\n\n/**\n * Toggles a mark on the current selection.\n * If collapsed, toggles stored marks. If range, applies/removes from text.\n */\nexport function toggleMark(\n\tstate: EditorState,\n\tmarkType: MarkType,\n\tfeatures: FeatureConfig = defaultFeatures,\n): Transaction | null {\n\tif (isFeatureGated(markType, features)) return null;\n\tif (!isMarkAllowed(state.schema, markType)) return null;\n\tif (isNodeSelection(state.selection)) return null;\n\n\tconst mark: Mark = { type: markType };\n\tconst sel = state.selection;\n\n\tif (isCollapsed(sel)) {\n\t\t// Toggle stored marks\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return null;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tconst hasIt = hasMark(currentMarks, markType);\n\t\tconst newMarks = hasIt\n\t\t\t? currentMarks.filter((m) => m.type !== markType)\n\t\t\t: [...currentMarks, mark];\n\n\t\treturn state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t}\n\n\t// Range selection — apply/remove mark to all blocks in range\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\t// Determine if we should add or remove\n\tconst shouldRemove = isMarkActiveInRange(state, markType);\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tif (shouldRemove) {\n\t\t\tbuilder.removeMark(blockId, from, to, mark);\n\t\t} else {\n\t\t\tbuilder.addMark(blockId, from, to, mark);\n\t\t}\n\t});\n\n\tbuilder.setSelection(sel);\n\treturn builder.build();\n}\n\n/** Checks if a mark is active across the entire selection range. */\nfunction isMarkActiveInRange(state: EditorState, markType: MarkType): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst blockLen = getBlockLength(block);\n\t\tconst from = i === fromIdx ? range.from.offset : 0;\n\t\tconst to = i === toIdx ? range.to.offset : blockLen;\n\n\t\tif (!isMarkActiveInBlock(block, from, to, markType)) return false;\n\t}\n\n\treturn true;\n}\n\nfunction isMarkActiveInBlock(\n\tblock: BlockNode,\n\tfrom: number,\n\tto: number,\n\tmarkType: MarkType,\n): boolean {\n\tif (from === to) return false;\n\tlet pos = 0;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst childEnd = pos + child.text.length;\n\t\t\tif (childEnd > from && pos < to) {\n\t\t\t\tif (!hasMark(child.marks, markType)) return false;\n\t\t\t}\n\t\t\tpos = childEnd;\n\t\t} else {\n\t\t\t// InlineNode: skip (width 1, no marks)\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn true;\n}\n\nexport function toggleBold(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('bold'), features);\n}\n\nexport function toggleItalic(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('italic'), features);\n}\n\nexport function toggleUnderline(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('underline'), features);\n}\n\n// --- Text Commands ---\n\n/** Inserts text at the current selection, replacing any selected range. */\nexport function insertTextCommand(\n\tstate: EditorState,\n\ttext: string,\n\torigin: 'input' | 'paste' = 'input',\n): Transaction {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert paragraph after void block with the text\n\tif (isNodeSelection(sel)) {\n\t\treturn insertTextAfterNodeSelection(state, sel, text, origin);\n\t}\n\n\tconst builder = state.transaction(origin);\n\tconst marks = resolveActiveMarks(state);\n\n\tif (!isCollapsed(sel)) {\n\t\taddDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst range = isCollapsed(sel) ? null : selectionRange(sel, state.getBlockOrder());\n\tconst insertBlockId = range ? range.from.blockId : sel.anchor.blockId;\n\tconst insertOffset = range ? range.from.offset : sel.anchor.offset;\n\n\tbuilder.insertText(insertBlockId, insertOffset, text, marks);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + text.length));\n\n\treturn builder.build();\n}\n\n/** Deletes the current selection. */\nexport function deleteSelectionCommand(state: EditorState): Transaction | null {\n\tif (isNodeSelection(state.selection)) {\n\t\treturn deleteNodeSelection(state, state.selection);\n\t}\n\tif (isCollapsed(state.selection)) return null;\n\n\tconst builder = state.transaction('input');\n\taddDeleteSelectionSteps(state, builder);\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\tbuilder.setSelection(createCollapsedSelection(range.from.blockId, range.from.offset));\n\n\treturn builder.build();\n}\n\n/** Handles backspace key. */\nexport function deleteBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tif (sel.anchor.offset > 0) {\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.deleteTextAt(block.id, sel.anchor.offset - 1, sel.anchor.offset)\n\t\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset - 1))\n\t\t\t.build();\n\t}\n\n\t// At start of block — merge with previous\n\treturn mergeBlockBackward(state);\n}\n\n/** Handles delete key. */\nexport function deleteForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tconst blockLen = getBlockLength(block);\n\n\tif (sel.anchor.offset < blockLen) {\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.deleteTextAt(block.id, sel.anchor.offset, sel.anchor.offset + 1)\n\t\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset))\n\t\t\t.build();\n\t}\n\n\t// At end of block — merge with next\n\treturn mergeBlockForward(state);\n}\n\n/** Handles Ctrl+Backspace: delete word backward. */\nexport function deleteWordBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tif (sel.anchor.offset === 0) {\n\t\treturn mergeBlockBackward(state);\n\t}\n\n\tconst wordStart = findWordBoundaryBackward(block, sel.anchor.offset);\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, wordStart, sel.anchor.offset)\n\t\t.setSelection(createCollapsedSelection(block.id, wordStart))\n\t\t.build();\n}\n\n/** Handles Ctrl+Delete: delete word forward. */\nexport function deleteWordForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tconst blockLen = getBlockLength(block);\n\tif (sel.anchor.offset === blockLen) {\n\t\treturn mergeBlockForward(state);\n\t}\n\n\tconst wordEnd = findWordBoundaryForward(block, sel.anchor.offset);\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, sel.anchor.offset, wordEnd)\n\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Handles Cmd+Backspace: delete to start of line/block. */\nexport function deleteSoftLineBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tif (sel.anchor.offset === 0) {\n\t\treturn mergeBlockBackward(state);\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, 0, sel.anchor.offset)\n\t\t.setSelection(createCollapsedSelection(block.id, 0))\n\t\t.build();\n}\n\n/** Handles Cmd+Delete: delete to end of line/block. */\nexport function deleteSoftLineForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) {\n\t\treturn deleteNodeSelection(state, sel);\n\t}\n\n\tif (!isCollapsed(sel)) {\n\t\treturn deleteSelectionCommand(state);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tconst blockLen = getBlockLength(block);\n\tif (sel.anchor.offset === blockLen) {\n\t\treturn mergeBlockForward(state);\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, sel.anchor.offset, blockLen)\n\t\t.setSelection(createCollapsedSelection(block.id, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Splits the current block at the cursor position (Enter key). */\nexport function splitBlockCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert empty paragraph after the void block\n\tif (isNodeSelection(sel)) {\n\t\treturn insertParagraphAfterNodeSelection(state, sel);\n\t}\n\n\tconst builder = state.transaction('input');\n\n\tif (!isCollapsed(sel)) {\n\t\taddDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst blockId = isCollapsed(sel)\n\t\t? sel.anchor.blockId\n\t\t: selectionRange(sel, state.getBlockOrder()).from.blockId;\n\tconst offset = isCollapsed(sel)\n\t\t? sel.anchor.offset\n\t\t: selectionRange(sel, state.getBlockOrder()).from.offset;\n\n\tconst newBlockId = generateBlockId();\n\n\t// splitBlock operates at the same level in the tree — the StepApplication\n\t// handles this correctly because it looks up the block by ID recursively.\n\tbuilder.splitBlock(blockId, offset, newBlockId);\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\n/** Inserts a hard line break (InlineNode) at the current cursor position. */\nexport function insertHardBreakCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) return null;\n\n\tconst builder = state.transaction('input');\n\n\tif (!isCollapsed(sel)) {\n\t\taddDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst range = isCollapsed(sel) ? null : selectionRange(sel, state.getBlockOrder());\n\tconst insertBlockId: BlockId = range ? range.from.blockId : sel.anchor.blockId;\n\tconst insertOffset: number = range ? range.from.offset : sel.anchor.offset;\n\n\tconst hardBreak = createInlineNode(inlineType('hard_break'));\n\tbuilder.insertInlineNode(insertBlockId, insertOffset, hardBreak);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + 1));\n\n\treturn builder.build();\n}\n\n/** Checks whether two blocks share the same parent in the document tree. */\nexport function sharesParent(state: EditorState, blockIdA: BlockId, blockIdB: BlockId): boolean {\n\tconst pathA = state.getNodePath(blockIdA);\n\tconst pathB = state.getNodePath(blockIdB);\n\tif (!pathA || !pathB) return false;\n\tif (pathA.length !== pathB.length) return false;\n\t// Compare parent paths (all but last element)\n\tfor (let i = 0; i < pathA.length - 1; i++) {\n\t\tif (pathA[i] !== pathB[i]) return false;\n\t}\n\treturn true;\n}\n\n/** Checks whether a block is inside an isolating node (e.g. table_cell). */\nexport function isInsideIsolating(state: EditorState, blockId: BlockId): boolean {\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\tconst path = state.getNodePath(blockId);\n\tif (!path || path.length <= 1) return false;\n\n\t// Check ancestors (not the block itself)\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tconst ancestorId = path[i];\n\t\tif (!ancestorId) continue;\n\t\tconst ancestor = state.getBlock(ancestorId);\n\t\tif (!ancestor) continue;\n\t\tconst spec = getNodeSpec(ancestor.type);\n\t\tif (spec?.isolating) return true;\n\t}\n\treturn false;\n}\n\nfunction isIsolatingBlock(state: EditorState, blockId: BlockId): boolean {\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\tconst block = state.getBlock(blockId);\n\tif (!block) return false;\n\treturn getNodeSpec(block.type)?.isolating === true;\n}\n\n/**\n * Merges the current block with the previous block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockBackward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return null;\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx = blockOrder.indexOf(sel.anchor.blockId);\n\n\tif (blockIdx <= 0) return null;\n\n\tconst prevBlockId = blockOrder[blockIdx - 1];\n\tif (!prevBlockId) return null;\n\n\t// Never merge isolating blocks directly (e.g. table cells).\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, prevBlockId)) {\n\t\treturn null;\n\t}\n\n\t// Prevent merge across isolating boundaries\n\tif (!sharesParent(state, sel.anchor.blockId, prevBlockId)) {\n\t\tif (isInsideIsolating(state, sel.anchor.blockId)) return null;\n\t}\n\n\t// If previous block is void, select it instead of merging\n\tif (isVoidBlock(state, prevBlockId)) {\n\t\tconst path = findNodePath(state.doc, prevBlockId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(prevBlockId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tconst prevBlock = state.getBlock(prevBlockId);\n\tif (!prevBlock) return null;\n\tconst prevLen = getBlockLength(prevBlock);\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(prevBlockId, sel.anchor.blockId)\n\t\t.setSelection(createCollapsedSelection(prevBlockId, prevLen))\n\t\t.build();\n}\n\n/**\n * Merges the next block into the current block, respecting\n * isolating boundaries and void blocks.\n */\nfunction mergeBlockForward(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return null;\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx = blockOrder.indexOf(sel.anchor.blockId);\n\n\tif (blockIdx >= blockOrder.length - 1) return null;\n\n\tconst nextBlockId = blockOrder[blockIdx + 1];\n\tif (!nextBlockId) return null;\n\n\t// Never merge isolating blocks directly (e.g. table cells).\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, nextBlockId)) {\n\t\treturn null;\n\t}\n\n\t// Prevent merge across isolating boundaries\n\tif (!sharesParent(state, sel.anchor.blockId, nextBlockId)) {\n\t\tif (isInsideIsolating(state, sel.anchor.blockId)) return null;\n\t}\n\n\t// If next block is void, select it instead of merging\n\tif (isVoidBlock(state, nextBlockId)) {\n\t\tconst path = findNodePath(state.doc, nextBlockId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(nextBlockId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(sel.anchor.blockId, nextBlockId)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Selects all content in the editor. */\nexport function selectAll(state: EditorState): Transaction {\n\tconst blocks = state.doc.children;\n\tconst firstBlock = blocks[0];\n\tconst lastBlock = blocks[blocks.length - 1];\n\tif (!firstBlock || !lastBlock)\n\t\treturn state.transaction('command').setSelection(state.selection).build();\n\tconst lastBlockLen = getBlockLength(lastBlock);\n\n\treturn state\n\t\t.transaction('command')\n\t\t.setSelection(\n\t\t\tcreateSelection(\n\t\t\t\t{ blockId: firstBlock.id, offset: 0 },\n\t\t\t\t{ blockId: lastBlock.id, offset: lastBlockLen },\n\t\t\t),\n\t\t)\n\t\t.build();\n}\n\n// --- Check Commands ---\n\n/** Checks if a mark is active at the current selection. */\nexport function isMarkActive(state: EditorState, markType: MarkType): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\tif (state.storedMarks) {\n\t\t\treturn hasMark(state.storedMarks, markType);\n\t\t}\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return false;\n\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\treturn hasMark(marks, markType);\n\t}\n\n\treturn isMarkActiveInRange(state, markType);\n}\n\n// --- Internal Helpers ---\n\nfunction resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\tif (isNodeSelection(state.selection)) return [];\n\n\tconst block = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return [];\n\n\treturn getBlockMarksAtOffset(block, state.selection.anchor.offset);\n}\n\nexport function addDeleteSelectionSteps(state: EditorState, builder: TransactionBuilder): void {\n\tif (isNodeSelection(state.selection)) return;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(state.selection, blockOrder);\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tif (fromIdx === toIdx) {\n\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, range.to.offset);\n\t} else {\n\t\tconst firstBlock = state.getBlock(range.from.blockId);\n\t\tif (!firstBlock) return;\n\t\tconst firstLen = getBlockLength(firstBlock);\n\n\t\t// Delete from the end of first block\n\t\tif (range.from.offset < firstLen) {\n\t\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, firstLen);\n\t\t}\n\n\t\t// Delete from start of last block\n\t\tif (range.to.offset > 0) {\n\t\t\tbuilder.deleteTextAt(range.to.blockId, 0, range.to.offset);\n\t\t}\n\n\t\t// Delete middle blocks entirely and merge last into first\n\t\tfor (let i = fromIdx + 1; i < toIdx; i++) {\n\t\t\tconst midBlockId = blockOrder[i];\n\t\t\tif (!midBlockId) continue;\n\t\t\tconst midBlock = state.getBlock(midBlockId);\n\t\t\tif (!midBlock) continue;\n\t\t\tconst midLen = getBlockLength(midBlock);\n\t\t\tif (midLen > 0) {\n\t\t\t\tbuilder.deleteTextAt(midBlockId, 0, midLen);\n\t\t\t}\n\t\t\tbuilder.mergeBlocksAt(range.from.blockId, midBlockId);\n\t\t}\n\n\t\t// Merge last block into first\n\t\tbuilder.mergeBlocksAt(range.from.blockId, range.to.blockId);\n\t}\n}\n\n/**\n * Finds the word boundary backward from the given offset.\n * InlineNodes act as word boundaries.\n */\nfunction findWordBoundaryBackward(block: BlockNode, offset: number): number {\n\tlet pos = offset - 1;\n\t// Skip trailing whitespace\n\twhile (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (!/\\s/.test(content.char)) break;\n\t\tpos--;\n\t}\n\t// If at InlineNode, delete just it (treat as word boundary)\n\tif (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (content?.kind === 'inline') return pos;\n\t}\n\t// Skip word characters until whitespace or InlineNode\n\twhile (pos >= 0) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (/\\s/.test(content.char)) break;\n\t\tpos--;\n\t}\n\treturn pos + 1;\n}\n\n/**\n * Finds the word boundary forward from the given offset.\n * InlineNodes act as word boundaries.\n */\nfunction findWordBoundaryForward(block: BlockNode, offset: number): number {\n\tconst len = getBlockLength(block);\n\tlet pos = offset;\n\t// Skip word characters first\n\twhile (pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (/\\s/.test(content.char)) break;\n\t\tpos++;\n\t}\n\t// If at InlineNode and haven't moved, delete just the InlineNode\n\tif (pos === offset && pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (content?.kind === 'inline') return pos + 1;\n\t}\n\t// Skip trailing whitespace\n\twhile (pos < len) {\n\t\tconst content = getContentAtOffset(block, pos);\n\t\tif (!content || content.kind === 'inline') break;\n\t\tif (!/\\s/.test(content.char)) break;\n\t\tpos++;\n\t}\n\treturn pos;\n}\n\nfunction isFeatureGated(type: MarkType, features: FeatureConfig): boolean {\n\tconst key = type as string;\n\tif (key === 'bold') return !features.bold;\n\tif (key === 'italic') return !features.italic;\n\tif (key === 'underline') return !features.underline;\n\treturn false;\n}\n\n/** Inserts a new paragraph after a NodeSelection-targeted void block. */\nfunction insertParagraphAfterNodeSelection(\n\tstate: EditorState,\n\tsel: NodeSelection,\n): Transaction | null {\n\tconst path = findNodePath(state.doc, sel.nodeId);\n\tif (!path) return null;\n\n\tconst parentPath: BlockId[] = path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\n\tconst siblings =\n\t\tparentPath.length === 0\n\t\t\t? state.doc.children\n\t\t\t: (() => {\n\t\t\t\t\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\t\t\t\t\treturn parent ? parent.children : [];\n\t\t\t\t})();\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.nodeId);\n\tif (index < 0) return null;\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tbuilder.insertNode(\n\t\tparentPath,\n\t\tindex + 1,\n\t\tcreateBlockNode(\n\t\t\t'paragraph' as import('../model/TypeBrands.js').NodeTypeName,\n\t\t\t[createTextNode('')],\n\t\t\tnewId,\n\t\t),\n\t);\n\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\treturn builder.build();\n}\n\n/** Inserts text in a new paragraph after a NodeSelection-targeted void block. */\nfunction insertTextAfterNodeSelection(\n\tstate: EditorState,\n\tsel: NodeSelection,\n\ttext: string,\n\torigin: 'input' | 'paste',\n): Transaction {\n\tconst path = findNodePath(state.doc, sel.nodeId);\n\tconst parentPath: BlockId[] = path && path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n\n\tconst siblings =\n\t\tparentPath.length === 0\n\t\t\t? state.doc.children\n\t\t\t: (() => {\n\t\t\t\t\tconst parent = state.getBlock(parentPath[parentPath.length - 1] as BlockId);\n\t\t\t\t\treturn parent ? parent.children : [];\n\t\t\t\t})();\n\n\tconst index: number = siblings.findIndex((c) => 'id' in c && c.id === sel.nodeId);\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction(origin);\n\n\tconst insertIdx = index >= 0 ? index + 1 : siblings.length;\n\tbuilder.insertNode(\n\t\tparentPath,\n\t\tinsertIdx,\n\t\tcreateBlockNode(\n\t\t\t'paragraph' as import('../model/TypeBrands.js').NodeTypeName,\n\t\t\t[createTextNode('')],\n\t\t\tnewId,\n\t\t),\n\t);\n\tbuilder.insertText(newId, 0, text, []);\n\tbuilder.setSelection(createCollapsedSelection(newId, text.length));\n\treturn builder.build();\n}\n\n/**\n * Navigates arrow keys into/out of void blocks.\n * Returns a transaction if navigation should create a NodeSelection, or null.\n */\nexport function navigateArrowIntoVoid(\n\tstate: EditorState,\n\tdirection: 'left' | 'right' | 'up' | 'down',\n): Transaction | null {\n\tconst sel = state.selection;\n\tconst blockOrder = state.getBlockOrder();\n\n\t// If currently on a NodeSelection, navigate away from it\n\tif (isNodeSelection(sel)) {\n\t\tconst nodeIdx = blockOrder.indexOf(sel.nodeId);\n\t\tif (direction === 'left' || direction === 'up') {\n\t\t\t// Move to end of previous block\n\t\t\tif (nodeIdx > 0) {\n\t\t\t\tconst prevId = blockOrder[nodeIdx - 1];\n\t\t\t\tif (!prevId) return null;\n\t\t\t\tif (isVoidBlock(state, prevId)) {\n\t\t\t\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\t\t\t\treturn state\n\t\t\t\t\t\t.transaction('input')\n\t\t\t\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t\t\t\t.build();\n\t\t\t\t}\n\t\t\t\tconst prevBlock = state.getBlock(prevId);\n\t\t\t\tconst prevLen = prevBlock ? getBlockLength(prevBlock) : 0;\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t// right or down\n\t\tif (nodeIdx < blockOrder.length - 1) {\n\t\t\tconst nextId = blockOrder[nodeIdx + 1];\n\t\t\tif (!nextId) return null;\n\t\t\tif (isVoidBlock(state, nextId)) {\n\t\t\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Text selection: check if navigating into a void block\n\tif (!isCollapsed(sel)) return null;\n\n\tconst blockIdx = blockOrder.indexOf(sel.anchor.blockId);\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tconst blockLen = getBlockLength(block);\n\n\tif (direction === 'right' || direction === 'down') {\n\t\tif (sel.anchor.offset === blockLen && blockIdx < blockOrder.length - 1) {\n\t\t\tconst nextId = blockOrder[blockIdx + 1];\n\t\t\tif (nextId && isVoidBlock(state, nextId)) {\n\t\t\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t}\n\t}\n\n\tif (direction === 'left' || direction === 'up') {\n\t\tif (sel.anchor.offset === 0 && blockIdx > 0) {\n\t\t\tconst prevId = blockOrder[blockIdx - 1];\n\t\t\tif (prevId && isVoidBlock(state, prevId)) {\n\t\t\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t\t\t.build();\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n"],"names":["defaultSchema","nodeTypes","markTypes","getNodeSpec","schemaFromRegistry","registry","getNodeTypes","getMarkTypes","type","isMarkAllowed","schema","markType","includes","isNodeTypeAllowed","nodeType","defaultFeatures","bold","italic","underline","isVoidBlock","state","bid","block","getBlock","isVoid","deleteNodeSelection","sel","path","findNodePath","doc","nodeId","parentPath","length","slice","siblings","children","parent","index","findIndex","c","id","builder","transaction","newId","generateBlockId","insertNode","createBlockNode","createTextNode","removeNode","setSelection","createCollapsedSelection","build","prevSibling","isBlockNode","prevLeafId","node","current","lastBlockChild","i","child","prevLeaf","prevLen","getBlockLength","nextSibling","nextLeafId","firstBlockChild","find","forEachBlockInRange","range","callback","blockOrder","getBlockOrder","fromIdx","indexOf","from","blockId","toIdx","to","offset","toggleMark","features","key","isNodeSelection","selection","mark","isCollapsed","anchorBlock","anchor","currentMarks","storedMarks","getBlockMarksAtOffset","newMarks","hasMark","filter","m","setStoredMarks","selectionRange","shouldRemove","isMarkActiveInRange","removeMark","addMark","blockLen","isMarkActiveInBlock","pos","getInlineChildren","isTextNode","childEnd","text","marks","toggleBold","mkType","toggleItalic","toggleUnderline","insertTextCommand","origin","insertIdx","insertText","addDeleteSelectionSteps","insertBlockId","insertOffset","deleteSelectionCommand","deleteBackward","deleteTextAt","mergeBlockBackward","deleteForward","mergeBlockForward","deleteWordBackward","wordStart","content","getContentAtOffset","kind","test","char","deleteWordForward","wordEnd","len","deleteSoftLineBackward","deleteSoftLineForward","splitBlockCommand","newBlockId","splitBlock","insertHardBreakCommand","hardBreak","createInlineNode","inlineType","insertInlineNode","sharesParent","blockIdA","blockIdB","pathA","getNodePath","pathB","isInsideIsolating","ancestorId","ancestor","spec","isolating","isIsolatingBlock","blockIdx","prevBlockId","createNodeSelection","prevBlock","mergeBlocksAt","nextBlockId","selectAll","blocks","firstBlock","lastBlock","lastBlockLen","createSelection","isMarkActive","firstLen","midBlockId","midBlock","midLen","navigateArrowIntoVoid","direction","nodeIdx","prevId","nextId"],"mappings":";;;;AAgBO,SAASA,IAAAA;AACf,SAAO,EACNC,WAAW,CAAC,WAAA,GACZC,WAAW,CAAC,QAAQ,UAAU,WAAA,GAC9BC,aAAa,M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