@rtif-sdk/web 1.0.0
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/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/block-drag-handler.d.ts +189 -0
- package/dist/block-drag-handler.d.ts.map +1 -0
- package/dist/block-drag-handler.js +745 -0
- package/dist/block-drag-handler.js.map +1 -0
- package/dist/block-renderer.d.ts +402 -0
- package/dist/block-renderer.d.ts.map +1 -0
- package/dist/block-renderer.js +424 -0
- package/dist/block-renderer.js.map +1 -0
- package/dist/clipboard.d.ts +178 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +432 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/command-bus.d.ts +113 -0
- package/dist/command-bus.d.ts.map +1 -0
- package/dist/command-bus.js +70 -0
- package/dist/command-bus.js.map +1 -0
- package/dist/composition.d.ts +220 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +271 -0
- package/dist/composition.js.map +1 -0
- package/dist/content-extraction.d.ts +69 -0
- package/dist/content-extraction.d.ts.map +1 -0
- package/dist/content-extraction.js +228 -0
- package/dist/content-extraction.js.map +1 -0
- package/dist/content-handler-file.d.ts +40 -0
- package/dist/content-handler-file.d.ts.map +1 -0
- package/dist/content-handler-file.js +91 -0
- package/dist/content-handler-file.js.map +1 -0
- package/dist/content-handler-image.d.ts +82 -0
- package/dist/content-handler-image.d.ts.map +1 -0
- package/dist/content-handler-image.js +120 -0
- package/dist/content-handler-image.js.map +1 -0
- package/dist/content-handler-url.d.ts +129 -0
- package/dist/content-handler-url.d.ts.map +1 -0
- package/dist/content-handler-url.js +244 -0
- package/dist/content-handler-url.js.map +1 -0
- package/dist/content-handlers.d.ts +67 -0
- package/dist/content-handlers.d.ts.map +1 -0
- package/dist/content-handlers.js +263 -0
- package/dist/content-handlers.js.map +1 -0
- package/dist/content-pipeline.d.ts +383 -0
- package/dist/content-pipeline.d.ts.map +1 -0
- package/dist/content-pipeline.js +232 -0
- package/dist/content-pipeline.js.map +1 -0
- package/dist/cursor-nav.d.ts +149 -0
- package/dist/cursor-nav.d.ts.map +1 -0
- package/dist/cursor-nav.js +230 -0
- package/dist/cursor-nav.js.map +1 -0
- package/dist/cursor-rect.d.ts +65 -0
- package/dist/cursor-rect.d.ts.map +1 -0
- package/dist/cursor-rect.js +98 -0
- package/dist/cursor-rect.js.map +1 -0
- package/dist/drop-indicator.d.ts +108 -0
- package/dist/drop-indicator.d.ts.map +1 -0
- package/dist/drop-indicator.js +236 -0
- package/dist/drop-indicator.js.map +1 -0
- package/dist/editor.d.ts +41 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +710 -0
- package/dist/editor.js.map +1 -0
- package/dist/floating-toolbar.d.ts +93 -0
- package/dist/floating-toolbar.d.ts.map +1 -0
- package/dist/floating-toolbar.js +159 -0
- package/dist/floating-toolbar.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +119 -0
- package/dist/index.js.map +1 -0
- package/dist/input-bridge.d.ts +273 -0
- package/dist/input-bridge.d.ts.map +1 -0
- package/dist/input-bridge.js +884 -0
- package/dist/input-bridge.js.map +1 -0
- package/dist/link-popover.d.ts +38 -0
- package/dist/link-popover.d.ts.map +1 -0
- package/dist/link-popover.js +278 -0
- package/dist/link-popover.js.map +1 -0
- package/dist/mark-renderer.d.ts +275 -0
- package/dist/mark-renderer.d.ts.map +1 -0
- package/dist/mark-renderer.js +210 -0
- package/dist/mark-renderer.js.map +1 -0
- package/dist/perf.d.ts +145 -0
- package/dist/perf.d.ts.map +1 -0
- package/dist/perf.js +260 -0
- package/dist/perf.js.map +1 -0
- package/dist/plugin-kit.d.ts +265 -0
- package/dist/plugin-kit.d.ts.map +1 -0
- package/dist/plugin-kit.js +234 -0
- package/dist/plugin-kit.js.map +1 -0
- package/dist/plugins/alignment-plugin.d.ts +68 -0
- package/dist/plugins/alignment-plugin.d.ts.map +1 -0
- package/dist/plugins/alignment-plugin.js +98 -0
- package/dist/plugins/alignment-plugin.js.map +1 -0
- package/dist/plugins/block-utils.d.ts +113 -0
- package/dist/plugins/block-utils.d.ts.map +1 -0
- package/dist/plugins/block-utils.js +191 -0
- package/dist/plugins/block-utils.js.map +1 -0
- package/dist/plugins/blockquote-plugin.d.ts +39 -0
- package/dist/plugins/blockquote-plugin.d.ts.map +1 -0
- package/dist/plugins/blockquote-plugin.js +88 -0
- package/dist/plugins/blockquote-plugin.js.map +1 -0
- package/dist/plugins/bold-plugin.d.ts +37 -0
- package/dist/plugins/bold-plugin.d.ts.map +1 -0
- package/dist/plugins/bold-plugin.js +48 -0
- package/dist/plugins/bold-plugin.js.map +1 -0
- package/dist/plugins/callout-plugin.d.ts +100 -0
- package/dist/plugins/callout-plugin.d.ts.map +1 -0
- package/dist/plugins/callout-plugin.js +200 -0
- package/dist/plugins/callout-plugin.js.map +1 -0
- package/dist/plugins/code-block-plugin.d.ts +62 -0
- package/dist/plugins/code-block-plugin.d.ts.map +1 -0
- package/dist/plugins/code-block-plugin.js +176 -0
- package/dist/plugins/code-block-plugin.js.map +1 -0
- package/dist/plugins/code-plugin.d.ts +37 -0
- package/dist/plugins/code-plugin.d.ts.map +1 -0
- package/dist/plugins/code-plugin.js +48 -0
- package/dist/plugins/code-plugin.js.map +1 -0
- package/dist/plugins/embed-plugin.d.ts +90 -0
- package/dist/plugins/embed-plugin.d.ts.map +1 -0
- package/dist/plugins/embed-plugin.js +147 -0
- package/dist/plugins/embed-plugin.js.map +1 -0
- package/dist/plugins/font-family-plugin.d.ts +58 -0
- package/dist/plugins/font-family-plugin.d.ts.map +1 -0
- package/dist/plugins/font-family-plugin.js +57 -0
- package/dist/plugins/font-family-plugin.js.map +1 -0
- package/dist/plugins/font-size-plugin.d.ts +57 -0
- package/dist/plugins/font-size-plugin.d.ts.map +1 -0
- package/dist/plugins/font-size-plugin.js +56 -0
- package/dist/plugins/font-size-plugin.js.map +1 -0
- package/dist/plugins/heading-plugin.d.ts +52 -0
- package/dist/plugins/heading-plugin.d.ts.map +1 -0
- package/dist/plugins/heading-plugin.js +114 -0
- package/dist/plugins/heading-plugin.js.map +1 -0
- package/dist/plugins/hr-plugin.d.ts +33 -0
- package/dist/plugins/hr-plugin.d.ts.map +1 -0
- package/dist/plugins/hr-plugin.js +75 -0
- package/dist/plugins/hr-plugin.js.map +1 -0
- package/dist/plugins/image-plugin.d.ts +115 -0
- package/dist/plugins/image-plugin.d.ts.map +1 -0
- package/dist/plugins/image-plugin.js +199 -0
- package/dist/plugins/image-plugin.js.map +1 -0
- package/dist/plugins/indent-plugin.d.ts +62 -0
- package/dist/plugins/indent-plugin.d.ts.map +1 -0
- package/dist/plugins/indent-plugin.js +128 -0
- package/dist/plugins/indent-plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +45 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +42 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/italic-plugin.d.ts +37 -0
- package/dist/plugins/italic-plugin.d.ts.map +1 -0
- package/dist/plugins/italic-plugin.js +48 -0
- package/dist/plugins/italic-plugin.js.map +1 -0
- package/dist/plugins/link-plugin.d.ts +129 -0
- package/dist/plugins/link-plugin.d.ts.map +1 -0
- package/dist/plugins/link-plugin.js +212 -0
- package/dist/plugins/link-plugin.js.map +1 -0
- package/dist/plugins/list-plugin.d.ts +53 -0
- package/dist/plugins/list-plugin.d.ts.map +1 -0
- package/dist/plugins/list-plugin.js +309 -0
- package/dist/plugins/list-plugin.js.map +1 -0
- package/dist/plugins/mark-utils.d.ts +173 -0
- package/dist/plugins/mark-utils.d.ts.map +1 -0
- package/dist/plugins/mark-utils.js +425 -0
- package/dist/plugins/mark-utils.js.map +1 -0
- package/dist/plugins/mention-plugin.d.ts +191 -0
- package/dist/plugins/mention-plugin.d.ts.map +1 -0
- package/dist/plugins/mention-plugin.js +295 -0
- package/dist/plugins/mention-plugin.js.map +1 -0
- package/dist/plugins/strikethrough-plugin.d.ts +37 -0
- package/dist/plugins/strikethrough-plugin.d.ts.map +1 -0
- package/dist/plugins/strikethrough-plugin.js +48 -0
- package/dist/plugins/strikethrough-plugin.js.map +1 -0
- package/dist/plugins/text-color-plugin.d.ts +57 -0
- package/dist/plugins/text-color-plugin.d.ts.map +1 -0
- package/dist/plugins/text-color-plugin.js +56 -0
- package/dist/plugins/text-color-plugin.js.map +1 -0
- package/dist/plugins/underline-plugin.d.ts +37 -0
- package/dist/plugins/underline-plugin.d.ts.map +1 -0
- package/dist/plugins/underline-plugin.js +48 -0
- package/dist/plugins/underline-plugin.js.map +1 -0
- package/dist/presets.d.ts +95 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +159 -0
- package/dist/presets.js.map +1 -0
- package/dist/renderer.d.ts +125 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +415 -0
- package/dist/renderer.js.map +1 -0
- package/dist/scroll-to-cursor.d.ts +25 -0
- package/dist/scroll-to-cursor.d.ts.map +1 -0
- package/dist/scroll-to-cursor.js +59 -0
- package/dist/scroll-to-cursor.js.map +1 -0
- package/dist/selection-sync.d.ts +159 -0
- package/dist/selection-sync.d.ts.map +1 -0
- package/dist/selection-sync.js +527 -0
- package/dist/selection-sync.js.map +1 -0
- package/dist/shortcut-handler.d.ts +98 -0
- package/dist/shortcut-handler.d.ts.map +1 -0
- package/dist/shortcut-handler.js +155 -0
- package/dist/shortcut-handler.js.map +1 -0
- package/dist/toolbar.d.ts +103 -0
- package/dist/toolbar.d.ts.map +1 -0
- package/dist/toolbar.js +134 -0
- package/dist/toolbar.js.map +1 -0
- package/dist/trigger-manager.d.ts +205 -0
- package/dist/trigger-manager.d.ts.map +1 -0
- package/dist/trigger-manager.js +466 -0
- package/dist/trigger-manager.js.map +1 -0
- package/dist/types.d.ts +216 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugins and shared utilities for the RTIF web editor.
|
|
3
|
+
*
|
|
4
|
+
* Mark plugins register mark types, toggle commands, and keyboard shortcuts.
|
|
5
|
+
* Block utilities provide shared helpers for block type plugins.
|
|
6
|
+
* Load only the plugins you need.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
// Mark utilities
|
|
11
|
+
export { createToggleMarkCommand, toggleMark, isMarkActiveAtSelection, createSetMarkCommand, createRemoveMarkCommand, findContiguousMarkRange, adjustOffsetAroundAtomicMarks, adjustOffsetAroundAtomicBlocks, } from './mark-utils.js';
|
|
12
|
+
// Block utilities
|
|
13
|
+
export { getBlockStartOffset, getBlockAtCursor, isBlockType, createToggleBlockTypeCommand, setBlockType, } from './block-utils.js';
|
|
14
|
+
// Simple boolean mark plugins
|
|
15
|
+
export { boldPlugin, BoldCommands } from './bold-plugin.js';
|
|
16
|
+
export { italicPlugin, ItalicCommands } from './italic-plugin.js';
|
|
17
|
+
export { underlinePlugin, UnderlineCommands } from './underline-plugin.js';
|
|
18
|
+
export { strikethroughPlugin, StrikethroughCommands } from './strikethrough-plugin.js';
|
|
19
|
+
export { codePlugin, CodeMarkCommands } from './code-plugin.js';
|
|
20
|
+
// Parameterized mark plugins
|
|
21
|
+
export { linkPlugin, createLinkPlugin, LinkCommands } from './link-plugin.js';
|
|
22
|
+
export { textColorPlugin, TextColorCommands } from './text-color-plugin.js';
|
|
23
|
+
export { fontSizePlugin, FontSizeCommands } from './font-size-plugin.js';
|
|
24
|
+
export { fontFamilyPlugin, FontFamilyCommands } from './font-family-plugin.js';
|
|
25
|
+
// Block type plugins
|
|
26
|
+
export { headingPlugin, HeadingCommands } from './heading-plugin.js';
|
|
27
|
+
export { listPlugin, ListCommands } from './list-plugin.js';
|
|
28
|
+
export { blockquotePlugin, BlockquoteCommands } from './blockquote-plugin.js';
|
|
29
|
+
export { codeBlockPlugin, CodeBlockCommands } from './code-block-plugin.js';
|
|
30
|
+
export { hrPlugin } from './hr-plugin.js';
|
|
31
|
+
export { calloutPlugin, CalloutCommands } from './callout-plugin.js';
|
|
32
|
+
export { embedPlugin, EmbedCommands } from './embed-plugin.js';
|
|
33
|
+
// Paragraph formatting plugins
|
|
34
|
+
export { alignmentPlugin, AlignmentCommands } from './alignment-plugin.js';
|
|
35
|
+
export { indentPlugin, IndentCommands, MAX_INDENT } from './indent-plugin.js';
|
|
36
|
+
// Image block plugin
|
|
37
|
+
export { imagePlugin, ImageCommands } from './image-plugin.js';
|
|
38
|
+
// Plugin kit
|
|
39
|
+
export { defineBooleanMark, defineParameterizedMark, defineBlockType, installWebPlugins, } from '../plugin-kit.js';
|
|
40
|
+
// Mention plugin
|
|
41
|
+
export { createMentionPlugin, MentionCommands, mentionPlaintextSerializer, mentionMarkdownSerializer, mentionHtmlSerializer, } from './mention-plugin.js';
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iBAAiB;AACjB,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,kBAAkB;AAClB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,4BAA4B,EAC5B,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,8BAA8B;AAC9B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,mBA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,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Italic mark plugin — registers the `italic` mark type, `toggleMark:italic` command,
|
|
3
|
+
* and Cmd/Ctrl+I keyboard shortcut.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { Plugin } from '@rtif-sdk/engine';
|
|
8
|
+
/**
|
|
9
|
+
* Command name constants for the italic plugin.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* engine.exec(ItalicCommands.TOGGLE);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const ItalicCommands: {
|
|
17
|
+
readonly TOGGLE: "toggleMark:italic";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Create the italic mark plugin.
|
|
21
|
+
*
|
|
22
|
+
* Registers:
|
|
23
|
+
* - Mark type: `italic` (value must be `true`)
|
|
24
|
+
* - Command: `toggleMark:italic`
|
|
25
|
+
* - Shortcut: Cmd/Ctrl+I
|
|
26
|
+
*
|
|
27
|
+
* @returns A plugin instance ready for `engine.use()`
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const engine = createEngine(initialDoc);
|
|
32
|
+
* engine.use(italicPlugin());
|
|
33
|
+
* engine.exec(ItalicCommands.TOGGLE);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function italicPlugin(): Plugin;
|
|
37
|
+
//# sourceMappingURL=italic-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"italic-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/italic-plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG/C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;CAEjB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAarC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Italic mark plugin — registers the `italic` mark type, `toggleMark:italic` command,
|
|
3
|
+
* and Cmd/Ctrl+I keyboard shortcut.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { createToggleMarkCommand } from './mark-utils.js';
|
|
8
|
+
/**
|
|
9
|
+
* Command name constants for the italic plugin.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* engine.exec(ItalicCommands.TOGGLE);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export const ItalicCommands = {
|
|
17
|
+
TOGGLE: 'toggleMark:italic',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Create the italic mark plugin.
|
|
21
|
+
*
|
|
22
|
+
* Registers:
|
|
23
|
+
* - Mark type: `italic` (value must be `true`)
|
|
24
|
+
* - Command: `toggleMark:italic`
|
|
25
|
+
* - Shortcut: Cmd/Ctrl+I
|
|
26
|
+
*
|
|
27
|
+
* @returns A plugin instance ready for `engine.use()`
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const engine = createEngine(initialDoc);
|
|
32
|
+
* engine.use(italicPlugin());
|
|
33
|
+
* engine.exec(ItalicCommands.TOGGLE);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function italicPlugin() {
|
|
37
|
+
return {
|
|
38
|
+
id: 'mark-italic',
|
|
39
|
+
init(ctx) {
|
|
40
|
+
ctx.registerMarkType('italic', {
|
|
41
|
+
validate: (value) => value === true,
|
|
42
|
+
});
|
|
43
|
+
ctx.registerCommand(ItalicCommands.TOGGLE, createToggleMarkCommand('italic'));
|
|
44
|
+
ctx.registerShortcut({ key: 'i', mod: true }, ItalicCommands.TOGGLE);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=italic-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"italic-plugin.js","sourceRoot":"","sources":["../../src/plugins/italic-plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,MAAM,EAAE,mBAAmB;CACnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL,EAAE,EAAE,aAAa;QACjB,IAAI,CAAC,GAAG;YACN,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE;gBAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI;aACpC,CAAC,CAAC;YAEH,GAAG,CAAC,eAAe,CAAC,cAAc,CAAC,MAAM,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAE9E,GAAG,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link mark plugin — registers the `link` mark type (parameterized with `href`),
|
|
3
|
+
* `insertLink`, `removeLink`, `updateLink`, `showLinkUI` commands, and
|
|
4
|
+
* Cmd/Ctrl+K shortcut.
|
|
5
|
+
*
|
|
6
|
+
* Unlike simple boolean marks, links carry structured data (`{ href, title? }`)
|
|
7
|
+
* and require multiple commands for create, update, and remove operations.
|
|
8
|
+
*
|
|
9
|
+
* The `createLinkPlugin()` factory returns `{ plugin, attach }` following the
|
|
10
|
+
* same pattern as the mention plugin. The `attach()` function wires up the
|
|
11
|
+
* `showLinkUI` command callback for the web layer.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { Plugin } from '@rtif-sdk/engine';
|
|
16
|
+
import type { WebEditor, Disposable } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Command name constants for the link plugin.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* engine.exec(LinkCommands.INSERT, { href: 'https://example.com' });
|
|
23
|
+
* engine.exec(LinkCommands.REMOVE);
|
|
24
|
+
* engine.exec(LinkCommands.UPDATE, { href: 'https://new-url.com' });
|
|
25
|
+
* engine.exec(LinkCommands.SHOW_UI);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const LinkCommands: {
|
|
29
|
+
readonly INSERT: "insertLink";
|
|
30
|
+
readonly REMOVE: "removeLink";
|
|
31
|
+
readonly UPDATE: "updateLink";
|
|
32
|
+
readonly SHOW_UI: "showLinkUI";
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Payload for the `insertLink` command.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* engine.exec('insertLink', { href: 'https://example.com', text: 'Example' });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export interface InsertLinkPayload {
|
|
43
|
+
/** The URL for the link */
|
|
44
|
+
readonly href: string;
|
|
45
|
+
/** Optional display text. If omitted and cursor is collapsed, the href is used. */
|
|
46
|
+
readonly text?: string;
|
|
47
|
+
/** Optional title attribute for the link */
|
|
48
|
+
readonly title?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Payload for the `updateLink` command.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* engine.exec('updateLink', { href: 'https://new-url.com' });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export interface UpdateLinkPayload {
|
|
59
|
+
/** The new URL for the link */
|
|
60
|
+
readonly href: string;
|
|
61
|
+
/** Optional new title attribute */
|
|
62
|
+
readonly title?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Callback invoked when the link UI should be shown.
|
|
66
|
+
*
|
|
67
|
+
* @param mode - Whether to show insert or edit UI
|
|
68
|
+
* @param currentHref - The current href when editing (undefined for insert mode)
|
|
69
|
+
*/
|
|
70
|
+
export type ShowLinkUICallback = (mode: 'insert' | 'edit', currentHref?: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Result from `createLinkPlugin()`.
|
|
73
|
+
*/
|
|
74
|
+
export interface LinkPluginResult {
|
|
75
|
+
/** The engine plugin instance */
|
|
76
|
+
readonly plugin: Plugin;
|
|
77
|
+
/**
|
|
78
|
+
* Attach the link plugin's web layer to a WebEditor instance.
|
|
79
|
+
* Sets up the `showLinkUI` command callback and click-to-edit behavior.
|
|
80
|
+
*
|
|
81
|
+
* @param editor - The web editor instance
|
|
82
|
+
* @param onShowUI - Callback to show the link UI
|
|
83
|
+
* @returns A disposable for cleanup
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const { plugin, attach } = createLinkPlugin();
|
|
88
|
+
* engine.use(plugin);
|
|
89
|
+
*
|
|
90
|
+
* const editor = createWebEditor({ root, engine, accessibleLabel: 'Editor' });
|
|
91
|
+
* const disposable = attach(editor, (mode, currentHref) => {
|
|
92
|
+
* showMyLinkPopover(mode, currentHref);
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
attach(editor: WebEditor, onShowUI: ShowLinkUICallback): Disposable;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create the link mark plugin with web layer attachment.
|
|
100
|
+
*
|
|
101
|
+
* Registers:
|
|
102
|
+
* - Mark type: `link` (value must be `{ href: string, title?: string }`)
|
|
103
|
+
* - Command: `insertLink` — apply link to selection or insert linked text
|
|
104
|
+
* - Command: `removeLink` — remove link mark at cursor
|
|
105
|
+
* - Command: `updateLink` — update href/title of link at cursor
|
|
106
|
+
* - Command: `showLinkUI` — trigger the link editing UI
|
|
107
|
+
* - Shortcut: Cmd/Ctrl+K → `showLinkUI`
|
|
108
|
+
*
|
|
109
|
+
* @returns Plugin and attach function
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const { plugin, attach } = createLinkPlugin();
|
|
114
|
+
* engine.use(plugin);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function createLinkPlugin(): LinkPluginResult;
|
|
118
|
+
/**
|
|
119
|
+
* Create the link mark plugin (backward-compatible wrapper).
|
|
120
|
+
*
|
|
121
|
+
* @returns A plugin instance ready for `engine.use()`
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* engine.use(linkPlugin());
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function linkPlugin(): Plugin;
|
|
129
|
+
//# sourceMappingURL=link-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/link-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,IAAI,EAAE,QAAQ,GAAG,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,KACjB,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,GAAG,UAAU,CAAC;CACrE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAiLnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link mark plugin — registers the `link` mark type (parameterized with `href`),
|
|
3
|
+
* `insertLink`, `removeLink`, `updateLink`, `showLinkUI` commands, and
|
|
4
|
+
* Cmd/Ctrl+K shortcut.
|
|
5
|
+
*
|
|
6
|
+
* Unlike simple boolean marks, links carry structured data (`{ href, title? }`)
|
|
7
|
+
* and require multiple commands for create, update, and remove operations.
|
|
8
|
+
*
|
|
9
|
+
* The `createLinkPlugin()` factory returns `{ plugin, attach }` following the
|
|
10
|
+
* same pattern as the mention plugin. The `attach()` function wires up the
|
|
11
|
+
* `showLinkUI` command callback for the web layer.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { findContiguousMarkRange } from './mark-utils.js';
|
|
16
|
+
/**
|
|
17
|
+
* Command name constants for the link plugin.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* engine.exec(LinkCommands.INSERT, { href: 'https://example.com' });
|
|
22
|
+
* engine.exec(LinkCommands.REMOVE);
|
|
23
|
+
* engine.exec(LinkCommands.UPDATE, { href: 'https://new-url.com' });
|
|
24
|
+
* engine.exec(LinkCommands.SHOW_UI);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const LinkCommands = {
|
|
28
|
+
INSERT: 'insertLink',
|
|
29
|
+
REMOVE: 'removeLink',
|
|
30
|
+
UPDATE: 'updateLink',
|
|
31
|
+
SHOW_UI: 'showLinkUI',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create the link mark plugin with web layer attachment.
|
|
35
|
+
*
|
|
36
|
+
* Registers:
|
|
37
|
+
* - Mark type: `link` (value must be `{ href: string, title?: string }`)
|
|
38
|
+
* - Command: `insertLink` — apply link to selection or insert linked text
|
|
39
|
+
* - Command: `removeLink` — remove link mark at cursor
|
|
40
|
+
* - Command: `updateLink` — update href/title of link at cursor
|
|
41
|
+
* - Command: `showLinkUI` — trigger the link editing UI
|
|
42
|
+
* - Shortcut: Cmd/Ctrl+K → `showLinkUI`
|
|
43
|
+
*
|
|
44
|
+
* @returns Plugin and attach function
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const { plugin, attach } = createLinkPlugin();
|
|
49
|
+
* engine.use(plugin);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function createLinkPlugin() {
|
|
53
|
+
// Mutable callback bridge — set by attach()
|
|
54
|
+
let showUICallback = null;
|
|
55
|
+
const plugin = {
|
|
56
|
+
id: 'mark-link',
|
|
57
|
+
init(ctx) {
|
|
58
|
+
ctx.registerMarkType('link', {
|
|
59
|
+
validate: (value) => {
|
|
60
|
+
return (typeof value === 'object' &&
|
|
61
|
+
value !== null &&
|
|
62
|
+
typeof value.href === 'string');
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
// ---------------------------------------------------------------
|
|
66
|
+
// insertLink command
|
|
67
|
+
// ---------------------------------------------------------------
|
|
68
|
+
ctx.registerCommand(LinkCommands.INSERT, {
|
|
69
|
+
execute(engine, payload) {
|
|
70
|
+
const p = payload;
|
|
71
|
+
if (!p || !p.href)
|
|
72
|
+
return;
|
|
73
|
+
const { anchor, focus } = engine.state.selection;
|
|
74
|
+
const start = Math.min(anchor.offset, focus.offset);
|
|
75
|
+
const end = Math.max(anchor.offset, focus.offset);
|
|
76
|
+
const linkMark = { href: p.href };
|
|
77
|
+
if (p.title)
|
|
78
|
+
linkMark.title = p.title;
|
|
79
|
+
if (start !== end) {
|
|
80
|
+
// Selection exists — apply link to selected text
|
|
81
|
+
engine.dispatch({
|
|
82
|
+
type: 'set_span_marks',
|
|
83
|
+
offset: start,
|
|
84
|
+
count: end - start,
|
|
85
|
+
marks: { link: linkMark },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// No selection — insert text + apply link
|
|
90
|
+
const text = p.text || p.href;
|
|
91
|
+
engine.dispatch([
|
|
92
|
+
{ type: 'insert_text', offset: start, text },
|
|
93
|
+
{
|
|
94
|
+
type: 'set_span_marks',
|
|
95
|
+
offset: start,
|
|
96
|
+
count: text.length,
|
|
97
|
+
marks: { link: linkMark },
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
canExecute(_engine) {
|
|
103
|
+
return true;
|
|
104
|
+
},
|
|
105
|
+
isActive(engine) {
|
|
106
|
+
const marks = engine.getMarksAtOffset(engine.state.selection.focus.offset);
|
|
107
|
+
return (typeof marks.link === 'object' &&
|
|
108
|
+
marks.link !== null);
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
// ---------------------------------------------------------------
|
|
112
|
+
// removeLink command
|
|
113
|
+
// ---------------------------------------------------------------
|
|
114
|
+
ctx.registerCommand(LinkCommands.REMOVE, {
|
|
115
|
+
execute(engine) {
|
|
116
|
+
const focusOffset = engine.state.selection.focus.offset;
|
|
117
|
+
const range = findContiguousMarkRange(engine.state.doc, focusOffset, 'link');
|
|
118
|
+
if (!range)
|
|
119
|
+
return;
|
|
120
|
+
engine.dispatch({
|
|
121
|
+
type: 'set_span_marks',
|
|
122
|
+
offset: range.offset,
|
|
123
|
+
count: range.count,
|
|
124
|
+
marks: { link: null },
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
canExecute(engine) {
|
|
128
|
+
const marks = engine.getMarksAtOffset(engine.state.selection.focus.offset);
|
|
129
|
+
return typeof marks.link === 'object' && marks.link !== null;
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
// ---------------------------------------------------------------
|
|
133
|
+
// updateLink command
|
|
134
|
+
// ---------------------------------------------------------------
|
|
135
|
+
ctx.registerCommand(LinkCommands.UPDATE, {
|
|
136
|
+
execute(engine, payload) {
|
|
137
|
+
const p = payload;
|
|
138
|
+
if (!p || !p.href)
|
|
139
|
+
return;
|
|
140
|
+
const focusOffset = engine.state.selection.focus.offset;
|
|
141
|
+
const range = findContiguousMarkRange(engine.state.doc, focusOffset, 'link');
|
|
142
|
+
if (!range)
|
|
143
|
+
return;
|
|
144
|
+
const linkMark = { href: p.href };
|
|
145
|
+
if (p.title)
|
|
146
|
+
linkMark.title = p.title;
|
|
147
|
+
engine.dispatch({
|
|
148
|
+
type: 'set_span_marks',
|
|
149
|
+
offset: range.offset,
|
|
150
|
+
count: range.count,
|
|
151
|
+
marks: { link: linkMark },
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
canExecute(engine) {
|
|
155
|
+
const marks = engine.getMarksAtOffset(engine.state.selection.focus.offset);
|
|
156
|
+
return typeof marks.link === 'object' && marks.link !== null;
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
// ---------------------------------------------------------------
|
|
160
|
+
// showLinkUI command
|
|
161
|
+
// ---------------------------------------------------------------
|
|
162
|
+
ctx.registerCommand(LinkCommands.SHOW_UI, {
|
|
163
|
+
execute(engine) {
|
|
164
|
+
if (!showUICallback)
|
|
165
|
+
return;
|
|
166
|
+
const marks = engine.getMarksAtOffset(engine.state.selection.focus.offset);
|
|
167
|
+
const linkMark = marks.link;
|
|
168
|
+
if (typeof linkMark === 'object' && linkMark !== null && linkMark.href) {
|
|
169
|
+
// Cursor is inside an existing link — edit mode
|
|
170
|
+
showUICallback('edit', linkMark.href);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
// No link at cursor — insert mode
|
|
174
|
+
showUICallback('insert');
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
canExecute(_engine) {
|
|
178
|
+
return showUICallback !== null;
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
// ---------------------------------------------------------------
|
|
182
|
+
// Keyboard shortcut: Cmd/Ctrl+K → showLinkUI
|
|
183
|
+
// ---------------------------------------------------------------
|
|
184
|
+
ctx.registerShortcut({ key: 'k', mod: true }, LinkCommands.SHOW_UI);
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
plugin,
|
|
189
|
+
attach(editor, onShowUI) {
|
|
190
|
+
showUICallback = onShowUI;
|
|
191
|
+
return {
|
|
192
|
+
dispose() {
|
|
193
|
+
showUICallback = null;
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Create the link mark plugin (backward-compatible wrapper).
|
|
201
|
+
*
|
|
202
|
+
* @returns A plugin instance ready for `engine.use()`
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* engine.use(linkPlugin());
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export function linkPlugin() {
|
|
210
|
+
return createLinkPlugin().plugin;
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=link-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-plugin.js","sourceRoot":"","sources":["../../src/plugins/link-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;CACb,CAAC;AA0EX;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,4CAA4C;IAC5C,IAAI,cAAc,GAA8B,IAAI,CAAC;IAErD,MAAM,MAAM,GAAW;QACrB,EAAE,EAAE,WAAW;QACf,IAAI,CAAC,GAAG;YACN,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE;gBAC3B,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE;oBAC3B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;wBACzB,KAAK,KAAK,IAAI;wBACd,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CACvD,CAAC;gBACJ,CAAC;aACF,CAAC,CAAC;YAEH,kEAAkE;YAClE,qBAAqB;YACrB,kEAAkE;YAElE,GAAG,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,EAAE;gBACvC,OAAO,CAAC,MAAqB,EAAE,OAAiB;oBAC9C,MAAM,CAAC,GAAG,OAAwC,CAAC;oBACnD,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;wBAAE,OAAO;oBAE1B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;oBACjD,MAAM,KAAK,GAAG,I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Q,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;wBACvE,gDAAgD;wBAChD,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACxC,CAAC;yBAAM,CAAC;wBACN,kCAAkC;wBAClC,cAAc,CAAC,QAAQ,CAAC,CAAC;oBAC3B,CAAC;gBACH,CAAC;gBAED,UAAU,CAAC,OAAsB;oBAC/B,OAAO,cAAc,KAAK,IAAI,CAAC;gBACjC,CAAC;aACF,CAAC,CAAC;YAEH,kEAAkE;YAClE,6CAA6C;YAC7C,kEAAkE;YAElE,GAAG,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACtE,CAAC;KACF,CAAC;IAEF,OAAO;QACL,MAAM;QAEN,MAAM,CAAC,MAAiB,EAAE,QAA4B;YACpD,cAAc,GAAG,QAAQ,CAAC;YAE1B,OAAO;gBACL,OAAO;oBACL,cAAc,GAAG,IAAI,CAAC;gBACxB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,gBAAgB,EAAE,CAAC,MAAM,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List item block type plugin -- registers the `list-item` block type,
|
|
3
|
+
* `toggleBulletList` / `toggleOrderedList` toggle commands,
|
|
4
|
+
* `indentList` / `outdentList` depth commands, and input rules for
|
|
5
|
+
* `- `, `* `, and `1. ` at block start.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { Plugin } from '@rtif-sdk/engine';
|
|
10
|
+
/**
|
|
11
|
+
* Command name constants for the list plugin.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* engine.exec(ListCommands.TOGGLE_BULLET);
|
|
16
|
+
* engine.exec(ListCommands.TOGGLE_ORDERED);
|
|
17
|
+
* engine.exec(ListCommands.INDENT);
|
|
18
|
+
* engine.exec(ListCommands.OUTDENT);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const ListCommands: {
|
|
22
|
+
readonly TOGGLE_BULLET: "toggleBulletList";
|
|
23
|
+
readonly TOGGLE_ORDERED: "toggleOrderedList";
|
|
24
|
+
readonly INDENT: "indentList";
|
|
25
|
+
readonly OUTDENT: "outdentList";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Create the list item block type plugin.
|
|
29
|
+
*
|
|
30
|
+
* Registers:
|
|
31
|
+
* - Block type: `list-item` (attrs must have `listStyle` of "bullet" or "ordered", `depth` >= 0)
|
|
32
|
+
* - Command: `toggleBulletList` -- toggle between bullet list-item and plain text
|
|
33
|
+
* - Command: `toggleOrderedList` -- toggle between ordered list-item and plain text
|
|
34
|
+
* - Command: `indentList` -- increase list-item depth by 1 (max 8)
|
|
35
|
+
* - Command: `outdentList` -- decrease list-item depth by 1, or revert to text at depth 0
|
|
36
|
+
* - Input rules: `- ` / `* ` at block start converts to bullet list, `1. ` converts to ordered list
|
|
37
|
+
*
|
|
38
|
+
* @returns A plugin instance ready for `engine.use()`
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const engine = createEngine(initialDoc);
|
|
43
|
+
* engine.use(listPlugin());
|
|
44
|
+
*
|
|
45
|
+
* // Toggle bullet list on the block at cursor
|
|
46
|
+
* engine.exec(ListCommands.TOGGLE_BULLET);
|
|
47
|
+
*
|
|
48
|
+
* // Indent the current list item
|
|
49
|
+
* engine.exec(ListCommands.INDENT);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function listPlugin(): Plugin;
|
|
53
|
+
//# sourceMappingURL=list-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/list-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAA8B,MAAM,kBAAkB,CAAC;AAK3E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAqEX;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAkOnC"}
|