xiaodao-editor 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +306 -0
- package/dist/block-editor.js +23254 -0
- package/dist/block-editor.umd.cjs +26 -0
- package/dist/core/Editor.d.ts +83 -0
- package/dist/core/command/Command.d.ts +32 -0
- package/dist/core/command/InputRule.d.ts +21 -0
- package/dist/core/command/Keymap.d.ts +42 -0
- package/dist/core/command/SlashCommand.d.ts +24 -0
- package/dist/core/command/primitiveCommands.d.ts +97 -0
- package/dist/core/extension/Extension.d.ts +52 -0
- package/dist/core/extension/Registry.d.ts +46 -0
- package/dist/core/history/HistoryManager.d.ts +37 -0
- package/dist/core/ids.d.ts +5 -0
- package/dist/core/index.d.ts +35 -0
- package/dist/core/plugin/Plugin.d.ts +26 -0
- package/dist/core/schema/BlockSchema.d.ts +70 -0
- package/dist/core/schema/SchemaRegistry.d.ts +22 -0
- package/dist/core/selection/Selection.d.ts +25 -0
- package/dist/core/serialize/Serializer.d.ts +31 -0
- package/dist/core/state/EditorState.d.ts +26 -0
- package/dist/core/state/Step.d.ts +39 -0
- package/dist/core/state/Transaction.d.ts +52 -0
- package/dist/core/state/invert.d.ts +19 -0
- package/dist/core/state/store.d.ts +78 -0
- package/dist/core/types.d.ts +105 -0
- package/dist/extensions/BulletList.d.ts +2 -0
- package/dist/extensions/CodeBlock.d.ts +2 -0
- package/dist/extensions/Divider.d.ts +2 -0
- package/dist/extensions/Heading.d.ts +2 -0
- package/dist/extensions/History.d.ts +2 -0
- package/dist/extensions/Image.d.ts +34 -0
- package/dist/extensions/Keymap.d.ts +2 -0
- package/dist/extensions/OrderedList.d.ts +18 -0
- package/dist/extensions/Paragraph.d.ts +5 -0
- package/dist/extensions/Quote.d.ts +2 -0
- package/dist/extensions/Table.d.ts +74 -0
- package/dist/extensions/TableOfContents.d.ts +18 -0
- package/dist/extensions/TodoList.d.ts +2 -0
- package/dist/extensions/_commonAttrs.d.ts +84 -0
- package/dist/extensions/builtin.d.ts +15 -0
- package/dist/extensions/tableModel.d.ts +199 -0
- package/dist/i18n.d.ts +31 -0
- package/dist/index.d.ts +30 -0
- package/dist/style.css +1 -0
- package/dist/test-img.png +0 -0
- package/dist/view/BlockContent.vue.d.ts +21 -0
- package/dist/view/BlockEditor.vue.d.ts +67 -0
- package/dist/view/BlockHost.vue.d.ts +51 -0
- package/dist/view/BlockList.vue.d.ts +64 -0
- package/dist/view/clipboard.d.ts +11 -0
- package/dist/view/context.d.ts +116 -0
- package/dist/view/domSelection.d.ts +65 -0
- package/dist/view/imageUpload.d.ts +130 -0
- package/dist/view/inlineDom.d.ts +23 -0
- package/dist/view/keymapHandler.d.ts +7 -0
- package/dist/view/ui/BlockHandle.vue.d.ts +33 -0
- package/dist/view/ui/BlockSettingsMenu.vue.d.ts +32 -0
- package/dist/view/ui/CodeLangPicker.vue.d.ts +20 -0
- package/dist/view/ui/HoverToolbar.vue.d.ts +81 -0
- package/dist/view/ui/LinkPopover.vue.d.ts +62 -0
- package/dist/view/ui/MobileToolbar.vue.d.ts +29 -0
- package/dist/view/ui/NumberPicker.vue.d.ts +20 -0
- package/dist/view/ui/OrderedListMenu.vue.d.ts +37 -0
- package/dist/view/ui/PlusMenu.vue.d.ts +29 -0
- package/dist/view/ui/SafeHtml.vue.d.ts +8 -0
- package/dist/view/ui/icons.d.ts +51 -0
- package/dist/view/ui/inputRulesEngine.d.ts +33 -0
- package/dist/view/ui/popup.d.ts +75 -0
- package/dist/view/ui/useMenuDismiss.d.ts +9 -0
- package/dist/view/ui/useMenuScroll.d.ts +2 -0
- package/dist/view/urlUtils.d.ts +39 -0
- package/package.json +73 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BlockId } from '../../core/types';
|
|
2
|
+
type PlusMenuMode = 'slash' | 'insert';
|
|
3
|
+
declare function onKeyDown(event: KeyboardEvent): boolean;
|
|
4
|
+
declare const _default: import('vue').DefineComponent<{
|
|
5
|
+
visible: boolean;
|
|
6
|
+
anchorEl: HTMLElement | null;
|
|
7
|
+
blockId: BlockId;
|
|
8
|
+
query: string;
|
|
9
|
+
rootEl: HTMLElement | null;
|
|
10
|
+
mode?: PlusMenuMode;
|
|
11
|
+
}, {
|
|
12
|
+
onKeyDown: typeof onKeyDown;
|
|
13
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
|
+
close: () => any;
|
|
15
|
+
commit: (command: import('../../core/command/SlashCommand').SlashCommandSpec, mode: PlusMenuMode) => any;
|
|
16
|
+
}, string, import('vue').PublicProps, Readonly<{
|
|
17
|
+
visible: boolean;
|
|
18
|
+
anchorEl: HTMLElement | null;
|
|
19
|
+
blockId: BlockId;
|
|
20
|
+
query: string;
|
|
21
|
+
rootEl: HTMLElement | null;
|
|
22
|
+
mode?: PlusMenuMode;
|
|
23
|
+
}> & Readonly<{
|
|
24
|
+
onClose?: (() => any) | undefined;
|
|
25
|
+
onCommit?: ((command: import('../../core/command/SlashCommand').SlashCommandSpec, mode: PlusMenuMode) => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
mode: PlusMenuMode;
|
|
28
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{
|
|
2
|
+
html?: string;
|
|
3
|
+
}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
4
|
+
html?: string;
|
|
5
|
+
}> & Readonly<{}>, {
|
|
6
|
+
html: string;
|
|
7
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG icon strings for block types, shared by the slash menu (PlusMenu),
|
|
3
|
+
* the block settings menu (BlockSettingsMenu), and the hover toolbar.
|
|
4
|
+
*
|
|
5
|
+
* All icons use a 1024×1024 viewBox with `currentColor` fill so they adapt
|
|
6
|
+
* to the surrounding text color.
|
|
7
|
+
*/
|
|
8
|
+
/** Paragraph — uppercase "T" glyph drawn as two merged rounded-rect strokes. */
|
|
9
|
+
export declare const ICON_PARAGRAPH = "<svg viewBox=\"0 0 1024 1024\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"M426.666667 939.050667a32 32 0 1 1 0-64h53.333333V160H235.093333V170.666667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667A32 32 0 0 1 171.093333 170.666667V128a32 32 0 0 1 32-32H820.693333a32 32 0 0 1 31.701334 27.648l0.298666 4.352v42.666667a32 32 0 1 1-64 0l-0.042666-10.666667H544v715.050667H597.333333a32 32 0 0 1 31.701334 27.648l0.298666 4.352a32 32 0 0 1-32 32h-170.666666z\" fill=\"currentColor\"/></svg>";
|
|
10
|
+
/** H1 — digit "1": simple vertical post with a short left serif (top). */
|
|
11
|
+
export declare const ICON_H1 = "<svg viewBox=\"0 0 1024 1024\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z M848.512 366.933333A32 32 0 0 1 896 394.965333v426.666667a32 32 0 1 1-64 0v-372.565333l-80.554667 44.416a32 32 0 0 1-41.130666-8.96l-2.346667-3.626667a32 32 0 0 1 12.586667-43.477333l128-70.485334z\" fill=\"currentColor\"/></svg>";
|
|
12
|
+
/** H2 — digit "2": mirrored-S arc flowing into a horizontal baseline bar. */
|
|
13
|
+
export declare const ICON_H2 = "<svg viewBox=\"0 0 1024 1024\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z M786.133333 362.666667a152.661333 152.661333 0 0 1 107.946667 260.693333l-166.058667 165.973333h178.773334a32 32 0 0 1 31.744 27.648l0.256 4.352a32 32 0 0 1-32 32h-256a32 32 0 0 1-22.613334-54.613333l220.672-220.672A88.661333 88.661333 0 0 0 786.133333 426.666667h-7.338666a96 96 0 0 0-96 96v20.565333a32 32 0 0 1-64 0v-20.565333a160 160 0 0 1 160-160h7.338666z\" fill=\"currentColor\"/></svg>";
|
|
14
|
+
/** H3 — digit "3": rounded double-stack form (upper + lower lobes). */
|
|
15
|
+
export declare const ICON_H3 = "<svg viewBox=\"0 0 1024 1024\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z m362.410667 192a32 32 0 0 1 22.613333 54.656L809.813333 536.746667l1.792 0.341333a160.085333 160.085333 0 0 1 126.506667 148.053333l0.256 8.490667a160 160 0 0 1-310.912 53.248 32 32 0 0 1 60.373333-21.333333 96 96 0 1 0 90.538667-127.914667h-42.666667a32 32 0 0 1-22.613333-54.613333l116.010667-116.053334h-178.773334a32 32 0 0 1-31.701333-27.648l-0.256-4.352a32 32 0 0 1 32-32h256z\" fill=\"currentColor\"/></svg>";
|
|
16
|
+
/** H4 — digit "4": vertical post + horizontal crossbar + diagonal connector. */
|
|
17
|
+
export declare const ICON_H4 = "<svg viewBox=\"0 0 1024 1024\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z m244.309333 193.493333a32 32 0 0 1 20.992 40.106667l-93.738666 299.776h116.48v-96a32 32 0 0 1 64 0v96h10.666666a32 32 0 0 1 31.744 27.648l0.298667 4.352a32 32 0 0 1-32 32H896v53.333333a32 32 0 1 1-64 0v-53.333333h-160a32 32 0 0 1-30.506667-41.557334l106.666667-341.333333a32 32 0 0 1 40.106667-20.992z\" fill=\"currentColor\"/></svg>";
|
|
18
|
+
/** H5 — digit "5": top bar + left stem + mid bar + sweeping lower arc. */
|
|
19
|
+
export declare const ICON_H5 = "<svg viewBox=\"0 0 1024 1024\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z m363.477333 192.426666a32 32 0 1 1 0 64h-145.706666l-28.245334 113.450667 5.12-1.493333a160.042667 160.042667 0 0 1 100.949334 6.4l9.472 4.266666a160 160 0 1 1-189.610667 249.856 32 32 0 0 1 48-42.325333 96 96 0 1 0 0-126.976c-22.186667 25.130667-63.146667 3.584-55.04-28.928l53.333333-214.016a32 32 0 0 1 31.061334-24.234667h170.666666z\" fill=\"currentColor\"/></svg>";
|
|
20
|
+
/** H6 — digit "6": descending loop with inner oval and opening stroke. */
|
|
21
|
+
export declare const ICON_H6 = "<svg viewBox=\"0 0 1024 1024\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z m292.522667 153.173333a32 32 0 0 1 12.586666 43.52l-93.141333 168.874667a159.957333 159.957333 0 0 1 102.4 19.712 158.848 158.848 0 0 1 58.581333 217.685333 160.426667 160.426667 0 0 1-218.453333 58.24 158.890667 158.890667 0 0 1-62.762667-209.962667l157.312-285.44a32 32 0 0 1 43.52-12.586666z m-141.226667 322.517333a94.890667 94.890667 0 0 0 35.072 130.048 96.426667 96.426667 0 0 0 131.242667-34.901333 94.848 94.848 0 0 0-35.114667-130.048 96.426667 96.426667 0 0 0-131.242667 34.901333z\" fill=\"currentColor\"/></svg>";
|
|
22
|
+
/** Unordered / bullet list — three filled dots with lines. */
|
|
23
|
+
export declare const ICON_BULLET_LIST = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><circle cx=\"3\" cy=\"4\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3\" cy=\"8\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3\" cy=\"12\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\"/><line x1=\"6.5\" y1=\"4\" x2=\"13.5\" y2=\"4\"/><line x1=\"6.5\" y1=\"8\" x2=\"13.5\" y2=\"8\"/><line x1=\"6.5\" y1=\"12\" x2=\"13.5\" y2=\"12\"/></svg>";
|
|
24
|
+
/**
|
|
25
|
+
* Ordered / numbered list — three rows, each with a small numeral
|
|
26
|
+
* drawn as SVG strokes (1, 2, 3) followed by a text line.
|
|
27
|
+
* The numerals are drawn purely with paths — no `<text>` elements.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ICON_ORDERED_LIST = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M2.3 3.7L3.1 2.8L3.1 5.8\" stroke-width=\"1.1\"/><line x1=\"6.5\" y1=\"4\" x2=\"13.5\" y2=\"4\" stroke-width=\"1.3\"/><path d=\"M1.8 7.4C1.8 6.6 4.2 6.6 4.2 7.4C4.2 8.2 1.8 9.5 1.8 9.5L4.2 9.5\" stroke-width=\"1.1\"/><line x1=\"6.5\" y1=\"8\" x2=\"13.5\" y2=\"8\" stroke-width=\"1.3\"/><path d=\"M4.2 11.2C4.2 10.5 3 10.5 1.8 11.5C1.8 12 3 12 3 12C3 12 4.2 12 4.2 13C4.2 13.5 3 13.5 1.8 12.8\" stroke-width=\"1.1\"/><line x1=\"6.5\" y1=\"12\" x2=\"13.5\" y2=\"12\" stroke-width=\"1.3\"/></svg>";
|
|
30
|
+
/** To-do list — checkbox with checkmark. */
|
|
31
|
+
export declare const ICON_TODO = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><rect x=\"2.5\" y=\"2.5\" width=\"11\" height=\"11\" rx=\"2.5\"/><path d=\"M5.5 8L7 9.8L10.8 5.8\"/></svg>";
|
|
32
|
+
/** Quote / blockquote — left bar with text lines. */
|
|
33
|
+
export declare const ICON_QUOTE = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><rect x=\"2.5\" y=\"3\" width=\"2\" height=\"10\" rx=\"1\" fill=\"currentColor\" stroke=\"none\"/><line x1=\"6.5\" y1=\"5\" x2=\"13\" y2=\"5\"/><line x1=\"6.5\" y1=\"8\" x2=\"13\" y2=\"8\"/><line x1=\"6.5\" y1=\"11\" x2=\"10\" y2=\"11\"/></svg>";
|
|
34
|
+
/** Code block — angle brackets with slash. */
|
|
35
|
+
export declare const ICON_CODE = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 4L2 8L5 12\"/><path d=\"M11 4L14 8L11 12\"/><line x1=\"10\" y1=\"3\" x2=\"6\" y2=\"13\"/></svg>";
|
|
36
|
+
/** Divider / horizontal rule — a single horizontal line. */
|
|
37
|
+
export declare const ICON_DIVIDER = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><line x1=\"2\" y1=\"8\" x2=\"14\" y2=\"8\"/></svg>";
|
|
38
|
+
/** Table of Contents — indented list lines with leading dots. */
|
|
39
|
+
export declare const ICON_TOC = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M2 3.5h10M2 8h10M2 12.5h10\"/><path d=\"M14.5 3.5v.01M14.5 8v.01M14.5 12.5v.01\"/></svg>";
|
|
40
|
+
/** Image — rectangle with mountain + sun. Drawn purely with SVG paths, no <text>. */
|
|
41
|
+
export declare const ICON_IMAGE = "<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><rect x=\"2\" y=\"3\" width=\"12\" height=\"10\" rx=\"1.5\"/><circle cx=\"5.5\" cy=\"6.5\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\"/><path d=\"M13 11.5L10 8.5L7 11.5L5 9.5L3 11.5\"/></svg>";
|
|
42
|
+
/** Upload progress spinner — dashed arc, drawn purely with paths. */
|
|
43
|
+
export declare const ICON_SPINNER = "<svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" aria-hidden=\"true\"><g fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\"><path d=\"M12 3a9 9 0 0 1 9 9\" opacity=\"0.25\"/><path d=\"M12 3a9 9 0 0 0-9 9\" class=\"be-spinner-arc\"/></g></svg>";
|
|
44
|
+
/** Retry / refresh icon — circular arrow, pure paths. */
|
|
45
|
+
export declare const ICON_RETRY = "<svg viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M3 8a5 5 0 0 1 8.5-3.5M13 3v3h-3\"/><path d=\"M13 8a5 5 0 0 1-8.5 3.5M3 13v-3h3\"/></svg>";
|
|
46
|
+
/** Close / delete icon — X, pure paths. */
|
|
47
|
+
export declare const ICON_CLOSE = "<svg viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M4 4L12 12\"/><path d=\"M12 4L4 12\"/></svg>";
|
|
48
|
+
/** Replace / swap icon — two horizontal arrows, pure paths. */
|
|
49
|
+
export declare const ICON_REPLACE = "<svg viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M2 5H12M9 2L12 5L9 8\"/><path d=\"M14 11H4M7 8L4 11L7 14\"/></svg>";
|
|
50
|
+
/** Upload (cloud + arrow) icon, pure paths. */
|
|
51
|
+
export declare const ICON_UPLOAD = "<svg viewBox=\"0 0 1024 1024\" width=\"32\" height=\"32\" aria-hidden=\"true\"><path d=\"M768.35456 416a256 256 0 1 0-512 0 192 192 0 1 0 0 384v64a256 256 0 0 1-58.88-505.216 320.128 320.128 0 0 1 629.76 0A256.128 256.128 0 0 1 768.35456 864v-64a192 192 0 0 0 0-384z m-512 384h128v64H256.35456v-64z m384 0h128v64h-128v-64z\" fill=\"currentColor\"/><path d=\"M539.04256 589.184v333.056a32.448 32.448 0 0 1-32 32.192 32.448 32.448 0 0 1-32-32.192V589.184l-36.096 36.096a32.192 32.192 0 0 1-45.056-0.192 31.616 31.616 0 0 1-0.192-45.056l90.88-90.88a31.36 31.36 0 0 1 22.528-9.152 30.08 30.08 0 0 1 22.4 9.088l90.88 90.944a32.192 32.192 0 0 1-0.192 45.056 31.616 31.616 0 0 1-45.056 0.192l-36.096-36.096z\" fill=\"currentColor\"/></svg>";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InputRuleRegistry } from '../../core/command/InputRule';
|
|
2
|
+
import { Editor } from '../../core/Editor';
|
|
3
|
+
import { BlockId } from '../../core/types';
|
|
4
|
+
export interface InputRuleRunContext {
|
|
5
|
+
readonly editor: Editor;
|
|
6
|
+
readonly registry: InputRuleRegistry;
|
|
7
|
+
readonly blockId: BlockId;
|
|
8
|
+
/** The full text currently in the block (after the just-typed character). */
|
|
9
|
+
readonly text: string;
|
|
10
|
+
/** True if we're in the middle of IME composition — we skip rules. */
|
|
11
|
+
readonly composing?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Test all registered rules. Returns `true` if a rule matched and fired, so
|
|
15
|
+
* the caller can stop syncing a setText (it was replaced by a transaction).
|
|
16
|
+
*
|
|
17
|
+
* For rule-matching we only examine the text currently in the block's leading
|
|
18
|
+
* prefix (i.e. no newline; rules always match a single-line prefix up to the
|
|
19
|
+
* caret). Because the editor's caret may be anywhere, `textBeforeCaret` is the
|
|
20
|
+
* full block text passed in — rules are responsible for anchoring patterns with
|
|
21
|
+
* `^…$`. This matches ProseMirror / Tiptap input-rule semantics.
|
|
22
|
+
*/
|
|
23
|
+
export declare function runInputRules(ctx: InputRuleRunContext): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns true when a text change starts a slash-menu trigger: the user typed
|
|
26
|
+
* "/" at the block start, or anywhere in an otherwise-empty block.
|
|
27
|
+
*
|
|
28
|
+
* This is a very lightweight check, called by `BlockContent` so it can signal
|
|
29
|
+
* the root `BlockEditor` to open the slash menu. The menu is kept in the root
|
|
30
|
+
* so it can float above sibling blocks without being clipped by a block's
|
|
31
|
+
* `overflow: hidden` or similar.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isSlashTrigger(text: string): boolean;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Popup helpers: position a floating element relative to an anchor (an
|
|
3
|
+
* `HTMLElement` or a DOM `Rect`). Used by the slash menu, the block
|
|
4
|
+
* settings menu, and the hover toolbar.
|
|
5
|
+
*
|
|
6
|
+
* All popups now prefer placing BELOW the anchor. The available height
|
|
7
|
+
* below the anchor (within the viewport) is returned so callers can
|
|
8
|
+
* auto-scale the menu height and use up/down scroll buttons instead of
|
|
9
|
+
* a scrollbar.
|
|
10
|
+
*/
|
|
11
|
+
export interface PopupPlacement {
|
|
12
|
+
readonly top: number;
|
|
13
|
+
readonly left: number;
|
|
14
|
+
readonly above: boolean;
|
|
15
|
+
/** Available height (px) in the viewport below the anchor. */
|
|
16
|
+
readonly availableHeight: number;
|
|
17
|
+
/**
|
|
18
|
+
* When `above=true`, the popup should expand *upward* from this
|
|
19
|
+
* viewport-relative "bottom" coordinate (the baseline next to the
|
|
20
|
+
* anchor). This lets callers set the popup's CSS `bottom` property
|
|
21
|
+
* instead of `top`, so height changes grow upward rather than
|
|
22
|
+
* downward. When `above=false` this equals the same numeric value
|
|
23
|
+
* as `top` so callers can always fall back to `top`.
|
|
24
|
+
*/
|
|
25
|
+
readonly bottom: number;
|
|
26
|
+
/**
|
|
27
|
+
* Viewport-relative "top" coordinate of the anchor baseline (same
|
|
28
|
+
* semantics as `bottom`): used when `above=false` (popup expands
|
|
29
|
+
* downward from this point). Provided for symmetry.
|
|
30
|
+
*/
|
|
31
|
+
readonly topBaseline: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Position a popup below an anchor element (or rect). If the anchor is close
|
|
35
|
+
* to the container bottom **and** the viewport below is too cramped while
|
|
36
|
+
* there is more room above the anchor in the viewport, place it above
|
|
37
|
+
* instead.
|
|
38
|
+
*
|
|
39
|
+
* All returned coordinates are **viewport-relative**, suitable for use with
|
|
40
|
+
* `position: fixed` (e.g. menus that teleport to `<body>`). Callers that
|
|
41
|
+
* operate within a container-relative coordinate space should subtract the
|
|
42
|
+
* container's `getBoundingClientRect().top/left` themselves.
|
|
43
|
+
*/
|
|
44
|
+
export declare function placeBelow(root: HTMLElement, anchor: HTMLElement | DOMRect, popupSize: {
|
|
45
|
+
readonly width: number;
|
|
46
|
+
readonly height: number;
|
|
47
|
+
}, margin?: number): PopupPlacement;
|
|
48
|
+
/**
|
|
49
|
+
* Position a popup below a selection rect (for the hover toolbar).
|
|
50
|
+
* Falls back to above only if there's zero space below.
|
|
51
|
+
* Returns viewport-relative coordinates (for use with position:fixed
|
|
52
|
+
* or a full-viewport positioning container).
|
|
53
|
+
*/
|
|
54
|
+
export declare function placeBelowSelection(_root: HTMLElement, selectionRect: DOMRect, popupSize: {
|
|
55
|
+
readonly width: number;
|
|
56
|
+
readonly height: number;
|
|
57
|
+
}, margin?: number): PopupPlacement;
|
|
58
|
+
/** Kept for backward compatibility — delegates to placeBelowSelection. */
|
|
59
|
+
export declare function placeAboveSelection(root: HTMLElement, selectionRect: DOMRect, popupSize: {
|
|
60
|
+
readonly width: number;
|
|
61
|
+
readonly height: number;
|
|
62
|
+
}, margin?: number): PopupPlacement;
|
|
63
|
+
/**
|
|
64
|
+
* Position a popup ABOVE a selection rect, falling back to below only if
|
|
65
|
+
* there is not enough space above. Used by the table cell selection
|
|
66
|
+
* toolbar so it doesn't obscure the selected cells below.
|
|
67
|
+
*/
|
|
68
|
+
export declare function placePreferAbove(_root: HTMLElement, selectionRect: DOMRect, popupSize: {
|
|
69
|
+
readonly width: number;
|
|
70
|
+
readonly height: number;
|
|
71
|
+
}, margin?: number): PopupPlacement;
|
|
72
|
+
/**
|
|
73
|
+
* Compute a rect relative to the editor root.
|
|
74
|
+
*/
|
|
75
|
+
export declare function relativeRect(root: HTMLElement, el: HTMLElement): DOMRect;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export declare function useMenuDismiss(menuEl: Ref<HTMLElement | null>, isVisible: () => boolean, onClose: () => void,
|
|
3
|
+
/** Optional extra elements that should also be treated as "inside the menu"
|
|
4
|
+
* (e.g. the trigger/anchor button). This is critical for mobile when the
|
|
5
|
+
* menu is teleported to <body>: a capture-phase `touchstart` listener on
|
|
6
|
+
* window fires BEFORE the element-level `@touchstart.stop` handler on the
|
|
7
|
+
* trigger; without treating the trigger as inside, the newly-opened menu
|
|
8
|
+
* closes instantly on the very same tap. */
|
|
9
|
+
extraInside?: () => (HTMLElement | null)[] | HTMLElement | null): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InlineSeq } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Check whether a URL string is safe to use as an href.
|
|
4
|
+
*
|
|
5
|
+
* A URL is considered safe if:
|
|
6
|
+
* 1. It is non-empty.
|
|
7
|
+
* 2. It does not start with a dangerous scheme (case-insensitive).
|
|
8
|
+
* 3. If it has an explicit scheme, that scheme is in the allow-list.
|
|
9
|
+
* 4. If it has no scheme (relative URL or bare domain), it is safe — the
|
|
10
|
+
* browser will resolve it relative to the current page, and it cannot
|
|
11
|
+
* execute script.
|
|
12
|
+
*
|
|
13
|
+
* Returns the cleaned URL (trimmed) or null if the URL is unsafe/empty.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sanitizeUrl(raw: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a string looks like a URL that should be auto-linked.
|
|
18
|
+
*
|
|
19
|
+
* This is intentionally conservative — it only matches strings that start
|
|
20
|
+
* with a known scheme or look like a domain (e.g. "example.com/path").
|
|
21
|
+
*/
|
|
22
|
+
export declare function looksLikeUrl(text: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Normalize a URL by adding a default scheme if missing.
|
|
25
|
+
*
|
|
26
|
+
* - If the URL already has a scheme, return as-is.
|
|
27
|
+
* - If it looks like a domain, prepend "https://".
|
|
28
|
+
* - If it starts with "@", treat as email → prepend "mailto:".
|
|
29
|
+
* - Otherwise, return as-is (may be a relative URL).
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeUrl(raw: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Scan an InlineSeq for URL-like substrings and add link marks to them.
|
|
34
|
+
*
|
|
35
|
+
* - Only scans text runs that do NOT already have a `link` mark or `code` mark.
|
|
36
|
+
* - Preserves all existing marks on non-URL portions.
|
|
37
|
+
* - Returns the same sequence if no URLs were found (no allocation).
|
|
38
|
+
*/
|
|
39
|
+
export declare function autoLinkInlineSeq(seq: InlineSeq): InlineSeq;
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xiaodao-editor",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Notion-style block editor for Vue 3",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"vue",
|
|
9
|
+
"vue3",
|
|
10
|
+
"editor",
|
|
11
|
+
"block-editor",
|
|
12
|
+
"notion",
|
|
13
|
+
"rich-text",
|
|
14
|
+
"wysiwyg"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/block-editor.umd.cjs",
|
|
20
|
+
"module": "./dist/block-editor.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/block-editor.js",
|
|
26
|
+
"require": "./dist/block-editor.umd.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./style.css": "./dist/style.css"
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"*.css"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"dev": "vite",
|
|
35
|
+
"build": "vue-tsc --noEmit && vite build",
|
|
36
|
+
"typecheck": "vue-tsc --noEmit",
|
|
37
|
+
"lint": "eslint . --ext .ts,.vue,.js --fix",
|
|
38
|
+
"lint:check": "eslint . --ext .ts,.vue,.js",
|
|
39
|
+
"format": "prettier --write \"src/**/*.{ts,vue,css}\" \"playground/**/*.{ts,vue}\"",
|
|
40
|
+
"prepublishOnly": "pnpm build"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"vue": "^3.4.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"highlight.js": "^11.11.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^20.14.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
51
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
52
|
+
"@vitejs/plugin-vue": "^5.1.2",
|
|
53
|
+
"eslint": "^8.57.0",
|
|
54
|
+
"eslint-config-prettier": "^10.1.8",
|
|
55
|
+
"eslint-plugin-vue": "^9.27.0",
|
|
56
|
+
"prettier": "^3.3.3",
|
|
57
|
+
"typescript": "^5.5.4",
|
|
58
|
+
"vite": "^5.4.0",
|
|
59
|
+
"vite-plugin-dts": "^4.0.3",
|
|
60
|
+
"vue": "^3.4.38",
|
|
61
|
+
"vue-tsc": "^2.0.29"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public",
|
|
65
|
+
"registry": "https://registry.npmjs.org/"
|
|
66
|
+
},
|
|
67
|
+
"pnpm": {
|
|
68
|
+
"onlyBuiltDependencies": [
|
|
69
|
+
"esbuild"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"packageManager": "pnpm@10.29.2+sha512.bef43fa759d91fd2da4b319a5a0d13ef7a45bb985a3d7342058470f9d2051a3ba8674e629672654686ef9443ad13a82da2beb9eeb3e0221c87b8154fff9d74b8"
|
|
73
|
+
}
|