@primeui/texteditor-types 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/texteditor.types.d.ts +819 -0
- package/package.json +52 -0
- package/src/index.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 PrimeTek
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# PrimeUI TextEditor Types
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './texteditor.types';
|
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
import type { ComponentContext, ComponentInstance } from '@primeui/core/types/api';
|
|
2
|
+
import type { UIElement } from '@primeui/core/types/shared';
|
|
3
|
+
import type { EditorState, Command as PMCommand, Plugin as PMPlugin } from 'prosemirror-state';
|
|
4
|
+
import type { EditorView } from 'prosemirror-view';
|
|
5
|
+
/**
|
|
6
|
+
* Viewport coordinates and dimensions of the text caret, used to position
|
|
7
|
+
* floating UI such as the context toolbar, slash menu, and mention popup.
|
|
8
|
+
* @group Interface
|
|
9
|
+
*/
|
|
10
|
+
export interface CaretPosition {
|
|
11
|
+
/** Distance from the top of the viewport to the top of the caret, in pixels. */
|
|
12
|
+
top: number;
|
|
13
|
+
/** Distance from the left of the viewport to the caret, in pixels. */
|
|
14
|
+
left: number;
|
|
15
|
+
/** Distance from the top of the viewport to the bottom of the caret, in pixels. */
|
|
16
|
+
bottom: number;
|
|
17
|
+
/** Height of the caret, in pixels. */
|
|
18
|
+
height: number;
|
|
19
|
+
/** Width of the caret, in pixels. */
|
|
20
|
+
width: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Upload slot entry — represents a single file in the upload UI
|
|
24
|
+
* @group Interface
|
|
25
|
+
*/
|
|
26
|
+
export interface UploadSlotEntry {
|
|
27
|
+
/** Unique identifier for the upload slot. */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Original name of the file being uploaded. */
|
|
30
|
+
fileName: string;
|
|
31
|
+
/** Size of the file in bytes. */
|
|
32
|
+
fileSize: number;
|
|
33
|
+
/** Human-readable file size (e.g. "1.2 MB"). */
|
|
34
|
+
fileSizeFormatted: string;
|
|
35
|
+
/** Upload progress as a percentage (0–100). */
|
|
36
|
+
progress: number;
|
|
37
|
+
/** Current state of the upload. */
|
|
38
|
+
status: 'uploading' | 'complete' | 'error' | 'cancelled';
|
|
39
|
+
/** Aborts the in-progress upload for this slot. */
|
|
40
|
+
cancel: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A heading entry extracted from the document
|
|
44
|
+
* @group Interface
|
|
45
|
+
*/
|
|
46
|
+
export interface TextEditorHeadingEntry {
|
|
47
|
+
/** ProseMirror document position of the heading node */
|
|
48
|
+
pos: number;
|
|
49
|
+
/** Heading level (1-6) */
|
|
50
|
+
level: number;
|
|
51
|
+
/** Plain text content of the heading */
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* TextEditor component refs
|
|
56
|
+
* @group Interface
|
|
57
|
+
*/
|
|
58
|
+
export interface TextEditorRefs {
|
|
59
|
+
/** Reference to the editor content element */
|
|
60
|
+
element?: UIElement;
|
|
61
|
+
/** Reference to the block mode container element (Block mode) */
|
|
62
|
+
blockModeElement?: UIElement;
|
|
63
|
+
/** Reference to the file input element for image uploads */
|
|
64
|
+
fileInputElement?: UIElement;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* TextEditor mode
|
|
68
|
+
* @group Types
|
|
69
|
+
*/
|
|
70
|
+
export type TextEditorMode = 'classic' | 'block';
|
|
71
|
+
/**
|
|
72
|
+
* TextEditor component props
|
|
73
|
+
* @group Props
|
|
74
|
+
*/
|
|
75
|
+
export interface TextEditorProps {
|
|
76
|
+
/** Editor value: string for classic mode, string[] for block mode */
|
|
77
|
+
value?: string | string[] | null | undefined;
|
|
78
|
+
/** Editor mode: 'classic' (toolbar editor) or 'block' (Notion-like block editor) */
|
|
79
|
+
mode?: TextEditorMode | null | undefined;
|
|
80
|
+
/** Placeholder text displayed inside an empty editor */
|
|
81
|
+
placeholder?: string | null | undefined;
|
|
82
|
+
/** Placeholder text displayed after '/' when slash commands are active (e.g. "Type to search") */
|
|
83
|
+
slashPlaceholder?: string | null | undefined;
|
|
84
|
+
/** Placeholder text displayed inside empty checklist items (e.g. "To-Do") */
|
|
85
|
+
checklistPlaceholder?: string | null | undefined;
|
|
86
|
+
/** Accepted file types for image uploads. Defaults to 'image/*'. */
|
|
87
|
+
allowedImageTypes?: string | undefined;
|
|
88
|
+
/** Accepted file types for document uploads. */
|
|
89
|
+
allowedDocumentTypes?: string | undefined;
|
|
90
|
+
/** Maximum number of images allowed per upload selection. */
|
|
91
|
+
imageMaxFileCount?: number | null | undefined;
|
|
92
|
+
/** Maximum image file size in bytes per file. */
|
|
93
|
+
imageMaxFileSize?: number | null | undefined;
|
|
94
|
+
/** Maximum number of documents allowed per upload selection. */
|
|
95
|
+
documentMaxFileCount?: number | null | undefined;
|
|
96
|
+
/** Maximum document file size in bytes per file. */
|
|
97
|
+
documentMaxFileSize?: number | null | undefined;
|
|
98
|
+
/** Enables the document navigator minimap. Default: false */
|
|
99
|
+
navigator?: boolean | undefined;
|
|
100
|
+
/** Enables markdown input rules (e.g. # heading, **bold**, - list). Default: false */
|
|
101
|
+
markdown?: boolean | undefined;
|
|
102
|
+
/** Debounce (ms) for `value-change`. Default 0 (immediate). */
|
|
103
|
+
valueChangeDebounce?: number | null | undefined;
|
|
104
|
+
/** Minimum column width in pixels for table column resize. Default: 40 */
|
|
105
|
+
minTableColumnWidth?: number | null | undefined;
|
|
106
|
+
/** Default column width in pixels when inserting a new table or adding columns. Default: 120 */
|
|
107
|
+
defaultTableColumnWidth?: number | null | undefined;
|
|
108
|
+
/** Color applied by the one-click highlight toggle and `==` rule. Default: soft yellow. */
|
|
109
|
+
defaultHighlightColor?: string | null | undefined;
|
|
110
|
+
/** Upload handler fallback when image/document handlers aren't set. */
|
|
111
|
+
uploadHandler?: ((file: File, options: {
|
|
112
|
+
onProgress: (percent: number) => void;
|
|
113
|
+
signal: AbortSignal;
|
|
114
|
+
}) => Promise<string>) | undefined;
|
|
115
|
+
/** Image upload handler; takes precedence over uploadHandler. */
|
|
116
|
+
imageUploadHandler?: ((file: File, options: {
|
|
117
|
+
onProgress: (percent: number) => void;
|
|
118
|
+
signal: AbortSignal;
|
|
119
|
+
}) => Promise<string>) | undefined;
|
|
120
|
+
/** Document upload handler; takes precedence over uploadHandler. */
|
|
121
|
+
documentUploadHandler?: ((file: File, options: {
|
|
122
|
+
onProgress: (percent: number) => void;
|
|
123
|
+
signal: AbortSignal;
|
|
124
|
+
}) => Promise<string>) | undefined;
|
|
125
|
+
/** Handler for fetching mention suggestions. Receives the current
|
|
126
|
+
* `@…` query and returns an array (or promise of array) of items. */
|
|
127
|
+
mentionHandler?: ((query: string) => unknown[] | Promise<unknown[]>) | undefined;
|
|
128
|
+
/** Field name used to filter mention items (e.g. 'name', 'label') */
|
|
129
|
+
mentionFilterField?: string | undefined;
|
|
130
|
+
/** Custom template function for rendering mention chips */
|
|
131
|
+
mentionTemplate?: ((data: unknown) => string) | undefined;
|
|
132
|
+
/** Array of editor plugins */
|
|
133
|
+
plugins?: unknown[] | undefined;
|
|
134
|
+
/** Disables editing and toolbar interactions while still rendering content. */
|
|
135
|
+
disabled?: boolean | undefined;
|
|
136
|
+
/** Keeps content selectable / copyable but blocks edits. */
|
|
137
|
+
readonly?: boolean | undefined;
|
|
138
|
+
/** Accessible name for the editor region (WCAG 4.1.2). */
|
|
139
|
+
ariaLabel?: string | undefined;
|
|
140
|
+
/** ID(s) of element(s) labelling the editor region (alternative to ariaLabel). */
|
|
141
|
+
ariaLabelledby?: string | undefined;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* TextEditor component state
|
|
145
|
+
* @group State
|
|
146
|
+
*/
|
|
147
|
+
export interface TextEditorState {
|
|
148
|
+
/** Snapshot of the active formatting at the current selection. */
|
|
149
|
+
formatState?: TextEditorFormatState | null | undefined;
|
|
150
|
+
/** Currently hovered block index (block mode) */
|
|
151
|
+
hoveredBlockIndex?: number | null | undefined;
|
|
152
|
+
/** Block index being dragged (block mode) */
|
|
153
|
+
draggedBlockIndex?: number | null | undefined;
|
|
154
|
+
/** Drop indicator position - shows line above this index (block mode) */
|
|
155
|
+
dropIndicatorIndex?: number | null | undefined;
|
|
156
|
+
/** Whether mention feature is enabled (determined by #mention-list slot existence) */
|
|
157
|
+
isMentionEnabled?: boolean;
|
|
158
|
+
/** Whether slash commands are enabled (determined by #slash-menu slot existence) */
|
|
159
|
+
isSlashCommandsEnabled?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* TextEditor component event emitters
|
|
163
|
+
* @group Events
|
|
164
|
+
*/
|
|
165
|
+
export interface TextEditorEmits {
|
|
166
|
+
/** Emitted when editor content value changes */
|
|
167
|
+
valueChange: (value: string | string[]) => void;
|
|
168
|
+
/** Emitted when editor format state changes */
|
|
169
|
+
formatStateChange: (value: TextEditorFormatState) => void;
|
|
170
|
+
/** Emitted when the selection changes (caret move or range change) without a document edit */
|
|
171
|
+
selectionUpdate: () => void;
|
|
172
|
+
/** Emitted when the editor gains focus */
|
|
173
|
+
editorFocus: () => void;
|
|
174
|
+
/** Emitted when the editor loses focus */
|
|
175
|
+
editorBlur: () => void;
|
|
176
|
+
/** Emitted once when the editor view is created and ready */
|
|
177
|
+
editorCreate: () => void;
|
|
178
|
+
/** Emitted when context toolbar should be shown (on double-click or text selection) */
|
|
179
|
+
contextToolbarRequest: (position: CaretPosition) => void;
|
|
180
|
+
/** Emitted on every transaction while slash menu is active — provides filter text, position, and dismiss signal */
|
|
181
|
+
slashMenuRequest: (update: {
|
|
182
|
+
active: boolean;
|
|
183
|
+
text: string;
|
|
184
|
+
position: CaretPosition | null;
|
|
185
|
+
}) => void;
|
|
186
|
+
/** Emitted when image upload placeholder is inserted and upload UI should be shown */
|
|
187
|
+
imageUploadRequest: () => void;
|
|
188
|
+
/** Emitted when document upload placeholder is inserted and upload UI should be shown */
|
|
189
|
+
documentUploadRequest: () => void;
|
|
190
|
+
/** Emitted on every transaction while mention is active — provides filter text, position, and dismiss signal */
|
|
191
|
+
mentionRequest: (update: {
|
|
192
|
+
active: boolean;
|
|
193
|
+
text: string;
|
|
194
|
+
position: CaretPosition | null;
|
|
195
|
+
items?: unknown[];
|
|
196
|
+
}) => void;
|
|
197
|
+
/** Emitted when files are rejected due to validation (max count, max size, or disallowed file type) */
|
|
198
|
+
imageReject: (data: {
|
|
199
|
+
files: File[];
|
|
200
|
+
reason: 'max-file-count' | 'max-file-size' | 'file-type';
|
|
201
|
+
}) => void;
|
|
202
|
+
/** Emitted when documents are rejected due to validation (max count, max size, or disallowed file type) */
|
|
203
|
+
documentReject: (data: {
|
|
204
|
+
files: File[];
|
|
205
|
+
reason: 'max-file-count' | 'max-file-size' | 'file-type';
|
|
206
|
+
}) => void;
|
|
207
|
+
/** Emitted when an image upload handler rejects (network/server error) */
|
|
208
|
+
imageUploadError: (data: {
|
|
209
|
+
file: File;
|
|
210
|
+
error: unknown;
|
|
211
|
+
}) => void;
|
|
212
|
+
/** Emitted when a document upload handler rejects (network/server error) */
|
|
213
|
+
documentUploadError: (data: {
|
|
214
|
+
file: File;
|
|
215
|
+
error: unknown;
|
|
216
|
+
}) => void;
|
|
217
|
+
/** Emitted when an incoming value can't be parsed (e.g. pathological nesting); the editor falls back to an empty document */
|
|
218
|
+
parseError: (data: {
|
|
219
|
+
error: unknown;
|
|
220
|
+
}) => void;
|
|
221
|
+
/** Emitted when image upload entries change (progress, status) */
|
|
222
|
+
imageUploadStateChange: (entries: UploadSlotEntry[]) => void;
|
|
223
|
+
/** Emitted when document upload entries change (progress, status) */
|
|
224
|
+
documentUploadStateChange: (entries: UploadSlotEntry[]) => void;
|
|
225
|
+
/** Emitted when all image uploads complete (entries cleared) */
|
|
226
|
+
imageUploadComplete: () => void;
|
|
227
|
+
/** Emitted when all document uploads complete (entries cleared) */
|
|
228
|
+
documentUploadComplete: () => void;
|
|
229
|
+
/** Emitted when table overlay rect changes (for positioning controls) */
|
|
230
|
+
tableOverlayRectChange: (rect: TableOverlayRect | null) => void;
|
|
231
|
+
/** Emitted when table active state changes */
|
|
232
|
+
tableActiveStateChange: (state: TableActiveState | null) => void;
|
|
233
|
+
/** Emitted when table column trigger dot is clicked */
|
|
234
|
+
tableColumnMenuRequest: (colIndex: number, event: MouseEvent) => void;
|
|
235
|
+
/** Emitted when table row trigger dot is clicked */
|
|
236
|
+
tableRowMenuRequest: (rowIndex: number, event: MouseEvent) => void;
|
|
237
|
+
/** Emitted when table cell trigger dot is clicked */
|
|
238
|
+
tableCellMenuRequest: (event: MouseEvent) => void;
|
|
239
|
+
/** Emitted when hovered block changes (block mode, for floating controls positioning) */
|
|
240
|
+
blockHoverChange: (data: {
|
|
241
|
+
index: number;
|
|
242
|
+
element: HTMLElement | null;
|
|
243
|
+
}) => void;
|
|
244
|
+
/** Emitted when a block drag starts (block mode), with the dragged block index */
|
|
245
|
+
blockDragStart: (index: number) => void;
|
|
246
|
+
/** Emitted when a block drag ends (block mode) */
|
|
247
|
+
blockDragEnd: () => void;
|
|
248
|
+
/** Emitted when document headings change (for navigator minimap) */
|
|
249
|
+
navigatorHeadingsChange: (headings: TextEditorHeadingEntry[]) => void;
|
|
250
|
+
/** Emitted when the navigator's active heading index changes during scrolling */
|
|
251
|
+
navigatorActiveIndexChange: (index: number) => void;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* TextEditor component exposed public API methods
|
|
255
|
+
* @group Methods
|
|
256
|
+
*/
|
|
257
|
+
export interface TextEditorExpose {
|
|
258
|
+
/** Re-applies the ProseMirror `editable` predicate after `disabled`
|
|
259
|
+
* or `readonly` props change. */
|
|
260
|
+
refreshEditable: () => void;
|
|
261
|
+
/** Adds/removes the markdown input-rules plugin live after the
|
|
262
|
+
* `markdown` prop changes, without remounting. */
|
|
263
|
+
refreshMarkdown: () => void;
|
|
264
|
+
/** Serialize the current document to HTML. */
|
|
265
|
+
getHTML: () => string;
|
|
266
|
+
/** Serialize as the array-of-block-HTML representation used by block mode. */
|
|
267
|
+
getBlocks: () => string[];
|
|
268
|
+
/** ProseMirror document as JSON (loss-less). */
|
|
269
|
+
getJSON: () => unknown;
|
|
270
|
+
/** Plain-text projection of the document. */
|
|
271
|
+
getText: () => string;
|
|
272
|
+
/** Markdown projection of the document. */
|
|
273
|
+
getMarkdown: () => string;
|
|
274
|
+
/** Internal handler for keydown events on the editor element. */
|
|
275
|
+
onEditorKeyDown: () => void;
|
|
276
|
+
/** Internal handler for mousedown events on the editor element. */
|
|
277
|
+
onEditorMouseDown: () => void;
|
|
278
|
+
/** Filters out files that fail image validation (count, size, type), returning the accepted ones. */
|
|
279
|
+
validateImageFiles: (files: File[]) => File[];
|
|
280
|
+
/** Starts uploading the given image files and inserts upload placeholders. */
|
|
281
|
+
startImageUploads: (files: File[]) => void;
|
|
282
|
+
/** Cancels any in-progress image uploads and clears the upload UI. */
|
|
283
|
+
dismissImageUpload: () => void;
|
|
284
|
+
/** Filters out files that fail document validation (count, size, type), returning the accepted ones. */
|
|
285
|
+
validateDocumentFiles: (files: File[]) => File[];
|
|
286
|
+
/** Starts uploading the given document files and inserts upload placeholders. */
|
|
287
|
+
startDocumentUploads: (files: File[]) => void;
|
|
288
|
+
/** Cancels any in-progress document uploads and clears the upload UI. */
|
|
289
|
+
dismissDocumentUpload: () => void;
|
|
290
|
+
/** Inserts a new empty block immediately after the block at the given index (block mode). */
|
|
291
|
+
addBlockAfter: (index: number) => void;
|
|
292
|
+
/** Returns the block type name (e.g. 'paragraph', 'heading') at the given index (block mode). */
|
|
293
|
+
getBlockType: (index: number) => string;
|
|
294
|
+
/** Internal handler invoked when a block drag starts (block mode). */
|
|
295
|
+
onBlockDragStart: (index: number, event: DragEvent) => void;
|
|
296
|
+
/** Internal handler invoked when a block drag ends (block mode). */
|
|
297
|
+
onBlockDragEnd: () => void;
|
|
298
|
+
/** Moves a block from one index to another, reordering the document (block mode). */
|
|
299
|
+
moveBlock: (fromIndex: number, toIndex: number) => void;
|
|
300
|
+
/** Returns the full set of imperative editing commands for the editor. */
|
|
301
|
+
getCommands: () => TextEditorCommands;
|
|
302
|
+
/** Returns the command set for the block handle menu at the given block index (block mode). */
|
|
303
|
+
getBlockMenuCommands: (blockIndex: number, onDismiss: () => void) => TextEditorBlockMenuCommands;
|
|
304
|
+
/** Returns the command set for the slash (`/`) menu at the given block index. */
|
|
305
|
+
getSlashMenuCommands: (blockIndex: number, onDismiss: () => void) => TextEditorSlashMenuCommands;
|
|
306
|
+
/** Adds a row to the given table element at the current cursor position. */
|
|
307
|
+
onTableAddRow: (table: HTMLTableElement) => void;
|
|
308
|
+
/** Adds a column to the given table element at the current cursor position. */
|
|
309
|
+
onTableAddColumn: (table: HTMLTableElement) => void;
|
|
310
|
+
/** Returns the command set for the active table column. */
|
|
311
|
+
getTableColumnCommands: (colIndex: number, onDismiss: () => void) => TextEditorTableColumnCommands;
|
|
312
|
+
/** Returns the command set for the active table row. */
|
|
313
|
+
getTableRowCommands: (rowIndex: number, onDismiss: () => void) => TextEditorTableRowCommands;
|
|
314
|
+
/** Returns the command set for the active table cell (or multi-cell selection). */
|
|
315
|
+
getTableCellCommands: (onDismiss: () => void) => TextEditorTableCellCommands;
|
|
316
|
+
/** Returns the geometry used to position the table editing overlay, or null when not in a table. */
|
|
317
|
+
getTableOverlayRect: () => TableOverlayRect | null;
|
|
318
|
+
/** Returns the active table state when the cursor is inside a table, or null otherwise. */
|
|
319
|
+
getTableActiveState: () => TableActiveState | null;
|
|
320
|
+
/** Returns true when more than one table cell is currently selected. */
|
|
321
|
+
getIsMultiCellSelected: () => boolean;
|
|
322
|
+
/** Returns true when the active cell is a merged cell. */
|
|
323
|
+
getIsCellMerged: () => boolean;
|
|
324
|
+
/** Recomputes and emits the table overlay rect (e.g. after layout changes). */
|
|
325
|
+
updateTableOverlayRect: () => void;
|
|
326
|
+
/** Returns the command set for the mention popup. */
|
|
327
|
+
getMentionCommands: (onDismiss: () => void, options?: {
|
|
328
|
+
filterField?: string;
|
|
329
|
+
template?: (data: unknown) => string;
|
|
330
|
+
}) => TextEditorMentionCommands;
|
|
331
|
+
/** Filters mention items by the given field and filter text. */
|
|
332
|
+
getFilteredMentionItems: (items: unknown[], filterField?: string, filterText?: string) => unknown[];
|
|
333
|
+
/** Returns the plain text of the current selection. */
|
|
334
|
+
getSelectedText: () => string;
|
|
335
|
+
/** Replaces the current selection with the given content, optionally interpreted as HTML. */
|
|
336
|
+
replaceSelection: (content: string, asHtml?: boolean) => void;
|
|
337
|
+
/** Returns the editor's content DOM element, or null before mount. */
|
|
338
|
+
getEditorElement: () => HTMLElement | null;
|
|
339
|
+
/** Returns the live ProseMirror EditorView, or null before mount. */
|
|
340
|
+
getView: () => EditorView | null;
|
|
341
|
+
/** Returns the current ProseMirror EditorState, or null before mount. */
|
|
342
|
+
getState: () => EditorState | null;
|
|
343
|
+
/** Attaches a ProseMirror plugin to the live editor; returns a remover function. */
|
|
344
|
+
registerProseMirrorPlugin: (plugin: PMPlugin) => () => void;
|
|
345
|
+
/** Runs a ProseMirror command against the editor; returns whether it applied. */
|
|
346
|
+
runCommand: (command: PMCommand) => boolean;
|
|
347
|
+
/** Visually preserves the current selection while focus moves to external UI (e.g. toolbar inputs). */
|
|
348
|
+
preserveSelection: () => void;
|
|
349
|
+
/** Points the editor's aria-activedescendant at the active option of an open type-ahead menu. */
|
|
350
|
+
setComboboxActiveDescendant: (id: string | null) => void;
|
|
351
|
+
/** Replaces the editor content with the given value (string for classic, string[] for block mode). */
|
|
352
|
+
setValue: (value: string | string[]) => void;
|
|
353
|
+
/** Returns all headings in the document, used by the navigator minimap. */
|
|
354
|
+
getDocumentHeadings: () => TextEditorHeadingEntry[];
|
|
355
|
+
/** Moves focus to the heading at the given document position. */
|
|
356
|
+
focusHeading: (pos: number) => void;
|
|
357
|
+
/** Scrolls the heading at the given position into view. */
|
|
358
|
+
scrollToHeading: (pos: number, headings: TextEditorHeadingEntry[]) => void;
|
|
359
|
+
/** Recomputes which heading is currently active based on scroll position. */
|
|
360
|
+
updateActiveHeading: (headings: TextEditorHeadingEntry[]) => void;
|
|
361
|
+
/** Internal handler invoked on navigator scroll to sync the active heading. */
|
|
362
|
+
onNavigatorScroll: (headings: TextEditorHeadingEntry[]) => void;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Context provided to TextEditor plugins via defineTextEditorPlugin.
|
|
366
|
+
* @group Interface
|
|
367
|
+
*/
|
|
368
|
+
export interface TextEditorPluginContext<TOptions = unknown> {
|
|
369
|
+
/** Returns the plain text of the current selection. */
|
|
370
|
+
getSelectedText: () => string;
|
|
371
|
+
/** Replaces the current selection with the given content, optionally interpreted as HTML. */
|
|
372
|
+
replaceSelection: (content: string, asHtml?: boolean) => void;
|
|
373
|
+
/** Returns the editor's content DOM element, or null before mount. */
|
|
374
|
+
getEditorElement: () => HTMLElement | null;
|
|
375
|
+
/** The live ProseMirror EditorView, or null before mount. */
|
|
376
|
+
getView: () => EditorView | null;
|
|
377
|
+
/** The current ProseMirror EditorState, or null before mount. */
|
|
378
|
+
getState: () => EditorState | null;
|
|
379
|
+
/** Attach a ProseMirror plugin to the live editor; returns a remover. */
|
|
380
|
+
registerProseMirrorPlugin: (plugin: PMPlugin) => () => void;
|
|
381
|
+
/** Run a ProseMirror command against the editor. */
|
|
382
|
+
runCommand: (command: PMCommand) => boolean;
|
|
383
|
+
/** Options passed to the plugin at registration time. */
|
|
384
|
+
options?: TOptions;
|
|
385
|
+
/** Registers a cleanup callback run when the editor unmounts. */
|
|
386
|
+
onUnmounted: (fn: () => void) => void;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Return type from a TextEditor plugin's install function.
|
|
390
|
+
* @group Interface
|
|
391
|
+
*/
|
|
392
|
+
export interface TextEditorPluginExpose {
|
|
393
|
+
/** Named commands contributed by the plugin, merged into the editor's command surface. */
|
|
394
|
+
commands?: Record<string, (...args: unknown[]) => unknown>;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* TextEditor component instance with reactive state management and lifecycle methods
|
|
398
|
+
*
|
|
399
|
+
* @remarks
|
|
400
|
+
* This type extends ComponentInstance with TextEditor-specific refs, props, state, emits, and exposed methods.
|
|
401
|
+
*
|
|
402
|
+
* @see {@link ComponentInstance} - Base component instance type
|
|
403
|
+
* @see {@link TextEditorRefs} - TextEditor refs type
|
|
404
|
+
* @see {@link TextEditorProps} - TextEditor props type
|
|
405
|
+
* @see {@link TextEditorState} - TextEditor state type
|
|
406
|
+
* @see {@link TextEditorEmits} - TextEditor emits type
|
|
407
|
+
* @see {@link TextEditorExpose} - TextEditor exposed methods
|
|
408
|
+
* @group Types
|
|
409
|
+
*/
|
|
410
|
+
export type TextEditorInstance = ComponentInstance<TextEditorRefs, TextEditorProps, TextEditorState, TextEditorEmits, TextEditorExpose>;
|
|
411
|
+
/**
|
|
412
|
+
* TextEditor component context for initialization
|
|
413
|
+
*
|
|
414
|
+
* @remarks
|
|
415
|
+
* Used to pass initial values to the TextEditor component.
|
|
416
|
+
* All properties are optional and will be merged with defaults.
|
|
417
|
+
*
|
|
418
|
+
* @see {@link TextEditorInstance} - The component instance type
|
|
419
|
+
* @see {@link ComponentContext} - Base component context type
|
|
420
|
+
* @group Types
|
|
421
|
+
*/
|
|
422
|
+
export type TextEditorContext = ComponentContext<TextEditorInstance>;
|
|
423
|
+
/**
|
|
424
|
+
* Attributes applied to an inserted image element. `alt`, `width`, and
|
|
425
|
+
* `height` are recognized explicitly; any additional string/number attributes
|
|
426
|
+
* are passed through to the rendered `<img>` element.
|
|
427
|
+
*/
|
|
428
|
+
export interface ImageAttributes {
|
|
429
|
+
/** Alternative text for the image (the `alt` attribute). */
|
|
430
|
+
alt?: string;
|
|
431
|
+
/** Image width, as a pixel number or CSS length string. */
|
|
432
|
+
width?: string | number;
|
|
433
|
+
/** Image height, as a pixel number or CSS length string. */
|
|
434
|
+
height?: string | number;
|
|
435
|
+
/** Additional pass-through attributes applied to the rendered `<img>` element. */
|
|
436
|
+
[key: string]: string | number | undefined;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Table active state emitted when cursor is inside a table
|
|
440
|
+
* @group Interface
|
|
441
|
+
*/
|
|
442
|
+
export interface TableActiveState {
|
|
443
|
+
/** The table element the cursor is currently inside. */
|
|
444
|
+
table: HTMLTableElement;
|
|
445
|
+
/** Zero-based column index of the active cell. */
|
|
446
|
+
colIndex: number;
|
|
447
|
+
/** Zero-based row index of the active cell. */
|
|
448
|
+
rowIndex: number;
|
|
449
|
+
/** Total number of columns in the table. */
|
|
450
|
+
colCount: number;
|
|
451
|
+
/** Total number of rows in the table. */
|
|
452
|
+
rowCount: number;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Geometry used to position the table editing overlay (resize handles and
|
|
456
|
+
* trigger dots) relative to the active table and the currently focused cell.
|
|
457
|
+
* @group Interface
|
|
458
|
+
*/
|
|
459
|
+
export interface TableOverlayRect {
|
|
460
|
+
/** Bounding rectangle of the table element. */
|
|
461
|
+
tableRect: DOMRect;
|
|
462
|
+
/** Bounding rectangle of the currently focused cell. */
|
|
463
|
+
cellRect: DOMRect;
|
|
464
|
+
/** Whether the active cell is in the last column. */
|
|
465
|
+
isLastColumn: boolean;
|
|
466
|
+
/** Whether the active cell is in the last row. */
|
|
467
|
+
isLastRow: boolean;
|
|
468
|
+
/** X positions of the column borders, used to render resize handles. */
|
|
469
|
+
columnBorders: number[];
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Bounding rectangle of a multi-cell table selection, expressed as inclusive
|
|
473
|
+
* row and column index ranges.
|
|
474
|
+
* @group Interface
|
|
475
|
+
*/
|
|
476
|
+
export interface TableSelectionRect {
|
|
477
|
+
/** Smallest (top-most) row index in the selection. */
|
|
478
|
+
minRow: number;
|
|
479
|
+
/** Largest (bottom-most) row index in the selection. */
|
|
480
|
+
maxRow: number;
|
|
481
|
+
/** Smallest (left-most) column index in the selection. */
|
|
482
|
+
minCol: number;
|
|
483
|
+
/** Largest (right-most) column index in the selection. */
|
|
484
|
+
maxCol: number;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Snapshot of the active formatting at the current selection. Each flag
|
|
488
|
+
* reflects whether a mark/block is applied, plus contextual values such as the
|
|
489
|
+
* current font, colors, heading level, link state, and undo/redo availability.
|
|
490
|
+
* Emitted via `formatStateChange` and consumed by toolbars to render active states.
|
|
491
|
+
* @group Interface
|
|
492
|
+
*/
|
|
493
|
+
export interface TextEditorFormatState {
|
|
494
|
+
/** Whether bold is applied to the selection. */
|
|
495
|
+
bold?: boolean;
|
|
496
|
+
/** Whether italic is applied to the selection. */
|
|
497
|
+
italic?: boolean;
|
|
498
|
+
/** Whether underline is applied to the selection. */
|
|
499
|
+
underline?: boolean;
|
|
500
|
+
/** Whether strikethrough is applied to the selection. */
|
|
501
|
+
strikethrough?: boolean;
|
|
502
|
+
/** Whether subscript is applied to the selection. */
|
|
503
|
+
subscript?: boolean;
|
|
504
|
+
/** Whether superscript is applied to the selection. */
|
|
505
|
+
superscript?: boolean;
|
|
506
|
+
/** Whether inline code is applied to the selection. */
|
|
507
|
+
code?: boolean;
|
|
508
|
+
/** Whether the selection is inside a code block. */
|
|
509
|
+
codeBlock?: boolean;
|
|
510
|
+
/** Whether the selection is inside a blockquote. */
|
|
511
|
+
blockquote?: boolean;
|
|
512
|
+
/** Current text alignment of the block, or null if mixed/none. */
|
|
513
|
+
textAlign?: string | null;
|
|
514
|
+
/** Current font family of the selection, or null if mixed/none. */
|
|
515
|
+
fontFamily?: string | null;
|
|
516
|
+
/** Current font size of the selection, or null if mixed/none. */
|
|
517
|
+
fontSize?: string | null;
|
|
518
|
+
/** Current text (foreground) color, or null if mixed/none. */
|
|
519
|
+
foregroundColor?: string | null;
|
|
520
|
+
/** Current highlight (background) color, or null if mixed/none. */
|
|
521
|
+
backgroundColor?: string | null;
|
|
522
|
+
/** Whether a highlight (any background color) is applied to the selection. */
|
|
523
|
+
highlight?: boolean;
|
|
524
|
+
/** Current heading level (1–6), or null when not a heading. */
|
|
525
|
+
heading?: number | null;
|
|
526
|
+
/** Whether the selection is inside a bullet list. */
|
|
527
|
+
bulletList?: boolean;
|
|
528
|
+
/** Whether the selection is inside an ordered list. */
|
|
529
|
+
orderedList?: boolean;
|
|
530
|
+
/** Whether the selection is inside a checklist. */
|
|
531
|
+
checkList?: boolean;
|
|
532
|
+
/** Whether the selection is within a link. */
|
|
533
|
+
link?: boolean;
|
|
534
|
+
/** URL of the active link, or null when not in a link. */
|
|
535
|
+
linkUrl?: string | null;
|
|
536
|
+
/** Whether the cursor is inside a table. */
|
|
537
|
+
inTable?: boolean;
|
|
538
|
+
/** Whether there is a non-empty text selection. */
|
|
539
|
+
hasSelection?: boolean;
|
|
540
|
+
/** Whether the editor currently has focus. */
|
|
541
|
+
hasFocus?: boolean;
|
|
542
|
+
/** Whether an undo step is available. */
|
|
543
|
+
canUndo?: boolean;
|
|
544
|
+
/** Whether a redo step is available. */
|
|
545
|
+
canRedo?: boolean;
|
|
546
|
+
/** Whether an image upload placeholder is present in the document. */
|
|
547
|
+
hasImageUploadPlaceholder?: boolean;
|
|
548
|
+
/** Whether a document upload placeholder is present in the document. */
|
|
549
|
+
hasDocumentUploadPlaceholder?: boolean;
|
|
550
|
+
/** Whether more than one table cell is selected. */
|
|
551
|
+
isMultiCellSelected?: boolean;
|
|
552
|
+
/** Whether the active cell is a merged cell. */
|
|
553
|
+
isCellMerged?: boolean;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Formatting state exposed to the toolbar slot. Identical in shape to
|
|
557
|
+
* {@link TextEditorFormatState}; provided as a distinct name for the toolbar API surface.
|
|
558
|
+
* @group Interface
|
|
559
|
+
*/
|
|
560
|
+
export interface TextEditorToolbarState extends TextEditorFormatState {
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Imperative formatting and editing commands available on the editor. Covers
|
|
564
|
+
* inline marks, block types, lists, links, images, tables, history, and the
|
|
565
|
+
* `turnInto` block-conversion group. Typically obtained via `getCommands()`.
|
|
566
|
+
*/
|
|
567
|
+
export interface TextEditorCommands {
|
|
568
|
+
/** Toggles bold on the current selection. */
|
|
569
|
+
bold: () => void;
|
|
570
|
+
/** Toggles italic on the current selection. */
|
|
571
|
+
italic: () => void;
|
|
572
|
+
/** Toggles underline on the current selection. */
|
|
573
|
+
underline: () => void;
|
|
574
|
+
/** Toggles strikethrough on the current selection. */
|
|
575
|
+
strikethrough: () => void;
|
|
576
|
+
/** Toggles subscript on the current selection. */
|
|
577
|
+
subscript: () => void;
|
|
578
|
+
/** Toggles superscript on the current selection. */
|
|
579
|
+
superscript: () => void;
|
|
580
|
+
/** Toggles inline code on the current selection. */
|
|
581
|
+
code: () => void;
|
|
582
|
+
/** Toggles a default highlight (background color) on the current selection. */
|
|
583
|
+
highlight: () => void;
|
|
584
|
+
/** Removes all marks from the selection and resets blocks to paragraphs. */
|
|
585
|
+
clearFormatting: () => void;
|
|
586
|
+
/** Toggles the current block between a code block and a paragraph. */
|
|
587
|
+
codeBlock: () => void;
|
|
588
|
+
/** Toggles blockquote on the current block. */
|
|
589
|
+
blockquote: () => void;
|
|
590
|
+
/** Sets the text alignment of the current block. */
|
|
591
|
+
textAlign: (alignment: string) => void;
|
|
592
|
+
/** Sets the font family of the current selection (null clears it). */
|
|
593
|
+
fontFamily: (fontFamily: string | null) => void;
|
|
594
|
+
/** Sets the font size of the current selection (null clears it). */
|
|
595
|
+
fontSize: (fontSize: string | null) => void;
|
|
596
|
+
/** Sets the text (foreground) color of the current selection (null clears it). */
|
|
597
|
+
foregroundColor: (color: string | null) => void;
|
|
598
|
+
/** Sets the highlight (background) color of the current selection (null clears it). */
|
|
599
|
+
backgroundColor: (color: string | null) => void;
|
|
600
|
+
/** Converts the current block into a heading of the given level (1–6). */
|
|
601
|
+
heading: (level: number) => void;
|
|
602
|
+
/** Converts the current block into a paragraph. */
|
|
603
|
+
paragraph: () => void;
|
|
604
|
+
/** Toggles a bullet list on the current block. */
|
|
605
|
+
bulletList: () => void;
|
|
606
|
+
/** Toggles an ordered list on the current block. */
|
|
607
|
+
orderedList: () => void;
|
|
608
|
+
/** Toggles a checklist on the current block. */
|
|
609
|
+
checkList: () => void;
|
|
610
|
+
/** Inserts a link with the given URL (and optional text) at the selection. */
|
|
611
|
+
insertLink: (url: string, text?: string) => void;
|
|
612
|
+
/** Updates the URL of the link at the current selection. */
|
|
613
|
+
updateLink: (url: string) => void;
|
|
614
|
+
/** Removes the link from the current selection. */
|
|
615
|
+
removeLink: () => void;
|
|
616
|
+
/** Opens the link at the current selection in a new browser tab. */
|
|
617
|
+
openLink: () => void;
|
|
618
|
+
/** Inserts an image with the given source and optional attributes. */
|
|
619
|
+
insertImage: (src: string, attrs?: ImageAttributes) => void;
|
|
620
|
+
/** Opens the image picker / starts the image upload flow. */
|
|
621
|
+
uploadImages: () => void;
|
|
622
|
+
/** Opens the document picker / starts the document upload flow. */
|
|
623
|
+
uploadDocuments: () => void;
|
|
624
|
+
/** Prints the editor content. */
|
|
625
|
+
print: () => void;
|
|
626
|
+
/** Inserts a horizontal rule (divider) at the cursor. */
|
|
627
|
+
insertHorizontalRule: () => void;
|
|
628
|
+
/** Inserts a table with the given dimensions and optional placeholder texts. */
|
|
629
|
+
table: (rows?: number, cols?: number, headerPlaceholder?: string, cellPlaceholder?: string) => void;
|
|
630
|
+
/** Undoes the last change. */
|
|
631
|
+
undo: () => void;
|
|
632
|
+
/** Redoes the last undone change. */
|
|
633
|
+
redo: () => void;
|
|
634
|
+
/** Visually preserves the current selection while focus moves to external UI. */
|
|
635
|
+
preserveSelection: () => void;
|
|
636
|
+
/** Converts the current block into another block type. */
|
|
637
|
+
turnInto: {
|
|
638
|
+
/** Converts the block into a paragraph. */
|
|
639
|
+
text: () => void;
|
|
640
|
+
/** Converts the block into a level-1 heading. */
|
|
641
|
+
heading1: () => void;
|
|
642
|
+
/** Converts the block into a level-2 heading. */
|
|
643
|
+
heading2: () => void;
|
|
644
|
+
/** Converts the block into a level-3 heading. */
|
|
645
|
+
heading3: () => void;
|
|
646
|
+
/** Converts the block into a bullet list. */
|
|
647
|
+
bulletList: () => void;
|
|
648
|
+
/** Converts the block into an ordered list. */
|
|
649
|
+
orderedList: () => void;
|
|
650
|
+
/** Converts the block into a checklist. */
|
|
651
|
+
checkList: () => void;
|
|
652
|
+
/** Converts the block into a blockquote. */
|
|
653
|
+
blockquote: () => void;
|
|
654
|
+
/** Converts the block into a code block. */
|
|
655
|
+
codeBlock: () => void;
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Commands for applying foreground (text) and background (highlight) colors.
|
|
660
|
+
* Shared base for the block, table column, row, and cell command sets.
|
|
661
|
+
* @group Interface
|
|
662
|
+
*/
|
|
663
|
+
export interface TextEditorColorCommands {
|
|
664
|
+
/** Applies the given text (foreground) color. */
|
|
665
|
+
foregroundColor: (color: string) => void;
|
|
666
|
+
/** Applies the given highlight (background) color. */
|
|
667
|
+
backgroundColor: (color: string) => void;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Commands exposed by the block handle menu (block mode): duplicate, copy,
|
|
671
|
+
* delete, color, and `turnInto` block-type conversions. Obtained via
|
|
672
|
+
* `getBlockMenuCommands()`.
|
|
673
|
+
* @group Interface
|
|
674
|
+
*/
|
|
675
|
+
export interface TextEditorBlockMenuCommands extends TextEditorColorCommands {
|
|
676
|
+
/** Duplicates the block. */
|
|
677
|
+
duplicate: () => void;
|
|
678
|
+
/** Copies the block's content to the clipboard. */
|
|
679
|
+
copyToClipboard: () => void;
|
|
680
|
+
/** Deletes the block. */
|
|
681
|
+
deleteBlock: () => void;
|
|
682
|
+
/** Converts the block into another block type. */
|
|
683
|
+
turnInto: {
|
|
684
|
+
/** Converts the block into a paragraph. */
|
|
685
|
+
text: () => void;
|
|
686
|
+
/** Converts the block into a level-1 heading. */
|
|
687
|
+
heading1: () => void;
|
|
688
|
+
/** Converts the block into a level-2 heading. */
|
|
689
|
+
heading2: () => void;
|
|
690
|
+
/** Converts the block into a level-3 heading. */
|
|
691
|
+
heading3: () => void;
|
|
692
|
+
/** Converts the block into a bullet list. */
|
|
693
|
+
bulletList: () => void;
|
|
694
|
+
/** Converts the block into an ordered list. */
|
|
695
|
+
orderedList: () => void;
|
|
696
|
+
/** Converts the block into a checklist. */
|
|
697
|
+
checkList: () => void;
|
|
698
|
+
/** Converts the block into a blockquote. */
|
|
699
|
+
blockquote: () => void;
|
|
700
|
+
/** Converts the block into a code block. */
|
|
701
|
+
codeBlock: () => void;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Commands available from the slash (`/`) command menu for inserting or
|
|
706
|
+
* converting the current block: text, headings, lists, blockquote, code,
|
|
707
|
+
* divider, uploads, and table. Obtained via `getSlashMenuCommands()`.
|
|
708
|
+
* @group Interface
|
|
709
|
+
*/
|
|
710
|
+
export interface TextEditorSlashMenuCommands {
|
|
711
|
+
/** Inserts/converts to a plain text paragraph. */
|
|
712
|
+
text: () => void;
|
|
713
|
+
/** Inserts/converts to a heading of the given level (1–6). */
|
|
714
|
+
heading: (level: number) => void;
|
|
715
|
+
/** Inserts/converts to a bullet list. */
|
|
716
|
+
bulletList: () => void;
|
|
717
|
+
/** Inserts/converts to an ordered list. */
|
|
718
|
+
orderedList: () => void;
|
|
719
|
+
/** Inserts/converts to a checklist. */
|
|
720
|
+
checkList: () => void;
|
|
721
|
+
/** Inserts/converts to a blockquote. */
|
|
722
|
+
blockquote: () => void;
|
|
723
|
+
/** Inserts/converts to a code block. */
|
|
724
|
+
code: () => void;
|
|
725
|
+
/** Inserts a horizontal rule (divider). */
|
|
726
|
+
divider: () => void;
|
|
727
|
+
/** Opens the image picker / starts the image upload flow. */
|
|
728
|
+
uploadImages: () => void;
|
|
729
|
+
/** Opens the document picker / starts the document upload flow. */
|
|
730
|
+
uploadDocuments: () => void;
|
|
731
|
+
/** Inserts a table. */
|
|
732
|
+
table: () => void;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Commands for the active table column: insert before/after, delete, reorder,
|
|
736
|
+
* duplicate, align, and color. Obtained via `getTableColumnCommands()`.
|
|
737
|
+
* @group Interface
|
|
738
|
+
*/
|
|
739
|
+
export interface TextEditorTableColumnCommands extends TextEditorColorCommands {
|
|
740
|
+
/** Inserts a new column before the active column. */
|
|
741
|
+
insertBefore: () => void;
|
|
742
|
+
/** Inserts a new column after the active column. */
|
|
743
|
+
insertAfter: () => void;
|
|
744
|
+
/** Deletes the active column. */
|
|
745
|
+
delete: () => void;
|
|
746
|
+
/** Moves the active column one position to the left. */
|
|
747
|
+
moveLeft: () => void;
|
|
748
|
+
/** Moves the active column one position to the right. */
|
|
749
|
+
moveRight: () => void;
|
|
750
|
+
/** Duplicates the active column. */
|
|
751
|
+
duplicate: () => void;
|
|
752
|
+
/** Sets the text alignment for the active column. */
|
|
753
|
+
align: (value: string) => void;
|
|
754
|
+
/** Toggles the active column between header and body cells. */
|
|
755
|
+
toggleHeader: () => void;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Commands for the active table row: insert before/after, delete, reorder,
|
|
759
|
+
* duplicate, delete the whole table, align, and color. Obtained via
|
|
760
|
+
* `getTableRowCommands()`.
|
|
761
|
+
* @group Interface
|
|
762
|
+
*/
|
|
763
|
+
export interface TextEditorTableRowCommands extends TextEditorColorCommands {
|
|
764
|
+
/** Inserts a new row before the active row. */
|
|
765
|
+
insertBefore: () => void;
|
|
766
|
+
/** Inserts a new row after the active row. */
|
|
767
|
+
insertAfter: () => void;
|
|
768
|
+
/** Deletes the active row. */
|
|
769
|
+
delete: () => void;
|
|
770
|
+
/** Moves the active row one position up. */
|
|
771
|
+
moveUp: () => void;
|
|
772
|
+
/** Moves the active row one position down. */
|
|
773
|
+
moveDown: () => void;
|
|
774
|
+
/** Duplicates the active row. */
|
|
775
|
+
duplicate: () => void;
|
|
776
|
+
/** Deletes the entire table. */
|
|
777
|
+
deleteTable: () => void;
|
|
778
|
+
/** Sets the text alignment for the active row. */
|
|
779
|
+
align: (value: string) => void;
|
|
780
|
+
/** Toggles the active row between header and body cells. */
|
|
781
|
+
toggleHeader: () => void;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Commands for the active table cell (or multi-cell selection): clear contents,
|
|
785
|
+
* align, merge, split, and color. Obtained via `getTableCellCommands()`.
|
|
786
|
+
* @group Interface
|
|
787
|
+
*/
|
|
788
|
+
export interface TextEditorTableCellCommands extends TextEditorColorCommands {
|
|
789
|
+
/** Clears the contents of the active cell(s). */
|
|
790
|
+
clearContents: () => void;
|
|
791
|
+
/** Sets the text alignment for the active cell(s). */
|
|
792
|
+
align: (value: string) => void;
|
|
793
|
+
/** Merges the selected cells into one. */
|
|
794
|
+
mergeCells: () => void;
|
|
795
|
+
/** Splits a merged cell back into individual cells. */
|
|
796
|
+
splitCell: () => void;
|
|
797
|
+
/** Toggles the active cell(s) between header and body cells. */
|
|
798
|
+
toggleHeader: () => void;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Command for the mention popup: select a mention item, inserting the
|
|
802
|
+
* corresponding mention chip. Obtained via `getMentionCommands()`.
|
|
803
|
+
* @group Interface
|
|
804
|
+
*/
|
|
805
|
+
export interface TextEditorMentionCommands {
|
|
806
|
+
/** Selects a mention item, inserting its mention chip into the document. */
|
|
807
|
+
select: (data: unknown) => void;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Controls for a named submenu (e.g. nested toolbar/menu panels): open the
|
|
811
|
+
* submenu anchored to an element, or close it.
|
|
812
|
+
* @group Interface
|
|
813
|
+
*/
|
|
814
|
+
export interface TextEditorSubmenu {
|
|
815
|
+
/** Opens the named submenu anchored to the given element. */
|
|
816
|
+
open: (name: string, anchor: HTMLElement) => void;
|
|
817
|
+
/** Closes the submenu. */
|
|
818
|
+
close: () => void;
|
|
819
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@primeui/texteditor-types",
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
|
+
"author": "PrimeTek Informatics",
|
|
5
|
+
"description": "Shared TextEditor type definitions for PrimeUI.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"texteditor",
|
|
8
|
+
"types",
|
|
9
|
+
"primeui"
|
|
10
|
+
],
|
|
11
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/primefaces/primeui.git",
|
|
15
|
+
"directory": "packages/components/texteditor/texteditor-types"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/primefaces/primeui/issues"
|
|
19
|
+
},
|
|
20
|
+
"main": "./src/index.ts",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./*": {
|
|
27
|
+
"types": "./dist/*.types.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@primeui/core": "0.0.1-alpha.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"prosemirror-state": "^1.4.4",
|
|
44
|
+
"prosemirror-view": "^1.41.7"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "NODE_ENV=production INPUT_DIR=src/ OUTPUT_DIR=dist/ pnpm run build:package",
|
|
48
|
+
"build:package": "pnpm run type:check && tsc -p tsconfig.build.json",
|
|
49
|
+
"type:check": "tsc --noEmit",
|
|
50
|
+
"dev:link": "pnpm link --global && npm link"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './texteditor.types';
|