@notectl/core 1.7.0 → 1.7.2
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 +2 -2
- package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs → AttrRegistry-D9Jx_RVb.mjs} +2 -2
- package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs.map → AttrRegistry-D9Jx_RVb.mjs.map} +1 -1
- package/dist/chunks/AttributedMarkCommands-BtLea72z.mjs +80 -0
- package/dist/chunks/AttributedMarkCommands-BtLea72z.mjs.map +1 -0
- package/dist/chunks/{CaretNavigation-CAJXoaae.mjs → CaretNavigation-7JYpIKbs.mjs} +56 -56
- package/dist/chunks/{CaretNavigation-CAJXoaae.mjs.map → CaretNavigation-7JYpIKbs.mjs.map} +1 -1
- package/dist/chunks/ColorGrid-Dneqb8if.mjs +81 -0
- package/dist/chunks/ColorGrid-Dneqb8if.mjs.map +1 -0
- package/dist/chunks/ColorPickerPopup-CiCLBbe9.mjs +37 -0
- package/dist/chunks/ColorPickerPopup-CiCLBbe9.mjs.map +1 -0
- package/dist/chunks/ColorValidation-CV4f1wu6.mjs +39 -0
- package/dist/chunks/ColorValidation-CV4f1wu6.mjs.map +1 -0
- package/dist/chunks/{Document-CuwE73FF.mjs → Document-Brtw2jL1.mjs} +18 -18
- package/dist/chunks/{Document-CuwE73FF.mjs.map → Document-Brtw2jL1.mjs.map} +1 -1
- package/dist/chunks/MarkCommands-6RUJ4L3r.mjs +94 -0
- package/dist/chunks/MarkCommands-6RUJ4L3r.mjs.map +1 -0
- package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs → NavigationUtils-Cspt2ZrK.mjs} +3 -3
- package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs.map → NavigationUtils-Cspt2ZrK.mjs.map} +1 -1
- package/dist/chunks/{NodeResolver-B-wzthAQ.mjs → NodeResolver-C2XYkeOi.mjs} +2 -2
- package/dist/chunks/{NodeResolver-B-wzthAQ.mjs.map → NodeResolver-C2XYkeOi.mjs.map} +1 -1
- package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs +32 -0
- package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs.map +1 -0
- package/dist/chunks/RangeIterator-Bh4Vl_6D.mjs +16 -0
- package/dist/chunks/RangeIterator-Bh4Vl_6D.mjs.map +1 -0
- package/dist/chunks/{Selection-DmFDwiPJ.mjs → Selection-BRTab5hO.mjs} +7 -7
- package/dist/chunks/{Selection-DmFDwiPJ.mjs.map → Selection-BRTab5hO.mjs.map} +1 -1
- package/dist/chunks/StyleRuntime-ChRjVQwL.mjs +239 -0
- package/dist/chunks/StyleRuntime-ChRjVQwL.mjs.map +1 -0
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
- package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs → ToolbarKeyboardNav-DhpL8zNV.mjs} +3 -3
- package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs.map → ToolbarKeyboardNav-DhpL8zNV.mjs.map} +1 -1
- package/dist/chunks/{ToolbarPlugin-B6JETWaw.mjs → ToolbarPlugin-DpLVJ71w.mjs} +348 -135
- package/dist/chunks/ToolbarPlugin-DpLVJ71w.mjs.map +1 -0
- package/dist/chunks/index--n1RGpq-.mjs +171 -0
- package/dist/chunks/index--n1RGpq-.mjs.map +1 -0
- package/dist/chunks/index-4or5UzNO.mjs +168 -0
- package/dist/chunks/index-4or5UzNO.mjs.map +1 -0
- package/dist/chunks/{index-pxbbDHVH.mjs → index-ABlTDvEX.mjs} +20 -19
- package/dist/chunks/index-ABlTDvEX.mjs.map +1 -0
- package/dist/chunks/{index--z_Txzej.mjs → index-BAke7kNL.mjs} +45 -45
- package/dist/chunks/{index--z_Txzej.mjs.map → index-BAke7kNL.mjs.map} +1 -1
- package/dist/chunks/{index-DMt3ojrY.mjs → index-BXtw5PNN.mjs} +2 -2
- package/dist/chunks/{index-DMt3ojrY.mjs.map → index-BXtw5PNN.mjs.map} +1 -1
- package/dist/chunks/{index-FlTg80Pk.mjs → index-BhDXjueu.mjs} +285 -325
- package/dist/chunks/index-BhDXjueu.mjs.map +1 -0
- package/dist/chunks/{index-D0s0Q8Wc.mjs → index-BqNUfq-y.mjs} +43 -35
- package/dist/chunks/index-BqNUfq-y.mjs.map +1 -0
- package/dist/chunks/{index-CflvcXSd.mjs → index-BvqkuEY1.mjs} +21 -17
- package/dist/chunks/index-BvqkuEY1.mjs.map +1 -0
- package/dist/chunks/{index-C9gc3Bws.mjs → index-C1opJocO.mjs} +32 -32
- package/dist/chunks/{index-C9gc3Bws.mjs.map → index-C1opJocO.mjs.map} +1 -1
- package/dist/chunks/index-CWltg1wK.mjs +124 -0
- package/dist/chunks/index-CWltg1wK.mjs.map +1 -0
- package/dist/chunks/{index-D8tbbW97.mjs → index-Cd3uJLP3.mjs} +2 -2
- package/dist/chunks/{index-D8tbbW97.mjs.map → index-Cd3uJLP3.mjs.map} +1 -1
- package/dist/chunks/{index-C0cEs7Jc.mjs → index-CluzpB2b.mjs} +10 -10
- package/dist/chunks/{index-C0cEs7Jc.mjs.map → index-CluzpB2b.mjs.map} +1 -1
- package/dist/chunks/{index-CoeD4T9-.mjs → index-D3NlpmT1.mjs} +15 -11
- package/dist/chunks/index-D3NlpmT1.mjs.map +1 -0
- package/dist/chunks/{index-CAV2N-fF.mjs → index-D515iymW.mjs} +75 -74
- package/dist/chunks/{index-CAV2N-fF.mjs.map → index-D515iymW.mjs.map} +1 -1
- package/dist/chunks/{index-B-NSeaM4.mjs → index-Dk49P9N4.mjs} +2 -2
- package/dist/chunks/{index-B-NSeaM4.mjs.map → index-Dk49P9N4.mjs.map} +1 -1
- package/dist/chunks/index-DyzigvbZ.mjs +410 -0
- package/dist/chunks/index-DyzigvbZ.mjs.map +1 -0
- package/dist/chunks/index-ErZ5_a1o.mjs +296 -0
- package/dist/chunks/index-ErZ5_a1o.mjs.map +1 -0
- package/dist/chunks/{index-CNs4QQ8l.mjs → index-fsVJLutn.mjs} +52 -64
- package/dist/chunks/index-fsVJLutn.mjs.map +1 -0
- package/dist/commands/AttributedMarkCommands.d.ts +46 -0
- package/dist/commands/AttributedMarkCommands.d.ts.map +1 -0
- package/dist/commands/CommandHelpers.d.ts +21 -0
- package/dist/commands/CommandHelpers.d.ts.map +1 -0
- package/dist/commands/Commands.d.ts +2 -8
- package/dist/commands/Commands.d.ts.map +1 -1
- package/dist/commands/DeleteCommands.d.ts.map +1 -1
- package/dist/commands/GapCursorCommands.d.ts.map +1 -1
- package/dist/commands/NodeSelectionCommands.d.ts.map +1 -1
- package/dist/commands/PasteCommand.d.ts.map +1 -1
- package/dist/commands/RangeIterator.d.ts +10 -0
- package/dist/commands/RangeIterator.d.ts.map +1 -0
- package/dist/editor/DocumentParser.d.ts.map +1 -1
- package/dist/editor/DocumentSerializer.d.ts +2 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/EditorThemeController.d.ts +3 -0
- package/dist/editor/EditorThemeController.d.ts.map +1 -1
- package/dist/editor/MarkSerializer.d.ts +11 -0
- package/dist/editor/MarkSerializer.d.ts.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +19 -3
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts +2 -0
- package/dist/editor/PaperLayoutController.d.ts.map +1 -1
- package/dist/editor/styles/font-select.d.ts +1 -1
- package/dist/editor/styles/font-select.d.ts.map +1 -1
- package/dist/editor/styles/font-size-select.d.ts +1 -1
- package/dist/editor/styles/font-size-select.d.ts.map +1 -1
- package/dist/editor/styles/heading-select.d.ts +1 -1
- package/dist/editor/styles/heading-select.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/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +0 -2
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -1
- package/dist/model/MarkSpec.d.ts +6 -0
- package/dist/model/MarkSpec.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2244 -2095
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2862 -2415
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +2 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontPlugin.d.ts +0 -6
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -5
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/gap-cursor.mjs +2 -2
- package/dist/plugins/hard-break.mjs +2 -25
- package/dist/plugins/hard-break.mjs.map +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +1 -7
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -1
- package/dist/plugins/heading/HeadingPlugin.d.ts +0 -6
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -1
- package/dist/plugins/shared/ColorGrid.d.ts +25 -0
- package/dist/plugins/shared/ColorGrid.d.ts.map +1 -0
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
- package/dist/plugins/shared/ColorValidation.d.ts +13 -2
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
- package/dist/plugins/shared/PopupKeyboardPatterns.d.ts +43 -0
- package/dist/plugins/shared/PopupKeyboardPatterns.d.ts.map +1 -0
- package/dist/plugins/shared/PopupManager.d.ts +45 -0
- package/dist/plugins/shared/PopupManager.d.ts.map +1 -0
- package/dist/plugins/shared/PopupPositioning.d.ts +21 -0
- package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -0
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +2 -1
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -1
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarItem.d.ts +11 -2
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +5 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +9 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -1
- package/dist/plugins/toolbar/index.d.ts +1 -1
- package/dist/plugins/toolbar/index.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/BlockTreeOps.d.ts +21 -0
- package/dist/state/BlockTreeOps.d.ts.map +1 -0
- package/dist/state/InlineContentOps.d.ts +37 -0
- package/dist/state/InlineContentOps.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts.map +1 -1
- package/dist/style/StyleRuntime.d.ts +38 -0
- package/dist/style/StyleRuntime.d.ts.map +1 -0
- package/dist/test/PluginTestUtils.d.ts +4 -0
- package/dist/test/PluginTestUtils.d.ts.map +1 -1
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/ColorNames-BdsHwA2f.mjs +0 -59
- package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +0 -1
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +0 -125
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +0 -1
- package/dist/chunks/Commands-CicwYoTQ.mjs +0 -286
- package/dist/chunks/Commands-CicwYoTQ.mjs.map +0 -1
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs +0 -94
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +0 -1
- package/dist/chunks/index-B9GkDVsx.mjs +0 -187
- package/dist/chunks/index-B9GkDVsx.mjs.map +0 -1
- package/dist/chunks/index-CKPrAOr6.mjs +0 -209
- package/dist/chunks/index-CKPrAOr6.mjs.map +0 -1
- package/dist/chunks/index-CNs4QQ8l.mjs.map +0 -1
- package/dist/chunks/index-CflvcXSd.mjs.map +0 -1
- package/dist/chunks/index-CoeD4T9-.mjs.map +0 -1
- package/dist/chunks/index-D0s0Q8Wc.mjs.map +0 -1
- package/dist/chunks/index-DfzCof6H.mjs +0 -191
- package/dist/chunks/index-DfzCof6H.mjs.map +0 -1
- package/dist/chunks/index-DyIwN_67.mjs +0 -404
- package/dist/chunks/index-DyIwN_67.mjs.map +0 -1
- package/dist/chunks/index-FlTg80Pk.mjs.map +0 -1
- package/dist/chunks/index-pxbbDHVH.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -136,8 +136,8 @@ See the [plugin documentation](https://samyssmile.github.io/notectl/plugins/over
|
|
|
136
136
|
Read and write content in any format:
|
|
137
137
|
|
|
138
138
|
```ts
|
|
139
|
-
editor.
|
|
140
|
-
editor.
|
|
139
|
+
editor.getContentHTML(); // export as HTML
|
|
140
|
+
editor.setContentHTML('<p>Hello <strong>world</strong></p>'); // import HTML
|
|
141
141
|
editor.getJSON(); // structured JSON
|
|
142
142
|
editor.getText(); // plain text
|
|
143
143
|
editor.isEmpty(); // check if empty
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as n } from "./Document-Brtw2jL1.mjs";
|
|
2
2
|
function t(n2, t2) {
|
|
3
3
|
return n2.type === t2;
|
|
4
4
|
}
|
|
@@ -13,4 +13,4 @@ export {
|
|
|
13
13
|
r as b,
|
|
14
14
|
e as i
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=AttrRegistry-
|
|
16
|
+
//# sourceMappingURL=AttrRegistry-D9Jx_RVb.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttrRegistry-
|
|
1
|
+
{"version":3,"file":"AttrRegistry-D9Jx_RVb.mjs","sources":["../../src/model/AttrRegistry.ts"],"sourcesContent":["/**\n * Module-augmentable attribute registries for type-safe node/mark attributes.\n *\n * Plugins extend these interfaces via `declare module`:\n * @example\n * declare module '../../model/AttrRegistry.js' {\n * interface NodeAttrRegistry {\n * heading: { level: HeadingLevel; align?: BlockAlignment };\n * }\n * }\n */\n\nimport type { BlockAlignment } from '../plugins/alignment/AlignmentPlugin.js';\nimport type { BlockNode, InlineNode, Mark } from './Document.js';\nimport { isInlineNode } from './Document.js';\n\n/** Plugins augment this interface to register typed node attributes. */\nexport interface NodeAttrRegistry {\n\tparagraph: { align?: BlockAlignment };\n}\n\n/** Plugins augment this interface to register typed mark attributes. */\nexport interface MarkAttrRegistry {\n\tbold: Record<string, never>;\n\titalic: Record<string, never>;\n\tunderline: Record<string, never>;\n}\n\n/** Resolves typed attributes for known node types, falls back for unknown. */\nexport type NodeAttrsFor<T extends string> = T extends keyof NodeAttrRegistry\n\t? NodeAttrRegistry[T]\n\t: Record<string, string | number | boolean>;\n\n/** Resolves typed attributes for known mark types, falls back for unknown. */\nexport type MarkAttrsFor<T extends string> = T extends keyof MarkAttrRegistry\n\t? MarkAttrRegistry[T]\n\t: Record<string, string | number | boolean>;\n\n/** Narrows a BlockNode to a typed variant with known attributes. */\nexport function isNodeOfType<T extends keyof NodeAttrRegistry>(\n\tnode: BlockNode,\n\ttype: T,\n): node is BlockNode & { readonly type: T; readonly attrs: NodeAttrRegistry[T] } {\n\treturn (node.type as string) === type;\n}\n\n/** Narrows a Mark to a typed variant with known attributes. */\nexport function isMarkOfType<T extends keyof MarkAttrRegistry>(\n\tmark: Mark,\n\ttype: T,\n): mark is Mark & { readonly type: T; readonly attrs: MarkAttrRegistry[T] } {\n\treturn (mark.type as string) === type;\n}\n\n// --- InlineNode Attribute Registry ---\n\n/** Plugins augment this interface to register typed inline node attributes. */\n// biome-ignore lint/suspicious/noEmptyInterface: module augmentation requires interface\nexport interface InlineNodeAttrRegistry {}\n\n/** Resolves typed attributes for known inline node types, falls back for unknown. */\nexport type InlineNodeAttrsFor<T extends string> = T extends keyof InlineNodeAttrRegistry\n\t? InlineNodeAttrRegistry[T]\n\t: Record<string, string | number | boolean>;\n\n/** Narrows an InlineNode to a typed variant with known attributes. */\nexport function isInlineNodeOfType<T extends keyof InlineNodeAttrRegistry>(\n\tnode: InlineNode,\n\tinlineNodeType: T,\n): node is InlineNode & {\n\treadonly inlineType: T;\n\treadonly attrs: InlineNodeAttrRegistry[T];\n} {\n\treturn isInlineNode(node) && (node.inlineType as string) === inlineNodeType;\n}\n"],"names":["isNodeOfType","node","type","isMarkOfType","mark","isInlineNodeOfType","inlineNodeType","isInlineNode","inlineType"],"mappings":";AAuCO,SAASA,EACfC,IACAC,IAAAA;AAEA,SAAQD,GAAKC,SAAoBA;AAClC;AAGO,SAASC,EACfC,IACAF,IAAAA;AAEA,SAAQE,GAAKF,SAAoBA;AAClC;AAcO,SAASG,EACfJ,IACAK,IAAAA;AAKA,SAAOC,EAAaN,EAAAA,KAAUA,GAAKO,eAA0BF;AAC9D;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { i as t } from "./AttrRegistry-D9Jx_RVb.mjs";
|
|
2
|
+
import { g as n, h as o, a as r, i as e } from "./Document-Brtw2jL1.mjs";
|
|
3
|
+
import { i as s, a as c, b as a, s as i } from "./Selection-BRTab5hO.mjs";
|
|
4
|
+
import { m as l } from "./TypeBrands-C09nE2qO.mjs";
|
|
5
|
+
import { f } from "./RangeIterator-Bh4Vl_6D.mjs";
|
|
6
|
+
function u(t2, o2) {
|
|
7
|
+
const r2 = t2.selection;
|
|
8
|
+
if (s(r2) || c(r2)) return null;
|
|
9
|
+
const e2 = l(o2.type);
|
|
10
|
+
if (a(r2)) {
|
|
11
|
+
const s2 = t2.getBlock(r2.anchor.blockId);
|
|
12
|
+
if (!s2) return null;
|
|
13
|
+
const c2 = [...(t2.storedMarks ?? n(s2, r2.anchor.offset)).filter((t3) => t3.type !== e2), o2];
|
|
14
|
+
return t2.transaction("command").setStoredMarks(c2, t2.storedMarks).setSelection(r2).build();
|
|
15
|
+
}
|
|
16
|
+
const u2 = i(r2, t2.getBlockOrder()), d2 = t2.transaction("command");
|
|
17
|
+
return f(t2, u2, (n2, r3, s2) => {
|
|
18
|
+
const c2 = t2.getBlock(n2);
|
|
19
|
+
if (c2) {
|
|
20
|
+
const t3 = p(c2, e2, r3, s2);
|
|
21
|
+
t3 && d2.removeMark(n2, r3, s2, t3);
|
|
22
|
+
}
|
|
23
|
+
d2.addMark(n2, r3, s2, o2);
|
|
24
|
+
}), d2.setSelection(r2), d2.build();
|
|
25
|
+
}
|
|
26
|
+
function d(t2, r2) {
|
|
27
|
+
const e2 = t2.selection;
|
|
28
|
+
if (s(e2) || c(e2)) return null;
|
|
29
|
+
if (a(e2)) {
|
|
30
|
+
const s2 = t2.getBlock(e2.anchor.blockId);
|
|
31
|
+
if (!s2) return null;
|
|
32
|
+
const c2 = t2.storedMarks ?? n(s2, e2.anchor.offset);
|
|
33
|
+
if (!o(c2, r2)) return null;
|
|
34
|
+
const a2 = c2.filter((t3) => t3.type !== r2);
|
|
35
|
+
return t2.transaction("command").setStoredMarks(a2, t2.storedMarks).setSelection(e2).build();
|
|
36
|
+
}
|
|
37
|
+
const l2 = i(e2, t2.getBlockOrder()), u2 = t2.transaction("command");
|
|
38
|
+
return f(t2, l2, (n2, o2, e3) => {
|
|
39
|
+
const s2 = t2.getBlock(n2), c2 = s2 ? p(s2, r2, o2, e3) : void 0;
|
|
40
|
+
u2.removeMark(n2, o2, e3, c2 ?? { type: r2 });
|
|
41
|
+
}), u2.setSelection(e2), u2.build();
|
|
42
|
+
}
|
|
43
|
+
function m(o2, r2, e2) {
|
|
44
|
+
const i2 = o2.selection;
|
|
45
|
+
if (s(i2) || c(i2)) return null;
|
|
46
|
+
if (a(i2) && o2.storedMarks) {
|
|
47
|
+
const n2 = o2.storedMarks.find((t2) => t2.type === r2);
|
|
48
|
+
return n2 && t(n2, r2) ? e2(n2) : null;
|
|
49
|
+
}
|
|
50
|
+
const l2 = o2.getBlock(i2.anchor.blockId);
|
|
51
|
+
if (!l2) return null;
|
|
52
|
+
const f2 = n(l2, i2.anchor.offset).find((t2) => t2.type === r2);
|
|
53
|
+
return f2 && t(f2, r2) ? e2(f2) : null;
|
|
54
|
+
}
|
|
55
|
+
function k(t2, n2) {
|
|
56
|
+
return null !== m(t2, n2, () => true);
|
|
57
|
+
}
|
|
58
|
+
function p(t2, n2, o2, s2) {
|
|
59
|
+
const c2 = r(t2);
|
|
60
|
+
let a2 = 0;
|
|
61
|
+
for (const t3 of c2) {
|
|
62
|
+
if (!e(t3)) {
|
|
63
|
+
a2 += 1;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const r2 = a2 + t3.text.length;
|
|
67
|
+
if (r2 > o2 && a2 < s2) {
|
|
68
|
+
const o3 = t3.marks.find((t4) => t4.type === n2);
|
|
69
|
+
if (o3) return o3;
|
|
70
|
+
}
|
|
71
|
+
a2 = r2;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
u as a,
|
|
76
|
+
m as g,
|
|
77
|
+
k as i,
|
|
78
|
+
d as r
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=AttributedMarkCommands-BtLea72z.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttributedMarkCommands-BtLea72z.mjs","sources":["../../src/commands/AttributedMarkCommands.ts"],"sourcesContent":["/**\n * Generic helpers for attributed marks (marks with key/value attrs).\n *\n * Unlike boolean marks (`bold`, `italic`) that toggle on/off, attributed\n * marks (`font`, `fontSize`, `textColor`, `highlight`) carry data and use\n * **replace** semantics: applying a new value removes the old one first.\n *\n * These helpers extract the duplicated collapsed-vs-range branching that\n * was previously copy-pasted across ColorMarkOperations, FontSizeOperations,\n * and FontPlugin.\n */\n\nimport { isMarkOfType } from '../model/AttrRegistry.js';\nimport type { MarkAttrRegistry } from '../model/AttrRegistry.js';\nimport type { BlockNode, Mark, TextNode } from '../model/Document.js';\nimport {\n\tgetBlockMarksAtOffset,\n\tgetInlineChildren,\n\thasMark,\n\tisTextNode,\n} from '../model/Document.js';\nimport type { InlineNode } from '../model/Document.js';\nimport { isCollapsed, isGapCursor, 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 { Transaction } from '../state/Transaction.js';\nimport { forEachBlockInRange } from './RangeIterator.js';\n\n/**\n * Applies an attributed mark to the current selection.\n *\n * - **Collapsed cursor**: replaces stored marks (filters out old mark of the\n * same type, appends the new one).\n * - **Range selection**: removes then re-adds the mark in every block span.\n *\n * Returns the built `Transaction`, or `null` when the selection is\n * unsupported (node-selection / gap-cursor) or the anchor block is missing.\n */\nexport function applyAttributedMark(state: EditorState, mark: Mark): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tconst typeName: MarkTypeName = markType(mark.type as string);\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return null;\n\t\tconst currentMarks: readonly Mark[] =\n\t\t\tstate.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tconst withoutMark: readonly Mark[] = currentMarks.filter((m) => m.type !== typeName);\n\t\tconst newMarks: readonly Mark[] = [...withoutMark, 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\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tconst block: BlockNode | undefined = state.getBlock(blockId);\n\t\tif (block) {\n\t\t\tconst existing: Mark | undefined = findMarkInRange(block, typeName, from, to);\n\t\t\tif (existing) {\n\t\t\t\tbuilder.removeMark(blockId, from, to, existing);\n\t\t\t}\n\t\t}\n\t\tbuilder.addMark(blockId, from, to, mark);\n\t});\n\n\tbuilder.setSelection(sel);\n\treturn builder.build();\n}\n\n/**\n * Removes an attributed mark from the current selection.\n *\n * - **Collapsed cursor**: filters the mark out of stored marks.\n * Returns `null` when the mark was not present.\n * - **Range selection**: removes the mark across all block spans.\n *\n * Returns the built `Transaction`, or `null` when the selection is\n * unsupported or the mark is absent at a collapsed cursor.\n */\nexport function removeAttributedMark(\n\tstate: EditorState,\n\tmarkTypeName: MarkTypeName,\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return null;\n\t\tconst currentMarks: readonly Mark[] =\n\t\t\tstate.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tif (!hasMark(currentMarks, markTypeName)) return null;\n\n\t\tconst newMarks: readonly Mark[] = currentMarks.filter((m) => m.type !== markTypeName);\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\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tconst block: BlockNode | undefined = state.getBlock(blockId);\n\t\tconst existing: Mark | undefined = block\n\t\t\t? findMarkInRange(block, markTypeName, from, to)\n\t\t\t: undefined;\n\t\tbuilder.removeMark(blockId, from, to, existing ?? { type: markTypeName });\n\t});\n\n\tbuilder.setSelection(sel);\n\treturn builder.build();\n}\n\n/**\n * Extracts a typed attribute value from the mark at the current selection.\n *\n * Looks at stored marks (collapsed w/ stored), block marks at cursor offset\n * (collapsed w/o stored), or anchor-block marks (range).\n *\n * @param extractFn — Narrows the found mark and returns the desired value,\n * or `null` when the mark's attrs don't match expectations.\n */\nexport function getMarkAttrAtSelection<K extends keyof MarkAttrRegistry, V>(\n\tstate: EditorState,\n\tmarkTypeName: K,\n\textractFn: (mark: Mark & { readonly type: K; readonly attrs: MarkAttrRegistry[K] }) => V | null,\n): V | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\n\tif (isCollapsed(sel) && state.storedMarks) {\n\t\tconst found = state.storedMarks.find((m) => (m.type as string) === markTypeName);\n\t\treturn found && isMarkOfType(found, markTypeName) ? extractFn(found) : null;\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tconst marks: readonly Mark[] = getBlockMarksAtOffset(block, sel.anchor.offset);\n\tconst found = marks.find((m) => (m.type as string) === markTypeName);\n\treturn found && isMarkOfType(found, markTypeName) ? extractFn(found) : null;\n}\n\n/**\n * Returns `true` when the given attributed mark type is present at the\n * current selection (collapsed or range).\n */\nexport function isAttributedMarkActive<K extends keyof MarkAttrRegistry>(\n\tstate: EditorState,\n\tmarkTypeName: K,\n): boolean {\n\treturn getMarkAttrAtSelection(state, markTypeName, () => true as const) !== null;\n}\n\n/**\n * Finds the first mark of the given type within an offset range of a block.\n *\n * Returns the full mark (including attrs) so callers can pass it to\n * `removeMark` for correct undo inversion, or `undefined` when absent.\n */\nfunction findMarkInRange(\n\tblock: BlockNode,\n\ttypeName: MarkTypeName,\n\tfrom: number,\n\tto: number,\n): Mark | undefined {\n\tconst children: readonly (TextNode | InlineNode)[] = getInlineChildren(block);\n\tlet pos = 0;\n\n\tfor (const child of children) {\n\t\tif (!isTextNode(child)) {\n\t\t\tpos += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tconst nodeEnd: number = pos + child.text.length;\n\t\tif (nodeEnd > from && pos < to) {\n\t\t\tconst found: Mark | undefined = child.marks.find((m) => m.type === typeName);\n\t\t\tif (found) return found;\n\t\t}\n\t\tpos = nodeEnd;\n\t}\n\treturn undefined;\n}\n"],"names":["applyAttributedMark","state","mark","sel","selection","isNodeSelection","isGapCursor","typeName","markType","type","isCollapsed","anchorBlock","getBlock","anchor","blockId","newMarks","storedMarks","getBlockMarksAtOffset","offset","filter","m","transaction","setStoredMarks","setSelection","build","range","selectionRange","getBlockOrder","builder","forEachBlockInRange","from","to","block","existing","findMarkInRange","removeMark","addMark","removeAttributedMark","markTypeName","currentMarks","hasMark","getMarkAttrAtSelection","extractFn","found","find","isMarkOfType","isAttributedMarkActive","children","getInlineChildren","pos","child","isTextNode","nodeEnd","text","length","marks"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as n, c as o } from "./NavigationUtils-
|
|
3
|
-
import {
|
|
4
|
-
import { f as a } from "./NodeResolver-
|
|
1
|
+
import { c as t, e } from "./Document-Brtw2jL1.mjs";
|
|
2
|
+
import { i as n, c as o } from "./NavigationUtils-Cspt2ZrK.mjs";
|
|
3
|
+
import { c as r, d as i, e as f, a as l, i as c, f as s, b as u } from "./Selection-BRTab5hO.mjs";
|
|
4
|
+
import { f as a } from "./NodeResolver-C2XYkeOi.mjs";
|
|
5
5
|
import { g as d } from "./Platform-S_xqIqcM.mjs";
|
|
6
6
|
import { b as g } from "./TypeBrands-C09nE2qO.mjs";
|
|
7
7
|
function h(t2, e2, n2) {
|
|
@@ -9,7 +9,7 @@ function h(t2, e2, n2) {
|
|
|
9
9
|
}
|
|
10
10
|
function b(t2, e2) {
|
|
11
11
|
const n2 = a(t2.doc, e2) ?? [];
|
|
12
|
-
return t2.transaction("input").setSelection(
|
|
12
|
+
return t2.transaction("input").setSelection(f(e2, n2)).setStoredMarks(null, t2.storedMarks).build();
|
|
13
13
|
}
|
|
14
14
|
function m(t2, e2, n2, o2, i2) {
|
|
15
15
|
return t2.transaction("input").setSelection(r({ blockId: e2, offset: n2 }, { blockId: o2, offset: i2 })).setStoredMarks(null, t2.storedMarks).build();
|
|
@@ -37,7 +37,7 @@ function k(t2) {
|
|
|
37
37
|
function p(t2, e2) {
|
|
38
38
|
const n2 = k(t2);
|
|
39
39
|
if (!n2) return;
|
|
40
|
-
if (
|
|
40
|
+
if (l(e2)) return void n2.removeAllRanges();
|
|
41
41
|
if (c(e2)) {
|
|
42
42
|
const o3 = t2.querySelector(`[data-block-id="${e2.nodeId}"]`);
|
|
43
43
|
if (!o3) return;
|
|
@@ -62,8 +62,8 @@ function T(t2) {
|
|
|
62
62
|
const n2 = e2.anchorNode, o2 = e2.focusNode;
|
|
63
63
|
if (!n2 || !o2) return null;
|
|
64
64
|
if (!t2.contains(n2) || !t2.contains(o2)) return null;
|
|
65
|
-
const i2 = I(t2, n2, e2.anchorOffset),
|
|
66
|
-
return i2 &&
|
|
65
|
+
const i2 = I(t2, n2, e2.anchorOffset), f2 = I(t2, o2, e2.focusOffset);
|
|
66
|
+
return i2 && f2 ? r(i2, f2) : null;
|
|
67
67
|
}
|
|
68
68
|
function E(t2, e2) {
|
|
69
69
|
let n2 = null;
|
|
@@ -81,23 +81,23 @@ function E(t2, e2) {
|
|
|
81
81
|
if (1 === o2.childNodes.length && "BR" === o2.firstChild?.nodeName) return { node: o2, offset: 0 };
|
|
82
82
|
let r2 = e2.offset;
|
|
83
83
|
const i2 = y(o2);
|
|
84
|
-
let
|
|
85
|
-
for (;
|
|
86
|
-
if (
|
|
87
|
-
const t3 =
|
|
88
|
-
if (r2 <= t3) return { node:
|
|
84
|
+
let f2 = i2.nextNode();
|
|
85
|
+
for (; f2; ) {
|
|
86
|
+
if (f2.nodeType === Node.TEXT_NODE) {
|
|
87
|
+
const t3 = f2.textContent?.length ?? 0;
|
|
88
|
+
if (r2 <= t3) return { node: f2, offset: r2 };
|
|
89
89
|
r2 -= t3;
|
|
90
|
-
} else if (
|
|
90
|
+
} else if (f2 instanceof HTMLElement && "false" === f2.getAttribute("contenteditable")) {
|
|
91
91
|
if (0 === r2) {
|
|
92
|
-
const t3 =
|
|
93
|
-
if (t3) return { node: t3, offset: A(t3,
|
|
92
|
+
const t3 = f2.parentNode;
|
|
93
|
+
if (t3) return { node: t3, offset: A(t3, f2) };
|
|
94
94
|
}
|
|
95
95
|
r2 -= 1;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
f2 = i2.nextNode();
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
return
|
|
99
|
+
const l2 = o2.lastChild;
|
|
100
|
+
return l2 ? l2.nodeType === Node.TEXT_NODE ? { node: l2, offset: l2.textContent?.length ?? 0 } : { node: o2, offset: o2.childNodes.length } : { node: o2, offset: 0 };
|
|
101
101
|
}
|
|
102
102
|
function I(t2, e2, n2) {
|
|
103
103
|
const o2 = (function(t3, e3) {
|
|
@@ -111,27 +111,27 @@ function I(t2, e2, n2) {
|
|
|
111
111
|
if (!o2) return null;
|
|
112
112
|
const r2 = o2.getAttribute("data-block-id");
|
|
113
113
|
if (!r2) return null;
|
|
114
|
-
const i2 = g(r2),
|
|
114
|
+
const i2 = g(r2), f2 = (function(t3, e3) {
|
|
115
115
|
const n3 = [];
|
|
116
116
|
let o3 = e3;
|
|
117
117
|
for (; o3 && o3 !== t3; ) o3.hasAttribute("data-block-id") && n3.unshift(g(o3.getAttribute("data-block-id") ?? "")), o3 = o3.parentElement;
|
|
118
118
|
return n3;
|
|
119
|
-
})(t2, o2),
|
|
120
|
-
if (e2 === o2 || e2 ===
|
|
121
|
-
const t3 = e2 ===
|
|
119
|
+
})(t2, o2), l2 = M(o2);
|
|
120
|
+
if (e2 === o2 || e2 === l2) {
|
|
121
|
+
const t3 = e2 === l2 ? l2 : o2;
|
|
122
122
|
let r3 = 0, c3 = 0;
|
|
123
123
|
for (const e3 of Array.from(t3.childNodes)) {
|
|
124
124
|
if (c3 >= n2) break;
|
|
125
125
|
r3 += O(e3), c3++;
|
|
126
126
|
}
|
|
127
|
-
return s(i2, r3,
|
|
127
|
+
return s(i2, r3, f2.length > 1 ? f2 : void 0);
|
|
128
128
|
}
|
|
129
|
-
if (
|
|
129
|
+
if (l2 !== o2 && !l2.contains(e2)) return s(i2, 0, f2.length > 1 ? f2 : void 0);
|
|
130
130
|
let c2 = 0;
|
|
131
|
-
const u2 = y(
|
|
131
|
+
const u2 = y(l2);
|
|
132
132
|
let a2 = u2.nextNode();
|
|
133
133
|
for (; a2; ) {
|
|
134
|
-
if (a2 === e2) return a2.nodeType === Node.TEXT_NODE ? s(i2, c2 + n2,
|
|
134
|
+
if (a2 === e2) return a2.nodeType === Node.TEXT_NODE ? s(i2, c2 + n2, f2.length > 1 ? f2 : void 0) : s(i2, c2, f2.length > 1 ? f2 : void 0);
|
|
135
135
|
a2.nodeType === Node.TEXT_NODE ? c2 += a2.textContent?.length ?? 0 : a2 instanceof HTMLElement && "false" === a2.getAttribute("contenteditable") && (c2 += 1), a2 = u2.nextNode();
|
|
136
136
|
}
|
|
137
137
|
if (e2.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -140,9 +140,9 @@ function I(t2, e2, n2) {
|
|
|
140
140
|
if (o3 >= n2) break;
|
|
141
141
|
t3 += O(r3), o3++;
|
|
142
142
|
}
|
|
143
|
-
return s(i2, t3,
|
|
143
|
+
return s(i2, t3, f2.length > 1 ? f2 : void 0);
|
|
144
144
|
}
|
|
145
|
-
return s(i2, 0,
|
|
145
|
+
return s(i2, 0, f2.length > 1 ? f2 : void 0);
|
|
146
146
|
}
|
|
147
147
|
function y(t2) {
|
|
148
148
|
return document.createTreeWalker(t2, NodeFilter.SHOW_ALL, { acceptNode: (e2) => e2 instanceof HTMLElement && e2.hasAttribute("data-cursor-wrapper") || (function(t3, e3) {
|
|
@@ -174,26 +174,26 @@ function O(t2) {
|
|
|
174
174
|
}
|
|
175
175
|
function S(e2, n2, o2, r2) {
|
|
176
176
|
const i2 = n2.selection;
|
|
177
|
-
if (c(i2) ||
|
|
177
|
+
if (c(i2) || l(i2)) return false;
|
|
178
178
|
if (!u(i2)) return false;
|
|
179
|
-
const
|
|
180
|
-
if (!
|
|
181
|
-
const s2 = i2.anchor.offset, a2 = t(
|
|
179
|
+
const f2 = n2.getBlock(i2.anchor.blockId);
|
|
180
|
+
if (!f2) return false;
|
|
181
|
+
const s2 = i2.anchor.offset, a2 = t(f2), g2 = e2.querySelector(`[data-block-id="${i2.anchor.blockId}"]`), h2 = g2 instanceof HTMLElement && "rtl" === d(g2);
|
|
182
182
|
if ("left" === o2) return h2 ? s2 === a2 : 0 === s2;
|
|
183
183
|
if ("right" === o2) return h2 ? 0 === s2 : s2 === a2;
|
|
184
184
|
if ("up" === o2 && 0 === s2) return true;
|
|
185
185
|
if ("down" === o2 && s2 === a2) return true;
|
|
186
186
|
const b2 = k(e2);
|
|
187
187
|
return b2 && b2.modify ? (function(t2, e3, n3, o3) {
|
|
188
|
-
const r3 = e3.anchorNode, i3 = e3.anchorOffset,
|
|
189
|
-
if (!r3 || !
|
|
188
|
+
const r3 = e3.anchorNode, i3 = e3.anchorOffset, f3 = e3.focusNode, l2 = e3.focusOffset;
|
|
189
|
+
if (!r3 || !f3) return false;
|
|
190
190
|
const c2 = o3 ?? B(e3), s3 = "up" === n3 ? "backward" : "forward";
|
|
191
191
|
try {
|
|
192
192
|
e3.modify("move", s3, "line");
|
|
193
193
|
const n4 = e3.focusNode;
|
|
194
194
|
if (!n4) return false;
|
|
195
|
-
if (F(t2,
|
|
196
|
-
if (e3.anchorNode === r3 && e3.anchorOffset === i3 && e3.focusNode ===
|
|
195
|
+
if (F(t2, f3) !== F(t2, n4)) return true;
|
|
196
|
+
if (e3.anchorNode === r3 && e3.anchorOffset === i3 && e3.focusNode === f3 && e3.focusOffset === l2) return true;
|
|
197
197
|
if (c2) {
|
|
198
198
|
const t3 = B(e3);
|
|
199
199
|
if (t3 && Math.abs(t3.top - c2.top) < 1) return true;
|
|
@@ -201,7 +201,7 @@ function S(e2, n2, o2, r2) {
|
|
|
201
201
|
return false;
|
|
202
202
|
} finally {
|
|
203
203
|
try {
|
|
204
|
-
e3.setBaseAndExtent(r3, i3,
|
|
204
|
+
e3.setBaseAndExtent(r3, i3, f3, l2);
|
|
205
205
|
} catch {
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -220,14 +220,14 @@ function C(e2, n2, o2, r2) {
|
|
|
220
220
|
const i2 = w(n2, o2);
|
|
221
221
|
if (!i2) return null;
|
|
222
222
|
if (i2.isVoid) return b(n2, i2.targetId);
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
225
|
-
const
|
|
223
|
+
const f2 = n2.getBlock(i2.targetId);
|
|
224
|
+
if (!f2) return null;
|
|
225
|
+
const l2 = t(f2);
|
|
226
226
|
if (null !== r2) {
|
|
227
227
|
const t2 = (function(t3, e3, n3, o3) {
|
|
228
228
|
const r3 = t3.querySelector(`[data-block-id="${e3}"]`);
|
|
229
229
|
if (!r3) return null;
|
|
230
|
-
const i3 = r3.getBoundingClientRect(),
|
|
230
|
+
const i3 = r3.getBoundingClientRect(), f3 = "down" === n3 ? i3.top + 2 : i3.bottom - 2, l3 = Math.min(Math.max(o3, i3.left), i3.right - 1), c3 = N(t3.getRootNode(), l3, f3, t3.ownerDocument);
|
|
231
231
|
if (!c3) return null;
|
|
232
232
|
if (!r3.contains(c3.node)) return null;
|
|
233
233
|
const s2 = I(t3, c3.node, c3.offset);
|
|
@@ -235,33 +235,33 @@ function C(e2, n2, o2, r2) {
|
|
|
235
235
|
})(e2, i2.targetId, o2, r2);
|
|
236
236
|
if (t2) return h(n2, t2.blockId, t2.offset);
|
|
237
237
|
}
|
|
238
|
-
const c2 = "down" === o2 ? 0 :
|
|
238
|
+
const c2 = "down" === o2 ? 0 : l2;
|
|
239
239
|
return h(n2, i2.targetId, c2);
|
|
240
240
|
}
|
|
241
241
|
function L(t2, n2) {
|
|
242
242
|
if ("up" === n2 || "down" === n2) return null;
|
|
243
243
|
const o2 = t2.selection;
|
|
244
|
-
if (c(o2) ||
|
|
244
|
+
if (c(o2) || l(o2)) return null;
|
|
245
245
|
if (!u(o2)) return null;
|
|
246
246
|
const r2 = o2.anchor.blockId, i2 = t2.getBlock(r2);
|
|
247
247
|
if (!i2) return null;
|
|
248
|
-
const
|
|
248
|
+
const f2 = o2.anchor.offset;
|
|
249
249
|
return "right" === n2 ? (function(t3, n3, o3, r3) {
|
|
250
250
|
const i3 = e(o3, r3);
|
|
251
251
|
return i3 && "inline" === i3.kind ? h(t3, n3, r3 + 1) : null;
|
|
252
|
-
})(t2, r2, i2,
|
|
252
|
+
})(t2, r2, i2, f2) : (function(t3, n3, o3, r3) {
|
|
253
253
|
if (0 === r3) return null;
|
|
254
254
|
const i3 = e(o3, r3 - 1);
|
|
255
255
|
return i3 && "inline" === i3.kind ? h(t3, n3, r3 - 1) : null;
|
|
256
|
-
})(t2, r2, i2,
|
|
256
|
+
})(t2, r2, i2, f2);
|
|
257
257
|
}
|
|
258
258
|
function x(e2, o2) {
|
|
259
259
|
const r2 = e2.selection;
|
|
260
|
-
if (!
|
|
261
|
-
const i2 = e2.getBlockOrder(),
|
|
262
|
-
if (
|
|
260
|
+
if (!l(r2)) return null;
|
|
261
|
+
const i2 = e2.getBlockOrder(), f2 = i2.indexOf(r2.blockId);
|
|
262
|
+
if (f2 < 0) return null;
|
|
263
263
|
if ("before" === r2.side && ("right" === o2 || "down" === o2) || "after" === r2.side && ("left" === o2 || "up" === o2)) return b(e2, r2.blockId);
|
|
264
|
-
const c2 = "before" === r2.side ?
|
|
264
|
+
const c2 = "before" === r2.side ? f2 - 1 : f2 + 1;
|
|
265
265
|
if (c2 < 0 || c2 >= i2.length) return null;
|
|
266
266
|
const s2 = i2[c2];
|
|
267
267
|
if (!s2) return null;
|
|
@@ -276,10 +276,10 @@ function B(t2) {
|
|
|
276
276
|
}
|
|
277
277
|
function w(t2, e2) {
|
|
278
278
|
const r2 = t2.getBlockOrder(), i2 = t2.selection;
|
|
279
|
-
if (c(i2) ||
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
const s2 = "left" === e2 || "up" === e2 ?
|
|
279
|
+
if (c(i2) || l(i2)) return null;
|
|
280
|
+
const f2 = r2.indexOf(i2.anchor.blockId);
|
|
281
|
+
if (f2 < 0) return null;
|
|
282
|
+
const s2 = "left" === e2 || "up" === e2 ? f2 - 1 : f2 + 1;
|
|
283
283
|
if (s2 < 0 || s2 >= r2.length) return null;
|
|
284
284
|
const u2 = r2[s2];
|
|
285
285
|
return u2 && o(t2, i2.anchor.blockId, u2) ? { targetId: u2, isVoid: n(t2, u2) } : null;
|
|
@@ -308,4 +308,4 @@ export {
|
|
|
308
308
|
T as r,
|
|
309
309
|
p as s
|
|
310
310
|
};
|
|
311
|
-
//# sourceMappingURL=CaretNavigation-
|
|
311
|
+
//# sourceMappingURL=CaretNavigation-7JYpIKbs.mjs.map
|