@dou-ui/editor 0.1.0-alpha.11 → 0.1.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collaboration/cursors.js +42 -10
- package/dist/collaboration/cursors.js.map +1 -1
- package/dist/collaboration/index.js +30 -3
- package/dist/collaboration/index.js.map +1 -1
- package/dist/components/block-handle.js.map +1 -1
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +73 -15
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/slash-choices.js +6 -0
- package/dist/components/slash-choices.js.map +1 -0
- package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js +56 -0
- package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/slash-menu.js.map +1 -1
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +185 -20
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/core/block-selection.js +32 -4
- package/dist/core/block-selection.js.map +1 -1
- package/dist/core/blocks.js +21 -3
- package/dist/core/blocks.js.map +1 -1
- package/dist/core/commands.js +125 -13
- package/dist/core/commands.js.map +1 -1
- package/dist/core/extension.js +6 -2
- package/dist/core/extension.js.map +1 -1
- package/dist/core/model.js +8 -2
- package/dist/core/model.js.map +1 -1
- package/dist/core/schema.js.map +1 -1
- package/dist/core/transaction.js +12 -3
- package/dist/core/transaction.js.map +1 -1
- package/dist/document.js +40 -4
- package/dist/document.js.map +1 -1
- package/dist/dom.js +96 -13
- package/dist/dom.js.map +1 -1
- package/dist/editor.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/editor2.js.map +1 -1
- package/dist/extensions/columns/column-picker.js +6 -0
- package/dist/extensions/columns/column-picker.js.map +1 -0
- package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/columns/columns-controls.js +6 -0
- package/dist/extensions/columns/columns-controls.js.map +1 -0
- package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js +341 -0
- package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/columns/html.js +34 -0
- package/dist/extensions/columns/html.js.map +1 -0
- package/dist/extensions/columns/index.js +57 -0
- package/dist/extensions/columns/index.js.map +1 -0
- package/dist/extensions/columns/keys.js +53 -0
- package/dist/extensions/columns/keys.js.map +1 -0
- package/dist/extensions/columns/plugin.js +213 -0
- package/dist/extensions/columns/plugin.js.map +1 -0
- package/dist/extensions/columns/schema.js +58 -0
- package/dist/extensions/columns/schema.js.map +1 -0
- package/dist/extensions/columns/select-columns.js +6 -0
- package/dist/extensions/columns/select-columns.js.map +1 -0
- package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/editor-kit.js +3 -1
- package/dist/extensions/editor-kit.js.map +1 -1
- package/dist/extensions/table/plugin.js +33 -1
- package/dist/extensions/table/plugin.js.map +1 -1
- package/dist/extensions/table/table-controls.js.map +1 -1
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/extensions/table/view.js +25 -1
- package/dist/extensions/table/view.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/locale.js +30 -0
- package/dist/locale.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/collaboration/cursors.d.ts +29 -1
- package/dist/types/collaboration/index.d.ts +17 -2
- package/dist/types/components/slash-choices.vue.d.ts +18 -0
- package/dist/types/core/blocks.d.ts +10 -0
- package/dist/types/core/commands.d.ts +17 -2
- package/dist/types/core/extension.d.ts +53 -2
- package/dist/types/core/model.d.ts +6 -1
- package/dist/types/core/schema.d.ts +1 -1
- package/dist/types/document.d.ts +4 -2
- package/dist/types/dom.d.ts +34 -4
- package/dist/types/editor.vue.d.ts +10 -0
- package/dist/types/extensions/columns/column-picker.vue.d.ts +10 -0
- package/dist/types/extensions/columns/columns-controls.vue.d.ts +3 -0
- package/dist/types/extensions/columns/html.d.ts +10 -0
- package/dist/types/extensions/columns/index.d.ts +9 -0
- package/dist/types/extensions/columns/keys.d.ts +6 -0
- package/dist/types/extensions/columns/plugin.d.ts +28 -0
- package/dist/types/extensions/columns/schema.d.ts +17 -0
- package/dist/types/extensions/columns/select-columns.vue.d.ts +13 -0
- package/dist/types/extensions/editor-kit.d.ts +4 -1
- package/dist/types/extensions/table/view.d.ts +8 -1
- package/dist/types/index.d.ts +12 -2
- package/dist/types/locale.d.ts +17 -0
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@ import type { Command, Plugin } from 'prosemirror-state';
|
|
|
4
4
|
import type { NodeViewConstructor } from 'prosemirror-view';
|
|
5
5
|
import { type CommentAction, type CommentThread } from 'dou-ui';
|
|
6
6
|
import type { Component, Ref } from 'vue';
|
|
7
|
-
import type
|
|
7
|
+
import { type EditorMessages } from '../locale';
|
|
8
8
|
import type { BlockProps } from './model';
|
|
9
9
|
import type { EditorExtensionOutput } from './output';
|
|
10
10
|
/** Text shown in a menu: fixed, or read from the editor's messages so it follows the locale. */
|
|
@@ -25,6 +25,51 @@ export interface BlockOption {
|
|
|
25
25
|
keywords?: string[];
|
|
26
26
|
/** The Markdown shortcut, shown as a hint. */
|
|
27
27
|
shortcut?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Variants to pick from in a panel beside the option in the slash menu,
|
|
30
|
+
* e.g. how many columns. Choosing the option itself inserts the first.
|
|
31
|
+
*/
|
|
32
|
+
choices?: BlockOptionChoices;
|
|
33
|
+
}
|
|
34
|
+
/** One variant of a slash menu option. */
|
|
35
|
+
export interface BlockOptionChoice {
|
|
36
|
+
/** The props it inserts with, over the option's own. */
|
|
37
|
+
props: BlockProps;
|
|
38
|
+
/** Its name, also read out by screen readers. */
|
|
39
|
+
label: Label;
|
|
40
|
+
}
|
|
41
|
+
/** The variants of a slash menu option, picked in a panel beside it. */
|
|
42
|
+
export interface BlockOptionChoices {
|
|
43
|
+
/** The panel's title, e.g. “Number of columns”; also the name screen readers give the panel. */
|
|
44
|
+
title: Label;
|
|
45
|
+
items: BlockOptionChoice[];
|
|
46
|
+
/**
|
|
47
|
+
* Draws the variants (the panel around them and its title are drawn by
|
|
48
|
+
* the menu). It gets the props in `BlockOptionChoicesProps` and emits
|
|
49
|
+
* `hover` and `choose` with an index, as in `BlockOptionChoicesEmits`.
|
|
50
|
+
* Without it, the panel lists their names.
|
|
51
|
+
*/
|
|
52
|
+
component?: Component<BlockOptionChoicesProps>;
|
|
53
|
+
}
|
|
54
|
+
/** What the `component` of `BlockOptionChoices` gets. */
|
|
55
|
+
export interface BlockOptionChoicesProps {
|
|
56
|
+
items: BlockOptionChoice[];
|
|
57
|
+
/** The index of the highlighted variant; -1 while the option itself is highlighted. */
|
|
58
|
+
active: number;
|
|
59
|
+
messages: EditorMessages;
|
|
60
|
+
/**
|
|
61
|
+
* For screen readers: give the element of variant `index` the id
|
|
62
|
+
* `${idPrefix}-${index}` and `role="option"` (with `aria-selected`), so
|
|
63
|
+
* the editor can point at the highlighted one.
|
|
64
|
+
*/
|
|
65
|
+
idPrefix: string;
|
|
66
|
+
}
|
|
67
|
+
/** What the `component` of `BlockOptionChoices` emits. */
|
|
68
|
+
export interface BlockOptionChoicesEmits {
|
|
69
|
+
/** The pointer is on variant `index`. */
|
|
70
|
+
hover: [index: number];
|
|
71
|
+
/** Variant `index` is picked: the menu inserts it. */
|
|
72
|
+
choose: [index: number];
|
|
28
73
|
}
|
|
29
74
|
/** A toggle in the formatting toolbar for a mark. */
|
|
30
75
|
export interface FormatOption {
|
|
@@ -43,6 +88,12 @@ export interface CommentsProvider {
|
|
|
43
88
|
}
|
|
44
89
|
export interface EditorExtensionContext {
|
|
45
90
|
schema: Schema;
|
|
91
|
+
/**
|
|
92
|
+
* The editor's messages, in its current locale, for text a plugin puts
|
|
93
|
+
* in the document's markup (e.g. a name for screen readers). Outside an
|
|
94
|
+
* editor (converting documents) the Chinese ones.
|
|
95
|
+
*/
|
|
96
|
+
messages: () => EditorMessages;
|
|
46
97
|
}
|
|
47
98
|
/** What the extension replacing the undo history provides (e.g. collaboration). */
|
|
48
99
|
export interface HistoryProvider {
|
|
@@ -164,4 +215,4 @@ export interface ResolvedEditorExtensions {
|
|
|
164
215
|
/** `mod+shift+h` → `Mod-Shift-h`, the way the ProseMirror keymap names keys. */
|
|
165
216
|
export declare function toEditorKey(hotkey: string): string;
|
|
166
217
|
/** Sort the extensions by priority, build the schema and collect what they add. */
|
|
167
|
-
export declare function resolveEditorExtensions(list: readonly (EditorExtension | EditorExtension[])[]): ResolvedEditorExtensions;
|
|
218
|
+
export declare function resolveEditorExtensions(list: readonly (EditorExtension | EditorExtension[])[], messages?: () => EditorMessages): ResolvedEditorExtensions;
|
|
@@ -152,7 +152,12 @@ export declare function inlineNodes(schema: Schema, content: PartialBlock['conte
|
|
|
152
152
|
*/
|
|
153
153
|
export declare function contentAttrs(type: NodeType, props?: BlockProps): Record<string, unknown>;
|
|
154
154
|
export declare function createContentNode(schema: Schema, type: ContentType, props?: BlockProps, content?: PartialBlock['content'], rows?: PartialTableRow[]): PMNode;
|
|
155
|
-
|
|
155
|
+
/**
|
|
156
|
+
* The block node for `block`. With `fill`, a block that starts with
|
|
157
|
+
* children of its own (`template` in its spec, e.g. columns) and is given
|
|
158
|
+
* none gets them, as when it is picked from the slash menu.
|
|
159
|
+
*/
|
|
160
|
+
export declare function nodeFromBlock(schema: Schema, block: PartialBlock, fill?: boolean): PMNode;
|
|
156
161
|
export declare function blocksToDoc(schema: Schema, blocks: PartialBlock[]): PMNode;
|
|
157
162
|
/** A development warning, once per message. */
|
|
158
163
|
export declare function warnOnce(message: string): void;
|
|
@@ -32,7 +32,7 @@ export declare function createSchema({ blocks, nodes: inner, inlines, marks }: S
|
|
|
32
32
|
/** Links may only point to web pages, mail, phone numbers or relative paths. */
|
|
33
33
|
export declare function isSafeHref(href: string): boolean;
|
|
34
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';
|
|
35
|
+
export type BuiltinContentType = 'paragraph' | 'heading' | 'bulletItem' | 'numberedItem' | 'checkItem' | 'quote' | 'codeBlock' | 'divider' | 'toggle' | 'callout' | 'table' | 'columns' | 'column';
|
|
36
36
|
export type ContentType = BuiltinContentType | (string & {});
|
|
37
37
|
export type BuiltinMarkType = 'bold' | 'italic' | 'underline' | 'strike' | 'code';
|
|
38
38
|
export type MarkType = BuiltinMarkType | (string & {});
|
package/dist/types/document.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Block, EditorDocument, PartialBlock } from './core/model';
|
|
|
3
3
|
/** A document with no blocks, to start from when nothing is saved yet. */
|
|
4
4
|
export declare const emptyDocument: () => EditorDocument<Block>;
|
|
5
5
|
export interface DocumentProblem {
|
|
6
|
-
code: 'version' | 'shape' | 'duplicate-id' | 'unknown-type' | 'unknown-mark' | 'unknown-inline';
|
|
6
|
+
code: 'version' | 'shape' | 'duplicate-id' | 'unknown-type' | 'unknown-mark' | 'unknown-inline' | 'invalid-columns';
|
|
7
7
|
/** The block at fault, when it has an id. */
|
|
8
8
|
blockId?: string;
|
|
9
9
|
/**
|
|
@@ -24,7 +24,9 @@ export interface CheckDocumentOptions {
|
|
|
24
24
|
* The problems of an editor document, before it is saved or shown: an
|
|
25
25
|
* unknown version, blocks or table rows sharing an id, and block types,
|
|
26
26
|
* marks and inline nodes the extensions don't define, which the editor
|
|
27
|
-
* would show as a paragraph or leave out
|
|
27
|
+
* would show as a paragraph or leave out, and columns the editor would
|
|
28
|
+
* change on the next edit (a column outside a set of columns, a set with
|
|
29
|
+
* fewer than two, columns in a column…).
|
|
28
30
|
*/
|
|
29
31
|
export declare function checkDocument(document: EditorDocument<PartialBlock>, options?: CheckDocumentOptions): DocumentProblem[];
|
|
30
32
|
/**
|
package/dist/types/dom.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import type { EditorView } from 'prosemirror-view';
|
|
2
|
+
/** The blocks right inside a container element: the editing area or a group. */
|
|
3
|
+
export declare const childBlocks: (container: Element) => HTMLElement[];
|
|
4
|
+
/** The group of a set of columns, around an element in one of them. */
|
|
5
|
+
export declare const COLUMNS_GROUP = ".dou-editor__content--columns + .dou-editor__group";
|
|
6
|
+
/** The group of one column (its blocks). */
|
|
7
|
+
export declare const COLUMN_GROUP = ".dou-editor__content--column + .dou-editor__group";
|
|
8
|
+
/** Whether columns sit side by side; a narrow editor stacks them. */
|
|
9
|
+
export declare function sideBySide(columns: HTMLElement[]): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The column at `x` among side-by-side ones: the gap before a column
|
|
12
|
+
* belongs to it (its handle sits there), what is left of the first to the
|
|
13
|
+
* first and right of the last to the last.
|
|
14
|
+
*/
|
|
15
|
+
export declare function columnAtX(columns: HTMLElement[], x: number): number;
|
|
2
16
|
/**
|
|
3
17
|
* The content element (paragraph, heading, …) at height `y` in viewport
|
|
4
|
-
* coordinates: the last one whose top is above it
|
|
5
|
-
* other from top to bottom
|
|
6
|
-
*
|
|
18
|
+
* coordinates: the last one whose top is above it, nested ones included.
|
|
19
|
+
* Blocks follow each other from top to bottom, so a binary search finds
|
|
20
|
+
* the block, then the same again among its children. In a set of
|
|
21
|
+
* columns, `x` picks the column (stacked columns go by `y` too).
|
|
7
22
|
*/
|
|
8
|
-
export declare function contentAt(view: EditorView, y: number): HTMLElement | null;
|
|
23
|
+
export declare function contentAt(view: EditorView, y: number, x?: number): HTMLElement | null;
|
|
9
24
|
/** The block element around a content element. */
|
|
10
25
|
export declare function blockElementOf(content: HTMLElement): HTMLElement | null;
|
|
11
26
|
/** The nearest ancestor that scrolls vertically, or `null` for the page. */
|
|
@@ -15,5 +30,20 @@ export declare function firstLine(content: HTMLElement): {
|
|
|
15
30
|
top: number;
|
|
16
31
|
height: number;
|
|
17
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Where a block's content goes across: its box, less what a top-level
|
|
35
|
+
* table's frame reaches into the margins (its start padding and end margin),
|
|
36
|
+
* which keeps the table in line with the text. The editor lays out left to
|
|
37
|
+
* right, so the logical start and end are the left and right.
|
|
38
|
+
*/
|
|
39
|
+
export declare function contentSpan(content: HTMLElement): {
|
|
40
|
+
left: number;
|
|
41
|
+
right: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Where the block handle goes: before the content, or before what shows of
|
|
45
|
+
* a table, whose left edge moves out into the margin as it scrolls.
|
|
46
|
+
*/
|
|
47
|
+
export declare function handleLeft(content: HTMLElement): number;
|
|
18
48
|
/** The right edge of the editor's text column: the surface less its padding (a reading width). */
|
|
19
49
|
export declare function columnRight(surface: HTMLElement): number;
|
|
@@ -50,6 +50,7 @@ declare const __VLS_export: import("vue").DefineComponent<EditorProps, EditorExp
|
|
|
50
50
|
toggle?: string | undefined;
|
|
51
51
|
callout?: string | undefined;
|
|
52
52
|
table?: string | undefined;
|
|
53
|
+
columns?: string | undefined;
|
|
53
54
|
attachment?: string | undefined;
|
|
54
55
|
embed?: string | undefined;
|
|
55
56
|
} | undefined;
|
|
@@ -68,6 +69,7 @@ declare const __VLS_export: import("vue").DefineComponent<EditorProps, EditorExp
|
|
|
68
69
|
toggle?: string | undefined;
|
|
69
70
|
callout?: string | undefined;
|
|
70
71
|
table?: string | undefined;
|
|
72
|
+
columns?: string | undefined;
|
|
71
73
|
attachment?: string | undefined;
|
|
72
74
|
embed?: string | undefined;
|
|
73
75
|
} | undefined;
|
|
@@ -128,6 +130,14 @@ declare const __VLS_export: import("vue").DefineComponent<EditorProps, EditorExp
|
|
|
128
130
|
addRow?: string | undefined;
|
|
129
131
|
addColumn?: string | undefined;
|
|
130
132
|
} | undefined;
|
|
133
|
+
columns?: {
|
|
134
|
+
pick?: string | undefined;
|
|
135
|
+
count?: string | undefined;
|
|
136
|
+
select?: string | undefined;
|
|
137
|
+
resize?: string | undefined;
|
|
138
|
+
even?: string | undefined;
|
|
139
|
+
column?: string | undefined;
|
|
140
|
+
} | undefined;
|
|
131
141
|
colors?: {
|
|
132
142
|
label?: string | undefined;
|
|
133
143
|
text?: string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type BlockOptionChoicesProps } from '../../core/extension';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<BlockOptionChoicesProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
+
hover: (index: number) => any;
|
|
4
|
+
choose: (index: number) => any;
|
|
5
|
+
}, string, import("vue").PublicProps, Readonly<BlockOptionChoicesProps> & Readonly<{
|
|
6
|
+
onHover?: ((index: number) => any) | undefined;
|
|
7
|
+
onChoose?: ((index: number) => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BlockOutput } from '../../core/output';
|
|
2
|
+
/**
|
|
3
|
+
* Columns in HTML: a flex row of `div`s, each with its share of the row,
|
|
4
|
+
* so the page shows them side by side without the editor's styles; on a
|
|
5
|
+
* narrow page they wrap, one under the other.
|
|
6
|
+
* Markdown has no columns: their blocks follow one another.
|
|
7
|
+
*/
|
|
8
|
+
export declare const columnsOutput: Record<string, BlockOutput>;
|
|
9
|
+
/** Back from that HTML: `div[data-columns]` and the `div[data-column]` in it. */
|
|
10
|
+
export declare function prepareColumns(root: HTMLElement): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Columns: blocks side by side, two to five of them. In the slash menu,
|
|
3
|
+
* “Columns” opens a picker for how many. Each column holds any blocks,
|
|
4
|
+
* which move between columns like anywhere else; dropping blocks between
|
|
5
|
+
* two columns makes a new one there, and dragging the bar between two
|
|
6
|
+
* columns resizes them. On a narrow screen the columns stack.
|
|
7
|
+
*/
|
|
8
|
+
export declare const columns: import("../..").EditorExtension;
|
|
9
|
+
export { MAX_COLUMNS } from './schema';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Plugin, PluginKey, type Transaction } from 'prosemirror-state';
|
|
2
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
3
|
+
/** A column's width while its bar is dragged: shown, not yet in the document. */
|
|
4
|
+
export interface ColumnPreview {
|
|
5
|
+
/** The position before the column's block. */
|
|
6
|
+
pos: number;
|
|
7
|
+
width: number;
|
|
8
|
+
}
|
|
9
|
+
interface ColumnsState {
|
|
10
|
+
decorations: DecorationSet;
|
|
11
|
+
preview: ColumnPreview[] | null;
|
|
12
|
+
}
|
|
13
|
+
/** The name of a column: its place among the columns of its set. */
|
|
14
|
+
export type ColumnLabel = (index: number, count: number) => string;
|
|
15
|
+
export declare const columnsKey: PluginKey<ColumnsState>;
|
|
16
|
+
/** Show `preview` widths without changing the document, or stop showing them (`null`). */
|
|
17
|
+
export declare function previewColumns(tr: Transaction, preview: ColumnPreview[] | null): Transaction;
|
|
18
|
+
/** Lay the columns out again, e.g. after the locale changed their names. */
|
|
19
|
+
export declare const refreshColumns: (tr: Transaction) => Transaction;
|
|
20
|
+
/**
|
|
21
|
+
* Keeps columns well formed after every change, also one from another
|
|
22
|
+
* collaborator (the fix is the same everywhere): columns only in a set of
|
|
23
|
+
* columns, at least one block in each, at least two in a set, no set of
|
|
24
|
+
* columns in a column. Lays each column's width on it, and turns a text
|
|
25
|
+
* selection across columns into a selection of the whole blocks.
|
|
26
|
+
*/
|
|
27
|
+
export declare function columnsPlugin(label: ColumnLabel): Plugin<ColumnsState>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NodeSpec } from 'prosemirror-model';
|
|
2
|
+
/** The most columns a set can have, from the picker or by dropping blocks beside them. */
|
|
3
|
+
export declare const MAX_COLUMNS = 5;
|
|
4
|
+
export declare const MIN_COLUMNS = 2;
|
|
5
|
+
/** A column's width: a positive weight, rounded; anything else is the default (1). */
|
|
6
|
+
export declare function widthOf(value: unknown): number | null;
|
|
7
|
+
/**
|
|
8
|
+
* A set of columns. Its content node holds no text and isn't shown; its
|
|
9
|
+
* children are `column` blocks, laid out side by side.
|
|
10
|
+
*/
|
|
11
|
+
export declare const columnsSpec: NodeSpec;
|
|
12
|
+
/**
|
|
13
|
+
* One column: its children are the blocks shown in it. `props.width` is
|
|
14
|
+
* its share of the row, a weight against the other columns' (1 when left
|
|
15
|
+
* out), so two people resizing different columns at once both keep theirs.
|
|
16
|
+
*/
|
|
17
|
+
export declare const columnSpec: NodeSpec;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Block } from '../../core/model';
|
|
2
|
+
/**
|
|
3
|
+
* In the block menu of a block inside columns: select the whole set of
|
|
4
|
+
* columns, to move, copy or remove it with the handle or the keyboard;
|
|
5
|
+
* and, when the columns differ in width, make them even (where the bar
|
|
6
|
+
* between them can't be dragged, e.g. on a touch screen).
|
|
7
|
+
*/
|
|
8
|
+
type __VLS_Props = {
|
|
9
|
+
block: Block;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -4,6 +4,7 @@ import { align } from './align';
|
|
|
4
4
|
import { callout } from './callout';
|
|
5
5
|
import { colors } from './colors';
|
|
6
6
|
import { codeBlock, type CodeBlockOptions } from './code-block';
|
|
7
|
+
import { columns } from './columns';
|
|
7
8
|
import { formatting, link } from './formatting';
|
|
8
9
|
import { lists } from './lists';
|
|
9
10
|
import { table } from './table';
|
|
@@ -22,6 +23,8 @@ export interface EditorKitOptions {
|
|
|
22
23
|
toggle?: boolean;
|
|
23
24
|
callout?: boolean;
|
|
24
25
|
table?: boolean;
|
|
26
|
+
/** Blocks side by side in columns. */
|
|
27
|
+
columns?: boolean;
|
|
25
28
|
formatting?: boolean;
|
|
26
29
|
link?: boolean;
|
|
27
30
|
/** Text and background colors. */
|
|
@@ -34,4 +37,4 @@ export interface EditorKitOptions {
|
|
|
34
37
|
* it out, e.g. `editorKit({ codeBlock: false })`.
|
|
35
38
|
*/
|
|
36
39
|
export declare function editorKit(options?: EditorKitOptions): EditorExtension[];
|
|
37
|
-
export { align, callout, colors, codeBlock, divider, formatting, heading, link, lists, paragraph, quote, table, toggle, };
|
|
40
|
+
export { align, callout, colors, codeBlock, columns, divider, formatting, heading, link, lists, paragraph, quote, table, toggle, };
|
|
@@ -5,9 +5,16 @@ import type { NodeView, ViewMutationRecord } from 'prosemirror-view';
|
|
|
5
5
|
export declare const CELL_MIN_WIDTH = 96;
|
|
6
6
|
/**
|
|
7
7
|
* A table in the editor: a scrolling frame (the block's content element)
|
|
8
|
-
* around the table, with a `<colgroup>` that holds the column widths.
|
|
8
|
+
* around the table, with a `<colgroup>` that holds the column widths. When
|
|
9
|
+
* columns are cut off at either side of the frame, that side has a shadow:
|
|
10
|
+
* `is-cut-start` / `is-cut-end` on the frame.
|
|
9
11
|
*/
|
|
10
12
|
export declare class TableBlockView extends TableView implements NodeView {
|
|
13
|
+
private readonly observer;
|
|
14
|
+
private readonly onScroll;
|
|
11
15
|
constructor(node: PMNode);
|
|
16
|
+
/** Which sides cut columns off: the table's edges against the frame's, padding left out. */
|
|
17
|
+
private edges;
|
|
12
18
|
ignoreMutation(record: ViewMutationRecord): boolean;
|
|
19
|
+
destroy(): void;
|
|
13
20
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export declare const DouEditor: import("dou-ui").WithInstall<import("vue").Defin
|
|
|
48
48
|
toggle?: string | undefined;
|
|
49
49
|
callout?: string | undefined;
|
|
50
50
|
table?: string | undefined;
|
|
51
|
+
columns?: string | undefined;
|
|
51
52
|
attachment?: string | undefined;
|
|
52
53
|
embed?: string | undefined;
|
|
53
54
|
} | undefined;
|
|
@@ -66,6 +67,7 @@ export declare const DouEditor: import("dou-ui").WithInstall<import("vue").Defin
|
|
|
66
67
|
toggle?: string | undefined;
|
|
67
68
|
callout?: string | undefined;
|
|
68
69
|
table?: string | undefined;
|
|
70
|
+
columns?: string | undefined;
|
|
69
71
|
attachment?: string | undefined;
|
|
70
72
|
embed?: string | undefined;
|
|
71
73
|
} | undefined;
|
|
@@ -126,6 +128,14 @@ export declare const DouEditor: import("dou-ui").WithInstall<import("vue").Defin
|
|
|
126
128
|
addRow?: string | undefined;
|
|
127
129
|
addColumn?: string | undefined;
|
|
128
130
|
} | undefined;
|
|
131
|
+
columns?: {
|
|
132
|
+
pick?: string | undefined;
|
|
133
|
+
count?: string | undefined;
|
|
134
|
+
select?: string | undefined;
|
|
135
|
+
resize?: string | undefined;
|
|
136
|
+
even?: string | undefined;
|
|
137
|
+
column?: string | undefined;
|
|
138
|
+
} | undefined;
|
|
129
139
|
colors?: {
|
|
130
140
|
label?: string | undefined;
|
|
131
141
|
text?: string | undefined;
|
|
@@ -215,8 +225,8 @@ export { editorLocales, useEditorMessages } from './locale';
|
|
|
215
225
|
export type { EditorMessages, EditorMessagesOverride } from './locale';
|
|
216
226
|
export { filterOptions } from './catalog';
|
|
217
227
|
export { defineEditorExtension, labelOf } from './core/extension';
|
|
218
|
-
export type { BlockOption, CommentsProvider, EditorExtension, EditorExtensionContext, FormatOption, HistoryProvider, Label, MountComponent, ResolvedEditorExtensions, } from './core/extension';
|
|
219
|
-
export { align, callout, codeBlock, colors, divider, formatting, heading, link, lists, paragraph, quote, editorKit, table, toggle, } from './extensions/editor-kit';
|
|
228
|
+
export type { BlockOption, BlockOptionChoice, BlockOptionChoices, BlockOptionChoicesEmits, BlockOptionChoicesProps, CommentsProvider, EditorExtension, EditorExtensionContext, FormatOption, HistoryProvider, Label, MountComponent, ResolvedEditorExtensions, } from './core/extension';
|
|
229
|
+
export { align, callout, codeBlock, colors, columns, divider, formatting, heading, link, lists, paragraph, quote, editorKit, table, toggle, } from './extensions/editor-kit';
|
|
220
230
|
export type { CalloutTone } from './extensions/callout';
|
|
221
231
|
export { setHighlight, setTextColor, textColors } from './extensions/colors';
|
|
222
232
|
export type { TextColor } from './extensions/colors';
|
package/dist/types/locale.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface EditorMessages {
|
|
|
19
19
|
toggle: string;
|
|
20
20
|
callout: string;
|
|
21
21
|
table: string;
|
|
22
|
+
columns: string;
|
|
22
23
|
attachment: string;
|
|
23
24
|
embed: string;
|
|
24
25
|
};
|
|
@@ -38,6 +39,7 @@ export interface EditorMessages {
|
|
|
38
39
|
toggle: string;
|
|
39
40
|
callout: string;
|
|
40
41
|
table: string;
|
|
42
|
+
columns: string;
|
|
41
43
|
attachment: string;
|
|
42
44
|
embed: string;
|
|
43
45
|
};
|
|
@@ -103,6 +105,21 @@ export interface EditorMessages {
|
|
|
103
105
|
addRow: string;
|
|
104
106
|
addColumn: string;
|
|
105
107
|
};
|
|
108
|
+
/** Columns: the picker in the slash menu, the block menu entry, the resize bar. */
|
|
109
|
+
columns: {
|
|
110
|
+
/** The title of the picker for the number of columns. */
|
|
111
|
+
pick: string;
|
|
112
|
+
/** A number of columns; `{count}` is replaced with it. */
|
|
113
|
+
count: string;
|
|
114
|
+
/** Selects the whole set of columns a block is in. */
|
|
115
|
+
select: string;
|
|
116
|
+
/** The bar between two columns. */
|
|
117
|
+
resize: string;
|
|
118
|
+
/** Makes every column of the set as wide as the others. */
|
|
119
|
+
even: string;
|
|
120
|
+
/** A column, for screen readers; `{index}` and `{count}` are replaced. */
|
|
121
|
+
column: string;
|
|
122
|
+
};
|
|
106
123
|
/** The color menu of the formatting toolbar. */
|
|
107
124
|
colors: {
|
|
108
125
|
label: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dou-ui/editor",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.13",
|
|
4
4
|
"description": "DouUI 的块编辑器:基于 ProseMirror,文档由可拖动、可转换的块组成",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"build": "vite build && vue-tsc -p tsconfig.build.json && bun scripts/build-style.ts"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@dou-ui/code": "0.1.0-alpha.
|
|
62
|
-
"dou-ui": "0.1.0-alpha.
|
|
61
|
+
"@dou-ui/code": "0.1.0-alpha.13",
|
|
62
|
+
"dou-ui": "0.1.0-alpha.13",
|
|
63
63
|
"vue": "^3.5.0",
|
|
64
64
|
"yjs": "^13.6.0",
|
|
65
65
|
"markdown-it": "^14.0.0"
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@dou-ui/icons": "0.1.0-alpha.
|
|
79
|
+
"@dou-ui/icons": "0.1.0-alpha.13",
|
|
80
80
|
"prosemirror-commands": "^1.7.2",
|
|
81
81
|
"prosemirror-history": "^1.5.1",
|
|
82
82
|
"prosemirror-inputrules": "^1.5.1",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"access": "public"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@dou-ui/code": "0.1.0-alpha.
|
|
94
|
+
"@dou-ui/code": "0.1.0-alpha.13",
|
|
95
95
|
"@types/markdown-it": "^14.1.2",
|
|
96
96
|
"markdown-it": "^14.1.0",
|
|
97
97
|
"y-protocols": "^1.0.7",
|