@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/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.5",
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/dom": "0.2.5",
48
- "@vitral/controls": "0.2.5",
49
- "@vitral/core": "0.2.5",
50
- "@vitral/styles": "0.2.5",
51
- "@vitral/icons": "0.2.5"
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"