@vizel/core 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/README.md +44 -0
- package/dist/components.css +1 -0
- package/dist/components.css.map +1 -0
- package/dist/index.d.ts +2642 -0
- package/dist/index.js +150 -0
- package/dist/index10.js +118 -0
- package/dist/index11.js +174 -0
- package/dist/index12.js +78 -0
- package/dist/index13.js +141 -0
- package/dist/index14.js +150 -0
- package/dist/index15.js +20 -0
- package/dist/index16.js +17 -0
- package/dist/index17.js +308 -0
- package/dist/index18.js +52 -0
- package/dist/index19.js +29 -0
- package/dist/index2.js +93 -0
- package/dist/index20.js +268 -0
- package/dist/index21.js +72 -0
- package/dist/index22.js +360 -0
- package/dist/index23.js +87 -0
- package/dist/index24.js +39 -0
- package/dist/index25.js +95 -0
- package/dist/index26.js +104 -0
- package/dist/index27.js +136 -0
- package/dist/index28.js +56 -0
- package/dist/index29.js +69 -0
- package/dist/index3.js +69 -0
- package/dist/index30.js +40 -0
- package/dist/index31.js +26 -0
- package/dist/index32.js +15 -0
- package/dist/index33.js +12 -0
- package/dist/index34.js +19 -0
- package/dist/index35.js +60 -0
- package/dist/index36.js +17 -0
- package/dist/index37.js +66 -0
- package/dist/index38.js +6 -0
- package/dist/index39.js +125 -0
- package/dist/index4.js +89 -0
- package/dist/index40.js +329 -0
- package/dist/index41.js +489 -0
- package/dist/index42.js +50 -0
- package/dist/index43.js +676 -0
- package/dist/index44.js +6 -0
- package/dist/index45.js +6 -0
- package/dist/index46.js +240 -0
- package/dist/index47.js +84 -0
- package/dist/index48.js +288 -0
- package/dist/index49.js +1504 -0
- package/dist/index5.js +13 -0
- package/dist/index50.js +7 -0
- package/dist/index51.js +1563 -0
- package/dist/index52.js +204 -0
- package/dist/index53.js +725 -0
- package/dist/index54.js +23 -0
- package/dist/index55.js +12 -0
- package/dist/index56.js +9 -0
- package/dist/index57.js +10 -0
- package/dist/index58.js +16 -0
- package/dist/index59.js +21 -0
- package/dist/index6.js +135 -0
- package/dist/index60.js +27 -0
- package/dist/index61.js +86 -0
- package/dist/index62.js +248 -0
- package/dist/index63.js +1234 -0
- package/dist/index64.js +736 -0
- package/dist/index65.js +5 -0
- package/dist/index66.js +1063 -0
- package/dist/index67.js +57 -0
- package/dist/index68.js +100 -0
- package/dist/index69.js +6 -0
- package/dist/index7.js +456 -0
- package/dist/index70.js +93 -0
- package/dist/index8.js +52 -0
- package/dist/index9.js +275 -0
- package/dist/styles.css +1 -0
- package/dist/styles.css.map +1 -0
- package/package.json +109 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2642 @@
|
|
|
1
|
+
import { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu';
|
|
2
|
+
import { CodeBlockLowlightOptions } from '@tiptap/extension-code-block-lowlight';
|
|
3
|
+
import { createLowlight } from 'lowlight';
|
|
4
|
+
import { DecorationSet } from '@tiptap/pm/view';
|
|
5
|
+
import { default as default_2 } from '@tiptap/extension-code-block-lowlight';
|
|
6
|
+
import { Editor } from '@tiptap/core';
|
|
7
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
8
|
+
import { Extension } from '@tiptap/core';
|
|
9
|
+
import { Extensions } from '@tiptap/core';
|
|
10
|
+
import { FileHandlePluginOptions } from '@tiptap/extension-file-handler';
|
|
11
|
+
import { ImageOptions } from '@tiptap/extension-image';
|
|
12
|
+
import { JSONContent } from '@tiptap/core';
|
|
13
|
+
import { LinkOptions } from '@tiptap/extension-link';
|
|
14
|
+
import { Mark } from '@tiptap/core';
|
|
15
|
+
import { Markdown } from '@tiptap/markdown';
|
|
16
|
+
import { MarkdownExtensionOptions } from '@tiptap/markdown';
|
|
17
|
+
import { MarkdownExtensionStorage } from '@tiptap/markdown';
|
|
18
|
+
import { MermaidConfig } from 'mermaid';
|
|
19
|
+
import { Node as Node_2 } from '@tiptap/core';
|
|
20
|
+
import { Plugin as Plugin_2 } from '@tiptap/pm/state';
|
|
21
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
22
|
+
import { SuggestionOptions } from '@tiptap/suggestion';
|
|
23
|
+
import { SuggestionProps } from '@tiptap/suggestion';
|
|
24
|
+
import { TableCellOptions } from '@tiptap/extension-table';
|
|
25
|
+
import { TableHeaderOptions } from '@tiptap/extension-table';
|
|
26
|
+
import { TableOptions } from '@tiptap/extension-table';
|
|
27
|
+
import { default as VizelDragHandle } from '@tiptap/extension-drag-handle';
|
|
28
|
+
import { default as VizelImage } from '@tiptap/extension-image';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Add a color to recent colors
|
|
32
|
+
*/
|
|
33
|
+
export declare function addVizelRecentColor(type: "textColor" | "highlight", color: string): void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Apply theme to target element
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyVizelTheme(resolvedTheme: VizelResolvedTheme, targetSelector?: string, disableTransition?: boolean): void;
|
|
39
|
+
|
|
40
|
+
export { BubbleMenuPlugin }
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Convert all diagram code blocks in a document to diagram nodes.
|
|
44
|
+
* This command should be called after importing markdown content.
|
|
45
|
+
* Supports mermaid, dot, and graphviz code blocks.
|
|
46
|
+
*
|
|
47
|
+
* @param editor - The editor instance
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* editor.commands.setContent(markdownText, { contentType: 'markdown' });
|
|
52
|
+
* convertVizelCodeBlocksToDiagrams(editor);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function convertVizelCodeBlocksToDiagrams(editor: Editor): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates auto-save handlers for an editor
|
|
59
|
+
*/
|
|
60
|
+
export declare function createVizelAutoSaveHandlers(getEditor: () => Editor | null | undefined, options: VizelAutoSaveOptions, onStateChange: (state: Partial<VizelAutoSaveState>) => void): {
|
|
61
|
+
/** Trigger a debounced save */
|
|
62
|
+
save: () => void;
|
|
63
|
+
/** Save immediately without debouncing */
|
|
64
|
+
saveNow: () => Promise<void>;
|
|
65
|
+
/** Restore content from storage */
|
|
66
|
+
restore: () => Promise<JSONContent | null>;
|
|
67
|
+
/** Handler for editor update events */
|
|
68
|
+
handleUpdate: () => void;
|
|
69
|
+
/** Cancel any pending debounced save */
|
|
70
|
+
cancel: () => void;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Creates the character count extension for tracking content statistics.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* import { createVizelCharacterCountExtension } from '@vizel/core'
|
|
79
|
+
*
|
|
80
|
+
* const extension = createVizelCharacterCountExtension({
|
|
81
|
+
* limit: 1000,
|
|
82
|
+
* mode: 'textSize'
|
|
83
|
+
* })
|
|
84
|
+
*
|
|
85
|
+
* // Access counts via editor storage
|
|
86
|
+
* const chars = editor.storage.characterCount.characters()
|
|
87
|
+
* const words = editor.storage.characterCount.words()
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function createVizelCharacterCountExtension(options?: VizelCharacterCountOptions): Extension;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Create the CodeBlockLowlight extension with all languages registered
|
|
94
|
+
*
|
|
95
|
+
* @example Basic usage
|
|
96
|
+
* ```ts
|
|
97
|
+
* const extensions = [
|
|
98
|
+
* ...createVizelCodeBlockExtension(),
|
|
99
|
+
* ];
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example With options
|
|
103
|
+
* ```ts
|
|
104
|
+
* const extensions = [
|
|
105
|
+
* ...createVizelCodeBlockExtension({
|
|
106
|
+
* defaultLanguage: 'typescript',
|
|
107
|
+
* lineNumbers: true,
|
|
108
|
+
* }),
|
|
109
|
+
* ];
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function createVizelCodeBlockExtension(options?: VizelCodeBlockOptions): CodeBlockLowlightOptions["lowlight"] extends undefined ? never : ReturnType<typeof default_2.configure>[];
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Create default fetchEmbedData function that works client-side
|
|
116
|
+
*
|
|
117
|
+
* This function fetches oEmbed data for providers that support CORS.
|
|
118
|
+
* For providers that don't support CORS or when oEmbed fails, it falls back to link type.
|
|
119
|
+
*
|
|
120
|
+
* For full OGP support, you need to provide a custom fetchEmbedData function
|
|
121
|
+
* that fetches data through a server-side proxy.
|
|
122
|
+
*
|
|
123
|
+
* @param providers - Custom providers to use (defaults to vizelDefaultEmbedProviders)
|
|
124
|
+
* @returns A fetchEmbedData function
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const editor = useVizelEditor({
|
|
129
|
+
* features: {
|
|
130
|
+
* embed: {
|
|
131
|
+
* // Use default client-side fetcher
|
|
132
|
+
* fetchEmbedData: createVizelDefaultFetchEmbedData(),
|
|
133
|
+
* },
|
|
134
|
+
* },
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare function createVizelDefaultFetchEmbedData(providers?: VizelEmbedProvider[]): VizelFetchEmbedDataFn;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Creates details extensions for collapsible content blocks.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* import { createVizelDetailsExtensions } from '@vizel/core'
|
|
146
|
+
*
|
|
147
|
+
* const extensions = createVizelDetailsExtensions({
|
|
148
|
+
* details: { openByDefault: false }
|
|
149
|
+
* })
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function createVizelDetailsExtensions(options?: VizelDetailsOptions): Extensions;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Create the Diagram extension
|
|
156
|
+
*
|
|
157
|
+
* @example Basic usage
|
|
158
|
+
* ```ts
|
|
159
|
+
* const extensions = [
|
|
160
|
+
* createVizelDiagramExtension(),
|
|
161
|
+
* ];
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @example With custom Mermaid config
|
|
165
|
+
* ```ts
|
|
166
|
+
* const extensions = [
|
|
167
|
+
* createVizelDiagramExtension({
|
|
168
|
+
* mermaidConfig: {
|
|
169
|
+
* theme: 'dark',
|
|
170
|
+
* },
|
|
171
|
+
* }),
|
|
172
|
+
* ];
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @example With custom GraphViz engine
|
|
176
|
+
* ```ts
|
|
177
|
+
* const extensions = [
|
|
178
|
+
* createVizelDiagramExtension({
|
|
179
|
+
* graphvizEngine: 'neato',
|
|
180
|
+
* }),
|
|
181
|
+
* ];
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export declare function createVizelDiagramExtension(options?: VizelDiagramOptions): ReturnType<typeof VizelDiagram.configure>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Creates a DragHandle extension with default styling.
|
|
188
|
+
* The drag handle appears on the left side of blocks when hovering.
|
|
189
|
+
*/
|
|
190
|
+
export declare function createVizelDragHandleExtension(options?: VizelDragHandleOptions): Extension;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Creates the complete drag handle extension set including:
|
|
194
|
+
* - Visual drag handle on block hover
|
|
195
|
+
* - Keyboard shortcuts for block movement (Alt+Up/Down)
|
|
196
|
+
*/
|
|
197
|
+
export declare function createVizelDragHandleExtensions(options?: VizelDragHandleOptions): Extension[];
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Create a configured Vizel editor instance.
|
|
201
|
+
*
|
|
202
|
+
* This is the recommended way for framework packages to create editors.
|
|
203
|
+
* It handles all common setup including:
|
|
204
|
+
* - Resolving feature options
|
|
205
|
+
* - Creating extensions
|
|
206
|
+
* - Setting up initial content (JSON or Markdown)
|
|
207
|
+
* - Configuring editor props and callbacks
|
|
208
|
+
*
|
|
209
|
+
* @param options - Editor configuration options
|
|
210
|
+
* @returns The created editor instance and extracted options
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* // In a framework hook/composable/rune:
|
|
215
|
+
* const { editor, imageOptions } = createVizelEditorInstance({
|
|
216
|
+
* initialMarkdown: "# Hello World",
|
|
217
|
+
* features: { table: true },
|
|
218
|
+
* createSlashMenuRenderer: () => createMySlashMenuRenderer(),
|
|
219
|
+
* onUpdate: ({ editor }) => console.log(editor.getJSON()),
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export declare function createVizelEditorInstance(options: CreateVizelEditorInstanceOptions): CreateVizelEditorInstanceResult;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Options for creating a Vizel editor instance.
|
|
227
|
+
* Extends VizelEditorOptions with additional framework-specific parameters.
|
|
228
|
+
*/
|
|
229
|
+
export declare interface CreateVizelEditorInstanceOptions extends VizelEditorOptions {
|
|
230
|
+
/** Additional extensions to include */
|
|
231
|
+
extensions?: Extensions;
|
|
232
|
+
/** Factory function to create the slash menu renderer */
|
|
233
|
+
createSlashMenuRenderer: () => Partial<SuggestionOptions<VizelSlashCommandItem>>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Result of creating a Vizel editor instance.
|
|
238
|
+
*/
|
|
239
|
+
export declare interface CreateVizelEditorInstanceResult {
|
|
240
|
+
/** The created Tiptap editor instance */
|
|
241
|
+
editor: Editor;
|
|
242
|
+
/** Image upload options extracted from features (for event handler registration) */
|
|
243
|
+
imageOptions: VizelImageFeatureOptions;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Create embed extension with options
|
|
248
|
+
*/
|
|
249
|
+
export declare function createVizelEmbedExtension(options?: VizelEmbedOptions): Node_2<VizelEmbedOptions, any>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Create the default set of extensions for Vizel editor.
|
|
253
|
+
* All features are enabled by default. Set any feature to `false` to disable it.
|
|
254
|
+
*
|
|
255
|
+
* @example Basic usage (all features enabled)
|
|
256
|
+
* ```ts
|
|
257
|
+
* const extensions = createVizelExtensions();
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* @example Disable specific features
|
|
261
|
+
* ```ts
|
|
262
|
+
* const extensions = createVizelExtensions({
|
|
263
|
+
* features: {
|
|
264
|
+
* table: false,
|
|
265
|
+
* slashCommand: false,
|
|
266
|
+
* mathematics: false,
|
|
267
|
+
* },
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @example Using Markdown support (enabled by default)
|
|
272
|
+
* ```ts
|
|
273
|
+
* const extensions = createVizelExtensions();
|
|
274
|
+
*
|
|
275
|
+
* // Then use:
|
|
276
|
+
* editor.commands.setContent('# Hello', { contentType: 'markdown' });
|
|
277
|
+
* const md = editor.getMarkdown();
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @example Custom image upload
|
|
281
|
+
* ```ts
|
|
282
|
+
* const extensions = createVizelExtensions({
|
|
283
|
+
* features: {
|
|
284
|
+
* image: {
|
|
285
|
+
* onUpload: async (file) => {
|
|
286
|
+
* const formData = new FormData();
|
|
287
|
+
* formData.append('file', file);
|
|
288
|
+
* const res = await fetch('/api/upload', { method: 'POST', body: formData });
|
|
289
|
+
* return (await res.json()).url;
|
|
290
|
+
* },
|
|
291
|
+
* },
|
|
292
|
+
* },
|
|
293
|
+
* });
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export declare function createVizelExtensions(options?: VizelExtensionsOptions): Extensions;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Create a file handler extension with unified drop/paste handling.
|
|
300
|
+
*
|
|
301
|
+
* This extension uses @tiptap/extension-file-handler to provide
|
|
302
|
+
* consistent file handling across paste and drop operations.
|
|
303
|
+
*
|
|
304
|
+
* @example Basic usage with image upload
|
|
305
|
+
* ```ts
|
|
306
|
+
* const extensions = [
|
|
307
|
+
* ...createVizelExtensions(),
|
|
308
|
+
* createVizelFileHandlerExtension({
|
|
309
|
+
* onDrop: (editor, files, pos) => {
|
|
310
|
+
* files.forEach(file => {
|
|
311
|
+
* // Handle dropped file (e.g., upload image)
|
|
312
|
+
* uploadImage(file).then(url => {
|
|
313
|
+
* editor.chain().focus().setImage({ src: url }).run();
|
|
314
|
+
* });
|
|
315
|
+
* });
|
|
316
|
+
* },
|
|
317
|
+
* onPaste: (editor, files) => {
|
|
318
|
+
* files.forEach(file => {
|
|
319
|
+
* // Handle pasted file
|
|
320
|
+
* uploadImage(file).then(url => {
|
|
321
|
+
* editor.chain().focus().setImage({ src: url }).run();
|
|
322
|
+
* });
|
|
323
|
+
* });
|
|
324
|
+
* },
|
|
325
|
+
* }),
|
|
326
|
+
* ];
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @example With custom MIME types
|
|
330
|
+
* ```ts
|
|
331
|
+
* createVizelFileHandlerExtension({
|
|
332
|
+
* allowedMimeTypes: ['image/*', 'application/pdf'],
|
|
333
|
+
* onDrop: (editor, files, pos) => { ... },
|
|
334
|
+
* onPaste: (editor, files) => { ... },
|
|
335
|
+
* });
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
export declare function createVizelFileHandlerExtension(options?: VizelFileHandlerOptions): Extension<Omit<FileHandlePluginOptions, "key" | "editor">, any>;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Create a configured Image extension for Vizel editor.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* const extensions = [
|
|
346
|
+
* ...createVizelExtensions(),
|
|
347
|
+
* createImageExtension({ inline: true }),
|
|
348
|
+
* ];
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
export declare function createVizelImageExtension(options?: VizelImageOptions): Node_2<ImageOptions, any>;
|
|
352
|
+
|
|
353
|
+
export declare function createVizelImageFileHandlers(options: VizelImageFileHandlerOptions): VizelImageFileHandlers;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Create an image uploader function
|
|
357
|
+
*/
|
|
358
|
+
export declare function createVizelImageUploader(options: VizelImageUploadPluginOptions): VizelUploadImageFn;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Create Image extension with upload support (drag-and-drop, paste, file picker).
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* const extensions = [
|
|
366
|
+
* ...createVizelExtensions(),
|
|
367
|
+
* ...createVizelImageUploadExtensions({
|
|
368
|
+
* upload: {
|
|
369
|
+
* onUpload: async (file) => {
|
|
370
|
+
* const formData = new FormData();
|
|
371
|
+
* formData.append("image", file);
|
|
372
|
+
* const res = await fetch("/api/upload", { method: "POST", body: formData });
|
|
373
|
+
* return (await res.json()).url;
|
|
374
|
+
* },
|
|
375
|
+
* maxFileSize: 10 * 1024 * 1024, // 10MB
|
|
376
|
+
* onValidationError: (error) => console.error(error.message),
|
|
377
|
+
* onUploadError: (error) => console.error(`Upload failed: ${error.message}`),
|
|
378
|
+
* },
|
|
379
|
+
* }),
|
|
380
|
+
* ];
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
export declare function createVizelImageUploadExtensions(options: VizelImageUploadOptions): (Extension<any, any> | Node_2<ImageOptions, any> | Node_2<VizelResizableImageOptions, any>)[];
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Create an image upload plugin with decoration-based placeholders
|
|
387
|
+
*/
|
|
388
|
+
export declare function createVizelImageUploadPlugin(options: VizelImageUploadPluginOptions): Plugin_2;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Create Image extension with upload support using @tiptap/extension-file-handler.
|
|
392
|
+
*
|
|
393
|
+
* This is an alternative to createImageUploadExtension that uses the official
|
|
394
|
+
* Tiptap FileHandler extension for more consistent file handling.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* const extensions = [
|
|
399
|
+
* ...createVizelExtensions(),
|
|
400
|
+
* ...createImageUploadWithFileHandler({
|
|
401
|
+
* upload: {
|
|
402
|
+
* onUpload: async (file) => {
|
|
403
|
+
* const formData = new FormData();
|
|
404
|
+
* formData.append("image", file);
|
|
405
|
+
* const res = await fetch("/api/upload", { method: "POST", body: formData });
|
|
406
|
+
* return (await res.json()).url;
|
|
407
|
+
* },
|
|
408
|
+
* },
|
|
409
|
+
* }),
|
|
410
|
+
* ];
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
export declare function createVizelImageUploadWithFileHandler(options: VizelImageUploadWithFileHandlerOptions): (Extension<any, any> | Extension<Omit<FileHandlePluginOptions, "key" | "editor">, any> | Node_2<ImageOptions, any> | Node_2<VizelResizableImageOptions, any>)[];
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Create a link extension for Vizel editor.
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```ts
|
|
420
|
+
* const editor = new Editor({
|
|
421
|
+
* extensions: [
|
|
422
|
+
* createVizelLinkExtension({
|
|
423
|
+
* openOnClick: true,
|
|
424
|
+
* autolink: true,
|
|
425
|
+
* }),
|
|
426
|
+
* ],
|
|
427
|
+
* });
|
|
428
|
+
*
|
|
429
|
+
* // Add a link
|
|
430
|
+
* editor.chain().focus().setLink({ href: 'https://example.com' }).run();
|
|
431
|
+
*
|
|
432
|
+
* // Remove a link
|
|
433
|
+
* editor.chain().focus().unsetLink().run();
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
export declare function createVizelLinkExtension(options?: VizelLinkOptions): Mark<LinkOptions, any>;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Create a configured Markdown extension.
|
|
440
|
+
*
|
|
441
|
+
* The Markdown extension provides bidirectional conversion between
|
|
442
|
+
* Markdown syntax and the editor's document structure.
|
|
443
|
+
*
|
|
444
|
+
* ## Import Markdown
|
|
445
|
+
* ```typescript
|
|
446
|
+
* editor.commands.setContent('# Hello\n\nWorld', { contentType: 'markdown' })
|
|
447
|
+
* ```
|
|
448
|
+
*
|
|
449
|
+
* ## Export Markdown
|
|
450
|
+
* ```typescript
|
|
451
|
+
* const markdown = editor.getMarkdown()
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* ## Parse/Serialize
|
|
455
|
+
* ```typescript
|
|
456
|
+
* const json = editor.markdown.parse('# Hello')
|
|
457
|
+
* const md = editor.markdown.serialize(json)
|
|
458
|
+
* ```
|
|
459
|
+
*
|
|
460
|
+
* @example Basic usage
|
|
461
|
+
* ```typescript
|
|
462
|
+
* import { VizelMarkdown } from '@vizel/core'
|
|
463
|
+
*
|
|
464
|
+
* const editor = new Editor({
|
|
465
|
+
* extensions: [VizelMarkdown],
|
|
466
|
+
* })
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
469
|
+
* @example With options
|
|
470
|
+
* ```typescript
|
|
471
|
+
* import { createVizelMarkdownExtension } from '@vizel/core'
|
|
472
|
+
*
|
|
473
|
+
* const editor = new Editor({
|
|
474
|
+
* extensions: [
|
|
475
|
+
* createVizelMarkdownExtension({
|
|
476
|
+
* gfm: true,
|
|
477
|
+
* indentation: { style: 'tab', size: 1 },
|
|
478
|
+
* }),
|
|
479
|
+
* ],
|
|
480
|
+
* })
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
export declare function createVizelMarkdownExtension(options?: VizelMarkdownOptions): ReturnType<typeof Markdown.configure>;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Create markdown sync handlers for framework implementations.
|
|
487
|
+
*/
|
|
488
|
+
export declare function createVizelMarkdownSyncHandlers(options?: VizelMarkdownSyncOptions): VizelMarkdownSyncHandlers;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Create the Mathematics extensions
|
|
492
|
+
*
|
|
493
|
+
* @example Basic usage
|
|
494
|
+
* ```ts
|
|
495
|
+
* const extensions = [
|
|
496
|
+
* ...createVizelMathematicsExtensions(),
|
|
497
|
+
* ];
|
|
498
|
+
* ```
|
|
499
|
+
*
|
|
500
|
+
* @example With custom KaTeX options
|
|
501
|
+
* ```ts
|
|
502
|
+
* const extensions = [
|
|
503
|
+
* ...createVizelMathematicsExtensions({
|
|
504
|
+
* katexOptions: {
|
|
505
|
+
* macros: {
|
|
506
|
+
* '\\R': '\\mathbb{R}',
|
|
507
|
+
* },
|
|
508
|
+
* },
|
|
509
|
+
* }),
|
|
510
|
+
* ];
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
export declare function createVizelMathematicsExtensions(options?: VizelMathematicsOptions): [typeof VizelMathInline, typeof VizelMathBlock];
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Create a portal element with proper styling.
|
|
517
|
+
*
|
|
518
|
+
* Creates a container div for portal content with appropriate
|
|
519
|
+
* positioning and z-index based on the specified layer.
|
|
520
|
+
*
|
|
521
|
+
* @param layer - The z-index layer for the portal element
|
|
522
|
+
* @returns A configured portal element
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```typescript
|
|
526
|
+
* const element = createVizelPortalElement("dropdown");
|
|
527
|
+
* element.appendChild(menuContent);
|
|
528
|
+
* getVizelPortalContainer().appendChild(element);
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
export declare function createVizelPortalElement(layer?: VizelPortalLayer): HTMLDivElement;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Create a positioned container for suggestion popups.
|
|
535
|
+
*
|
|
536
|
+
* This creates a container element that is:
|
|
537
|
+
* - Positioned absolutely in the document
|
|
538
|
+
* - Contains an inner element for mounting framework components
|
|
539
|
+
* - Provides a method to update position based on cursor location
|
|
540
|
+
*
|
|
541
|
+
* @returns A managed suggestion container
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```typescript
|
|
545
|
+
* // In a slash menu renderer:
|
|
546
|
+
* const { container, menuContainer, updatePosition, destroy } =
|
|
547
|
+
* createVizelSuggestionContainer();
|
|
548
|
+
*
|
|
549
|
+
* // Mount your framework component to menuContainer
|
|
550
|
+
* ReactDOM.createRoot(menuContainer).render(<SlashMenu />);
|
|
551
|
+
*
|
|
552
|
+
* // Update position when Tiptap provides new coordinates
|
|
553
|
+
* updatePosition(props.clientRect);
|
|
554
|
+
*
|
|
555
|
+
* // Clean up when done
|
|
556
|
+
* destroy();
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
export declare function createVizelSuggestionContainer(): VizelSuggestionContainer;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Create a media query listener for system theme changes
|
|
563
|
+
*/
|
|
564
|
+
export declare function createVizelSystemThemeListener(callback: (theme: VizelResolvedTheme) => void): () => void;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Create table extensions for Vizel editor.
|
|
568
|
+
* Returns an array of extensions: Table, TableRow, TableHeader, TableCell.
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```ts
|
|
572
|
+
* const editor = new Editor({
|
|
573
|
+
* extensions: [
|
|
574
|
+
* ...createVizelTableExtensions({ resizable: true }),
|
|
575
|
+
* ],
|
|
576
|
+
* });
|
|
577
|
+
*
|
|
578
|
+
* // Insert a table
|
|
579
|
+
* editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run();
|
|
580
|
+
*
|
|
581
|
+
* // Column operations
|
|
582
|
+
* editor.chain().focus().addColumnBefore().run(); // Add column at the beginning/middle
|
|
583
|
+
* editor.chain().focus().addColumnAfter().run(); // Add column at the end/middle
|
|
584
|
+
* editor.chain().focus().deleteColumn().run();
|
|
585
|
+
*
|
|
586
|
+
* // Row operations
|
|
587
|
+
* editor.chain().focus().addRowBefore().run(); // Add row at the beginning/middle
|
|
588
|
+
* editor.chain().focus().addRowAfter().run(); // Add row at the end/middle
|
|
589
|
+
* editor.chain().focus().deleteRow().run();
|
|
590
|
+
*
|
|
591
|
+
* // Delete table
|
|
592
|
+
* editor.chain().focus().deleteTable().run();
|
|
593
|
+
*
|
|
594
|
+
* // Cell alignment
|
|
595
|
+
* editor.chain().focus().setCellAttribute('textAlign', 'left').run();
|
|
596
|
+
* editor.chain().focus().setCellAttribute('textAlign', 'center').run();
|
|
597
|
+
* editor.chain().focus().setCellAttribute('textAlign', 'right').run();
|
|
598
|
+
*
|
|
599
|
+
* // Merge and split cells
|
|
600
|
+
* editor.chain().focus().mergeCells().run();
|
|
601
|
+
* editor.chain().focus().splitCell().run();
|
|
602
|
+
* editor.chain().focus().mergeOrSplit().run();
|
|
603
|
+
*
|
|
604
|
+
* // Header operations
|
|
605
|
+
* editor.chain().focus().toggleHeaderRow().run();
|
|
606
|
+
* editor.chain().focus().toggleHeaderColumn().run();
|
|
607
|
+
* editor.chain().focus().toggleHeaderCell().run();
|
|
608
|
+
*
|
|
609
|
+
* // Navigation
|
|
610
|
+
* editor.chain().focus().goToNextCell().run();
|
|
611
|
+
* editor.chain().focus().goToPreviousCell().run();
|
|
612
|
+
*
|
|
613
|
+
* // Cell selection
|
|
614
|
+
* editor.chain().focus().setCellSelection({ anchorCell: 1, headCell: 2 }).run();
|
|
615
|
+
*
|
|
616
|
+
* // Fix table structure
|
|
617
|
+
* editor.chain().focus().fixTables().run();
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
export declare function createVizelTableExtensions(options?: VizelTableOptions): Extensions;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Creates task list extensions for checkbox/todo functionality.
|
|
624
|
+
*
|
|
625
|
+
* @example
|
|
626
|
+
* ```typescript
|
|
627
|
+
* import { createVizelTaskListExtensions } from '@vizel/core'
|
|
628
|
+
*
|
|
629
|
+
* const extensions = createVizelTaskListExtensions({
|
|
630
|
+
* taskItem: { nested: true }
|
|
631
|
+
* })
|
|
632
|
+
* ```
|
|
633
|
+
*/
|
|
634
|
+
export declare function createVizelTaskListExtensions(options?: VizelTaskListExtensionsOptions): Extensions;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Create text color and highlight extensions
|
|
638
|
+
*/
|
|
639
|
+
export declare function createVizelTextColorExtensions(options?: VizelTextColorOptions): Extensions;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Creates an event handler for the vizel:upload-image custom event.
|
|
643
|
+
* This handler is used by the slash command to trigger image uploads.
|
|
644
|
+
*/
|
|
645
|
+
export declare function createVizelUploadEventHandler(options: VizelCreateUploadEventHandlerOptions): (event: Event) => void;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Custom icon mappings to override default Iconify icon IDs.
|
|
649
|
+
* Keys are semantic icon names, values are Iconify icon IDs.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```ts
|
|
653
|
+
* const customIcons: CustomIconMap = {
|
|
654
|
+
* heading1: "mdi:format-header-1",
|
|
655
|
+
* bold: "mdi:format-bold",
|
|
656
|
+
* // Use any Iconify icon set: Material Design, Heroicons, Phosphor, etc.
|
|
657
|
+
* };
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
export declare type CustomIconMap = Partial<Record<VizelIconName, string>>;
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Detect provider from URL
|
|
664
|
+
*/
|
|
665
|
+
export declare function detectVizelEmbedProvider(url: string, providers?: VizelEmbedProvider[]): VizelEmbedProvider | null;
|
|
666
|
+
|
|
667
|
+
export { Editor }
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Filter files by allowed MIME types
|
|
671
|
+
*/
|
|
672
|
+
export declare function filterVizelFilesByMimeType(files: File[], allowedMimeTypes: string[]): File[];
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Filter slash commands using fuzzy search
|
|
676
|
+
* @param items - The items to filter
|
|
677
|
+
* @param query - The search query
|
|
678
|
+
* @returns Filtered and sorted items
|
|
679
|
+
*/
|
|
680
|
+
export declare function filterVizelSlashCommands(items: VizelSlashCommandItem[], query: string): VizelSlashCommandItem[];
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Find a language by ID
|
|
684
|
+
*/
|
|
685
|
+
export declare function findVizelLanguage(id: string): VizelCodeBlockLanguage | undefined;
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Flatten grouped commands back to a single array
|
|
689
|
+
* @param groups - The groups to flatten
|
|
690
|
+
* @returns Flat array of items
|
|
691
|
+
*/
|
|
692
|
+
export declare function flattenVizelSlashCommandGroups(groups: VizelSlashCommandGroup[]): VizelSlashCommandItem[];
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Format relative time for display
|
|
696
|
+
*/
|
|
697
|
+
export declare function formatVizelRelativeTime(date: Date): string;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Get all language IDs
|
|
701
|
+
*/
|
|
702
|
+
export declare function getAllVizelLanguageIds(): string[];
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Get stored theme from storage
|
|
706
|
+
*/
|
|
707
|
+
export declare function getStoredVizelTheme(storageKey: string): VizelTheme | null;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Get the currently active node type
|
|
711
|
+
*/
|
|
712
|
+
export declare function getVizelActiveNodeType(editor: Editor, nodeTypes?: VizelNodeTypeOption[]): VizelNodeTypeOption | undefined;
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Extracts the current editor state from an editor instance.
|
|
716
|
+
* This provides a snapshot of common editor state values including
|
|
717
|
+
* focus, empty status, undo/redo availability, and character/word counts.
|
|
718
|
+
*
|
|
719
|
+
* @param editor - The editor instance to extract state from
|
|
720
|
+
* @returns The current editor state
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const state = getVizelEditorState(editor);
|
|
725
|
+
* console.log(`Characters: ${state.characterCount}, Words: ${state.wordCount}`);
|
|
726
|
+
* console.log(`Can undo: ${state.canUndo}, Can redo: ${state.canRedo}`);
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
export declare function getVizelEditorState(editor: Editor | null | undefined): VizelEditorState;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Get the Iconify icon ID for a given icon name.
|
|
733
|
+
* @param name - The semantic icon name
|
|
734
|
+
* @param customIcons - Optional custom icon mappings to override defaults
|
|
735
|
+
* @returns The Iconify icon ID (e.g., "lucide:heading-1")
|
|
736
|
+
*/
|
|
737
|
+
export declare function getVizelIconId(name: VizelIconName, customIcons?: Partial<Record<VizelIconName, string>>): string;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Get the image upload plugin key (for external access)
|
|
741
|
+
*/
|
|
742
|
+
export declare function getVizelImageUploadPluginKey(): PluginKey<DecorationSet>;
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Get markdown content from the editor.
|
|
746
|
+
* Returns empty string if markdown extension is not enabled.
|
|
747
|
+
*/
|
|
748
|
+
export declare function getVizelMarkdown(editor: Editor | null | undefined): string;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Get or create the portal container element.
|
|
752
|
+
*
|
|
753
|
+
* This function ensures a single portal container exists in the document,
|
|
754
|
+
* creating one if necessary. The container is appended to document.body.
|
|
755
|
+
*
|
|
756
|
+
* @returns The portal container element
|
|
757
|
+
*
|
|
758
|
+
* @example
|
|
759
|
+
* ```typescript
|
|
760
|
+
* const container = getVizelPortalContainer();
|
|
761
|
+
* container.appendChild(myFloatingElement);
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
764
|
+
export declare function getVizelPortalContainer(): HTMLElement;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Get recent colors from localStorage
|
|
768
|
+
*/
|
|
769
|
+
export declare function getVizelRecentColors(type: "textColor" | "highlight"): string[];
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Get the list of all registered languages (sorted alphabetically)
|
|
773
|
+
*/
|
|
774
|
+
export declare function getVizelRegisteredLanguages(): VizelCodeBlockLanguage[];
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Gets the storage object based on backend type
|
|
778
|
+
*/
|
|
779
|
+
export declare function getVizelStorageBackend(storage: VizelStorageBackend, key: string): {
|
|
780
|
+
save: (content: JSONContent) => Promise<void>;
|
|
781
|
+
load: () => Promise<JSONContent | null>;
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Get the system theme preference
|
|
786
|
+
*/
|
|
787
|
+
export declare function getVizelSystemTheme(): VizelResolvedTheme;
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Initialize theme on page load (for SSR/hydration)
|
|
791
|
+
*
|
|
792
|
+
* Call this in a script tag in the head to prevent flash of incorrect theme.
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* ```html
|
|
796
|
+
* <script>
|
|
797
|
+
* (function() {
|
|
798
|
+
* const storageKey = 'vizel-theme';
|
|
799
|
+
* const stored = localStorage.getItem(storageKey);
|
|
800
|
+
* const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
801
|
+
* const theme = stored === 'dark' ? 'dark' :
|
|
802
|
+
* stored === 'light' ? 'light' :
|
|
803
|
+
* systemDark ? 'dark' : 'light';
|
|
804
|
+
* document.documentElement.setAttribute('data-vizel-theme', theme);
|
|
805
|
+
* })();
|
|
806
|
+
* </script>
|
|
807
|
+
* ```
|
|
808
|
+
*/
|
|
809
|
+
export declare function getVizelThemeInitScript(storageKey?: string): string;
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* GraphViz layout engine options
|
|
813
|
+
*/
|
|
814
|
+
export declare type GraphvizEngine = "dot" | "neato" | "fdp" | "sfdp" | "twopi" | "circo";
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Group slash commands by their group property
|
|
818
|
+
* @param items - The items to group
|
|
819
|
+
* @param groupOrder - Optional order for groups
|
|
820
|
+
* @returns Grouped commands
|
|
821
|
+
*/
|
|
822
|
+
export declare function groupVizelSlashCommands(items: VizelSlashCommandItem[], groupOrder?: string[]): VizelSlashCommandGroup[];
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Handle image drop from drag-and-drop
|
|
826
|
+
*/
|
|
827
|
+
export declare function handleVizelImageDrop(view: EditorView, event: DragEvent, moved: boolean, uploadFn: VizelUploadImageFn): boolean;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Handle image paste from clipboard
|
|
831
|
+
*/
|
|
832
|
+
export declare function handleVizelImagePaste(view: EditorView, event: ClipboardEvent, uploadFn: VizelUploadImageFn): boolean;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Handle the Escape key for suggestion popups.
|
|
836
|
+
*
|
|
837
|
+
* Returns true if the event was an Escape key press, indicating
|
|
838
|
+
* that the suggestion should be dismissed.
|
|
839
|
+
*
|
|
840
|
+
* @param event - The keyboard event to check
|
|
841
|
+
* @returns true if this was an Escape key press
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* ```typescript
|
|
845
|
+
* onKeyDown: ({ event }) => {
|
|
846
|
+
* if (handleVizelSuggestionEscape(event)) {
|
|
847
|
+
* return true; // Tell Tiptap we handled it
|
|
848
|
+
* }
|
|
849
|
+
* // Handle other keys...
|
|
850
|
+
* }
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
853
|
+
export declare function handleVizelSuggestionEscape(event: KeyboardEvent): boolean;
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Check if the portal container exists.
|
|
857
|
+
*
|
|
858
|
+
* @returns true if the portal container exists in the document
|
|
859
|
+
*/
|
|
860
|
+
export declare function hasVizelPortalContainer(): boolean;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Initialize editor with markdown content.
|
|
864
|
+
* This should be called in onCreate callback when using initialMarkdown.
|
|
865
|
+
*
|
|
866
|
+
* @param editor - The editor instance
|
|
867
|
+
* @param markdown - The markdown content to set
|
|
868
|
+
* @param options - Options for initialization
|
|
869
|
+
*/
|
|
870
|
+
export declare function initializeVizelMarkdownContent(editor: Editor, markdown: string, options?: {
|
|
871
|
+
transformDiagrams?: boolean;
|
|
872
|
+
}): void;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Initialize the Vizel icon renderer with the default Lucide implementation.
|
|
876
|
+
* Call this once when your framework package is loaded.
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* ```typescript
|
|
880
|
+
* // In @vizel/react entry point
|
|
881
|
+
* import { initVizelIconRenderer } from "@vizel/core";
|
|
882
|
+
* initVizelIconRenderer();
|
|
883
|
+
* ```
|
|
884
|
+
*/
|
|
885
|
+
export declare function initVizelIconRenderer(): void;
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Color utilities for Vizel editor.
|
|
889
|
+
*
|
|
890
|
+
* These utilities help with validating and normalizing hex color values.
|
|
891
|
+
*/
|
|
892
|
+
/**
|
|
893
|
+
* Validate if a string is a valid hex color.
|
|
894
|
+
*
|
|
895
|
+
* @param color - The color string to validate
|
|
896
|
+
* @returns True if the color is a valid hex color (3 or 6 digits)
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* ```ts
|
|
900
|
+
* isVizelValidHexColor("#FF0000"); // true
|
|
901
|
+
* isVizelValidHexColor("#F00"); // true
|
|
902
|
+
* isVizelValidHexColor("#GGGGGG"); // false
|
|
903
|
+
* isVizelValidHexColor("red"); // false
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
906
|
+
export declare function isVizelValidHexColor(color: string): boolean;
|
|
907
|
+
|
|
908
|
+
export { JSONContent }
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Mount an element to the portal container.
|
|
912
|
+
*
|
|
913
|
+
* @param content - The content element to mount
|
|
914
|
+
* @param options - Mount options
|
|
915
|
+
* @returns The wrapper element that was added to the portal
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
* ```typescript
|
|
919
|
+
* const wrapper = mountToVizelPortal(menuElement, { layer: "dropdown" });
|
|
920
|
+
* // Later, to unmount:
|
|
921
|
+
* unmountFromVizelPortal(wrapper);
|
|
922
|
+
* ```
|
|
923
|
+
*/
|
|
924
|
+
export declare function mountToVizelPortal(content: HTMLElement, options?: VizelMountPortalOptions): HTMLDivElement;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Normalize a hex color string to standard format (#RRGGBB uppercase).
|
|
928
|
+
* Handles shorthand (#RGB) conversion and adds # prefix if missing.
|
|
929
|
+
*
|
|
930
|
+
* @param color - The color string to normalize
|
|
931
|
+
* @returns Normalized uppercase hex color string
|
|
932
|
+
*
|
|
933
|
+
* @example
|
|
934
|
+
* ```ts
|
|
935
|
+
* normalizeVizelHexColor("#f00"); // "#FF0000"
|
|
936
|
+
* normalizeVizelHexColor("#FF0000"); // "#FF0000"
|
|
937
|
+
* normalizeVizelHexColor("ff0000"); // "#FF0000"
|
|
938
|
+
* ```
|
|
939
|
+
*/
|
|
940
|
+
export declare function normalizeVizelHexColor(color: string): string;
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Parse markdown to JSON content.
|
|
944
|
+
* Returns null if markdown extension is not enabled.
|
|
945
|
+
*
|
|
946
|
+
* @param editor - The editor instance (needed for markdown extension access)
|
|
947
|
+
* @param markdown - The markdown content to parse
|
|
948
|
+
* @param options - Options for parsing
|
|
949
|
+
* @returns The parsed JSON content, or null if parsing failed
|
|
950
|
+
*/
|
|
951
|
+
export declare function parseVizelMarkdown(editor: Editor | null | undefined, markdown: string, options?: {
|
|
952
|
+
transformDiagrams?: boolean;
|
|
953
|
+
}): JSONContent | null;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Registers the image upload event handler.
|
|
957
|
+
* Returns a cleanup function to remove the event listener.
|
|
958
|
+
*/
|
|
959
|
+
export declare function registerVizelUploadEventHandler(options: VizelCreateUploadEventHandlerOptions): () => void;
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Remove the portal container from the document.
|
|
963
|
+
*
|
|
964
|
+
* This should only be called during cleanup when no more
|
|
965
|
+
* portal content is expected to be rendered.
|
|
966
|
+
*/
|
|
967
|
+
export declare function removeVizelPortalContainer(): void;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Render an internal icon as an SVG string.
|
|
971
|
+
* Uses the injected renderer from framework packages.
|
|
972
|
+
*
|
|
973
|
+
* @param name - The internal icon name
|
|
974
|
+
* @param options - Optional rendering options (width, height)
|
|
975
|
+
* @returns The SVG string, or empty string if no renderer is set
|
|
976
|
+
*/
|
|
977
|
+
export declare function renderVizelIcon(name: VizelInternalIconName, options?: VizelIconRendererOptions): string;
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Render an Iconify icon as an SVG string using Lucide icons.
|
|
981
|
+
* This is the default implementation used by framework packages.
|
|
982
|
+
*
|
|
983
|
+
* @param name - The internal icon name
|
|
984
|
+
* @param options - Optional rendering options (width, height)
|
|
985
|
+
* @returns The SVG string, or empty string if icon not found
|
|
986
|
+
*/
|
|
987
|
+
export declare function renderVizelIconSvg(name: VizelInternalIconName, options?: VizelIconRendererOptions): string;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Resolves feature options with default slash menu renderer.
|
|
991
|
+
* If slashCommand is enabled but no suggestion renderer is provided,
|
|
992
|
+
* automatically adds the provided renderer.
|
|
993
|
+
*/
|
|
994
|
+
export declare function resolveVizelFeatures(options: VizelResolveFeaturesOptions): VizelFeatureOptions | undefined;
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Resolve theme to actual applied theme
|
|
998
|
+
*/
|
|
999
|
+
export declare function resolveVizelTheme(theme: VizelTheme, systemTheme: VizelResolvedTheme): VizelResolvedTheme;
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Filter slash commands with search result metadata
|
|
1003
|
+
* @param items - The items to filter
|
|
1004
|
+
* @param query - The search query
|
|
1005
|
+
* @returns Search results with score and match info
|
|
1006
|
+
*/
|
|
1007
|
+
export declare function searchVizelSlashCommands(items: VizelSlashCommandItem[], query: string): VizelSlashCommandSearchResult[];
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Set the icon renderer function.
|
|
1011
|
+
* Called by framework packages (react, vue, svelte) to inject their Iconify-based implementation.
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* ```typescript
|
|
1015
|
+
* // In @vizel/react
|
|
1016
|
+
* import { setVizelIconRenderer, vizelDefaultIconIds } from "@vizel/core";
|
|
1017
|
+
* import { iconToSVG, getIconData } from "@iconify/utils";
|
|
1018
|
+
* import lucideIcons from "@iconify-json/lucide";
|
|
1019
|
+
*
|
|
1020
|
+
* setVizelIconRenderer((name, options) => {
|
|
1021
|
+
* const iconId = vizelDefaultIconIds[name];
|
|
1022
|
+
* const [, iconName] = iconId.split(":");
|
|
1023
|
+
* const data = getIconData(lucideIcons, iconName);
|
|
1024
|
+
* if (!data) return "";
|
|
1025
|
+
* const svg = iconToSVG(data, { width: options?.width, height: options?.height });
|
|
1026
|
+
* return `<svg ...>${svg.body}</svg>`;
|
|
1027
|
+
* });
|
|
1028
|
+
* ```
|
|
1029
|
+
*/
|
|
1030
|
+
export declare function setVizelIconRenderer(renderer: VizelIconRendererWithOptions): void;
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Set markdown content to the editor.
|
|
1034
|
+
* Optionally transforms diagram code blocks to diagram nodes.
|
|
1035
|
+
*
|
|
1036
|
+
* @param editor - The editor instance
|
|
1037
|
+
* @param markdown - The markdown content to set
|
|
1038
|
+
* @param options - Options for setting content
|
|
1039
|
+
*/
|
|
1040
|
+
export declare function setVizelMarkdown(editor: Editor | null | undefined, markdown: string, options?: {
|
|
1041
|
+
transformDiagrams?: boolean;
|
|
1042
|
+
}): void;
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Split text into segments based on match indices from fuzzy search.
|
|
1046
|
+
*
|
|
1047
|
+
* @param text - The original text to split
|
|
1048
|
+
* @param matches - Array of [start, end] index pairs indicating matched regions
|
|
1049
|
+
* @returns Array of text segments with highlight flags
|
|
1050
|
+
*
|
|
1051
|
+
* @example
|
|
1052
|
+
* ```ts
|
|
1053
|
+
* // "Hello World" with "llo Wo" matched (indices [2,7])
|
|
1054
|
+
* const segments = splitVizelTextByMatches("Hello World", [[2, 7]]);
|
|
1055
|
+
* // Returns:
|
|
1056
|
+
* // [
|
|
1057
|
+
* // { text: "He", highlight: false },
|
|
1058
|
+
* // { text: "llo Wo", highlight: true },
|
|
1059
|
+
* // { text: "rld", highlight: false },
|
|
1060
|
+
* // ]
|
|
1061
|
+
* ```
|
|
1062
|
+
*/
|
|
1063
|
+
export declare function splitVizelTextByMatches(text: string, matches?: [number, number][]): VizelTextSegment[];
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Store theme to storage
|
|
1067
|
+
*/
|
|
1068
|
+
export declare function storeVizelTheme(storageKey: string, theme: VizelTheme): void;
|
|
1069
|
+
|
|
1070
|
+
export { SuggestionOptions }
|
|
1071
|
+
|
|
1072
|
+
export { SuggestionProps }
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* Transform content to convert diagram code blocks to diagram nodes.
|
|
1076
|
+
* This is useful when importing markdown content that contains diagrams.
|
|
1077
|
+
* Supports mermaid, dot, and graphviz code blocks.
|
|
1078
|
+
*
|
|
1079
|
+
* @param content - The content to transform (JSONContent format)
|
|
1080
|
+
* @returns The transformed content with diagram code blocks converted to diagram nodes
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```typescript
|
|
1084
|
+
* // After parsing markdown with editor.markdown.parse()
|
|
1085
|
+
* const parsed = editor.markdown.parse(markdownText);
|
|
1086
|
+
* const transformed = transformVizelDiagramCodeBlocks(parsed);
|
|
1087
|
+
* editor.commands.setContent(transformed);
|
|
1088
|
+
* ```
|
|
1089
|
+
*/
|
|
1090
|
+
export declare function transformVizelDiagramCodeBlocks(content: VizelContentNode): VizelContentNode;
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Unmount an element from the portal container.
|
|
1094
|
+
*
|
|
1095
|
+
* @param wrapper - The wrapper element returned by mountToVizelPortal
|
|
1096
|
+
*/
|
|
1097
|
+
export declare function unmountFromVizelPortal(wrapper: HTMLElement): void;
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Validate an image file
|
|
1101
|
+
*/
|
|
1102
|
+
export declare function validateVizelImageFile(file: File, options: Pick<VizelImageUploadPluginOptions, "maxFileSize" | "allowedTypes">): VizelImageValidationError | null;
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Default auto-save options
|
|
1106
|
+
*/
|
|
1107
|
+
export declare const VIZEL_DEFAULT_AUTO_SAVE_OPTIONS: {
|
|
1108
|
+
enabled: true;
|
|
1109
|
+
debounceMs: number;
|
|
1110
|
+
storage: "localStorage";
|
|
1111
|
+
key: string;
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* Default allowed MIME types (images only)
|
|
1116
|
+
*/
|
|
1117
|
+
export declare const VIZEL_DEFAULT_FILE_MIME_TYPES: string[];
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Default debounce delay for markdown export in milliseconds.
|
|
1121
|
+
*/
|
|
1122
|
+
export declare const VIZEL_DEFAULT_MARKDOWN_DEBOUNCE_MS = 300;
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Default theme configuration
|
|
1126
|
+
*/
|
|
1127
|
+
export declare const VIZEL_DEFAULT_THEME: VizelTheme;
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* Default storage key for persisting theme preference
|
|
1131
|
+
*/
|
|
1132
|
+
export declare const VIZEL_DEFAULT_THEME_STORAGE_KEY = "vizel-theme";
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Extended highlight color palette (lighter/pastel colors)
|
|
1136
|
+
*/
|
|
1137
|
+
export declare const VIZEL_HIGHLIGHT_COLORS: VizelColorDefinition[];
|
|
1138
|
+
|
|
1139
|
+
/** Portal container ID */
|
|
1140
|
+
export declare const VIZEL_PORTAL_ID = "vizel-portal-root";
|
|
1141
|
+
|
|
1142
|
+
/** Portal layer z-index values */
|
|
1143
|
+
export declare const VIZEL_PORTAL_Z_INDEX: {
|
|
1144
|
+
/** Base layer for dropdowns and menus */
|
|
1145
|
+
readonly dropdown: 50;
|
|
1146
|
+
/** Layer for modals and dialogs */
|
|
1147
|
+
readonly modal: 100;
|
|
1148
|
+
/** Layer for tooltips (highest priority) */
|
|
1149
|
+
readonly tooltip: 150;
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Default z-index for suggestion containers.
|
|
1154
|
+
*/
|
|
1155
|
+
export declare const VIZEL_SUGGESTION_Z_INDEX = "50";
|
|
1156
|
+
|
|
1157
|
+
/** Combined menu items (legacy, for reference) */
|
|
1158
|
+
export declare const VIZEL_TABLE_MENU_ITEMS: VizelTableMenuItem[];
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Extended text color palette with gradient-like arrangement
|
|
1162
|
+
*/
|
|
1163
|
+
export declare const VIZEL_TEXT_COLORS: VizelColorDefinition[];
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Data attribute used for theme application
|
|
1167
|
+
*/
|
|
1168
|
+
export declare const VIZEL_THEME_DATA_ATTRIBUTE = "data-vizel-theme";
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* The custom event name for image uploads from slash commands.
|
|
1172
|
+
*/
|
|
1173
|
+
export declare const VIZEL_UPLOAD_IMAGE_EVENT = "vizel:upload-image";
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Auto-save configuration options
|
|
1177
|
+
*/
|
|
1178
|
+
export declare interface VizelAutoSaveOptions {
|
|
1179
|
+
/** Enable auto-save (default: true) */
|
|
1180
|
+
enabled?: boolean;
|
|
1181
|
+
/** Debounce delay in milliseconds (default: 1000) */
|
|
1182
|
+
debounceMs?: number;
|
|
1183
|
+
/** Storage backend (default: 'localStorage') */
|
|
1184
|
+
storage?: VizelStorageBackend;
|
|
1185
|
+
/** Storage key for localStorage/sessionStorage (default: 'vizel-content') */
|
|
1186
|
+
key?: string;
|
|
1187
|
+
/** Callback when content is saved */
|
|
1188
|
+
onSave?: (content: JSONContent) => void;
|
|
1189
|
+
/** Callback when save fails */
|
|
1190
|
+
onError?: (error: Error) => void;
|
|
1191
|
+
/** Callback when restore is attempted */
|
|
1192
|
+
onRestore?: (content: JSONContent | null) => void;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Auto-save state
|
|
1197
|
+
*/
|
|
1198
|
+
export declare interface VizelAutoSaveState {
|
|
1199
|
+
/** Current save status */
|
|
1200
|
+
status: VizelSaveStatus;
|
|
1201
|
+
/** Whether there are unsaved changes */
|
|
1202
|
+
hasUnsavedChanges: boolean;
|
|
1203
|
+
/** Timestamp of last successful save */
|
|
1204
|
+
lastSaved: Date | null;
|
|
1205
|
+
/** Last error that occurred */
|
|
1206
|
+
error: Error | null;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Extension for keyboard shortcuts to move blocks up/down.
|
|
1211
|
+
* Alt+ArrowUp moves block up, Alt+ArrowDown moves block down.
|
|
1212
|
+
* Supports moving list items within their parent list.
|
|
1213
|
+
*/
|
|
1214
|
+
export declare const VizelBlockMoveKeymap: Extension<any, any>;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* Icon names used in BubbleMenu toolbar.
|
|
1218
|
+
*/
|
|
1219
|
+
export declare type VizelBubbleMenuIconName = "bold" | "italic" | "strikethrough" | "underline" | "code" | "link" | "textColor" | "highlighter";
|
|
1220
|
+
|
|
1221
|
+
export declare interface VizelCharacterCountOptions {
|
|
1222
|
+
/**
|
|
1223
|
+
* The maximum number of characters allowed. Set to 0 or null for unlimited.
|
|
1224
|
+
* @default null
|
|
1225
|
+
*/
|
|
1226
|
+
limit?: number | null;
|
|
1227
|
+
/**
|
|
1228
|
+
* The counting mode.
|
|
1229
|
+
* - 'textSize': Count characters in the text content only
|
|
1230
|
+
* - 'nodeSize': Count all nodes including formatting
|
|
1231
|
+
* @default 'textSize'
|
|
1232
|
+
*/
|
|
1233
|
+
mode?: "textSize" | "nodeSize";
|
|
1234
|
+
/**
|
|
1235
|
+
* Custom function to count words.
|
|
1236
|
+
* By default, words are counted by splitting on whitespace.
|
|
1237
|
+
*/
|
|
1238
|
+
wordCounter?: (text: string) => number;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* Character count storage interface for accessing count values.
|
|
1243
|
+
*/
|
|
1244
|
+
export declare interface VizelCharacterCountStorage {
|
|
1245
|
+
/**
|
|
1246
|
+
* Get the character count.
|
|
1247
|
+
* @param options - Optional mode override
|
|
1248
|
+
*/
|
|
1249
|
+
characters: (options?: {
|
|
1250
|
+
mode?: "textSize" | "nodeSize";
|
|
1251
|
+
}) => number;
|
|
1252
|
+
/**
|
|
1253
|
+
* Get the word count.
|
|
1254
|
+
*/
|
|
1255
|
+
words: () => number;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Language definition for the code block language selector
|
|
1260
|
+
*/
|
|
1261
|
+
export declare interface VizelCodeBlockLanguage {
|
|
1262
|
+
/** Language identifier (e.g., "javascript", "python") */
|
|
1263
|
+
id: string;
|
|
1264
|
+
/** Display name (e.g., "JavaScript", "Python") */
|
|
1265
|
+
name: string;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Options for creating the code block lowlight extension
|
|
1270
|
+
*/
|
|
1271
|
+
export declare interface VizelCodeBlockOptions {
|
|
1272
|
+
/**
|
|
1273
|
+
* Default language for code blocks
|
|
1274
|
+
* @default "plaintext"
|
|
1275
|
+
*/
|
|
1276
|
+
defaultLanguage?: string;
|
|
1277
|
+
/**
|
|
1278
|
+
* Enable line numbers by default
|
|
1279
|
+
* @default false
|
|
1280
|
+
*/
|
|
1281
|
+
lineNumbers?: boolean;
|
|
1282
|
+
/**
|
|
1283
|
+
* Custom lowlight instance (if not provided, uses all languages)
|
|
1284
|
+
*/
|
|
1285
|
+
lowlight?: ReturnType<typeof createLowlight>;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* Color definition for text color and highlight
|
|
1290
|
+
*/
|
|
1291
|
+
export declare interface VizelColorDefinition {
|
|
1292
|
+
/** Display name for the color */
|
|
1293
|
+
name: string;
|
|
1294
|
+
/** CSS color value */
|
|
1295
|
+
color: string;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* JSON content type for Tiptap documents
|
|
1300
|
+
*/
|
|
1301
|
+
export declare interface VizelContentNode {
|
|
1302
|
+
type: string;
|
|
1303
|
+
attrs?: Record<string, unknown>;
|
|
1304
|
+
content?: VizelContentNode[];
|
|
1305
|
+
text?: string;
|
|
1306
|
+
marks?: Array<{
|
|
1307
|
+
type: string;
|
|
1308
|
+
attrs?: Record<string, unknown>;
|
|
1309
|
+
}>;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Options for creating a Vizel editor instance with framework hooks/composables/runes.
|
|
1314
|
+
* Extends VizelEditorOptions with ability to add custom Tiptap extensions.
|
|
1315
|
+
*/
|
|
1316
|
+
export declare interface VizelCreateEditorOptions extends VizelEditorOptions {
|
|
1317
|
+
/**
|
|
1318
|
+
* Additional Tiptap extensions to include.
|
|
1319
|
+
* These are added alongside the default Vizel extensions.
|
|
1320
|
+
*
|
|
1321
|
+
* @example
|
|
1322
|
+
* ```typescript
|
|
1323
|
+
* import { useVizelEditor } from '@vizel/react';
|
|
1324
|
+
* import { Underline } from '@tiptap/extension-underline';
|
|
1325
|
+
*
|
|
1326
|
+
* const editor = useVizelEditor({
|
|
1327
|
+
* extensions: [Underline],
|
|
1328
|
+
* });
|
|
1329
|
+
* ```
|
|
1330
|
+
*/
|
|
1331
|
+
extensions?: Extensions;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* Options for creating an image upload event handler.
|
|
1336
|
+
*/
|
|
1337
|
+
export declare interface VizelCreateUploadEventHandlerOptions {
|
|
1338
|
+
/** Function to get the current editor instance */
|
|
1339
|
+
getEditor: () => Editor | null | undefined;
|
|
1340
|
+
/** Function to get the current image options */
|
|
1341
|
+
getImageOptions: () => VizelImageFeatureOptions;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Default base64 image uploader (converts file to data URL).
|
|
1346
|
+
* Use this as the default onUpload handler when no custom uploader is provided.
|
|
1347
|
+
*/
|
|
1348
|
+
export declare function vizelDefaultBase64Upload(file: File): Promise<string>;
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Default editor props for Vizel editors.
|
|
1352
|
+
*/
|
|
1353
|
+
export declare const vizelDefaultEditorProps: {
|
|
1354
|
+
attributes: {
|
|
1355
|
+
class: string;
|
|
1356
|
+
};
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Default oEmbed providers
|
|
1361
|
+
*/
|
|
1362
|
+
export declare const vizelDefaultEmbedProviders: VizelEmbedProvider[];
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* Default group order for display
|
|
1366
|
+
*/
|
|
1367
|
+
export declare const vizelDefaultGroupOrder: string[];
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* Default Iconify icon IDs for each icon name.
|
|
1371
|
+
* Uses Lucide icons as the default set.
|
|
1372
|
+
* Users can override these by providing their own icon mappings.
|
|
1373
|
+
*/
|
|
1374
|
+
export declare const vizelDefaultIconIds: Record<VizelIconName, string>;
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Default node types available in the node selector
|
|
1378
|
+
*/
|
|
1379
|
+
export declare const vizelDefaultNodeTypes: ({
|
|
1380
|
+
name: string;
|
|
1381
|
+
label: string;
|
|
1382
|
+
icon: "paragraph";
|
|
1383
|
+
isActive: (editor: Editor) => boolean;
|
|
1384
|
+
command: (editor: Editor) => boolean;
|
|
1385
|
+
} | {
|
|
1386
|
+
name: string;
|
|
1387
|
+
label: string;
|
|
1388
|
+
icon: "heading1";
|
|
1389
|
+
isActive: (editor: Editor) => boolean;
|
|
1390
|
+
command: (editor: Editor) => boolean;
|
|
1391
|
+
} | {
|
|
1392
|
+
name: string;
|
|
1393
|
+
label: string;
|
|
1394
|
+
icon: "heading2";
|
|
1395
|
+
isActive: (editor: Editor) => boolean;
|
|
1396
|
+
command: (editor: Editor) => boolean;
|
|
1397
|
+
} | {
|
|
1398
|
+
name: string;
|
|
1399
|
+
label: string;
|
|
1400
|
+
icon: "heading3";
|
|
1401
|
+
isActive: (editor: Editor) => boolean;
|
|
1402
|
+
command: (editor: Editor) => boolean;
|
|
1403
|
+
} | {
|
|
1404
|
+
name: string;
|
|
1405
|
+
label: string;
|
|
1406
|
+
icon: "bulletList";
|
|
1407
|
+
isActive: (editor: Editor) => boolean;
|
|
1408
|
+
command: (editor: Editor) => boolean;
|
|
1409
|
+
} | {
|
|
1410
|
+
name: string;
|
|
1411
|
+
label: string;
|
|
1412
|
+
icon: "orderedList";
|
|
1413
|
+
isActive: (editor: Editor) => boolean;
|
|
1414
|
+
command: (editor: Editor) => boolean;
|
|
1415
|
+
} | {
|
|
1416
|
+
name: string;
|
|
1417
|
+
label: string;
|
|
1418
|
+
icon: "taskList";
|
|
1419
|
+
isActive: (editor: Editor) => boolean;
|
|
1420
|
+
command: (editor: Editor) => boolean;
|
|
1421
|
+
} | {
|
|
1422
|
+
name: string;
|
|
1423
|
+
label: string;
|
|
1424
|
+
icon: "blockquote";
|
|
1425
|
+
isActive: (editor: Editor) => boolean;
|
|
1426
|
+
command: (editor: Editor) => boolean;
|
|
1427
|
+
} | {
|
|
1428
|
+
name: string;
|
|
1429
|
+
label: string;
|
|
1430
|
+
icon: "codeBlock";
|
|
1431
|
+
isActive: (editor: Editor) => boolean;
|
|
1432
|
+
command: (editor: Editor) => boolean;
|
|
1433
|
+
})[];
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Default slash commands with groups and keywords
|
|
1437
|
+
*/
|
|
1438
|
+
export declare const vizelDefaultSlashCommands: VizelSlashCommandItem[];
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* Options for the VizelDetailsContent extension
|
|
1442
|
+
*/
|
|
1443
|
+
export declare interface VizelDetailsContentOptions {
|
|
1444
|
+
/**
|
|
1445
|
+
* HTML attributes to add to the details content element
|
|
1446
|
+
*/
|
|
1447
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Options for the Details container extension
|
|
1452
|
+
*/
|
|
1453
|
+
export declare interface VizelDetailsNodeOptions {
|
|
1454
|
+
/**
|
|
1455
|
+
* HTML attributes to add to the details element
|
|
1456
|
+
*/
|
|
1457
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Whether the details should be open by default
|
|
1460
|
+
* @default false
|
|
1461
|
+
*/
|
|
1462
|
+
openByDefault?: boolean;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Combined options for all VizelDetails extensions
|
|
1467
|
+
*/
|
|
1468
|
+
export declare interface VizelDetailsOptions {
|
|
1469
|
+
/**
|
|
1470
|
+
* Options for the details container extension
|
|
1471
|
+
*/
|
|
1472
|
+
details?: VizelDetailsNodeOptions;
|
|
1473
|
+
/**
|
|
1474
|
+
* Options for the details content extension
|
|
1475
|
+
*/
|
|
1476
|
+
detailsContent?: VizelDetailsContentOptions;
|
|
1477
|
+
/**
|
|
1478
|
+
* Options for the details summary extension
|
|
1479
|
+
*/
|
|
1480
|
+
detailsSummary?: VizelDetailsSummaryOptions;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* Options for the VizelDetailsSummary extension
|
|
1485
|
+
*/
|
|
1486
|
+
export declare interface VizelDetailsSummaryOptions {
|
|
1487
|
+
/**
|
|
1488
|
+
* HTML attributes to add to the details summary element
|
|
1489
|
+
*/
|
|
1490
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Diagram extension for block diagrams
|
|
1495
|
+
*/
|
|
1496
|
+
export declare const VizelDiagram: Node_2<VizelDiagramOptions, any>;
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* Options for the Diagram extension
|
|
1500
|
+
*/
|
|
1501
|
+
export declare interface VizelDiagramOptions {
|
|
1502
|
+
/**
|
|
1503
|
+
* Mermaid configuration options
|
|
1504
|
+
* @see https://mermaid.js.org/config/setup/modules/config.html
|
|
1505
|
+
*/
|
|
1506
|
+
mermaidConfig?: MermaidConfig;
|
|
1507
|
+
/**
|
|
1508
|
+
* Default GraphViz layout engine
|
|
1509
|
+
* @default "dot"
|
|
1510
|
+
*/
|
|
1511
|
+
graphvizEngine?: GraphvizEngine;
|
|
1512
|
+
/**
|
|
1513
|
+
* Default diagram type when creating new diagrams
|
|
1514
|
+
* @default "mermaid"
|
|
1515
|
+
*/
|
|
1516
|
+
defaultType?: VizelDiagramType;
|
|
1517
|
+
/**
|
|
1518
|
+
* Default diagram code for new diagrams (for mermaid)
|
|
1519
|
+
* @default "flowchart TD\n A[Start] --> B[End]"
|
|
1520
|
+
*/
|
|
1521
|
+
defaultCode?: string;
|
|
1522
|
+
/**
|
|
1523
|
+
* Default diagram code for new GraphViz diagrams
|
|
1524
|
+
* @default "digraph G {\n A -> B\n}"
|
|
1525
|
+
*/
|
|
1526
|
+
defaultGraphvizCode?: string;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Supported diagram types
|
|
1531
|
+
*/
|
|
1532
|
+
export declare type VizelDiagramType = "mermaid" | "graphviz";
|
|
1533
|
+
|
|
1534
|
+
/**
|
|
1535
|
+
* Utilities for managing suggestion popup containers (e.g., slash menu).
|
|
1536
|
+
* These helpers provide consistent positioning and lifecycle management
|
|
1537
|
+
* across all framework implementations.
|
|
1538
|
+
*/
|
|
1539
|
+
/**
|
|
1540
|
+
* A function that returns a DOMRect or null.
|
|
1541
|
+
* Used by Tiptap's suggestion system for positioning.
|
|
1542
|
+
*/
|
|
1543
|
+
export declare type VizelDOMRectGetter = (() => DOMRect | null) | null | undefined;
|
|
1544
|
+
|
|
1545
|
+
export { VizelDragHandle }
|
|
1546
|
+
|
|
1547
|
+
export declare interface VizelDragHandleOptions {
|
|
1548
|
+
/**
|
|
1549
|
+
* Whether to show the drag handle
|
|
1550
|
+
* @default true
|
|
1551
|
+
*/
|
|
1552
|
+
enabled?: boolean;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Editor configuration options
|
|
1557
|
+
*/
|
|
1558
|
+
export declare interface VizelEditorOptions {
|
|
1559
|
+
/** Feature configuration */
|
|
1560
|
+
features?: VizelFeatureOptions;
|
|
1561
|
+
/** Initial content in JSON format */
|
|
1562
|
+
initialContent?: JSONContent;
|
|
1563
|
+
/**
|
|
1564
|
+
* Initial content in Markdown format.
|
|
1565
|
+
* If both initialContent and initialMarkdown are provided, initialMarkdown takes precedence.
|
|
1566
|
+
* @example
|
|
1567
|
+
* ```typescript
|
|
1568
|
+
* const editor = useVizelEditor({
|
|
1569
|
+
* initialMarkdown: "# Hello World\n\nThis is **bold** text.",
|
|
1570
|
+
* });
|
|
1571
|
+
* ```
|
|
1572
|
+
*/
|
|
1573
|
+
initialMarkdown?: string;
|
|
1574
|
+
/**
|
|
1575
|
+
* Automatically transform diagram code blocks (mermaid, graphviz) to diagram nodes
|
|
1576
|
+
* when importing markdown content. Only applies when initialMarkdown is provided.
|
|
1577
|
+
* @default true
|
|
1578
|
+
*/
|
|
1579
|
+
transformDiagramsOnImport?: boolean;
|
|
1580
|
+
/** Placeholder text when editor is empty */
|
|
1581
|
+
placeholder?: string;
|
|
1582
|
+
/** Whether the editor is editable */
|
|
1583
|
+
editable?: boolean;
|
|
1584
|
+
/** Auto focus on mount */
|
|
1585
|
+
autofocus?: boolean | "start" | "end" | "all" | number;
|
|
1586
|
+
/** Callback when content changes */
|
|
1587
|
+
onUpdate?: (props: {
|
|
1588
|
+
editor: Editor;
|
|
1589
|
+
}) => void;
|
|
1590
|
+
/** Callback when editor is created */
|
|
1591
|
+
onCreate?: (props: {
|
|
1592
|
+
editor: Editor;
|
|
1593
|
+
}) => void;
|
|
1594
|
+
/** Callback when editor is destroyed */
|
|
1595
|
+
onDestroy?: () => void;
|
|
1596
|
+
/** Callback when selection changes */
|
|
1597
|
+
onSelectionUpdate?: (props: {
|
|
1598
|
+
editor: Editor;
|
|
1599
|
+
}) => void;
|
|
1600
|
+
/** Callback when editor gets focus */
|
|
1601
|
+
onFocus?: (props: {
|
|
1602
|
+
editor: Editor;
|
|
1603
|
+
}) => void;
|
|
1604
|
+
/** Callback when editor loses focus */
|
|
1605
|
+
onBlur?: (props: {
|
|
1606
|
+
editor: Editor;
|
|
1607
|
+
}) => void;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* Editor state for external consumption
|
|
1612
|
+
*/
|
|
1613
|
+
export declare interface VizelEditorState {
|
|
1614
|
+
/** Whether the editor is currently focused */
|
|
1615
|
+
isFocused: boolean;
|
|
1616
|
+
/** Whether the editor is empty */
|
|
1617
|
+
isEmpty: boolean;
|
|
1618
|
+
/** Whether content can be undone */
|
|
1619
|
+
canUndo: boolean;
|
|
1620
|
+
/** Whether content can be redone */
|
|
1621
|
+
canRedo: boolean;
|
|
1622
|
+
/** Character count */
|
|
1623
|
+
characterCount: number;
|
|
1624
|
+
/** Word count */
|
|
1625
|
+
wordCount: number;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Embed node extension
|
|
1630
|
+
*/
|
|
1631
|
+
export declare const VizelEmbed: Node_2<VizelEmbedOptions, any>;
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Embed metadata returned from fetch
|
|
1635
|
+
*/
|
|
1636
|
+
export declare interface VizelEmbedData {
|
|
1637
|
+
/** Original URL */
|
|
1638
|
+
url: string;
|
|
1639
|
+
/** Type of embed based on available data */
|
|
1640
|
+
type: VizelEmbedType;
|
|
1641
|
+
/** Provider name if detected */
|
|
1642
|
+
provider?: string;
|
|
1643
|
+
/** oEmbed HTML content */
|
|
1644
|
+
html?: string;
|
|
1645
|
+
/** oEmbed width */
|
|
1646
|
+
width?: number;
|
|
1647
|
+
/** oEmbed height */
|
|
1648
|
+
height?: number;
|
|
1649
|
+
/** OGP/oEmbed title */
|
|
1650
|
+
title?: string;
|
|
1651
|
+
/** OGP/oEmbed description */
|
|
1652
|
+
description?: string;
|
|
1653
|
+
/** OGP/oEmbed image URL */
|
|
1654
|
+
image?: string;
|
|
1655
|
+
/** OGP site name */
|
|
1656
|
+
siteName?: string;
|
|
1657
|
+
/** Favicon URL */
|
|
1658
|
+
favicon?: string;
|
|
1659
|
+
/** Whether the embed is currently loading */
|
|
1660
|
+
loading?: boolean;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* Embed extension options
|
|
1665
|
+
*/
|
|
1666
|
+
export declare interface VizelEmbedOptions {
|
|
1667
|
+
/**
|
|
1668
|
+
* Function to fetch embed data from URL
|
|
1669
|
+
*
|
|
1670
|
+
* By default, uses createVizelDefaultFetchEmbedData() which fetches oEmbed data
|
|
1671
|
+
* for CORS-enabled providers (YouTube, Vimeo, Spotify, etc.)
|
|
1672
|
+
*
|
|
1673
|
+
* For full OGP/metadata support, provide a custom function that uses
|
|
1674
|
+
* a server-side proxy to fetch page metadata.
|
|
1675
|
+
*/
|
|
1676
|
+
fetchEmbedData?: VizelFetchEmbedDataFn;
|
|
1677
|
+
/** Custom providers to add or override */
|
|
1678
|
+
providers?: VizelEmbedProvider[];
|
|
1679
|
+
/** HTML attributes for the embed wrapper */
|
|
1680
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
1681
|
+
/** Enable paste handler for URL detection */
|
|
1682
|
+
pasteHandler?: boolean;
|
|
1683
|
+
/** Inline embeds (rendered inline with text) vs block embeds */
|
|
1684
|
+
inline?: boolean;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* Plugin key for embed paste handler
|
|
1689
|
+
*/
|
|
1690
|
+
export declare const vizelEmbedPastePluginKey: PluginKey<any>;
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* oEmbed provider definition
|
|
1694
|
+
*/
|
|
1695
|
+
export declare interface VizelEmbedProvider {
|
|
1696
|
+
/** Provider name (e.g., 'youtube', 'twitter') */
|
|
1697
|
+
name: string;
|
|
1698
|
+
/** URL patterns to match */
|
|
1699
|
+
patterns: RegExp[];
|
|
1700
|
+
/** oEmbed API endpoint (optional - some providers don't support oEmbed) */
|
|
1701
|
+
oEmbedEndpoint?: string;
|
|
1702
|
+
/** Whether the oEmbed endpoint supports CORS (can be fetched from browser) */
|
|
1703
|
+
supportsCors?: boolean;
|
|
1704
|
+
/** Transform function for URL (e.g., extract video ID) */
|
|
1705
|
+
transform?: (url: string) => string;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* Embed type based on available metadata
|
|
1710
|
+
*/
|
|
1711
|
+
export declare type VizelEmbedType = "oembed" | "ogp" | "title" | "link";
|
|
1712
|
+
|
|
1713
|
+
export declare interface VizelExtensionsOptions {
|
|
1714
|
+
/** Placeholder text when editor is empty */
|
|
1715
|
+
placeholder?: string;
|
|
1716
|
+
/** Configure heading levels (default: [1, 2, 3]) */
|
|
1717
|
+
headingLevels?: (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
1718
|
+
/**
|
|
1719
|
+
* Feature configuration. All features are enabled by default.
|
|
1720
|
+
* Set to false to disable a feature, or pass options to configure it.
|
|
1721
|
+
*/
|
|
1722
|
+
features?: VizelFeatureOptions;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* Feature configuration for Vizel editor.
|
|
1727
|
+
* All features are enabled by default.
|
|
1728
|
+
* Set to `true` to enable with defaults, `false` to disable, or pass options to configure.
|
|
1729
|
+
*/
|
|
1730
|
+
export declare interface VizelFeatureOptions {
|
|
1731
|
+
/** Slash command menu (type "/" to open) */
|
|
1732
|
+
slashCommand?: VizelSlashCommandOptions | boolean;
|
|
1733
|
+
/** Table support with column/row controls */
|
|
1734
|
+
table?: VizelTableOptions | boolean;
|
|
1735
|
+
/** Link extension with autolink and paste support */
|
|
1736
|
+
link?: VizelLinkOptions | boolean;
|
|
1737
|
+
/** Image upload and resize */
|
|
1738
|
+
image?: VizelImageFeatureOptions | boolean;
|
|
1739
|
+
/** Markdown import/export support */
|
|
1740
|
+
markdown?: VizelMarkdownOptions | boolean;
|
|
1741
|
+
/** Task list (checkbox) support */
|
|
1742
|
+
taskList?: VizelTaskListExtensionsOptions | boolean;
|
|
1743
|
+
/** Character and word count tracking */
|
|
1744
|
+
characterCount?: VizelCharacterCountOptions | boolean;
|
|
1745
|
+
/** Text color and highlight support */
|
|
1746
|
+
textColor?: VizelTextColorOptions | boolean;
|
|
1747
|
+
/** Code block with syntax highlighting */
|
|
1748
|
+
codeBlock?: VizelCodeBlockOptions | boolean;
|
|
1749
|
+
/** Mathematics (LaTeX) support with KaTeX rendering */
|
|
1750
|
+
mathematics?: VizelMathematicsOptions | boolean;
|
|
1751
|
+
/** Drag handle for block reordering (includes Alt+Up/Down keyboard shortcuts) */
|
|
1752
|
+
dragHandle?: VizelDragHandleOptions | boolean;
|
|
1753
|
+
/** URL embedding with oEmbed/OGP support */
|
|
1754
|
+
embed?: VizelEmbedOptions | boolean;
|
|
1755
|
+
/** Collapsible content blocks (accordion) */
|
|
1756
|
+
details?: VizelDetailsOptions | boolean;
|
|
1757
|
+
/** Diagram support (Mermaid, GraphViz) */
|
|
1758
|
+
diagram?: VizelDiagramOptions | boolean;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* Function to fetch embed data from URL
|
|
1763
|
+
* This should be provided by the user to handle CORS
|
|
1764
|
+
*/
|
|
1765
|
+
export declare type VizelFetchEmbedDataFn = (url: string) => Promise<VizelEmbedData>;
|
|
1766
|
+
|
|
1767
|
+
/**
|
|
1768
|
+
* File handler error
|
|
1769
|
+
*/
|
|
1770
|
+
export declare interface VizelFileHandlerError {
|
|
1771
|
+
type: VizelFileHandlerErrorType;
|
|
1772
|
+
message: string;
|
|
1773
|
+
files?: File[];
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* File handler error types
|
|
1778
|
+
*/
|
|
1779
|
+
export declare type VizelFileHandlerErrorType = "invalid_mime_type" | "no_files";
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* Options for file handler extension
|
|
1783
|
+
*/
|
|
1784
|
+
export declare interface VizelFileHandlerOptions {
|
|
1785
|
+
/**
|
|
1786
|
+
* Allowed MIME types for files
|
|
1787
|
+
* @default ["image/jpeg", "image/png", "image/gif", "image/webp", "image/svg+xml"]
|
|
1788
|
+
*/
|
|
1789
|
+
allowedMimeTypes?: string[];
|
|
1790
|
+
/**
|
|
1791
|
+
* Handler called when files are pasted
|
|
1792
|
+
* @param editor - The editor instance
|
|
1793
|
+
* @param files - Array of pasted files
|
|
1794
|
+
* @param htmlContent - HTML content from clipboard (useful for external images)
|
|
1795
|
+
*/
|
|
1796
|
+
onPaste?: (editor: Editor, files: File[], htmlContent: string | undefined) => void;
|
|
1797
|
+
/**
|
|
1798
|
+
* Handler called when files are dropped
|
|
1799
|
+
* @param editor - The editor instance
|
|
1800
|
+
* @param files - Array of dropped files
|
|
1801
|
+
* @param pos - Drop position in the document
|
|
1802
|
+
*/
|
|
1803
|
+
onDrop?: (editor: Editor, files: File[], pos: number) => void;
|
|
1804
|
+
/**
|
|
1805
|
+
* Handler for validation errors (file type not allowed, etc.)
|
|
1806
|
+
*/
|
|
1807
|
+
onError?: (error: VizelFileHandlerError) => void;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
/**
|
|
1811
|
+
* Context value for icon customization.
|
|
1812
|
+
* Used by framework-specific icon providers.
|
|
1813
|
+
*/
|
|
1814
|
+
export declare interface VizelIconContextValue {
|
|
1815
|
+
/**
|
|
1816
|
+
* Custom icon mappings that override default Lucide icons.
|
|
1817
|
+
*/
|
|
1818
|
+
customIcons?: CustomIconMap | undefined;
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/**
|
|
1822
|
+
* All icon names used in Vizel.
|
|
1823
|
+
*/
|
|
1824
|
+
export declare type VizelIconName = VizelSlashCommandIconName | VizelNodeTypeIconName | VizelTableIconName | VizelUIIconName | VizelBubbleMenuIconName | VizelInternalIconName;
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* Icon renderer function type.
|
|
1828
|
+
* Framework packages inject their implementation to render icons as SVG strings.
|
|
1829
|
+
*/
|
|
1830
|
+
export declare type VizelIconRenderer = (name: VizelInternalIconName) => string;
|
|
1831
|
+
|
|
1832
|
+
/**
|
|
1833
|
+
* Icon renderer options for customization.
|
|
1834
|
+
*/
|
|
1835
|
+
export declare interface VizelIconRendererOptions {
|
|
1836
|
+
/** Icon width in pixels */
|
|
1837
|
+
width?: number;
|
|
1838
|
+
/** Icon height in pixels */
|
|
1839
|
+
height?: number;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* Extended icon renderer function type with options support.
|
|
1844
|
+
*/
|
|
1845
|
+
export declare type VizelIconRendererWithOptions = (name: VizelInternalIconName, options?: VizelIconRendererOptions) => string;
|
|
1846
|
+
|
|
1847
|
+
export { VizelImage }
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* Image feature options
|
|
1851
|
+
*/
|
|
1852
|
+
export declare interface VizelImageFeatureOptions extends Partial<VizelImageUploadPluginOptions> {
|
|
1853
|
+
/** Enable image resizing (default: true) */
|
|
1854
|
+
resize?: boolean;
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
/**
|
|
1858
|
+
* Create file handler handlers for image upload integration.
|
|
1859
|
+
*
|
|
1860
|
+
* This is a convenience function that creates onPaste and onDrop handlers
|
|
1861
|
+
* that integrate with the image upload system.
|
|
1862
|
+
*
|
|
1863
|
+
* @example
|
|
1864
|
+
* ```ts
|
|
1865
|
+
* const { onPaste, onDrop } = createVizelImageFileHandlers({
|
|
1866
|
+
* onUpload: async (file) => {
|
|
1867
|
+
* const formData = new FormData();
|
|
1868
|
+
* formData.append("file", file);
|
|
1869
|
+
* const res = await fetch("/api/upload", { method: "POST", body: formData });
|
|
1870
|
+
* return (await res.json()).url;
|
|
1871
|
+
* },
|
|
1872
|
+
* onError: (error) => console.error(error),
|
|
1873
|
+
* });
|
|
1874
|
+
*
|
|
1875
|
+
* const extension = createVizelFileHandlerExtension({ onPaste, onDrop });
|
|
1876
|
+
* ```
|
|
1877
|
+
*/
|
|
1878
|
+
export declare interface VizelImageFileHandlerOptions {
|
|
1879
|
+
/**
|
|
1880
|
+
* Upload function that receives a file and returns a URL
|
|
1881
|
+
*/
|
|
1882
|
+
onUpload: (file: File) => Promise<string>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Called when an upload error occurs
|
|
1885
|
+
*/
|
|
1886
|
+
onUploadError?: (error: Error, file: File) => void;
|
|
1887
|
+
/**
|
|
1888
|
+
* Called during upload progress (if supported)
|
|
1889
|
+
*/
|
|
1890
|
+
onUploadProgress?: (progress: number, file: File) => void;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
export declare interface VizelImageFileHandlers {
|
|
1894
|
+
onPaste: NonNullable<VizelFileHandlerOptions["onPaste"]>;
|
|
1895
|
+
onDrop: NonNullable<VizelFileHandlerOptions["onDrop"]>;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
export declare interface VizelImageOptions {
|
|
1899
|
+
/** Allow inline images */
|
|
1900
|
+
inline?: boolean;
|
|
1901
|
+
/** Allow base64 encoded images */
|
|
1902
|
+
allowBase64?: boolean;
|
|
1903
|
+
/** HTML attributes for the image element */
|
|
1904
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
/**
|
|
1908
|
+
* Options for image resize functionality
|
|
1909
|
+
*/
|
|
1910
|
+
export declare interface VizelImageResizeOptions {
|
|
1911
|
+
/** Enable image resizing (default: true when resize options provided) */
|
|
1912
|
+
enabled?: boolean;
|
|
1913
|
+
/** Minimum width in pixels (default: 100) */
|
|
1914
|
+
minWidth?: number;
|
|
1915
|
+
/** Minimum height in pixels (default: 100) */
|
|
1916
|
+
minHeight?: number;
|
|
1917
|
+
/** Maximum width in pixels (default: undefined - uses container width) */
|
|
1918
|
+
maxWidth?: number;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* Options for image upload extension
|
|
1923
|
+
*/
|
|
1924
|
+
export declare interface VizelImageUploadOptions extends VizelImageOptions {
|
|
1925
|
+
/** Image upload configuration */
|
|
1926
|
+
upload: VizelImageUploadPluginOptions;
|
|
1927
|
+
/** Image resize options (set to false to disable) */
|
|
1928
|
+
resize?: VizelImageResizeOptions | false;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
/**
|
|
1932
|
+
* Image upload plugin options
|
|
1933
|
+
*/
|
|
1934
|
+
export declare interface VizelImageUploadPluginOptions {
|
|
1935
|
+
/**
|
|
1936
|
+
* Handler to upload file and return the uploaded image URL
|
|
1937
|
+
* @param file The file to upload
|
|
1938
|
+
* @returns Promise resolving to the uploaded image URL
|
|
1939
|
+
*/
|
|
1940
|
+
onUpload: (file: File) => Promise<string>;
|
|
1941
|
+
/**
|
|
1942
|
+
* Maximum file size in bytes
|
|
1943
|
+
* @default 20MB (20 * 1024 * 1024)
|
|
1944
|
+
*/
|
|
1945
|
+
maxFileSize?: number;
|
|
1946
|
+
/**
|
|
1947
|
+
* Allowed MIME types
|
|
1948
|
+
* @default ["image/jpeg", "image/png", "image/gif", "image/webp", "image/svg+xml"]
|
|
1949
|
+
*/
|
|
1950
|
+
allowedTypes?: string[];
|
|
1951
|
+
/**
|
|
1952
|
+
* CSS class for the placeholder element
|
|
1953
|
+
* @default "vizel-image-placeholder"
|
|
1954
|
+
*/
|
|
1955
|
+
placeholderClass?: string;
|
|
1956
|
+
/**
|
|
1957
|
+
* CSS class for the uploading image
|
|
1958
|
+
* @default "vizel-image-uploading"
|
|
1959
|
+
*/
|
|
1960
|
+
imageClass?: string;
|
|
1961
|
+
/**
|
|
1962
|
+
* Callback for validation errors
|
|
1963
|
+
*/
|
|
1964
|
+
onValidationError?: (error: VizelImageValidationError) => void;
|
|
1965
|
+
/**
|
|
1966
|
+
* Callback for upload errors
|
|
1967
|
+
*/
|
|
1968
|
+
onUploadError?: (error: Error, file: File) => void;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
/**
|
|
1972
|
+
* Options for image upload with file handler
|
|
1973
|
+
*/
|
|
1974
|
+
export declare interface VizelImageUploadWithFileHandlerOptions extends VizelImageOptions {
|
|
1975
|
+
/** Image upload configuration */
|
|
1976
|
+
upload: VizelImageUploadPluginOptions;
|
|
1977
|
+
/** Image resize options (set to false to disable) */
|
|
1978
|
+
resize?: VizelImageResizeOptions | false;
|
|
1979
|
+
/** Use @tiptap/extension-file-handler for drop/paste handling (default: true) */
|
|
1980
|
+
useFileHandler?: boolean;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* Image validation error
|
|
1985
|
+
*/
|
|
1986
|
+
export declare interface VizelImageValidationError {
|
|
1987
|
+
type: VizelImageValidationErrorType;
|
|
1988
|
+
message: string;
|
|
1989
|
+
file: File;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Image validation error types
|
|
1994
|
+
*/
|
|
1995
|
+
export declare type VizelImageValidationErrorType = "invalid_type" | "file_too_large";
|
|
1996
|
+
|
|
1997
|
+
/**
|
|
1998
|
+
* Icon names used internally in NodeView rendering (drag handle, table controls).
|
|
1999
|
+
* These icons are rendered via the injected VizelIconRenderer from framework packages.
|
|
2000
|
+
*/
|
|
2001
|
+
export declare type VizelInternalIconName = "grip" | "gripHorizontal" | "plusSmall" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "alignLeft" | "alignCenter" | "alignRight" | "listOrdered";
|
|
2002
|
+
|
|
2003
|
+
export declare interface VizelLinkOptions {
|
|
2004
|
+
/**
|
|
2005
|
+
* If enabled, links will be opened on click.
|
|
2006
|
+
* @default true
|
|
2007
|
+
*/
|
|
2008
|
+
openOnClick?: boolean;
|
|
2009
|
+
/**
|
|
2010
|
+
* If enabled, URLs will be automatically linked while typing.
|
|
2011
|
+
* @default true
|
|
2012
|
+
*/
|
|
2013
|
+
autolink?: boolean;
|
|
2014
|
+
/**
|
|
2015
|
+
* If enabled, pasted URLs will be linked.
|
|
2016
|
+
* @default true
|
|
2017
|
+
*/
|
|
2018
|
+
linkOnPaste?: boolean;
|
|
2019
|
+
/**
|
|
2020
|
+
* Default protocol for links without one.
|
|
2021
|
+
* @default 'https'
|
|
2022
|
+
*/
|
|
2023
|
+
defaultProtocol?: string;
|
|
2024
|
+
/**
|
|
2025
|
+
* Additional HTML attributes to add to links.
|
|
2026
|
+
*/
|
|
2027
|
+
HTMLAttributes?: Record<string, string>;
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
/**
|
|
2031
|
+
* Pre-configured Markdown extension with default settings.
|
|
2032
|
+
*
|
|
2033
|
+
* Uses:
|
|
2034
|
+
* - Space indentation (2 spaces)
|
|
2035
|
+
* - GitHub Flavored Markdown enabled
|
|
2036
|
+
* - No automatic line breaks
|
|
2037
|
+
*/
|
|
2038
|
+
export declare const VizelMarkdown: Extension<MarkdownExtensionOptions, MarkdownExtensionStorage>;
|
|
2039
|
+
|
|
2040
|
+
/**
|
|
2041
|
+
* Configuration options for the Markdown extension
|
|
2042
|
+
*/
|
|
2043
|
+
export declare interface VizelMarkdownOptions {
|
|
2044
|
+
/**
|
|
2045
|
+
* Configure indentation for markdown output
|
|
2046
|
+
* @default { style: 'space', size: 2 }
|
|
2047
|
+
*/
|
|
2048
|
+
indentation?: MarkdownExtensionOptions["indentation"];
|
|
2049
|
+
/**
|
|
2050
|
+
* Enable GitHub Flavored Markdown
|
|
2051
|
+
* @default true
|
|
2052
|
+
*/
|
|
2053
|
+
gfm?: boolean;
|
|
2054
|
+
/**
|
|
2055
|
+
* Convert newlines to <br> tags
|
|
2056
|
+
* @default false
|
|
2057
|
+
*/
|
|
2058
|
+
breaks?: boolean;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
/**
|
|
2062
|
+
* Create debounced markdown sync handlers.
|
|
2063
|
+
* This is a framework-agnostic helper that frameworks can use to implement their own hooks.
|
|
2064
|
+
*
|
|
2065
|
+
* @param options - Sync options
|
|
2066
|
+
* @returns Object with handlers and state
|
|
2067
|
+
*
|
|
2068
|
+
* @example
|
|
2069
|
+
* ```typescript
|
|
2070
|
+
* const sync = createVizelMarkdownSyncHandlers({
|
|
2071
|
+
* debounceMs: 300,
|
|
2072
|
+
* transformDiagrams: true,
|
|
2073
|
+
* });
|
|
2074
|
+
*
|
|
2075
|
+
* // In onUpdate callback:
|
|
2076
|
+
* sync.handleUpdate(editor);
|
|
2077
|
+
*
|
|
2078
|
+
* // Get current markdown:
|
|
2079
|
+
* console.log(sync.getMarkdown());
|
|
2080
|
+
*
|
|
2081
|
+
* // Set markdown:
|
|
2082
|
+
* sync.setMarkdown(editor, "# New content");
|
|
2083
|
+
*
|
|
2084
|
+
* // Cleanup:
|
|
2085
|
+
* sync.destroy();
|
|
2086
|
+
* ```
|
|
2087
|
+
*/
|
|
2088
|
+
export declare interface VizelMarkdownSyncHandlers {
|
|
2089
|
+
/** Handle editor update (call in onUpdate callback) */
|
|
2090
|
+
handleUpdate: (editor: Editor) => void;
|
|
2091
|
+
/** Get current markdown content */
|
|
2092
|
+
getMarkdown: () => string;
|
|
2093
|
+
/** Set markdown content to editor */
|
|
2094
|
+
setMarkdown: (editor: Editor, markdown: string) => void;
|
|
2095
|
+
/** Check if export is pending */
|
|
2096
|
+
isPending: () => boolean;
|
|
2097
|
+
/** Force immediate export (flush pending) */
|
|
2098
|
+
flush: (editor: Editor) => void;
|
|
2099
|
+
/** Cleanup (cancel pending timers) */
|
|
2100
|
+
destroy: () => void;
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
/**
|
|
2104
|
+
* Options for Markdown synchronization
|
|
2105
|
+
*/
|
|
2106
|
+
export declare interface VizelMarkdownSyncOptions {
|
|
2107
|
+
/**
|
|
2108
|
+
* Debounce delay in milliseconds for markdown export.
|
|
2109
|
+
* Set to 0 for immediate export (not recommended for large documents).
|
|
2110
|
+
* @default 300
|
|
2111
|
+
*/
|
|
2112
|
+
debounceMs?: number;
|
|
2113
|
+
/**
|
|
2114
|
+
* Automatically transform diagram code blocks when setting markdown content.
|
|
2115
|
+
* @default true
|
|
2116
|
+
*/
|
|
2117
|
+
transformDiagrams?: boolean;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
/**
|
|
2121
|
+
* Result of Markdown synchronization
|
|
2122
|
+
*/
|
|
2123
|
+
export declare interface VizelMarkdownSyncResult {
|
|
2124
|
+
/** Current markdown content (reactive) */
|
|
2125
|
+
markdown: string;
|
|
2126
|
+
/**
|
|
2127
|
+
* Set markdown content to the editor.
|
|
2128
|
+
* Automatically transforms diagram code blocks if transformDiagrams is enabled.
|
|
2129
|
+
*/
|
|
2130
|
+
setMarkdown: (markdown: string) => void;
|
|
2131
|
+
/** Whether markdown export is currently pending (debounced) */
|
|
2132
|
+
isPending: boolean;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
/**
|
|
2136
|
+
* Mathematics extension for block math expressions
|
|
2137
|
+
*/
|
|
2138
|
+
export declare const VizelMathBlock: Node_2<VizelMathematicsOptions, any>;
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* Options for the Mathematics extension
|
|
2142
|
+
*/
|
|
2143
|
+
export declare interface VizelMathematicsOptions {
|
|
2144
|
+
/**
|
|
2145
|
+
* KaTeX rendering options
|
|
2146
|
+
* @see https://katex.org/docs/options.html
|
|
2147
|
+
*/
|
|
2148
|
+
katexOptions?: katex.KatexOptions;
|
|
2149
|
+
/**
|
|
2150
|
+
* Enable inline math input rules ($...$)
|
|
2151
|
+
* @default true
|
|
2152
|
+
*/
|
|
2153
|
+
inlineInputRules?: boolean;
|
|
2154
|
+
/**
|
|
2155
|
+
* Enable block math input rules ($$...$$)
|
|
2156
|
+
* @default true
|
|
2157
|
+
*/
|
|
2158
|
+
blockInputRules?: boolean;
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
/**
|
|
2162
|
+
* Mathematics extension for inline math expressions
|
|
2163
|
+
*/
|
|
2164
|
+
export declare const VizelMathInline: Node_2<VizelMathematicsOptions, any>;
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* Options for mounting portal content.
|
|
2168
|
+
*/
|
|
2169
|
+
export declare interface VizelMountPortalOptions {
|
|
2170
|
+
/** The z-index layer for the portal */
|
|
2171
|
+
layer?: VizelPortalLayer;
|
|
2172
|
+
/** Additional CSS class names */
|
|
2173
|
+
className?: string;
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
/**
|
|
2177
|
+
* Icon names used in node type selector.
|
|
2178
|
+
*/
|
|
2179
|
+
export declare type VizelNodeTypeIconName = "paragraph" | "heading1" | "heading2" | "heading3" | "bulletList" | "orderedList" | "taskList" | "blockquote" | "codeBlock";
|
|
2180
|
+
|
|
2181
|
+
/**
|
|
2182
|
+
* Node type option for the node selector dropdown
|
|
2183
|
+
*/
|
|
2184
|
+
export declare interface VizelNodeTypeOption {
|
|
2185
|
+
/** Internal node name */
|
|
2186
|
+
name: string;
|
|
2187
|
+
/** Display label */
|
|
2188
|
+
label: string;
|
|
2189
|
+
/** Icon name (semantic name, rendered by framework packages) */
|
|
2190
|
+
icon: VizelNodeTypeIconName;
|
|
2191
|
+
/** Check if this node type is currently active */
|
|
2192
|
+
isActive: (editor: Editor) => boolean;
|
|
2193
|
+
/** Command to transform the current block to this node type */
|
|
2194
|
+
command: (editor: Editor) => void;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
/** Portal layer type */
|
|
2198
|
+
export declare type VizelPortalLayer = keyof typeof VIZEL_PORTAL_Z_INDEX;
|
|
2199
|
+
|
|
2200
|
+
/**
|
|
2201
|
+
* ResizableImage Extension
|
|
2202
|
+
*
|
|
2203
|
+
* Extends the base Image extension with resize handles.
|
|
2204
|
+
* Uses a NodeView to wrap images with draggable resize handles.
|
|
2205
|
+
*/
|
|
2206
|
+
declare const VizelResizableImage: Node_2<VizelResizableImageOptions, any>;
|
|
2207
|
+
export { VizelResizableImage as VizelImageResize }
|
|
2208
|
+
export { VizelResizableImage }
|
|
2209
|
+
|
|
2210
|
+
/**
|
|
2211
|
+
* Configuration options for the VizelResizableImage extension.
|
|
2212
|
+
* These are passed to VizelResizableImage.configure().
|
|
2213
|
+
*/
|
|
2214
|
+
export declare interface VizelResizableImageOptions {
|
|
2215
|
+
/** Minimum width in pixels (default: 100) */
|
|
2216
|
+
minWidth?: number;
|
|
2217
|
+
/** Minimum height in pixels (default: 100) */
|
|
2218
|
+
minHeight?: number;
|
|
2219
|
+
/** Maximum width in pixels (default: undefined - no limit, uses container width) */
|
|
2220
|
+
maxWidth?: number;
|
|
2221
|
+
/** Allow inline images */
|
|
2222
|
+
inline?: boolean;
|
|
2223
|
+
/** Allow base64 encoded images */
|
|
2224
|
+
allowBase64?: boolean;
|
|
2225
|
+
/** HTML attributes for the image element */
|
|
2226
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
/**
|
|
2230
|
+
* Resolved theme (actual applied theme)
|
|
2231
|
+
*/
|
|
2232
|
+
export declare type VizelResolvedTheme = "light" | "dark";
|
|
2233
|
+
|
|
2234
|
+
/**
|
|
2235
|
+
* Options for resolving features with a custom slash menu renderer.
|
|
2236
|
+
*/
|
|
2237
|
+
export declare interface VizelResolveFeaturesOptions {
|
|
2238
|
+
/** The features configuration */
|
|
2239
|
+
features?: VizelFeatureOptions;
|
|
2240
|
+
/** Factory function to create the slash menu renderer */
|
|
2241
|
+
createSlashMenuRenderer: () => unknown;
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
/**
|
|
2245
|
+
* Save status type
|
|
2246
|
+
*/
|
|
2247
|
+
export declare type VizelSaveStatus = "saved" | "saving" | "unsaved" | "error";
|
|
2248
|
+
|
|
2249
|
+
export declare const VizelSlashCommand: Extension<VizelSlashCommandExtensionOptions, any>;
|
|
2250
|
+
|
|
2251
|
+
export declare interface VizelSlashCommandExtensionOptions {
|
|
2252
|
+
/** Custom slash command items (defaults to heading, list, quote, code) */
|
|
2253
|
+
items?: VizelSlashCommandItem[];
|
|
2254
|
+
/** Suggestion options for customizing the popup behavior */
|
|
2255
|
+
suggestion?: Partial<SuggestionOptions>;
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
/**
|
|
2259
|
+
* Command group for categorized display
|
|
2260
|
+
*/
|
|
2261
|
+
export declare interface VizelSlashCommandGroup {
|
|
2262
|
+
/** Group name */
|
|
2263
|
+
name: string;
|
|
2264
|
+
/** Commands in this group */
|
|
2265
|
+
items: VizelSlashCommandItem[];
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
/**
|
|
2269
|
+
* Icon system types for Vizel editor.
|
|
2270
|
+
*
|
|
2271
|
+
* This module defines the icon names and types used throughout the editor.
|
|
2272
|
+
* Framework packages (react, vue, svelte) provide the actual icon implementations
|
|
2273
|
+
* using Iconify or other icon libraries.
|
|
2274
|
+
*/
|
|
2275
|
+
/**
|
|
2276
|
+
* Icon names used in slash commands and menus.
|
|
2277
|
+
* These are semantic names that map to actual icons in framework packages.
|
|
2278
|
+
*/
|
|
2279
|
+
export declare type VizelSlashCommandIconName = "heading1" | "heading2" | "heading3" | "bulletList" | "orderedList" | "taskList" | "blockquote" | "horizontalRule" | "details" | "codeBlock" | "table" | "image" | "imageUpload" | "embed" | "mathBlock" | "mathInline" | "mermaid" | "graphviz";
|
|
2280
|
+
|
|
2281
|
+
/**
|
|
2282
|
+
* Extended slash command item with enhanced features
|
|
2283
|
+
*/
|
|
2284
|
+
export declare interface VizelSlashCommandItem {
|
|
2285
|
+
/** Display title */
|
|
2286
|
+
title: string;
|
|
2287
|
+
/** Description of the command */
|
|
2288
|
+
description: string;
|
|
2289
|
+
/** Icon name (semantic name, rendered by framework packages) */
|
|
2290
|
+
icon: VizelSlashCommandIconName;
|
|
2291
|
+
/** Command to execute */
|
|
2292
|
+
command: (props: {
|
|
2293
|
+
editor: Editor;
|
|
2294
|
+
range: VizelSlashCommandRange;
|
|
2295
|
+
}) => void;
|
|
2296
|
+
/** Keyboard shortcut hint (e.g., "⌘B") */
|
|
2297
|
+
shortcut?: string;
|
|
2298
|
+
/** Additional keywords for fuzzy search */
|
|
2299
|
+
keywords?: string[];
|
|
2300
|
+
/** Group name for categorization */
|
|
2301
|
+
group?: string;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
/**
|
|
2305
|
+
* Slash command feature options
|
|
2306
|
+
*/
|
|
2307
|
+
export declare interface VizelSlashCommandOptions {
|
|
2308
|
+
/** Custom slash command items */
|
|
2309
|
+
items?: VizelSlashCommandItem[];
|
|
2310
|
+
/** Suggestion options (framework-specific renderer) */
|
|
2311
|
+
suggestion?: Record<string, unknown>;
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
/**
|
|
2315
|
+
* Range for slash command execution
|
|
2316
|
+
*/
|
|
2317
|
+
export declare interface VizelSlashCommandRange {
|
|
2318
|
+
from: number;
|
|
2319
|
+
to: number;
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
/**
|
|
2323
|
+
* Fuzzy search result with match highlighting
|
|
2324
|
+
*/
|
|
2325
|
+
export declare interface VizelSlashCommandSearchResult {
|
|
2326
|
+
/** The original item */
|
|
2327
|
+
item: VizelSlashCommandItem;
|
|
2328
|
+
/** Match score (0 = perfect match, higher = worse) */
|
|
2329
|
+
score: number;
|
|
2330
|
+
/** Matched indices for title highlighting */
|
|
2331
|
+
titleMatches?: [number, number][] | undefined;
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
/**
|
|
2335
|
+
* Options for creating a slash menu renderer
|
|
2336
|
+
*/
|
|
2337
|
+
export declare interface VizelSlashMenuRendererOptions {
|
|
2338
|
+
/** Custom class name for the menu */
|
|
2339
|
+
className?: string;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
/**
|
|
2343
|
+
* Storage backend type for auto-save
|
|
2344
|
+
*/
|
|
2345
|
+
export declare type VizelStorageBackend = "localStorage" | "sessionStorage" | {
|
|
2346
|
+
save: (content: JSONContent) => void | Promise<void>;
|
|
2347
|
+
load?: () => JSONContent | null | Promise<JSONContent | null>;
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* A managed suggestion container with positioning support.
|
|
2352
|
+
*/
|
|
2353
|
+
export declare interface VizelSuggestionContainer {
|
|
2354
|
+
/** The outer container element appended to document.body */
|
|
2355
|
+
container: HTMLDivElement;
|
|
2356
|
+
/** The inner container for mounting framework components */
|
|
2357
|
+
menuContainer: HTMLDivElement;
|
|
2358
|
+
/** Update the container position based on the cursor/selection rect */
|
|
2359
|
+
updatePosition: (clientRect: VizelDOMRectGetter) => void;
|
|
2360
|
+
/** Remove the container from the DOM */
|
|
2361
|
+
destroy: () => void;
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
/**
|
|
2365
|
+
* Extended Table with Markdown parsing/rendering support.
|
|
2366
|
+
*/
|
|
2367
|
+
export declare const VizelTable: Node_2<TableOptions, any>;
|
|
2368
|
+
|
|
2369
|
+
/**
|
|
2370
|
+
* Extended TableCell with textAlign attribute support.
|
|
2371
|
+
*/
|
|
2372
|
+
export declare const VizelTableCell: Node_2<TableCellOptions, any>;
|
|
2373
|
+
|
|
2374
|
+
/**
|
|
2375
|
+
* Text alignment options for table cells.
|
|
2376
|
+
*/
|
|
2377
|
+
export declare type VizelTableCellAlignment = "left" | "center" | "right";
|
|
2378
|
+
|
|
2379
|
+
/**
|
|
2380
|
+
* Combined options for table with controls - extends Table's options with UI controls.
|
|
2381
|
+
*/
|
|
2382
|
+
export declare type VizelTableControlsOptions = Partial<TableOptions> & VizelTableControlsUIOptions;
|
|
2383
|
+
|
|
2384
|
+
/**
|
|
2385
|
+
* Options for table controls UI (column/row insert buttons, row handle menu).
|
|
2386
|
+
*/
|
|
2387
|
+
export declare interface VizelTableControlsUIOptions {
|
|
2388
|
+
/**
|
|
2389
|
+
* Show column insert buttons on vertical border hover
|
|
2390
|
+
* @default true
|
|
2391
|
+
*/
|
|
2392
|
+
showColumnInsert?: boolean;
|
|
2393
|
+
/**
|
|
2394
|
+
* Show row insert buttons on horizontal border hover
|
|
2395
|
+
* @default true
|
|
2396
|
+
*/
|
|
2397
|
+
showRowInsert?: boolean;
|
|
2398
|
+
/**
|
|
2399
|
+
* Show row handle with edit menu on cell hover
|
|
2400
|
+
* @default true
|
|
2401
|
+
*/
|
|
2402
|
+
showRowHandle?: boolean;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* Extended TableHeader with textAlign attribute support.
|
|
2407
|
+
*/
|
|
2408
|
+
export declare const VizelTableHeader: Node_2<TableHeaderOptions, any>;
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* Icon names used in table controls.
|
|
2412
|
+
*/
|
|
2413
|
+
export declare type VizelTableIconName = "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "alignLeft" | "alignCenter" | "alignRight" | "plus" | "gripVertical" | "gripHorizontal";
|
|
2414
|
+
|
|
2415
|
+
export declare interface VizelTableMenuItem {
|
|
2416
|
+
label: string;
|
|
2417
|
+
icon?: VizelTableIconName;
|
|
2418
|
+
command: string | ((editor: Editor) => void);
|
|
2419
|
+
destructive?: boolean;
|
|
2420
|
+
divider?: boolean;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
export declare interface VizelTableOptions {
|
|
2424
|
+
/**
|
|
2425
|
+
* If enabled, tables can be resized.
|
|
2426
|
+
* @default false
|
|
2427
|
+
*/
|
|
2428
|
+
resizable?: boolean;
|
|
2429
|
+
/**
|
|
2430
|
+
* Minimum width for table cells.
|
|
2431
|
+
* @default 50
|
|
2432
|
+
*/
|
|
2433
|
+
cellMinWidth?: number;
|
|
2434
|
+
/**
|
|
2435
|
+
* If enabled, the last column can be resized.
|
|
2436
|
+
* @default true
|
|
2437
|
+
*/
|
|
2438
|
+
lastColumnResizable?: boolean;
|
|
2439
|
+
/**
|
|
2440
|
+
* Enable interactive table controls (column/row insert buttons, row handle with menu).
|
|
2441
|
+
* Set to `true` to enable all controls, `false` to disable, or an object to customize.
|
|
2442
|
+
* @default true
|
|
2443
|
+
*/
|
|
2444
|
+
controls?: boolean | VizelTableControlsOptions;
|
|
2445
|
+
/**
|
|
2446
|
+
* Additional HTML attributes for table elements.
|
|
2447
|
+
*/
|
|
2448
|
+
tableHTMLAttributes?: Record<string, string>;
|
|
2449
|
+
headerHTMLAttributes?: Record<string, string>;
|
|
2450
|
+
cellHTMLAttributes?: Record<string, string>;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* VizelTableWithControls - Table extension with interactive controls
|
|
2455
|
+
*/
|
|
2456
|
+
export declare const VizelTableWithControls: Node_2<VizelTableControlsOptions, any>;
|
|
2457
|
+
|
|
2458
|
+
export declare interface VizelTaskItemOptions {
|
|
2459
|
+
/**
|
|
2460
|
+
* HTML attributes to add to the task item element
|
|
2461
|
+
*/
|
|
2462
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
2463
|
+
/**
|
|
2464
|
+
* Whether the task item checkbox is nested inside a label
|
|
2465
|
+
* @default true
|
|
2466
|
+
*/
|
|
2467
|
+
nested?: boolean;
|
|
2468
|
+
/**
|
|
2469
|
+
* A callback triggered when a task item is clicked (checked/unchecked)
|
|
2470
|
+
*/
|
|
2471
|
+
onReadOnlyChecked?: (node: unknown, checked: boolean) => boolean;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
export declare interface VizelTaskListExtensionsOptions {
|
|
2475
|
+
/**
|
|
2476
|
+
* Options for the task list extension
|
|
2477
|
+
*/
|
|
2478
|
+
taskList?: VizelTaskListOptions;
|
|
2479
|
+
/**
|
|
2480
|
+
* Options for the task item extension
|
|
2481
|
+
*/
|
|
2482
|
+
taskItem?: VizelTaskItemOptions;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
export declare interface VizelTaskListOptions {
|
|
2486
|
+
/**
|
|
2487
|
+
* HTML attributes to add to the task list element
|
|
2488
|
+
*/
|
|
2489
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
2490
|
+
/**
|
|
2491
|
+
* The node name for list items
|
|
2492
|
+
* @default 'taskItem'
|
|
2493
|
+
*/
|
|
2494
|
+
itemTypeName?: string;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
/**
|
|
2498
|
+
* Options for text color extensions
|
|
2499
|
+
*/
|
|
2500
|
+
export declare interface VizelTextColorOptions {
|
|
2501
|
+
/** Custom text color palette */
|
|
2502
|
+
textColors?: VizelColorDefinition[];
|
|
2503
|
+
/** Custom highlight color palette */
|
|
2504
|
+
highlightColors?: VizelColorDefinition[];
|
|
2505
|
+
/** Enable multicolor highlights (allows any color) */
|
|
2506
|
+
multicolor?: boolean;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
/**
|
|
2510
|
+
* Text highlighting utilities for Vizel editor.
|
|
2511
|
+
*
|
|
2512
|
+
* These utilities help with highlighting matched text segments,
|
|
2513
|
+
* typically used in fuzzy search results (e.g., slash menu).
|
|
2514
|
+
*/
|
|
2515
|
+
/**
|
|
2516
|
+
* A segment of text that may or may not be highlighted.
|
|
2517
|
+
*/
|
|
2518
|
+
export declare interface VizelTextSegment {
|
|
2519
|
+
/** The text content of this segment */
|
|
2520
|
+
text: string;
|
|
2521
|
+
/** Whether this segment should be highlighted */
|
|
2522
|
+
highlight: boolean;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
/**
|
|
2526
|
+
* Theme utilities for Vizel editor
|
|
2527
|
+
*
|
|
2528
|
+
* Provides dark mode support with system preference detection and manual toggle.
|
|
2529
|
+
*/
|
|
2530
|
+
/**
|
|
2531
|
+
* Available theme options
|
|
2532
|
+
*/
|
|
2533
|
+
export declare type VizelTheme = "light" | "dark" | "system";
|
|
2534
|
+
|
|
2535
|
+
/**
|
|
2536
|
+
* Theme provider options
|
|
2537
|
+
*/
|
|
2538
|
+
export declare interface VizelThemeProviderOptions {
|
|
2539
|
+
/** Default theme (default: "system") */
|
|
2540
|
+
defaultTheme?: VizelTheme;
|
|
2541
|
+
/** Storage key for persisting theme (default: "vizel-theme") */
|
|
2542
|
+
storageKey?: string;
|
|
2543
|
+
/** Target element to apply theme attribute (default: document.documentElement) */
|
|
2544
|
+
targetSelector?: string;
|
|
2545
|
+
/** Disable theme transitions during initial load */
|
|
2546
|
+
disableTransitionOnChange?: boolean;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
/**
|
|
2550
|
+
* Theme state returned by useTheme hooks
|
|
2551
|
+
*/
|
|
2552
|
+
export declare interface VizelThemeState {
|
|
2553
|
+
/** Current theme setting */
|
|
2554
|
+
theme: VizelTheme;
|
|
2555
|
+
/** Resolved theme (actual applied theme) */
|
|
2556
|
+
resolvedTheme: VizelResolvedTheme;
|
|
2557
|
+
/** System theme preference */
|
|
2558
|
+
systemTheme: VizelResolvedTheme;
|
|
2559
|
+
/** Set theme */
|
|
2560
|
+
setTheme: (theme: VizelTheme) => void;
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
/**
|
|
2564
|
+
* Icon names used in UI components (SaveIndicator, etc.).
|
|
2565
|
+
*/
|
|
2566
|
+
export declare type VizelUIIconName = "check" | "loader" | "circle" | "warning" | "chevronDown" | "x";
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* Image upload function type
|
|
2570
|
+
*/
|
|
2571
|
+
export declare type VizelUploadImageFn = (file: File, view: EditorView, pos: number) => void;
|
|
2572
|
+
|
|
2573
|
+
export { }
|
|
2574
|
+
|
|
2575
|
+
|
|
2576
|
+
declare module "@tiptap/core" {
|
|
2577
|
+
interface Commands<ReturnType> {
|
|
2578
|
+
embed: {
|
|
2579
|
+
/**
|
|
2580
|
+
* Set an embed from URL
|
|
2581
|
+
*/
|
|
2582
|
+
setEmbed: (options: {
|
|
2583
|
+
url: string;
|
|
2584
|
+
}) => ReturnType;
|
|
2585
|
+
/**
|
|
2586
|
+
* Update embed data
|
|
2587
|
+
*/
|
|
2588
|
+
updateEmbed: (data: Partial<VizelEmbedData>) => ReturnType;
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
declare module "@tiptap/core" {
|
|
2595
|
+
interface Commands<ReturnType> {
|
|
2596
|
+
vizelBlockMove: {
|
|
2597
|
+
/**
|
|
2598
|
+
* Move the current block up
|
|
2599
|
+
*/
|
|
2600
|
+
moveBlockUp: () => ReturnType;
|
|
2601
|
+
/**
|
|
2602
|
+
* Move the current block down
|
|
2603
|
+
*/
|
|
2604
|
+
moveBlockDown: () => ReturnType;
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
|
|
2610
|
+
declare module "@tiptap/core" {
|
|
2611
|
+
interface Commands<ReturnType> {
|
|
2612
|
+
diagram: {
|
|
2613
|
+
/**
|
|
2614
|
+
* Insert a diagram block
|
|
2615
|
+
*/
|
|
2616
|
+
insertDiagram: (options: {
|
|
2617
|
+
code: string;
|
|
2618
|
+
type?: VizelDiagramType;
|
|
2619
|
+
}) => ReturnType;
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
|
|
2625
|
+
declare module "@tiptap/core" {
|
|
2626
|
+
interface Commands<ReturnType> {
|
|
2627
|
+
mathematics: {
|
|
2628
|
+
/**
|
|
2629
|
+
* Insert an inline math expression
|
|
2630
|
+
*/
|
|
2631
|
+
insertMath: (options: {
|
|
2632
|
+
latex: string;
|
|
2633
|
+
}) => ReturnType;
|
|
2634
|
+
/**
|
|
2635
|
+
* Insert a block math expression
|
|
2636
|
+
*/
|
|
2637
|
+
insertMathBlock: (options: {
|
|
2638
|
+
latex: string;
|
|
2639
|
+
}) => ReturnType;
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
}
|