@vitral/editor 0.2.5 → 0.2.7
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/chips.d.ts +38 -0
- package/dist/chips.js +178 -0
- package/dist/chips.js.map +1 -0
- package/dist/editor.js +43 -1
- package/dist/editor.js.map +1 -1
- package/dist/find.d.ts +36 -0
- package/dist/find.js +319 -0
- package/dist/find.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/render/menus.d.ts +7 -0
- package/dist/render/menus.js +4 -3
- package/dist/render/menus.js.map +1 -1
- package/dist/render/toolbar.d.ts +2 -0
- package/dist/render/toolbar.js +15 -2
- package/dist/render/toolbar.js.map +1 -1
- package/dist/types.d.ts +45 -2
- package/package.json +6 -6
package/dist/types.d.ts
CHANGED
|
@@ -7,10 +7,35 @@ import type { PassThrough } from '@vitral/dom';
|
|
|
7
7
|
* toolbar, which panels, what a host draws itself.
|
|
8
8
|
*/
|
|
9
9
|
/** What a toolbar can hold, by name. */
|
|
10
|
-
export type EditorToolbarItem = 'blockType' | 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'color' | 'highlight' | 'bulletList' | 'orderedList' | 'taskList' | 'indent' | 'outdent' | 'blockquote' | 'codeBlock' | 'image' | 'table' | 'horizontalRule' | 'link' | 'undo' | 'redo' | 'clear';
|
|
10
|
+
export type EditorToolbarItem = 'blockType' | 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'color' | 'highlight' | 'bulletList' | 'orderedList' | 'taskList' | 'indent' | 'outdent' | 'blockquote' | 'codeBlock' | 'image' | 'table' | 'horizontalRule' | 'link' | 'undo' | 'redo' | 'clear' | 'find';
|
|
11
11
|
/** The commands a plain button can run. */
|
|
12
|
-
export type EditorButtonCommand = Exclude<EditorToolbarItem, 'blockType' | 'color' | 'highlight' | 'image' | 'table'>;
|
|
12
|
+
export type EditorButtonCommand = Exclude<EditorToolbarItem, 'blockType' | 'color' | 'highlight' | 'image' | 'table' | 'find'>;
|
|
13
13
|
/** One entry of the menu a slash opens. */
|
|
14
|
+
/** Something a chip trigger offers: who or what the chip will stand for. */
|
|
15
|
+
export interface ChipSuggestion {
|
|
16
|
+
/** What the chip stands for, for the application. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** The words on the chip, and in the list. */
|
|
19
|
+
label: string;
|
|
20
|
+
/** A category the chip's look follows: `'mention'`, `'tag'`, `'variable'`. */
|
|
21
|
+
kind?: string;
|
|
22
|
+
/** A line under the label in the list: an email, a count. */
|
|
23
|
+
description?: string;
|
|
24
|
+
icon?: string;
|
|
25
|
+
}
|
|
26
|
+
/** A character that, typed at the start of a word, offers chips to put in its place. */
|
|
27
|
+
export interface ChipTrigger {
|
|
28
|
+
/** One character: `'@'` for people, `'#'` for tags. Defaults to `'@'`. */
|
|
29
|
+
char?: string;
|
|
30
|
+
/**
|
|
31
|
+
* What to offer for the words typed after the trigger: a list, or a
|
|
32
|
+
* promise of one — a search on the server. A late answer to an older
|
|
33
|
+
* query is thrown away.
|
|
34
|
+
*/
|
|
35
|
+
items: (query: string) => ChipSuggestion[] | Promise<ChipSuggestion[]>;
|
|
36
|
+
/** Given to every chip this trigger makes, unless its suggestion says otherwise. */
|
|
37
|
+
kind?: string;
|
|
38
|
+
}
|
|
14
39
|
export interface SlashCommand {
|
|
15
40
|
/** Identifies it, and is what a host matches on. */
|
|
16
41
|
id: string;
|
|
@@ -61,6 +86,18 @@ export interface TextEditorConfig {
|
|
|
61
86
|
/** The handle beside the block the caret is in, and what it offers. */
|
|
62
87
|
blockMenu?: boolean | BlockAction[];
|
|
63
88
|
placeholder?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Inline chips the reader puts in by typing a trigger: `{ char: '@',
|
|
91
|
+
* items: (q) => people.filter(…) }` for mentions, or several triggers at
|
|
92
|
+
* once. Chips can also be put in with `run('insertChip', { id, label, kind })`.
|
|
93
|
+
*/
|
|
94
|
+
chips?: ChipTrigger | ChipTrigger[];
|
|
95
|
+
/**
|
|
96
|
+
* Find and replace: Ctrl/⌘+F opens the bar over the text, Ctrl+H (⌘+⌥+F
|
|
97
|
+
* on a Mac) opens it with the replace row. On by default; `false` leaves
|
|
98
|
+
* those keys to the browser. The `find` toolbar item opens it too.
|
|
99
|
+
*/
|
|
100
|
+
find?: boolean;
|
|
64
101
|
/** The most characters the document may hold. */
|
|
65
102
|
maxLength?: number | null;
|
|
66
103
|
/** Milliseconds of quiet before an edit starts a new undo step. */
|
|
@@ -124,6 +161,12 @@ export interface TextEditorHandle {
|
|
|
124
161
|
can(name: string, ...args: unknown[]): boolean;
|
|
125
162
|
isActive(name: string, attrs?: Record<string, unknown>): boolean;
|
|
126
163
|
focus(): void;
|
|
164
|
+
/** Opens the find bar, with the replace row and a query when given. */
|
|
165
|
+
openFind(options?: {
|
|
166
|
+
replace?: boolean;
|
|
167
|
+
query?: string;
|
|
168
|
+
}): void;
|
|
169
|
+
closeFind(): void;
|
|
127
170
|
/** Draws again, for anything that changed underneath. */
|
|
128
171
|
refresh(): void;
|
|
129
172
|
destroy(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitral/editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Framework-free rich text editor for Vitral: the toolbar, the panels and the content area over @vitral/core's editor engine, which the Vue, React and Angular components wrap.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vitral",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@vitral/
|
|
48
|
-
"@vitral/
|
|
49
|
-
"@vitral/
|
|
50
|
-
"@vitral/
|
|
51
|
-
"@vitral/
|
|
47
|
+
"@vitral/controls": "0.2.7",
|
|
48
|
+
"@vitral/core": "0.2.7",
|
|
49
|
+
"@vitral/dom": "0.2.7",
|
|
50
|
+
"@vitral/icons": "0.2.7",
|
|
51
|
+
"@vitral/styles": "0.2.7"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "vite build && tsc -p tsconfig.build.json"
|