@dou-ui/editor 0.0.0-stage → 0.1.0-alpha.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 +10 -2
- package/dist/catalog.js +18 -0
- package/dist/catalog.js.map +1 -0
- package/dist/code/code-editor-block.js +6 -0
- package/dist/code/code-editor-block.js.map +1 -0
- package/dist/code/code-editor-block.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/code/code-editor-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/code/index.js +69 -0
- package/dist/code/index.js.map +1 -0
- package/dist/code/languages.js +51 -0
- package/dist/code/languages.js.map +1 -0
- package/dist/code/view.js +255 -0
- package/dist/code/view.js.map +1 -0
- package/dist/collaboration/binding.js +381 -0
- package/dist/collaboration/binding.js.map +1 -0
- package/dist/collaboration/cursors.js +150 -0
- package/dist/collaboration/cursors.js.map +1 -0
- package/dist/collaboration/index.js +108 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/collaboration/order.js +88 -0
- package/dist/collaboration/order.js.map +1 -0
- package/dist/collaboration/table.js +234 -0
- package/dist/collaboration/table.js.map +1 -0
- package/dist/collaboration/text.js +91 -0
- package/dist/collaboration/text.js.map +1 -0
- package/dist/components/block-handle.js +6 -0
- package/dist/components/block-handle.js.map +1 -0
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +474 -0
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/bubble-toolbar.js +6 -0
- package/dist/components/bubble-toolbar.js.map +1 -0
- package/dist/components/bubble-toolbar.vue_vue_type_script_setup_true_lang.js +381 -0
- package/dist/components/bubble-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/comment-button.js +6 -0
- package/dist/components/comment-button.js.map +1 -0
- package/dist/components/comment-button.vue_vue_type_script_setup_true_lang.js +83 -0
- package/dist/components/comment-button.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/comment-card.js +6 -0
- package/dist/components/comment-card.js.map +1 -0
- package/dist/components/comment-card.vue_vue_type_script_setup_true_lang.js +104 -0
- package/dist/components/comment-card.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/menu-escape.js +25 -0
- package/dist/components/menu-escape.js.map +1 -0
- package/dist/components/search-bar.js +6 -0
- package/dist/components/search-bar.js.map +1 -0
- package/dist/components/search-bar.vue_vue_type_script_setup_true_lang.js +192 -0
- package/dist/components/search-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/slash-menu.js +6 -0
- package/dist/components/slash-menu.js.map +1 -0
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +164 -0
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/core/align.js +94 -0
- package/dist/core/align.js.map +1 -0
- package/dist/core/block-selection.js +155 -0
- package/dist/core/block-selection.js.map +1 -0
- package/dist/core/blocks.js +132 -0
- package/dist/core/blocks.js.map +1 -0
- package/dist/core/changes.js +85 -0
- package/dist/core/changes.js.map +1 -0
- package/dist/core/colors.js +16 -0
- package/dist/core/colors.js.map +1 -0
- package/dist/core/commands.js +379 -0
- package/dist/core/commands.js.map +1 -0
- package/dist/core/comments.js +186 -0
- package/dist/core/comments.js.map +1 -0
- package/dist/core/compare.js +106 -0
- package/dist/core/compare.js.map +1 -0
- package/dist/core/convert.js +28 -0
- package/dist/core/convert.js.map +1 -0
- package/dist/core/diff.js +141 -0
- package/dist/core/diff.js.map +1 -0
- package/dist/core/editor.js +138 -0
- package/dist/core/editor.js.map +1 -0
- package/dist/core/extension.js +99 -0
- package/dist/core/extension.js.map +1 -0
- package/dist/core/file-drop.js +56 -0
- package/dist/core/file-drop.js.map +1 -0
- package/dist/core/highlight.js +120 -0
- package/dist/core/highlight.js.map +1 -0
- package/dist/core/input-rules.js +61 -0
- package/dist/core/input-rules.js.map +1 -0
- package/dist/core/keymap.js +38 -0
- package/dist/core/keymap.js.map +1 -0
- package/dist/core/model.js +196 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/output.js +263 -0
- package/dist/core/output.js.map +1 -0
- package/dist/core/plugins.js +102 -0
- package/dist/core/plugins.js.map +1 -0
- package/dist/core/prepare.js +102 -0
- package/dist/core/prepare.js.map +1 -0
- package/dist/core/schema.js +158 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/search.js +197 -0
- package/dist/core/search.js.map +1 -0
- package/dist/core/selection.js +16 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/slash.js +83 -0
- package/dist/core/slash.js.map +1 -0
- package/dist/core/transaction.js +311 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/define-block.js +177 -0
- package/dist/define-block.js.map +1 -0
- package/dist/document.js +157 -0
- package/dist/document.js.map +1 -0
- package/dist/dom.js +48 -0
- package/dist/dom.js.map +1 -0
- package/dist/editor.js +33 -0
- package/dist/editor.js.map +1 -0
- package/dist/editor.vue_vue_type_script_setup_true_lang.js +564 -0
- package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/editor2.js +6 -0
- package/dist/editor2.js.map +1 -0
- package/dist/extensions/align/align-menu.js +6 -0
- package/dist/extensions/align/align-menu.js.map +1 -0
- package/dist/extensions/align/align-menu.vue_vue_type_script_setup_true_lang.js +82 -0
- package/dist/extensions/align/align-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/align/align-sub.js +6 -0
- package/dist/extensions/align/align-sub.js.map +1 -0
- package/dist/extensions/align/align-sub.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/extensions/align/align-sub.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/align/commands.js +40 -0
- package/dist/extensions/align/commands.js.map +1 -0
- package/dist/extensions/align/index.js +27 -0
- package/dist/extensions/align/index.js.map +1 -0
- package/dist/extensions/attachment/attachment-block.js +6 -0
- package/dist/extensions/attachment/attachment-block.js.map +1 -0
- package/dist/extensions/attachment/attachment-block.vue_vue_type_script_setup_true_lang.js +119 -0
- package/dist/extensions/attachment/attachment-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/attachment/files.js +66 -0
- package/dist/extensions/attachment/files.js.map +1 -0
- package/dist/extensions/attachment/index.js +132 -0
- package/dist/extensions/attachment/index.js.map +1 -0
- package/dist/extensions/blocks.js +170 -0
- package/dist/extensions/blocks.js.map +1 -0
- package/dist/extensions/callout/callout-block.js +6 -0
- package/dist/extensions/callout/callout-block.js.map +1 -0
- package/dist/extensions/callout/callout-block.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/extensions/callout/callout-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/callout/html.js +61 -0
- package/dist/extensions/callout/html.js.map +1 -0
- package/dist/extensions/callout/index.js +52 -0
- package/dist/extensions/callout/index.js.map +1 -0
- package/dist/extensions/callout/tones.js +12 -0
- package/dist/extensions/callout/tones.js.map +1 -0
- package/dist/extensions/code-block/code-block-view.js +6 -0
- package/dist/extensions/code-block/code-block-view.js.map +1 -0
- package/dist/extensions/code-block/code-block-view.vue_vue_type_script_setup_true_lang.js +87 -0
- package/dist/extensions/code-block/code-block-view.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/code-block/index.js +98 -0
- package/dist/extensions/code-block/index.js.map +1 -0
- package/dist/extensions/code-block/languages.js +116 -0
- package/dist/extensions/code-block/languages.js.map +1 -0
- package/dist/extensions/colors/color-menu.js +6 -0
- package/dist/extensions/colors/color-menu.js.map +1 -0
- package/dist/extensions/colors/color-menu.vue_vue_type_script_setup_true_lang.js +113 -0
- package/dist/extensions/colors/color-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/colors/index.js +49 -0
- package/dist/extensions/colors/index.js.map +1 -0
- package/dist/extensions/colors/palette.js +26 -0
- package/dist/extensions/colors/palette.js.map +1 -0
- package/dist/extensions/editor-kit.js +35 -0
- package/dist/extensions/editor-kit.js.map +1 -0
- package/dist/extensions/embed/embed-block.js +6 -0
- package/dist/extensions/embed/embed-block.js.map +1 -0
- package/dist/extensions/embed/embed-block.vue_vue_type_script_setup_true_lang.js +210 -0
- package/dist/extensions/embed/embed-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/embed/index.js +118 -0
- package/dist/extensions/embed/index.js.map +1 -0
- package/dist/extensions/embed/targets.js +79 -0
- package/dist/extensions/embed/targets.js.map +1 -0
- package/dist/extensions/formatting.js +153 -0
- package/dist/extensions/formatting.js.map +1 -0
- package/dist/extensions/image/image-block.js +6 -0
- package/dist/extensions/image/image-block.js.map +1 -0
- package/dist/extensions/image/image-block.vue_vue_type_script_setup_true_lang.js +206 -0
- package/dist/extensions/image/image-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/image/index.js +125 -0
- package/dist/extensions/image/index.js.map +1 -0
- package/dist/extensions/image/uploads.js +96 -0
- package/dist/extensions/image/uploads.js.map +1 -0
- package/dist/extensions/list-html.js +58 -0
- package/dist/extensions/list-html.js.map +1 -0
- package/dist/extensions/lists.js +182 -0
- package/dist/extensions/lists.js.map +1 -0
- package/dist/extensions/mention/index.js +56 -0
- package/dist/extensions/mention/index.js.map +1 -0
- package/dist/extensions/mention/mention-menu.js +6 -0
- package/dist/extensions/mention/mention-menu.js.map +1 -0
- package/dist/extensions/mention/mention-menu.vue_vue_type_script_setup_true_lang.js +132 -0
- package/dist/extensions/mention/mention-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/mention/state.js +113 -0
- package/dist/extensions/mention/state.js.map +1 -0
- package/dist/extensions/table/commands.js +356 -0
- package/dist/extensions/table/commands.js.map +1 -0
- package/dist/extensions/table/html.js +134 -0
- package/dist/extensions/table/html.js.map +1 -0
- package/dist/extensions/table/index.js +56 -0
- package/dist/extensions/table/index.js.map +1 -0
- package/dist/extensions/table/plugin.js +81 -0
- package/dist/extensions/table/plugin.js.map +1 -0
- package/dist/extensions/table/schema.js +258 -0
- package/dist/extensions/table/schema.js.map +1 -0
- package/dist/extensions/table/table-controls.js +6 -0
- package/dist/extensions/table/table-controls.js.map +1 -0
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +698 -0
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/table/view.js +19 -0
- package/dist/extensions/table/view.js.map +1 -0
- package/dist/extensions/toggle/index.js +87 -0
- package/dist/extensions/toggle/index.js.map +1 -0
- package/dist/extensions/toggle/state.js +120 -0
- package/dist/extensions/toggle/state.js.map +1 -0
- package/dist/extensions/toggle/toggle-block.js +6 -0
- package/dist/extensions/toggle/toggle-block.js.map +1 -0
- package/dist/extensions/toggle/toggle-block.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/extensions/toggle/toggle-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/locale.js +522 -0
- package/dist/locale.js.map +1 -0
- package/dist/markdown/index.js +24 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +8 -0
- package/dist/types/catalog.d.ts +8 -0
- package/dist/types/code/code-editor-block.vue.d.ts +17 -0
- package/dist/types/code/index.d.ts +18 -0
- package/dist/types/code/languages.d.ts +7 -0
- package/dist/types/code/types.d.ts +37 -0
- package/dist/types/code/view.d.ts +12 -0
- package/dist/types/collaboration/binding.d.ts +32 -0
- package/dist/types/collaboration/cursors.d.ts +26 -0
- package/dist/types/collaboration/index.d.ts +47 -0
- package/dist/types/collaboration/order.d.ts +20 -0
- package/dist/types/collaboration/table.d.ts +25 -0
- package/dist/types/collaboration/text.d.ts +9 -0
- package/dist/types/components/block-handle.vue.d.ts +3 -0
- package/dist/types/components/bubble-toolbar.vue.d.ts +7 -0
- package/dist/types/components/comment-button.vue.d.ts +3 -0
- package/dist/types/components/comment-card.vue.d.ts +3 -0
- package/dist/types/components/menu-escape.d.ts +7 -0
- package/dist/types/components/search-bar.vue.d.ts +22 -0
- package/dist/types/components/slash-menu.vue.d.ts +11 -0
- package/dist/types/core/align.d.ts +16 -0
- package/dist/types/core/block-selection.d.ts +22 -0
- package/dist/types/core/blocks.d.ts +52 -0
- package/dist/types/core/changes.d.ts +14 -0
- package/dist/types/core/colors.d.ts +4 -0
- package/dist/types/core/commands.d.ts +61 -0
- package/dist/types/core/comments.d.ts +44 -0
- package/dist/types/core/compare.d.ts +10 -0
- package/dist/types/core/convert.d.ts +12 -0
- package/dist/types/core/diff.d.ts +49 -0
- package/dist/types/core/editor.d.ts +64 -0
- package/dist/types/core/extension.d.ts +167 -0
- package/dist/types/core/file-drop.d.ts +19 -0
- package/dist/types/core/highlight.d.ts +32 -0
- package/dist/types/core/input-rules.d.ts +21 -0
- package/dist/types/core/keymap.d.ts +8 -0
- package/dist/types/core/model.d.ts +158 -0
- package/dist/types/core/output.d.ts +64 -0
- package/dist/types/core/plugins.d.ts +24 -0
- package/dist/types/core/prepare.d.ts +23 -0
- package/dist/types/core/schema.d.ts +38 -0
- package/dist/types/core/search.d.ts +83 -0
- package/dist/types/core/selection.d.ts +8 -0
- package/dist/types/core/slash.d.ts +21 -0
- package/dist/types/core/transaction.d.ts +97 -0
- package/dist/types/define-block.d.ts +66 -0
- package/dist/types/document.d.ts +46 -0
- package/dist/types/dom.d.ts +17 -0
- package/dist/types/editor.d.ts +252 -0
- package/dist/types/editor.vue.d.ts +210 -0
- package/dist/types/extensions/align/align-menu.vue.d.ts +3 -0
- package/dist/types/extensions/align/align-sub.vue.d.ts +7 -0
- package/dist/types/extensions/align/commands.d.ts +13 -0
- package/dist/types/extensions/align/index.d.ts +7 -0
- package/dist/types/extensions/attachment/attachment-block.vue.d.ts +17 -0
- package/dist/types/extensions/attachment/files.d.ts +6 -0
- package/dist/types/extensions/attachment/index.d.ts +20 -0
- package/dist/types/extensions/blocks.d.ts +8 -0
- package/dist/types/extensions/callout/callout-block.vue.d.ts +14 -0
- package/dist/types/extensions/callout/html.d.ts +4 -0
- package/dist/types/extensions/callout/index.d.ts +3 -0
- package/dist/types/extensions/callout/tones.d.ts +8 -0
- package/dist/types/extensions/code-block/code-block-view.vue.d.ts +16 -0
- package/dist/types/extensions/code-block/index.d.ts +19 -0
- package/dist/types/extensions/code-block/languages.d.ts +9 -0
- package/dist/types/extensions/colors/color-menu.vue.d.ts +3 -0
- package/dist/types/extensions/colors/index.d.ts +7 -0
- package/dist/types/extensions/colors/palette.d.ts +7 -0
- package/dist/types/extensions/editor-kit.d.ts +37 -0
- package/dist/types/extensions/embed/embed-block.vue.d.ts +16 -0
- package/dist/types/extensions/embed/index.d.ts +18 -0
- package/dist/types/extensions/embed/targets.d.ts +32 -0
- package/dist/types/extensions/formatting.d.ts +8 -0
- package/dist/types/extensions/image/image-block.vue.d.ts +16 -0
- package/dist/types/extensions/image/index.d.ts +16 -0
- package/dist/types/extensions/image/uploads.d.ts +35 -0
- package/dist/types/extensions/list-html.d.ts +11 -0
- package/dist/types/extensions/lists.d.ts +6 -0
- package/dist/types/extensions/mention/index.d.ts +11 -0
- package/dist/types/extensions/mention/mention-menu.vue.d.ts +7 -0
- package/dist/types/extensions/mention/state.d.ts +28 -0
- package/dist/types/extensions/table/commands.d.ts +69 -0
- package/dist/types/extensions/table/html.d.ts +4 -0
- package/dist/types/extensions/table/index.d.ts +8 -0
- package/dist/types/extensions/table/plugin.d.ts +4 -0
- package/dist/types/extensions/table/schema.d.ts +23 -0
- package/dist/types/extensions/table/table-controls.vue.d.ts +3 -0
- package/dist/types/extensions/table/view.d.ts +13 -0
- package/dist/types/extensions/toggle/index.d.ts +7 -0
- package/dist/types/extensions/toggle/state.d.ts +17 -0
- package/dist/types/extensions/toggle/toggle-block.vue.d.ts +14 -0
- package/dist/types/index.d.ts +266 -0
- package/dist/types/locale.d.ts +195 -0
- package/dist/types/markdown/index.d.ts +14 -0
- package/dist/types/use-comments.d.ts +17 -0
- package/dist/use-comments.js +141 -0
- package/dist/use-comments.js.map +1 -0
- package/package.json +98 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ResolvedEditorExtensions } from './extension';
|
|
2
|
+
import type { Block, InlineContent, PartialBlock } from './model';
|
|
3
|
+
/** What a block's writer gets besides the block. */
|
|
4
|
+
export interface BlockOutputContext {
|
|
5
|
+
/** The block's text, already written in the output format. */
|
|
6
|
+
content: string;
|
|
7
|
+
/** The block's text without formatting (e.g. for a code block). */
|
|
8
|
+
text: string;
|
|
9
|
+
/** The child blocks, already written. */
|
|
10
|
+
children: string;
|
|
11
|
+
/** The block's position, from 1, among the siblings of the same type right before it. */
|
|
12
|
+
index: number;
|
|
13
|
+
/** Write other inline content (e.g. a table cell's) in the same format. */
|
|
14
|
+
inline: (content: InlineContent[]) => string;
|
|
15
|
+
}
|
|
16
|
+
export interface MarkdownBlockContext extends BlockOutputContext {
|
|
17
|
+
/** The block's text as HTML, for Markdown that holds HTML (e.g. `<summary>`). */
|
|
18
|
+
html: string;
|
|
19
|
+
/** Write other inline content as HTML. */
|
|
20
|
+
inlineHTML: (content: InlineContent[]) => string;
|
|
21
|
+
}
|
|
22
|
+
/** How a block type is written as HTML and Markdown. */
|
|
23
|
+
export interface BlockOutput {
|
|
24
|
+
html?: (block: Block, context: BlockOutputContext) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Consecutive blocks with the same `group` sit in one element, written
|
|
27
|
+
* as its opening tag (e.g. `ul`, `ol`); in Markdown they are kept
|
|
28
|
+
* together without blank lines.
|
|
29
|
+
*/
|
|
30
|
+
group?: string;
|
|
31
|
+
markdown?: (block: Block, context: MarkdownBlockContext) => string;
|
|
32
|
+
}
|
|
33
|
+
/** How an inline node (e.g. a mention) is written. */
|
|
34
|
+
export interface InlineOutput {
|
|
35
|
+
html?: (props: Record<string, unknown>) => string;
|
|
36
|
+
markdown?: (props: Record<string, unknown>) => string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* How a mark is written: the text between an opening and a closing string.
|
|
40
|
+
* A mark with a value (a color) gives a function of the value.
|
|
41
|
+
*/
|
|
42
|
+
export type MarkTags = [open: string, close: string];
|
|
43
|
+
export interface MarkOutput {
|
|
44
|
+
html?: MarkTags | ((value: string) => MarkTags);
|
|
45
|
+
markdown?: MarkTags | ((value: string) => MarkTags);
|
|
46
|
+
}
|
|
47
|
+
/** What an extension contributes to `blocksToHTML` and `blocksToMarkdown`. */
|
|
48
|
+
export interface EditorExtensionOutput {
|
|
49
|
+
blocks?: Record<string, BlockOutput>;
|
|
50
|
+
inlines?: Record<string, InlineOutput>;
|
|
51
|
+
marks?: Record<string, MarkOutput>;
|
|
52
|
+
}
|
|
53
|
+
export declare const escapeHTML: (text: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Write blocks as HTML, e.g. to show a document outside the editor or to
|
|
56
|
+
* send it by email. Each extension decides how its blocks look; the
|
|
57
|
+
* result has no editor classes.
|
|
58
|
+
*/
|
|
59
|
+
export declare function writeHTML(blocks: PartialBlock[], kit: ResolvedEditorExtensions): string;
|
|
60
|
+
export declare const escapeMarkdown: (text: string) => string;
|
|
61
|
+
/** Put `prefix` before every line, and `rest` (default: as many spaces) before the ones after the first. */
|
|
62
|
+
export declare function indentLines(text: string, prefix: string, rest?: string): string;
|
|
63
|
+
/** Write blocks as Markdown (CommonMark with GitHub's extensions). */
|
|
64
|
+
export declare function writeMarkdown(blocks: PartialBlock[], kit: ResolvedEditorExtensions): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Plugin, type Transaction } from 'prosemirror-state';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a transaction came from another collaborator. Collaborative
|
|
4
|
+
* bindings mark theirs; the Yjs binding uses the `y-sync$` key.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isRemote(tr: Transaction): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Every block gets a unique id. Splitting a block copies its attributes,
|
|
9
|
+
* so the copy gets a fresh id here; the first occurrence keeps the old one.
|
|
10
|
+
* Changes from collaborators are left alone, so two editors never fight
|
|
11
|
+
* over an id.
|
|
12
|
+
*/
|
|
13
|
+
export declare function idPlugin(): Plugin;
|
|
14
|
+
export declare function numberingPlugin(): Plugin;
|
|
15
|
+
export interface PlaceholderOptions {
|
|
16
|
+
/** The hint in the empty block the cursor is in. */
|
|
17
|
+
text: () => string;
|
|
18
|
+
/** The hint in an empty heading. */
|
|
19
|
+
heading: () => string;
|
|
20
|
+
/** The hint when the whole document is one empty paragraph. */
|
|
21
|
+
empty: () => string;
|
|
22
|
+
}
|
|
23
|
+
/** A hint inside the empty block under the cursor, and in an empty document. */
|
|
24
|
+
export declare function placeholderPlugin(options: PlaceholderOptions): Plugin;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import type { ResolvedEditorExtensions } from './extension';
|
|
3
|
+
import { type Block } from './model';
|
|
4
|
+
/**
|
|
5
|
+
* The editor's own markup for a block: a content element of `type` holding
|
|
6
|
+
* `content`, followed by a group holding `children`. Extensions use it in
|
|
7
|
+
* `prepareHTML` to turn containers such as `<details>` into blocks.
|
|
8
|
+
*/
|
|
9
|
+
export declare function blockElement(doc: Document, type: string, content: Node[], children?: Node[], data?: Record<string, string>): HTMLElement;
|
|
10
|
+
/**
|
|
11
|
+
* Split a container's children into its own text (the first paragraph, or
|
|
12
|
+
* the inline nodes before the first block element) and the blocks after it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function splitContainer(element: Element): {
|
|
15
|
+
content: Node[];
|
|
16
|
+
children: Node[];
|
|
17
|
+
};
|
|
18
|
+
/** Run every extension's `prepareHTML` over the markup. */
|
|
19
|
+
export declare function prepareElement(root: HTMLElement, kit: ResolvedEditorExtensions): void;
|
|
20
|
+
/** Read HTML as blocks, with the block types, inline nodes and marks of `kit`. */
|
|
21
|
+
export declare function parseHTML(html: string, kit: ResolvedEditorExtensions): Block[];
|
|
22
|
+
/** Pasted HTML goes through the extensions' `prepareHTML` too. */
|
|
23
|
+
export declare function preparePastePlugin(kit: ResolvedEditorExtensions): Plugin;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Schema, type DOMOutputSpec, type MarkSpec, type NodeSpec } from 'prosemirror-model';
|
|
2
|
+
/**
|
|
3
|
+
* The document is a list of blocks. Each block is a `block` node holding
|
|
4
|
+
* one piece of content (a paragraph, a heading, a list item…) and,
|
|
5
|
+
* optionally, a `blockGroup` of child blocks:
|
|
6
|
+
*
|
|
7
|
+
* doc
|
|
8
|
+
* └─ block#id
|
|
9
|
+
* ├─ paragraph "Hello"
|
|
10
|
+
* └─ blockGroup
|
|
11
|
+
* └─ block#id
|
|
12
|
+
* └─ checkItem "Nested"
|
|
13
|
+
*
|
|
14
|
+
* The frame (doc, block, group, paragraph, text, line break) is fixed;
|
|
15
|
+
* every other content type and mark comes from an extension. Every piece
|
|
16
|
+
* of state lives in node attributes (never in a node view), so a
|
|
17
|
+
* collaborative binding can sync it like any other change.
|
|
18
|
+
*/
|
|
19
|
+
/** The DOM of a content node: `div.dou-editor__content--<type>[data-content-type]`. */
|
|
20
|
+
export declare const contentDOM: (type: string, extra?: Record<string, string>) => DOMOutputSpec;
|
|
21
|
+
/** A content type holding formatted text, parsed back from its own DOM. */
|
|
22
|
+
export declare const textBlock: (type: string, spec?: Partial<NodeSpec>) => NodeSpec;
|
|
23
|
+
export interface SchemaParts {
|
|
24
|
+
blocks: Record<string, NodeSpec>;
|
|
25
|
+
/** Nodes inside blocks, e.g. table rows and cells. */
|
|
26
|
+
nodes?: Record<string, NodeSpec>;
|
|
27
|
+
inlines: Record<string, NodeSpec>;
|
|
28
|
+
marks: Record<string, MarkSpec>;
|
|
29
|
+
}
|
|
30
|
+
/** The schema for a set of extensions' blocks, inline nodes and marks. */
|
|
31
|
+
export declare function createSchema({ blocks, nodes: inner, inlines, marks }: SchemaParts): Schema;
|
|
32
|
+
/** Links may only point to web pages, mail, phone numbers or relative paths. */
|
|
33
|
+
export declare function isSafeHref(href: string): boolean;
|
|
34
|
+
/** The content types that come with `editorKit`; extensions add more. */
|
|
35
|
+
export type BuiltinContentType = 'paragraph' | 'heading' | 'bulletItem' | 'numberedItem' | 'checkItem' | 'quote' | 'codeBlock' | 'divider' | 'toggle' | 'callout' | 'table';
|
|
36
|
+
export type ContentType = BuiltinContentType | (string & {});
|
|
37
|
+
export type BuiltinMarkType = 'bold' | 'italic' | 'underline' | 'strike' | 'code';
|
|
38
|
+
export type MarkType = BuiltinMarkType | (string & {});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { Plugin, PluginKey, type EditorState, type Transaction } from 'prosemirror-state';
|
|
3
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
4
|
+
/** What to look for in the editor's text. */
|
|
5
|
+
export interface EditorSearchQuery {
|
|
6
|
+
/** The text, or a regular expression with `regexp`. */
|
|
7
|
+
search: string;
|
|
8
|
+
/** What replacing puts in; with `regexp`, `$1` and `$<name>` refer to groups. */
|
|
9
|
+
replace?: string;
|
|
10
|
+
/** Tells upper and lower case apart. */
|
|
11
|
+
caseSensitive?: boolean;
|
|
12
|
+
/** Only matches that are whole words. */
|
|
13
|
+
wholeWord?: boolean;
|
|
14
|
+
/** `search` is a regular expression (JavaScript syntax). */
|
|
15
|
+
regexp?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** A match, as document positions. */
|
|
18
|
+
export interface EditorMatch {
|
|
19
|
+
from: number;
|
|
20
|
+
to: number;
|
|
21
|
+
}
|
|
22
|
+
export interface EditorSearchState {
|
|
23
|
+
query: EditorSearchQuery;
|
|
24
|
+
/** Whether matches are shown; a query is kept while the panel is closed. */
|
|
25
|
+
active: boolean;
|
|
26
|
+
matches: EditorMatch[];
|
|
27
|
+
/** More matches exist than were counted. */
|
|
28
|
+
capped: boolean;
|
|
29
|
+
/** Why the regular expression can't be read, when it can't. */
|
|
30
|
+
error?: string;
|
|
31
|
+
/** The match the selection is on. */
|
|
32
|
+
current?: EditorMatch;
|
|
33
|
+
decorations: DecorationSet;
|
|
34
|
+
}
|
|
35
|
+
export declare const searchKey: PluginKey<EditorSearchState>;
|
|
36
|
+
/** The query as one global regular expression, or the reason it can't be one. */
|
|
37
|
+
export declare function queryRegExp(query: EditorSearchQuery): RegExp | string;
|
|
38
|
+
/**
|
|
39
|
+
* Every match of the query in the document's text, in order, at most
|
|
40
|
+
* `limit` of them. A match stays inside one block; blocks for which
|
|
41
|
+
* `skip` says yes, such as ones that draw their own text, are left out.
|
|
42
|
+
*/
|
|
43
|
+
export declare function searchDoc(doc: PMNode, query: EditorSearchQuery, options?: {
|
|
44
|
+
limit?: number;
|
|
45
|
+
skip?: (node: PMNode) => boolean;
|
|
46
|
+
}): {
|
|
47
|
+
matches: EditorMatch[];
|
|
48
|
+
capped: boolean;
|
|
49
|
+
error?: string;
|
|
50
|
+
};
|
|
51
|
+
/** The text that replaces one match: `query.replace`, with groups filled in for a regular expression. */
|
|
52
|
+
export declare function replacementFor(doc: PMNode, match: EditorMatch, query: EditorSearchQuery): string;
|
|
53
|
+
/** The index of the match the selection is on, or `-1`. */
|
|
54
|
+
export declare function currentMatch(state: EditorState): number;
|
|
55
|
+
/** The index of the first match from `pos` on, wrapping round to the first. */
|
|
56
|
+
export declare function matchAfter(matches: readonly EditorMatch[], pos: number): number;
|
|
57
|
+
type SearchMeta = {
|
|
58
|
+
query?: EditorSearchQuery;
|
|
59
|
+
active?: boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Keeps the matches of the query in step with the document and marks
|
|
63
|
+
* them; the match the selection is on stands out.
|
|
64
|
+
*/
|
|
65
|
+
export declare function searchPlugin(options?: {
|
|
66
|
+
skip?: (node: PMNode) => boolean;
|
|
67
|
+
}): Plugin;
|
|
68
|
+
/** Sets the query, or shows or hides the matches, in a transaction. */
|
|
69
|
+
export declare function setSearch(tr: Transaction, meta: SearchMeta): Transaction;
|
|
70
|
+
/**
|
|
71
|
+
* Selects the first match from the cursor on, as a preview while the
|
|
72
|
+
* search is typed; `null` when the selection is on a match already or
|
|
73
|
+
* there is none.
|
|
74
|
+
*/
|
|
75
|
+
export declare function previewMatch(state: EditorState): Transaction | null;
|
|
76
|
+
/** Selects a match and scrolls it into view. */
|
|
77
|
+
export declare function selectMatch(state: EditorState, match: EditorMatch): Transaction;
|
|
78
|
+
/**
|
|
79
|
+
* Replaces the matches given, last first so the positions stay right, in
|
|
80
|
+
* one transaction: one step to undo.
|
|
81
|
+
*/
|
|
82
|
+
export declare function replaceMatches(state: EditorState, matches: readonly EditorMatch[], query: EditorSearchQuery): Transaction;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EditorState } from 'prosemirror-state';
|
|
2
|
+
/** Where the selection is, by block. */
|
|
3
|
+
export interface BlockSelectionInfo {
|
|
4
|
+
block: string | null;
|
|
5
|
+
blocks: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function selectionOf(state: EditorState): BlockSelectionInfo;
|
|
8
|
+
export declare function sameSelection(a: BlockSelectionInfo, b: BlockSelectionInfo): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Plugin, PluginKey, type EditorState } from 'prosemirror-state';
|
|
2
|
+
import type { EditorView } from 'prosemirror-view';
|
|
3
|
+
/**
|
|
4
|
+
* The slash menu's state: open from the `/` at `from` to the cursor,
|
|
5
|
+
* with the text typed after it as the query. A Chinese keyboard types
|
|
6
|
+
* `、` for the same key, so that opens it too.
|
|
7
|
+
*/
|
|
8
|
+
export interface SlashState {
|
|
9
|
+
from: number;
|
|
10
|
+
query: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const slashKey: PluginKey<SlashState | null>;
|
|
13
|
+
export interface SlashOptions {
|
|
14
|
+
/** The menu reads the state; called whenever it changes. */
|
|
15
|
+
onChange: (state: SlashState | null, view: EditorView) => void;
|
|
16
|
+
/** Keys go to the open menu first: arrows, `Enter`, `Tab`. Return whether it took the key. */
|
|
17
|
+
onKey: (event: KeyboardEvent) => boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function getSlash(state: EditorState): SlashState | null;
|
|
20
|
+
export declare function closeSlash(view: EditorView): void;
|
|
21
|
+
export declare function slashPlugin(options: SlashOptions): Plugin<SlashState | null>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Selection, type EditorState, type Transaction } from 'prosemirror-state';
|
|
2
|
+
import { type BlockInfo } from './blocks';
|
|
3
|
+
import { type Block, type BlockProps, type InlineContent, type PartialBlock, type PartialTableRow } from './model';
|
|
4
|
+
import type { ContentType } from './schema';
|
|
5
|
+
import type { EditorView } from 'prosemirror-view';
|
|
6
|
+
/**
|
|
7
|
+
* Where blocks go: right before or after a block, or among a block's
|
|
8
|
+
* children (`parent: null` is the top level). `index` counts from 0 and
|
|
9
|
+
* defaults to the end.
|
|
10
|
+
*/
|
|
11
|
+
export type BlockPlacement = {
|
|
12
|
+
before: string;
|
|
13
|
+
} | {
|
|
14
|
+
after: string;
|
|
15
|
+
} | {
|
|
16
|
+
parent: string | null;
|
|
17
|
+
index?: number;
|
|
18
|
+
};
|
|
19
|
+
/** The parts of a block to change. `props` are merged into the current ones. */
|
|
20
|
+
export interface BlockPatch {
|
|
21
|
+
type?: ContentType;
|
|
22
|
+
props?: BlockProps;
|
|
23
|
+
/** Inline content, or plain text. */
|
|
24
|
+
content?: InlineContent[] | string;
|
|
25
|
+
rows?: PartialTableRow[];
|
|
26
|
+
/** Replaces all children; `[]` removes them. */
|
|
27
|
+
children?: PartialBlock[];
|
|
28
|
+
}
|
|
29
|
+
export interface EditorTransactionMeta {
|
|
30
|
+
/** `false` keeps the change out of undo, e.g. a fix made by the program. */
|
|
31
|
+
history?: boolean;
|
|
32
|
+
/** Who made the change; passed on to the `transaction` event. */
|
|
33
|
+
origin?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Where a selection is put inside a block: at the start of its text or at the end. */
|
|
36
|
+
export type BlockEdge = 'start' | 'end';
|
|
37
|
+
/**
|
|
38
|
+
* Set on a transaction that is an undo step of its own, for history
|
|
39
|
+
* providers other than the built-in one (collaboration reads it).
|
|
40
|
+
*/
|
|
41
|
+
export declare const ownStepKey = "douOwnStep";
|
|
42
|
+
/**
|
|
43
|
+
* Changes made by blocks and ids, applied together as one undo step. Ids
|
|
44
|
+
* are looked up in the document as it is after the earlier calls.
|
|
45
|
+
*/
|
|
46
|
+
export declare class EditorTransaction {
|
|
47
|
+
/** The state the changes start from. */
|
|
48
|
+
readonly before: EditorState;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the selection was placed by the user or the program. An editor
|
|
51
|
+
* that never had focus has its selection at the start, which is no cursor.
|
|
52
|
+
*/
|
|
53
|
+
private readonly hasCursor;
|
|
54
|
+
/** The ProseMirror transaction underneath, for anything the methods don't cover. */
|
|
55
|
+
readonly tr: Transaction;
|
|
56
|
+
readonly meta: EditorTransactionMeta;
|
|
57
|
+
/** `focusBlock` was called: the editor takes focus once the changes are applied. */
|
|
58
|
+
focused: boolean;
|
|
59
|
+
constructor(
|
|
60
|
+
/** The state the changes start from. */
|
|
61
|
+
before: EditorState, meta?: EditorTransactionMeta,
|
|
62
|
+
/**
|
|
63
|
+
* Whether the selection was placed by the user or the program. An editor
|
|
64
|
+
* that never had focus has its selection at the start, which is no cursor.
|
|
65
|
+
*/
|
|
66
|
+
hasCursor?: boolean);
|
|
67
|
+
get changed(): boolean;
|
|
68
|
+
setMeta(meta: EditorTransactionMeta): this;
|
|
69
|
+
/** A block as it is now, or `null`. */
|
|
70
|
+
getBlock(id: string): Block | null;
|
|
71
|
+
/**
|
|
72
|
+
* Insert blocks, by default after the block with the cursor (at the end
|
|
73
|
+
* without one). Returns the new blocks' ids; an id already in the
|
|
74
|
+
* document is replaced with a fresh one.
|
|
75
|
+
*/
|
|
76
|
+
insertBlocks(blocks: PartialBlock[], placement?: BlockPlacement): string[];
|
|
77
|
+
/** Change a block's type, props, content or children. Returns `false` when it isn't found. */
|
|
78
|
+
updateBlock(id: string, patch: BlockPatch): boolean;
|
|
79
|
+
/** Remove blocks with their children. The document always keeps one block. */
|
|
80
|
+
removeBlocks(ids: string[]): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Move blocks, in the order given, to `placement`. Fails when it is
|
|
83
|
+
* inside one of them.
|
|
84
|
+
*/
|
|
85
|
+
moveBlocks(ids: string[], placement: BlockPlacement): boolean;
|
|
86
|
+
/** Put the cursor at the start or end of a block's text (or select a block without text). */
|
|
87
|
+
focusBlock(id: string, edge?: BlockEdge): boolean;
|
|
88
|
+
/** After the selection's block, or at the end. */
|
|
89
|
+
private defaultPlacement;
|
|
90
|
+
}
|
|
91
|
+
/** A cursor at the start or end of a block's text; a node selection for a block without text. */
|
|
92
|
+
export declare function selectionIn(tr: Transaction, info: BlockInfo, edge: BlockEdge): Selection;
|
|
93
|
+
/**
|
|
94
|
+
* Apply a transaction made with `transact`: one undo step of its own,
|
|
95
|
+
* unless `history` is `false`. Returns whether anything happened.
|
|
96
|
+
*/
|
|
97
|
+
export declare function applyEditorTransaction(view: EditorView, transaction: EditorTransaction): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { NodeSpec } from 'prosemirror-model';
|
|
2
|
+
import type { NodeViewConstructor } from 'prosemirror-view';
|
|
3
|
+
import { type AppContext, type Component, type InjectionKey, type PropType } from 'vue';
|
|
4
|
+
import type { BlockOption, EditorExtension, Label, MountComponent } from './core/extension';
|
|
5
|
+
import type { BlockProps } from './core/model';
|
|
6
|
+
/** What a block's Vue component receives. */
|
|
7
|
+
export interface BlockViewProps {
|
|
8
|
+
/** The block's id, type and current props. */
|
|
9
|
+
block: {
|
|
10
|
+
id: string;
|
|
11
|
+
type: string;
|
|
12
|
+
props: BlockProps;
|
|
13
|
+
};
|
|
14
|
+
/** Change props; the change goes into the document, the undo history and collaboration. */
|
|
15
|
+
updateProps: (props: BlockProps) => void;
|
|
16
|
+
/** The block is selected as a whole (a block without text was clicked). */
|
|
17
|
+
selected: boolean;
|
|
18
|
+
editable: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface DefineBlockOptions {
|
|
21
|
+
type: string;
|
|
22
|
+
/** The props and their defaults. They are stored in the document, as `Block.props`. */
|
|
23
|
+
props?: Record<string, unknown>;
|
|
24
|
+
/** `inline` holds formatted text; `none` has no text (an image, an embed). Defaults to `inline`. */
|
|
25
|
+
content?: 'inline' | 'none';
|
|
26
|
+
/** Renders the block. Put `<EditorContent />` where the text goes. */
|
|
27
|
+
component?: Component;
|
|
28
|
+
/** `Enter` at the end continues with the same type, like a list. */
|
|
29
|
+
continues?: boolean;
|
|
30
|
+
/** Entries for the slash menu and the “turn into” menus; one is made from `menu` when given. */
|
|
31
|
+
menu?: Omit<BlockOption, 'key' | 'type'> & {
|
|
32
|
+
key?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Override the ProseMirror spec, e.g. `parseDOM` for pasting HTML from elsewhere. */
|
|
35
|
+
spec?: Partial<NodeSpec>;
|
|
36
|
+
}
|
|
37
|
+
/** Where a block component's text goes. */
|
|
38
|
+
export declare const EditorContent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
39
|
+
as: {
|
|
40
|
+
type: PropType<string>;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
46
|
+
as: {
|
|
47
|
+
type: PropType<string>;
|
|
48
|
+
default: string;
|
|
49
|
+
};
|
|
50
|
+
}>> & Readonly<{}>, {
|
|
51
|
+
as: string;
|
|
52
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
53
|
+
/** Renders components inside an app, with values provided to them. */
|
|
54
|
+
export declare function componentMounter(appContext: AppContext | null, provides?: [InjectionKey<unknown>, unknown][]): MountComponent;
|
|
55
|
+
/**
|
|
56
|
+
* A node view that renders a Vue component. Everything the component shows
|
|
57
|
+
* besides the text is outside the editable content, so its buttons and
|
|
58
|
+
* inputs work as usual.
|
|
59
|
+
*/
|
|
60
|
+
export declare function vueNodeView(component: Component, appContext: AppContext | null, provides?: [InjectionKey<unknown>, unknown][]): NodeViewConstructor;
|
|
61
|
+
/**
|
|
62
|
+
* Declare a block type rendered by a Vue component (or by plain DOM), with
|
|
63
|
+
* its props stored in the document. Returns an extension for `extensions`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function defineBlock(options: DefineBlockOptions): EditorExtension;
|
|
66
|
+
export type { Label };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type EditorExtensionList } from './core/convert';
|
|
2
|
+
import type { Block, EditorDocument, PartialBlock } from './core/model';
|
|
3
|
+
/** A document with no blocks, to start from when nothing is saved yet. */
|
|
4
|
+
export declare const emptyDocument: () => EditorDocument<Block>;
|
|
5
|
+
export interface DocumentProblem {
|
|
6
|
+
code: 'version' | 'shape' | 'duplicate-id' | 'unknown-type' | 'unknown-mark' | 'unknown-inline';
|
|
7
|
+
/** The block at fault, when it has an id. */
|
|
8
|
+
blockId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Where the problem is, as a path into the document, e.g.
|
|
11
|
+
* `blocks[0].children[2]` or `blocks[1].content[0]`; `version` for the version.
|
|
12
|
+
*/
|
|
13
|
+
path: string;
|
|
14
|
+
/** The id, type, mark or inline node at fault, for the editor's message. */
|
|
15
|
+
text: string;
|
|
16
|
+
/** An English description, for logs. */
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CheckDocumentOptions {
|
|
20
|
+
/** The editor's `extensions`, for the blocks, marks and inline nodes they add; `[editorKit()]` by default, as in the editor. */
|
|
21
|
+
extensions?: EditorExtensionList;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The problems of an editor document, before it is saved or shown: an
|
|
25
|
+
* unknown version, blocks or table rows sharing an id, and block types,
|
|
26
|
+
* marks and inline nodes the extensions don't define, which the editor
|
|
27
|
+
* would show as a paragraph or leave out.
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkDocument(document: EditorDocument<PartialBlock>, options?: CheckDocumentOptions): DocumentProblem[];
|
|
30
|
+
/**
|
|
31
|
+
* Brings a saved document up to the current version, and fills what an
|
|
32
|
+
* older or hand-written one may lack (`version`, `blocks`). Blocks that are
|
|
33
|
+
* not objects are dropped; anything else is kept as it is, for the editor
|
|
34
|
+
* to read as it reads partial blocks. Throws for data that is not an object (an array,
|
|
35
|
+
* `null`, a string) and for a version it does not know.
|
|
36
|
+
*/
|
|
37
|
+
export declare function migrateDocument(input: unknown): EditorDocument<PartialBlock>;
|
|
38
|
+
/**
|
|
39
|
+
* The blocks of the `v-model`, as the editor reads them. A document of the
|
|
40
|
+
* wrong shape (not an object, a bare list of blocks, without `blocks` or a
|
|
41
|
+
* known `version`) gets a warning in development and is read as well as it
|
|
42
|
+
* can be: a list as the blocks, anything else missing as no blocks. What
|
|
43
|
+
* the editor writes back always carries `version: 1`. `undefined`, no
|
|
44
|
+
* `v-model` bound, is fine.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readBlocks(value: unknown): PartialBlock[] | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EditorView } from 'prosemirror-view';
|
|
2
|
+
/**
|
|
3
|
+
* The content element (paragraph, heading, …) at height `y` in viewport
|
|
4
|
+
* coordinates: the last one whose top is above it. Contents follow each
|
|
5
|
+
* other from top to bottom in document order, nested ones included, so
|
|
6
|
+
* a binary search does.
|
|
7
|
+
*/
|
|
8
|
+
export declare function contentAt(view: EditorView, y: number): HTMLElement | null;
|
|
9
|
+
/** The block element around a content element. */
|
|
10
|
+
export declare function blockElementOf(content: HTMLElement): HTMLElement | null;
|
|
11
|
+
/** The nearest ancestor that scrolls vertically, or `null` for the page. */
|
|
12
|
+
export declare function scrollParent(element: HTMLElement): HTMLElement | null;
|
|
13
|
+
/** Where the first line of a content element sits: its top and height. */
|
|
14
|
+
export declare function firstLine(content: HTMLElement): {
|
|
15
|
+
top: number;
|
|
16
|
+
height: number;
|
|
17
|
+
};
|