@notectl/core 2.0.0 → 2.0.1
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/dist/chunks/{AttrRegistry-B2AGfTE0.mjs → AttrRegistry-Ckj9eCHj.mjs} +2 -2
- package/dist/chunks/{AttrRegistry-B2AGfTE0.mjs.map → AttrRegistry-Ckj9eCHj.mjs.map} +1 -1
- package/dist/chunks/AttributedMarkCommands-x7h4Xy7V.mjs +2 -0
- package/dist/chunks/AttributedMarkCommands-x7h4Xy7V.mjs.map +1 -0
- package/dist/chunks/BlockInsertion-zPxm6oa_.mjs +2 -0
- package/dist/chunks/BlockInsertion-zPxm6oa_.mjs.map +1 -0
- package/dist/chunks/{ColorPickerPopup-DRzFvt7o.mjs → ColorPickerPopup-CDUvkgcK.mjs} +2 -2
- package/dist/chunks/ColorPickerPopup-CDUvkgcK.mjs.map +1 -0
- package/dist/chunks/Commands-DwXBBVGR.mjs +2 -0
- package/dist/chunks/Commands-DwXBBVGR.mjs.map +1 -0
- package/dist/chunks/Document-HC8s50qJ.mjs +2 -0
- package/dist/chunks/Document-HC8s50qJ.mjs.map +1 -0
- package/dist/chunks/DocumentParser-w70-Axud.mjs +2 -0
- package/dist/chunks/DocumentParser-w70-Axud.mjs.map +1 -0
- package/dist/chunks/DomUtils-CznMAZZg.mjs +2 -0
- package/dist/chunks/DomUtils-CznMAZZg.mjs.map +1 -0
- package/dist/chunks/HTMLUtils-Cxy99Ak2.mjs +2 -0
- package/dist/chunks/HTMLUtils-Cxy99Ak2.mjs.map +1 -0
- package/dist/chunks/HeadingPlugin-B-LF-AMM.mjs +2 -0
- package/dist/chunks/HeadingPlugin-B-LF-AMM.mjs.map +1 -0
- package/dist/chunks/MarkCommands-CTuVDqnn.mjs +2 -0
- package/dist/chunks/MarkCommands-CTuVDqnn.mjs.map +1 -0
- package/dist/chunks/{NavigationQueries-ogQuObz7.mjs → NavigationQueries-DCOv4Ca5.mjs} +2 -2
- package/dist/chunks/{NavigationQueries-ogQuObz7.mjs.map → NavigationQueries-DCOv4Ca5.mjs.map} +1 -1
- package/dist/chunks/NotectlEditor-DBBJkPCW.mjs +3 -0
- package/dist/chunks/NotectlEditor-DBBJkPCW.mjs.map +1 -0
- package/dist/chunks/PluginHelpers-CdPR0MuT.mjs +2 -0
- package/dist/chunks/PluginHelpers-CdPR0MuT.mjs.map +1 -0
- package/dist/chunks/PopupManager-Du3dYnsJ.mjs +2 -0
- package/dist/chunks/{PopupManager-BM8IT6M7.mjs.map → PopupManager-Du3dYnsJ.mjs.map} +1 -1
- package/dist/chunks/PrintTypes-DukwDSWS.mjs +2 -0
- package/dist/chunks/{PrintTypes-ehbL7ipA.mjs.map → PrintTypes-DukwDSWS.mjs.map} +1 -1
- package/dist/chunks/{RangeIterator-CNI6smOg.mjs → RangeIterator-CprUbOWv.mjs} +2 -2
- package/dist/chunks/{RangeIterator-CNI6smOg.mjs.map → RangeIterator-CprUbOWv.mjs.map} +1 -1
- package/dist/chunks/{Selection-6-W6Flxc.mjs → Selection-DhbizDM4.mjs} +2 -2
- package/dist/chunks/{Selection-6-W6Flxc.mjs.map → Selection-DhbizDM4.mjs.map} +1 -1
- package/dist/chunks/{SelectionTransactions-q71GEzgE.mjs → SelectionTransactions-DB3YDIEa.mjs} +2 -2
- package/dist/chunks/{SelectionTransactions-q71GEzgE.mjs.map → SelectionTransactions-DB3YDIEa.mjs.map} +1 -1
- package/dist/chunks/{TextDirectionLocale-DB_aqrMg.mjs → TextDirectionLocale-BraFI9JF.mjs} +2 -2
- package/dist/chunks/{TextDirectionLocale-DB_aqrMg.mjs.map → TextDirectionLocale-BraFI9JF.mjs.map} +1 -1
- package/dist/chunks/XmlPatterns-DxQXGjP8.mjs +2 -0
- package/dist/chunks/XmlPatterns-DxQXGjP8.mjs.map +1 -0
- package/dist/chunks/ar-b6VdnxAs.mjs +2 -0
- package/dist/chunks/ar-b6VdnxAs.mjs.map +1 -0
- package/dist/chunks/de-fXvs5vQT.mjs +2 -0
- package/dist/chunks/de-fXvs5vQT.mjs.map +1 -0
- package/dist/chunks/es-BTqy_aQ4.mjs +2 -0
- package/dist/chunks/es-BTqy_aQ4.mjs.map +1 -0
- package/dist/chunks/fr-VdiCNF4J.mjs +2 -0
- package/dist/chunks/fr-VdiCNF4J.mjs.map +1 -0
- package/dist/chunks/hi-BdtVhAzs.mjs +2 -0
- package/dist/chunks/hi-BdtVhAzs.mjs.map +1 -0
- package/dist/chunks/index-CVwf0cdH.mjs +2 -0
- package/dist/chunks/index-CVwf0cdH.mjs.map +1 -0
- package/dist/chunks/index-D3BZFsAD.mjs +2 -0
- package/dist/chunks/index-D3BZFsAD.mjs.map +1 -0
- package/dist/chunks/pt-K0BUlM9X.mjs +2 -0
- package/dist/chunks/pt-K0BUlM9X.mjs.map +1 -0
- package/dist/chunks/ru-Tzd5N37W.mjs +2 -0
- package/dist/chunks/ru-Tzd5N37W.mjs.map +1 -0
- package/dist/chunks/zh-Di3WqY4_.mjs +2 -0
- package/dist/chunks/zh-Di3WqY4_.mjs.map +1 -0
- package/dist/{input → commands}/BlockInsertion.d.ts +14 -1
- package/dist/commands/BlockInsertion.d.ts.map +1 -0
- package/dist/commands/CommandHelpers.d.ts +4 -0
- package/dist/commands/CommandHelpers.d.ts.map +1 -1
- package/dist/commands/Commands.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/editor/EditorThemeController.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/styles/code-block.d.ts +1 -1
- package/dist/editor/styles/code-block.d.ts.map +1 -1
- package/dist/editor/theme/ThemeEngine.d.ts.map +1 -1
- package/dist/editor/theme/ThemeTokens.d.ts +17 -1
- package/dist/editor/theme/ThemeTokens.d.ts.map +1 -1
- package/dist/full.d.ts +1 -0
- package/dist/full.d.ts.map +1 -1
- package/dist/full.mjs +1 -1
- package/dist/html.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/input/InputManager.d.ts +2 -0
- package/dist/input/InputManager.d.ts.map +1 -1
- package/dist/input/InternalClipboard.d.ts +2 -22
- package/dist/input/InternalClipboard.d.ts.map +1 -1
- package/dist/input/PasteHandler.d.ts +7 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/model/Document.d.ts.map +1 -1
- package/dist/model/HTMLUtils.d.ts +2 -0
- package/dist/model/HTMLUtils.d.ts.map +1 -1
- package/dist/model/PasteInterceptor.d.ts +21 -0
- package/dist/model/PasteInterceptor.d.ts.map +1 -0
- package/dist/model/RichBlockData.d.ts +24 -0
- package/dist/model/RichBlockData.d.ts.map +1 -0
- package/dist/model/SchemaRegistry.d.ts +2 -0
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/notectl-core.mjs +1 -1
- package/dist/notectl-core.umd.js +1 -1
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +3 -0
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +7 -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/alignment.mjs.map +1 -1
- package/dist/plugins/blockquote/BlockquoteKeyboardHandlers.d.ts.map +1 -1
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/blockquote.mjs.map +1 -1
- package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts.map +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +7 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -1
- package/dist/plugins/code-block/highlighter/RegexTokenizer.d.ts +14 -0
- package/dist/plugins/code-block/highlighter/RegexTokenizer.d.ts.map +1 -0
- package/dist/plugins/code-block/highlighter/TokenizerTypes.d.ts +15 -0
- package/dist/plugins/code-block/highlighter/TokenizerTypes.d.ts.map +1 -0
- package/dist/plugins/code-block/highlighter/languages/index.d.ts +3 -0
- package/dist/plugins/code-block/highlighter/languages/index.d.ts.map +1 -0
- package/dist/plugins/code-block/highlighter/languages/json.d.ts +3 -0
- package/dist/plugins/code-block/highlighter/languages/json.d.ts.map +1 -0
- package/dist/plugins/code-block/highlighter/languages/xml.d.ts +3 -0
- package/dist/plugins/code-block/highlighter/languages/xml.d.ts.map +1 -0
- package/dist/plugins/code-block/index.d.ts +5 -1
- package/dist/plugins/code-block/index.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/code-block.mjs.map +1 -1
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font-size.mjs.map +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/font.mjs.map +1 -1
- package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -1
- package/dist/plugins/gap-cursor.mjs +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -1
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -1
- 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/highlight.mjs.map +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/horizontal-rule.mjs.map +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts +0 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image/ImagePopup.d.ts +11 -0
- package/dist/plugins/image/ImagePopup.d.ts.map +1 -0
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/image.mjs.map +1 -1
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/link.mjs.map +1 -1
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/list.mjs.map +1 -1
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/dist/plugins/print.mjs +1 -1
- package/dist/plugins/print.mjs.map +1 -1
- package/dist/plugins/shared/ColorMarkOperations.d.ts +1 -2
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
- package/dist/plugins/shared/ColorPickerPopup.d.ts +1 -8
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
- package/dist/plugins/shared/PluginHelpers.d.ts +8 -0
- package/dist/plugins/shared/PluginHelpers.d.ts.map +1 -1
- package/dist/plugins/shared/XmlPatterns.d.ts +10 -0
- package/dist/plugins/shared/XmlPatterns.d.ts.map +1 -0
- package/dist/plugins/shared/index.d.ts +1 -0
- package/dist/plugins/shared/index.d.ts.map +1 -1
- package/dist/plugins/shared.mjs +1 -1
- package/dist/plugins/shared.mjs.map +1 -1
- package/dist/plugins/smart-paste/SmartPasteLocale.d.ts +7 -0
- package/dist/plugins/smart-paste/SmartPasteLocale.d.ts.map +1 -0
- package/dist/plugins/smart-paste/SmartPastePlugin.d.ts +19 -0
- package/dist/plugins/smart-paste/SmartPastePlugin.d.ts.map +1 -0
- package/dist/plugins/smart-paste/SmartPasteTypes.d.ts +24 -0
- package/dist/plugins/smart-paste/SmartPasteTypes.d.ts.map +1 -0
- package/dist/plugins/smart-paste/detectors/JsonDetector.d.ts +6 -0
- package/dist/plugins/smart-paste/detectors/JsonDetector.d.ts.map +1 -0
- package/dist/plugins/smart-paste/detectors/XmlDetector.d.ts +26 -0
- package/dist/plugins/smart-paste/detectors/XmlDetector.d.ts.map +1 -0
- package/dist/plugins/smart-paste/index.d.ts +7 -0
- package/dist/plugins/smart-paste/index.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/ar.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/ar.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/de.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/de.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/es.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/es.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/fr.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/fr.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/hi.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/hi.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/pt.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/pt.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/ru.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/ru.d.ts.map +1 -0
- package/dist/plugins/smart-paste/locales/zh.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/zh.d.ts.map +1 -0
- package/dist/plugins/smart-paste.mjs +2 -0
- package/dist/plugins/smart-paste.mjs.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/strikethrough.mjs.map +1 -1
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/super-sub.mjs.map +1 -1
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table/index.d.ts +1 -0
- package/dist/plugins/table/index.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/table.mjs.map +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-color.mjs.map +1 -1
- package/dist/plugins/text-direction/TextDirectionCorePlugin.d.ts.map +1 -1
- package/dist/plugins/text-direction/TextDirectionPlugin.d.ts.map +1 -1
- package/dist/plugins/text-direction-advanced.mjs +1 -1
- package/dist/plugins/text-direction-advanced.mjs.map +1 -1
- package/dist/plugins/text-direction.mjs +1 -1
- package/dist/plugins/text-direction.mjs.map +1 -1
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/text-formatting.mjs.map +1 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/plugins/toolbar.mjs.map +1 -1
- package/dist/presets/FullPreset.d.ts.map +1 -1
- package/dist/presets/PresetTypes.d.ts +2 -0
- package/dist/presets/PresetTypes.d.ts.map +1 -1
- package/dist/presets/full.mjs +1 -1
- package/dist/presets/full.mjs.map +1 -1
- package/dist/serialization/DocumentSerializer.d.ts.map +1 -1
- package/dist/state/InlineContentOps.d.ts.map +1 -1
- package/dist/state/StepInversion.d.ts +7 -0
- package/dist/state/StepInversion.d.ts.map +1 -0
- package/dist/state/Steps.d.ts +108 -0
- package/dist/state/Steps.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +5 -174
- package/dist/state/Transaction.d.ts.map +1 -1
- package/dist/state/TransactionBuilder.d.ts +69 -0
- package/dist/state/TransactionBuilder.d.ts.map +1 -0
- package/dist/test/TestUtils.d.ts.map +1 -1
- package/dist/view/CaretNavigation.d.ts.map +1 -1
- package/dist/view/DomUtils.d.ts +10 -1
- package/dist/view/DomUtils.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +2 -2
- package/dist/view/EditorView.d.ts.map +1 -1
- package/dist/view/ViewMovementCommands.d.ts.map +1 -1
- package/package.json +11 -1
- package/dist/chunks/AttributedMarkCommands-BB7lzFct.mjs +0 -2
- package/dist/chunks/AttributedMarkCommands-BB7lzFct.mjs.map +0 -1
- package/dist/chunks/ColorPickerPopup-DRzFvt7o.mjs.map +0 -1
- package/dist/chunks/Commands-P9wS8qtN.mjs +0 -2
- package/dist/chunks/Commands-P9wS8qtN.mjs.map +0 -1
- package/dist/chunks/Document-BFYAonMF.mjs +0 -2
- package/dist/chunks/Document-BFYAonMF.mjs.map +0 -1
- package/dist/chunks/DocumentParser-DFcvVMGY.mjs +0 -2
- package/dist/chunks/DocumentParser-DFcvVMGY.mjs.map +0 -1
- package/dist/chunks/DomUtils-Cdz1eDKM.mjs +0 -2
- package/dist/chunks/DomUtils-Cdz1eDKM.mjs.map +0 -1
- package/dist/chunks/HTMLUtils-CCvQ5f83.mjs +0 -2
- package/dist/chunks/HTMLUtils-CCvQ5f83.mjs.map +0 -1
- package/dist/chunks/HeadingPlugin-DYy3IoT_.mjs +0 -2
- package/dist/chunks/HeadingPlugin-DYy3IoT_.mjs.map +0 -1
- package/dist/chunks/LocaleService-B6Z-wyAF.mjs +0 -2
- package/dist/chunks/LocaleService-B6Z-wyAF.mjs.map +0 -1
- package/dist/chunks/MarkCommands-B_erV7zz.mjs +0 -2
- package/dist/chunks/MarkCommands-B_erV7zz.mjs.map +0 -1
- package/dist/chunks/NotectlEditor-4NFnXLyD.mjs +0 -2
- package/dist/chunks/NotectlEditor-4NFnXLyD.mjs.map +0 -1
- package/dist/chunks/Plugin-OzM8Oxm_.mjs +0 -2
- package/dist/chunks/Plugin-OzM8Oxm_.mjs.map +0 -1
- package/dist/chunks/PluginHelpers-DjZt0pQi.mjs +0 -2
- package/dist/chunks/PluginHelpers-DjZt0pQi.mjs.map +0 -1
- package/dist/chunks/PopupManager-BM8IT6M7.mjs +0 -2
- package/dist/chunks/PrintTypes-ehbL7ipA.mjs +0 -2
- package/dist/chunks/index-C8xtb3SM.mjs +0 -2
- package/dist/chunks/index-C8xtb3SM.mjs.map +0 -1
- package/dist/chunks/index-DAoSt12h.mjs +0 -2
- package/dist/chunks/index-DAoSt12h.mjs.map +0 -1
- package/dist/input/BlockInsertion.d.ts.map +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BlockAttrs, BlockNode, InlineNode, Mark, TextSegment } from '../model/Document.js';
|
|
2
|
+
import { BlockId, NodeTypeName } from '../model/TypeBrands.js';
|
|
3
|
+
export interface InsertTextStep {
|
|
4
|
+
readonly type: 'insertText';
|
|
5
|
+
readonly blockId: BlockId;
|
|
6
|
+
readonly offset: number;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly marks: readonly Mark[];
|
|
9
|
+
readonly segments?: readonly TextSegment[];
|
|
10
|
+
readonly path?: readonly BlockId[];
|
|
11
|
+
}
|
|
12
|
+
export interface DeleteTextStep {
|
|
13
|
+
readonly type: 'deleteText';
|
|
14
|
+
readonly blockId: BlockId;
|
|
15
|
+
readonly from: number;
|
|
16
|
+
readonly to: number;
|
|
17
|
+
readonly deletedText: string;
|
|
18
|
+
readonly deletedMarks: readonly Mark[];
|
|
19
|
+
readonly deletedSegments: readonly TextSegment[];
|
|
20
|
+
readonly path?: readonly BlockId[];
|
|
21
|
+
}
|
|
22
|
+
export interface SplitBlockStep {
|
|
23
|
+
readonly type: 'splitBlock';
|
|
24
|
+
readonly blockId: BlockId;
|
|
25
|
+
readonly offset: number;
|
|
26
|
+
readonly newBlockId: BlockId;
|
|
27
|
+
readonly path?: readonly BlockId[];
|
|
28
|
+
}
|
|
29
|
+
export interface MergeBlocksStep {
|
|
30
|
+
readonly type: 'mergeBlocks';
|
|
31
|
+
readonly targetBlockId: BlockId;
|
|
32
|
+
readonly sourceBlockId: BlockId;
|
|
33
|
+
readonly targetLengthBefore: number;
|
|
34
|
+
readonly path?: readonly BlockId[];
|
|
35
|
+
}
|
|
36
|
+
export interface AddMarkStep {
|
|
37
|
+
readonly type: 'addMark';
|
|
38
|
+
readonly blockId: BlockId;
|
|
39
|
+
readonly from: number;
|
|
40
|
+
readonly to: number;
|
|
41
|
+
readonly mark: Mark;
|
|
42
|
+
readonly path?: readonly BlockId[];
|
|
43
|
+
}
|
|
44
|
+
export interface RemoveMarkStep {
|
|
45
|
+
readonly type: 'removeMark';
|
|
46
|
+
readonly blockId: BlockId;
|
|
47
|
+
readonly from: number;
|
|
48
|
+
readonly to: number;
|
|
49
|
+
readonly mark: Mark;
|
|
50
|
+
readonly path?: readonly BlockId[];
|
|
51
|
+
}
|
|
52
|
+
export interface SetStoredMarksStep {
|
|
53
|
+
readonly type: 'setStoredMarks';
|
|
54
|
+
readonly marks: readonly Mark[] | null;
|
|
55
|
+
readonly previousMarks: readonly Mark[] | null;
|
|
56
|
+
}
|
|
57
|
+
export interface SetBlockTypeStep {
|
|
58
|
+
readonly type: 'setBlockType';
|
|
59
|
+
readonly blockId: BlockId;
|
|
60
|
+
readonly nodeType: NodeTypeName;
|
|
61
|
+
readonly attrs?: BlockAttrs;
|
|
62
|
+
readonly previousNodeType: NodeTypeName;
|
|
63
|
+
readonly previousAttrs?: BlockAttrs;
|
|
64
|
+
readonly path?: readonly BlockId[];
|
|
65
|
+
}
|
|
66
|
+
export interface InsertNodeStep {
|
|
67
|
+
readonly type: 'insertNode';
|
|
68
|
+
readonly parentPath: readonly BlockId[];
|
|
69
|
+
readonly index: number;
|
|
70
|
+
readonly node: BlockNode;
|
|
71
|
+
}
|
|
72
|
+
export interface RemoveNodeStep {
|
|
73
|
+
readonly type: 'removeNode';
|
|
74
|
+
readonly parentPath: readonly BlockId[];
|
|
75
|
+
readonly index: number;
|
|
76
|
+
readonly removedNode: BlockNode;
|
|
77
|
+
}
|
|
78
|
+
export interface SetNodeAttrStep {
|
|
79
|
+
readonly type: 'setNodeAttr';
|
|
80
|
+
readonly path: readonly BlockId[];
|
|
81
|
+
readonly attrs: BlockAttrs | undefined;
|
|
82
|
+
readonly previousAttrs?: BlockAttrs;
|
|
83
|
+
}
|
|
84
|
+
export interface InsertInlineNodeStep {
|
|
85
|
+
readonly type: 'insertInlineNode';
|
|
86
|
+
readonly blockId: BlockId;
|
|
87
|
+
readonly offset: number;
|
|
88
|
+
readonly node: InlineNode;
|
|
89
|
+
readonly path?: readonly BlockId[];
|
|
90
|
+
}
|
|
91
|
+
export interface RemoveInlineNodeStep {
|
|
92
|
+
readonly type: 'removeInlineNode';
|
|
93
|
+
readonly blockId: BlockId;
|
|
94
|
+
readonly offset: number;
|
|
95
|
+
readonly removedNode: InlineNode;
|
|
96
|
+
readonly path?: readonly BlockId[];
|
|
97
|
+
}
|
|
98
|
+
export interface SetInlineNodeAttrStep {
|
|
99
|
+
readonly type: 'setInlineNodeAttr';
|
|
100
|
+
readonly blockId: BlockId;
|
|
101
|
+
readonly offset: number;
|
|
102
|
+
readonly attrs: Readonly<Record<string, string | number | boolean>>;
|
|
103
|
+
readonly previousAttrs: Readonly<Record<string, string | number | boolean>>;
|
|
104
|
+
readonly path?: readonly BlockId[];
|
|
105
|
+
}
|
|
106
|
+
export type Step = InsertTextStep | DeleteTextStep | SplitBlockStep | MergeBlocksStep | AddMarkStep | RemoveMarkStep | SetStoredMarksStep | SetBlockTypeStep | InsertNodeStep | RemoveNodeStep | SetNodeAttrStep | InsertInlineNodeStep | RemoveInlineNodeStep | SetInlineNodeAttrStep;
|
|
107
|
+
export type TransactionOrigin = 'input' | 'paste' | 'command' | 'history' | 'api';
|
|
108
|
+
//# sourceMappingURL=Steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Steps.d.ts","sourceRoot":"","sources":["../../src/state/Steps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE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,kBAAkB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IACpE,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,IAAI,GACb,cAAc,GACd,cAAc,GACd,cAAc,GACd,eAAe,GACf,WAAW,GACX,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,eAAe,GACf,oBAAoB,GACpB,oBAAoB,GACpB,qBAAqB,CAAC;AAEzB,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC"}
|
|
@@ -1,111 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Mark } from '../model/Document.js';
|
|
2
2
|
import { EditorSelection } from '../model/Selection.js';
|
|
3
|
-
import {
|
|
4
|
-
export interface InsertTextStep {
|
|
5
|
-
readonly type: 'insertText';
|
|
6
|
-
readonly blockId: BlockId;
|
|
7
|
-
readonly offset: number;
|
|
8
|
-
readonly text: string;
|
|
9
|
-
readonly marks: readonly Mark[];
|
|
10
|
-
readonly segments?: readonly TextSegment[];
|
|
11
|
-
readonly path?: readonly BlockId[];
|
|
12
|
-
}
|
|
13
|
-
export interface DeleteTextStep {
|
|
14
|
-
readonly type: 'deleteText';
|
|
15
|
-
readonly blockId: BlockId;
|
|
16
|
-
readonly from: number;
|
|
17
|
-
readonly to: number;
|
|
18
|
-
readonly deletedText: string;
|
|
19
|
-
readonly deletedMarks: readonly Mark[];
|
|
20
|
-
readonly deletedSegments: readonly TextSegment[];
|
|
21
|
-
readonly path?: readonly BlockId[];
|
|
22
|
-
}
|
|
23
|
-
export interface SplitBlockStep {
|
|
24
|
-
readonly type: 'splitBlock';
|
|
25
|
-
readonly blockId: BlockId;
|
|
26
|
-
readonly offset: number;
|
|
27
|
-
readonly newBlockId: BlockId;
|
|
28
|
-
readonly path?: readonly BlockId[];
|
|
29
|
-
}
|
|
30
|
-
export interface MergeBlocksStep {
|
|
31
|
-
readonly type: 'mergeBlocks';
|
|
32
|
-
readonly targetBlockId: BlockId;
|
|
33
|
-
readonly sourceBlockId: BlockId;
|
|
34
|
-
readonly targetLengthBefore: number;
|
|
35
|
-
readonly path?: readonly BlockId[];
|
|
36
|
-
}
|
|
37
|
-
export interface AddMarkStep {
|
|
38
|
-
readonly type: 'addMark';
|
|
39
|
-
readonly blockId: BlockId;
|
|
40
|
-
readonly from: number;
|
|
41
|
-
readonly to: number;
|
|
42
|
-
readonly mark: Mark;
|
|
43
|
-
readonly path?: readonly BlockId[];
|
|
44
|
-
}
|
|
45
|
-
export interface RemoveMarkStep {
|
|
46
|
-
readonly type: 'removeMark';
|
|
47
|
-
readonly blockId: BlockId;
|
|
48
|
-
readonly from: number;
|
|
49
|
-
readonly to: number;
|
|
50
|
-
readonly mark: Mark;
|
|
51
|
-
readonly path?: readonly BlockId[];
|
|
52
|
-
}
|
|
53
|
-
export interface SetStoredMarksStep {
|
|
54
|
-
readonly type: 'setStoredMarks';
|
|
55
|
-
readonly marks: readonly Mark[] | null;
|
|
56
|
-
readonly previousMarks: readonly Mark[] | null;
|
|
57
|
-
}
|
|
58
|
-
export interface SetBlockTypeStep {
|
|
59
|
-
readonly type: 'setBlockType';
|
|
60
|
-
readonly blockId: BlockId;
|
|
61
|
-
readonly nodeType: NodeTypeName;
|
|
62
|
-
readonly attrs?: BlockAttrs;
|
|
63
|
-
readonly previousNodeType: NodeTypeName;
|
|
64
|
-
readonly previousAttrs?: BlockAttrs;
|
|
65
|
-
readonly path?: readonly BlockId[];
|
|
66
|
-
}
|
|
67
|
-
export interface InsertNodeStep {
|
|
68
|
-
readonly type: 'insertNode';
|
|
69
|
-
readonly parentPath: readonly BlockId[];
|
|
70
|
-
readonly index: number;
|
|
71
|
-
readonly node: BlockNode;
|
|
72
|
-
}
|
|
73
|
-
export interface RemoveNodeStep {
|
|
74
|
-
readonly type: 'removeNode';
|
|
75
|
-
readonly parentPath: readonly BlockId[];
|
|
76
|
-
readonly index: number;
|
|
77
|
-
readonly removedNode: BlockNode;
|
|
78
|
-
}
|
|
79
|
-
export interface SetNodeAttrStep {
|
|
80
|
-
readonly type: 'setNodeAttr';
|
|
81
|
-
readonly path: readonly BlockId[];
|
|
82
|
-
readonly attrs: BlockAttrs | undefined;
|
|
83
|
-
readonly previousAttrs?: BlockAttrs;
|
|
84
|
-
}
|
|
85
|
-
export interface InsertInlineNodeStep {
|
|
86
|
-
readonly type: 'insertInlineNode';
|
|
87
|
-
readonly blockId: BlockId;
|
|
88
|
-
readonly offset: number;
|
|
89
|
-
readonly node: InlineNode;
|
|
90
|
-
readonly path?: readonly BlockId[];
|
|
91
|
-
}
|
|
92
|
-
export interface RemoveInlineNodeStep {
|
|
93
|
-
readonly type: 'removeInlineNode';
|
|
94
|
-
readonly blockId: BlockId;
|
|
95
|
-
readonly offset: number;
|
|
96
|
-
readonly removedNode: InlineNode;
|
|
97
|
-
readonly path?: readonly BlockId[];
|
|
98
|
-
}
|
|
99
|
-
export interface SetInlineNodeAttrStep {
|
|
100
|
-
readonly type: 'setInlineNodeAttr';
|
|
101
|
-
readonly blockId: BlockId;
|
|
102
|
-
readonly offset: number;
|
|
103
|
-
readonly attrs: Readonly<Record<string, string | number | boolean>>;
|
|
104
|
-
readonly previousAttrs: Readonly<Record<string, string | number | boolean>>;
|
|
105
|
-
readonly path?: readonly BlockId[];
|
|
106
|
-
}
|
|
107
|
-
export type Step = InsertTextStep | DeleteTextStep | SplitBlockStep | MergeBlocksStep | AddMarkStep | RemoveMarkStep | SetStoredMarksStep | SetBlockTypeStep | InsertNodeStep | RemoveNodeStep | SetNodeAttrStep | InsertInlineNodeStep | RemoveInlineNodeStep | SetInlineNodeAttrStep;
|
|
108
|
-
export type TransactionOrigin = 'input' | 'paste' | 'command' | 'history' | 'api';
|
|
3
|
+
import { Step, TransactionOrigin } from './Steps.js';
|
|
109
4
|
export interface TransactionMetadata {
|
|
110
5
|
readonly origin: TransactionOrigin;
|
|
111
6
|
readonly timestamp: number;
|
|
@@ -119,71 +14,7 @@ export interface Transaction {
|
|
|
119
14
|
readonly storedMarksAfter: readonly Mark[] | null;
|
|
120
15
|
readonly metadata: TransactionMetadata;
|
|
121
16
|
}
|
|
122
|
-
|
|
123
|
-
export
|
|
124
|
-
|
|
125
|
-
export declare function invertTransaction(tr: Transaction): Transaction;
|
|
126
|
-
/** Fluent API for building transactions. */
|
|
127
|
-
export declare class TransactionBuilder {
|
|
128
|
-
private readonly steps;
|
|
129
|
-
private selection;
|
|
130
|
-
private storedMarks;
|
|
131
|
-
private readonly selectionBefore;
|
|
132
|
-
private readonly origin;
|
|
133
|
-
private workingDoc;
|
|
134
|
-
private _readonlyAllowed;
|
|
135
|
-
constructor(currentSelection: EditorSelection, currentStoredMarks: readonly Mark[] | null, origin?: TransactionOrigin, doc?: Document);
|
|
136
|
-
/** Adds an insert-text step. Updates workingDoc if available. */
|
|
137
|
-
insertText(blockId: BlockId, offset: number, text: string, marks: readonly Mark[], segments?: readonly TextSegment[]): this;
|
|
138
|
-
/** Adds a delete-text step with explicit data. Updates workingDoc if available. */
|
|
139
|
-
deleteText(blockId: BlockId, from: number, to: number, deletedText: string, deletedMarks: readonly Mark[], deletedSegments?: readonly TextSegment[]): this;
|
|
140
|
-
/**
|
|
141
|
-
* Deletes text at the given range, auto-deriving deletedText, deletedMarks, and deletedSegments
|
|
142
|
-
* from the working document. Requires a document to be provided at construction.
|
|
143
|
-
*/
|
|
144
|
-
deleteTextAt(blockId: BlockId, from: number, to: number): this;
|
|
145
|
-
/** Adds a split-block step. Updates workingDoc if available. */
|
|
146
|
-
splitBlock(blockId: BlockId, offset: number, newBlockId: BlockId): this;
|
|
147
|
-
/** Adds a merge-blocks step with explicit targetLengthBefore. Updates workingDoc if available. */
|
|
148
|
-
mergeBlocks(targetBlockId: BlockId, sourceBlockId: BlockId, targetLengthBefore: number): this;
|
|
149
|
-
/**
|
|
150
|
-
* Merges two blocks, auto-deriving targetLengthBefore from the working document.
|
|
151
|
-
* Requires a document to be provided at construction.
|
|
152
|
-
*/
|
|
153
|
-
mergeBlocksAt(targetBlockId: BlockId, sourceBlockId: BlockId): this;
|
|
154
|
-
/** Adds an add-mark step. Updates workingDoc if available. */
|
|
155
|
-
addMark(blockId: BlockId, from: number, to: number, mark: Mark): this;
|
|
156
|
-
/** Adds a remove-mark step. Updates workingDoc if available. */
|
|
157
|
-
removeMark(blockId: BlockId, from: number, to: number, mark: Mark): this;
|
|
158
|
-
/** Adds a set-block-type step, changing a block's node type and optionally its attrs. */
|
|
159
|
-
setBlockType(blockId: BlockId, nodeType: NodeTypeName, attrs?: BlockAttrs): this;
|
|
160
|
-
/** Inserts a node as a child of the parent at the given path and index. */
|
|
161
|
-
insertNode(parentPath: readonly BlockId[], index: number, node: BlockNode): this;
|
|
162
|
-
/** Removes a node at the given index from the parent at the given path. */
|
|
163
|
-
removeNode(parentPath: readonly BlockId[], index: number): this;
|
|
164
|
-
/** Sets attributes on a node at the given path. */
|
|
165
|
-
setNodeAttr(path: readonly BlockId[], attrs: BlockAttrs): this;
|
|
166
|
-
/** Inserts an InlineNode at the given offset within a block. */
|
|
167
|
-
insertInlineNode(blockId: BlockId, offset: number, node: InlineNode): this;
|
|
168
|
-
/** Removes an InlineNode at the given offset, deriving removedNode from workingDoc. */
|
|
169
|
-
removeInlineNode(blockId: BlockId, offset: number): this;
|
|
170
|
-
/** Sets attributes on an InlineNode at the given offset. */
|
|
171
|
-
setInlineNodeAttr(blockId: BlockId, offset: number, attrs: Readonly<Record<string, string | number | boolean>>): this;
|
|
172
|
-
/** Marks this transaction as allowed in readonly mode. */
|
|
173
|
-
readonlyAllowed(): this;
|
|
174
|
-
/** Sets the selection for the resulting state. */
|
|
175
|
-
setSelection(selection: EditorSelection): this;
|
|
176
|
-
/** Sets a NodeSelection for the resulting state. */
|
|
177
|
-
setNodeSelection(nodeId: BlockId, path: readonly BlockId[]): this;
|
|
178
|
-
/** Sets stored marks for the resulting state. */
|
|
179
|
-
setStoredMarks(marks: readonly Mark[] | null, previousMarks: readonly Mark[] | null): this;
|
|
180
|
-
/** Builds the final transaction. */
|
|
181
|
-
build(): Transaction;
|
|
182
|
-
/** Advances the working document by applying a step. */
|
|
183
|
-
private advanceDoc;
|
|
184
|
-
}
|
|
185
|
-
/** Helper to create a TransactionBuilder with input origin. */
|
|
186
|
-
export declare function inputTransaction(selection: EditorSelection, storedMarks: readonly Mark[] | null): TransactionBuilder;
|
|
187
|
-
/** Helper to create a TransactionBuilder with command origin. */
|
|
188
|
-
export declare function commandTransaction(selection: EditorSelection, storedMarks: readonly Mark[] | null): TransactionBuilder;
|
|
17
|
+
export * from './Steps.js';
|
|
18
|
+
export { invertStep, invertTransaction } from './StepInversion.js';
|
|
19
|
+
export { TransactionBuilder } from './TransactionBuilder.js';
|
|
189
20
|
//# sourceMappingURL=Transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/state/Transaction.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/state/Transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI1D,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5C,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAC;IACzC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACvC;AAID,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { BlockAttrs, BlockNode, Document, InlineNode, Mark, TextSegment } from '../model/Document.js';
|
|
2
|
+
import { EditorSelection } from '../model/Selection.js';
|
|
3
|
+
import { BlockId, NodeTypeName } from '../model/TypeBrands.js';
|
|
4
|
+
import { TransactionOrigin } from './Steps.js';
|
|
5
|
+
import { Transaction } from './Transaction.js';
|
|
6
|
+
/** Fluent API for building transactions. */
|
|
7
|
+
export declare class TransactionBuilder {
|
|
8
|
+
private readonly steps;
|
|
9
|
+
private selection;
|
|
10
|
+
private storedMarks;
|
|
11
|
+
private readonly selectionBefore;
|
|
12
|
+
private readonly origin;
|
|
13
|
+
private workingDoc;
|
|
14
|
+
private _readonlyAllowed;
|
|
15
|
+
constructor(currentSelection: EditorSelection, currentStoredMarks: readonly Mark[] | null, origin?: TransactionOrigin, doc?: Document);
|
|
16
|
+
/** Adds an insert-text step. Updates workingDoc if available. */
|
|
17
|
+
insertText(blockId: BlockId, offset: number, text: string, marks: readonly Mark[], segments?: readonly TextSegment[]): this;
|
|
18
|
+
/** Adds a delete-text step with explicit data. Updates workingDoc if available. */
|
|
19
|
+
deleteText(blockId: BlockId, from: number, to: number, deletedText: string, deletedMarks: readonly Mark[], deletedSegments?: readonly TextSegment[]): this;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes text at the given range, auto-deriving deletedText, deletedMarks, and deletedSegments
|
|
22
|
+
* from the working document. Requires a document to be provided at construction.
|
|
23
|
+
*/
|
|
24
|
+
deleteTextAt(blockId: BlockId, from: number, to: number): this;
|
|
25
|
+
/** Adds a split-block step. Updates workingDoc if available. */
|
|
26
|
+
splitBlock(blockId: BlockId, offset: number, newBlockId: BlockId): this;
|
|
27
|
+
/** Adds a merge-blocks step with explicit targetLengthBefore. Updates workingDoc if available. */
|
|
28
|
+
mergeBlocks(targetBlockId: BlockId, sourceBlockId: BlockId, targetLengthBefore: number): this;
|
|
29
|
+
/**
|
|
30
|
+
* Merges two blocks, auto-deriving targetLengthBefore from the working document.
|
|
31
|
+
* Requires a document to be provided at construction.
|
|
32
|
+
*/
|
|
33
|
+
mergeBlocksAt(targetBlockId: BlockId, sourceBlockId: BlockId): this;
|
|
34
|
+
/** Adds an add-mark step. Updates workingDoc if available. */
|
|
35
|
+
addMark(blockId: BlockId, from: number, to: number, mark: Mark): this;
|
|
36
|
+
/** Adds a remove-mark step. Updates workingDoc if available. */
|
|
37
|
+
removeMark(blockId: BlockId, from: number, to: number, mark: Mark): this;
|
|
38
|
+
/** Adds a set-block-type step, changing a block's node type and optionally its attrs. */
|
|
39
|
+
setBlockType(blockId: BlockId, nodeType: NodeTypeName, attrs?: BlockAttrs): this;
|
|
40
|
+
/** Inserts a node as a child of the parent at the given path and index. */
|
|
41
|
+
insertNode(parentPath: readonly BlockId[], index: number, node: BlockNode): this;
|
|
42
|
+
/** Removes a node at the given index from the parent at the given path. */
|
|
43
|
+
removeNode(parentPath: readonly BlockId[], index: number): this;
|
|
44
|
+
/** Sets attributes on a node at the given path. */
|
|
45
|
+
setNodeAttr(path: readonly BlockId[], attrs: BlockAttrs): this;
|
|
46
|
+
/** Inserts an InlineNode at the given offset within a block. */
|
|
47
|
+
insertInlineNode(blockId: BlockId, offset: number, node: InlineNode): this;
|
|
48
|
+
/** Removes an InlineNode at the given offset, deriving removedNode from workingDoc. */
|
|
49
|
+
removeInlineNode(blockId: BlockId, offset: number): this;
|
|
50
|
+
/** Sets attributes on an InlineNode at the given offset. */
|
|
51
|
+
setInlineNodeAttr(blockId: BlockId, offset: number, attrs: Readonly<Record<string, string | number | boolean>>): this;
|
|
52
|
+
/** Marks this transaction as allowed in readonly mode. */
|
|
53
|
+
readonlyAllowed(): this;
|
|
54
|
+
/** Sets the selection for the resulting state. */
|
|
55
|
+
setSelection(selection: EditorSelection): this;
|
|
56
|
+
/** Sets a NodeSelection for the resulting state. */
|
|
57
|
+
setNodeSelection(nodeId: BlockId, path: readonly BlockId[]): this;
|
|
58
|
+
/** Sets stored marks for the resulting state. */
|
|
59
|
+
setStoredMarks(marks: readonly Mark[] | null, previousMarks: readonly Mark[] | null): this;
|
|
60
|
+
/** Builds the final transaction. */
|
|
61
|
+
build(): Transaction;
|
|
62
|
+
/** Returns the working document or throws if not available. */
|
|
63
|
+
private requireDoc;
|
|
64
|
+
/** Finds a block in the document or throws if not found. */
|
|
65
|
+
private requireBlock;
|
|
66
|
+
/** Advances the working document by applying a step. */
|
|
67
|
+
private advanceDoc;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=TransactionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionBuilder.d.ts","sourceRoot":"","sources":["../../src/state/TransactionBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,WAAW,EACX,MAAM,sBAAsB,CAAC;AAY9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAeX,iBAAiB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,4CAA4C;AAC5C,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,gBAAgB,CAAS;gBAGhC,gBAAgB,EAAE,eAAe,EACjC,kBAAkB,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,EAC1C,MAAM,GAAE,iBAAyB,EACjC,GAAG,CAAC,EAAE,QAAQ;IASf,iEAAiE;IACjE,UAAU,CACT,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,CAAC,EAAE,SAAS,WAAW,EAAE,GAC/B,IAAI;IAcP,mFAAmF;IACnF,UAAU,CACT,OAAO,EAAE,OAAO,EAChB,IAAI,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AC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAI9F;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,WAAW,GAAG,IAAI,GAC7C,WAAW,CAMb;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAQxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaretNavigation.d.ts","sourceRoot":"","sources":["../../src/view/CaretNavigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"CaretNavigation.d.ts","sourceRoot":"","sources":["../../src/view/CaretNavigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAWjE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;AAQ9D;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,cAAc,EACzB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,GACxB,OAAO,CAiCT;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,cAAc,GACvB,WAAW,GAAG,IAAI,CAcpB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC7C,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,IAAI,GAAG,MAAM,EACxB,UAAU,EAAE,MAAM,GAAG,IAAI,GACvB,WAAW,GAAG,IAAI,CAoBpB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,GAAG,WAAW,GAAG,IAAI,CAgBhG;AAyBD,wEAAwE;AACxE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,GAAG,OAAO,GAAG,IAAI,CAMtF"}
|
package/dist/view/DomUtils.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { BlockId } from '../model/TypeBrands.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Creates an HTMLElement with the required `data-block-id` attribute.
|
|
4
|
+
*
|
|
5
|
+
* Intentionally used by plugins in `NodeSpec.toDOM()` callbacks —
|
|
6
|
+
* this is an accepted targeted import per ARCHITECTURE.md.
|
|
7
|
+
*/
|
|
3
8
|
export declare function createBlockElement(tag: string, blockId: BlockId): HTMLElement;
|
|
9
|
+
/** Builds the block path from a leaf element up to the container. */
|
|
10
|
+
export declare function buildBlockPath(container: HTMLElement, leafBlockEl: HTMLElement): BlockId[];
|
|
11
|
+
/** Finds the nearest ancestor element with a `data-block-id` attribute. */
|
|
12
|
+
export declare function findBlockAncestor(container: HTMLElement, node: Node): HTMLElement | null;
|
|
4
13
|
//# sourceMappingURL=DomUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomUtils.d.ts","sourceRoot":"","sources":["../../src/view/DomUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"DomUtils.d.ts","sourceRoot":"","sources":["../../src/view/DomUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGtD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,WAAW,CAI7E;AAED,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,EAAE,CAU1F;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,WAAW,GAAG,IAAI,CASxF"}
|
|
@@ -74,8 +74,6 @@ export declare class EditorView {
|
|
|
74
74
|
* appends a new paragraph after the last block and focuses it.
|
|
75
75
|
*/
|
|
76
76
|
private handleClickBelowContent;
|
|
77
|
-
/** Builds an array of block IDs from root to leaf. */
|
|
78
|
-
private buildBlockPath;
|
|
79
77
|
/** Allows file drop by preventing default on dragover when files are present. */
|
|
80
78
|
private onDragover;
|
|
81
79
|
/** Handles file drop by delegating to registered file handlers. */
|
|
@@ -84,6 +82,8 @@ export declare class EditorView {
|
|
|
84
82
|
private getPositionFromPoint;
|
|
85
83
|
/** Handles DOM selection changes (clicks, arrow keys). */
|
|
86
84
|
private onSelectionChange;
|
|
85
|
+
/** Reconciles DOM and syncs selection, updating decoration state. */
|
|
86
|
+
private reconcileAndSync;
|
|
87
87
|
private reconcileOptions;
|
|
88
88
|
/** Registers arrow-key keymaps with navigation priority for cross-block movement. */
|
|
89
89
|
private registerNavigationKeymaps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorView.d.ts","sourceRoot":"","sources":["../../src/view/EditorView.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,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":3,"file":"ViewMovementCommands.d.ts","sourceRoot":"","sources":["../../src/view/ViewMovementCommands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D,KAAK,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AACxC,KAAK,WAAW,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC;AAMpD;;;GAGG;AACH,wBAAgB,QAAQ,CACvB,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,GACtB,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"ViewMovementCommands.d.ts","sourceRoot":"","sources":["../../src/view/ViewMovementCommands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D,KAAK,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AACxC,KAAK,WAAW,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC;AAMpD;;;GAGG;AACH,wBAAgB,QAAQ,CACvB,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,GACtB,WAAW,GAAG,IAAI,CAEpB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACzB,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,GACtB,WAAW,GAAG,IAAI,CAEpB;AAmMD,yCAAyC;AACzC,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,GAAG,WA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E,KAAK,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAE7F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notectl/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A modern and accessible rich text editor shipped as a single Web Component. Immutable state, transaction-based architecture, and a plugin system that powers every feature.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -126,6 +126,10 @@
|
|
|
126
126
|
"types": "./dist/plugins/print/index.d.ts",
|
|
127
127
|
"import": "./dist/plugins/print.mjs"
|
|
128
128
|
},
|
|
129
|
+
"./plugins/smart-paste": {
|
|
130
|
+
"types": "./dist/plugins/smart-paste/index.d.ts",
|
|
131
|
+
"import": "./dist/plugins/smart-paste.mjs"
|
|
132
|
+
},
|
|
129
133
|
"./plugins/text-direction": {
|
|
130
134
|
"types": "./dist/plugins/text-direction/index.d.ts",
|
|
131
135
|
"import": "./dist/plugins/text-direction.mjs"
|
|
@@ -242,6 +246,12 @@
|
|
|
242
246
|
"limit": "15 KB",
|
|
243
247
|
"gzip": true
|
|
244
248
|
},
|
|
249
|
+
{
|
|
250
|
+
"name": "Plugin: Smart Paste",
|
|
251
|
+
"path": "dist/plugins/smart-paste.mjs",
|
|
252
|
+
"limit": "5 KB",
|
|
253
|
+
"gzip": true
|
|
254
|
+
},
|
|
245
255
|
{
|
|
246
256
|
"name": "Plugin: Link",
|
|
247
257
|
"path": "dist/plugins/link.mjs",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./AttrRegistry-B2AGfTE0.mjs";import{h as n,m as o,k as r,q as e}from"./Document-BFYAonMF.mjs";import{h as s,g as c,i as a,s as i}from"./Selection-6-W6Flxc.mjs";import{m as l}from"./TypeBrands-Bp_Z_o5Y.mjs";import{f}from"./RangeIterator-CNI6smOg.mjs";function u(t,o){const r=t.selection;if(s(r)||c(r))return null;const e=l(o.type);if(a(r)){const s=t.getBlock(r.anchor.blockId);if(!s)return null;const c=[...(t.storedMarks??n(s,r.anchor.offset)).filter(t=>t.type!==e),o];return t.transaction("command").setStoredMarks(c,t.storedMarks).setSelection(r).build()}const u=i(r,t.getBlockOrder()),m=t.transaction("command");return f(t,u,(n,r,s)=>{const c=t.getBlock(n);if(c){const t=p(c,e,r,s);t&&m.removeMark(n,r,s,t)}m.addMark(n,r,s,o)}),m.setSelection(r),m.build()}function m(t,r){const e=t.selection;if(s(e)||c(e))return null;if(a(e)){const s=t.getBlock(e.anchor.blockId);if(!s)return null;const c=t.storedMarks??n(s,e.anchor.offset);if(!o(c,r))return null;const a=c.filter(t=>t.type!==r);return t.transaction("command").setStoredMarks(a,t.storedMarks).setSelection(e).build()}const l=i(e,t.getBlockOrder()),u=t.transaction("command");return f(t,l,(n,o,e)=>{const s=t.getBlock(n),c=s?p(s,r,o,e):void 0;u.removeMark(n,o,e,c??{type:r})}),u.setSelection(e),u.build()}function d(o,r,e){const i=o.selection;if(s(i)||c(i))return null;if(a(i)&&o.storedMarks){const n=o.storedMarks.find(t=>t.type===r);return n&&t(n,r)?e(n):null}const l=o.getBlock(i.anchor.blockId);if(!l)return null;const f=n(l,i.anchor.offset).find(t=>t.type===r);return f&&t(f,r)?e(f):null}function k(t,n){return null!==d(t,n,()=>!0)}function p(t,n,o,s){const c=r(t);let a=0;for(const r of c){if(!e(r)){a+=1;continue}const t=a+r.text.length;if(t>o&&a<s){const t=r.marks.find(t=>t.type===n);if(t)return t}a=t}}export{u as a,d as g,k as i,m as r};
|
|
2
|
-
//# sourceMappingURL=AttributedMarkCommands-BB7lzFct.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AttributedMarkCommands-BB7lzFct.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":"6QAuCO,SAASA,EAAoBC,EAAoBC,GACvD,MAAMC,EAAMF,EAAMG,UAClB,GAAIC,EAAgBF,IAAQG,EAAYH,GAAM,OAAO,KAErD,MAAMI,EAAyBC,EAASN,EAAKO,MAE7C,GAAIC,EAAYP,GAAM,CACrB,MAAMQ,EAAcV,EAAMW,SAAST,EAAIU,OAAOC,SAC9C,IAAKH,EAAa,OAAO,KACzB,MAGMI,EAA4B,KAFjCd,EAAMe,aAAeC,EAAsBN,EAAaR,EAAIU,OAAOK,SAClBC,OAAQC,GAAMA,EAAEX,OAASF,GACxBL,GAEnD,OAAOD,EACLoB,YAAY,WACZC,eAAeP,EAAUd,EAAMe,aAC/BO,aAAapB,GACbqB,OACH,CAEA,MAAMC,EAAQC,EAAevB,EAAKF,EAAM0B,iBAClCC,EAAU3B,EAAMoB,YAAY,WAclC,OAZAQ,EAAoB5B,EAAOwB,EAAO,CAACX,EAASgB,EAAMC,KACjD,MAAMC,EAA+B/B,EAAMW,SAASE,GACpD,GAAI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6B,GACnE,OAAOK,GAASE,EAAaF,EAAOL,GAAgBI,EAAUC,GAAS,IACxE,CAEA,MAAMX,EAAQ/B,EAAMW,SAAST,EAAIU,OAAOC,SACxC,IAAKkB,EAAO,OAAO,KACnB,MACMW,EADyB1B,EAAsBe,EAAO7B,EAAIU,OAAOK,QACnD0B,KAAMxB,GAAOA,EAAEX,OAAoB6B,GACvD,OAAOK,GAASE,EAAaF,EAAOL,GAAgBI,EAAUC,GAAS,IACxE,CAMO,SAASG,EACf7C,EACAqC,GAEA,OAA4E,OAArEG,EAAuBxC,EAAOqC,EAAc,KAAM,EAC1D,CAQA,SAASJ,EACRF,EACAzB,EACAuB,EACAC,GAEA,MAAMgB,EAA+CC,EAAkBhB,GACvE,IAAIiB,EAAM,EAEV,IAAA,MAAWC,KAASH,EAAU,CAC7B,IAAKI,EAAWD,GAAQ,CACvBD,GAAO,EACP,QACD,CACA,MAAMG,EAAkBH,EAAMC,EAAMG,KAAKC,OACzC,GAAIF,EAAUtB,GAAQmB,EAAMlB,EAAI,CAC/B,MAAMY,EAA0BO,EAAMK,MAAMX,KAAMxB,GAAMA,EAAEX,OAASF,GACnE,GAAIoC,EAAO,OAAOA,CACnB,CACAM,EAAMG,CACP,CAED"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerPopup-DRzFvt7o.mjs","sources":["../../src/plugins/shared/ColorMarkOperations.ts","../../src/plugins/shared/ColorPickerPopup.ts"],"sourcesContent":["/**\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 * Delegates to the generic AttributedMarkCommands helpers for the\n * collapsed-vs-range branching logic.\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport type { MarkAttrRegistry } from '../../model/AttrRegistry.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { isValidCSSColor } from './ColorValidation.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\treturn getMarkAttrAtSelection(state, markTypeName, (m) => m.attrs.color ?? 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\tif (!isValidCSSColor(color)) return false;\n\n\tconst mark = { type: markType(markTypeName), attrs: { color } };\n\tconst tr = applyAttributedMark(state, mark);\n\tif (!tr) return false;\n\n\tcontext.dispatch(tr);\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 tr = removeAttributedMark(state, markType(markTypeName));\n\tif (!tr) return false;\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n","/**\n * Shared color picker popup rendering with WAI-ARIA grid keyboard navigation.\n * Used by TextColorPlugin and HighlightPlugin.\n * Delegates grid rendering to the shared ColorGrid module.\n */\n\nimport type { MarkAttrRegistry } from '../../model/AttrRegistry.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { renderColorGrid } from './ColorGrid.js';\nimport { applyColorMark, getActiveColor } from './ColorMarkOperations.js';\nimport type { PopupCloseOptions } from './PopupManager.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: (options?: PopupCloseOptions) => void;\n}\n\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 contentElement: HTMLElement = context.getContainer();\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({ restoreFocusTo: contentElement });\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 (delegated to shared ColorGrid) ---\n\trenderColorGrid(container, {\n\t\tcolors: config.colors,\n\t\tcolumns,\n\t\tariaLabel: `${config.ariaLabelPrefix} color picker`,\n\t\tariaLabelPrefix: config.ariaLabelPrefix,\n\t\tactiveColor,\n\t\tonSelect: (color: string) => {\n\t\t\tapplyColorMark(context, context.getState(), config.markType, color);\n\t\t\tconfig.onClose({ restoreFocusTo: contentElement });\n\t\t},\n\t\tonClose: config.onClose,\n\t});\n}\n"],"names":["getActiveColor","state","markTypeName","getMarkAttrAtSelection","m","attrs","color","isColorMarkActive","applyColorMark","context","isValidCSSColor","mark","type","markType","tr","applyAttributedMark","dispatch","removeColorMark","removeAttributedMark","renderColorPickerPopup","container","config","classList","add","activeColor","getState","columns","contentElement","getContainer","resetBtn","document","createElement","className","textContent","resetLabel","addEventListener","e","preventDefault","stopPropagation","executeCommand","resetCommand","onClose","restoreFocusTo","key","appendChild","renderColorGrid","colors","ariaLabel","ariaLabelPrefix","onSelect"],"mappings":"iNA6BO,SAASA,EAAeC,EAAoBC,GAClD,OAAOC,EAAuBF,EAAOC,EAAeE,GAAMA,EAAEC,MAAMC,OAAS,KAC5E,CAGO,SAASC,EAAkBN,EAAoBC,GACrD,OAA+C,OAAxCF,EAAeC,EAAOC,EAC9B,CAMO,SAASM,EACfC,EACAR,EACAC,EACAI,GAEA,IAAKI,EAAgBJ,GAAQ,OAAO,EAEpC,MAAMK,EAAO,CAAEC,KAAMC,EAASX,GAAeG,MAAO,CAAEC,UAChDQ,EAAKC,EAAoBd,EAAOU,GACtC,QAAKG,IAELL,EAAQO,SAASF,IACV,EACR,CAMO,SAASG,EACfR,EACAR,EACAC,GAEA,MAAMY,EAAKI,EAAqBjB,EAAOY,EAASX,IAChD,QAAKY,IAELL,EAAQO,SAASF,IACV,EACR,CChCO,SAASK,EACfC,EACAX,EACAY,GAEAD,EAAUE,UAAUC,IAAI,wBAExB,MACMC,EAA6BxB,EADrBS,EAAQgB,WACmCJ,EAAOR,UAC1Da,EAAkBL,EAAOK,SArBhB,GAsBTC,EAA8BlB,EAAQmB,eAGtCC,EAA8BC,SAASC,cAAc,UAC3DF,EAASjB,KAAO,SAChBiB,EAASG,UAAY,gCACrBH,EAASI,YAAcZ,EAAOa,WAC9BL,EAASM,iBAAiB,YAAcC,IACvCA,EAAEC,iBACFD,EAAEE,kBACF7B,EAAQ8B,eAAelB,EAAOmB,cAC9BnB,EAAOoB,QAAQ,CAAEC,eAAgBf,MAElCE,EAASM,iBAAiB,UAAYC,IACvB,WAAVA,EAAEO,MACLP,EAAEC,iBACFhB,EAAOoB,aAGTrB,EAAUwB,YAAYf,GAGtBgB,EAAgBzB,EAAW,CAC1B0B,OAAQzB,EAAOyB,OACfpB,UACAqB,UAAW,GAAG1B,EAAO2B,+BACrBA,gBAAiB3B,EAAO2B,gBACxBxB,cACAyB,SAAW3C,IACVE,EAAeC,EAASA,EAAQgB,WAAYJ,EAAOR,SAAUP,GAC7De,EAAOoB,QAAQ,CAAEC,eAAgBf,KAElCc,QAASpB,EAAOoB,SAElB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as t,e as n,s as e,n as o,f as c,d as r,h as i,p as l}from"./Document-BFYAonMF.mjs";import{a as s,e as d,d as f,s as u,i as a}from"./NavigationQueries-ogQuObz7.mjs";import{i as b,s as k,c as I,h,g,a as m,b as p,e as S}from"./Selection-6-W6Flxc.mjs";import{n as B,i as x}from"./TypeBrands-Bp_Z_o5Y.mjs";function O(t,n){if(0===n.length)return t.doc.children;const e=t.getBlock(n[n.length-1]);return e?e.children:[]}function N(e){return t(B("paragraph"),[n("")],e)}function A(t,n){if(b(t))return{blockId:t.anchor.blockId,offset:t.anchor.offset};const e=k(t,n);return{blockId:e.from.blockId,offset:e.from.offset}}function T(t,n){const r=s(t.doc,n.nodeId);if(!r)return null;const i=r.length>1?r.slice(0,-1):[],l=O(t,i),d=l.findIndex(t=>"id"in t&&t.id===n.nodeId);if(d<0)return null;const f=t.transaction("input");if(1===l.length&&0===i.length){const t=e();return f.insertNode(i,0,N(t)),f.removeNode(i,1),f.setSelection(I(t,0)),f.build()}f.removeNode(i,d);const u=l[d-1];if(u&&o(u)){const n=M(u);if(n){const e=t.getBlock(n),o=e?c(e):0;f.setSelection(I(n,o))}}else{const t=l[d+1];if(t&&o(t)){const n=v(t);n&&f.setSelection(I(n,0))}}return f.build()}function j(t,n,e){const o=t.selection,r=t.getBlockOrder(),i=!e||"left"!==n&&"right"!==n?n:"left"===n?"right":"left";return h(o)?function(t,n,e,o){const r=o.indexOf(n.nodeId),i=s(t.doc,n.nodeId)??[];if("left"===e||"up"===e){if(r>0){const e=o[r-1];if(!e)return null;if(d(t,e))return t.transaction("input").setSelection(m(n.nodeId,"before",i)).build();const l=t.getBlock(e),s=l?c(l):0;return t.transaction("input").setSelection(I(e,s)).build()}return t.transaction("input").setSelection(m(n.nodeId,"before",i)).build()}if(r<o.length-1){const e=o[r+1];return e?d(t,e)?t.transaction("input").setSelection(m(n.nodeId,"after",i)).build():t.transaction("input").setSelection(I(e,0)).build():null}return t.transaction("input").setSelection(m(n.nodeId,"after",i)).build()}(t,o,i,r):g(o)?null:b(o)?function(t,n,e,o){const r=o.indexOf(n.anchor.blockId),i=t.getBlock(n.anchor.blockId);if(!i)return null;const l=c(i);if(("right"===e||"down"===e)&&n.anchor.offset===l&&r<o.length-1){const n=o[r+1];if(n&&d(t,n)){const e=s(t.doc,n)??[];return t.transaction("input").setSelection(p(n,e)).build()}}if(("left"===e||"up"===e)&&0===n.anchor.offset&&r>0){const n=o[r-1];if(n&&d(t,n)){const e=s(t.doc,n)??[];return t.transaction("input").setSelection(p(n,e)).build()}}return null}(t,o,i,r):null}function v(t){let n=t;for(;;){const t=n.children.find(t=>o(t));if(!t)return n.id;n=t}}function M(t){let n=t;for(;;){let t;for(let e=n.children.length-1;e>=0;e--){const c=n.children[e];if(c&&o(c)){t=c;break}}if(!t)return n.id;n=t}}function _(t,n){if("after"===n.side)return y(t,n);const e=t.getBlockOrder(),o=e.indexOf(n.blockId);if(o<=0)return null;const r=e[o-1];if(!r)return null;if(d(t,r)){const n=s(t.doc,r)??[];return t.transaction("input").setSelection(p(r,n)).build()}const i=t.getBlock(r);if(!i)return null;const l=c(i);return t.transaction("input").setSelection(I(r,l)).build()}function w(t,n){if("before"===n.side)return y(t,n);const e=t.getBlockOrder(),o=e.indexOf(n.blockId);if(o>=e.length-1)return null;const c=e[o+1];if(!c)return null;if(d(t,c)){const n=s(t.doc,c)??[];return t.transaction("input").setSelection(p(c,n)).build()}return t.transaction("input").setSelection(I(c,0)).build()}function y(t,n){const e=s(t.doc,n.blockId)??[];return T(t,p(n.blockId,e))}function D(t,n,o="input"){const c=t.selection;if(h(c))return function(t,n,o,c){const r=s(t.doc,n.nodeId),i=r&&r.length>1?r.slice(0,-1):[],l=O(t,i),d=l.findIndex(t=>"id"in t&&t.id===n.nodeId),f=e(),u=t.transaction(c),a=d>=0?d+1:l.length;return u.insertNode(i,a,N(f)),u.insertText(f,0,o,[]),u.setSelection(I(f,o.length)),u.build()}(t,c,n,o);if(g(c))return function(t,n,o,c){const r=s(t.doc,n.blockId),i=r&&r.length>1?r.slice(0,-1):[],l=O(t,i),d=l.findIndex(t=>"id"in t&&t.id===n.blockId),f="before"===n.side?Math.max(d,0):d>=0?d+1:l.length,u=e(),a=t.transaction(c);return a.insertNode(i,f,N(u)),a.insertText(u,0,o,[]),a.setSelection(I(u,o.length)),a.build()}(t,c,n,o);const r=t.transaction(o),l=function(t){if(t.storedMarks)return t.storedMarks;if(h(t.selection)||g(t.selection))return[];const n=t.getBlock(t.selection.anchor.blockId);return n?i(n,t.selection.anchor.offset):[]}(t);let d;b(c)||(d=G(t,r));const f=A(c,t.getBlockOrder()),u=d??f.blockId,a=d?0:f.offset;return r.insertText(u,a,n,l),r.setSelection(I(u,a+n.length)),r.build()}function Q(t){if(h(t.selection))return T(t,t.selection);if(g(t.selection))return null;if(b(t.selection))return null;const n=t.transaction("input"),e=G(t,n),o=k(t.selection,t.getBlockOrder()),c=e??o.from.blockId,r=e?0:o.from.offset;return n.setSelection(I(c,r)),n.build()}function q(t){const n=t.selection;if(h(n))return function(t,n){const o=s(t.doc,n.nodeId);if(!o)return null;const c=o.length>1?o.slice(0,-1):[],r=O(t,c).findIndex(t=>"id"in t&&t.id===n.nodeId);if(r<0)return null;const i=e(),l=t.transaction("input");return l.insertNode(c,r+1,N(i)),l.setSelection(I(i,0)),l.build()}(t,n);if(g(n))return function(t,n){const o=s(t.doc,n.blockId);if(!o)return null;const c=o.length>1?o.slice(0,-1):[],r=O(t,c).findIndex(t=>"id"in t&&t.id===n.blockId);if(r<0)return null;const i="before"===n.side?r:r+1,l=e(),d=t.transaction("input");return d.insertNode(c,i,N(l)),d.setSelection(I(l,0)),d.build()}(t,n);const o=t.transaction("input");let c;b(n)||(c=G(t,o));const r=A(n,t.getBlockOrder()),i=c??r.blockId,l=c?0:r.offset,d=e();return o.splitBlock(i,l,d),o.setSelection(I(d,0)),o.build()}function z(t){const n=t.selection;if(h(n)||g(n))return null;const e=t.transaction("input");let o;if(b(n)||(o=G(t,e)),o)e.insertInlineNode(o,0,r(x("hard_break"))),e.setSelection(I(o,1));else{const{blockId:o,offset:c}=A(n,t.getBlockOrder());e.insertInlineNode(o,c,r(x("hard_break"))),e.setSelection(I(o,c+1))}return e.build()}function C(t){const n=t.selection;if(h(n)||g(n))return null;const e=t.getBlockOrder(),o=e.indexOf(n.anchor.blockId);if(o<=0)return null;const r=e[o-1];if(!r)return null;if(f(t,n.anchor.blockId)||f(t,r))return null;if(!u(t,n.anchor.blockId,r)&&a(t,n.anchor.blockId))return null;if(d(t,r)){const n=s(t.doc,r)??[];return t.transaction("input").setSelection(p(r,n)).build()}const i=t.getBlock(r);if(!i)return null;const l=c(i);return t.transaction("input").mergeBlocksAt(r,n.anchor.blockId).setSelection(I(r,l)).build()}function E(t){const n=t.selection;if(h(n)||g(n))return null;const e=t.getBlockOrder(),o=e.indexOf(n.anchor.blockId);if(o>=e.length-1)return null;const c=e[o+1];if(!c)return null;if(f(t,n.anchor.blockId)||f(t,c))return null;if(!u(t,n.anchor.blockId,c)&&a(t,n.anchor.blockId))return null;if(d(t,c)){const n=s(t.doc,c)??[];return t.transaction("input").setSelection(p(c,n)).build()}return t.transaction("input").mergeBlocksAt(n.anchor.blockId,c).setSelection(I(n.anchor.blockId,n.anchor.offset)).build()}function F(t){const n=t.doc.children,e=n[0],o=n[n.length-1];if(!e||!o)return t.transaction("command").setSelection(t.selection).build();const r=v(e),i=M(o),l=t.getBlock(i),s=l?c(l):0;return t.transaction("command").setSelection(S({blockId:r,offset:0},{blockId:i,offset:s})).build()}function G(t,n){if(h(t.selection)||g(t.selection))return;const o=t.getBlockOrder(),r=k(t.selection,o),i=o.indexOf(r.from.blockId),s=o.indexOf(r.to.blockId);if(i===s)return void n.deleteTextAt(r.from.blockId,r.from.offset,r.to.offset);const d=H(t,r.from.blockId),f=H(t,r.to.blockId);if(!(d===f||d<0||f<0))return function(t,n,o,r,i){const s=t.doc.children[r],d=t.doc.children[i];if(!s||!d)return;const f=l(s),u=l(d);let a,b=0;if(f||(a=e(),n.insertNode([],r,N(a)),b=1),f){const e=t.getBlock(o.from.blockId);if(e){const t=c(e);o.from.offset<t&&n.deleteTextAt(o.from.blockId,o.from.offset,t)}}u&&o.to.offset>0&&n.deleteTextAt(o.to.blockId,0,o.to.offset);const k=f?r+1:r+b;for(let e=u?i-1+b:i+b;e>=k;e--)n.removeNode([],e);return f&&u&&n.mergeBlocksAt(o.from.blockId,o.to.blockId),a}(t,n,r,d,f);!function(t,n,e,o,r,i){const l=t.getBlock(o.from.blockId);if(!l)return;const s=c(l);o.from.offset<s&&n.deleteTextAt(o.from.blockId,o.from.offset,s),o.to.offset>0&&n.deleteTextAt(o.to.blockId,0,o.to.offset);for(let d=r+1;d<i;d++){const r=e[d];if(!r)continue;const i=t.getBlock(r);if(!i)continue;const l=c(i);l>0&&n.deleteTextAt(r,0,l),n.mergeBlocksAt(o.from.blockId,r)}n.mergeBlocksAt(o.from.blockId,o.to.blockId)}(t,n,o,r,i,s)}function H(t,n){const e=s(t.doc,n);if(!e||0===e.length)return-1;const o=e[0];return t.doc.children.findIndex(t=>t.id===o)}export{w as a,T as b,Q as c,_ as d,D as e,q as f,E as g,G as h,z as i,M as j,C as m,j as n,A as r,F as s};
|
|
2
|
-
//# sourceMappingURL=Commands-P9wS8qtN.mjs.map
|