@notectl/core 1.0.6 → 1.0.8
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 +78 -56
- package/custom-elements.json +344 -0
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs → AttrRegistry-D-przlzb.mjs} +4 -4
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs.map → AttrRegistry-D-przlzb.mjs.map} +1 -1
- package/dist/chunks/ColorNames-iaWsSZx1.mjs +35 -0
- package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +1 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +140 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +1 -0
- package/dist/chunks/{Commands-DLP85Mp5.mjs → Commands-CSpSwGXv.mjs} +13 -13
- package/dist/chunks/{Commands-DLP85Mp5.mjs.map → Commands-CSpSwGXv.mjs.map} +1 -1
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs +46 -0
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs.map +1 -0
- package/dist/chunks/{ToolbarPlugin-sJTiZr-S.mjs → ToolbarPlugin-DY2xaJiu.mjs} +63 -93
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +1 -0
- package/dist/chunks/index-BAk1EG1x.mjs +541 -0
- package/dist/chunks/index-BAk1EG1x.mjs.map +1 -0
- package/dist/chunks/index-BRYzYOYC.mjs +63 -0
- package/dist/chunks/index-BRYzYOYC.mjs.map +1 -0
- package/dist/chunks/index-BSFLNveF.mjs +953 -0
- package/dist/chunks/index-BSFLNveF.mjs.map +1 -0
- package/dist/chunks/index-BYgspns5.mjs +209 -0
- package/dist/chunks/index-BYgspns5.mjs.map +1 -0
- package/dist/chunks/index-B_3qDrUN.mjs +64 -0
- package/dist/chunks/index-B_3qDrUN.mjs.map +1 -0
- package/dist/chunks/index-Bsp4LC5t.mjs +130 -0
- package/dist/chunks/index-Bsp4LC5t.mjs.map +1 -0
- package/dist/chunks/index-C-YWHOcC.mjs +100 -0
- package/dist/chunks/index-C-YWHOcC.mjs.map +1 -0
- package/dist/chunks/index-C2GQoHot.mjs +92 -0
- package/dist/chunks/index-C2GQoHot.mjs.map +1 -0
- package/dist/chunks/index-CT3HGdQt.mjs +39 -0
- package/dist/chunks/index-CT3HGdQt.mjs.map +1 -0
- package/dist/chunks/index-Ct0ivLhO.mjs +407 -0
- package/dist/chunks/index-Ct0ivLhO.mjs.map +1 -0
- package/dist/chunks/index-CxiWyUho.mjs +191 -0
- package/dist/chunks/index-CxiWyUho.mjs.map +1 -0
- package/dist/chunks/index-D3CQWJiw.mjs +200 -0
- package/dist/chunks/index-D3CQWJiw.mjs.map +1 -0
- package/dist/chunks/index-DC1EK22F.mjs +41 -0
- package/dist/chunks/index-DC1EK22F.mjs.map +1 -0
- package/dist/chunks/index-Dh76rR13.mjs +196 -0
- package/dist/chunks/index-Dh76rR13.mjs.map +1 -0
- package/dist/chunks/index-o6hDR07y.mjs +41 -0
- package/dist/chunks/index-o6hDR07y.mjs.map +1 -0
- package/dist/chunks/index-uTnc9y7M.mjs +62 -0
- package/dist/chunks/index-uTnc9y7M.mjs.map +1 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs +34 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +10 -0
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts +27 -0
- package/dist/editor/PaperLayoutController.d.ts.map +1 -0
- package/dist/editor/PaperSize.d.ts +35 -0
- package/dist/editor/PaperSize.d.ts.map +1 -0
- package/dist/editor/styles/color-picker.d.ts +1 -1
- package/dist/editor/styles/color-picker.d.ts.map +1 -1
- package/dist/editor/styles/paper.d.ts +3 -0
- package/dist/editor/styles/paper.d.ts.map +1 -0
- package/dist/editor/styles/table.d.ts +1 -1
- package/dist/editor/styles/table.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/editor/styles.d.ts.map +1 -1
- package/dist/i18n/Locale.d.ts +17 -0
- package/dist/i18n/Locale.d.ts.map +1 -0
- package/dist/i18n/LocaleService.d.ts +8 -0
- package/dist/i18n/LocaleService.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/resolvePluginLocale.d.ts +3 -0
- package/dist/i18n/resolvePluginLocale.d.ts.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2126 -1952
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2002 -1544
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +5 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentLocale.d.ts +19 -0
- package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +4 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +3 -89
- package/dist/plugins/alignment.mjs.map +1 -1
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts +17 -0
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +3 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +2 -55
- package/dist/plugins/blockquote.mjs.map +1 -1
- package/dist/plugins/code-block/CodeBlockLocale.d.ts +17 -0
- package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +2 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +3 -3
- package/dist/plugins/font/FontLocale.d.ts +15 -0
- package/dist/plugins/font/FontLocale.d.ts.map +1 -0
- package/dist/plugins/font/FontPlugin.d.ts +3 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeLocale.d.ts +17 -0
- package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +3 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +2 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +2 -201
- package/dist/plugins/font-size.mjs.map +1 -1
- package/dist/plugins/font.mjs +2 -183
- package/dist/plugins/font.mjs.map +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingLocale.d.ts +26 -0
- package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +4 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -184
- package/dist/plugins/heading.mjs.map +1 -1
- package/dist/plugins/highlight/HighlightLocale.d.ts +17 -0
- package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts +3 -5
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +2 -123
- package/dist/plugins/highlight.mjs.map +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts +15 -0
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +4 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +2 -56
- package/dist/plugins/horizontal-rule.mjs.map +1 -1
- package/dist/plugins/image/ImageLocale.d.ts +25 -0
- package/dist/plugins/image/ImageLocale.d.ts.map +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image/ImageUpload.d.ts +3 -0
- package/dist/plugins/image/ImageUpload.d.ts.map +1 -1
- package/dist/plugins/image.mjs +4 -378
- package/dist/plugins/image.mjs.map +1 -1
- package/dist/plugins/link/LinkLocale.d.ts +23 -0
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +3 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +2 -124
- package/dist/plugins/link.mjs.map +1 -1
- package/dist/plugins/list/ListLocale.d.ts +18 -0
- package/dist/plugins/list/ListLocale.d.ts.map +1 -0
- package/dist/plugins/list/ListPlugin.d.ts +4 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +2 -190
- package/dist/plugins/list.mjs.map +1 -1
- package/dist/plugins/print/PrintLocale.d.ts +16 -0
- package/dist/plugins/print/PrintLocale.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts +7 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- package/dist/plugins/print/PrintTypes.d.ts +5 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
- package/dist/plugins/shared/ColorMarkOperations.d.ts +28 -0
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -0
- package/dist/plugins/shared/ColorNames.d.ts +22 -0
- package/dist/plugins/shared/ColorNames.d.ts.map +1 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts +31 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -0
- package/dist/plugins/shared/ColorValidation.d.ts +14 -0
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts +17 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +3 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +2 -32
- package/dist/plugins/strikethrough.mjs.map +1 -1
- package/dist/plugins/super-sub/SuperSubLocale.d.ts +19 -0
- package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts +3 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +2 -78
- package/dist/plugins/super-sub.mjs.map +1 -1
- package/dist/plugins/table/TableBorderColor.d.ts +24 -0
- package/dist/plugins/table/TableBorderColor.d.ts.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts +9 -8
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +14 -0
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts +3 -1
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts +13 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table/TableLocale.d.ts +48 -0
- package/dist/plugins/table/TableLocale.d.ts.map +1 -0
- package/dist/plugins/table/TableNavigation.d.ts +2 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TableNodeViews.d.ts +3 -1
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts +7 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table/index.d.ts +3 -0
- package/dist/plugins/table/index.d.ts.map +1 -1
- package/dist/plugins/table.mjs +18 -660
- package/dist/plugins/table.mjs.map +1 -1
- package/dist/plugins/text-color/TextColorLocale.d.ts +17 -0
- package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts +3 -5
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +2 -123
- package/dist/plugins/text-color.mjs.map +1 -1
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts +18 -0
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +4 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +2 -49
- package/dist/plugins/text-formatting.mjs.map +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts +14 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/EditorState.d.ts +4 -1
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs +0 -15
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +0 -1
- package/dist/chunks/color-picker-Csf0wx5a.mjs +0 -5
- package/dist/chunks/color-picker-Csf0wx5a.mjs.map +0 -1
- package/dist/chunks/index-QvKiO9_4.mjs +0 -538
- package/dist/chunks/index-QvKiO9_4.mjs.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { n as t } from "./ToolbarKeyboardNav-B32OMv8r.mjs";
|
|
2
|
+
import { f as e } from "./Commands-CSpSwGXv.mjs";
|
|
3
|
+
import { i as o } from "./AttrRegistry-D-przlzb.mjs";
|
|
4
|
+
import { e as n, h as r } from "./Document-CI3iCwEP.mjs";
|
|
5
|
+
import { i as s, a as c, s as a } from "./Selection-D5ZjXoB7.mjs";
|
|
6
|
+
import { m as l } from "./TypeBrands-C09nE2qO.mjs";
|
|
7
|
+
import { g as i, i as d } from "./ColorNames-iaWsSZx1.mjs";
|
|
8
|
+
const p = '\n/* Color Picker Popup */\n.notectl-color-picker {\n padding: 8px;\n min-width: 240px;\n}\n\n.notectl-color-picker__default {\n display: block;\n width: 100%;\n padding: 6px 12px;\n margin-bottom: 8px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n cursor: pointer;\n font-size: 13px;\n color: var(--notectl-fg);\n text-align: center;\n}\n\n.notectl-color-picker__default:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-color-picker__grid {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n gap: 3px;\n}\n\n.notectl-color-picker__grid [role="row"] {\n display: contents;\n}\n\n.notectl-color-picker__swatch {\n width: 22px;\n height: 22px;\n border: 1px solid transparent;\n border-radius: 3px;\n padding: 0;\n cursor: pointer;\n transition: transform 0.1s;\n}\n\n.notectl-color-picker__swatch:hover,\n.notectl-color-picker__swatch:focus-visible {\n transform: scale(1.25);\n z-index: 1;\n}\n\n.notectl-color-picker__swatch:focus-visible {\n outline: 2px solid var(--notectl-focus-ring);\n outline-offset: 1px;\n}\n\n.notectl-color-picker__swatch--active {\n border: 2px solid var(--notectl-primary-fg);\n border-radius: 3px;\n}\n\n.notectl-toolbar-btn--textColor .notectl-toolbar-btn__color-indicator {\n display: block;\n width: 16px;\n height: 3px;\n margin-top: 1px;\n border-radius: 1px;\n}\n';
|
|
9
|
+
function u(t2, e2) {
|
|
10
|
+
const r2 = t2.selection;
|
|
11
|
+
if (s(r2)) return null;
|
|
12
|
+
if (c(r2)) {
|
|
13
|
+
if (t2.storedMarks) {
|
|
14
|
+
const n2 = t2.storedMarks.find((t3) => t3.type === e2);
|
|
15
|
+
return n2 && o(n2, e2) ? n2.attrs.color ?? null : null;
|
|
16
|
+
}
|
|
17
|
+
const s2 = t2.getBlock(r2.anchor.blockId);
|
|
18
|
+
if (!s2) return null;
|
|
19
|
+
const c2 = n(s2, r2.anchor.offset).find((t3) => t3.type === e2);
|
|
20
|
+
return c2 && o(c2, e2) ? c2.attrs.color ?? null : null;
|
|
21
|
+
}
|
|
22
|
+
const a2 = t2.getBlock(r2.anchor.blockId);
|
|
23
|
+
if (!a2) return null;
|
|
24
|
+
const l2 = n(a2, r2.anchor.offset).find((t3) => t3.type === e2);
|
|
25
|
+
return l2 && o(l2, e2) ? l2.attrs.color ?? null : null;
|
|
26
|
+
}
|
|
27
|
+
function f(t2, e2) {
|
|
28
|
+
return null !== u(t2, e2);
|
|
29
|
+
}
|
|
30
|
+
function m(t2, o2, r2, i2) {
|
|
31
|
+
const d2 = o2.selection;
|
|
32
|
+
if (s(d2)) return false;
|
|
33
|
+
const p2 = l(r2);
|
|
34
|
+
if (c(d2)) {
|
|
35
|
+
const e2 = o2.getBlock(d2.anchor.blockId);
|
|
36
|
+
if (!e2) return false;
|
|
37
|
+
const s2 = [...(o2.storedMarks ?? n(e2, d2.anchor.offset)).filter((t3) => t3.type !== r2), { type: p2, attrs: { color: i2 } }], c2 = o2.transaction("command").setStoredMarks(s2, o2.storedMarks).setSelection(d2).build();
|
|
38
|
+
return t2.dispatch(c2), true;
|
|
39
|
+
}
|
|
40
|
+
const u2 = a(d2, o2.getBlockOrder()), f2 = o2.transaction("command"), m2 = { type: p2, attrs: { color: i2 } };
|
|
41
|
+
return e(o2, u2, (t3, e2, o3) => {
|
|
42
|
+
f2.removeMark(t3, e2, o3, { type: p2 }), f2.addMark(t3, e2, o3, m2);
|
|
43
|
+
}), f2.setSelection(d2), t2.dispatch(f2.build()), true;
|
|
44
|
+
}
|
|
45
|
+
function k(t2, o2, i2) {
|
|
46
|
+
const d2 = o2.selection;
|
|
47
|
+
if (s(d2)) return false;
|
|
48
|
+
const p2 = l(i2);
|
|
49
|
+
if (c(d2)) {
|
|
50
|
+
const e2 = o2.getBlock(d2.anchor.blockId);
|
|
51
|
+
if (!e2) return false;
|
|
52
|
+
const s2 = o2.storedMarks ?? n(e2, d2.anchor.offset);
|
|
53
|
+
if (!r(s2, p2)) return false;
|
|
54
|
+
const c2 = s2.filter((t3) => t3.type !== i2), a2 = o2.transaction("command").setStoredMarks(c2, o2.storedMarks).setSelection(d2).build();
|
|
55
|
+
return t2.dispatch(a2), true;
|
|
56
|
+
}
|
|
57
|
+
const u2 = a(d2, o2.getBlockOrder()), f2 = o2.transaction("command");
|
|
58
|
+
return e(o2, u2, (t3, e2, o3) => {
|
|
59
|
+
f2.removeMark(t3, e2, o3, { type: p2 });
|
|
60
|
+
}), f2.setSelection(d2), t2.dispatch(f2.build()), true;
|
|
61
|
+
}
|
|
62
|
+
const b = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]), h = /* @__PURE__ */ new Set(["Home", "End"]);
|
|
63
|
+
function g(e2, o2, n2) {
|
|
64
|
+
e2.classList.add("notectl-color-picker");
|
|
65
|
+
const r2 = u(o2.getState(), n2.markType), s2 = n2.columns || 10, c2 = n2.colors.length, a2 = Math.ceil(c2 / s2), l2 = document.createElement("button");
|
|
66
|
+
l2.type = "button", l2.className = "notectl-color-picker__default", l2.textContent = n2.resetLabel, l2.addEventListener("mousedown", (t2) => {
|
|
67
|
+
t2.preventDefault(), t2.stopPropagation(), o2.executeCommand(n2.resetCommand), n2.onClose();
|
|
68
|
+
}), l2.addEventListener("keydown", (t2) => {
|
|
69
|
+
"Escape" === t2.key && (t2.preventDefault(), n2.onClose());
|
|
70
|
+
}), e2.appendChild(l2);
|
|
71
|
+
const p2 = document.createElement("div");
|
|
72
|
+
p2.className = "notectl-color-picker__grid", p2.setAttribute("role", "grid"), p2.setAttribute("aria-label", `${n2.ariaLabelPrefix} color picker`);
|
|
73
|
+
const f2 = [];
|
|
74
|
+
let k2 = 0;
|
|
75
|
+
for (let t2 = 0; t2 < a2; t2++) {
|
|
76
|
+
const e3 = document.createElement("div");
|
|
77
|
+
e3.setAttribute("role", "row");
|
|
78
|
+
for (let a3 = 0; a3 < s2; a3++) {
|
|
79
|
+
const l3 = t2 * s2 + a3;
|
|
80
|
+
if (l3 >= c2) break;
|
|
81
|
+
const p3 = n2.colors[l3], u2 = i(p3), b2 = !!r2 && r2.toLowerCase() === p3.toLowerCase(), h2 = document.createElement("button");
|
|
82
|
+
h2.type = "button", h2.className = "notectl-color-picker__swatch", h2.setAttribute("role", "gridcell"), h2.setAttribute("aria-label", `${n2.ariaLabelPrefix} ${u2}`), h2.setAttribute("aria-selected", String(b2)), h2.dataset.index = String(l3), h2.style.backgroundColor = p3, h2.title = p3, d(p3) && (h2.style.border = "1px solid #d0d0d0"), b2 && (h2.classList.add("notectl-color-picker__swatch--active"), k2 = l3), h2.addEventListener("mousedown", (t3) => {
|
|
83
|
+
t3.preventDefault(), t3.stopPropagation(), m(o2, o2.getState(), n2.markType, p3), n2.onClose();
|
|
84
|
+
}), f2.push(h2), e3.appendChild(h2);
|
|
85
|
+
}
|
|
86
|
+
p2.appendChild(e3);
|
|
87
|
+
}
|
|
88
|
+
x(f2, k2), p2.addEventListener("keydown", (e3) => {
|
|
89
|
+
if ("Escape" === e3.key) return e3.preventDefault(), void n2.onClose();
|
|
90
|
+
if ("Enter" === e3.key || " " === e3.key) {
|
|
91
|
+
e3.preventDefault();
|
|
92
|
+
const t2 = e3.target.dataset.index;
|
|
93
|
+
if (void 0 !== t2) {
|
|
94
|
+
const e4 = n2.colors[Number(t2)];
|
|
95
|
+
e4 && (m(o2, o2.getState(), n2.markType, e4), n2.onClose());
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (b.has(e3.key)) {
|
|
100
|
+
e3.preventDefault();
|
|
101
|
+
const o3 = Math.floor(k2 / s2) + 1, n3 = k2 % s2 + 1, r3 = a2, l3 = s2, [i2, d2] = t(o3, n3, r3, l3, e3.key);
|
|
102
|
+
let p3 = (i2 - 1) * s2 + (d2 - 1);
|
|
103
|
+
return p3 >= c2 && (p3 = c2 - 1), k2 = p3, x(f2, k2), void f2[k2]?.focus();
|
|
104
|
+
}
|
|
105
|
+
if (h.has(e3.key)) {
|
|
106
|
+
e3.preventDefault();
|
|
107
|
+
const t2 = Math.floor(k2 / s2) * s2, o3 = Math.min(t2 + s2 - 1, c2 - 1);
|
|
108
|
+
k2 = "Home" === e3.key ? t2 : o3, x(f2, k2), f2[k2]?.focus();
|
|
109
|
+
}
|
|
110
|
+
}), e2.appendChild(p2);
|
|
111
|
+
}
|
|
112
|
+
function x(t2, e2) {
|
|
113
|
+
for (let o2 = 0; o2 < t2.length; o2++) {
|
|
114
|
+
const n2 = t2[o2];
|
|
115
|
+
n2 && n2.setAttribute("tabindex", o2 === e2 ? "0" : "-1");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const v = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
119
|
+
function y(t2, e2, o2) {
|
|
120
|
+
if (!t2 || 0 === t2.length) return e2;
|
|
121
|
+
const n2 = t2.filter((t3) => {
|
|
122
|
+
return e3 = t3, !v.test(e3);
|
|
123
|
+
var e3;
|
|
124
|
+
});
|
|
125
|
+
if (n2.length > 0) throw new Error(`${o2}: invalid hex color(s): ${n2.join(", ")}. Expected format: #RGB or #RRGGBB.`);
|
|
126
|
+
const r2 = /* @__PURE__ */ new Set(), s2 = [];
|
|
127
|
+
for (const e3 of t2) {
|
|
128
|
+
const t3 = e3.toLowerCase();
|
|
129
|
+
r2.has(t3) || (r2.add(t3), s2.push(t3));
|
|
130
|
+
}
|
|
131
|
+
return s2;
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
p as C,
|
|
135
|
+
k as a,
|
|
136
|
+
g as b,
|
|
137
|
+
f as i,
|
|
138
|
+
y as r
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=ColorValidation-Dyy4Bye8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorValidation-Dyy4Bye8.mjs","sources":["../../src/editor/styles/color-picker.ts","../../src/plugins/shared/ColorMarkOperations.ts","../../src/plugins/shared/ColorPickerPopup.ts","../../src/plugins/shared/ColorValidation.ts"],"sourcesContent":["/** Color picker popup styles (text-color + highlight plugins). */\nexport const COLOR_PICKER_CSS = `\n/* Color Picker Popup */\n.notectl-color-picker {\n\tpadding: 8px;\n\tmin-width: 240px;\n}\n\n.notectl-color-picker__default {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 6px 12px;\n\tmargin-bottom: 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n\tcursor: pointer;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg);\n\ttext-align: center;\n}\n\n.notectl-color-picker__default:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-color-picker__grid {\n\tdisplay: grid;\n\tgrid-template-columns: repeat(10, 1fr);\n\tgap: 3px;\n}\n\n.notectl-color-picker__grid [role=\"row\"] {\n\tdisplay: contents;\n}\n\n.notectl-color-picker__swatch {\n\twidth: 22px;\n\theight: 22px;\n\tborder: 1px solid transparent;\n\tborder-radius: 3px;\n\tpadding: 0;\n\tcursor: pointer;\n\ttransition: transform 0.1s;\n}\n\n.notectl-color-picker__swatch:hover,\n.notectl-color-picker__swatch:focus-visible {\n\ttransform: scale(1.25);\n\tz-index: 1;\n}\n\n.notectl-color-picker__swatch:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: 1px;\n}\n\n.notectl-color-picker__swatch--active {\n\tborder: 2px solid var(--notectl-primary-fg);\n\tborder-radius: 3px;\n}\n\n.notectl-toolbar-btn--textColor .notectl-toolbar-btn__color-indicator {\n\tdisplay: block;\n\twidth: 16px;\n\theight: 3px;\n\tmargin-top: 1px;\n\tborder-radius: 1px;\n}\n`;\n","/**\n * Shared color mark operations for color-based mark plugins.\n * All functions are parameterized by mark type name so they work\n * identically for TextColor, Highlight, or any future color mark.\n */\n\nimport { forEachBlockInRange } from '../../commands/Commands.js';\nimport { type MarkAttrRegistry, isMarkOfType } from '../../model/AttrRegistry.js';\nimport { getBlockMarksAtOffset, hasMark } from '../../model/Document.js';\nimport { isCollapsed, isNodeSelection, selectionRange } from '../../model/Selection.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { MarkTypeName } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\n\n/** Color mark type names that have `{ color: string }` attrs. */\ntype ColorMarkType = {\n\t[K in keyof MarkAttrRegistry]: MarkAttrRegistry[K] extends { color: string } ? K : never;\n}[keyof MarkAttrRegistry];\n\n/**\n * Returns the active color value for the given mark type at the current\n * selection, or `null` if the mark is not present.\n */\nexport function getActiveColor(state: EditorState, markTypeName: ColorMarkType): string | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return null;\n\n\tif (isCollapsed(sel)) {\n\t\tif (state.storedMarks) {\n\t\t\tconst mark = state.storedMarks.find((m) => m.type === markTypeName);\n\t\t\treturn mark && isMarkOfType(mark, markTypeName) ? (mark.attrs.color ?? null) : null;\n\t\t}\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return null;\n\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\tconst mark = marks.find((m) => m.type === markTypeName);\n\t\treturn mark && isMarkOfType(mark, markTypeName) ? (mark.attrs.color ?? null) : null;\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\tconst mark = marks.find((m) => m.type === markTypeName);\n\treturn mark && isMarkOfType(mark, markTypeName) ? (mark.attrs.color ?? null) : null;\n}\n\n/** Returns `true` when the given color mark is active at the current selection. */\nexport function isColorMarkActive(state: EditorState, markTypeName: ColorMarkType): boolean {\n\treturn getActiveColor(state, markTypeName) !== null;\n}\n\n/**\n * Applies the given color to the selection. For collapsed selections,\n * sets stored marks. For range selections, removes then re-adds the mark.\n */\nexport function applyColorMark(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tmarkTypeName: ColorMarkType,\n\tcolor: string,\n): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tconst typeName: MarkTypeName = markType(markTypeName);\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tconst withoutMark = currentMarks.filter((m) => m.type !== markTypeName);\n\t\tconst newMarks = [...withoutMark, { type: typeName, attrs: { color } }];\n\n\t\tconst tr = 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\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\tconst mark = { type: typeName, attrs: { color } };\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: typeName });\n\t\tbuilder.addMark(blockId, from, to, mark);\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/**\n * Removes the given color mark from the selection.\n * Returns `false` when the mark was not present.\n */\nexport function removeColorMark(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tmarkTypeName: ColorMarkType,\n): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tconst typeName: MarkTypeName = markType(markTypeName);\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tif (!hasMark(currentMarks, typeName)) return false;\n\n\t\tconst newMarks = currentMarks.filter((m) => m.type !== markTypeName);\n\t\tconst tr = 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\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: typeName });\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n","/**\n * Shared color picker popup rendering with WAI-ARIA grid keyboard navigation.\n * Used by TextColorPlugin and HighlightPlugin.\n */\n\nimport type { MarkAttrRegistry } from '../../model/AttrRegistry.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { navigateGrid } from '../toolbar/ToolbarKeyboardNav.js';\nimport { applyColorMark, getActiveColor } from './ColorMarkOperations.js';\nimport { getColorName, isLightColor } from './ColorNames.js';\n\n/** Color mark type names that have `{ color: string }` attrs. */\ntype ColorMarkType = {\n\t[K in keyof MarkAttrRegistry]: MarkAttrRegistry[K] extends { color: string } ? K : never;\n}[keyof MarkAttrRegistry];\n\n/** Configuration for `renderColorPickerPopup`. */\nexport interface ColorPickerConfig {\n\treadonly markType: ColorMarkType;\n\treadonly colors: readonly string[];\n\treadonly columns: number;\n\treadonly resetLabel: string;\n\treadonly resetCommand: string;\n\treadonly ariaLabelPrefix: string;\n\treadonly onClose: () => void;\n}\n\nconst GRID_NAV_KEYS = new Set(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);\nconst GRID_HOME_END_KEYS = new Set(['Home', 'End']);\nconst LIGHT_COLOR_BORDER = '1px solid #d0d0d0';\nconst COLUMNS = 10;\n\n/**\n * Renders an accessible color picker popup into `container`.\n *\n * Features:\n * - WAI-ARIA `role=\"grid\"` with row/gridcell structure\n * - Arrow key navigation (wraps around, clamps on partial last row)\n * - Enter/Space selects color and closes popup\n * - Escape closes popup\n * - Roving tabindex on swatches\n */\nexport function renderColorPickerPopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: ColorPickerConfig,\n): void {\n\tcontainer.classList.add('notectl-color-picker');\n\n\tconst state = context.getState();\n\tconst activeColor: string | null = getActiveColor(state, config.markType);\n\tconst columns: number = config.columns || COLUMNS;\n\tconst totalSwatches: number = config.colors.length;\n\tconst totalRows: number = Math.ceil(totalSwatches / columns);\n\n\t// --- Reset button ---\n\tconst resetBtn: HTMLButtonElement = document.createElement('button');\n\tresetBtn.type = 'button';\n\tresetBtn.className = 'notectl-color-picker__default';\n\tresetBtn.textContent = config.resetLabel;\n\tresetBtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\tcontext.executeCommand(config.resetCommand);\n\t\tconfig.onClose();\n\t});\n\tresetBtn.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.onClose();\n\t\t}\n\t});\n\tcontainer.appendChild(resetBtn);\n\n\t// --- Color grid ---\n\tconst grid: HTMLDivElement = document.createElement('div');\n\tgrid.className = 'notectl-color-picker__grid';\n\tgrid.setAttribute('role', 'grid');\n\tgrid.setAttribute('aria-label', `${config.ariaLabelPrefix} color picker`);\n\n\tconst swatches: HTMLButtonElement[] = [];\n\tlet focusedIndex = 0;\n\n\t// Build rows for ARIA structure\n\tfor (let rowIdx = 0; rowIdx < totalRows; rowIdx++) {\n\t\tconst row: HTMLDivElement = document.createElement('div');\n\t\trow.setAttribute('role', 'row');\n\n\t\tfor (let colIdx = 0; colIdx < columns; colIdx++) {\n\t\t\tconst swatchIdx: number = rowIdx * columns + colIdx;\n\t\t\tif (swatchIdx >= totalSwatches) break;\n\n\t\t\tconst color: string = config.colors[swatchIdx] as string;\n\t\t\tconst colorName: string = getColorName(color);\n\t\t\tconst isActive: boolean = !!activeColor && activeColor.toLowerCase() === color.toLowerCase();\n\n\t\t\tconst swatch: HTMLButtonElement = document.createElement('button');\n\t\t\tswatch.type = 'button';\n\t\t\tswatch.className = 'notectl-color-picker__swatch';\n\t\t\tswatch.setAttribute('role', 'gridcell');\n\t\t\tswatch.setAttribute('aria-label', `${config.ariaLabelPrefix} ${colorName}`);\n\t\t\tswatch.setAttribute('aria-selected', String(isActive));\n\t\t\tswatch.dataset.index = String(swatchIdx);\n\t\t\tswatch.style.backgroundColor = color;\n\t\t\tswatch.title = color;\n\n\t\t\tif (isLightColor(color)) {\n\t\t\t\tswatch.style.border = LIGHT_COLOR_BORDER;\n\t\t\t}\n\n\t\t\tif (isActive) {\n\t\t\t\tswatch.classList.add('notectl-color-picker__swatch--active');\n\t\t\t\tfocusedIndex = swatchIdx;\n\t\t\t}\n\n\t\t\t// Mouse handler\n\t\t\tswatch.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tapplyColorMark(context, context.getState(), config.markType, color);\n\t\t\t\tconfig.onClose();\n\t\t\t});\n\n\t\t\tswatches.push(swatch);\n\t\t\trow.appendChild(swatch);\n\t\t}\n\n\t\tgrid.appendChild(row);\n\t}\n\n\t// Apply initial roving tabindex\n\tapplySwatchTabindex(swatches, focusedIndex);\n\n\t// --- Keyboard navigation (delegated on the grid) ---\n\tgrid.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.onClose();\n\t\t\treturn;\n\t\t}\n\n\t\tif (e.key === 'Enter' || e.key === ' ') {\n\t\t\te.preventDefault();\n\t\t\tconst target = e.target as HTMLElement;\n\t\t\tconst idx: string | undefined = target.dataset.index;\n\t\t\tif (idx !== undefined) {\n\t\t\t\tconst color: string | undefined = config.colors[Number(idx)];\n\t\t\t\tif (color) {\n\t\t\t\t\tapplyColorMark(context, context.getState(), config.markType, color);\n\t\t\t\t\tconfig.onClose();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (GRID_NAV_KEYS.has(e.key)) {\n\t\t\te.preventDefault();\n\t\t\tconst currentRow: number = Math.floor(focusedIndex / columns) + 1;\n\t\t\tconst currentCol: number = (focusedIndex % columns) + 1;\n\n\t\t\tconst maxRows: number = totalRows;\n\t\t\tconst maxCols: number = columns;\n\n\t\t\tconst [newRow, newCol] = navigateGrid(\n\t\t\t\tcurrentRow,\n\t\t\t\tcurrentCol,\n\t\t\t\tmaxRows,\n\t\t\t\tmaxCols,\n\t\t\t\te.key as 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight',\n\t\t\t);\n\n\t\t\t// Convert back to 0-based index and clamp to valid range\n\t\t\tlet newIdx: number = (newRow - 1) * columns + (newCol - 1);\n\t\t\tif (newIdx >= totalSwatches) {\n\t\t\t\tnewIdx = totalSwatches - 1;\n\t\t\t}\n\n\t\t\tfocusedIndex = newIdx;\n\t\t\tapplySwatchTabindex(swatches, focusedIndex);\n\t\t\tswatches[focusedIndex]?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Home/End — jump to first/last swatch in current row\n\t\tif (GRID_HOME_END_KEYS.has(e.key)) {\n\t\t\te.preventDefault();\n\t\t\tconst currentRow: number = Math.floor(focusedIndex / columns);\n\t\t\tconst rowStart: number = currentRow * columns;\n\t\t\tconst rowEnd: number = Math.min(rowStart + columns - 1, totalSwatches - 1);\n\n\t\t\tfocusedIndex = e.key === 'Home' ? rowStart : rowEnd;\n\t\t\tapplySwatchTabindex(swatches, focusedIndex);\n\t\t\tswatches[focusedIndex]?.focus();\n\t\t}\n\t});\n\n\tcontainer.appendChild(grid);\n}\n\n/** Sets `tabindex=\"0\"` on the focused swatch, `-1` on all others. */\nfunction applySwatchTabindex(swatches: readonly HTMLButtonElement[], focusedIndex: number): void {\n\tfor (let i = 0; i < swatches.length; i++) {\n\t\tconst swatch = swatches[i];\n\t\tif (swatch) {\n\t\t\tswatch.setAttribute('tabindex', i === focusedIndex ? '0' : '-1');\n\t\t}\n\t}\n}\n","/**\n * Shared color validation and normalization utilities\n * for color-based mark plugins (TextColor, Highlight).\n */\n\nconst HEX_COLOR_PATTERN: RegExp = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\n\n/** Returns `true` when the value is a valid `#RGB` or `#RRGGBB` hex color. */\nexport function isValidHexColor(value: string): boolean {\n\treturn HEX_COLOR_PATTERN.test(value);\n}\n\n/**\n * Validates, deduplicates, and normalizes a user-supplied color list.\n * Returns `fallbackPalette` when no custom colors are provided.\n *\n * @throws {Error} if any value is not a valid hex color code.\n */\nexport function resolveColors(\n\tcolors: readonly string[] | undefined,\n\tfallbackPalette: readonly string[],\n\tpluginName: string,\n): readonly string[] {\n\tif (!colors || colors.length === 0) return fallbackPalette;\n\n\tconst invalid: string[] = colors.filter((c) => !isValidHexColor(c));\n\tif (invalid.length > 0) {\n\t\tthrow new Error(\n\t\t\t`${pluginName}: invalid hex color(s): ${invalid.join(', ')}. Expected format: #RGB or #RRGGBB.`,\n\t\t);\n\t}\n\n\tconst seen: Set<string> = new Set();\n\tconst unique: string[] = [];\n\tfor (const color of colors) {\n\t\tconst normalized: string = color.toLowerCase();\n\t\tif (!seen.has(normalized)) {\n\t\t\tseen.add(normalized);\n\t\t\tunique.push(normalized);\n\t\t}\n\t}\n\treturn unique;\n}\n"],"names":["COLOR_PICKER_CSS","getActiveColor","state","markTypeName","sel","selection","isNodeSelection","isCollapsed","storedMarks","mark","find","m","type","isMarkOfType","attrs","color","block","getBlock","anchor","blockId","getBlockMarksAtOffset","offset","isColorMarkActive","applyColorMark","context","typeName","markType","anchorBlock","newMarks","filter","tr","transaction","setStoredMarks","setSelection","build","dispatch","range","selectionRange","getBlockOrder","builder","forEachBlockInRange","from","to","removeMark","addMark","removeColorMark","currentMarks","hasMark","GRID_NAV_KEYS","Set","GRID_HOME_END_KEYS","renderColorPickerPopup","container","config","classList","add","activeColor","getState","columns","totalSwatches","colors","length","totalRows","Math","ceil","resetBtn","document","createElement","className","textContent","resetLabel","addEventListener","e","preventDefault","stopPropagation","executeCommand","resetCommand","onClose","key","appendChild","grid","setAttribute","ariaLabelPrefix","swatches","focusedIndex","rowIdx","row","colIdx","swatchIdx","colorName","getColorName","isActive","toLowerCase","swatch","String","dataset","index","style","backgroundColor","title","isLightColor","border","push","applySwatchTabindex","idx","target","Number","has","currentRow","floor","currentCol","maxRows","maxCols","newRow","newCol","navigateGrid","newIdx","focus","rowStart","rowEnd","min","i","HEX_COLOR_PATTERN","resolveColors","fallbackPalette","pluginName","invalid","c","value","test","Error","join","seen","unique","normalized"],"mappings":";;;;;;;AACO,MAAMA,IAAmB;ACuBzB,SAASC,EAAeC,IAAoBC,IAAAA;AAClD,QAAMC,KAAMF,GAAMG;AAClB,MAAIC,EAAgBF,IAAM,QAAO;AAEjC,MAAIG,EAAYH,EAAAA,GAAM;AACrB,QAAIF,GAAMM,aAAa;AACtB,YAAMC,KAAOP,GAAMM,YAAYE,KAAMC,CAAAA,OAAMA,GAAEC,SAAST,EAAAA;AACtD,aAAOM,MAAQI,EAAaJ,IAAMN,MAAiBM,GAAKK,MAAMC,SAAS,OAAQ;AAAA,IAChF;AACA,UAAMC,KAAQd,GAAMe,SAASb,GAAIc,OAAOC;AACxC,QAAA,CAAKH,GAAO,QAAO;AACnB,UACMP,KADQW,EAAsBJ,IAAOZ,GAAIc,OAAOG,MAAAA,EACn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AMrC,KAAe,MAAM,IAAA;AAAA,EAE7D;AACD;AC1MA,MAAMsC,IAA4B;AAa3B,SAASC,EACf/D,IACAgE,IACAC,IAAAA;AAEA,MAAA,CAAKjE,MAA4B,MAAlBA,GAAOC,OAAc,QAAO+D;AAE3C,QAAME,KAAoBlE,GAAO/B,OAAQkG,CAAAA;AAAM,WAjBhBC,KAiBiCD,KAhBzDL,EAAkBO,KAAKD;AADxB,QAAyBA;AAAAA,EAAAA,CAAAA;AAkB/B,MAAIF,GAAQjE,SAAS,EACpB,OAAM,IAAIqE,MACT,GAAGL,EAAAA,2BAAqCC,GAAQK,KAAK;AAIvD,QAAMC,yBAAwBnF,OACxBoF,KAAmB,CAAA;AACzB,aAAWtH,MAAS6C,IAAQ;AAC3B,UAAM0E,KAAqBvH,GAAM6E,YAAAA;AAC5BwC,IAAAA,GAAKzB,IAAI2B,EAAAA,MACbF,GAAK7E,IAAI+E,EAAAA,GACTD,GAAO/B,KAAKgC,EAAAA;AAAAA,EAEd;AACA,SAAOD;AACR;"}
|
|
@@ -436,21 +436,21 @@ export {
|
|
|
436
436
|
D as c,
|
|
437
437
|
B as d,
|
|
438
438
|
R as e,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
A as f,
|
|
440
|
+
F as g,
|
|
441
|
+
E as h,
|
|
442
442
|
z as i,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
443
|
+
C as j,
|
|
444
|
+
_ as k,
|
|
445
|
+
V as l,
|
|
446
|
+
H as m,
|
|
447
447
|
Z as n,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
Y as o,
|
|
449
|
+
x as p,
|
|
450
|
+
O as q,
|
|
451
|
+
S as r,
|
|
452
452
|
W as s,
|
|
453
|
-
|
|
453
|
+
X as t,
|
|
454
454
|
K as u,
|
|
455
455
|
N as v,
|
|
456
456
|
Q as w,
|
|
@@ -458,4 +458,4 @@ export {
|
|
|
458
458
|
P as y,
|
|
459
459
|
w as z
|
|
460
460
|
};
|
|
461
|
-
//# sourceMappingURL=Commands-
|
|
461
|
+
//# sourceMappingURL=Commands-CSpSwGXv.mjs.map
|
|
@@ -1 +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,MAAA;AAAA,EAAA,EAAA;AAEf;AAGO,SAASC,EAAmBC;AAClC,SAAO,EACNJ,WAAWI,GAASC,gBACpBJ,WAAWG,GAASE,aAAAA,GACpBJ,aA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aAAO/J,GACLsB,YAAY,OAAA,EACZO,aAAa+G,EAAoBmB,IAAQxJ,EAAAA,CAAAA,EACzCwB,MAAAA;AAAAA,IACH;AAAA,EACD;AAGD,OAAkB,WAAd6H,MAAsC,SAAdA,OACD,MAAtBtJ,GAAI6D,OAAOT,UAAgBgF,KAAW,GAAG;AAC5C,UAAMoB,KAAS5G,GAAWwF,KAAW,CAAA;AACrC,QAAIoB,MAAU/J,EAAYC,IAAO8J,EAAAA,GAAS;AACzC,YAAMvJ,KAAOC,EAAaR,GAAMS,KAAKqJ,OAAW,CAAA;AAChD,aAAO9J,GACLsB,YAAY,SACZO,aAAa+G,EAAoBkB,IAAQvJ,EAAAA,CAAAA,EACzCwB;IACH;AAAA,EACD;AAGD,SAAO;AACR;"}
|
|
1
|
+
{"version":3,"file":"Commands-CSpSwGXv.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,MAAA;AAAA,EAAA,EAAA;AAEf;AAGO,SAASC,EAAmBC;AAClC,SAAO,EACNJ,WAAWI,GAASC,gBACpBJ,WAAWG,GAASE,aAAAA,GACpBJ,aAAcK,CAAAA,OAAiBH,GAASF,YAAYK,EAAAA,EAAAA;AAEtD;AAGO,SAASC,EAAcC,IAAgBC,IAAAA;AAC7C,SAAOD,GAAOR,UAAUU,SAASD,EAAAA;AAClC;AAGO,SAASE,EAAkBH,IAAgBI,IAAAA;AACjD,SAAOJ,GAAOT,UAAUW,SAASE,EAAAA;AAClC;ACGA,MAAMC,IAAiC,EAAEC,MAAAA,MAAYC,cAAcC,WAAAA,KAAW;AAKvE,SAASC,EAAYC,IAAoBC,IAAAA;AAC/C,QAAMC,KAAQF,GAAMG,SAASF,EAAAA;AAC7B,MAAA,CAAKC,GAAO;AACZ,QAAMnB,KAAciB,GAAMV,OAAOP;AACjC,SAAA,CAAA,CAAKA,MAAAA,SACEA,GAAYmB,GAAMd,IAAAA,GAAOgB;AACjC;AAMO,SAASC,EAAoBL,IAAoBM,IAAAA;AACvD,QAAMC,KAAOC,EAAaR,GAAMS,KAAKH,GAAII;AACzC,MAAA,CAAKH,GAAM,QAAO;AAGlB,QAAMI,KAAwBJ,GAAKK,SAAS,IAAKL,GAAKM,MAAM,GAAA,EAAG,IAAoB,CAAA,GAG7EC,KACiB,MAAtBH,GAAWC,SACRZ,GAAMS,IAAIM;AAEV,UAAMC,KAAShB,GAAMG,SAASQ,GAAWA,GAAWC,SAAS;AAC7D,WAAOI,KAASA,GAAOD,WAAW;EACnC,MAEGE,KAAgBH,GAASI,UAAWC,CAAAA,OAAM,QAAQA,MAAKA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,CAAKrD,GAAO,QAAO;AACnB,QAAM+E,KAAWvC,EAAexC,EAAAA;AAEhC,OAAkB,YAAd0J,MAAuC,WAAdA,OACxBtJ,GAAI6D,OAAOT,WAAWuB,MAAYyD,KAAWxF,GAAWtC,SAAS,GAAG;AACvE,UAAMmJ,KAAS7G,GAAWwF,KAAW,CAAA;AACrC,QAAIqB,MAAUhK,EAAYC,IAAO+J,EAAAA,GAAS;AACzC,YAAMxJ,KAAOC,EAAaR,GAAMS,KAAKsJ,EAAAA,KAAW;AAChD,aAAO/J,GACLsB,YAAY,OAAA,EACZO,aAAa+G,EAAoBmB,IAAQxJ,EAAAA,CAAAA,EACzCwB,MAAAA;AAAAA,IACH;AAAA,EACD;AAGD,OAAkB,WAAd6H,MAAsC,SAAdA,OACD,MAAtBtJ,GAAI6D,OAAOT,UAAgBgF,KAAW,GAAG;AAC5C,UAAMoB,KAAS5G,GAAWwF,KAAW,CAAA;AACrC,QAAIoB,MAAU/J,EAAYC,IAAO8J,EAAAA,GAAS;AACzC,YAAMvJ,KAAOC,EAAaR,GAAMS,KAAKqJ,OAAW,CAAA;AAChD,aAAO9J,GACLsB,YAAY,SACZO,aAAa+G,EAAoBkB,IAAQvJ,EAAAA,CAAAA,EACzCwB;IACH;AAAA,EACD;AAGD,SAAO;AACR;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function t(t2, r2, n2) {
|
|
2
|
+
const e2 = t2.length;
|
|
3
|
+
if (0 === e2) return -1;
|
|
4
|
+
let o2 = r2;
|
|
5
|
+
for (let r3 = 0; r3 < e2; r3++) if (o2 = (o2 + n2 + e2) % e2, !t2[o2]?.disabled) return o2;
|
|
6
|
+
return r2;
|
|
7
|
+
}
|
|
8
|
+
function r(t2) {
|
|
9
|
+
for (let r2 = 0; r2 < t2.length; r2++) if (!t2[r2]?.disabled) return r2;
|
|
10
|
+
return -1;
|
|
11
|
+
}
|
|
12
|
+
function n(t2) {
|
|
13
|
+
for (let r2 = t2.length - 1; r2 >= 0; r2--) if (!t2[r2]?.disabled) return r2;
|
|
14
|
+
return -1;
|
|
15
|
+
}
|
|
16
|
+
function e(t2, r2) {
|
|
17
|
+
for (let n2 = 0; n2 < t2.length; n2++) {
|
|
18
|
+
const e2 = t2[n2];
|
|
19
|
+
e2 && e2.setAttribute("tabindex", n2 === r2 ? "0" : "-1");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function o(t2, r2, n2) {
|
|
23
|
+
const e2 = t2.length;
|
|
24
|
+
return 0 === e2 ? -1 : (r2 + n2 + e2) % e2;
|
|
25
|
+
}
|
|
26
|
+
function u(t2, r2, n2, e2, o2) {
|
|
27
|
+
switch (o2) {
|
|
28
|
+
case "ArrowUp":
|
|
29
|
+
return [t2 > 1 ? t2 - 1 : n2, r2];
|
|
30
|
+
case "ArrowDown":
|
|
31
|
+
return [t2 < n2 ? t2 + 1 : 1, r2];
|
|
32
|
+
case "ArrowLeft":
|
|
33
|
+
return [t2, r2 > 1 ? r2 - 1 : e2];
|
|
34
|
+
case "ArrowRight":
|
|
35
|
+
return [t2, r2 < e2 ? r2 + 1 : 1];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
r as a,
|
|
40
|
+
e as b,
|
|
41
|
+
n as c,
|
|
42
|
+
t as d,
|
|
43
|
+
o as f,
|
|
44
|
+
u as n
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=ToolbarKeyboardNav-B32OMv8r.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarKeyboardNav-B32OMv8r.mjs","sources":["../../src/plugins/toolbar/ToolbarKeyboardNav.ts"],"sourcesContent":["/**\n * Keyboard navigation helpers for the toolbar (WAI-ARIA Toolbar pattern).\n * Pure functions that operate on arrays of buttons and DOM elements.\n */\n\n/** Returns indices of all enabled buttons. */\nexport function getEnabledIndices(buttons: readonly HTMLButtonElement[]): number[] {\n\tconst result: number[] = [];\n\tfor (let i = 0; i < buttons.length; i++) {\n\t\tif (!buttons[i]?.disabled) {\n\t\t\tresult.push(i);\n\t\t}\n\t}\n\treturn result;\n}\n\n/** Finds the next enabled button index in the given direction (wraps around). */\nexport function findNextEnabled(\n\tbuttons: readonly HTMLButtonElement[],\n\tcurrent: number,\n\tdirection: 1 | -1,\n): number {\n\tconst len = buttons.length;\n\tif (len === 0) return -1;\n\n\tlet index = current;\n\tfor (let i = 0; i < len; i++) {\n\t\tindex = (index + direction + len) % len;\n\t\tif (!buttons[index]?.disabled) {\n\t\t\treturn index;\n\t\t}\n\t}\n\treturn current;\n}\n\n/** Finds the first enabled button index. */\nexport function findFirstEnabled(buttons: readonly HTMLButtonElement[]): number {\n\tfor (let i = 0; i < buttons.length; i++) {\n\t\tif (!buttons[i]?.disabled) return i;\n\t}\n\treturn -1;\n}\n\n/** Finds the last enabled button index. */\nexport function findLastEnabled(buttons: readonly HTMLButtonElement[]): number {\n\tfor (let i = buttons.length - 1; i >= 0; i--) {\n\t\tif (!buttons[i]?.disabled) return i;\n\t}\n\treturn -1;\n}\n\n/**\n * Applies roving tabindex: sets tabindex=\"0\" on the focused button,\n * tabindex=\"-1\" on all others.\n */\nexport function applyRovingTabindex(\n\tbuttons: readonly HTMLButtonElement[],\n\tfocusedIndex: number,\n): void {\n\tfor (let i = 0; i < buttons.length; i++) {\n\t\tconst btn = buttons[i];\n\t\tif (btn) {\n\t\t\tbtn.setAttribute('tabindex', i === focusedIndex ? '0' : '-1');\n\t\t}\n\t}\n}\n\n/** Navigates dropdown items with arrow keys (wraps around). */\nexport function findNextDropdownItem(\n\titems: readonly HTMLElement[],\n\tcurrent: number,\n\tdirection: 1 | -1,\n): number {\n\tconst len = items.length;\n\tif (len === 0) return -1;\n\treturn (current + direction + len) % len;\n}\n\n/**\n * Navigates a grid of cells with arrow keys.\n * Returns the new [row, col] position.\n */\nexport function navigateGrid(\n\trow: number,\n\tcol: number,\n\tmaxRows: number,\n\tmaxCols: number,\n\tkey: 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight',\n): [number, number] {\n\tswitch (key) {\n\t\tcase 'ArrowUp':\n\t\t\treturn [row > 1 ? row - 1 : maxRows, col];\n\t\tcase 'ArrowDown':\n\t\t\treturn [row < maxRows ? row + 1 : 1, col];\n\t\tcase 'ArrowLeft':\n\t\t\treturn [row, col > 1 ? col - 1 : maxCols];\n\t\tcase 'ArrowRight':\n\t\t\treturn [row, col < maxCols ? col + 1 : 1];\n\t}\n}\n"],"names":["findNextEnabled","buttons","current","direction","len","length","index","i","disabled","findFirstEnabled","findLastEnabled","applyRovingTabindex","focusedIndex","btn","setAttribute","findNextDropdownItem","items","navigateGrid","row","col","maxRows","maxCols","key"],"mappings":"AAiBO,SAASA,EACfC,IACAC,IACAC;AAEA,QAAMC,KAAMH,GAAQI;AACpB,MAAY,MAARD,GAAW;AAEf,MAAIE,KAAQJ;AACZ,WAASK,KAAI,GAAGA,KAAIH,IAAKG,KAExB,KADAD,MAASA,KAAQH,KAAYC,MAAOA,KAC/BH,GAAQK,EAAAA,GAAQE,SACpB,QAAOF;AAGT,SAAOJ;AACR;AAGO,SAASO,EAAiBR,IAAAA;AAChC,WAASM,KAAI,GAAGA,KAAIN,GAAQI,QAAQE,KACnC,MAAKN,GAAQM,EAAAA,GAAIC,SAAU,QAAOD;AAEnC,SAAA;AACD;AAGO,SAASG,EAAgBT;AAC/B,WAASM,KAAIN,GAAQI,SAAS,GAAGE,MAAK,GAAGA,KACxC,KAAA,CAAKN,GAAQM,EAAAA,GAAIC,SAAU,QAAOD;AAEnC,SAAA;AACD;AAMO,SAASI,EACfV,IACAW,IAAAA;AAEA,WAASL,KAAI,GAAGA,KAAIN,GAAQI,QAAQE,MAAK;AACxC,UAAMM,KAAMZ,GAAQM,EAAAA;AAChBM,IAAAA,MACHA,GAAIC,aAAa,YAAYP,OAAMK,KAAe,MAAM,IAAA;AAAA,EAE1D;AACD;AAGO,SAASG,EACfC,IACAd,IACAC,IAAAA;AAEA,QAAMC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