@notectl/core 1.0.4 → 1.0.6
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 +52 -148
- package/dist/chunks/AttrRegistry-DTsHyDVA.mjs +16 -0
- package/dist/chunks/AttrRegistry-DTsHyDVA.mjs.map +1 -0
- package/dist/chunks/Commands-DLP85Mp5.mjs +461 -0
- package/dist/chunks/Commands-DLP85Mp5.mjs.map +1 -0
- package/dist/chunks/Document-CI3iCwEP.mjs +177 -0
- package/dist/chunks/Document-CI3iCwEP.mjs.map +1 -0
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +7 -0
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +1 -0
- package/dist/chunks/NodeResolver-D68ZLXti.mjs +81 -0
- package/dist/chunks/NodeResolver-D68ZLXti.mjs.map +1 -0
- package/dist/chunks/NodeSpec-NZVvcCuH.mjs +8 -0
- package/dist/chunks/NodeSpec-NZVvcCuH.mjs.map +1 -0
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs +15 -0
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +1 -0
- package/dist/chunks/Selection-D5ZjXoB7.mjs +44 -0
- package/dist/chunks/Selection-D5ZjXoB7.mjs.map +1 -0
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs +7 -0
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs +398 -0
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +1 -0
- package/dist/chunks/TypeBrands-C09nE2qO.mjs +27 -0
- package/dist/chunks/TypeBrands-C09nE2qO.mjs.map +1 -0
- package/dist/chunks/color-picker-Csf0wx5a.mjs +5 -0
- package/dist/chunks/color-picker-Csf0wx5a.mjs.map +1 -0
- package/dist/chunks/index-QvKiO9_4.mjs +538 -0
- package/dist/chunks/index-QvKiO9_4.mjs.map +1 -0
- package/dist/commands/Commands.d.ts +71 -0
- package/dist/commands/Commands.d.ts.map +1 -0
- package/dist/commands/PasteCommand.d.ts +9 -0
- package/dist/commands/PasteCommand.d.ts.map +1 -0
- package/dist/decorations/Decoration.d.ts +76 -0
- package/dist/decorations/Decoration.d.ts.map +1 -0
- package/dist/decorations/PositionMapping.d.ts +9 -0
- package/dist/decorations/PositionMapping.d.ts.map +1 -0
- package/dist/editor/Announcer.d.ts +12 -0
- package/dist/editor/Announcer.d.ts.map +1 -0
- package/dist/editor/DocumentParser.d.ts +5 -0
- package/dist/editor/DocumentParser.d.ts.map +1 -0
- package/dist/editor/DocumentSerializer.d.ts +5 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -0
- package/dist/editor/EditorDOM.d.ts +18 -0
- package/dist/editor/EditorDOM.d.ts.map +1 -0
- package/dist/editor/EditorThemeController.d.ts +21 -0
- package/dist/editor/EditorThemeController.d.ts.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +135 -0
- package/dist/editor/NotectlEditor.d.ts.map +1 -0
- package/dist/editor/styles/base.d.ts +3 -0
- package/dist/editor/styles/base.d.ts.map +1 -0
- package/dist/editor/styles/code-block.d.ts +3 -0
- package/dist/editor/styles/code-block.d.ts.map +1 -0
- package/dist/editor/styles/color-picker.d.ts +3 -0
- package/dist/editor/styles/color-picker.d.ts.map +1 -0
- package/dist/editor/styles/font-select.d.ts +3 -0
- package/dist/editor/styles/font-select.d.ts.map +1 -0
- package/dist/editor/styles/font-size-select.d.ts +3 -0
- package/dist/editor/styles/font-size-select.d.ts.map +1 -0
- package/dist/editor/styles/heading-select.d.ts +3 -0
- package/dist/editor/styles/heading-select.d.ts.map +1 -0
- package/dist/editor/styles/image.d.ts +3 -0
- package/dist/editor/styles/image.d.ts.map +1 -0
- package/dist/editor/styles/list.d.ts +3 -0
- package/dist/editor/styles/list.d.ts.map +1 -0
- package/dist/editor/styles/reduced-motion.d.ts +3 -0
- package/dist/editor/styles/reduced-motion.d.ts.map +1 -0
- package/dist/editor/styles/table.d.ts +3 -0
- package/dist/editor/styles/table.d.ts.map +1 -0
- package/dist/editor/styles/toolbar.d.ts +3 -0
- package/dist/editor/styles/toolbar.d.ts.map +1 -0
- package/dist/editor/styles.d.ts +12 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/theme/ThemeEngine.d.ts +6 -0
- package/dist/editor/theme/ThemeEngine.d.ts.map +1 -0
- package/dist/editor/theme/ThemeTokens.d.ts +73 -0
- package/dist/editor/theme/ThemeTokens.d.ts.map +1 -0
- package/dist/fonts.d.ts +17 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.mjs +7 -0
- package/dist/fonts.mjs.map +1 -0
- package/dist/index.d.ts +83 -2360
- package/dist/index.d.ts.map +1 -0
- package/dist/input/ClipboardHandler.d.ts +29 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -0
- package/dist/input/InputHandler.d.ts +32 -0
- package/dist/input/InputHandler.d.ts.map +1 -0
- package/dist/input/InputRule.d.ts +9 -0
- package/dist/input/InputRule.d.ts.map +1 -0
- package/dist/input/InternalClipboard.d.ts +23 -0
- package/dist/input/InternalClipboard.d.ts.map +1 -0
- package/dist/input/KeyboardHandler.d.ts +42 -0
- package/dist/input/KeyboardHandler.d.ts.map +1 -0
- package/dist/input/Keymap.d.ts +11 -0
- package/dist/input/Keymap.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +38 -0
- package/dist/input/PasteHandler.d.ts.map +1 -0
- package/dist/input/SourceNormalizer.d.ts +7 -0
- package/dist/input/SourceNormalizer.d.ts.map +1 -0
- package/dist/model/AttrRegistry.d.ts +39 -0
- package/dist/model/AttrRegistry.d.ts.map +1 -0
- package/dist/model/BuiltinSpecs.d.ts +4 -0
- package/dist/model/BuiltinSpecs.d.ts.map +1 -0
- package/dist/model/ContentModel.d.ts +12 -0
- package/dist/model/ContentModel.d.ts.map +1 -0
- package/dist/model/ContentSlice.d.ts +17 -0
- package/dist/model/ContentSlice.d.ts.map +1 -0
- package/dist/model/Document.d.ts +127 -0
- package/dist/model/Document.d.ts.map +1 -0
- package/dist/model/HTMLParser.d.ts +36 -0
- package/dist/model/HTMLParser.d.ts.map +1 -0
- package/dist/model/HTMLUtils.d.ts +6 -0
- package/dist/model/HTMLUtils.d.ts.map +1 -0
- package/dist/model/InlineNodeSpec.d.ts +20 -0
- package/dist/model/InlineNodeSpec.d.ts.map +1 -0
- package/dist/model/MarkSpec.d.ts +22 -0
- package/dist/model/MarkSpec.d.ts.map +1 -0
- package/dist/model/NodeResolver.d.ts +36 -0
- package/dist/model/NodeResolver.d.ts.map +1 -0
- package/dist/model/NodeSpec.d.ts +67 -0
- package/dist/model/NodeSpec.d.ts.map +1 -0
- package/dist/model/ParseRule.d.ts +11 -0
- package/dist/model/ParseRule.d.ts.map +1 -0
- package/dist/model/SanitizeConfig.d.ts +9 -0
- package/dist/model/SanitizeConfig.d.ts.map +1 -0
- package/dist/model/Schema.d.ts +17 -0
- package/dist/model/Schema.d.ts.map +1 -0
- package/dist/model/SchemaRegistry.d.ts +81 -0
- package/dist/model/SchemaRegistry.d.ts.map +1 -0
- package/dist/model/Selection.d.ts +52 -0
- package/dist/model/Selection.d.ts.map +1 -0
- package/dist/model/TypeBrands.d.ts +28 -0
- package/dist/model/TypeBrands.d.ts.map +1 -0
- package/dist/notectl-core.mjs +2715 -11109
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +6894 -0
- package/dist/notectl-core.umd.js.map +1 -0
- package/dist/plugins/EventBus.d.ts +13 -0
- package/dist/plugins/EventBus.d.ts.map +1 -0
- package/dist/plugins/Plugin.d.ts +85 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/PluginManager.d.ts +68 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +48 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -0
- package/dist/plugins/alignment/index.d.ts +2 -0
- package/dist/plugins/alignment/index.d.ts.map +1 -0
- package/dist/plugins/alignment.mjs +92 -0
- package/dist/plugins/alignment.mjs.map +1 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +30 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -0
- package/dist/plugins/blockquote/index.d.ts +2 -0
- package/dist/plugins/blockquote/index.d.ts.map +1 -0
- package/dist/plugins/blockquote.mjs +58 -0
- package/dist/plugins/blockquote.mjs.map +1 -0
- package/dist/plugins/code-block/CodeBlockCommands.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +27 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +69 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
- package/dist/plugins/code-block/index.d.ts +2 -0
- package/dist/plugins/code-block/index.d.ts.map +1 -0
- package/dist/plugins/code-block.mjs +6 -0
- package/dist/plugins/code-block.mjs.map +1 -0
- package/dist/plugins/font/FontPlugin.d.ts +85 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -0
- package/dist/plugins/font/StarterFonts.d.ts +10 -0
- package/dist/plugins/font/StarterFonts.d.ts.map +1 -0
- package/dist/plugins/font/index.d.ts +2 -0
- package/dist/plugins/font/index.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts +22 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +56 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts +9 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
- package/dist/plugins/font-size/index.d.ts +2 -0
- package/dist/plugins/font-size/index.d.ts.map +1 -0
- package/dist/plugins/font-size.mjs +204 -0
- package/dist/plugins/font-size.mjs.map +1 -0
- package/dist/plugins/font.mjs +186 -0
- package/dist/plugins/font.mjs.map +1 -0
- package/dist/plugins/hard-break/HardBreakPlugin.d.ts +16 -0
- package/dist/plugins/hard-break/HardBreakPlugin.d.ts.map +1 -0
- package/dist/plugins/hard-break/index.d.ts +2 -0
- package/dist/plugins/hard-break/index.d.ts.map +1 -0
- package/dist/plugins/hard-break.mjs +28 -0
- package/dist/plugins/hard-break.mjs.map +1 -0
- package/dist/plugins/heading/BlockTypePickerEntry.d.ts +20 -0
- package/dist/plugins/heading/BlockTypePickerEntry.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +78 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -0
- package/dist/plugins/heading/index.d.ts +3 -0
- package/dist/plugins/heading/index.d.ts.map +1 -0
- package/dist/plugins/heading.mjs +188 -0
- package/dist/plugins/heading.mjs.map +1 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts +37 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -0
- package/dist/plugins/highlight/index.d.ts +2 -0
- package/dist/plugins/highlight/index.d.ts.map +1 -0
- package/dist/plugins/highlight.mjs +126 -0
- package/dist/plugins/highlight.mjs.map +1 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +29 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule/index.d.ts +2 -0
- package/dist/plugins/horizontal-rule/index.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule.mjs +59 -0
- package/dist/plugins/horizontal-rule.mjs.map +1 -0
- package/dist/plugins/image/ImageCommands.d.ts +26 -0
- package/dist/plugins/image/ImageCommands.d.ts.map +1 -0
- package/dist/plugins/image/ImageNodeView.d.ts +6 -0
- package/dist/plugins/image/ImageNodeView.d.ts.map +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts +43 -0
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -0
- package/dist/plugins/image/ImageUpload.d.ts +48 -0
- package/dist/plugins/image/ImageUpload.d.ts.map +1 -0
- package/dist/plugins/image/index.d.ts +3 -0
- package/dist/plugins/image/index.d.ts.map +1 -0
- package/dist/plugins/image.mjs +381 -0
- package/dist/plugins/image.mjs.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +32 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -0
- package/dist/plugins/link/index.d.ts +2 -0
- package/dist/plugins/link/index.d.ts.map +1 -0
- package/dist/plugins/link.mjs +127 -0
- package/dist/plugins/link.mjs.map +1 -0
- package/dist/plugins/list/ListPlugin.d.ts +51 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -0
- package/dist/plugins/list/index.d.ts +2 -0
- package/dist/plugins/list/index.d.ts.map +1 -0
- package/dist/plugins/list.mjs +193 -0
- package/dist/plugins/list.mjs.map +1 -0
- package/dist/plugins/print/PrintContentPreparer.d.ts +12 -0
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +12 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts +10 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
- package/dist/plugins/print/PrintTypes.d.ts +56 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +23 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -0
- package/dist/plugins/strikethrough/index.d.ts +2 -0
- package/dist/plugins/strikethrough/index.d.ts.map +1 -0
- package/dist/plugins/strikethrough.mjs +35 -0
- package/dist/plugins/strikethrough.mjs.map +1 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts +44 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -0
- package/dist/plugins/super-sub/index.d.ts +2 -0
- package/dist/plugins/super-sub/index.d.ts.map +1 -0
- package/dist/plugins/super-sub.mjs +81 -0
- package/dist/plugins/super-sub.mjs.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts +50 -0
- package/dist/plugins/table/TableCommands.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts +10 -0
- package/dist/plugins/table/TableControls.d.ts.map +1 -0
- package/dist/plugins/table/TableControlsDOM.d.ts +18 -0
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -0
- package/dist/plugins/table/TableControlsLayout.d.ts +34 -0
- package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -0
- package/dist/plugins/table/TableHelpers.d.ts +39 -0
- package/dist/plugins/table/TableHelpers.d.ts.map +1 -0
- package/dist/plugins/table/TableNavigation.d.ts +4 -0
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -0
- package/dist/plugins/table/TableNodeViews.d.ts +18 -0
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -0
- package/dist/plugins/table/TablePlugin.d.ts +39 -0
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -0
- package/dist/plugins/table/TableSelection.d.ts +26 -0
- package/dist/plugins/table/TableSelection.d.ts.map +1 -0
- package/dist/plugins/table/TableTestUtils.d.ts +45 -0
- package/dist/plugins/table/TableTestUtils.d.ts.map +1 -0
- package/dist/plugins/table/index.d.ts +4 -0
- package/dist/plugins/table/index.d.ts.map +1 -0
- package/dist/plugins/table.mjs +663 -0
- package/dist/plugins/table.mjs.map +1 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts +37 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -0
- package/dist/plugins/text-color/index.d.ts +2 -0
- package/dist/plugins/text-color/index.d.ts.map +1 -0
- package/dist/plugins/text-color.mjs +126 -0
- package/dist/plugins/text-color.mjs.map +1 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +34 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -0
- package/dist/plugins/text-formatting/index.d.ts +2 -0
- package/dist/plugins/text-formatting/index.d.ts.map +1 -0
- package/dist/plugins/text-formatting.mjs +52 -0
- package/dist/plugins/text-formatting.mjs.map +1 -0
- package/dist/plugins/toolbar/ToolbarItem.d.ts +66 -0
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts +25 -0
- package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +47 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +25 -0
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts +19 -0
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts +17 -0
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -0
- package/dist/plugins/toolbar/index.d.ts +4 -0
- package/dist/plugins/toolbar/index.d.ts.map +1 -0
- package/dist/plugins/toolbar.mjs +8 -0
- package/dist/plugins/toolbar.mjs.map +1 -0
- package/dist/state/EditorState.d.ts +40 -0
- package/dist/state/EditorState.d.ts.map +1 -0
- package/dist/state/History.d.ts +38 -0
- package/dist/state/History.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts +5 -0
- package/dist/state/StepApplication.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +185 -0
- package/dist/state/Transaction.d.ts.map +1 -0
- package/dist/test/PluginTestUtils.d.ts +127 -0
- package/dist/test/PluginTestUtils.d.ts.map +1 -0
- package/dist/test/TestUtils.d.ts +153 -0
- package/dist/test/TestUtils.d.ts.map +1 -0
- package/dist/view/EditorView.d.ts +74 -0
- package/dist/view/EditorView.d.ts.map +1 -0
- package/dist/view/NodeView.d.ts +18 -0
- package/dist/view/NodeView.d.ts.map +1 -0
- package/dist/view/Reconciler.d.ts +23 -0
- package/dist/view/Reconciler.d.ts.map +1 -0
- package/dist/view/SelectionSync.d.ts +8 -0
- package/dist/view/SelectionSync.d.ts.map +1 -0
- package/package.json +112 -11
- package/dist/notectl-core.js +0 -1463
- package/dist/notectl-core.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin, PluginContext } from '../Plugin.js';
|
|
2
|
+
declare module '../../model/AttrRegistry.js' {
|
|
3
|
+
interface MarkAttrRegistry {
|
|
4
|
+
strikethrough: Record<string, never>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export interface StrikethroughConfig {
|
|
8
|
+
/** When true, a separator is rendered after the strikethrough toolbar item. */
|
|
9
|
+
readonly separatorAfter?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class StrikethroughPlugin implements Plugin {
|
|
12
|
+
readonly id = "strikethrough";
|
|
13
|
+
readonly name = "Strikethrough";
|
|
14
|
+
readonly priority = 22;
|
|
15
|
+
private readonly config;
|
|
16
|
+
constructor(config?: Partial<StrikethroughConfig>);
|
|
17
|
+
init(context: PluginContext): void;
|
|
18
|
+
private registerMarkSpec;
|
|
19
|
+
private registerCommand;
|
|
20
|
+
private registerKeymap;
|
|
21
|
+
private registerToolbarItem;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=StrikethroughPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrikethroughPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/strikethrough/StrikethroughPlugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK1D,OAAO,QAAQ,6BAA6B,CAAC;IAC5C,UAAU,gBAAgB;QACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KACrC;CACD;AAID,MAAM,WAAW,mBAAmB;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAClC;AAMD,qBAAa,mBAAoB,YAAW,MAAM;IACjD,QAAQ,CAAC,EAAE,mBAAmB;IAC9B,QAAQ,CAAC,IAAI,mBAAmB;IAChC,QAAQ,CAAC,QAAQ,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAEjC,MAAM,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAIjD,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAOlC,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,mBAAmB;CAgB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/strikethrough/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,KAAK,mBAAmB,GACxB,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { A as t, r } from "../chunks/Commands-DLP85Mp5.mjs";
|
|
2
|
+
import { m as e } from "../chunks/TypeBrands-C09nE2qO.mjs";
|
|
3
|
+
import { f as o } from "../chunks/ToolbarItem-ugDymuXi.mjs";
|
|
4
|
+
const s = {};
|
|
5
|
+
class i {
|
|
6
|
+
id = "strikethrough";
|
|
7
|
+
name = "Strikethrough";
|
|
8
|
+
priority = 22;
|
|
9
|
+
config;
|
|
10
|
+
constructor(t2) {
|
|
11
|
+
this.config = { ...s, ...t2 };
|
|
12
|
+
}
|
|
13
|
+
init(t2) {
|
|
14
|
+
this.registerMarkSpec(t2), this.registerCommand(t2), this.registerKeymap(t2), this.registerToolbarItem(t2);
|
|
15
|
+
}
|
|
16
|
+
registerMarkSpec(t2) {
|
|
17
|
+
t2.registerMarkSpec({ type: "strikethrough", rank: 3, toDOM: () => document.createElement("s"), toHTMLString: (t3, r2) => `<s>${r2}</s>`, parseHTML: [{ tag: "s" }, { tag: "strike" }, { tag: "del" }], sanitize: { tags: ["s"] } });
|
|
18
|
+
}
|
|
19
|
+
registerCommand(r2) {
|
|
20
|
+
r2.registerCommand("toggleStrikethrough", () => {
|
|
21
|
+
const o2 = t(r2.getState(), e("strikethrough"));
|
|
22
|
+
return !!o2 && (r2.dispatch(o2), true);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
registerKeymap(t2) {
|
|
26
|
+
t2.registerKeymap({ "Mod-Shift-X": () => t2.executeCommand("toggleStrikethrough") });
|
|
27
|
+
}
|
|
28
|
+
registerToolbarItem(t2) {
|
|
29
|
+
t2.registerToolbarItem({ id: "strikethrough", group: "format", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"/></svg>', label: "Strikethrough", tooltip: `Strikethrough (${o("Mod-Shift-X")})`, command: "toggleStrikethrough", priority: 40, separatorAfter: this.config.separatorAfter, isActive: (t3) => r(t3, e("strikethrough")) });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
i as StrikethroughPlugin
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=strikethrough.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strikethrough.mjs","sources":["../../src/plugins/strikethrough/StrikethroughPlugin.ts"],"sourcesContent":["/**\n * StrikethroughPlugin: registers a strikethrough inline mark with MarkSpec,\n * toggle command, keyboard shortcut (Mod-Shift-X), and a toolbar button.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tstrikethrough: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface StrikethroughConfig {\n\t/** When true, a separator is rendered after the strikethrough toolbar item. */\n\treadonly separatorAfter?: boolean;\n}\n\nconst DEFAULT_CONFIG: StrikethroughConfig = {};\n\n// --- Plugin ---\n\nexport class StrikethroughPlugin implements Plugin {\n\treadonly id = 'strikethrough';\n\treadonly name = 'Strikethrough';\n\treadonly priority = 22;\n\n\tprivate readonly config: StrikethroughConfig;\n\n\tconstructor(config?: Partial<StrikethroughConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommand(context);\n\t\tthis.registerKeymap(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'strikethrough',\n\t\t\trank: 3,\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement('s');\n\t\t\t},\n\t\t\ttoHTMLString: (_mark, content) => `<s>${content}</s>`,\n\t\t\tparseHTML: [{ tag: 's' }, { tag: 'strike' }, { tag: 'del' }],\n\t\t\tsanitize: { tags: ['s'] },\n\t\t});\n\t}\n\n\tprivate registerCommand(context: PluginContext): void {\n\t\tcontext.registerCommand('toggleStrikethrough', () => {\n\t\t\tconst tr = toggleMark(context.getState(), markType('strikethrough'));\n\t\t\tif (tr) {\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\t}\n\n\tprivate registerKeymap(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-X': () => context.executeCommand('toggleStrikethrough'),\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z\"/></svg>';\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'strikethrough',\n\t\t\tgroup: 'format',\n\t\t\ticon,\n\t\t\tlabel: 'Strikethrough',\n\t\t\ttooltip: `Strikethrough (${formatShortcut('Mod-Shift-X')})`,\n\t\t\tcommand: 'toggleStrikethrough',\n\t\t\tpriority: 40,\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: (state) => isMarkActive(state, markType('strikethrough')),\n\t\t});\n\t}\n}\n"],"names":["DEFAULT_CONFIG","StrikethroughPlugin","id","name","priority","config","this","context","registerMarkSpec","registerCommand","registerKeymap","registerToolbarItem","type","rank","toDOM","document","createElement","toHTMLString","_mark","content","parseHTML","tag","sanitize","tags","tr","toggleMark","getState","markType","dispatch","executeCommand","group","icon","label","tooltip","formatShortcut","command","separatorAfter","isActive","state","isMarkActive"],"mappings":";;;AAyBA,MAAMA,IAAsC,CAAA;AAIrC,MAAMC,EAAAA;AAAAA,EACHC,KAAK;AAAA,EACLC,OAAO;AAAA,EACPC,WAAW;AAAA,EAEHC;AAAAA,EAEjB,YAAYA,IAAAA;AACXC,SAAKD,SAAS,EAAA,GAAKL,GAAAA,GAAmBK,GAAAA;AAAAA,EACvC;AAAA,EAEA,KAAKE,IAAAA;AACJD,SAAKE,iBAAiBD,EAAAA,GACtBD,KAAKG,gBAAgBF,EAAAA,GACrBD,KAAKI,eAAeH,EAAAA,GACpBD,KAAKK,oBAAoBJ,EAAAA;AAAAA,EAC1B;AAAA,EAEQ,iBAAiBA;AACxBA,IAAAA,GAAQC,iBAAiB,EACxBI,MAAM,iBACNC,MAAM,GACNC,OAAA,MACQC,SAASC,cAAc,GAAA,GAE/BC,cAAc,CAACC,IAAOC,OAAY,MAAMA,EAAAA,QACxCC,WAAW,CAAC,EAAEC,KAAK,IAAA,GAAO,EAAEA,KAAK,SAAA,GAAY,EAAEA,KAAK,MAAA,CAAA,GACpDC,UAAU,EAAEC,MAAM,CAAC,GAAA,EAAA,EAAA,CAAA;AAAA,EAErB;AAAA,EAEQ,gBAAgBhB;AACvBA,IAAAA,GAAQE,gBAAgB,uBAAuB,MAAA;AAC9C,YAAMe,KAAKC,EAAWlB,GAAQmB,SAAAA,GAAYC,EAAS,eAAA,CAAA;AACnD,aAAA,CAAA,CAAIH,OACHjB,GAAQqB,SAASJ,EAAAA,GAAAA;AAAAA,IACV,CAAA;AAAA,EAIV;AAAA,EAEQ,eAAejB,IAAAA;AACtBA,IAAAA,GAAQG,eAAe,EACtB,eAAe,MAAMH,GAAQsB,eAAe,qBAAA,EAAA,CAAA;AAAA,EAE9C;AAAA,EAEQ,oBAAoBtB;AAI3BA,IAAAA,GAAQI,oBAAoB,EAC3BT,IAAI,iBACJ4B,OAAO,UACPC,MALA,wIAMAC,OAAO,iBACPC,SAAS,kBAAkBC,EAAe,aAAA,CAAA,KAC1CC,SAAS,uBACT/B,UAAU,IACVgC,gBAAgB9B,KAAKD,OAAO+B,gBAC5BC,UAAWC,CAAAA,OAAUC,EAAaD,IAAOX,EAAS;EAEpD;AAAA;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Plugin, PluginContext } from '../Plugin.js';
|
|
2
|
+
declare module '../../model/AttrRegistry.js' {
|
|
3
|
+
interface MarkAttrRegistry {
|
|
4
|
+
superscript: Record<string, never>;
|
|
5
|
+
subscript: Record<string, never>;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Controls toolbar button visibility per mark. */
|
|
9
|
+
export interface SuperSubToolbarConfig {
|
|
10
|
+
readonly superscript?: boolean;
|
|
11
|
+
readonly subscript?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Controls which marks are enabled and which toolbar buttons are shown. */
|
|
14
|
+
export interface SuperSubConfig {
|
|
15
|
+
readonly superscript: boolean;
|
|
16
|
+
readonly subscript: boolean;
|
|
17
|
+
readonly toolbar?: SuperSubToolbarConfig;
|
|
18
|
+
/** When true, a separator is rendered after the last toolbar item. */
|
|
19
|
+
readonly separatorAfter?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class SuperSubPlugin implements Plugin {
|
|
22
|
+
readonly id = "super-sub";
|
|
23
|
+
readonly name = "Superscript & Subscript";
|
|
24
|
+
readonly priority = 23;
|
|
25
|
+
private readonly config;
|
|
26
|
+
constructor(config?: Partial<SuperSubConfig>);
|
|
27
|
+
init(context: PluginContext): void;
|
|
28
|
+
private registerMark;
|
|
29
|
+
private registerKeymaps;
|
|
30
|
+
/**
|
|
31
|
+
* Ensures superscript and subscript are mutually exclusive.
|
|
32
|
+
* When an addMark step for one type is found, a removeMark step
|
|
33
|
+
* for the opposite type is injected. For stored marks, the opposite
|
|
34
|
+
* mark is filtered out.
|
|
35
|
+
*/
|
|
36
|
+
private registerExclusivityMiddleware;
|
|
37
|
+
/**
|
|
38
|
+
* Registers disabled toolbar buttons for marks whose feature is disabled
|
|
39
|
+
* but whose toolbar button is explicitly requested.
|
|
40
|
+
*/
|
|
41
|
+
private registerDisabledToolbarItems;
|
|
42
|
+
private isToolbarVisible;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=SuperSubPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SuperSubPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/super-sub/SuperSubPlugin.ts"],"names":[],"mappings":"AAAA;;;;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OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC1B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { A as t, r as s } from "../chunks/Commands-DLP85Mp5.mjs";
|
|
2
|
+
import { m as e } from "../chunks/TypeBrands-C09nE2qO.mjs";
|
|
3
|
+
import { f as i } from "../chunks/ToolbarItem-ugDymuXi.mjs";
|
|
4
|
+
const r = { superscript: true, subscript: true }, o = [{ type: "superscript", opposite: "subscript", configKey: "superscript", rank: 4, tag: "sup", label: "Superscript", icon: ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">', '<path d="M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z"', ' fill="none"/>', '<path d="M9.64 7.64c.23-.5.36-1.05.36-1.64', " 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9", " 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83", " 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83", ' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z" fill="none"/>', '<path d="M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49', " 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02", "-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88", " 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34", " 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53", " 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54", "-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96", " 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56", "-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46", '-.59-.46-.94z"/>', '<path d="M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38', ' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z"/>', "</svg>"].join(""), keyBinding: "Mod-.", toolbarPriority: 50, toHTMLString: (t2) => `<sup>${t2}</sup>`, parseHTML: [{ tag: "sup" }], sanitize: { tags: ["sup"] } }, { type: "subscript", opposite: "superscript", configKey: "subscript", rank: 4, tag: "sub", label: "Subscript", icon: ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">', '<path d="M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49', " 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02", "-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88", " 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34", " 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53", " 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54", "-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96", " 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56", "-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46", '-.59-.46-.94z"/>', '<path d="M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38', ' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z"/>', "</svg>"].join(""), keyBinding: "Mod-,", toolbarPriority: 51, toHTMLString: (t2) => `<sub>${t2}</sub>`, parseHTML: [{ tag: "sub" }], sanitize: { tags: ["sub"] } }];
|
|
5
|
+
class p {
|
|
6
|
+
id = "super-sub";
|
|
7
|
+
name = "Superscript & Subscript";
|
|
8
|
+
priority = 23;
|
|
9
|
+
config;
|
|
10
|
+
constructor(t2) {
|
|
11
|
+
this.config = { ...r, ...t2 };
|
|
12
|
+
}
|
|
13
|
+
init(t2) {
|
|
14
|
+
const s2 = o.filter((t3) => this.config[t3.configKey]), e2 = s2.filter((t3) => this.isToolbarVisible(t3.configKey)).at(-1);
|
|
15
|
+
for (const i2 of s2) {
|
|
16
|
+
const s3 = !!this.config.separatorAfter && i2 === e2;
|
|
17
|
+
this.registerMark(t2, i2, s3);
|
|
18
|
+
}
|
|
19
|
+
this.registerKeymaps(t2, s2), this.registerExclusivityMiddleware(t2, s2), this.registerDisabledToolbarItems(t2);
|
|
20
|
+
}
|
|
21
|
+
registerMark(r2, o2, p2) {
|
|
22
|
+
const a = n(o2.type), c = this.isToolbarVisible(o2.configKey);
|
|
23
|
+
r2.registerMarkSpec({ type: o2.type, rank: o2.rank, toDOM: () => document.createElement(o2.tag), toHTMLString: (t2, s2) => o2.toHTMLString(s2), parseHTML: o2.parseHTML, sanitize: o2.sanitize }), r2.registerCommand(a, () => {
|
|
24
|
+
const s2 = t(r2.getState(), e(o2.type));
|
|
25
|
+
return !!s2 && (r2.dispatch(s2), true);
|
|
26
|
+
}), c && r2.registerToolbarItem({ id: o2.type, group: "format", icon: o2.icon, label: o2.label, tooltip: `${o2.label} (${i(o2.keyBinding)})`, command: a, priority: o2.toolbarPriority, separatorAfter: p2, isActive: (t2) => s(t2, e(o2.type)) });
|
|
27
|
+
}
|
|
28
|
+
registerKeymaps(t2, s2) {
|
|
29
|
+
const e2 = {};
|
|
30
|
+
for (const i2 of s2) {
|
|
31
|
+
const s3 = n(i2.type);
|
|
32
|
+
e2[i2.keyBinding] = () => t2.executeCommand(s3);
|
|
33
|
+
}
|
|
34
|
+
Object.keys(e2).length > 0 && t2.registerKeymap(e2);
|
|
35
|
+
}
|
|
36
|
+
registerExclusivityMiddleware(t2, s2) {
|
|
37
|
+
s2.some((t3) => "superscript" === t3.type) && s2.some((t3) => "subscript" === t3.type) && t2.registerMiddleware((t3, s3, i2) => {
|
|
38
|
+
let r2 = false;
|
|
39
|
+
const p2 = [];
|
|
40
|
+
for (const s4 of t3.steps) {
|
|
41
|
+
if ("addMark" !== s4.type) {
|
|
42
|
+
p2.push(s4);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const t4 = s4.mark.type, i3 = o.find((s5) => s5.type === t4);
|
|
46
|
+
if (!i3) {
|
|
47
|
+
p2.push(s4);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
r2 = true;
|
|
51
|
+
const n3 = { type: "removeMark", blockId: s4.blockId, from: s4.from, to: s4.to, mark: { type: e(i3.opposite) }, ...s4.path ? { path: s4.path } : {} };
|
|
52
|
+
p2.push(n3, s4);
|
|
53
|
+
}
|
|
54
|
+
let n2 = t3.storedMarksAfter;
|
|
55
|
+
if (n2) {
|
|
56
|
+
const t4 = n2.some((t5) => "superscript" === t5.type), s4 = n2.some((t5) => "subscript" === t5.type);
|
|
57
|
+
if (t4 && s4) {
|
|
58
|
+
const t5 = n2.findLastIndex((t6) => "superscript" === t6.type) > n2.findLastIndex((t6) => "subscript" === t6.type) ? "subscript" : "superscript";
|
|
59
|
+
n2 = n2.filter((s5) => s5.type !== t5), r2 = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
i2(r2 ? { ...t3, steps: p2, storedMarksAfter: n2 } : t3);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
registerDisabledToolbarItems(t2) {
|
|
66
|
+
if (this.config.toolbar) for (const s2 of o) {
|
|
67
|
+
const e2 = this.config[s2.configKey], i2 = this.config.toolbar[s2.configKey] ?? true;
|
|
68
|
+
!e2 && i2 && t2.registerToolbarItem({ id: s2.type, group: "format", icon: s2.icon, label: s2.label, command: n(s2.type), priority: s2.toolbarPriority, isEnabled: () => false });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
isToolbarVisible(t2) {
|
|
72
|
+
return !this.config.toolbar || (this.config.toolbar[t2] ?? true);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function n(t2) {
|
|
76
|
+
return `toggle${t2.charAt(0).toUpperCase()}${t2.slice(1)}`;
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
p as SuperSubPlugin
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=super-sub.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"super-sub.mjs","sources":["../../src/plugins/super-sub/SuperSubPlugin.ts"],"sourcesContent":["/**\n * SuperSubPlugin: registers superscript and subscript inline marks with\n * MarkSpecs, toggle commands, keyboard shortcuts, toolbar buttons, and\n * a middleware that enforces mutual exclusivity between the two marks.\n *\n * Data-driven — each mark type is defined declaratively and all\n * registrations are derived from the same definition table.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { Mark } from '../../model/Document.js';\nimport type { ParseRule } from '../../model/ParseRule.js';\nimport type { SanitizeConfig } from '../../model/SanitizeConfig.js';\nimport { markType as mkType } from '../../model/TypeBrands.js';\nimport type { RemoveMarkStep, Step } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tsuperscript: Record<string, never>;\n\t\tsubscript: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface SuperSubToolbarConfig {\n\treadonly superscript?: boolean;\n\treadonly subscript?: boolean;\n}\n\n/** Controls which marks are enabled and which toolbar buttons are shown. */\nexport interface SuperSubConfig {\n\treadonly superscript: boolean;\n\treadonly subscript: boolean;\n\treadonly toolbar?: SuperSubToolbarConfig;\n\t/** When true, a separator is rendered after the last toolbar item. */\n\treadonly separatorAfter?: boolean;\n}\n\nconst DEFAULT_CONFIG: SuperSubConfig = {\n\tsuperscript: true,\n\tsubscript: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: 'superscript' | 'subscript';\n\treadonly opposite: 'superscript' | 'subscript';\n\treadonly configKey: keyof Omit<SuperSubConfig, 'toolbar' | 'separatorAfter'>;\n\treadonly rank: number;\n\treadonly tag: string;\n\treadonly label: string;\n\treadonly icon: string;\n\treadonly keyBinding: string;\n\treadonly toolbarPriority: number;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst SUPERSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z\"',\n\t' fill=\"none\"/>',\n\t'<path d=\"M9.64 7.64c.23-.5.36-1.05.36-1.64',\n\t' 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9',\n\t' 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83',\n\t' 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83',\n\t' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\" fill=\"none\"/>',\n\t'<path d=\"M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst SUBSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'superscript',\n\t\topposite: 'subscript',\n\t\tconfigKey: 'superscript',\n\t\trank: 4,\n\t\ttag: 'sup',\n\t\tlabel: 'Superscript',\n\t\ticon: SUPERSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-.',\n\t\ttoolbarPriority: 50,\n\t\ttoHTMLString: (content) => `<sup>${content}</sup>`,\n\t\tparseHTML: [{ tag: 'sup' }],\n\t\tsanitize: { tags: ['sup'] },\n\t},\n\t{\n\t\ttype: 'subscript',\n\t\topposite: 'superscript',\n\t\tconfigKey: 'subscript',\n\t\trank: 4,\n\t\ttag: 'sub',\n\t\tlabel: 'Subscript',\n\t\ticon: SUBSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-,',\n\t\ttoolbarPriority: 51,\n\t\ttoHTMLString: (content) => `<sub>${content}</sub>`,\n\t\tparseHTML: [{ tag: 'sub' }],\n\t\tsanitize: { tags: ['sub'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class SuperSubPlugin implements Plugin {\n\treadonly id = 'super-sub';\n\treadonly name = 'Superscript & Subscript';\n\treadonly priority = 23;\n\n\tprivate readonly config: SuperSubConfig;\n\n\tconstructor(config?: Partial<SuperSubConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tconst enabledMarks: MarkDefinition[] = MARK_DEFINITIONS.filter(\n\t\t\t(def) => this.config[def.configKey],\n\t\t);\n\n\t\tconst visibleToolbarMarks: MarkDefinition[] = enabledMarks.filter((def) =>\n\t\t\tthis.isToolbarVisible(def.configKey),\n\t\t);\n\t\tconst lastVisibleMark: MarkDefinition | undefined = visibleToolbarMarks.at(-1);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tconst isSeparatorTarget: boolean = !!this.config.separatorAfter && def === lastVisibleMark;\n\t\t\tthis.registerMark(context, def, isSeparatorTarget);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\t\tthis.registerExclusivityMiddleware(context, enabledMarks);\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(context: PluginContext, def: MarkDefinition, separatorAfter: boolean): void {\n\t\tconst commandName: string = toCommandName(def.type);\n\t\tconst toolbarVisible: boolean = this.isToolbarVisible(def.configKey);\n\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: def.type,\n\t\t\trank: def.rank,\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement(def.tag);\n\t\t\t},\n\t\t\ttoHTMLString: (_mark, content) => def.toHTMLString(content),\n\t\t\tparseHTML: def.parseHTML,\n\t\t\tsanitize: def.sanitize,\n\t\t});\n\n\t\tcontext.registerCommand(commandName, () => {\n\t\t\tconst tr = toggleMark(context.getState(), mkType(def.type));\n\t\t\tif (tr) {\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\n\t\tif (toolbarVisible) {\n\t\t\tcontext.registerToolbarItem({\n\t\t\t\tid: def.type,\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon: def.icon,\n\t\t\t\tlabel: def.label,\n\t\t\t\ttooltip: `${def.label} (${formatShortcut(def.keyBinding)})`,\n\t\t\t\tcommand: commandName,\n\t\t\t\tpriority: def.toolbarPriority,\n\t\t\t\tseparatorAfter,\n\t\t\t\tisActive: (state) => isMarkActive(state, mkType(def.type)),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate registerKeymaps(context: PluginContext, marks: readonly MarkDefinition[]): void {\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const def of marks) {\n\t\t\tconst commandName: string = toCommandName(def.type);\n\t\t\tkeymap[def.keyBinding] = () => context.executeCommand(commandName);\n\t\t}\n\t\tif (Object.keys(keymap).length > 0) {\n\t\t\tcontext.registerKeymap(keymap);\n\t\t}\n\t}\n\n\t/**\n\t * Ensures superscript and subscript are mutually exclusive.\n\t * When an addMark step for one type is found, a removeMark step\n\t * for the opposite type is injected. For stored marks, the opposite\n\t * mark is filtered out.\n\t */\n\tprivate registerExclusivityMiddleware(\n\t\tcontext: PluginContext,\n\t\tenabledMarks: readonly MarkDefinition[],\n\t): void {\n\t\tconst bothEnabled: boolean =\n\t\t\tenabledMarks.some((d) => d.type === 'superscript') &&\n\t\t\tenabledMarks.some((d) => d.type === 'subscript');\n\n\t\tif (!bothEnabled) return;\n\n\t\tcontext.registerMiddleware((tr, _state, next) => {\n\t\t\tlet patched = false;\n\n\t\t\t// Handle addMark steps: inject removeMark for the opposite type\n\t\t\tconst patchedSteps: Step[] = [];\n\t\t\tfor (const step of tr.steps) {\n\t\t\t\tif (step.type !== 'addMark') {\n\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst markName: string = step.mark.type;\n\t\t\t\tconst def: MarkDefinition | undefined = MARK_DEFINITIONS.find((d) => d.type === markName);\n\t\t\t\tif (!def) {\n\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tpatched = true;\n\t\t\t\tconst removeStep: RemoveMarkStep = {\n\t\t\t\t\ttype: 'removeMark',\n\t\t\t\t\tblockId: step.blockId,\n\t\t\t\t\tfrom: step.from,\n\t\t\t\t\tto: step.to,\n\t\t\t\t\tmark: { type: mkType(def.opposite) },\n\t\t\t\t\t...(step.path ? { path: step.path } : {}),\n\t\t\t\t};\n\t\t\t\tpatchedSteps.push(removeStep, step);\n\t\t\t}\n\n\t\t\t// Handle stored marks: remove the opposite mark\n\t\t\tlet storedMarksAfter: readonly Mark[] | null = tr.storedMarksAfter;\n\t\t\tif (storedMarksAfter) {\n\t\t\t\tconst hasSup: boolean = storedMarksAfter.some((m) => m.type === 'superscript');\n\t\t\t\tconst hasSub: boolean = storedMarksAfter.some((m) => m.type === 'subscript');\n\n\t\t\t\tif (hasSup && hasSub) {\n\t\t\t\t\t// Keep the one that was most recently added (last in array)\n\t\t\t\t\tconst lastSupIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t(m) => m.type === 'superscript',\n\t\t\t\t\t);\n\t\t\t\t\tconst lastSubIdx: number = storedMarksAfter.findLastIndex((m) => m.type === 'subscript');\n\t\t\t\t\tconst removeType: string = lastSupIdx > lastSubIdx ? 'subscript' : 'superscript';\n\n\t\t\t\t\tstoredMarksAfter = storedMarksAfter.filter((m) => m.type !== removeType);\n\t\t\t\t\tpatched = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnext(patched ? { ...tr, steps: patchedSteps, storedMarksAfter } : tr);\n\t\t});\n\t}\n\n\t/**\n\t * Registers disabled toolbar buttons for marks whose feature is disabled\n\t * but whose toolbar button is explicitly requested.\n\t */\n\tprivate registerDisabledToolbarItems(context: PluginContext): void {\n\t\tif (!this.config.toolbar) return;\n\n\t\tfor (const def of MARK_DEFINITIONS) {\n\t\t\tconst featureEnabled: boolean = this.config[def.configKey];\n\t\t\tconst toolbarVisible: boolean = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tcontext.registerToolbarItem({\n\t\t\t\t\tid: def.type,\n\t\t\t\t\tgroup: 'format',\n\t\t\t\t\ticon: def.icon,\n\t\t\t\t\tlabel: def.label,\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tpriority: def.toolbarPriority,\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate isToolbarVisible(\n\t\tconfigKey: keyof Omit<SuperSubConfig, 'toolbar' | 'separatorAfter'>,\n\t): boolean {\n\t\tif (!this.config.toolbar) return true;\n\t\treturn this.config.toolbar[configKey] ?? true;\n\t}\n}\n\n/** Converts a mark type to its toggle command name (e.g. 'superscript' → 'toggleSuperscript'). */\nfunction toCommandName(markType: string): string {\n\treturn `toggle${markType.charAt(0).toUpperCase()}${markType.slice(1)}`;\n}\n"],"names":["DEFAULT_CONFIG","superscript","subscript","MARK_DEFINITIONS","type","opposite","configKey","rank","tag","label","icon","join","keyBinding","toolbarPriority","toHTMLString","content","parseHTML","sanitize","tags","SuperSubPlugin","id","name","priority","config","this","context","enabledMarks","filter","def","lastVisibleMark","isToolbarVisible","at","isSeparatorTarget","separatorAfter","registerMark","registerKeymaps","registerExclusivityMiddleware","registerDisabledToolbarItems","commandName","toCommandName","toolbarVisible","registerMarkSpec","toDOM","document","createElement","_mark","registerCommand","tr","toggleMark","getState","mkType","dispatch","registerToolbarItem","group","tooltip","formatShortcut","command","isActive","state","isMarkActive","marks","keymap","executeCommand","Object","keys","length","registerKeymap","some","d","registerMiddleware","_state","next","patched","patchedSteps","step","steps","push","markName","mark","find","removeStep","blockId","from","to","path","storedMarksAfter","hasSup","m","hasSub","removeType","findLastIndex","toolbar","featureEnabled","isEnabled","markType","charAt","toUpperCase","slice"],"mappings":";;;AA4CA,MAAMA,IAAiC,EACtCC,aAAAA,MACAC,WAAAA,QA6DKC,IAA8C,CACnD,EACCC,MAAM,eACNC,UAAU,aACVC,WAAW,eACXC,MAAM,GACNC,KAAK,OACLC,OAAO,eACPC,MAjD+B,CAChC,gEACA,2DACA,kBACA,8CACA,gDACA,qDACA,+DACA,sDACA,0DACA,0DACA,0DACA,wDACA,0EACA,0EACA,2EACA,4EACA,4EACA,oBACA,2DACA,wDACA,QAAA,EACCC,KAAK,EAAA,GA4BLC,YAAY,SACZC,iBAAiB,IACjBC,cAAeC,CAAAA,OAAY,QAAQA,EAAAA,UACnCC,WAAW,CAAC,EAAER,KAAK,UACnBS,UAAU,EAAEC,MAAM,CAAC,KAAA,EAAA,EAAA,GAEpB,EACCd,MAAM,aACNC,UAAU,eACVC,WAAW,aACXC,MAAM,GACNC,KAAK,OACLC,OAAO,aACPC,MAvC6B,CAC9B,gEACA,2DACA,0DACA,wDACA,wDACA,0EACA,0EACA,2EACA,4EACA,4EACA,oB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OzB,GAAkB;AACnC,YAAMyF,KAA0BpE,KAAKD,OAAOK,GAAItB,SAAAA,GAC1CkC,KAA0BhB,KAAKD,OAAOoE,QAAQ/D,GAAItB;AAAc,OAEjEsF,MAAkBpD,MACtBf,GAAQ2B,oBAAoB,EAC3BhC,IAAIQ,GAAIxB,MACRiD,OAAO,UACP3C,MAAMkB,GAAIlB,MACVD,OAAOmB,GAAInB,OACX+C,SAASjB,EAAcX,GAAIxB,IAAAA,GAC3BkB,UAAUM,GAAIf,iBACdgF,WAAW,MAAA;IAGd;AAAA,EACD;AAAA,EAEQ,iBACPvF,IAAAA;AAEA,WAAA,CAAKkB,KAAKD,OAAOoE,YACVnE,KAAKD,OAAOoE,QAAQrF,EAAAA,KAAAA;AAAAA,EAC5B;AAAA;AAID,SAASiC,EAAcuD;AACtB,SAAO,SAASA,GAASC,OAAO,CAAA,EAAGC,YAAAA,CAAAA,GAAgBF,GAASG,MAAM;AACnE;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BlockId } from '../../model/TypeBrands.js';
|
|
2
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
3
|
+
import { Transaction } from '../../state/Transaction.js';
|
|
4
|
+
import { PluginContext } from '../Plugin.js';
|
|
5
|
+
/** Builds a transaction that inserts a new row at the given index. */
|
|
6
|
+
export declare function buildInsertRowTransaction(state: EditorState, tableId: BlockId, rowIndex: number): Transaction | null;
|
|
7
|
+
/** Builds a transaction that inserts a new column at the given index. */
|
|
8
|
+
export declare function buildInsertColumnTransaction(state: EditorState, tableId: BlockId, colIndex: number): Transaction | null;
|
|
9
|
+
/**
|
|
10
|
+
* Builds a transaction that deletes the row at the given index.
|
|
11
|
+
* If it's the last row, delegates to `createDeleteTableTransaction`.
|
|
12
|
+
* @param preferredCol Column index to place the cursor in after deletion (default 0).
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildDeleteRowTransaction(state: EditorState, tableId: BlockId, rowIndex: number, preferredCol?: number): Transaction | null;
|
|
15
|
+
/**
|
|
16
|
+
* Builds a transaction that deletes the column at the given index.
|
|
17
|
+
* If it's the last column, delegates to `createDeleteTableTransaction`.
|
|
18
|
+
* @param preferredRow Row index to place the cursor in after deletion (default 0).
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildDeleteColumnTransaction(state: EditorState, tableId: BlockId, colIndex: number, preferredRow?: number): Transaction | null;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a transaction that removes the given root-level table node.
|
|
23
|
+
* Cursor placement prefers the next root block, then previous.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createDeleteTableTransaction(state: EditorState, tableId: BlockId): Transaction | null;
|
|
26
|
+
/**
|
|
27
|
+
* Inserts a table with the given dimensions at the current cursor position.
|
|
28
|
+
* Adds a paragraph after the table for cursor escape.
|
|
29
|
+
* Moves cursor into the first cell.
|
|
30
|
+
*/
|
|
31
|
+
export declare function insertTable(context: PluginContext, rows: number, cols: number): boolean;
|
|
32
|
+
/** Adds a row above the current row. */
|
|
33
|
+
export declare function addRowAbove(context: PluginContext): boolean;
|
|
34
|
+
/** Adds a row below the current row. */
|
|
35
|
+
export declare function addRowBelow(context: PluginContext): boolean;
|
|
36
|
+
/** Adds a column to the left of the current column. */
|
|
37
|
+
export declare function addColumnLeft(context: PluginContext): boolean;
|
|
38
|
+
/** Adds a column to the right of the current column. */
|
|
39
|
+
export declare function addColumnRight(context: PluginContext): boolean;
|
|
40
|
+
/** Deletes the current row. If it's the last row, deletes the entire table. */
|
|
41
|
+
export declare function deleteRow(context: PluginContext): boolean;
|
|
42
|
+
/** Deletes the current column. If it's the last column, deletes the entire table. */
|
|
43
|
+
export declare function deleteColumn(context: PluginContext): boolean;
|
|
44
|
+
/** Deletes the entire table and moves cursor to surrounding block. */
|
|
45
|
+
export declare function deleteTable(context: PluginContext): boolean;
|
|
46
|
+
/** Selects the surrounding table as a node object. */
|
|
47
|
+
export declare function selectTable(context: PluginContext): boolean;
|
|
48
|
+
/** Registers all table commands on the given plugin context. */
|
|
49
|
+
export declare function registerTableCommands(context: PluginContext): void;
|
|
50
|
+
//# sourceMappingURL=TableCommands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableCommands.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableCommands.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,2BAA2B,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAalD,sEAAsE;AACtE,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GACd,WAAW,GAAG,IAAI,CAoBpB;AAED,yEAAyE;AACzE,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GACd,WAAW,GAAG,IAAI,CAcpB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,YAAY,SAAI,GACd,WAAW,GAAG,IAAI,CAmBpB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,YAAY,SAAI,GACd,WAAW,GAAG,IAAI,CA2BpB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,GACd,WAAW,GAAG,IAAI,CAkBpB;AAQD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAiDvF;AAED,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAW3D;AAED,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAW3D;AAED,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAE7D;AAED,wDAAwD;AACxD,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAE9D;AAgBD,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAgBzD;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAgB5D;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAS3D;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAqB3D;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAUlE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BlockNode } from '../../model/Document.js';
|
|
2
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
3
|
+
import { Transaction } from '../../state/Transaction.js';
|
|
4
|
+
export interface TableControlsHandle {
|
|
5
|
+
update(node: BlockNode): void;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
}
|
|
8
|
+
/** Creates table controls for the given table element. */
|
|
9
|
+
export declare function createTableControls(container: HTMLElement, tableEl: HTMLTableElement, initialNode: BlockNode, getState: () => EditorState, dispatch: (tr: Transaction) => void): TableControlsHandle;
|
|
10
|
+
//# sourceMappingURL=TableControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableControls.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableControls.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AA8B9D,MAAM,WAAW,mBAAmB;IACnC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;CAChB;AAkQD,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,MAAM,WAAW,EAC3B,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,GACjC,mBAAmB,CAErB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure DOM factory functions for table controls.
|
|
3
|
+
* No state logic — only element creation and CSS class assignment.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PLUS_SVG: string;
|
|
6
|
+
export declare const DELETE_SVG: string;
|
|
7
|
+
export declare const TABLE_DELETE_SVG: string;
|
|
8
|
+
/** Creates a button with standard table-control setup (mousedown prevention, ARIA). */
|
|
9
|
+
export declare function createButton(className: string, innerHTML: string, title: string): HTMLButtonElement;
|
|
10
|
+
/** Builds the insert-line element (horizontal or vertical) with a plus-icon button. */
|
|
11
|
+
export declare function buildInsertLine(orientation: 'horizontal' | 'vertical'): HTMLDivElement;
|
|
12
|
+
/** Builds a zone-button for adding rows or columns at the table edge. */
|
|
13
|
+
export declare function buildAddButton(className: string, title: string): HTMLButtonElement;
|
|
14
|
+
/** Builds a handle-bar container (for column or row handles). */
|
|
15
|
+
export declare function buildHandleBar(className: string): HTMLDivElement;
|
|
16
|
+
/** Builds a single column or row handle with a delete button. */
|
|
17
|
+
export declare function buildHandle(className: string, index: number, deleteLabel: string, onDelete: (idx: number) => void): HTMLDivElement;
|
|
18
|
+
//# sourceMappingURL=TableControlsDOM.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableControlsDOM.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableControlsDOM.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,eAAO,MAAM,QAAQ,EAAE,MAI6B,CAAC;AAErD,eAAO,MAAM,UAAU,EAAE,MAI2B,CAAC;AAErD,eAAO,MAAM,gBAAgB,EAAE,MAKG,CAAC;AAInC,uFAAuF;AACvF,wBAAgB,YAAY,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACX,iBAAiB,CAanB;AAED,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,WAAW,EAAE,YAAY,GAAG,UAAU,GAAG,cAAc,CAWtF;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAoBlF;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAMhE;AAED,iEAAiE;AACjE,wBAAgB,WAAW,CAC1B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAC7B,cAAc,CAchB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measurement and positioning logic for table controls.
|
|
3
|
+
* All functions are pure (take numeric/DOM inputs, return structured results).
|
|
4
|
+
*/
|
|
5
|
+
export interface BorderInfo {
|
|
6
|
+
readonly position: number;
|
|
7
|
+
readonly index: number;
|
|
8
|
+
}
|
|
9
|
+
export interface NearestBorderResult {
|
|
10
|
+
readonly type: 'row' | 'col' | 'none';
|
|
11
|
+
readonly border: BorderInfo | null;
|
|
12
|
+
}
|
|
13
|
+
export declare const BORDER_THRESHOLD: number;
|
|
14
|
+
/** Returns the table's offset relative to the container (walks offsetParent chain). */
|
|
15
|
+
export declare function getTableOffset(tableEl: HTMLElement, container: HTMLElement): {
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
};
|
|
19
|
+
/** Measures the Y-positions of inter-row borders (between adjacent <tr> elements). */
|
|
20
|
+
export declare function measureRowBorders(tableEl: HTMLTableElement): BorderInfo[];
|
|
21
|
+
/** Measures the X-positions of inter-column borders (evenly spaced). */
|
|
22
|
+
export declare function measureColBorders(tableWidth: number, numCols: number): BorderInfo[];
|
|
23
|
+
/** Positions column handles evenly across the table width. */
|
|
24
|
+
export declare function positionColHandles(colBar: HTMLDivElement, tableWidth: number, numCols: number): void;
|
|
25
|
+
/** Positions row handles to match actual <tr> offsets and heights. */
|
|
26
|
+
export declare function positionRowHandles(rowBar: HTMLDivElement, tableEl: HTMLTableElement): void;
|
|
27
|
+
/** Positions add-row and add-column buttons at the table edges. */
|
|
28
|
+
export declare function positionAddButtons(addRowZone: HTMLElement, addColZone: HTMLElement, tableEl: HTMLElement, container: HTMLElement): void;
|
|
29
|
+
/**
|
|
30
|
+
* Finds the nearest row or column border to the given mouse position.
|
|
31
|
+
* Returns which border is closest (within threshold), preferring the nearer one.
|
|
32
|
+
*/
|
|
33
|
+
export declare function findNearestBorder(x: number, y: number, rowBorders: readonly BorderInfo[], colBorders: readonly BorderInfo[]): NearestBorderResult;
|
|
34
|
+
//# sourceMappingURL=TableControlsLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableControlsLayout.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableControlsLayout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1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|
2
|
+
import { BlockId } from '../../model/TypeBrands.js';
|
|
3
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
4
|
+
/** Context information about a cell within a table. */
|
|
5
|
+
export interface TableContext {
|
|
6
|
+
readonly tableId: BlockId;
|
|
7
|
+
readonly tableIndex: number;
|
|
8
|
+
readonly rowId: BlockId;
|
|
9
|
+
readonly rowIndex: number;
|
|
10
|
+
readonly cellId: BlockId;
|
|
11
|
+
readonly colIndex: number;
|
|
12
|
+
readonly totalRows: number;
|
|
13
|
+
readonly totalCols: number;
|
|
14
|
+
}
|
|
15
|
+
/** Creates a table BlockNode structure with the given dimensions. */
|
|
16
|
+
export declare function createTable(rows: number, cols: number): BlockNode;
|
|
17
|
+
/** Creates a single table row with the given number of cells. */
|
|
18
|
+
export declare function createTableRow(cols: number): BlockNode;
|
|
19
|
+
/** Creates a single empty table cell containing a paragraph. */
|
|
20
|
+
export declare function createTableCell(): BlockNode;
|
|
21
|
+
/**
|
|
22
|
+
* Finds table context for a given block ID.
|
|
23
|
+
* Returns null if the block is not inside a table.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findTableContext(state: EditorState, blockId: BlockId): TableContext | null;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the cell BlockId at the given row and column indices.
|
|
28
|
+
* Returns null if out of bounds.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCellAt(state: EditorState, tableId: BlockId, rowIndex: number, colIndex: number): BlockId | null;
|
|
31
|
+
/** Returns all cell IDs in a table in row-major order. */
|
|
32
|
+
export declare function getAllCellIds(state: EditorState, tableId: BlockId): readonly BlockId[];
|
|
33
|
+
/** Returns the first leaf-block ID inside a table cell (e.g. the paragraph). */
|
|
34
|
+
export declare function getFirstLeafInCell(state: EditorState, cellId: BlockId): BlockId;
|
|
35
|
+
/** Returns the last leaf-block ID inside a table cell. */
|
|
36
|
+
export declare function getLastLeafInCell(state: EditorState, cellId: BlockId): BlockId;
|
|
37
|
+
/** Checks whether a block is inside a table. */
|
|
38
|
+
export declare function isInsideTable(state: EditorState, blockId: BlockId): boolean;
|
|
39
|
+
//# sourceMappingURL=TableHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHelpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,SAAS,EAMd,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,2BAA2B,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAejE;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAMtD;AAED,gEAAgE;AAChE,wBAAgB,eAAe,IAAI,SAAS,CAO3C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAyD1F;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACxB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACd,OAAO,GAAG,IAAI,CAWhB;AAED,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,OAAO,EAAE,CAatF;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAa/E;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAa9E;AAED,gDAAgD;AAChD,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAS3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableNavigation.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableNavigation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAUlD,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAejE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SchemaRegistry } from '../../model/SchemaRegistry.js';
|
|
2
|
+
import { NodeViewFactory } from '../../view/NodeView.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a NodeViewFactory for the table node type.
|
|
5
|
+
* Renders as outer container with controls + table + tbody.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTableNodeViewFactory(_registry: SchemaRegistry): NodeViewFactory;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a NodeViewFactory for the table_row node type.
|
|
10
|
+
* Renders as `<tr role="row">`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createTableRowNodeViewFactory(_registry: SchemaRegistry): NodeViewFactory;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a NodeViewFactory for the table_cell node type.
|
|
15
|
+
* Renders as `<td role="cell">` with text content rendered inside.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTableCellNodeViewFactory(_registry: SchemaRegistry): NodeViewFactory;
|
|
18
|
+
//# sourceMappingURL=TableNodeViews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableNodeViews.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableNodeViews.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGxE;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,cAAc,GAAG,eAAe,CA6ErF;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,cAAc,GAAG,eAAe,CAuBxF;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,cAAc,GAAG,eAAe,CAgDzF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
2
|
+
import { Transaction } from '../../state/Transaction.js';
|
|
3
|
+
import { Plugin, PluginContext } from '../Plugin.js';
|
|
4
|
+
declare module '../../model/AttrRegistry.js' {
|
|
5
|
+
interface NodeAttrRegistry {
|
|
6
|
+
table: Record<string, never>;
|
|
7
|
+
table_row: Record<string, never>;
|
|
8
|
+
table_cell: {
|
|
9
|
+
colspan?: number;
|
|
10
|
+
rowspan?: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export interface TableConfig {
|
|
15
|
+
/** Maximum rows in grid picker. Defaults to 8. */
|
|
16
|
+
readonly maxPickerRows?: number;
|
|
17
|
+
/** Maximum columns in grid picker. Defaults to 8. */
|
|
18
|
+
readonly maxPickerCols?: number;
|
|
19
|
+
/** When true, a separator is rendered after the table toolbar item. */
|
|
20
|
+
readonly separatorAfter?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class TablePlugin implements Plugin {
|
|
23
|
+
readonly id = "table";
|
|
24
|
+
readonly name = "Table";
|
|
25
|
+
readonly priority = 40;
|
|
26
|
+
private readonly config;
|
|
27
|
+
private selectionService;
|
|
28
|
+
private cleanupMouseSelection;
|
|
29
|
+
private context;
|
|
30
|
+
constructor(config?: Partial<TableConfig>);
|
|
31
|
+
init(context: PluginContext): void;
|
|
32
|
+
onReady(): void;
|
|
33
|
+
destroy(): void;
|
|
34
|
+
onStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void;
|
|
35
|
+
private registerNodeSpecs;
|
|
36
|
+
private registerNodeViews;
|
|
37
|
+
private registerToolbarItem;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=TablePlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TablePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TablePlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAiB1D,OAAO,QAAQ,6BAA6B,CAAC;IAC5C,UAAU,gBAAgB;QACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACjC,UAAU,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KACnD;CACD;AAID,MAAM,WAAW,WAAW;IAC3B,kDAAkD;IAClD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAClC;AAgBD,qBAAa,WAAY,YAAW,MAAM;IACzC,QAAQ,CAAC,EAAE,WAAW;IACtB,QAAQ,CAAC,IAAI,WAAW;IACxB,QAAQ,CAAC,QAAQ,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,gBAAgB,CAAsC;IAC9D,OAAO,CAAC,qBAAqB,CAA6B;IAC1D,OAAO,CAAC,OAAO,CAA8B;gBAEjC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;IAIzC,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAYlC,OAAO,IAAI,IAAI;IAMf,OAAO,IAAI,IAAI;IAOf,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI;IAUpF,OAAO,CAAC,iBAAiB;IA2CzB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,mBAAmB;CA2B3B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BlockId } from '../../model/TypeBrands.js';
|
|
2
|
+
import { ServiceKey, PluginContext } from '../Plugin.js';
|
|
3
|
+
/** Rectangular range of cells within a table. */
|
|
4
|
+
export interface CellRange {
|
|
5
|
+
readonly tableId: BlockId;
|
|
6
|
+
readonly fromRow: number;
|
|
7
|
+
readonly fromCol: number;
|
|
8
|
+
readonly toRow: number;
|
|
9
|
+
readonly toCol: number;
|
|
10
|
+
}
|
|
11
|
+
/** Service for managing multi-cell selection. */
|
|
12
|
+
export interface TableSelectionService {
|
|
13
|
+
getSelectedRange(): CellRange | null;
|
|
14
|
+
setSelectedRange(range: CellRange | null): void;
|
|
15
|
+
getSelectedCellIds(): readonly BlockId[];
|
|
16
|
+
isSelected(cellId: BlockId): boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const TableSelectionServiceKey: ServiceKey<TableSelectionService>;
|
|
19
|
+
/** Creates and registers the TableSelectionService. */
|
|
20
|
+
export declare function createTableSelectionService(context: PluginContext): TableSelectionService;
|
|
21
|
+
/**
|
|
22
|
+
* Installs mouse handlers for multi-cell selection on the editor container.
|
|
23
|
+
* Returns a cleanup function.
|
|
24
|
+
*/
|
|
25
|
+
export declare function installMouseSelection(context: PluginContext, service: TableSelectionService): () => void;
|
|
26
|
+
//# sourceMappingURL=TableSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableSelection.d.ts","sourceRoot":"","sources":["../../../src/plugins/table/TableSelection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,iDAAiD;AACjD,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,iDAAiD;AACjD,MAAM,WAAW,qBAAqB;IACrC,gBAAgB,IAAI,SAAS,GAAG,IAAI,CAAC;IACrC,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;IAChD,kBAAkB,IAAI,SAAS,OAAO,EAAE,CAAC;IACzC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;CACrC;AAED,eAAO,MAAM,wBAAwB,mCAA0D,CAAC;AAEhG,uDAAuD;AACvD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,aAAa,GAAG,qBAAqB,CAqDzF;AAiBD;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,qBAAqB,GAC5B,MAAM,IAAI,CAqFZ"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BlockNode } from '../../model/Document.js';
|
|
2
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
3
|
+
/** Standard schema for table tests. */
|
|
4
|
+
export declare const TABLE_SCHEMA: {
|
|
5
|
+
nodeTypes: string[];
|
|
6
|
+
markTypes: string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Creates a table BlockNode with predictable IDs.
|
|
10
|
+
*
|
|
11
|
+
* ID scheme:
|
|
12
|
+
* - Table: `tableId` (default `'t1'`)
|
|
13
|
+
* - Rows: `row{r}` (e.g. `row0`, `row1`)
|
|
14
|
+
* - Cells: `c{r}_{c}` (e.g. `c0_0`, `c1_2`)
|
|
15
|
+
* - Paragraphs: `p{r}_{c}` (e.g. `p0_0`, `p1_2`)
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTestTableNode(rows: number, cols: number, tableId?: string, cellText?: (row: number, col: number) => string): {
|
|
18
|
+
table: BlockNode;
|
|
19
|
+
cellIds: string[][];
|
|
20
|
+
};
|
|
21
|
+
/** Options for creating a table-containing EditorState. */
|
|
22
|
+
export interface CreateTableStateOptions {
|
|
23
|
+
readonly rows?: number;
|
|
24
|
+
readonly cols?: number;
|
|
25
|
+
readonly cursorRow?: number;
|
|
26
|
+
readonly cursorCol?: number;
|
|
27
|
+
readonly cursorOffset?: number;
|
|
28
|
+
readonly tableId?: string;
|
|
29
|
+
readonly extraBlocks?: 'before' | 'after' | 'both';
|
|
30
|
+
readonly cellText?: (row: number, col: number) => string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates an EditorState containing a table with predictable IDs.
|
|
34
|
+
*
|
|
35
|
+
* Extra blocks use IDs `'before'` and `'after'`.
|
|
36
|
+
* Cursor is placed in the paragraph at `p{cursorRow}_{cursorCol}`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createTableState(options?: CreateTableStateOptions): EditorState;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a table state using random IDs (via TableHelpers.createTable).
|
|
41
|
+
* Cursor is placed in the cell paragraph at [cursorRow][cursorCol].
|
|
42
|
+
* Includes an extra paragraph after the table with id `'para-after'`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createTableStateWithRandomIds(rows?: number, cols?: number, cursorRow?: number, cursorCol?: number): EditorState;
|
|
45
|
+
//# sourceMappingURL=TableTestUtils.d.ts.map
|