@richscripts/richtexteditor 2.9.0 → 2.11.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/index.d.ts +2075 -1412
- package/package.json +2 -2
- package/richtexteditor/all_plugins.js +15 -2
- package/richtexteditor/all_plugins.min.js +3 -3
- package/richtexteditor/plugins/all_plugins.js +15 -2
- package/richtexteditor/plugins/all_plugins.min.js +3 -3
- package/richtexteditor/plugins/imageeditor.js +3 -2
- package/richtexteditor/plugins/rubyannotation.js +6 -0
- package/richtexteditor/plugins/stateinspector.js +6 -0
- package/richtexteditor/rte.js +12 -8
package/index.d.ts
CHANGED
|
@@ -1,1412 +1,2075 @@
|
|
|
1
|
-
// Type definitions for richtexteditor 2.x
|
|
2
|
-
// Project: https://richtexteditor.com
|
|
3
|
-
//
|
|
4
|
-
// These declarations cover the public surface documented at
|
|
5
|
-
// https://richtexteditor.com/docs and exercised by the React / Vue
|
|
6
|
-
// wrappers in this package. The editor itself is shipped as a single
|
|
7
|
-
// bundle (`richtexteditor/rte.js`) that attaches `RichTextEditor` to
|
|
8
|
-
// the global scope; the typings below describe both the constructor
|
|
9
|
-
// and the per-instance methods.
|
|
10
|
-
|
|
11
|
-
// =====================
|
|
12
|
-
// Structured content (JSON / Markdown)
|
|
13
|
-
// =====================
|
|
14
|
-
|
|
15
|
-
export type RichTextEditorValueFormat = "html" | "json";
|
|
16
|
-
|
|
17
|
-
export interface RichTextEditorStructuredMark {
|
|
18
|
-
type: string;
|
|
19
|
-
attrs?: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface RichTextEditorPageMargins {
|
|
23
|
-
top?: string;
|
|
24
|
-
right?: string;
|
|
25
|
-
bottom?: string;
|
|
26
|
-
left?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface RichTextEditorPageSetup {
|
|
30
|
-
format?: string;
|
|
31
|
-
orientation?: "portrait" | "landscape";
|
|
32
|
-
width?: string;
|
|
33
|
-
height?: string;
|
|
34
|
-
margins?: RichTextEditorPageMargins;
|
|
35
|
-
headerHtml?: string;
|
|
36
|
-
footerHtml?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface RichTextEditorStructuredDocumentAttributes {
|
|
40
|
-
pageSetup?: RichTextEditorPageSetup;
|
|
41
|
-
[key: string]: unknown;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface RichTextEditorStructuredDocument {
|
|
45
|
-
type: "doc";
|
|
46
|
-
version: number;
|
|
47
|
-
format: string;
|
|
48
|
-
attrs?: RichTextEditorStructuredDocumentAttributes;
|
|
49
|
-
html?: string;
|
|
50
|
-
text?: string;
|
|
51
|
-
content?: RichTextEditorStructuredNode[];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface RichTextEditorStructuredNode {
|
|
55
|
-
type: string;
|
|
56
|
-
attrs?: Record<string, unknown>;
|
|
57
|
-
content?: RichTextEditorStructuredNode[];
|
|
58
|
-
html?: string;
|
|
59
|
-
marks?: RichTextEditorStructuredMark[];
|
|
60
|
-
text?: string;
|
|
61
|
-
[key: string]: unknown;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface RichTextEditorStructuredContentLike {
|
|
65
|
-
html?: string;
|
|
66
|
-
content?: RichTextEditorStructuredNode | RichTextEditorStructuredNode[];
|
|
67
|
-
[key: string]: unknown;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface RichTextEditorValidationIssue {
|
|
71
|
-
message: string;
|
|
72
|
-
path: string;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface RichTextEditorValidationResult {
|
|
76
|
-
document: RichTextEditorStructuredDocument;
|
|
77
|
-
issues: RichTextEditorValidationIssue[];
|
|
78
|
-
valid: boolean;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type RichTextEditorAccessibilitySeverity = "error" | "warning";
|
|
82
|
-
|
|
83
|
-
export interface RichTextEditorAccessibilityIssue {
|
|
84
|
-
code: string;
|
|
85
|
-
message: string;
|
|
86
|
-
path: string;
|
|
87
|
-
severity: RichTextEditorAccessibilitySeverity;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface RichTextEditorAccessibilityRepairOptions {
|
|
91
|
-
altText?: string;
|
|
92
|
-
headingText?: string;
|
|
93
|
-
targetLevel?: number;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface RichTextEditorAccessibilityResult {
|
|
97
|
-
document: RichTextEditorStructuredDocument;
|
|
98
|
-
issues: RichTextEditorAccessibilityIssue[];
|
|
99
|
-
valid: boolean;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export type RichTextEditorLinkAuditSeverity = "error" | "warning";
|
|
103
|
-
|
|
104
|
-
export interface RichTextEditorLinkAuditIssue {
|
|
105
|
-
code: string;
|
|
106
|
-
href?: string;
|
|
107
|
-
message: string;
|
|
108
|
-
path: string;
|
|
109
|
-
severity: RichTextEditorLinkAuditSeverity;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface RichTextEditorLinkAuditOptions {
|
|
113
|
-
allowedDomains?: string[];
|
|
114
|
-
allowedProtocols?: string[];
|
|
115
|
-
flagNewWindowWithoutRel?: boolean;
|
|
116
|
-
requireHttps?: boolean;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export interface RichTextEditorLinkAuditResult {
|
|
120
|
-
document: RichTextEditorStructuredDocument;
|
|
121
|
-
issues: RichTextEditorLinkAuditIssue[];
|
|
122
|
-
valid: boolean;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface RichTextEditorTextStatistics {
|
|
126
|
-
characters: number;
|
|
127
|
-
charactersNoSpaces: number;
|
|
128
|
-
words: number;
|
|
129
|
-
selectedCharacters: number;
|
|
130
|
-
selectedCharactersNoSpaces: number;
|
|
131
|
-
selectedWords: number;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface RichTextEditorDocumentMetrics extends RichTextEditorTextStatistics {
|
|
135
|
-
paragraphs: number;
|
|
136
|
-
sentences: number;
|
|
137
|
-
headings: number;
|
|
138
|
-
images: number;
|
|
139
|
-
tables: number;
|
|
140
|
-
links: number;
|
|
141
|
-
estimatedReadingMinutes: number;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export interface RichTextEditorDocumentOutlineItem {
|
|
145
|
-
id: string;
|
|
146
|
-
level: number;
|
|
147
|
-
path: string;
|
|
148
|
-
text: string;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface RichTextEditorTableOfContentsItem extends RichTextEditorDocumentOutlineItem {
|
|
152
|
-
itemIndex?: number;
|
|
153
|
-
indexLabel?: string;
|
|
154
|
-
children: RichTextEditorTableOfContentsItem[];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface RichTextEditorFootnoteItem {
|
|
158
|
-
id: string;
|
|
159
|
-
number: number;
|
|
160
|
-
path: string;
|
|
161
|
-
refId: string;
|
|
162
|
-
text: string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export interface RichTextEditorTableOfContentsOptions {
|
|
166
|
-
minLevel?: number;
|
|
167
|
-
maxLevel?: number;
|
|
168
|
-
indexMode?: "none" | "linear" | "hierarchical";
|
|
169
|
-
title?: string;
|
|
170
|
-
includeTitle?: boolean;
|
|
171
|
-
ordered?: boolean;
|
|
172
|
-
orderedListType?: "1" | "A" | "a" | "I" | "i";
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export type RichTextEditorStructuredInput =
|
|
176
|
-
| string
|
|
177
|
-
| RichTextEditorStructuredDocument
|
|
178
|
-
| RichTextEditorStructuredContentLike;
|
|
179
|
-
|
|
180
|
-
// =====================
|
|
181
|
-
// Commands
|
|
182
|
-
// =====================
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Built-in command identifiers accepted by execCommand / isCommandEnabled /
|
|
186
|
-
* isCommandActive. The list is intentionally non-exhaustive — custom commands
|
|
187
|
-
* registered via createToolbarButton are also valid execCommand inputs, hence
|
|
188
|
-
* the `string` fallback.
|
|
189
|
-
*/
|
|
190
|
-
export type RichTextEditorCommand =
|
|
191
|
-
| "bold" | "italic" | "underline" | "strikethrough" | "subscript" | "superscript"
|
|
192
|
-
| "fontname" | "fontsize" | "forecolor" | "backcolor" | "removeformat"
|
|
193
|
-
| "justifyleft" | "justifycenter" | "justifyright" | "justifyfull"
|
|
194
|
-
| "indent" | "outdent" | "insertorderedlist" | "insertunorderedlist"
|
|
195
|
-
| "insertimage" | "insertlink" | "unlink" | "inserthorizontalrule" | "insertpagebreak"
|
|
196
|
-
| "inserttable" | "insertrowbefore" | "insertrowafter"
|
|
197
|
-
| "insertcolumnbefore" | "insertcolumnafter" | "deleterow" | "deletecolumn" | "deletetable"
|
|
198
|
-
| "undo" | "redo" | "selectall" | "copy" | "cut" | "paste"
|
|
199
|
-
| "ucase" | "lcase" | "titlecase"
|
|
200
|
-
| "source" | "fullscreen" | "preview" | "print"
|
|
201
|
-
| "pastetext" | "pastefromword"
|
|
202
|
-
| "paragraph" | "heading"
|
|
203
|
-
| "documentoutline"
|
|
204
|
-
| "contentminimap"
|
|
205
|
-
| "accessibilitychecker"
|
|
206
|
-
| "ai-ask" | "ai-chat" | "ai-review" | "ai-export-docx" | "ai-import-docx"
|
|
207
|
-
| "dictation-toggle"
|
|
208
|
-
// Modern block types (2.3.0) — backed by the blocktypes plugin.
|
|
209
|
-
| "insertcallout" | "insertcolumns" | "inserttoggle"
|
|
210
|
-
// Interactive to-do / task list (2.3.0) — backed by the todolist plugin.
|
|
211
|
-
| "inserttodolist"
|
|
212
|
-
// Equation editor (2.3.0) — backed by the mathdialog plugin.
|
|
213
|
-
| "insertmath"
|
|
214
|
-
// Mermaid diagram (2.3.0) — backed by the mermaiddiagram plugin.
|
|
215
|
-
| "insertdiagram"
|
|
216
|
-
// Bookmark preview card (2.3.0) — backed by the bookmarkcard plugin.
|
|
217
|
-
| "insertbookmark"
|
|
218
|
-
// Spell check (2.3.0) — backed by the spellcheck plugin.
|
|
219
|
-
| "spellcheck"
|
|
220
|
-
// Smart chips (2.3.0) — backed by the smartchips plugin.
|
|
221
|
-
| "insertdatechip" | "insertchip"
|
|
222
|
-
// Email toolkit (2.3.0) — backed by the emailtoolkit plugin.
|
|
223
|
-
| "emailexport"
|
|
224
|
-
// Read-aloud / text-to-speech (2.3.0) — backed by the readaloud plugin.
|
|
225
|
-
| "readaloud"
|
|
226
|
-
| string;
|
|
227
|
-
|
|
228
|
-
// =====================
|
|
229
|
-
// Selection
|
|
230
|
-
// =====================
|
|
231
|
-
|
|
232
|
-
export interface RichTextEditorSelection {
|
|
233
|
-
/** The native Range, when one is available. */
|
|
234
|
-
range?: Range;
|
|
235
|
-
/** The selected control element (image / table / hr) or null for caret/text selections. */
|
|
236
|
-
control?: Element | null;
|
|
237
|
-
/** Whether the selection is collapsed (no range / caret only). */
|
|
238
|
-
isCollapsed: boolean;
|
|
239
|
-
/** Whether the selection covers the entire document. */
|
|
240
|
-
isAll?: boolean;
|
|
241
|
-
[key: string]: unknown;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// =====================
|
|
245
|
-
// AI Toolkit (v2.0)
|
|
246
|
-
// =====================
|
|
247
|
-
|
|
248
|
-
export type RichTextEditorAiOperationType =
|
|
249
|
-
| "preview-suggestion"
|
|
250
|
-
| "replace-document"
|
|
251
|
-
| "insert-below"
|
|
252
|
-
| "add-comment"
|
|
253
|
-
| string;
|
|
254
|
-
|
|
255
|
-
export interface RichTextEditorAiOperation {
|
|
256
|
-
type: RichTextEditorAiOperationType;
|
|
257
|
-
text: string;
|
|
258
|
-
reason?: string;
|
|
259
|
-
[key: string]: unknown;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export interface RichTextEditorAiResponse {
|
|
263
|
-
sourceLabel?: string;
|
|
264
|
-
reason?: string;
|
|
265
|
-
message?: string;
|
|
266
|
-
result?: string;
|
|
267
|
-
operations?: RichTextEditorAiOperation[];
|
|
268
|
-
[key: string]: unknown;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export interface RichTextEditorAiRequest {
|
|
272
|
-
mode: string;
|
|
273
|
-
prompt?: string;
|
|
274
|
-
source?: string;
|
|
275
|
-
selectionText?: string;
|
|
276
|
-
documentText?: string;
|
|
277
|
-
hasSelection?: boolean;
|
|
278
|
-
language?: string;
|
|
279
|
-
[key: string]: unknown;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export interface RichTextEditorAiStreamHandle {
|
|
283
|
-
abort(): void;
|
|
284
|
-
promise?: Promise<RichTextEditorAiResponse | undefined>;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export interface RichTextEditorAiStreamRequestOptions {
|
|
288
|
-
url: string;
|
|
289
|
-
body: Record<string, unknown>;
|
|
290
|
-
headers?: Record<string, string>;
|
|
291
|
-
onDelta?(delta: string, accumulated: string): void;
|
|
292
|
-
onResponse?(response: RichTextEditorAiResponse): void;
|
|
293
|
-
onDone?(text: string): void;
|
|
294
|
-
onError?(error: Error): void;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export interface RichTextEditorAiExportDocxOptions {
|
|
298
|
-
filename?: string;
|
|
299
|
-
fileName?: string;
|
|
300
|
-
title?: string;
|
|
301
|
-
url?: string;
|
|
302
|
-
download?: boolean;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export interface RichTextEditorAiImportDocxOptions {
|
|
306
|
-
file?: Blob | File | null;
|
|
307
|
-
filename?: string;
|
|
308
|
-
fileName?: string;
|
|
309
|
-
url?: string;
|
|
310
|
-
apply?: boolean;
|
|
311
|
-
mode?: "replace" | "insert";
|
|
312
|
-
onError?(error: Error): void;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export interface RichTextEditorAiToolkit {
|
|
316
|
-
setResolver(
|
|
317
|
-
resolver: (request: RichTextEditorAiRequest) => Promise<RichTextEditorAiResponse> | RichTextEditorAiResponse,
|
|
318
|
-
): void;
|
|
319
|
-
openDialog(options?: { presetMode?: string; prompt?: string }): void;
|
|
320
|
-
openChatPanel(options?: { focusComposer?: boolean }): void;
|
|
321
|
-
openReviewPanel(): void;
|
|
322
|
-
runQuickAction(mode: string, options?: Record<string, unknown>): Promise<RichTextEditorAiResponse | undefined>;
|
|
323
|
-
streamRequest(options: RichTextEditorAiStreamRequestOptions): RichTextEditorAiStreamHandle;
|
|
324
|
-
exportDocx(options?: RichTextEditorAiExportDocxOptions): Promise<Blob | undefined>;
|
|
325
|
-
importDocx(options?: RichTextEditorAiImportDocxOptions): Promise<string | undefined>;
|
|
326
|
-
refreshRemoteReviewState?(force?: boolean): Promise<void>;
|
|
327
|
-
acceptInline?(text: string): void;
|
|
328
|
-
rejectInline?(): void;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// =====================
|
|
332
|
-
// Dictation
|
|
333
|
-
// =====================
|
|
334
|
-
|
|
335
|
-
export interface RichTextEditorDictation {
|
|
336
|
-
isSupported(): boolean;
|
|
337
|
-
isListening(): boolean;
|
|
338
|
-
start(options?: { language?: string; continuous?: boolean }): void;
|
|
339
|
-
stop(): void;
|
|
340
|
-
toggle(options?: { language?: string }): void;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// =====================
|
|
344
|
-
// Revision history
|
|
345
|
-
// =====================
|
|
346
|
-
|
|
347
|
-
export interface RichTextEditorRevisionEntry {
|
|
348
|
-
id: string;
|
|
349
|
-
name?: string;
|
|
350
|
-
createdAt: number;
|
|
351
|
-
html: string;
|
|
352
|
-
authorId?: string;
|
|
353
|
-
authorName?: string;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export interface RichTextEditorRevisionDiff {
|
|
357
|
-
oldHtml: string;
|
|
358
|
-
newHtml: string;
|
|
359
|
-
unifiedDiff?: string;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export interface RichTextEditorRevisionHistory {
|
|
363
|
-
snapshot(name?: string): RichTextEditorRevisionEntry;
|
|
364
|
-
promptAndSnapshot(): Promise<RichTextEditorRevisionEntry | undefined>;
|
|
365
|
-
rename(id: string, name: string): void;
|
|
366
|
-
list(): RichTextEditorRevisionEntry[];
|
|
367
|
-
listNamed(): RichTextEditorRevisionEntry[];
|
|
368
|
-
diff(idA: string, idB: string): RichTextEditorRevisionDiff;
|
|
369
|
-
restore(id: string): void;
|
|
370
|
-
remove(id: string): void;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// =====================
|
|
374
|
-
// Yjs collab
|
|
375
|
-
// =====================
|
|
376
|
-
|
|
377
|
-
export interface RichTextEditorCollabAttachOptions {
|
|
378
|
-
doc: unknown;
|
|
379
|
-
provider: unknown;
|
|
380
|
-
textSync?: boolean;
|
|
381
|
-
awareness?: unknown;
|
|
382
|
-
fragmentName?: string;
|
|
383
|
-
/**
|
|
384
|
-
* The Yjs module (the `* as Y` namespace). REQUIRED to be the SAME Yjs
|
|
385
|
-
* instance that created `doc` and backs `provider` whenever the editor can't
|
|
386
|
-
* find it on `window.Y`. The CRDT engine builds document nodes with this
|
|
387
|
-
* module; mixing two Yjs copies throws "Unexpected content type in insert
|
|
388
|
-
* operation" and silently breaks text sync (yjs issue #438).
|
|
389
|
-
*/
|
|
390
|
-
Y?: unknown;
|
|
391
|
-
/**
|
|
392
|
-
* When attaching to an EMPTY shared document, seed it from the editor's
|
|
393
|
-
* current content (first-writer) instead of clearing the editor. Default
|
|
394
|
-
* `true`. Set `false` to always let the shared document win (the editor is
|
|
395
|
-
* cleared if the shared doc is empty). Reconciliation waits for the
|
|
396
|
-
* provider's initial sync so it never clobbers not-yet-synced remote state.
|
|
397
|
-
*/
|
|
398
|
-
seedFromHost?: boolean;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
export interface RichTextEditorCollab {
|
|
402
|
-
attach(options: RichTextEditorCollabAttachOptions): void;
|
|
403
|
-
detach(): void;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// =====================
|
|
407
|
-
// Slash commands / mentions / comments / review ledger
|
|
408
|
-
// =====================
|
|
409
|
-
|
|
410
|
-
export interface RichTextEditorSlashCommand {
|
|
411
|
-
id: string;
|
|
412
|
-
label: string;
|
|
413
|
-
description?: string;
|
|
414
|
-
icon?: string;
|
|
415
|
-
group?: string;
|
|
416
|
-
run(editor: RichTextEditorInstance, context?: unknown): void;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
export interface RichTextEditorSlashCommands {
|
|
420
|
-
register(command: RichTextEditorSlashCommand): void;
|
|
421
|
-
remove(id: string): void;
|
|
422
|
-
list(): RichTextEditorSlashCommand[];
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
export interface RichTextEditorMentionItem {
|
|
426
|
-
id: string;
|
|
427
|
-
name: string;
|
|
428
|
-
meta?: unknown;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
export interface RichTextEditorMentionProvider {
|
|
432
|
-
trigger: string;
|
|
433
|
-
search(query: string):
|
|
434
|
-
| Promise<RichTextEditorMentionItem[]>
|
|
435
|
-
| RichTextEditorMentionItem[];
|
|
436
|
-
render?(item: RichTextEditorMentionItem): string;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
export interface RichTextEditorMentions {
|
|
440
|
-
register(provider: RichTextEditorMentionProvider): void;
|
|
441
|
-
remove(trigger: string): void;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
export interface RichTextEditorCommentEntry {
|
|
445
|
-
id: string;
|
|
446
|
-
authorId?: string;
|
|
447
|
-
authorName?: string;
|
|
448
|
-
text: string;
|
|
449
|
-
createdAt: number;
|
|
450
|
-
resolved?: boolean;
|
|
451
|
-
parentId?: string;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export interface RichTextEditorComments {
|
|
455
|
-
add(text: string, options?: { authorName?: string }): RichTextEditorCommentEntry;
|
|
456
|
-
reply(parentId: string, text: string, options?: { authorName?: string }): RichTextEditorCommentEntry;
|
|
457
|
-
resolve(id: string): void;
|
|
458
|
-
delete(id: string): void;
|
|
459
|
-
list(): RichTextEditorCommentEntry[];
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
export interface RichTextEditorRestrictedEditingMarkOptions {
|
|
463
|
-
/** Optional aria-label to apply to the new wrapper span. */
|
|
464
|
-
label?: string;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
export interface RichTextEditorRestrictedEditing {
|
|
468
|
-
isEnabled(): boolean;
|
|
469
|
-
enable(): boolean;
|
|
470
|
-
disable(): boolean;
|
|
471
|
-
toggle(): boolean;
|
|
472
|
-
/** Wrap the current selection in a `<span data-rte-editable="true">` so it remains editable when restricted mode is on. */
|
|
473
|
-
markSelection(options?: RichTextEditorRestrictedEditingMarkOptions): Element | null;
|
|
474
|
-
/** Remove the editable wrapper around the given node (or the current selection's wrapper). */
|
|
475
|
-
unmark(node?: Element): boolean;
|
|
476
|
-
list(): Element[];
|
|
477
|
-
/** Move caret to the next editable region (wraps around). */
|
|
478
|
-
goToNext(): Element | null;
|
|
479
|
-
/** Move caret to the previous editable region. */
|
|
480
|
-
goToPrev(): Element | null;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
export interface RichTextEditorDocumentOutlinePanelItem {
|
|
484
|
-
id: string;
|
|
485
|
-
level: number;
|
|
486
|
-
text: string;
|
|
487
|
-
element: Element;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
export interface RichTextEditorDocumentOutlinePanel {
|
|
491
|
-
close(): void;
|
|
492
|
-
list(): RichTextEditorDocumentOutlinePanelItem[];
|
|
493
|
-
open(): void;
|
|
494
|
-
refresh(): void;
|
|
495
|
-
toggle(): void;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
export interface RichTextEditorContentMinimap {
|
|
499
|
-
close(): void;
|
|
500
|
-
isOpen(): boolean;
|
|
501
|
-
open(): void;
|
|
502
|
-
refresh(): void;
|
|
503
|
-
toggle(): void;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
export interface RichTextEditorAccessibilityChecker {
|
|
507
|
-
close(): void;
|
|
508
|
-
getIssues(): RichTextEditorAccessibilityIssue[];
|
|
509
|
-
open(): void;
|
|
510
|
-
refresh(): RichTextEditorAccessibilityResult;
|
|
511
|
-
repair(issueIndex: number, options?: RichTextEditorAccessibilityRepairOptions): RichTextEditorAccessibilityResult;
|
|
512
|
-
run(): RichTextEditorAccessibilityResult;
|
|
513
|
-
toggle(): void;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
export interface RichTextEditorRestrictedEditingRegion {
|
|
517
|
-
id: string;
|
|
518
|
-
label?: string;
|
|
519
|
-
element: Element;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export interface RichTextEditorRestrictedEditingMarkOptions {
|
|
523
|
-
block?: boolean;
|
|
524
|
-
id?: string;
|
|
525
|
-
label?: string;
|
|
526
|
-
placeholder?: string;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
export interface RichTextEditorRestrictedEditing {
|
|
530
|
-
clearSelectionRegion(): boolean;
|
|
531
|
-
disable(): void;
|
|
532
|
-
enable(): void;
|
|
533
|
-
goToNext(): Element | null;
|
|
534
|
-
goToPrevious(): Element | null;
|
|
535
|
-
isEnabled(): boolean;
|
|
536
|
-
list(): RichTextEditorRestrictedEditingRegion[];
|
|
537
|
-
markSelection(options?: RichTextEditorRestrictedEditingMarkOptions): Element | null;
|
|
538
|
-
refresh(): void;
|
|
539
|
-
toggle(): boolean;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
export type RichTextEditorReviewState = "pending" | "accepted" | "rejected" | string;
|
|
543
|
-
|
|
544
|
-
export interface RichTextEditorReviewLedgerEntry {
|
|
545
|
-
id: string;
|
|
546
|
-
state: RichTextEditorReviewState;
|
|
547
|
-
text: string;
|
|
548
|
-
reason?: string;
|
|
549
|
-
createdAt: number;
|
|
550
|
-
metadata?: Record<string, unknown>;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
export interface RichTextEditorReviewLedger {
|
|
554
|
-
add(entry: Omit<RichTextEditorReviewLedgerEntry, "id" | "createdAt"> & { id?: string }): RichTextEditorReviewLedgerEntry;
|
|
555
|
-
update(id: string, patch: Partial<RichTextEditorReviewLedgerEntry>): RichTextEditorReviewLedgerEntry | undefined;
|
|
556
|
-
remove(id: string): void;
|
|
557
|
-
list(state?: RichTextEditorReviewState): RichTextEditorReviewLedgerEntry[];
|
|
558
|
-
get(id: string): RichTextEditorReviewLedgerEntry | undefined;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// =====================
|
|
562
|
-
// Toolbar / dialog factories
|
|
563
|
-
// =====================
|
|
564
|
-
|
|
565
|
-
export interface RichTextEditorToolbarButtonOptions {
|
|
566
|
-
text?: string;
|
|
567
|
-
hint?: string;
|
|
568
|
-
iconUrl?: string;
|
|
569
|
-
shortcut?: string;
|
|
570
|
-
click?(editor: RichTextEditorInstance): void;
|
|
571
|
-
command?: string;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
export interface RichTextEditorToolbarDropDownItem {
|
|
575
|
-
text: string;
|
|
576
|
-
value?: string | number;
|
|
577
|
-
hint?: string;
|
|
578
|
-
className?: string;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
export interface RichTextEditorToolbarDropDownOptions {
|
|
582
|
-
width?: string | number;
|
|
583
|
-
items: RichTextEditorToolbarDropDownItem[];
|
|
584
|
-
onSelect?(value: string | number, item: RichTextEditorToolbarDropDownItem): void;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
export interface RichTextEditorDialogOptions {
|
|
588
|
-
title?: string;
|
|
589
|
-
width?: string | number;
|
|
590
|
-
height?: string | number;
|
|
591
|
-
/** Inner HTML for the dialog body (alternative to `html`). */
|
|
592
|
-
body?: string;
|
|
593
|
-
html?: string;
|
|
594
|
-
/** Buttons rendered in the dialog footer. Defaults to OK / Cancel when omitted. */
|
|
595
|
-
buttons?: Array<{
|
|
596
|
-
text: string;
|
|
597
|
-
isDefault?: boolean;
|
|
598
|
-
isCancel?: boolean;
|
|
599
|
-
click?(): void;
|
|
600
|
-
}>;
|
|
601
|
-
onClose?(): void;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
// =====================
|
|
605
|
-
// Events
|
|
606
|
-
// =====================
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* Built-in editor events. Custom events fired by plugins are also valid
|
|
610
|
-
* (matched by the `string` fallback).
|
|
611
|
-
*
|
|
612
|
-
* - `change` — fired after editable content changes (content edits, paste,
|
|
613
|
-
* undo/redo, AI replacement). Handler signature: `() => void`.
|
|
614
|
-
* - `selectionchange` — fired after the selection moves (caret move, range
|
|
615
|
-
* change, control selection). Handler signature: `() => void`.
|
|
616
|
-
* - `exec_command` — fired when a toolbar / shortcut command runs. Handler
|
|
617
|
-
* signature: `(commandName: string, value?: unknown) => void`.
|
|
618
|
-
* - `change_html_view` — fired when the editor toggles between Design and
|
|
619
|
-
* HTML/source modes. Handler signature: `(isHtmlView: boolean) => void`.
|
|
620
|
-
* - `keydown` / `keyup` / `keypress` — pass-through of editable keyboard
|
|
621
|
-
* events. Handler signature: `(event: KeyboardEvent) => void`.
|
|
622
|
-
* - `focus` / `blur` — editable focus / blur. Handler signature:
|
|
623
|
-
* `(event: FocusEvent) => void`.
|
|
624
|
-
*/
|
|
625
|
-
export type RichTextEditorEventName =
|
|
626
|
-
| "change"
|
|
627
|
-
| "selectionchange"
|
|
628
|
-
| "exec_command"
|
|
629
|
-
| "change_html_view"
|
|
630
|
-
| "keydown" | "keyup" | "keypress"
|
|
631
|
-
| "focus" | "blur"
|
|
632
|
-
// Reserved for the AI toolkit — not yet emitted by the current build.
|
|
633
|
-
| "ai_request" | "ai_response" | "ai_review_added" | "ai_review_resolved"
|
|
634
|
-
| "comment_added" | "comment_resolved"
|
|
635
|
-
| "revision_snapshot"
|
|
636
|
-
| "charlimit" | "commentsonlychanged" | "contentchange" | "resize" | "customdialog"
|
|
637
|
-
| string;
|
|
638
|
-
|
|
639
|
-
export type RichTextEditorEventHandler = (...args: any[]) => void;
|
|
640
|
-
|
|
641
|
-
// =====================
|
|
642
|
-
// Editor instance
|
|
643
|
-
// =====================
|
|
644
|
-
|
|
645
|
-
export interface RichTextEditorReadabilityStats {
|
|
646
|
-
words: number;
|
|
647
|
-
sentences: number;
|
|
648
|
-
syllables: number;
|
|
649
|
-
characters: number;
|
|
650
|
-
avgWordsPerSentence: number;
|
|
651
|
-
avgSyllablesPerWord: number;
|
|
652
|
-
/** Flesch Reading Ease (higher = easier; ~0–100 typical). */
|
|
653
|
-
fleschReadingEase: number;
|
|
654
|
-
/** Flesch–Kincaid US grade level (clamped at 0). */
|
|
655
|
-
fleschKincaidGrade: number;
|
|
656
|
-
readingTimeMinutes: number;
|
|
657
|
-
/** Human-readable reading time, e.g. "3 min" or "20 sec". */
|
|
658
|
-
readingTimeText: string;
|
|
659
|
-
/** Plain-language interpretation of the reading-ease score. */
|
|
660
|
-
easeLabel: string;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
export interface RichTextEditorImportOptions {
|
|
664
|
-
/** `replace` (default) swaps the whole document; `insert` adds at the caret. */
|
|
665
|
-
mode?: "replace" | "insert";
|
|
666
|
-
/** `accept` attribute for the file picker (default `.md,.markdown,.html,.htm,.txt,.doc,.docx`). */
|
|
667
|
-
accept?: string;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
export interface RichTextEditorWordExportOptions {
|
|
671
|
-
/** Document title (defaults to the first heading). */
|
|
672
|
-
title?: string;
|
|
673
|
-
/** Body font-family (default `"Calibri, 'Segoe UI', Arial, sans-serif"`). */
|
|
674
|
-
fontFamily?: string;
|
|
675
|
-
/** Body font-size (default `"11pt"`). */
|
|
676
|
-
fontSize?: string;
|
|
677
|
-
/** `@page` size (default `"8.5in 11in"`). */
|
|
678
|
-
pageSize?: string;
|
|
679
|
-
/** `@page` margin (default `"1in"`). */
|
|
680
|
-
margin?: string;
|
|
681
|
-
/** Landscape orientation (default `false`). */
|
|
682
|
-
landscape?: boolean;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
/**
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
delete
|
|
937
|
-
|
|
938
|
-
/**
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
|
|
942
|
-
/**
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
/**
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
/**
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
/**
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
/**
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
/**
|
|
1137
|
-
|
|
1138
|
-
/**
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
// ----
|
|
1142
|
-
/**
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
/**
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
/**
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
/**
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
/**
|
|
1244
|
-
|
|
1245
|
-
/**
|
|
1246
|
-
|
|
1247
|
-
/**
|
|
1248
|
-
|
|
1249
|
-
/**
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
/**
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
/**
|
|
1270
|
-
|
|
1271
|
-
/**
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
|
|
1285
|
-
/**
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
):
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
/**
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
):
|
|
1397
|
-
/**
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1
|
+
// Type definitions for richtexteditor 2.x
|
|
2
|
+
// Project: https://richtexteditor.com
|
|
3
|
+
//
|
|
4
|
+
// These declarations cover the public surface documented at
|
|
5
|
+
// https://richtexteditor.com/docs and exercised by the React / Vue
|
|
6
|
+
// wrappers in this package. The editor itself is shipped as a single
|
|
7
|
+
// bundle (`richtexteditor/rte.js`) that attaches `RichTextEditor` to
|
|
8
|
+
// the global scope; the typings below describe both the constructor
|
|
9
|
+
// and the per-instance methods.
|
|
10
|
+
|
|
11
|
+
// =====================
|
|
12
|
+
// Structured content (JSON / Markdown)
|
|
13
|
+
// =====================
|
|
14
|
+
|
|
15
|
+
export type RichTextEditorValueFormat = "html" | "json";
|
|
16
|
+
|
|
17
|
+
export interface RichTextEditorStructuredMark {
|
|
18
|
+
type: string;
|
|
19
|
+
attrs?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RichTextEditorPageMargins {
|
|
23
|
+
top?: string;
|
|
24
|
+
right?: string;
|
|
25
|
+
bottom?: string;
|
|
26
|
+
left?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface RichTextEditorPageSetup {
|
|
30
|
+
format?: string;
|
|
31
|
+
orientation?: "portrait" | "landscape";
|
|
32
|
+
width?: string;
|
|
33
|
+
height?: string;
|
|
34
|
+
margins?: RichTextEditorPageMargins;
|
|
35
|
+
headerHtml?: string;
|
|
36
|
+
footerHtml?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface RichTextEditorStructuredDocumentAttributes {
|
|
40
|
+
pageSetup?: RichTextEditorPageSetup;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RichTextEditorStructuredDocument {
|
|
45
|
+
type: "doc";
|
|
46
|
+
version: number;
|
|
47
|
+
format: string;
|
|
48
|
+
attrs?: RichTextEditorStructuredDocumentAttributes;
|
|
49
|
+
html?: string;
|
|
50
|
+
text?: string;
|
|
51
|
+
content?: RichTextEditorStructuredNode[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface RichTextEditorStructuredNode {
|
|
55
|
+
type: string;
|
|
56
|
+
attrs?: Record<string, unknown>;
|
|
57
|
+
content?: RichTextEditorStructuredNode[];
|
|
58
|
+
html?: string;
|
|
59
|
+
marks?: RichTextEditorStructuredMark[];
|
|
60
|
+
text?: string;
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface RichTextEditorStructuredContentLike {
|
|
65
|
+
html?: string;
|
|
66
|
+
content?: RichTextEditorStructuredNode | RichTextEditorStructuredNode[];
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface RichTextEditorValidationIssue {
|
|
71
|
+
message: string;
|
|
72
|
+
path: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface RichTextEditorValidationResult {
|
|
76
|
+
document: RichTextEditorStructuredDocument;
|
|
77
|
+
issues: RichTextEditorValidationIssue[];
|
|
78
|
+
valid: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type RichTextEditorAccessibilitySeverity = "error" | "warning";
|
|
82
|
+
|
|
83
|
+
export interface RichTextEditorAccessibilityIssue {
|
|
84
|
+
code: string;
|
|
85
|
+
message: string;
|
|
86
|
+
path: string;
|
|
87
|
+
severity: RichTextEditorAccessibilitySeverity;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface RichTextEditorAccessibilityRepairOptions {
|
|
91
|
+
altText?: string;
|
|
92
|
+
headingText?: string;
|
|
93
|
+
targetLevel?: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface RichTextEditorAccessibilityResult {
|
|
97
|
+
document: RichTextEditorStructuredDocument;
|
|
98
|
+
issues: RichTextEditorAccessibilityIssue[];
|
|
99
|
+
valid: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type RichTextEditorLinkAuditSeverity = "error" | "warning";
|
|
103
|
+
|
|
104
|
+
export interface RichTextEditorLinkAuditIssue {
|
|
105
|
+
code: string;
|
|
106
|
+
href?: string;
|
|
107
|
+
message: string;
|
|
108
|
+
path: string;
|
|
109
|
+
severity: RichTextEditorLinkAuditSeverity;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface RichTextEditorLinkAuditOptions {
|
|
113
|
+
allowedDomains?: string[];
|
|
114
|
+
allowedProtocols?: string[];
|
|
115
|
+
flagNewWindowWithoutRel?: boolean;
|
|
116
|
+
requireHttps?: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface RichTextEditorLinkAuditResult {
|
|
120
|
+
document: RichTextEditorStructuredDocument;
|
|
121
|
+
issues: RichTextEditorLinkAuditIssue[];
|
|
122
|
+
valid: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface RichTextEditorTextStatistics {
|
|
126
|
+
characters: number;
|
|
127
|
+
charactersNoSpaces: number;
|
|
128
|
+
words: number;
|
|
129
|
+
selectedCharacters: number;
|
|
130
|
+
selectedCharactersNoSpaces: number;
|
|
131
|
+
selectedWords: number;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface RichTextEditorDocumentMetrics extends RichTextEditorTextStatistics {
|
|
135
|
+
paragraphs: number;
|
|
136
|
+
sentences: number;
|
|
137
|
+
headings: number;
|
|
138
|
+
images: number;
|
|
139
|
+
tables: number;
|
|
140
|
+
links: number;
|
|
141
|
+
estimatedReadingMinutes: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface RichTextEditorDocumentOutlineItem {
|
|
145
|
+
id: string;
|
|
146
|
+
level: number;
|
|
147
|
+
path: string;
|
|
148
|
+
text: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface RichTextEditorTableOfContentsItem extends RichTextEditorDocumentOutlineItem {
|
|
152
|
+
itemIndex?: number;
|
|
153
|
+
indexLabel?: string;
|
|
154
|
+
children: RichTextEditorTableOfContentsItem[];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface RichTextEditorFootnoteItem {
|
|
158
|
+
id: string;
|
|
159
|
+
number: number;
|
|
160
|
+
path: string;
|
|
161
|
+
refId: string;
|
|
162
|
+
text: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface RichTextEditorTableOfContentsOptions {
|
|
166
|
+
minLevel?: number;
|
|
167
|
+
maxLevel?: number;
|
|
168
|
+
indexMode?: "none" | "linear" | "hierarchical";
|
|
169
|
+
title?: string;
|
|
170
|
+
includeTitle?: boolean;
|
|
171
|
+
ordered?: boolean;
|
|
172
|
+
orderedListType?: "1" | "A" | "a" | "I" | "i";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type RichTextEditorStructuredInput =
|
|
176
|
+
| string
|
|
177
|
+
| RichTextEditorStructuredDocument
|
|
178
|
+
| RichTextEditorStructuredContentLike;
|
|
179
|
+
|
|
180
|
+
// =====================
|
|
181
|
+
// Commands
|
|
182
|
+
// =====================
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Built-in command identifiers accepted by execCommand / isCommandEnabled /
|
|
186
|
+
* isCommandActive. The list is intentionally non-exhaustive — custom commands
|
|
187
|
+
* registered via createToolbarButton are also valid execCommand inputs, hence
|
|
188
|
+
* the `string` fallback.
|
|
189
|
+
*/
|
|
190
|
+
export type RichTextEditorCommand =
|
|
191
|
+
| "bold" | "italic" | "underline" | "strikethrough" | "subscript" | "superscript"
|
|
192
|
+
| "fontname" | "fontsize" | "forecolor" | "backcolor" | "removeformat"
|
|
193
|
+
| "justifyleft" | "justifycenter" | "justifyright" | "justifyfull"
|
|
194
|
+
| "indent" | "outdent" | "insertorderedlist" | "insertunorderedlist"
|
|
195
|
+
| "insertimage" | "insertlink" | "unlink" | "inserthorizontalrule" | "insertpagebreak"
|
|
196
|
+
| "inserttable" | "insertrowbefore" | "insertrowafter"
|
|
197
|
+
| "insertcolumnbefore" | "insertcolumnafter" | "deleterow" | "deletecolumn" | "deletetable"
|
|
198
|
+
| "undo" | "redo" | "selectall" | "copy" | "cut" | "paste"
|
|
199
|
+
| "ucase" | "lcase" | "titlecase"
|
|
200
|
+
| "source" | "fullscreen" | "preview" | "print"
|
|
201
|
+
| "pastetext" | "pastefromword"
|
|
202
|
+
| "paragraph" | "heading"
|
|
203
|
+
| "documentoutline"
|
|
204
|
+
| "contentminimap"
|
|
205
|
+
| "accessibilitychecker"
|
|
206
|
+
| "ai-ask" | "ai-chat" | "ai-review" | "ai-export-docx" | "ai-import-docx"
|
|
207
|
+
| "dictation-toggle"
|
|
208
|
+
// Modern block types (2.3.0) — backed by the blocktypes plugin.
|
|
209
|
+
| "insertcallout" | "insertcolumns" | "inserttoggle"
|
|
210
|
+
// Interactive to-do / task list (2.3.0) — backed by the todolist plugin.
|
|
211
|
+
| "inserttodolist"
|
|
212
|
+
// Equation editor (2.3.0) — backed by the mathdialog plugin.
|
|
213
|
+
| "insertmath"
|
|
214
|
+
// Mermaid diagram (2.3.0) — backed by the mermaiddiagram plugin.
|
|
215
|
+
| "insertdiagram"
|
|
216
|
+
// Bookmark preview card (2.3.0) — backed by the bookmarkcard plugin.
|
|
217
|
+
| "insertbookmark"
|
|
218
|
+
// Spell check (2.3.0) — backed by the spellcheck plugin.
|
|
219
|
+
| "spellcheck"
|
|
220
|
+
// Smart chips (2.3.0) — backed by the smartchips plugin.
|
|
221
|
+
| "insertdatechip" | "insertchip"
|
|
222
|
+
// Email toolkit (2.3.0) — backed by the emailtoolkit plugin.
|
|
223
|
+
| "emailexport"
|
|
224
|
+
// Read-aloud / text-to-speech (2.3.0) — backed by the readaloud plugin.
|
|
225
|
+
| "readaloud"
|
|
226
|
+
| string;
|
|
227
|
+
|
|
228
|
+
// =====================
|
|
229
|
+
// Selection
|
|
230
|
+
// =====================
|
|
231
|
+
|
|
232
|
+
export interface RichTextEditorSelection {
|
|
233
|
+
/** The native Range, when one is available. */
|
|
234
|
+
range?: Range;
|
|
235
|
+
/** The selected control element (image / table / hr) or null for caret/text selections. */
|
|
236
|
+
control?: Element | null;
|
|
237
|
+
/** Whether the selection is collapsed (no range / caret only). */
|
|
238
|
+
isCollapsed: boolean;
|
|
239
|
+
/** Whether the selection covers the entire document. */
|
|
240
|
+
isAll?: boolean;
|
|
241
|
+
[key: string]: unknown;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// =====================
|
|
245
|
+
// AI Toolkit (v2.0)
|
|
246
|
+
// =====================
|
|
247
|
+
|
|
248
|
+
export type RichTextEditorAiOperationType =
|
|
249
|
+
| "preview-suggestion"
|
|
250
|
+
| "replace-document"
|
|
251
|
+
| "insert-below"
|
|
252
|
+
| "add-comment"
|
|
253
|
+
| string;
|
|
254
|
+
|
|
255
|
+
export interface RichTextEditorAiOperation {
|
|
256
|
+
type: RichTextEditorAiOperationType;
|
|
257
|
+
text: string;
|
|
258
|
+
reason?: string;
|
|
259
|
+
[key: string]: unknown;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface RichTextEditorAiResponse {
|
|
263
|
+
sourceLabel?: string;
|
|
264
|
+
reason?: string;
|
|
265
|
+
message?: string;
|
|
266
|
+
result?: string;
|
|
267
|
+
operations?: RichTextEditorAiOperation[];
|
|
268
|
+
[key: string]: unknown;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface RichTextEditorAiRequest {
|
|
272
|
+
mode: string;
|
|
273
|
+
prompt?: string;
|
|
274
|
+
source?: string;
|
|
275
|
+
selectionText?: string;
|
|
276
|
+
documentText?: string;
|
|
277
|
+
hasSelection?: boolean;
|
|
278
|
+
language?: string;
|
|
279
|
+
[key: string]: unknown;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface RichTextEditorAiStreamHandle {
|
|
283
|
+
abort(): void;
|
|
284
|
+
promise?: Promise<RichTextEditorAiResponse | undefined>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface RichTextEditorAiStreamRequestOptions {
|
|
288
|
+
url: string;
|
|
289
|
+
body: Record<string, unknown>;
|
|
290
|
+
headers?: Record<string, string>;
|
|
291
|
+
onDelta?(delta: string, accumulated: string): void;
|
|
292
|
+
onResponse?(response: RichTextEditorAiResponse): void;
|
|
293
|
+
onDone?(text: string): void;
|
|
294
|
+
onError?(error: Error): void;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface RichTextEditorAiExportDocxOptions {
|
|
298
|
+
filename?: string;
|
|
299
|
+
fileName?: string;
|
|
300
|
+
title?: string;
|
|
301
|
+
url?: string;
|
|
302
|
+
download?: boolean;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface RichTextEditorAiImportDocxOptions {
|
|
306
|
+
file?: Blob | File | null;
|
|
307
|
+
filename?: string;
|
|
308
|
+
fileName?: string;
|
|
309
|
+
url?: string;
|
|
310
|
+
apply?: boolean;
|
|
311
|
+
mode?: "replace" | "insert";
|
|
312
|
+
onError?(error: Error): void;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface RichTextEditorAiToolkit {
|
|
316
|
+
setResolver(
|
|
317
|
+
resolver: (request: RichTextEditorAiRequest) => Promise<RichTextEditorAiResponse> | RichTextEditorAiResponse,
|
|
318
|
+
): void;
|
|
319
|
+
openDialog(options?: { presetMode?: string; prompt?: string }): void;
|
|
320
|
+
openChatPanel(options?: { focusComposer?: boolean }): void;
|
|
321
|
+
openReviewPanel(): void;
|
|
322
|
+
runQuickAction(mode: string, options?: Record<string, unknown>): Promise<RichTextEditorAiResponse | undefined>;
|
|
323
|
+
streamRequest(options: RichTextEditorAiStreamRequestOptions): RichTextEditorAiStreamHandle;
|
|
324
|
+
exportDocx(options?: RichTextEditorAiExportDocxOptions): Promise<Blob | undefined>;
|
|
325
|
+
importDocx(options?: RichTextEditorAiImportDocxOptions): Promise<string | undefined>;
|
|
326
|
+
refreshRemoteReviewState?(force?: boolean): Promise<void>;
|
|
327
|
+
acceptInline?(text: string): void;
|
|
328
|
+
rejectInline?(): void;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// =====================
|
|
332
|
+
// Dictation
|
|
333
|
+
// =====================
|
|
334
|
+
|
|
335
|
+
export interface RichTextEditorDictation {
|
|
336
|
+
isSupported(): boolean;
|
|
337
|
+
isListening(): boolean;
|
|
338
|
+
start(options?: { language?: string; continuous?: boolean }): void;
|
|
339
|
+
stop(): void;
|
|
340
|
+
toggle(options?: { language?: string }): void;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// =====================
|
|
344
|
+
// Revision history
|
|
345
|
+
// =====================
|
|
346
|
+
|
|
347
|
+
export interface RichTextEditorRevisionEntry {
|
|
348
|
+
id: string;
|
|
349
|
+
name?: string;
|
|
350
|
+
createdAt: number;
|
|
351
|
+
html: string;
|
|
352
|
+
authorId?: string;
|
|
353
|
+
authorName?: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface RichTextEditorRevisionDiff {
|
|
357
|
+
oldHtml: string;
|
|
358
|
+
newHtml: string;
|
|
359
|
+
unifiedDiff?: string;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export interface RichTextEditorRevisionHistory {
|
|
363
|
+
snapshot(name?: string): RichTextEditorRevisionEntry;
|
|
364
|
+
promptAndSnapshot(): Promise<RichTextEditorRevisionEntry | undefined>;
|
|
365
|
+
rename(id: string, name: string): void;
|
|
366
|
+
list(): RichTextEditorRevisionEntry[];
|
|
367
|
+
listNamed(): RichTextEditorRevisionEntry[];
|
|
368
|
+
diff(idA: string, idB: string): RichTextEditorRevisionDiff;
|
|
369
|
+
restore(id: string): void;
|
|
370
|
+
remove(id: string): void;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// =====================
|
|
374
|
+
// Yjs collab
|
|
375
|
+
// =====================
|
|
376
|
+
|
|
377
|
+
export interface RichTextEditorCollabAttachOptions {
|
|
378
|
+
doc: unknown;
|
|
379
|
+
provider: unknown;
|
|
380
|
+
textSync?: boolean;
|
|
381
|
+
awareness?: unknown;
|
|
382
|
+
fragmentName?: string;
|
|
383
|
+
/**
|
|
384
|
+
* The Yjs module (the `* as Y` namespace). REQUIRED to be the SAME Yjs
|
|
385
|
+
* instance that created `doc` and backs `provider` whenever the editor can't
|
|
386
|
+
* find it on `window.Y`. The CRDT engine builds document nodes with this
|
|
387
|
+
* module; mixing two Yjs copies throws "Unexpected content type in insert
|
|
388
|
+
* operation" and silently breaks text sync (yjs issue #438).
|
|
389
|
+
*/
|
|
390
|
+
Y?: unknown;
|
|
391
|
+
/**
|
|
392
|
+
* When attaching to an EMPTY shared document, seed it from the editor's
|
|
393
|
+
* current content (first-writer) instead of clearing the editor. Default
|
|
394
|
+
* `true`. Set `false` to always let the shared document win (the editor is
|
|
395
|
+
* cleared if the shared doc is empty). Reconciliation waits for the
|
|
396
|
+
* provider's initial sync so it never clobbers not-yet-synced remote state.
|
|
397
|
+
*/
|
|
398
|
+
seedFromHost?: boolean;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export interface RichTextEditorCollab {
|
|
402
|
+
attach(options: RichTextEditorCollabAttachOptions): void;
|
|
403
|
+
detach(): void;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// =====================
|
|
407
|
+
// Slash commands / mentions / comments / review ledger
|
|
408
|
+
// =====================
|
|
409
|
+
|
|
410
|
+
export interface RichTextEditorSlashCommand {
|
|
411
|
+
id: string;
|
|
412
|
+
label: string;
|
|
413
|
+
description?: string;
|
|
414
|
+
icon?: string;
|
|
415
|
+
group?: string;
|
|
416
|
+
run(editor: RichTextEditorInstance, context?: unknown): void;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export interface RichTextEditorSlashCommands {
|
|
420
|
+
register(command: RichTextEditorSlashCommand): void;
|
|
421
|
+
remove(id: string): void;
|
|
422
|
+
list(): RichTextEditorSlashCommand[];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export interface RichTextEditorMentionItem {
|
|
426
|
+
id: string;
|
|
427
|
+
name: string;
|
|
428
|
+
meta?: unknown;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface RichTextEditorMentionProvider {
|
|
432
|
+
trigger: string;
|
|
433
|
+
search(query: string):
|
|
434
|
+
| Promise<RichTextEditorMentionItem[]>
|
|
435
|
+
| RichTextEditorMentionItem[];
|
|
436
|
+
render?(item: RichTextEditorMentionItem): string;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface RichTextEditorMentions {
|
|
440
|
+
register(provider: RichTextEditorMentionProvider): void;
|
|
441
|
+
remove(trigger: string): void;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export interface RichTextEditorCommentEntry {
|
|
445
|
+
id: string;
|
|
446
|
+
authorId?: string;
|
|
447
|
+
authorName?: string;
|
|
448
|
+
text: string;
|
|
449
|
+
createdAt: number;
|
|
450
|
+
resolved?: boolean;
|
|
451
|
+
parentId?: string;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface RichTextEditorComments {
|
|
455
|
+
add(text: string, options?: { authorName?: string }): RichTextEditorCommentEntry;
|
|
456
|
+
reply(parentId: string, text: string, options?: { authorName?: string }): RichTextEditorCommentEntry;
|
|
457
|
+
resolve(id: string): void;
|
|
458
|
+
delete(id: string): void;
|
|
459
|
+
list(): RichTextEditorCommentEntry[];
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export interface RichTextEditorRestrictedEditingMarkOptions {
|
|
463
|
+
/** Optional aria-label to apply to the new wrapper span. */
|
|
464
|
+
label?: string;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export interface RichTextEditorRestrictedEditing {
|
|
468
|
+
isEnabled(): boolean;
|
|
469
|
+
enable(): boolean;
|
|
470
|
+
disable(): boolean;
|
|
471
|
+
toggle(): boolean;
|
|
472
|
+
/** Wrap the current selection in a `<span data-rte-editable="true">` so it remains editable when restricted mode is on. */
|
|
473
|
+
markSelection(options?: RichTextEditorRestrictedEditingMarkOptions): Element | null;
|
|
474
|
+
/** Remove the editable wrapper around the given node (or the current selection's wrapper). */
|
|
475
|
+
unmark(node?: Element): boolean;
|
|
476
|
+
list(): Element[];
|
|
477
|
+
/** Move caret to the next editable region (wraps around). */
|
|
478
|
+
goToNext(): Element | null;
|
|
479
|
+
/** Move caret to the previous editable region. */
|
|
480
|
+
goToPrev(): Element | null;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export interface RichTextEditorDocumentOutlinePanelItem {
|
|
484
|
+
id: string;
|
|
485
|
+
level: number;
|
|
486
|
+
text: string;
|
|
487
|
+
element: Element;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface RichTextEditorDocumentOutlinePanel {
|
|
491
|
+
close(): void;
|
|
492
|
+
list(): RichTextEditorDocumentOutlinePanelItem[];
|
|
493
|
+
open(): void;
|
|
494
|
+
refresh(): void;
|
|
495
|
+
toggle(): void;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export interface RichTextEditorContentMinimap {
|
|
499
|
+
close(): void;
|
|
500
|
+
isOpen(): boolean;
|
|
501
|
+
open(): void;
|
|
502
|
+
refresh(): void;
|
|
503
|
+
toggle(): void;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface RichTextEditorAccessibilityChecker {
|
|
507
|
+
close(): void;
|
|
508
|
+
getIssues(): RichTextEditorAccessibilityIssue[];
|
|
509
|
+
open(): void;
|
|
510
|
+
refresh(): RichTextEditorAccessibilityResult;
|
|
511
|
+
repair(issueIndex: number, options?: RichTextEditorAccessibilityRepairOptions): RichTextEditorAccessibilityResult;
|
|
512
|
+
run(): RichTextEditorAccessibilityResult;
|
|
513
|
+
toggle(): void;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export interface RichTextEditorRestrictedEditingRegion {
|
|
517
|
+
id: string;
|
|
518
|
+
label?: string;
|
|
519
|
+
element: Element;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export interface RichTextEditorRestrictedEditingMarkOptions {
|
|
523
|
+
block?: boolean;
|
|
524
|
+
id?: string;
|
|
525
|
+
label?: string;
|
|
526
|
+
placeholder?: string;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export interface RichTextEditorRestrictedEditing {
|
|
530
|
+
clearSelectionRegion(): boolean;
|
|
531
|
+
disable(): void;
|
|
532
|
+
enable(): void;
|
|
533
|
+
goToNext(): Element | null;
|
|
534
|
+
goToPrevious(): Element | null;
|
|
535
|
+
isEnabled(): boolean;
|
|
536
|
+
list(): RichTextEditorRestrictedEditingRegion[];
|
|
537
|
+
markSelection(options?: RichTextEditorRestrictedEditingMarkOptions): Element | null;
|
|
538
|
+
refresh(): void;
|
|
539
|
+
toggle(): boolean;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export type RichTextEditorReviewState = "pending" | "accepted" | "rejected" | string;
|
|
543
|
+
|
|
544
|
+
export interface RichTextEditorReviewLedgerEntry {
|
|
545
|
+
id: string;
|
|
546
|
+
state: RichTextEditorReviewState;
|
|
547
|
+
text: string;
|
|
548
|
+
reason?: string;
|
|
549
|
+
createdAt: number;
|
|
550
|
+
metadata?: Record<string, unknown>;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export interface RichTextEditorReviewLedger {
|
|
554
|
+
add(entry: Omit<RichTextEditorReviewLedgerEntry, "id" | "createdAt"> & { id?: string }): RichTextEditorReviewLedgerEntry;
|
|
555
|
+
update(id: string, patch: Partial<RichTextEditorReviewLedgerEntry>): RichTextEditorReviewLedgerEntry | undefined;
|
|
556
|
+
remove(id: string): void;
|
|
557
|
+
list(state?: RichTextEditorReviewState): RichTextEditorReviewLedgerEntry[];
|
|
558
|
+
get(id: string): RichTextEditorReviewLedgerEntry | undefined;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// =====================
|
|
562
|
+
// Toolbar / dialog factories
|
|
563
|
+
// =====================
|
|
564
|
+
|
|
565
|
+
export interface RichTextEditorToolbarButtonOptions {
|
|
566
|
+
text?: string;
|
|
567
|
+
hint?: string;
|
|
568
|
+
iconUrl?: string;
|
|
569
|
+
shortcut?: string;
|
|
570
|
+
click?(editor: RichTextEditorInstance): void;
|
|
571
|
+
command?: string;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
export interface RichTextEditorToolbarDropDownItem {
|
|
575
|
+
text: string;
|
|
576
|
+
value?: string | number;
|
|
577
|
+
hint?: string;
|
|
578
|
+
className?: string;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export interface RichTextEditorToolbarDropDownOptions {
|
|
582
|
+
width?: string | number;
|
|
583
|
+
items: RichTextEditorToolbarDropDownItem[];
|
|
584
|
+
onSelect?(value: string | number, item: RichTextEditorToolbarDropDownItem): void;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export interface RichTextEditorDialogOptions {
|
|
588
|
+
title?: string;
|
|
589
|
+
width?: string | number;
|
|
590
|
+
height?: string | number;
|
|
591
|
+
/** Inner HTML for the dialog body (alternative to `html`). */
|
|
592
|
+
body?: string;
|
|
593
|
+
html?: string;
|
|
594
|
+
/** Buttons rendered in the dialog footer. Defaults to OK / Cancel when omitted. */
|
|
595
|
+
buttons?: Array<{
|
|
596
|
+
text: string;
|
|
597
|
+
isDefault?: boolean;
|
|
598
|
+
isCancel?: boolean;
|
|
599
|
+
click?(): void;
|
|
600
|
+
}>;
|
|
601
|
+
onClose?(): void;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// =====================
|
|
605
|
+
// Events
|
|
606
|
+
// =====================
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Built-in editor events. Custom events fired by plugins are also valid
|
|
610
|
+
* (matched by the `string` fallback).
|
|
611
|
+
*
|
|
612
|
+
* - `change` — fired after editable content changes (content edits, paste,
|
|
613
|
+
* undo/redo, AI replacement). Handler signature: `() => void`.
|
|
614
|
+
* - `selectionchange` — fired after the selection moves (caret move, range
|
|
615
|
+
* change, control selection). Handler signature: `() => void`.
|
|
616
|
+
* - `exec_command` — fired when a toolbar / shortcut command runs. Handler
|
|
617
|
+
* signature: `(commandName: string, value?: unknown) => void`.
|
|
618
|
+
* - `change_html_view` — fired when the editor toggles between Design and
|
|
619
|
+
* HTML/source modes. Handler signature: `(isHtmlView: boolean) => void`.
|
|
620
|
+
* - `keydown` / `keyup` / `keypress` — pass-through of editable keyboard
|
|
621
|
+
* events. Handler signature: `(event: KeyboardEvent) => void`.
|
|
622
|
+
* - `focus` / `blur` — editable focus / blur. Handler signature:
|
|
623
|
+
* `(event: FocusEvent) => void`.
|
|
624
|
+
*/
|
|
625
|
+
export type RichTextEditorEventName =
|
|
626
|
+
| "change"
|
|
627
|
+
| "selectionchange"
|
|
628
|
+
| "exec_command"
|
|
629
|
+
| "change_html_view"
|
|
630
|
+
| "keydown" | "keyup" | "keypress"
|
|
631
|
+
| "focus" | "blur"
|
|
632
|
+
// Reserved for the AI toolkit — not yet emitted by the current build.
|
|
633
|
+
| "ai_request" | "ai_response" | "ai_review_added" | "ai_review_resolved"
|
|
634
|
+
| "comment_added" | "comment_resolved"
|
|
635
|
+
| "revision_snapshot"
|
|
636
|
+
| "charlimit" | "commentsonlychanged" | "contentchange" | "resize" | "customdialog"
|
|
637
|
+
| string;
|
|
638
|
+
|
|
639
|
+
export type RichTextEditorEventHandler = (...args: any[]) => void;
|
|
640
|
+
|
|
641
|
+
// =====================
|
|
642
|
+
// Editor instance
|
|
643
|
+
// =====================
|
|
644
|
+
|
|
645
|
+
export interface RichTextEditorReadabilityStats {
|
|
646
|
+
words: number;
|
|
647
|
+
sentences: number;
|
|
648
|
+
syllables: number;
|
|
649
|
+
characters: number;
|
|
650
|
+
avgWordsPerSentence: number;
|
|
651
|
+
avgSyllablesPerWord: number;
|
|
652
|
+
/** Flesch Reading Ease (higher = easier; ~0–100 typical). */
|
|
653
|
+
fleschReadingEase: number;
|
|
654
|
+
/** Flesch–Kincaid US grade level (clamped at 0). */
|
|
655
|
+
fleschKincaidGrade: number;
|
|
656
|
+
readingTimeMinutes: number;
|
|
657
|
+
/** Human-readable reading time, e.g. "3 min" or "20 sec". */
|
|
658
|
+
readingTimeText: string;
|
|
659
|
+
/** Plain-language interpretation of the reading-ease score. */
|
|
660
|
+
easeLabel: string;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export interface RichTextEditorImportOptions {
|
|
664
|
+
/** `replace` (default) swaps the whole document; `insert` adds at the caret. */
|
|
665
|
+
mode?: "replace" | "insert";
|
|
666
|
+
/** `accept` attribute for the file picker (default `.md,.markdown,.html,.htm,.txt,.doc,.docx`). */
|
|
667
|
+
accept?: string;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
export interface RichTextEditorWordExportOptions {
|
|
671
|
+
/** Document title (defaults to the first heading). */
|
|
672
|
+
title?: string;
|
|
673
|
+
/** Body font-family (default `"Calibri, 'Segoe UI', Arial, sans-serif"`). */
|
|
674
|
+
fontFamily?: string;
|
|
675
|
+
/** Body font-size (default `"11pt"`). */
|
|
676
|
+
fontSize?: string;
|
|
677
|
+
/** `@page` size (default `"8.5in 11in"`). */
|
|
678
|
+
pageSize?: string;
|
|
679
|
+
/** `@page` margin (default `"1in"`). */
|
|
680
|
+
margin?: string;
|
|
681
|
+
/** Landscape orientation (default `false`). */
|
|
682
|
+
landscape?: boolean;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// =====================
|
|
686
|
+
// Autocorrect, sanitiser, shadow DOM, imported styles
|
|
687
|
+
// (autocorrect, sanitizer, shadowdom, importstyles). Shapes read from a live editor.
|
|
688
|
+
// =====================
|
|
689
|
+
|
|
690
|
+
/** Misspelling -> replacement, e.g. `{ teh: "the" }`. */
|
|
691
|
+
export type RichTextEditorAutocorrectRules = Record<string, string>;
|
|
692
|
+
|
|
693
|
+
export interface RichTextEditorSanitizerReport {
|
|
694
|
+
removedTags: Record<string, number> | string[];
|
|
695
|
+
removedAttributes: Record<string, number> | string[];
|
|
696
|
+
/** How many times the sanitiser has run. */
|
|
697
|
+
calls: number;
|
|
698
|
+
lastPasses: number;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// =====================
|
|
702
|
+
// Tables, links, languages, pen, drag handle
|
|
703
|
+
// (layouttable, tabletools, linkchecker, textpartlanguage, permanentpen, draghandle, rtlui).
|
|
704
|
+
// Shapes read from a live editor.
|
|
705
|
+
// =====================
|
|
706
|
+
|
|
707
|
+
export interface RichTextEditorLinkIssue {
|
|
708
|
+
element: HTMLElement;
|
|
709
|
+
href: string;
|
|
710
|
+
text: string;
|
|
711
|
+
severity: string;
|
|
712
|
+
code: string;
|
|
713
|
+
message: string;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export interface RichTextEditorLanguageOption {
|
|
717
|
+
code: string;
|
|
718
|
+
label: string;
|
|
719
|
+
dir?: RichTextEditorTextDirection;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// =====================
|
|
723
|
+
// Page layout, merge fields, cross-references, text direction
|
|
724
|
+
// (pagination, mergefields, crossreference, textdirection). Shapes read from a live editor.
|
|
725
|
+
// =====================
|
|
726
|
+
|
|
727
|
+
export interface RichTextEditorPageGeometry {
|
|
728
|
+
format: string;
|
|
729
|
+
orientation: "portrait" | "landscape" | string;
|
|
730
|
+
pageWidth: number;
|
|
731
|
+
pageHeight: number;
|
|
732
|
+
contentWidth: number;
|
|
733
|
+
contentHeight: number;
|
|
734
|
+
marginTop: number;
|
|
735
|
+
marginRight: number;
|
|
736
|
+
marginBottom: number;
|
|
737
|
+
marginLeft: number;
|
|
738
|
+
headerHtml: string;
|
|
739
|
+
footerHtml: string;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
export interface RichTextEditorMergeFieldDefinition {
|
|
743
|
+
id: string;
|
|
744
|
+
label: string;
|
|
745
|
+
/** Value shown while previewing, before real data is merged. */
|
|
746
|
+
sample?: unknown;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
export interface RichTextEditorCrossReferenceTarget {
|
|
750
|
+
id: string;
|
|
751
|
+
label: string;
|
|
752
|
+
/** "heading", "table", "figure", "footnote", … */
|
|
753
|
+
type: string;
|
|
754
|
+
/** Current number, when the target is numbered. */
|
|
755
|
+
number?: string | number | null;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
export type RichTextEditorTextDirection = "ltr" | "rtl";
|
|
759
|
+
|
|
760
|
+
// =====================
|
|
761
|
+
// Document tooling that shipped without typings
|
|
762
|
+
// (watermark, footnotes, change case, format painter, table of contents,
|
|
763
|
+
// legal numbering, line numbers). Shapes read from a live editor.
|
|
764
|
+
// =====================
|
|
765
|
+
|
|
766
|
+
export interface RichTextEditorWatermarkOptions {
|
|
767
|
+
text?: string;
|
|
768
|
+
image?: string | null;
|
|
769
|
+
/** `tile` repeats across the page; other modes place a single mark. */
|
|
770
|
+
mode?: "tile" | string;
|
|
771
|
+
color?: string;
|
|
772
|
+
fontSize?: number;
|
|
773
|
+
opacity?: number;
|
|
774
|
+
angle?: number;
|
|
775
|
+
/** Include the watermark when printing (default false). */
|
|
776
|
+
print?: boolean;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
export type RichTextEditorChangeCaseMode = "upper" | "lower" | "title" | "sentence" | "toggle";
|
|
780
|
+
|
|
781
|
+
export interface RichTextEditorTocEntry {
|
|
782
|
+
id: string;
|
|
783
|
+
level: number;
|
|
784
|
+
text: string;
|
|
785
|
+
/** Page number when page view is on. */
|
|
786
|
+
page?: number;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export interface RichTextEditorLineNumberOptions {
|
|
790
|
+
start?: number;
|
|
791
|
+
interval?: number;
|
|
792
|
+
restartEachPage?: boolean;
|
|
793
|
+
[key: string]: unknown;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// =====================
|
|
797
|
+
// Node types, state inspector, ruby, tracked changes
|
|
798
|
+
// (plugins/nodetypes.js, stateinspector.js, rubyannotation.js, trackedchanges.js)
|
|
799
|
+
// Shapes below were read from a live editor, not inferred from the sources.
|
|
800
|
+
// =====================
|
|
801
|
+
|
|
802
|
+
export interface RichTextEditorNodeTypeDefinition {
|
|
803
|
+
name: string;
|
|
804
|
+
/** CSS selector, or a predicate run against candidate elements. */
|
|
805
|
+
match: string | ((el: HTMLElement) => boolean);
|
|
806
|
+
/** Enforced as one uneditable unit (default true). */
|
|
807
|
+
atomic?: boolean;
|
|
808
|
+
inline?: boolean;
|
|
809
|
+
toJSON?(el: HTMLElement): unknown;
|
|
810
|
+
fromJSON?(data: unknown): HTMLElement;
|
|
811
|
+
toMarkdown?(el: HTMLElement): string;
|
|
812
|
+
/** Covers .docx and PDF at once; toDocx / toPdf / toWord override per format. */
|
|
813
|
+
toExportHTML?(el: HTMLElement): string;
|
|
814
|
+
toDocx?(el: HTMLElement): string;
|
|
815
|
+
toPdf?(el: HTMLElement): string;
|
|
816
|
+
toWord?(el: HTMLElement): string;
|
|
817
|
+
/** Fed to the sanitizer allowlist on registration. */
|
|
818
|
+
allowTags?: string[];
|
|
819
|
+
allowAttributes?: string[];
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export interface RichTextEditorNodeTypeSummary {
|
|
823
|
+
name: string;
|
|
824
|
+
atomic: boolean;
|
|
825
|
+
inline: boolean;
|
|
826
|
+
hasToJSON: boolean;
|
|
827
|
+
hasFromJSON: boolean;
|
|
828
|
+
hasToMarkdown: boolean;
|
|
829
|
+
hasExportHTML: boolean;
|
|
830
|
+
instances: number;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
export interface RichTextEditorNodeTypes {
|
|
834
|
+
register(definition: RichTextEditorNodeTypeDefinition): boolean;
|
|
835
|
+
unregister(name: string): boolean;
|
|
836
|
+
insert(name: string, data?: unknown): HTMLElement | null;
|
|
837
|
+
find(name?: string): HTMLElement[];
|
|
838
|
+
get(name: string): RichTextEditorNodeTypeDefinition | null;
|
|
839
|
+
list(): RichTextEditorNodeTypeSummary[];
|
|
840
|
+
/** Every instance in the document as `{ name, data }`. */
|
|
841
|
+
serialize(): { name: string; data: unknown }[];
|
|
842
|
+
typeOf(el: HTMLElement): string | null;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
export interface RichTextEditorStateIssue {
|
|
846
|
+
id: string;
|
|
847
|
+
severity: "warn" | "error" | string;
|
|
848
|
+
message: string;
|
|
849
|
+
detail?: string;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
export interface RichTextEditorStateSnapshot {
|
|
853
|
+
snapshotVersion: number;
|
|
854
|
+
generatedAt: string;
|
|
855
|
+
counters: { elements: number; textNodes: number; comments: number; characters: number; tags: Record<string, number> };
|
|
856
|
+
issues: RichTextEditorStateIssue[];
|
|
857
|
+
plugins: string[];
|
|
858
|
+
recentEvents: { at: string; event: string }[];
|
|
859
|
+
selection: {
|
|
860
|
+
available: boolean;
|
|
861
|
+
collapsed: boolean;
|
|
862
|
+
anchor?: unknown;
|
|
863
|
+
focus?: unknown;
|
|
864
|
+
insideEditable: boolean;
|
|
865
|
+
textLength: number;
|
|
866
|
+
text: string;
|
|
867
|
+
block?: string;
|
|
868
|
+
};
|
|
869
|
+
tree: { type: string; name?: string; attrs?: Record<string, string>; children?: unknown[] };
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
export interface RichTextEditorStateInspector {
|
|
873
|
+
open(): void;
|
|
874
|
+
close(): void;
|
|
875
|
+
toggle(): void;
|
|
876
|
+
isOpen(): boolean;
|
|
877
|
+
refresh(): void;
|
|
878
|
+
/** Derived document model as plain JSON — safe to attach to a support case. */
|
|
879
|
+
snapshot(): RichTextEditorStateSnapshot;
|
|
880
|
+
issues(): RichTextEditorStateIssue[];
|
|
881
|
+
/** Plugin initialisation order. */
|
|
882
|
+
plugins(): string[];
|
|
883
|
+
log(): { at: string; event: string }[];
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
export interface RichTextEditorRuby {
|
|
887
|
+
/** Wraps the selection in <ruby> with this reading. */
|
|
888
|
+
add(reading: string): boolean;
|
|
889
|
+
/** Reading of the ruby at the caret, or null. */
|
|
890
|
+
get(): string | null;
|
|
891
|
+
isRuby(): boolean;
|
|
892
|
+
remove(): boolean;
|
|
893
|
+
open(): void;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
export interface RichTextEditorTrackedChangeEntry {
|
|
897
|
+
id: string;
|
|
898
|
+
changeType: "insert" | "delete" | string;
|
|
899
|
+
status: "pending" | "accepted" | "rejected" | string;
|
|
900
|
+
author?: string;
|
|
901
|
+
text?: string;
|
|
902
|
+
[key: string]: unknown;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
export interface RichTextEditorTrackedChanges {
|
|
906
|
+
enable(user?: { name?: string; id?: string }): void;
|
|
907
|
+
disable(): void;
|
|
908
|
+
isEnabled(): boolean;
|
|
909
|
+
/** Pending entries by default; `{ all: true }` includes decided ones. */
|
|
910
|
+
list(options?: { all?: boolean }): RichTextEditorTrackedChangeEntry[];
|
|
911
|
+
accept(id: string): boolean;
|
|
912
|
+
reject(id: string): boolean;
|
|
913
|
+
acceptAll(filter?: unknown): number | boolean;
|
|
914
|
+
rejectAll(filter?: unknown): number | boolean;
|
|
915
|
+
canDecide(id: string, action?: "accept" | "reject"): boolean;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// =====================
|
|
919
|
+
// Component blocks, commands, transforms (plugins/componentblocks.js,
|
|
920
|
+
// plugins/commandbus.js, plugins/transforms.js)
|
|
921
|
+
// =====================
|
|
922
|
+
|
|
923
|
+
export interface RichTextEditorComponentContext {
|
|
924
|
+
editor: RichTextEditorInstance;
|
|
925
|
+
/** The host element in the document; its shadow root is where you render. */
|
|
926
|
+
el: HTMLElement;
|
|
927
|
+
name: string;
|
|
928
|
+
props: Record<string, unknown>;
|
|
929
|
+
setProps(props: Record<string, unknown>): boolean;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export interface RichTextEditorComponentDefinition {
|
|
933
|
+
name: string;
|
|
934
|
+
/** Render into the host's shadow root. Required. */
|
|
935
|
+
mount(root: ShadowRoot, ctx: RichTextEditorComponentContext): void;
|
|
936
|
+
/** Release timers, listeners and framework roots. Runs on delete and before a remount. */
|
|
937
|
+
unmount?(root: ShadowRoot, ctx: RichTextEditorComponentContext): void;
|
|
938
|
+
/** Re-render in place after setProps; without it the block is rebuilt. */
|
|
939
|
+
update?(root: ShadowRoot, ctx: RichTextEditorComponentContext): void;
|
|
940
|
+
/** `span` host instead of `div`. */
|
|
941
|
+
inline?: boolean;
|
|
942
|
+
/** Text used by exports and by clients that never run the component. */
|
|
943
|
+
placeholder?: string;
|
|
944
|
+
toMarkdown?(el: HTMLElement): string;
|
|
945
|
+
toExportHTML?(el: HTMLElement): string;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
export interface RichTextEditorComponentSummary {
|
|
949
|
+
name: string;
|
|
950
|
+
inline: boolean;
|
|
951
|
+
mounted: number;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
export interface RichTextEditorComponents {
|
|
955
|
+
register(definition: RichTextEditorComponentDefinition): boolean;
|
|
956
|
+
unregister(name: string): boolean;
|
|
957
|
+
insert(name: string, props?: Record<string, unknown>): HTMLElement | null;
|
|
958
|
+
props(el: HTMLElement): Record<string, unknown>;
|
|
959
|
+
setProps(el: HTMLElement, props: Record<string, unknown>): boolean;
|
|
960
|
+
find(name?: string): HTMLElement[];
|
|
961
|
+
get(name: string): RichTextEditorComponentDefinition | null;
|
|
962
|
+
list(): RichTextEditorComponentSummary[];
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
export type RichTextEditorCommandHandler = (
|
|
966
|
+
payload: unknown,
|
|
967
|
+
ctx: { editor: RichTextEditorInstance; command: string }
|
|
968
|
+
) => boolean | void;
|
|
969
|
+
|
|
970
|
+
export interface RichTextEditorCommandSummary {
|
|
971
|
+
command: string;
|
|
972
|
+
handlers: number;
|
|
973
|
+
priorities: number[];
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
export interface RichTextEditorCommands {
|
|
977
|
+
/** Higher priority runs first. Returns an unregister function. */
|
|
978
|
+
register(name: string, handler: RichTextEditorCommandHandler, priority?: number): () => void;
|
|
979
|
+
unregister(name: string, handler: RichTextEditorCommandHandler): boolean;
|
|
980
|
+
/** Runs handlers until one returns true. Returns whether it was handled. */
|
|
981
|
+
dispatch(name: string, payload?: unknown): boolean;
|
|
982
|
+
has(name: string): boolean;
|
|
983
|
+
list(): RichTextEditorCommandSummary[];
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
export type RichTextEditorTransform = (
|
|
987
|
+
editable: HTMLElement,
|
|
988
|
+
ctx: { editor: RichTextEditorInstance; name: string; pass: number; reason: string }
|
|
989
|
+
) => boolean | void;
|
|
990
|
+
|
|
991
|
+
export interface RichTextEditorTransforms {
|
|
992
|
+
/** Returns an unregister function. Return true from a transform to request another pass. */
|
|
993
|
+
register(transform: RichTextEditorTransform, options?: { name?: string; priority?: number }): () => void;
|
|
994
|
+
unregister(transform: RichTextEditorTransform): boolean;
|
|
995
|
+
run(): { passes: number; changed: boolean };
|
|
996
|
+
list(): { name: string; priority: number }[];
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
export interface RichTextEditorInstance {
|
|
1000
|
+
// ---- Lifecycle / events ----
|
|
1001
|
+
|
|
1002
|
+
/** Subscribe to an editor event. See {@link RichTextEditorEventName}. */
|
|
1003
|
+
attachEvent(name: RichTextEditorEventName, handler: RichTextEditorEventHandler): void;
|
|
1004
|
+
/** Unsubscribe from an editor event. */
|
|
1005
|
+
detachEvent(name: RichTextEditorEventName, handler: RichTextEditorEventHandler): void;
|
|
1006
|
+
|
|
1007
|
+
/** Move keyboard focus into the editable area. */
|
|
1008
|
+
focus(): void;
|
|
1009
|
+
|
|
1010
|
+
// ---- Content I/O ----
|
|
1011
|
+
|
|
1012
|
+
/** Returns the current HTML string. */
|
|
1013
|
+
getHTMLCode(): string;
|
|
1014
|
+
/** Replaces editable content with the provided HTML and resets undo stack. */
|
|
1015
|
+
setHTMLCode(html: string): unknown;
|
|
1016
|
+
/** Returns the document as plain text (no markup). */
|
|
1017
|
+
getPlainText(): string;
|
|
1018
|
+
// The structured-content instance methods below are installed by the
|
|
1019
|
+
// structured-content bridge. The React/Vue/Angular wrappers install it
|
|
1020
|
+
// automatically; in any other setup call
|
|
1021
|
+
// `require("@richscripts/richtexteditor/integrations/shared").installStructuredContentBridge()`
|
|
1022
|
+
// once before relying on them. They are typed optional because a plain
|
|
1023
|
+
// `<script src="rte.js">` editor does not have them.
|
|
1024
|
+
/** Returns word/character statistics for the current document and selection. Requires the structured-content bridge. */
|
|
1025
|
+
getTextStatistics?(): RichTextEditorTextStatistics;
|
|
1026
|
+
/** Returns word/character statistics for the current selection only. Requires the structured-content bridge. */
|
|
1027
|
+
getSelectionStatistics?(): RichTextEditorTextStatistics;
|
|
1028
|
+
/** Returns richer document metrics including structure counts and estimated reading time. Requires the structured-content bridge. */
|
|
1029
|
+
getDocumentMetrics?(): RichTextEditorDocumentMetrics;
|
|
1030
|
+
/** Returns document footnotes in numeric/source order for review/sidebar workflows. Requires the structured-content bridge. */
|
|
1031
|
+
getFootnotes?(): RichTextEditorFootnoteItem[];
|
|
1032
|
+
/** Returns document-level page setup metadata used by JSON/HTML export workflows. Requires the structured-content bridge. */
|
|
1033
|
+
getDocumentPageSetup?(): RichTextEditorPageSetup | null;
|
|
1034
|
+
/** Returns the document as a structured-content JSON document. Requires the structured-content bridge. */
|
|
1035
|
+
getJSON?(): RichTextEditorStructuredDocument;
|
|
1036
|
+
/** Updates document-level page setup metadata and reapplies the document JSON. Requires the structured-content bridge. */
|
|
1037
|
+
setDocumentPageSetup?(pageSetup: RichTextEditorPageSetup | null): this;
|
|
1038
|
+
/** Replaces editable content from a structured-content JSON document or HTML string. Requires the structured-content bridge. */
|
|
1039
|
+
setJSON?(value: RichTextEditorStructuredInput): this;
|
|
1040
|
+
|
|
1041
|
+
// ---- Read-only mode ----
|
|
1042
|
+
|
|
1043
|
+
/** Returns the current read-only state. */
|
|
1044
|
+
getReadOnly(): boolean;
|
|
1045
|
+
/** Toggles the read-only state. When read-only, the editor blocks edits but keeps selection / scroll behaviour. */
|
|
1046
|
+
setReadOnly(readOnly: boolean): void;
|
|
1047
|
+
/** Returns whether the editor is in comments-only mode (content locked, comment workflows enabled). */
|
|
1048
|
+
getCommentsOnly(): boolean;
|
|
1049
|
+
/** Toggles comments-only mode without enabling full content editing. */
|
|
1050
|
+
setCommentsOnly(commentsOnly: boolean): void;
|
|
1051
|
+
|
|
1052
|
+
// ---- Commands ----
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Execute a toolbar / shortcut command. Most browser-native commands are
|
|
1056
|
+
* supported (`bold`, `italic`, `insertimage`, …) along with a number of
|
|
1057
|
+
* editor-specific commands (`source`, `fullscreen`, `ai-ask`, …).
|
|
1058
|
+
*/
|
|
1059
|
+
execCommand(command: RichTextEditorCommand, value?: unknown): unknown;
|
|
1060
|
+
/** Returns true when the command is enabled in the current selection context. */
|
|
1061
|
+
isCommandEnabled(command: RichTextEditorCommand): boolean;
|
|
1062
|
+
/** Returns true when the command's effect is currently active (e.g. selection is bold). */
|
|
1063
|
+
isCommandActive(command: RichTextEditorCommand): boolean;
|
|
1064
|
+
|
|
1065
|
+
// ---- Math (inline equations) ----
|
|
1066
|
+
/**
|
|
1067
|
+
* Wrap `$...$` runs in `<span class="rte-math-inline" data-tex="...">` so a
|
|
1068
|
+
* host-loaded math renderer can target them. Returns the number of runs wrapped.
|
|
1069
|
+
* No-op when `config.inlineMath === false`.
|
|
1070
|
+
*/
|
|
1071
|
+
applyMathMarkup(): number;
|
|
1072
|
+
/**
|
|
1073
|
+
* Run `applyMathMarkup()` then render every `.rte-math-inline` span via a
|
|
1074
|
+
* math renderer detected on the host page (KaTeX, then MathJax v3+). Leaves
|
|
1075
|
+
* the markup intact when no renderer is present. Returns the span count.
|
|
1076
|
+
*/
|
|
1077
|
+
renderMath(): number;
|
|
1078
|
+
|
|
1079
|
+
// ---- Mermaid diagrams ----
|
|
1080
|
+
/**
|
|
1081
|
+
* Render every `.rte-mermaid` diagram block in the editor. Uses
|
|
1082
|
+
* `config.diagramResolver` (server-side render) if provided, else a
|
|
1083
|
+
* `window.mermaid` instance loaded by the host page; falls back to showing the
|
|
1084
|
+
* Mermaid source when neither is present. The source always round-trips in
|
|
1085
|
+
* `data-diagram`, so blocks stay editable. Returns the block count.
|
|
1086
|
+
*/
|
|
1087
|
+
renderDiagrams(): number;
|
|
1088
|
+
|
|
1089
|
+
// ---- Email export ----
|
|
1090
|
+
/**
|
|
1091
|
+
* Return email-client-safe HTML: a curated set of computed styles is inlined
|
|
1092
|
+
* onto each element as `style=""`, class/id removed, and (by default) the
|
|
1093
|
+
* content wrapped in a centered max-width table. Email clients strip `<style>`
|
|
1094
|
+
* and classes, so this produces HTML that renders correctly in Outlook/Gmail.
|
|
1095
|
+
*/
|
|
1096
|
+
getEmailHTML(options?: { wrap?: boolean; width?: number }): string;
|
|
1097
|
+
|
|
1098
|
+
// ---- Read aloud (text-to-speech) ----
|
|
1099
|
+
/**
|
|
1100
|
+
* Read the current selection (or the whole document if nothing is selected)
|
|
1101
|
+
* aloud via the browser's Web Speech API, sentence by sentence, highlighting
|
|
1102
|
+
* each sentence as it is spoken. No content is modified. Options: `rate`
|
|
1103
|
+
* (0.5–2), `voice` (a `SpeechSynthesisVoice.name`).
|
|
1104
|
+
*/
|
|
1105
|
+
readAloud(options?: { rate?: number; voice?: string }): void;
|
|
1106
|
+
/** Stop any in-progress read-aloud and restore the caret/selection. */
|
|
1107
|
+
stopReadAloud(): void;
|
|
1108
|
+
|
|
1109
|
+
// ---- Auto-embed ----
|
|
1110
|
+
/**
|
|
1111
|
+
* Programmatically convert a media URL (YouTube / Vimeo by default) into a
|
|
1112
|
+
* responsive embed at the caret. Returns `true` if the URL resolved to a
|
|
1113
|
+
* supported provider. The iframe src is rebuilt from a sanitized video id, never
|
|
1114
|
+
* the raw input. The same conversion happens automatically when a bare media URL
|
|
1115
|
+
* is pasted on its own line (see `config.autoEmbedEnabled`).
|
|
1116
|
+
*/
|
|
1117
|
+
embedUrl(url: string): boolean;
|
|
1118
|
+
|
|
1119
|
+
// ---- Foldable headings ----
|
|
1120
|
+
/** Collapse/expand the section beneath a heading element (everything up to the next heading of the same or higher level). */
|
|
1121
|
+
toggleHeadingFold(heading: Element): void;
|
|
1122
|
+
/** Fold the section enclosing the caret (its heading, or the nearest preceding heading). Returns `true` if a heading was found. */
|
|
1123
|
+
foldAtCaret(): boolean;
|
|
1124
|
+
/** Expand every collapsed heading section. */
|
|
1125
|
+
unfoldAll(): void;
|
|
1126
|
+
|
|
1127
|
+
// ---- Typewriter / focus writing modes ----
|
|
1128
|
+
/** Turn typewriter scrolling (caret line pinned to a fixed vertical anchor) on or off. Returns the new state. */
|
|
1129
|
+
setTypewriterMode(on: boolean): boolean;
|
|
1130
|
+
/** Toggle typewriter scrolling. Returns the new state. */
|
|
1131
|
+
toggleTypewriterMode(): boolean;
|
|
1132
|
+
/** `true` if typewriter scrolling is active. */
|
|
1133
|
+
isTypewriterMode(): boolean;
|
|
1134
|
+
/** Turn focus mode (dim every block except the one with the caret) on or off. Returns the new state. */
|
|
1135
|
+
setFocusMode(on: boolean): boolean;
|
|
1136
|
+
/** Toggle focus mode. Returns the new state. */
|
|
1137
|
+
toggleFocusMode(): boolean;
|
|
1138
|
+
/** `true` if focus mode is active. */
|
|
1139
|
+
isFocusMode(): boolean;
|
|
1140
|
+
|
|
1141
|
+
// ---- Accessibility ----
|
|
1142
|
+
/** Re-apply the assistive-technology metadata (iframe title, editing-region role/aria-label, document lang). Called automatically on init and remount. */
|
|
1143
|
+
applyAccessibilityMetadata(): void;
|
|
1144
|
+
/** Re-apply dialog accessibility (role="dialog" + aria-label on dialog popups, aria-labels on their fields). Called automatically when dialogs open. */
|
|
1145
|
+
applyDialogAccessibility(): void;
|
|
1146
|
+
|
|
1147
|
+
// ---- Markdown export ----
|
|
1148
|
+
/** Serialize the document to Markdown (friendly alias for the core `toMarkdown()` engine). */
|
|
1149
|
+
getMarkdown(): string;
|
|
1150
|
+
/** Copy the document to the clipboard as Markdown. Returns a promise that resolves `true` on success. Call from a user gesture. */
|
|
1151
|
+
copyAsMarkdown(): Promise<boolean>;
|
|
1152
|
+
/** Download the document as a `.md` file. `filename` is optional (derived from the first heading when omitted). Returns `true` if the download was triggered. */
|
|
1153
|
+
downloadMarkdown(filename?: string): boolean;
|
|
1154
|
+
|
|
1155
|
+
// ---- Word export ----
|
|
1156
|
+
/** Build a Word-compatible HTML document string (MSO namespaces + page setup) from the current content. */
|
|
1157
|
+
getWordDocument(options?: RichTextEditorWordExportOptions): string;
|
|
1158
|
+
/** Download the document as a `.doc` Word file (opens natively in Word / LibreOffice). `filename` optional (derived from the first heading). Returns `true` if the download was triggered. */
|
|
1159
|
+
exportToWord(filename?: string, options?: RichTextEditorWordExportOptions): boolean;
|
|
1160
|
+
/** Alias of `exportToWord`. */
|
|
1161
|
+
downloadWord(filename?: string, options?: RichTextEditorWordExportOptions): boolean;
|
|
1162
|
+
|
|
1163
|
+
// ---- Document import ----
|
|
1164
|
+
/** Open a file picker and import the chosen file (Markdown/HTML/text/Word `.doc`) into the editor. */
|
|
1165
|
+
openImportDialog(options?: RichTextEditorImportOptions): boolean;
|
|
1166
|
+
/** Import a `File` object. Resolves `true` if content was loaded. `.docx` needs `documentImportResolver`. */
|
|
1167
|
+
importFile(file: File, options?: RichTextEditorImportOptions): Promise<boolean>;
|
|
1168
|
+
/** Convert text to HTML for a given kind (`md` | `html` | `txt` | `doc`) without applying it. */
|
|
1169
|
+
htmlFromImportText(text: string, kind: "md" | "html" | "txt" | "doc"): string;
|
|
1170
|
+
|
|
1171
|
+
// ---- Readability statistics ----
|
|
1172
|
+
/** Compute instant, local readability metrics for the current content (or `text`). */
|
|
1173
|
+
getReadabilityStats(text?: string): RichTextEditorReadabilityStats;
|
|
1174
|
+
/** Heuristic English syllable count for a single word. */
|
|
1175
|
+
countSyllables(word: string): number;
|
|
1176
|
+
|
|
1177
|
+
// ---- Find & replace ----
|
|
1178
|
+
/** Open the built-in Find & Replace dialog (live match highlighting + replace-all). Also reachable via the `/find` slash command. */
|
|
1179
|
+
openFindDialog(): void;
|
|
1180
|
+
/** Highlight every occurrence of `query` in the document and return the match count. */
|
|
1181
|
+
findHighlight(query: string): { matches: number };
|
|
1182
|
+
/** Open the keyboard-shortcut cheat sheet modal (also bound to Ctrl/Cmd+/ and the `/shortcuts` slash command). */
|
|
1183
|
+
showShortcuts(): void;
|
|
1184
|
+
|
|
1185
|
+
// ---- Character / word limit ----
|
|
1186
|
+
/** Current character count (plain text, no markup). */
|
|
1187
|
+
getCharCount(): number;
|
|
1188
|
+
/** Current word count. */
|
|
1189
|
+
getWordCount(): number;
|
|
1190
|
+
/** Remaining characters before `maxLength`, or `null` when no `maxLength` is set. */
|
|
1191
|
+
getRemainingChars(): number | null;
|
|
1192
|
+
/** Whether the content exceeds the configured `maxLength`/`maxWords`. */
|
|
1193
|
+
isOverLimit(): boolean;
|
|
1194
|
+
|
|
1195
|
+
// ---- Local draft autosave / recovery ----
|
|
1196
|
+
/** Persist the current document to localStorage immediately. Returns `true` on success. */
|
|
1197
|
+
saveLocalDraft(): boolean;
|
|
1198
|
+
/** `true` if a stored (non-expired) local draft exists for this editor. */
|
|
1199
|
+
hasLocalDraft(): boolean;
|
|
1200
|
+
/** The stored draft `{ html, t }` (t = epoch ms), or `null`. */
|
|
1201
|
+
getLocalDraft(): { html: string; t: number } | null;
|
|
1202
|
+
/** Apply the stored local draft to the editor. Returns `true` if one was restored. */
|
|
1203
|
+
restoreLocalDraft(): boolean;
|
|
1204
|
+
/** Delete the stored local draft (call after a successful server save). */
|
|
1205
|
+
clearLocalDraft(): boolean;
|
|
1206
|
+
|
|
1207
|
+
// ---- AI ghost-text autocomplete ----
|
|
1208
|
+
/** Set (or clear with `null`) the resolver that produces inline completions. */
|
|
1209
|
+
setGhostTextResolver(fn: ((context: { before: string; after: string; full: string }) => string | Promise<string>) | null): void;
|
|
1210
|
+
/** Manually request an inline ghost-text suggestion at the caret. */
|
|
1211
|
+
requestGhostText(): void;
|
|
1212
|
+
/** Accept the currently-shown ghost suggestion (inserts it). Returns `true` if one was accepted. */
|
|
1213
|
+
acceptGhostText(): boolean;
|
|
1214
|
+
/** Dismiss the currently-shown ghost suggestion without inserting it. */
|
|
1215
|
+
dismissGhostText(): void;
|
|
1216
|
+
/** `true` while a ghost suggestion is being shown. */
|
|
1217
|
+
hasGhostText(): boolean;
|
|
1218
|
+
|
|
1219
|
+
// ---- Theming ----
|
|
1220
|
+
|
|
1221
|
+
/** Replaces the editable area's content stylesheet with raw CSS. */
|
|
1222
|
+
setContentCssText(css: string): void;
|
|
1223
|
+
/** Replaces the preview pane stylesheet with raw CSS. */
|
|
1224
|
+
setPreviewCssText(css: string): void;
|
|
1225
|
+
|
|
1226
|
+
// ---- Insertion / selection helpers ----
|
|
1227
|
+
|
|
1228
|
+
/** Inserts a new root paragraph at the current selection. */
|
|
1229
|
+
insertRootParagraph(): void;
|
|
1230
|
+
/** Wraps the current selection in a new element with the given tag name. */
|
|
1231
|
+
insertByTagName(tagName: string): Element | null;
|
|
1232
|
+
/** Surrounds the selection with the given tag name (e.g. `"strong"`, `"mark"`). */
|
|
1233
|
+
surroundByTagName(tagName: string): Element | null;
|
|
1234
|
+
/** Inserts the supplied element at the current selection. */
|
|
1235
|
+
insertElement(element: Element): Element;
|
|
1236
|
+
/** Surrounds the selection with the supplied element. */
|
|
1237
|
+
surroundElement(element: Element): Element;
|
|
1238
|
+
/** Inserts plain text (non-HTML) at the caret. */
|
|
1239
|
+
insertText(text: string): void;
|
|
1240
|
+
/** Inserts a raw HTML fragment at the caret. */
|
|
1241
|
+
insertHTML(html: string): void;
|
|
1242
|
+
|
|
1243
|
+
/** Selects the supplied control (image / table / hr). */
|
|
1244
|
+
selectControl(element: Element): void;
|
|
1245
|
+
/** Selects the entire document. */
|
|
1246
|
+
selectDoc(): void;
|
|
1247
|
+
/** Collapses the current selection. */
|
|
1248
|
+
collapse(toEnd?: boolean): void;
|
|
1249
|
+
/** Deletes the current selection. */
|
|
1250
|
+
delete(): void;
|
|
1251
|
+
|
|
1252
|
+
/** Persists the current caret position so it can be restored after a popup closes. */
|
|
1253
|
+
commitBookmark(): void;
|
|
1254
|
+
/** Resets the undo / redo stack. */
|
|
1255
|
+
clearHistory(): void;
|
|
1256
|
+
/** Re-evaluates toolbar enabled / active states. Useful after programmatic mutations. */
|
|
1257
|
+
notifySelectionChange(): void;
|
|
1258
|
+
|
|
1259
|
+
// ---- DOM accessors ----
|
|
1260
|
+
|
|
1261
|
+
/** Returns the editable Document (iframe document or main document for non-iframe mode). */
|
|
1262
|
+
getDocument(): Document;
|
|
1263
|
+
/** Returns the editable element (iframe body, or contenteditable host). */
|
|
1264
|
+
getEditable(): HTMLElement;
|
|
1265
|
+
/** Returns a serialized snapshot of the current selection. */
|
|
1266
|
+
getSelection(): RichTextEditorSelection;
|
|
1267
|
+
/** Returns the currently selected control element (image / table / hr) or null. */
|
|
1268
|
+
getSelectedControl(): Element | null;
|
|
1269
|
+
/** Returns the closest element ancestor of the current selection. */
|
|
1270
|
+
getSelectionElement(): Element | null;
|
|
1271
|
+
/** Returns the selected text as a plain string. */
|
|
1272
|
+
getSelectedText(): string;
|
|
1273
|
+
|
|
1274
|
+
// ---- HTML helpers ----
|
|
1275
|
+
|
|
1276
|
+
/** HTML-encodes a string (escapes `&`, `<`, `>`, `"`). */
|
|
1277
|
+
htmlEncode(value: string): string;
|
|
1278
|
+
/** Reverses {@link htmlEncode}. */
|
|
1279
|
+
htmlDecode(value: string): string;
|
|
1280
|
+
|
|
1281
|
+
// ---- UI factories ----
|
|
1282
|
+
|
|
1283
|
+
/** Creates a custom toolbar button. */
|
|
1284
|
+
createToolbarButton(id: string, options: RichTextEditorToolbarButtonOptions): unknown;
|
|
1285
|
+
/** Creates a custom toolbar drop-down. */
|
|
1286
|
+
createToolbarDropDown(id: string, options: RichTextEditorToolbarDropDownOptions): unknown;
|
|
1287
|
+
/** Opens a custom dialog. */
|
|
1288
|
+
createDialog(options: RichTextEditorDialogOptions): unknown;
|
|
1289
|
+
/** Closes the currently active popup dialog (if any). */
|
|
1290
|
+
closeCurrentPopup(): void;
|
|
1291
|
+
|
|
1292
|
+
/** Replaces the icon shown for a command. */
|
|
1293
|
+
setImageForCommand(command: string, iconUrl: string): void;
|
|
1294
|
+
|
|
1295
|
+
// ---- Optional v2.0 surfaces (presence depends on config / plugin loading) ----
|
|
1296
|
+
|
|
1297
|
+
/** AI Toolkit (proofread / rewrite / chat / review). Present when `enable-ai-toolkit` / `config.enableAiToolkit` is true. */
|
|
1298
|
+
aiToolkit?: RichTextEditorAiToolkit;
|
|
1299
|
+
|
|
1300
|
+
/** Web Speech API dictation helper. */
|
|
1301
|
+
dictation?: RichTextEditorDictation;
|
|
1302
|
+
|
|
1303
|
+
/** Local + named revision history. */
|
|
1304
|
+
revisionHistory?: RichTextEditorRevisionHistory;
|
|
1305
|
+
|
|
1306
|
+
/** Yjs-based real-time collaboration. */
|
|
1307
|
+
collab?: RichTextEditorCollab;
|
|
1308
|
+
|
|
1309
|
+
/** Slash-command menu (/<command> at start of line). */
|
|
1310
|
+
slashCommands?: RichTextEditorSlashCommands;
|
|
1311
|
+
|
|
1312
|
+
// ---- Autocorrect and typography ----
|
|
1313
|
+
|
|
1314
|
+
setAutocorrectEnabled?(on: boolean): boolean;
|
|
1315
|
+
isAutocorrectEnabled?(): boolean;
|
|
1316
|
+
/** Adds one replacement rule. */
|
|
1317
|
+
addAutocorrectRule?(from: string, to: string): boolean;
|
|
1318
|
+
getAutocorrectRules?(): RichTextEditorAutocorrectRules;
|
|
1319
|
+
/** Applies smart quotes, dashes and ellipses to a string and returns it. */
|
|
1320
|
+
applyTypography?(text: string): string;
|
|
1321
|
+
|
|
1322
|
+
// ---- Sanitiser ----
|
|
1323
|
+
|
|
1324
|
+
/** Cleans an HTML string with the editor's allowlist. */
|
|
1325
|
+
sanitizeHtml?(html: string): string;
|
|
1326
|
+
/** Counters for what the sanitiser has removed so far. */
|
|
1327
|
+
getSanitizerReport?(): RichTextEditorSanitizerReport;
|
|
1328
|
+
|
|
1329
|
+
// ---- Markdown ----
|
|
1330
|
+
|
|
1331
|
+
toMarkdown?(): string;
|
|
1332
|
+
fromMarkdown?(markdown: string): unknown;
|
|
1333
|
+
getMarkdown?(): string;
|
|
1334
|
+
copyAsMarkdown?(): unknown;
|
|
1335
|
+
downloadMarkdown?(filename?: string): unknown;
|
|
1336
|
+
|
|
1337
|
+
// ---- Export ----
|
|
1338
|
+
|
|
1339
|
+
getPdfBytes?(options?: Record<string, unknown>): Uint8Array | Promise<Uint8Array>;
|
|
1340
|
+
exportToPdf?(filename?: string, options?: Record<string, unknown>): unknown;
|
|
1341
|
+
downloadPdf?(filename?: string, options?: Record<string, unknown>): unknown;
|
|
1342
|
+
exportPdf?(options?: Record<string, unknown>): unknown;
|
|
1343
|
+
getDocxBlob?(options?: Record<string, unknown>): Blob | Promise<Blob>;
|
|
1344
|
+
exportToDocx?(filename?: string, options?: Record<string, unknown>): unknown;
|
|
1345
|
+
exportToWord?(options?: RichTextEditorWordExportOptions): unknown;
|
|
1346
|
+
downloadWord?(filename?: string, options?: RichTextEditorWordExportOptions): unknown;
|
|
1347
|
+
getWordDocument?(options?: RichTextEditorWordExportOptions): string;
|
|
1348
|
+
getEmailHTML?(options?: Record<string, unknown>): string;
|
|
1349
|
+
|
|
1350
|
+
// ---- Formatting marks and inline code ----
|
|
1351
|
+
|
|
1352
|
+
setFormattingMarks?(on: boolean): boolean;
|
|
1353
|
+
toggleFormattingMarks?(): unknown;
|
|
1354
|
+
isFormattingMarks?(): boolean;
|
|
1355
|
+
getFormattingMarksCss?(): string;
|
|
1356
|
+
toggleInlineCode?(): unknown;
|
|
1357
|
+
isInlineCode?(): boolean;
|
|
1358
|
+
|
|
1359
|
+
// ---- Gap cursor (blocks with no paragraph around them) ----
|
|
1360
|
+
|
|
1361
|
+
/** Places where a paragraph can be inserted between or beside atomic blocks. */
|
|
1362
|
+
getGapPositions?(): unknown[];
|
|
1363
|
+
insertParagraphBefore?(el: HTMLElement): unknown;
|
|
1364
|
+
insertParagraphAfter?(el: HTMLElement): unknown;
|
|
1365
|
+
insertParagraphAt?(index: number): unknown;
|
|
1366
|
+
|
|
1367
|
+
// ---- Shadow DOM hosting ----
|
|
1368
|
+
|
|
1369
|
+
isInShadowDom?(): boolean;
|
|
1370
|
+
getShadowRoot?(): ShadowRoot | null;
|
|
1371
|
+
/** Copies the editor's stylesheets into a shadow root; returns how many. */
|
|
1372
|
+
adoptEditorStyles?(target?: ShadowRoot): number;
|
|
1373
|
+
getAdoptedStyleCount?(): number;
|
|
1374
|
+
|
|
1375
|
+
// ---- Imported styles ----
|
|
1376
|
+
|
|
1377
|
+
importStyles?(options?: Record<string, unknown>): unknown;
|
|
1378
|
+
getImportedStyles?(): unknown;
|
|
1379
|
+
scanStylesheetClasses?(options?: Record<string, unknown>): unknown;
|
|
1380
|
+
|
|
1381
|
+
// ---- Accessibility helpers ----
|
|
1382
|
+
|
|
1383
|
+
/** Announces text to screen readers through the editor's live region. */
|
|
1384
|
+
announce?(text: string, options?: { assertive?: boolean }): unknown;
|
|
1385
|
+
/** Moves focus to the first toolbar button (the documented Escape hatch target). */
|
|
1386
|
+
focusToolbar?(): unknown;
|
|
1387
|
+
applyAccessibilityMetadata?(): unknown;
|
|
1388
|
+
applyDialogAccessibility?(dialog?: HTMLElement): unknown;
|
|
1389
|
+
ensureStyleSheetLive?(doc: Document, style: HTMLStyleElement, id: string, cssText: string): unknown;
|
|
1390
|
+
|
|
1391
|
+
// ---- Toolbar / dialog building blocks ----
|
|
1392
|
+
|
|
1393
|
+
createTabUI?(...args: unknown[]): unknown;
|
|
1394
|
+
createToolbarItemDropDownPanel?(...args: unknown[]): unknown;
|
|
1395
|
+
/** Fires an editor event by name. */
|
|
1396
|
+
fireEvent?(name: string, ...args: unknown[]): unknown;
|
|
1397
|
+
/** Subscribe to formatting state changes for a command. */
|
|
1398
|
+
formatChanged?(...args: unknown[]): unknown;
|
|
1399
|
+
getLangText?(key: string): string;
|
|
1400
|
+
|
|
1401
|
+
// ---- Other feature entry points ----
|
|
1402
|
+
|
|
1403
|
+
insertTableOfContents?(): unknown;
|
|
1404
|
+
toggleWatermark?(): unknown;
|
|
1405
|
+
readAloud?(): unknown;
|
|
1406
|
+
stopReadAloud?(): unknown;
|
|
1407
|
+
showShortcuts?(): unknown;
|
|
1408
|
+
openFindDialog?(): unknown;
|
|
1409
|
+
openImportDialog?(): unknown;
|
|
1410
|
+
importFile?(file: File, options?: RichTextEditorImportOptions): unknown;
|
|
1411
|
+
htmlFromImportText?(text: string, filename?: string): string;
|
|
1412
|
+
embedUrl?(url: string): unknown;
|
|
1413
|
+
renderMath?(): unknown;
|
|
1414
|
+
applyMathMarkup?(): unknown;
|
|
1415
|
+
renderDiagrams?(): unknown;
|
|
1416
|
+
getReadabilityStats?(): Record<string, unknown>;
|
|
1417
|
+
countSyllables?(word: string): number;
|
|
1418
|
+
getFootnotes?(): unknown[];
|
|
1419
|
+
getCharCount?(): number;
|
|
1420
|
+
getWordCount?(): number;
|
|
1421
|
+
getRemainingChars?(): number;
|
|
1422
|
+
isOverLimit?(): boolean;
|
|
1423
|
+
getCommentsOnly?(): boolean;
|
|
1424
|
+
setCommentsOnly?(on: boolean): unknown;
|
|
1425
|
+
setFocusMode?(on: boolean): unknown;
|
|
1426
|
+
toggleFocusMode?(): unknown;
|
|
1427
|
+
isFocusMode?(): boolean;
|
|
1428
|
+
setTypewriterMode?(on: boolean): unknown;
|
|
1429
|
+
toggleTypewriterMode?(): unknown;
|
|
1430
|
+
isTypewriterMode?(): boolean;
|
|
1431
|
+
saveLocalDraft?(): unknown;
|
|
1432
|
+
restoreLocalDraft?(): unknown;
|
|
1433
|
+
hasLocalDraft?(): boolean;
|
|
1434
|
+
getLocalDraft?(): unknown;
|
|
1435
|
+
clearLocalDraft?(): unknown;
|
|
1436
|
+
requestGhostText?(): unknown;
|
|
1437
|
+
acceptGhostText?(): unknown;
|
|
1438
|
+
dismissGhostText?(): unknown;
|
|
1439
|
+
hasGhostText?(): boolean;
|
|
1440
|
+
setGhostTextResolver?(resolver: (context: unknown) => unknown): unknown;
|
|
1441
|
+
foldAtCaret?(): unknown;
|
|
1442
|
+
toggleHeadingFold?(el?: HTMLElement): unknown;
|
|
1443
|
+
unfoldAll?(): unknown;
|
|
1444
|
+
findHighlight?(text: string): unknown;
|
|
1445
|
+
getSelectedControl?(): HTMLElement | null;
|
|
1446
|
+
getSelectedText?(): string;
|
|
1447
|
+
getDocument?(): Document;
|
|
1448
|
+
|
|
1449
|
+
// ---- Tables ----
|
|
1450
|
+
|
|
1451
|
+
insertLayoutTable?(rows: number, cols: number, options?: Record<string, unknown>): unknown;
|
|
1452
|
+
/** "layout" or "data" for the table at the caret (or the one passed), null when there is none. */
|
|
1453
|
+
getTableLayoutMode?(table?: HTMLTableElement): "layout" | "data" | null;
|
|
1454
|
+
setTableLayoutMode?(mode: "layout" | "data"): unknown;
|
|
1455
|
+
toggleTableLayoutMode?(): unknown;
|
|
1456
|
+
isLayoutTable?(table?: HTMLTableElement): boolean;
|
|
1457
|
+
listLayoutTables?(): HTMLTableElement[];
|
|
1458
|
+
showLayoutTableOutlines?(on: boolean): boolean;
|
|
1459
|
+
/** `{ ok }` is false with a `reason` when the table at the caret cannot be sorted. */
|
|
1460
|
+
canSortTable?(): { ok: boolean; reason: string };
|
|
1461
|
+
sortTableByColumn?(index: number, dir?: "asc" | "desc"): unknown;
|
|
1462
|
+
sortTableAtCaret?(): unknown;
|
|
1463
|
+
addTableRowNumbers?(options?: Record<string, unknown>): unknown;
|
|
1464
|
+
removeTableRowNumbers?(): unknown;
|
|
1465
|
+
hasTableRowNumbers?(): boolean;
|
|
1466
|
+
|
|
1467
|
+
// ---- Link checking ----
|
|
1468
|
+
|
|
1469
|
+
/** Runs the check; read the findings with getLinkIssues(). */
|
|
1470
|
+
checkLinks?(): unknown;
|
|
1471
|
+
getLinkIssues?(): RichTextEditorLinkIssue[];
|
|
1472
|
+
highlightLinkIssues?(on?: boolean): unknown;
|
|
1473
|
+
clearLinkHighlights?(): unknown;
|
|
1474
|
+
getLinkCheckerCss?(): string;
|
|
1475
|
+
|
|
1476
|
+
// ---- Language of parts ----
|
|
1477
|
+
|
|
1478
|
+
/** Marks the selection with a BCP 47 language tag (WCAG 3.1.2). */
|
|
1479
|
+
setTextLanguage?(code: string): unknown;
|
|
1480
|
+
getTextLanguage?(): string | null;
|
|
1481
|
+
removeTextLanguage?(): unknown;
|
|
1482
|
+
getMarkedLanguages?(): unknown[];
|
|
1483
|
+
listTextLanguages?(): RichTextEditorLanguageOption[];
|
|
1484
|
+
|
|
1485
|
+
// ---- Permanent pen ----
|
|
1486
|
+
|
|
1487
|
+
setPermanentPen?(on: boolean): unknown;
|
|
1488
|
+
togglePermanentPen?(): unknown;
|
|
1489
|
+
isPermanentPenActive?(): boolean;
|
|
1490
|
+
/** CSS declarations applied while the pen is on, e.g. `{ color, "font-weight" }`. */
|
|
1491
|
+
getPermanentPenStyle?(): Record<string, string>;
|
|
1492
|
+
setPermanentPenStyle?(style: Record<string, string>): unknown;
|
|
1493
|
+
|
|
1494
|
+
// ---- Drag handle / block moves ----
|
|
1495
|
+
|
|
1496
|
+
setDragHandleEnabled?(on: boolean): boolean;
|
|
1497
|
+
isDragHandleEnabled?(): boolean;
|
|
1498
|
+
moveBlock?(block: HTMLElement, beforeEl?: HTMLElement | null): unknown;
|
|
1499
|
+
moveBlockUp?(): unknown;
|
|
1500
|
+
moveBlockDown?(): unknown;
|
|
1501
|
+
|
|
1502
|
+
// ---- Right-to-left user interface ----
|
|
1503
|
+
|
|
1504
|
+
setRtlUserInterface?(on: boolean): boolean;
|
|
1505
|
+
toggleRtlUserInterface?(): boolean;
|
|
1506
|
+
isRtlUserInterface?(): boolean;
|
|
1507
|
+
getRtlUiCss?(): string;
|
|
1508
|
+
|
|
1509
|
+
// ---- Content (core, previously untyped) ----
|
|
1510
|
+
|
|
1511
|
+
/** Alias of getHTMLCode(). */
|
|
1512
|
+
getHTML?(): string;
|
|
1513
|
+
/** Alias of setHTMLCode(). */
|
|
1514
|
+
setHTML?(html: string): unknown;
|
|
1515
|
+
getText?(): string;
|
|
1516
|
+
setText?(text: string): unknown;
|
|
1517
|
+
setPlainText?(text: string): unknown;
|
|
1518
|
+
/** HTML of the current selection, empty when nothing is selected. */
|
|
1519
|
+
getSelectedHTML?(): string;
|
|
1520
|
+
/** Word and character counts for the document. */
|
|
1521
|
+
getStatistics?(): { words: number; characters: number };
|
|
1522
|
+
showWordCount?(): void;
|
|
1523
|
+
insertImageByUrl?(url: string): void;
|
|
1524
|
+
/** Highlights every occurrence of the selected text; returns how many. */
|
|
1525
|
+
markAllOccurrencesOfSelection?(): number;
|
|
1526
|
+
clearFindHighlights?(): void;
|
|
1527
|
+
printPreview?(): unknown;
|
|
1528
|
+
/** Distraction-free reading mode; returns the new state. */
|
|
1529
|
+
toggleReadingMode?(state?: boolean): boolean;
|
|
1530
|
+
isReadingMode?(): boolean;
|
|
1531
|
+
/** Adds a stylesheet to the editing document (or `doc`) under a stable id. */
|
|
1532
|
+
injectStyleSheet?(doc: Document | null, id: string, cssText: string): unknown;
|
|
1533
|
+
/** Releases listeners and observers before the host removes the editor. */
|
|
1534
|
+
prepareDestroy?(): void;
|
|
1535
|
+
destroy?(): void;
|
|
1536
|
+
|
|
1537
|
+
// ---- Page layout ----
|
|
1538
|
+
|
|
1539
|
+
setPageView?(on: boolean): boolean;
|
|
1540
|
+
togglePageView?(): boolean;
|
|
1541
|
+
isPageView?(): boolean;
|
|
1542
|
+
getPageCount?(): number;
|
|
1543
|
+
getPageGeometry?(): RichTextEditorPageGeometry;
|
|
1544
|
+
setPageSetup?(setup: RichTextEditorPageSetup): void;
|
|
1545
|
+
|
|
1546
|
+
// ---- Merge fields ----
|
|
1547
|
+
|
|
1548
|
+
insertMergeField?(id: string): unknown;
|
|
1549
|
+
listMergeFields?(): unknown[];
|
|
1550
|
+
getMergeFieldDefinitions?(): RichTextEditorMergeFieldDefinition[];
|
|
1551
|
+
/** Renders the document with one record's data. */
|
|
1552
|
+
renderMergeFields?(data: Record<string, unknown>): unknown;
|
|
1553
|
+
setMergeFieldPreview?(on: boolean): unknown;
|
|
1554
|
+
toggleMergeFieldPreview?(): unknown;
|
|
1555
|
+
isMergeFieldPreview?(): boolean;
|
|
1556
|
+
getMergeFieldCss?(): string;
|
|
1557
|
+
|
|
1558
|
+
// ---- Cross-references ----
|
|
1559
|
+
|
|
1560
|
+
insertCrossReference?(targetId: string, format?: string): unknown;
|
|
1561
|
+
listCrossReferenceTargets?(): RichTextEditorCrossReferenceTarget[];
|
|
1562
|
+
getCrossReferences?(): unknown[];
|
|
1563
|
+
/** Renumbers references after content moved. */
|
|
1564
|
+
updateCrossReferences?(): unknown;
|
|
1565
|
+
getPageOfElement?(el: HTMLElement): number | null;
|
|
1566
|
+
getCrossReferenceCss?(): string;
|
|
1567
|
+
|
|
1568
|
+
// ---- Text direction (bidi) ----
|
|
1569
|
+
|
|
1570
|
+
setBaseDirection?(dir: RichTextEditorTextDirection): unknown;
|
|
1571
|
+
getBaseDirection?(): RichTextEditorTextDirection;
|
|
1572
|
+
setTextDirection?(dir: RichTextEditorTextDirection): unknown;
|
|
1573
|
+
getTextDirection?(): RichTextEditorTextDirection;
|
|
1574
|
+
toggleTextDirection?(): unknown;
|
|
1575
|
+
/** Direction of the first strong character in `text`. */
|
|
1576
|
+
detectTextDirection?(text: string): RichTextEditorTextDirection;
|
|
1577
|
+
autoDetectTextDirection?(): unknown;
|
|
1578
|
+
/** Wraps html in a bidi isolate so it cannot reorder surrounding text. */
|
|
1579
|
+
isolateBidi?(html: string, dir?: RichTextEditorTextDirection): string;
|
|
1580
|
+
insertIsolated?(html: string, dir?: RichTextEditorTextDirection): unknown;
|
|
1581
|
+
getTextDirectionCss?(): string;
|
|
1582
|
+
|
|
1583
|
+
// ---- Watermark ----
|
|
1584
|
+
|
|
1585
|
+
/** Turns the watermark on or off; returns the new state. */
|
|
1586
|
+
setWatermark?(on: boolean): boolean;
|
|
1587
|
+
isWatermark?(): boolean;
|
|
1588
|
+
getWatermarkOptions?(): RichTextEditorWatermarkOptions;
|
|
1589
|
+
setWatermarkOptions?(options: RichTextEditorWatermarkOptions): void;
|
|
1590
|
+
|
|
1591
|
+
// ---- Footnotes ----
|
|
1592
|
+
|
|
1593
|
+
/** Inserts an auto-numbered footnote at the caret. */
|
|
1594
|
+
insertFootnote?(text?: string): unknown;
|
|
1595
|
+
/** Renumbers footnotes after content moved. */
|
|
1596
|
+
syncFootnotes?(): unknown;
|
|
1597
|
+
/** Footnote CSS, for rendering saved content outside the editor. */
|
|
1598
|
+
getFootnotesCss?(): string;
|
|
1599
|
+
|
|
1600
|
+
// ---- Change case ----
|
|
1601
|
+
|
|
1602
|
+
changeCase?(mode: RichTextEditorChangeCaseMode): unknown;
|
|
1603
|
+
getChangeCaseModes?(): RichTextEditorChangeCaseMode[];
|
|
1604
|
+
|
|
1605
|
+
// ---- Format painter ----
|
|
1606
|
+
|
|
1607
|
+
copyFormatting?(): unknown;
|
|
1608
|
+
pasteFormatting?(): unknown;
|
|
1609
|
+
/** `isSticky` keeps painting until cancelled. */
|
|
1610
|
+
toggleFormatPainter?(isSticky?: boolean): unknown;
|
|
1611
|
+
cancelFormatPainter?(): unknown;
|
|
1612
|
+
isFormatPainterActive?(): boolean;
|
|
1613
|
+
/** The captured character formatting, or null when nothing is captured. */
|
|
1614
|
+
getCapturedFormatting?(): Record<string, unknown> | null;
|
|
1615
|
+
|
|
1616
|
+
// ---- Table of contents ----
|
|
1617
|
+
|
|
1618
|
+
getTableOfContents?(): RichTextEditorTocEntry[];
|
|
1619
|
+
hasTableOfContents?(): boolean;
|
|
1620
|
+
updateTableOfContents?(): unknown;
|
|
1621
|
+
removeTableOfContents?(): unknown;
|
|
1622
|
+
getTocCss?(): string;
|
|
1623
|
+
|
|
1624
|
+
// ---- Legal / multi-level numbering ----
|
|
1625
|
+
|
|
1626
|
+
setLegalNumbering?(on: boolean): unknown;
|
|
1627
|
+
toggleLegalNumbering?(): unknown;
|
|
1628
|
+
isLegalNumbering?(): boolean;
|
|
1629
|
+
getLegalListCss?(): string;
|
|
1630
|
+
|
|
1631
|
+
// ---- Line numbers ----
|
|
1632
|
+
|
|
1633
|
+
setLineNumbers?(on: boolean): boolean;
|
|
1634
|
+
toggleLineNumbers?(): unknown;
|
|
1635
|
+
isLineNumbers?(): boolean;
|
|
1636
|
+
getLineCount?(): number;
|
|
1637
|
+
setLineNumberOptions?(options: RichTextEditorLineNumberOptions): void;
|
|
1638
|
+
getLineNumbersCss?(): string;
|
|
1639
|
+
|
|
1640
|
+
/** Declare your own element as a node type. See docs/CUSTOM-NODE-TYPES.md. */
|
|
1641
|
+
nodeTypes?: RichTextEditorNodeTypes;
|
|
1642
|
+
|
|
1643
|
+
/** Developer tool: derived document model and structural checks. */
|
|
1644
|
+
stateInspector?: RichTextEditorStateInspector;
|
|
1645
|
+
|
|
1646
|
+
/** Ruby annotations (furigana, pinyin, bopomofo). */
|
|
1647
|
+
ruby?: RichTextEditorRuby;
|
|
1648
|
+
|
|
1649
|
+
/** Track changes review queue. */
|
|
1650
|
+
trackedChanges?: RichTextEditorTrackedChanges;
|
|
1651
|
+
|
|
1652
|
+
/** Framework components hosted as editable blocks. See docs/COMPONENT-BLOCKS.md. */
|
|
1653
|
+
components?: RichTextEditorComponents;
|
|
1654
|
+
|
|
1655
|
+
/** Priority-ordered commands, and interception of built-in ones. See docs/COMMAND-BUS.md. */
|
|
1656
|
+
commands?: RichTextEditorCommands;
|
|
1657
|
+
|
|
1658
|
+
/** Document normalization that runs after changes. See docs/TRANSFORMS.md. */
|
|
1659
|
+
transforms?: RichTextEditorTransforms;
|
|
1660
|
+
|
|
1661
|
+
/** @-mention / #-tag pickers. */
|
|
1662
|
+
mentions?: RichTextEditorMentions;
|
|
1663
|
+
|
|
1664
|
+
/** Inline comments + threaded replies. */
|
|
1665
|
+
comments?: RichTextEditorComments;
|
|
1666
|
+
|
|
1667
|
+
/** Word-style "protect document with editable regions" — lock the
|
|
1668
|
+
* document except for spans tagged `data-rte-editable="true"`. */
|
|
1669
|
+
restrictedEditing?: RichTextEditorRestrictedEditing;
|
|
1670
|
+
|
|
1671
|
+
/** Live heading sidebar for in-editor document navigation. */
|
|
1672
|
+
documentOutline?: RichTextEditorDocumentOutlinePanel;
|
|
1673
|
+
|
|
1674
|
+
/** Scroll-aware miniature document preview for long-form navigation. */
|
|
1675
|
+
contentMinimap?: RichTextEditorContentMinimap;
|
|
1676
|
+
|
|
1677
|
+
/** In-editor accessibility audit and repair workflow. */
|
|
1678
|
+
accessibilityChecker?: RichTextEditorAccessibilityChecker;
|
|
1679
|
+
|
|
1680
|
+
/** Persistent review ledger (pending / accepted / rejected). */
|
|
1681
|
+
reviewLedger?: RichTextEditorReviewLedger;
|
|
1682
|
+
|
|
1683
|
+
/** Escape hatch for plugin-attached APIs not covered by these declarations. */
|
|
1684
|
+
[key: string]: unknown;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
// =====================
|
|
1688
|
+
// Constructor
|
|
1689
|
+
// =====================
|
|
1690
|
+
|
|
1691
|
+
export interface RichTextEditorConfig {
|
|
1692
|
+
toolbar?: string | string[];
|
|
1693
|
+
height?: string | number;
|
|
1694
|
+
width?: string | number;
|
|
1695
|
+
iframe?: boolean;
|
|
1696
|
+
showSource?: boolean;
|
|
1697
|
+
contentCssUrl?: string;
|
|
1698
|
+
contentCssText?: string;
|
|
1699
|
+
enableAiToolkit?: boolean;
|
|
1700
|
+
enableStructuredContent?: boolean;
|
|
1701
|
+
enableRevisionHistory?: boolean;
|
|
1702
|
+
enableComments?: boolean;
|
|
1703
|
+
enableMentions?: boolean;
|
|
1704
|
+
enableSlashCommands?: boolean;
|
|
1705
|
+
enableTrackChanges?: boolean;
|
|
1706
|
+
enableYjsCollab?: boolean;
|
|
1707
|
+
enableDictation?: boolean;
|
|
1708
|
+
showStatistics?: boolean;
|
|
1709
|
+
statisticsDisplayMode?: "characters" | "words" | "both";
|
|
1710
|
+
statisticsShowSelection?: boolean;
|
|
1711
|
+
placeholder?: string;
|
|
1712
|
+
placeholderShowOnlyWhenEditable?: boolean;
|
|
1713
|
+
placeholderColor?: string;
|
|
1714
|
+
commentsOnly?: boolean;
|
|
1715
|
+
documentOutlineEnabled?: boolean;
|
|
1716
|
+
documentOutlineAutoOpen?: boolean;
|
|
1717
|
+
documentOutlineTitle?: string;
|
|
1718
|
+
documentOutlineHint?: string;
|
|
1719
|
+
documentOutlineEmptyText?: string;
|
|
1720
|
+
documentOutlineMinLevel?: number;
|
|
1721
|
+
documentOutlineMaxLevel?: number;
|
|
1722
|
+
contentMinimapEnabled?: boolean;
|
|
1723
|
+
contentMinimapAutoOpen?: boolean;
|
|
1724
|
+
contentMinimapTitle?: string;
|
|
1725
|
+
contentMinimapHint?: string;
|
|
1726
|
+
contentMinimapEmptyText?: string;
|
|
1727
|
+
contentMinimapWidth?: number;
|
|
1728
|
+
contentMinimapScale?: number;
|
|
1729
|
+
accessibilityCheckerEnabled?: boolean;
|
|
1730
|
+
accessibilityCheckerAutoOpen?: boolean;
|
|
1731
|
+
accessibilityCheckerTitle?: string;
|
|
1732
|
+
accessibilityCheckerHint?: string;
|
|
1733
|
+
accessibilityCheckerEmptyText?: string;
|
|
1734
|
+
restrictedEditingEnabled?: boolean;
|
|
1735
|
+
restrictedEditingMode?: boolean;
|
|
1736
|
+
restrictedEditingEditableAttr?: string;
|
|
1737
|
+
restrictedEditingEditableClassName?: string;
|
|
1738
|
+
restrictedEditingNavigable?: boolean;
|
|
1739
|
+
showTagList?: boolean;
|
|
1740
|
+
showFloatTextToolBar?: boolean;
|
|
1741
|
+
showFloatParagraph?: boolean;
|
|
1742
|
+
editorResizeMode?: "both" | "horizontal" | "vertical" | "none";
|
|
1743
|
+
/**
|
|
1744
|
+
* Notion-style block drag handles (2.3.0): hovering a top-level block shows a
|
|
1745
|
+
* ⋮⋮ handle to drag-reorder blocks. Default: `true`. Set `false` to disable.
|
|
1746
|
+
*/
|
|
1747
|
+
blockDragHandles?: boolean;
|
|
1748
|
+
|
|
1749
|
+
// ---- Auto-formatting on type ----
|
|
1750
|
+
/** Type a URL / email followed by space → auto-wraps it in an `<a>`. Default: `true`. */
|
|
1751
|
+
autoLinkOnType?: boolean;
|
|
1752
|
+
/** Auto-assign stable slug IDs to `<h1>`–`<h6>` so deep links / TOC navigation work. Default: `true`. */
|
|
1753
|
+
autoHeadingAnchors?: boolean;
|
|
1754
|
+
/** Show a 🔗 "copy link" icon on hover over `<h1>`–`<h6>`. Default: `true`. */
|
|
1755
|
+
copyHeadingLink?: boolean;
|
|
1756
|
+
/** Master toggle for smart typography (curly quotes, em-dash, ellipsis, trademarks). Default: `true`. */
|
|
1757
|
+
smartTypography?: boolean;
|
|
1758
|
+
/** `--` → em-dash on type. Default: `true`. */
|
|
1759
|
+
smartTypographyDashes?: boolean;
|
|
1760
|
+
/** `...` → `…` on type. Default: `true`. */
|
|
1761
|
+
smartTypographyEllipsis?: boolean;
|
|
1762
|
+
/** `(c)` → ©, `(r)` → ®, `(tm)` → ™. Default: `true`. */
|
|
1763
|
+
smartTypographyTrademarks?: boolean;
|
|
1764
|
+
/** Straight quotes → curly quotes (apostrophe-aware). Default: `true`. */
|
|
1765
|
+
smartTypographyQuotes?: boolean;
|
|
1766
|
+
/** Markdown-style **block** shortcuts: `# `/`## `/`### ` → headings, `> ` → blockquote, `- `/`* ` → bullet list, `1. ` → numbered list, `---`/`***`/`___` + Enter → `<hr>`. Default: `true`. */
|
|
1767
|
+
markdownShortcutsEnabled?: boolean;
|
|
1768
|
+
/** Markdown-style **inline** autoformat, applied when the closing delimiter is typed: `**bold**`/`__bold__` → `<strong>`, `*italic*`/`_italic_` → `<em>`, `` `code` `` → `<code>`, `~~strike~~` → `<s>`. Opening delimiter must sit at a word boundary (math, globs and snake_case are left alone). Default: `true`. */
|
|
1769
|
+
markdownInlineEnabled?: boolean;
|
|
1770
|
+
/** Right-click on selected text shows AI menu (Ask AI / Rewrite / Summarize / Translate). Default: `true`. */
|
|
1771
|
+
aiContextMenu?: boolean;
|
|
1772
|
+
|
|
1773
|
+
// ---- Paste pipeline knobs ----
|
|
1774
|
+
/**
|
|
1775
|
+
* Show a brief "Cleaned from Word / Google Docs / LibreOffice / Notion / Excel / Confluence"
|
|
1776
|
+
* toast after the paste cleanup pipeline strips Office-source artefacts. Default: `true`.
|
|
1777
|
+
*/
|
|
1778
|
+
smartPasteToast?: boolean;
|
|
1779
|
+
/**
|
|
1780
|
+
* When pasting a URL / email while text is selected, wrap the selection in `<a href>`
|
|
1781
|
+
* instead of replacing it. Matches Google Docs / Notion / TipTap / ProseMirror
|
|
1782
|
+
* behavior. Default: `true`.
|
|
1783
|
+
*/
|
|
1784
|
+
smartLinkPaste?: boolean;
|
|
1785
|
+
/**
|
|
1786
|
+
* Paste mode override. `"text"` / `"pastetext"` forces plain-text paste; `"word"` /
|
|
1787
|
+
* `"pasteword"` runs the Word-paste cleanup pipeline even on non-Word HTML; `"disable"`
|
|
1788
|
+
* / `"disabled"` blocks paste entirely.
|
|
1789
|
+
*/
|
|
1790
|
+
pasteMode?: "text" | "pastetext" | "word" | "pasteword" | "disable" | "disabled";
|
|
1791
|
+
|
|
1792
|
+
// ---- Modern block types (2.3.0) ----
|
|
1793
|
+
/**
|
|
1794
|
+
* Callout/admonition variants offered by the callout block. Each entry is
|
|
1795
|
+
* `{ id, label, icon }`; `icon` is a string (emoji or text) shown in the
|
|
1796
|
+
* callout. Defaults to info / success / warning / danger / note.
|
|
1797
|
+
*/
|
|
1798
|
+
calloutTypes?: Array<{ id: string; label: string; icon: string }>;
|
|
1799
|
+
/** Default callout variant id used when inserting without an explicit type. Default: `"info"`. */
|
|
1800
|
+
calloutDefaultType?: string;
|
|
1801
|
+
/** Default column count for the columns block (clamped 2–4). Default: `2`. */
|
|
1802
|
+
columnsDefaultCount?: number;
|
|
1803
|
+
|
|
1804
|
+
// ---- Equation editor (2.3.0) ----
|
|
1805
|
+
/**
|
|
1806
|
+
* When true, `editor.applyMathMarkup()` wraps `$...$` runs in
|
|
1807
|
+
* `<span class="rte-math-inline" data-tex="...">` so a host-loaded math
|
|
1808
|
+
* renderer (KaTeX / MathJax) can target them, and the equation-editor dialog
|
|
1809
|
+
* (`insertmath`) is available. Default: `true`.
|
|
1810
|
+
*/
|
|
1811
|
+
inlineMath?: boolean;
|
|
1812
|
+
/** Sample equations shown as quick-insert chips in the equation-editor dialog. */
|
|
1813
|
+
mathDialogSamples?: string[];
|
|
1814
|
+
|
|
1815
|
+
// ---- Bookmark preview cards (2.3.0) ----
|
|
1816
|
+
/**
|
|
1817
|
+
* Optional resolver for rich bookmark previews. Given a URL, return a promise
|
|
1818
|
+
* of `{ title, description, image, favicon }` (any field optional). When omitted,
|
|
1819
|
+
* the `insertbookmark` command renders a basic card from the URL + favicon.
|
|
1820
|
+
*/
|
|
1821
|
+
bookmarkResolver?: (url: string) => Promise<{ title?: string; description?: string; image?: string; favicon?: string }>;
|
|
1822
|
+
/**
|
|
1823
|
+
* Favicon service URL prefix (the page domain is appended + URL-encoded). Defaults
|
|
1824
|
+
* to the public Google s2 favicon endpoint. Set to `""` to disable favicon fetch.
|
|
1825
|
+
*/
|
|
1826
|
+
bookmarkFaviconService?: string;
|
|
1827
|
+
|
|
1828
|
+
// ---- Spell check (2.3.0) ----
|
|
1829
|
+
/**
|
|
1830
|
+
* When true (default), the editable carries `spellcheck="true"` so the browser's
|
|
1831
|
+
* native checker underlines misspellings.
|
|
1832
|
+
*/
|
|
1833
|
+
spellCheckEnabled?: boolean;
|
|
1834
|
+
/**
|
|
1835
|
+
* Optional spell-check service (BYOK). Given the document text, return a promise
|
|
1836
|
+
* of issues `[{ word, offset?, length?, suggestions: string[] }]`. When set, the
|
|
1837
|
+
* `spellcheck` command opens a review panel with click-to-replace suggestions;
|
|
1838
|
+
* when omitted it falls back to the browser's native spell-check.
|
|
1839
|
+
*/
|
|
1840
|
+
spellCheckResolver?: (text: string) => Promise<Array<{ word: string; offset?: number; length?: number; suggestions?: string[] }>>;
|
|
1841
|
+
|
|
1842
|
+
// ---- Smart chips (2.3.0) ----
|
|
1843
|
+
/**
|
|
1844
|
+
* Optional resolver for Person / Link smart chips (BYOK). Given a query and chip
|
|
1845
|
+
* type, return a promise of `[{ label, value, icon?, href? }]`. Date chips need
|
|
1846
|
+
* no resolver. When omitted, Person/Link chips fall back to a plain text input.
|
|
1847
|
+
*/
|
|
1848
|
+
chipResolver?: (query: string, type: "person" | "link") => Promise<Array<{ label?: string; value?: string; icon?: string; href?: string }>>;
|
|
1849
|
+
/** Optional date formatter for date chips: `(date: Date) => string`. Defaults to "Mon D, YYYY". */
|
|
1850
|
+
chipDateFormat?: (date: Date) => string;
|
|
1851
|
+
|
|
1852
|
+
// ---- Email export (2.3.0) ----
|
|
1853
|
+
/**
|
|
1854
|
+
* Whitelist of CSS properties inlined onto each element by `getEmailHTML()`.
|
|
1855
|
+
* Kept small by default to avoid bloat. Provide your own array to widen or
|
|
1856
|
+
* narrow the set. Defaults to color/background/font/text/spacing/border props.
|
|
1857
|
+
*/
|
|
1858
|
+
emailInlineProperties?: string[];
|
|
1859
|
+
/** Max content width (px) of the centered table `getEmailHTML()` wraps content in. Default 640. */
|
|
1860
|
+
emailWrapWidth?: number;
|
|
1861
|
+
|
|
1862
|
+
// ---- Mermaid diagrams (2.3.0) ----
|
|
1863
|
+
/**
|
|
1864
|
+
* Optional server-side diagram renderer (BYOK). Given Mermaid source, return a
|
|
1865
|
+
* promise of `{ svg }` or `{ imageUrl }` (e.g. a Kroki endpoint). When omitted,
|
|
1866
|
+
* the plugin uses a `window.mermaid` instance loaded by the host page, and
|
|
1867
|
+
* falls back to showing the source when neither is available.
|
|
1868
|
+
*/
|
|
1869
|
+
diagramResolver?: (source: string) => Promise<{ svg?: string; imageUrl?: string }>;
|
|
1870
|
+
/** Starter Mermaid snippets shown as chips in the diagram dialog. */
|
|
1871
|
+
diagramSamples?: string[];
|
|
1872
|
+
|
|
1873
|
+
// ---- Auto-embed (2.3.0) ----
|
|
1874
|
+
/** Auto-convert a bare YouTube/Vimeo URL pasted on its own line into a responsive embed. Default `true`. */
|
|
1875
|
+
autoEmbedEnabled?: boolean;
|
|
1876
|
+
/**
|
|
1877
|
+
* Optional resolver to support providers beyond the built-in YouTube/Vimeo.
|
|
1878
|
+
* Given a pasted URL, return a trusted `https://` provider embed URL (used as
|
|
1879
|
+
* the iframe src) or `null` to decline.
|
|
1880
|
+
*/
|
|
1881
|
+
autoEmbedResolver?: (url: string) => string | null;
|
|
1882
|
+
|
|
1883
|
+
// ---- Foldable headings (2.3.0) ----
|
|
1884
|
+
/** Enable collapsible heading sections (gutter chevron + `toggleHeadingFold`/`foldAtCaret`/`unfoldAll`). Default `true`. */
|
|
1885
|
+
foldHeadingsEnabled?: boolean;
|
|
1886
|
+
|
|
1887
|
+
// ---- Typewriter / focus writing modes (2.3.0) ----
|
|
1888
|
+
/** Start with typewriter scrolling active (caret line pinned to a fixed vertical anchor). Default `false`. Toggle at runtime via `toggleTypewriterMode`. */
|
|
1889
|
+
typewriterModeEnabled?: boolean;
|
|
1890
|
+
/** Start with focus mode active (dim every block except the current one). Default `false`. Toggle at runtime via `toggleFocusMode`. */
|
|
1891
|
+
focusModeEnabled?: boolean;
|
|
1892
|
+
/** Fraction (0.15–0.85) of the viewport height the caret line is held at in typewriter mode. `0.5` = vertical centre (default). */
|
|
1893
|
+
typewriterAnchor?: number;
|
|
1894
|
+
|
|
1895
|
+
// ---- Markdown export (2.3.0) ----
|
|
1896
|
+
/** Enable the Copy/Download-as-Markdown commands and `getMarkdown`/`copyAsMarkdown`/`downloadMarkdown` API. Default `true`. */
|
|
1897
|
+
markdownExportEnabled?: boolean;
|
|
1898
|
+
|
|
1899
|
+
// ---- Word export (2.3.2) ----
|
|
1900
|
+
/** Enable Export-to-Word (`exportToWord`/`getWordDocument` API, `exportword` command, `/export word` slash). Default `true`. */
|
|
1901
|
+
wordExport?: boolean;
|
|
1902
|
+
/** Default base file name for `exportToWord()` (derived from the first heading when unset). */
|
|
1903
|
+
wordExportFileName?: string;
|
|
1904
|
+
/** Body font-family for the exported Word document. Default `"Calibri, 'Segoe UI', Arial, sans-serif"`. */
|
|
1905
|
+
wordExportFontFamily?: string;
|
|
1906
|
+
/** Body font-size for the exported Word document. Default `"11pt"`. */
|
|
1907
|
+
wordExportFontSize?: string;
|
|
1908
|
+
/** `@page` size for the exported Word document. Default `"8.5in 11in"` (Letter); use `"21cm 29.7cm"` for A4. */
|
|
1909
|
+
wordExportPageSize?: string;
|
|
1910
|
+
/** `@page` margin for the exported Word document. Default `"1in"`. */
|
|
1911
|
+
wordExportMargin?: string;
|
|
1912
|
+
/** Export in landscape orientation. Default `false`. */
|
|
1913
|
+
wordExportLandscape?: boolean;
|
|
1914
|
+
|
|
1915
|
+
// ---- Document import (2.3.2) ----
|
|
1916
|
+
/** Enable file import (`importFile`/`openImportDialog` API, `importdocument` command, `/import` slash). Default `true`. */
|
|
1917
|
+
documentImport?: boolean;
|
|
1918
|
+
/** Import behavior: `replace` (default) swaps the document; `insert` adds at the caret. */
|
|
1919
|
+
documentImportMode?: "replace" | "insert";
|
|
1920
|
+
/** `accept` attribute for the import file picker. */
|
|
1921
|
+
documentImportAccept?: string;
|
|
1922
|
+
/** Optional converter — `(file) => htmlString | Promise<htmlString>`. Lets a host handle `.docx` (or override any type) server-side. */
|
|
1923
|
+
documentImportResolver?: (file: File) => string | Promise<string>;
|
|
1924
|
+
|
|
1925
|
+
// ---- Readability statistics (2.3.2) ----
|
|
1926
|
+
/** Enable readability stats (`getReadabilityStats`/`countSyllables` API, `readability` command, `/readability` slash). Default `true`. */
|
|
1927
|
+
readabilityStats?: boolean;
|
|
1928
|
+
/** Reading speed (words/minute) for the reading-time estimate. Default `200`. */
|
|
1929
|
+
readabilityWordsPerMinute?: number;
|
|
1930
|
+
|
|
1931
|
+
// ---- Character / word limit (2.3.2) ----
|
|
1932
|
+
/** Maximum characters (0 / unset = no limit). Enables the char-limit plugin. */
|
|
1933
|
+
maxLength?: number;
|
|
1934
|
+
/** Maximum words (0 / unset = no limit). */
|
|
1935
|
+
maxWords?: number;
|
|
1936
|
+
/** Block input past the limit. Default `true`. */
|
|
1937
|
+
charLimitEnforce?: boolean;
|
|
1938
|
+
/** Show the floating live counter. Default `true`. */
|
|
1939
|
+
charLimitShowCounter?: boolean;
|
|
1940
|
+
|
|
1941
|
+
// ---- Accessibility metadata (2.3.0) ----
|
|
1942
|
+
/** Add assistive-technology metadata (iframe title, editing-region `role="textbox"`/`aria-label`, document `lang`). Default `true`. */
|
|
1943
|
+
a11yEnhance?: boolean;
|
|
1944
|
+
/** Accessible name announced for the editing region and iframe (WCAG 4.1.2). Default `"Rich text editor. Editing area."`. */
|
|
1945
|
+
contentAriaLabel?: string;
|
|
1946
|
+
/** BCP-47 language tag applied to the editing document (WCAG 3.1.1). Defaults to the host page `<html lang>` or `"en"`. */
|
|
1947
|
+
contentLang?: string;
|
|
1948
|
+
/** Add `role="dialog"` + accessible names to dialog popups and `aria-label`s to their fields (WCAG 4.1.2 / 1.3.1 / 3.3.2). Default `true`. */
|
|
1949
|
+
dialogA11y?: boolean;
|
|
1950
|
+
|
|
1951
|
+
// ---- Local draft autosave / recovery (2.3.0) ----
|
|
1952
|
+
/**
|
|
1953
|
+
* Persist the document to localStorage as you type and offer to restore it on
|
|
1954
|
+
* the next load (crash / refresh recovery). `true` for defaults, or an options
|
|
1955
|
+
* object. Off by default. The `editor.saveLocalDraft`/`restoreLocalDraft`/etc.
|
|
1956
|
+
* API is always available regardless of this flag.
|
|
1957
|
+
*/
|
|
1958
|
+
localDraft?: boolean | {
|
|
1959
|
+
/** Storage key suffix (default: editor id or page path). */
|
|
1960
|
+
key?: string;
|
|
1961
|
+
/** Debounce between autosaves in ms (default 2500). */
|
|
1962
|
+
intervalMs?: number;
|
|
1963
|
+
/** Drop drafts older than this many ms (default 14 days). */
|
|
1964
|
+
ttlMs?: number;
|
|
1965
|
+
/** Show the built-in restore bar on load (default true). */
|
|
1966
|
+
promptRestore?: boolean;
|
|
1967
|
+
};
|
|
1968
|
+
|
|
1969
|
+
// ---- AI ghost-text autocomplete (2.3.0) ----
|
|
1970
|
+
/**
|
|
1971
|
+
* Enable Copilot/Notion-style inline AI completion: after a typing pause a
|
|
1972
|
+
* greyed suggestion appears after the caret (Tab accepts, Esc / typing
|
|
1973
|
+
* dismisses). `true` for defaults or an options object. Requires
|
|
1974
|
+
* `ghostTextResolver` to be set — inert otherwise. Off by default.
|
|
1975
|
+
*/
|
|
1976
|
+
ghostText?: boolean | {
|
|
1977
|
+
/** Idle delay before requesting a suggestion, ms (default 600). */
|
|
1978
|
+
delayMs?: number;
|
|
1979
|
+
/** Minimum non-space chars of left context before requesting (default 3). */
|
|
1980
|
+
minChars?: number;
|
|
1981
|
+
/** Max chars of left context passed to the resolver (default 2000). */
|
|
1982
|
+
maxContext?: number;
|
|
1983
|
+
};
|
|
1984
|
+
/**
|
|
1985
|
+
* Bring-your-own completion source. Receives the text around the caret and
|
|
1986
|
+
* returns the continuation string (or a promise of one). No model ships by
|
|
1987
|
+
* default and no network call is made without this.
|
|
1988
|
+
*/
|
|
1989
|
+
ghostTextResolver?: ((context: { before: string; after: string; full: string }) => string | Promise<string>) | null;
|
|
1990
|
+
|
|
1991
|
+
// ---- Read aloud (2.3.0) ----
|
|
1992
|
+
/** Default speech rate for read-aloud (0.5–2). Default 1.0. */
|
|
1993
|
+
readAloudRate?: number;
|
|
1994
|
+
/** Highlight each sentence (via the native selection) as it is spoken. Default `true`. */
|
|
1995
|
+
readAloudHighlight?: boolean;
|
|
1996
|
+
|
|
1997
|
+
// ---- Emoji :shortcode: autocomplete (2.3.0) ----
|
|
1998
|
+
/** Enable inline emoji autocomplete: complete `:shortcode:` → emoji, and a `:query` popup. Default `true`. */
|
|
1999
|
+
emojiAutocompleteEnabled?: boolean;
|
|
2000
|
+
/**
|
|
2001
|
+
* Map of `shortcode` → emoji used by the autocomplete (GitHub/Slack style, e.g.
|
|
2002
|
+
* `{ fire: "🔥", "+1": "👍" }`). Provide your own to extend or replace the
|
|
2003
|
+
* built-in curated set.
|
|
2004
|
+
*/
|
|
2005
|
+
emojiShortcodes?: Record<string, string>;
|
|
2006
|
+
|
|
2007
|
+
/** Any additional config flag understood by the editor. */
|
|
2008
|
+
[key: string]: unknown;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
export interface RichTextEditorConstructor {
|
|
2012
|
+
/** Audit HTML or structured-content documents for common accessibility issues. */
|
|
2013
|
+
auditAccessibility(value: RichTextEditorStructuredInput): RichTextEditorAccessibilityResult;
|
|
2014
|
+
/** Audit link marks for empty, unsafe, malformed, or policy-disallowed destinations. */
|
|
2015
|
+
auditLinks(
|
|
2016
|
+
value: RichTextEditorStructuredInput,
|
|
2017
|
+
options?: RichTextEditorLinkAuditOptions
|
|
2018
|
+
): RichTextEditorLinkAuditResult;
|
|
2019
|
+
/** Apply a supported accessibility repair and return the updated structured document. */
|
|
2020
|
+
repairAccessibilityIssue(
|
|
2021
|
+
value: RichTextEditorStructuredInput,
|
|
2022
|
+
issue: RichTextEditorAccessibilityIssue,
|
|
2023
|
+
options?: RichTextEditorAccessibilityRepairOptions
|
|
2024
|
+
): RichTextEditorStructuredDocument;
|
|
2025
|
+
/** Read document-level page setup metadata from HTML or structured-content JSON. */
|
|
2026
|
+
getDocumentPageSetup(value: RichTextEditorStructuredInput): RichTextEditorPageSetup | null;
|
|
2027
|
+
/** Compute richer document metrics such as paragraphs, headings, links, and estimated reading time. */
|
|
2028
|
+
getDocumentMetrics(
|
|
2029
|
+
value: RichTextEditorStructuredInput,
|
|
2030
|
+
options?: {
|
|
2031
|
+
selectionText?: string | null | undefined;
|
|
2032
|
+
wordsPerMinute?: number | null | undefined;
|
|
2033
|
+
}
|
|
2034
|
+
): RichTextEditorDocumentMetrics;
|
|
2035
|
+
/** Extract a flat heading outline suitable for document navigation sidebars. */
|
|
2036
|
+
getDocumentOutline(value: RichTextEditorStructuredInput): RichTextEditorDocumentOutlineItem[];
|
|
2037
|
+
/** Returns document footnotes in numeric/source order for review/sidebar workflows. */
|
|
2038
|
+
getFootnotes(value: RichTextEditorStructuredInput): RichTextEditorFootnoteItem[];
|
|
2039
|
+
/** Build a nested table-of-contents tree from the document headings. */
|
|
2040
|
+
getTableOfContents(
|
|
2041
|
+
value: RichTextEditorStructuredInput,
|
|
2042
|
+
options?: RichTextEditorTableOfContentsOptions
|
|
2043
|
+
): RichTextEditorTableOfContentsItem[];
|
|
2044
|
+
new (container: string | Element, config?: RichTextEditorConfig): RichTextEditorInstance;
|
|
2045
|
+
/** Parse Markdown and return a structured-content document. */
|
|
2046
|
+
fromMarkdown(markdown: string): RichTextEditorStructuredDocument;
|
|
2047
|
+
prototype: RichTextEditorInstance;
|
|
2048
|
+
/** Server-safe HTML render of a structured-content document or HTML string. */
|
|
2049
|
+
renderHTML(value: RichTextEditorStructuredInput): string;
|
|
2050
|
+
/** Return a copy of the document with normalized page setup metadata applied. */
|
|
2051
|
+
setDocumentPageSetup(
|
|
2052
|
+
value: RichTextEditorStructuredInput,
|
|
2053
|
+
pageSetup: RichTextEditorPageSetup | null
|
|
2054
|
+
): RichTextEditorStructuredDocument;
|
|
2055
|
+
/** Repopulate any `tableOfContents` nodes from the current heading structure. */
|
|
2056
|
+
syncTableOfContents(
|
|
2057
|
+
value: RichTextEditorStructuredInput,
|
|
2058
|
+
options?: RichTextEditorTableOfContentsOptions
|
|
2059
|
+
): RichTextEditorStructuredDocument;
|
|
2060
|
+
/** Convert a structured-content document or HTML string to Markdown. */
|
|
2061
|
+
toMarkdown(value: RichTextEditorStructuredInput): string;
|
|
2062
|
+
/** Validate a structured-content document against the editor's schema. */
|
|
2063
|
+
validateStructuredContent(value: RichTextEditorStructuredInput): RichTextEditorValidationResult;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
declare global {
|
|
2067
|
+
interface Window {
|
|
2068
|
+
RichTextEditor: RichTextEditorConstructor;
|
|
2069
|
+
RTE_DefaultConfig?: RichTextEditorConfig;
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
declare const RichTextEditor: RichTextEditorConstructor;
|
|
2074
|
+
|
|
2075
|
+
export default RichTextEditor;
|