@domternal/vue 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/index.d.ts +786 -0
- package/dist/index.js +2046 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { ShallowRef, Ref, ComputedRef, InjectionKey, defineComponent, PropType, Component, AppContext } from 'vue';
|
|
3
|
+
import * as _domternal_core from '@domternal/core';
|
|
4
|
+
import { AnyExtension, Content, FocusPosition, Editor, JSONContent, IconSet, ToolbarLayoutEntry, BubbleMenuOptions, FloatingMenuOptions } from '@domternal/core';
|
|
5
|
+
export { AnyExtension, Content, Editor, FocusPosition, GenerateHTMLOptions, GenerateJSONOptions, GenerateTextOptions, JSONContent, generateHTML, generateJSON, generateText } from '@domternal/core';
|
|
6
|
+
import * as prosemirror_state from 'prosemirror-state';
|
|
7
|
+
import * as prosemirror_view from 'prosemirror-view';
|
|
8
|
+
|
|
9
|
+
declare const DEFAULT_EXTENSIONS: AnyExtension[];
|
|
10
|
+
interface UseEditorOptions {
|
|
11
|
+
/** Custom extensions to add to the editor. */
|
|
12
|
+
extensions?: AnyExtension[];
|
|
13
|
+
/** Initial editor content (HTML string or JSON). */
|
|
14
|
+
content?: Content;
|
|
15
|
+
/** Whether the editor is editable. @default true */
|
|
16
|
+
editable?: boolean;
|
|
17
|
+
/** Where to autofocus on mount. @default false */
|
|
18
|
+
autofocus?: FocusPosition;
|
|
19
|
+
/** Output format for content comparison. @default 'html' */
|
|
20
|
+
outputFormat?: 'html' | 'json';
|
|
21
|
+
/**
|
|
22
|
+
* Set to true to create the editor synchronously during setup instead of
|
|
23
|
+
* waiting for onMounted. Only useful when SSR is not a concern.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
immediatelyRender?: boolean;
|
|
27
|
+
/** Called when the editor instance is created. */
|
|
28
|
+
onCreate?: (editor: Editor) => void;
|
|
29
|
+
/** Called when the document content changes. */
|
|
30
|
+
onUpdate?: (props: {
|
|
31
|
+
editor: Editor;
|
|
32
|
+
}) => void;
|
|
33
|
+
/** Called when the selection changes without content change. */
|
|
34
|
+
onSelectionChange?: (props: {
|
|
35
|
+
editor: Editor;
|
|
36
|
+
}) => void;
|
|
37
|
+
/** Called when the editor gains focus. */
|
|
38
|
+
onFocus?: (props: {
|
|
39
|
+
editor: Editor;
|
|
40
|
+
event: FocusEvent;
|
|
41
|
+
}) => void;
|
|
42
|
+
/** Called when the editor loses focus. */
|
|
43
|
+
onBlur?: (props: {
|
|
44
|
+
editor: Editor;
|
|
45
|
+
event: FocusEvent;
|
|
46
|
+
}) => void;
|
|
47
|
+
/** Called before the editor is destroyed. */
|
|
48
|
+
onDestroy?: () => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Core composable for creating and managing a Domternal editor instance.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const { editor, editorRef } = useEditor({ extensions, content });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example SSR-safe (default in Vue - onMounted never runs on server)
|
|
59
|
+
* ```ts
|
|
60
|
+
* const { editor, editorRef } = useEditor({ extensions, content });
|
|
61
|
+
* // editor.value is null until onMounted
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function useEditor(options?: UseEditorOptions): {
|
|
65
|
+
editor: ShallowRef<Editor | null>;
|
|
66
|
+
editorRef: Ref<HTMLDivElement | undefined>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Full editor state returned when no selector is provided.
|
|
71
|
+
*/
|
|
72
|
+
interface EditorState {
|
|
73
|
+
htmlContent: Ref<string>;
|
|
74
|
+
jsonContent: Ref<JSONContent | null>;
|
|
75
|
+
isEmpty: Ref<boolean>;
|
|
76
|
+
isFocused: Ref<boolean>;
|
|
77
|
+
isEditable: Ref<boolean>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Subscribe to editor state changes.
|
|
81
|
+
*
|
|
82
|
+
* **Overload 1 - Full state:**
|
|
83
|
+
* ```ts
|
|
84
|
+
* const { htmlContent, isEmpty } = useEditorState(editor);
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* **Overload 2 - Selector (granular, avoids unnecessary re-renders):**
|
|
88
|
+
* ```ts
|
|
89
|
+
* const isBold = useEditorState(editor, (ed) => ed.isActive('bold'));
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function useEditorState(editor: ShallowRef<Editor | null>): EditorState;
|
|
93
|
+
declare function useEditorState<T>(editor: ShallowRef<Editor | null>, selector: (editor: Editor) => T): ComputedRef<T | undefined>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Typed injection key for the editor instance.
|
|
97
|
+
* Components use this via provide/inject to share the editor
|
|
98
|
+
* without prop drilling.
|
|
99
|
+
*/
|
|
100
|
+
declare const EDITOR_KEY: InjectionKey<ShallowRef<Editor | null>>;
|
|
101
|
+
/**
|
|
102
|
+
* Provides an editor instance to all descendant components via Vue's
|
|
103
|
+
* provide/inject system. Also stores the appContext in the WeakMap
|
|
104
|
+
* for VueNodeViewRenderer to forward the provide/inject chain.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const { editor } = useEditor({ extensions, content });
|
|
109
|
+
* provideEditor(editor);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare function provideEditor(editor: ShallowRef<Editor | null>): void;
|
|
113
|
+
/**
|
|
114
|
+
* Access the editor instance from the nearest provider.
|
|
115
|
+
*
|
|
116
|
+
* @returns `{ editor }` where editor is a ShallowRef that may be null
|
|
117
|
+
* if the provider has no editor yet or if used outside a provider.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const { editor } = useCurrentEditor();
|
|
122
|
+
* if (editor.value) {
|
|
123
|
+
* editor.value.commands.toggleBold();
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare function useCurrentEditor(): {
|
|
128
|
+
editor: ShallowRef<Editor | null>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
interface DomternalProps extends UseEditorOptions {
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Composable root component that creates an editor and provides it to all
|
|
135
|
+
* subcomponents via inject. No need to pass `editor` prop to children.
|
|
136
|
+
*
|
|
137
|
+
* Supports namespaced subcomponents in `<script setup>` templates:
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```vue
|
|
141
|
+
* <script setup>
|
|
142
|
+
* import { Domternal } from '@domternal/vue';
|
|
143
|
+
* </script>
|
|
144
|
+
* <template>
|
|
145
|
+
* <Domternal :extensions="extensions" :content="content">
|
|
146
|
+
* <Domternal.Toolbar />
|
|
147
|
+
* <Domternal.Content />
|
|
148
|
+
* <Domternal.BubbleMenu :contexts="{ text: ['bold', 'italic'] }" />
|
|
149
|
+
* <Domternal.EmojiPicker :emojis="emojis" />
|
|
150
|
+
* </Domternal>
|
|
151
|
+
* </template>
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
declare const Domternal: ReturnType<typeof defineComponent> & {
|
|
155
|
+
Content: ReturnType<typeof defineComponent>;
|
|
156
|
+
Loading: ReturnType<typeof defineComponent>;
|
|
157
|
+
Toolbar: ReturnType<typeof defineComponent>;
|
|
158
|
+
BubbleMenu: ReturnType<typeof defineComponent>;
|
|
159
|
+
FloatingMenu: ReturnType<typeof defineComponent>;
|
|
160
|
+
EmojiPicker: ReturnType<typeof defineComponent>;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
interface DomternalEditorProps {
|
|
164
|
+
extensions?: AnyExtension[];
|
|
165
|
+
content?: Content;
|
|
166
|
+
editable?: boolean;
|
|
167
|
+
autofocus?: FocusPosition;
|
|
168
|
+
immediatelyRender?: boolean;
|
|
169
|
+
outputFormat?: 'html' | 'json';
|
|
170
|
+
modelValue?: Content;
|
|
171
|
+
class?: string;
|
|
172
|
+
onCreate?: (editor: _domternal_core.Editor) => void;
|
|
173
|
+
onUpdate?: (props: {
|
|
174
|
+
editor: _domternal_core.Editor;
|
|
175
|
+
}) => void;
|
|
176
|
+
onSelectionChange?: (props: {
|
|
177
|
+
editor: _domternal_core.Editor;
|
|
178
|
+
}) => void;
|
|
179
|
+
onFocus?: (props: {
|
|
180
|
+
editor: _domternal_core.Editor;
|
|
181
|
+
event: FocusEvent;
|
|
182
|
+
}) => void;
|
|
183
|
+
onBlur?: (props: {
|
|
184
|
+
editor: _domternal_core.Editor;
|
|
185
|
+
event: FocusEvent;
|
|
186
|
+
}) => void;
|
|
187
|
+
onDestroy?: () => void;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* All-in-one editor component with v-model support and integrated context.
|
|
191
|
+
*
|
|
192
|
+
* Wraps children with provideEditor automatically, so toolbar, bubble menu,
|
|
193
|
+
* and emoji picker components can access the editor via inject.
|
|
194
|
+
*
|
|
195
|
+
* @example Basic usage
|
|
196
|
+
* ```vue
|
|
197
|
+
* <DomternalEditor
|
|
198
|
+
* :extensions="[Bold, Italic, Heading]"
|
|
199
|
+
* content="<p>Hello</p>"
|
|
200
|
+
* />
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @example v-model (two-way binding)
|
|
204
|
+
* ```vue
|
|
205
|
+
* <DomternalEditor v-model="content" :extensions="extensions" />
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @example With children (toolbar, bubble menu)
|
|
209
|
+
* ```vue
|
|
210
|
+
* <DomternalEditor :extensions="extensions" v-model="content">
|
|
211
|
+
* <DomternalToolbar />
|
|
212
|
+
* <DomternalBubbleMenu :contexts="{ text: ['bold', 'italic'] }" />
|
|
213
|
+
* </DomternalEditor>
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
declare const DomternalEditor: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
217
|
+
extensions: {
|
|
218
|
+
type: PropType<AnyExtension[]>;
|
|
219
|
+
default: undefined;
|
|
220
|
+
};
|
|
221
|
+
content: {
|
|
222
|
+
type: PropType<Content>;
|
|
223
|
+
default: undefined;
|
|
224
|
+
};
|
|
225
|
+
editable: {
|
|
226
|
+
type: BooleanConstructor;
|
|
227
|
+
default: boolean;
|
|
228
|
+
};
|
|
229
|
+
autofocus: {
|
|
230
|
+
type: PropType<FocusPosition>;
|
|
231
|
+
default: boolean;
|
|
232
|
+
};
|
|
233
|
+
immediatelyRender: {
|
|
234
|
+
type: BooleanConstructor;
|
|
235
|
+
default: boolean;
|
|
236
|
+
};
|
|
237
|
+
outputFormat: {
|
|
238
|
+
type: PropType<"html" | "json">;
|
|
239
|
+
default: string;
|
|
240
|
+
};
|
|
241
|
+
modelValue: {
|
|
242
|
+
type: PropType<Content>;
|
|
243
|
+
default: undefined;
|
|
244
|
+
};
|
|
245
|
+
class: {
|
|
246
|
+
type: StringConstructor;
|
|
247
|
+
default: undefined;
|
|
248
|
+
};
|
|
249
|
+
onCreate: {
|
|
250
|
+
type: PropType<(editor: _domternal_core.Editor) => void>;
|
|
251
|
+
default: undefined;
|
|
252
|
+
};
|
|
253
|
+
onUpdate: {
|
|
254
|
+
type: PropType<(props: {
|
|
255
|
+
editor: _domternal_core.Editor;
|
|
256
|
+
}) => void>;
|
|
257
|
+
default: undefined;
|
|
258
|
+
};
|
|
259
|
+
onSelectionChange: {
|
|
260
|
+
type: PropType<(props: {
|
|
261
|
+
editor: _domternal_core.Editor;
|
|
262
|
+
}) => void>;
|
|
263
|
+
default: undefined;
|
|
264
|
+
};
|
|
265
|
+
onFocus: {
|
|
266
|
+
type: PropType<(props: {
|
|
267
|
+
editor: _domternal_core.Editor;
|
|
268
|
+
event: FocusEvent;
|
|
269
|
+
}) => void>;
|
|
270
|
+
default: undefined;
|
|
271
|
+
};
|
|
272
|
+
onBlur: {
|
|
273
|
+
type: PropType<(props: {
|
|
274
|
+
editor: _domternal_core.Editor;
|
|
275
|
+
event: FocusEvent;
|
|
276
|
+
}) => void>;
|
|
277
|
+
default: undefined;
|
|
278
|
+
};
|
|
279
|
+
onDestroy: {
|
|
280
|
+
type: PropType<() => void>;
|
|
281
|
+
default: undefined;
|
|
282
|
+
};
|
|
283
|
+
}>, () => (vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
284
|
+
[key: string]: any;
|
|
285
|
+
}> | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
286
|
+
[key: string]: any;
|
|
287
|
+
}>[] | undefined)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
288
|
+
'update:modelValue': (_value: Content | JSONContent) => true;
|
|
289
|
+
}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
290
|
+
extensions: {
|
|
291
|
+
type: PropType<AnyExtension[]>;
|
|
292
|
+
default: undefined;
|
|
293
|
+
};
|
|
294
|
+
content: {
|
|
295
|
+
type: PropType<Content>;
|
|
296
|
+
default: undefined;
|
|
297
|
+
};
|
|
298
|
+
editable: {
|
|
299
|
+
type: BooleanConstructor;
|
|
300
|
+
default: boolean;
|
|
301
|
+
};
|
|
302
|
+
autofocus: {
|
|
303
|
+
type: PropType<FocusPosition>;
|
|
304
|
+
default: boolean;
|
|
305
|
+
};
|
|
306
|
+
immediatelyRender: {
|
|
307
|
+
type: BooleanConstructor;
|
|
308
|
+
default: boolean;
|
|
309
|
+
};
|
|
310
|
+
outputFormat: {
|
|
311
|
+
type: PropType<"html" | "json">;
|
|
312
|
+
default: string;
|
|
313
|
+
};
|
|
314
|
+
modelValue: {
|
|
315
|
+
type: PropType<Content>;
|
|
316
|
+
default: undefined;
|
|
317
|
+
};
|
|
318
|
+
class: {
|
|
319
|
+
type: StringConstructor;
|
|
320
|
+
default: undefined;
|
|
321
|
+
};
|
|
322
|
+
onCreate: {
|
|
323
|
+
type: PropType<(editor: _domternal_core.Editor) => void>;
|
|
324
|
+
default: undefined;
|
|
325
|
+
};
|
|
326
|
+
onUpdate: {
|
|
327
|
+
type: PropType<(props: {
|
|
328
|
+
editor: _domternal_core.Editor;
|
|
329
|
+
}) => void>;
|
|
330
|
+
default: undefined;
|
|
331
|
+
};
|
|
332
|
+
onSelectionChange: {
|
|
333
|
+
type: PropType<(props: {
|
|
334
|
+
editor: _domternal_core.Editor;
|
|
335
|
+
}) => void>;
|
|
336
|
+
default: undefined;
|
|
337
|
+
};
|
|
338
|
+
onFocus: {
|
|
339
|
+
type: PropType<(props: {
|
|
340
|
+
editor: _domternal_core.Editor;
|
|
341
|
+
event: FocusEvent;
|
|
342
|
+
}) => void>;
|
|
343
|
+
default: undefined;
|
|
344
|
+
};
|
|
345
|
+
onBlur: {
|
|
346
|
+
type: PropType<(props: {
|
|
347
|
+
editor: _domternal_core.Editor;
|
|
348
|
+
event: FocusEvent;
|
|
349
|
+
}) => void>;
|
|
350
|
+
default: undefined;
|
|
351
|
+
};
|
|
352
|
+
onDestroy: {
|
|
353
|
+
type: PropType<() => void>;
|
|
354
|
+
default: undefined;
|
|
355
|
+
};
|
|
356
|
+
}>> & Readonly<{
|
|
357
|
+
"onUpdate:modelValue"?: (_value: Content) => any;
|
|
358
|
+
}>, {
|
|
359
|
+
onBlur: (props: {
|
|
360
|
+
editor: _domternal_core.Editor;
|
|
361
|
+
event: FocusEvent;
|
|
362
|
+
}) => void;
|
|
363
|
+
onFocus: (props: {
|
|
364
|
+
editor: _domternal_core.Editor;
|
|
365
|
+
event: FocusEvent;
|
|
366
|
+
}) => void;
|
|
367
|
+
class: string;
|
|
368
|
+
onCreate: (editor: _domternal_core.Editor) => void;
|
|
369
|
+
onUpdate: (props: {
|
|
370
|
+
editor: _domternal_core.Editor;
|
|
371
|
+
}) => void;
|
|
372
|
+
onDestroy: () => void;
|
|
373
|
+
content: Content;
|
|
374
|
+
onSelectionChange: (props: {
|
|
375
|
+
editor: _domternal_core.Editor;
|
|
376
|
+
}) => void;
|
|
377
|
+
extensions: AnyExtension[];
|
|
378
|
+
editable: boolean;
|
|
379
|
+
autofocus: FocusPosition;
|
|
380
|
+
outputFormat: "html" | "json";
|
|
381
|
+
immediatelyRender: boolean;
|
|
382
|
+
modelValue: Content;
|
|
383
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Renders the ProseMirror editor view into a div element.
|
|
387
|
+
*
|
|
388
|
+
* Use this with `useEditor` for a flexible, decoupled pattern where the
|
|
389
|
+
* editor composable and rendering are separated.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```vue
|
|
393
|
+
* <script setup>
|
|
394
|
+
* import { useEditor, EditorContent } from '@domternal/vue';
|
|
395
|
+
* const { editor } = useEditor({ extensions, content });
|
|
396
|
+
* </script>
|
|
397
|
+
* <template>
|
|
398
|
+
* <EditorContent :editor="editor" class="my-editor" />
|
|
399
|
+
* </template>
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
declare const EditorContent: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
403
|
+
editor: {
|
|
404
|
+
type: PropType<Editor | null>;
|
|
405
|
+
default: null;
|
|
406
|
+
};
|
|
407
|
+
class: {
|
|
408
|
+
type: StringConstructor;
|
|
409
|
+
default: undefined;
|
|
410
|
+
};
|
|
411
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
412
|
+
[key: string]: any;
|
|
413
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
414
|
+
editor: {
|
|
415
|
+
type: PropType<Editor | null>;
|
|
416
|
+
default: null;
|
|
417
|
+
};
|
|
418
|
+
class: {
|
|
419
|
+
type: StringConstructor;
|
|
420
|
+
default: undefined;
|
|
421
|
+
};
|
|
422
|
+
}>> & Readonly<{}>, {
|
|
423
|
+
editor: Editor | null;
|
|
424
|
+
class: string;
|
|
425
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
426
|
+
|
|
427
|
+
interface DomternalToolbarProps {
|
|
428
|
+
editor?: Editor;
|
|
429
|
+
icons?: IconSet;
|
|
430
|
+
layout?: ToolbarLayoutEntry[];
|
|
431
|
+
}
|
|
432
|
+
declare const DomternalToolbar: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
433
|
+
editor: {
|
|
434
|
+
type: PropType<Editor>;
|
|
435
|
+
default: undefined;
|
|
436
|
+
};
|
|
437
|
+
icons: {
|
|
438
|
+
type: PropType<IconSet>;
|
|
439
|
+
default: undefined;
|
|
440
|
+
};
|
|
441
|
+
layout: {
|
|
442
|
+
type: PropType<ToolbarLayoutEntry[]>;
|
|
443
|
+
default: undefined;
|
|
444
|
+
};
|
|
445
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
446
|
+
[key: string]: any;
|
|
447
|
+
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
448
|
+
editor: {
|
|
449
|
+
type: PropType<Editor>;
|
|
450
|
+
default: undefined;
|
|
451
|
+
};
|
|
452
|
+
icons: {
|
|
453
|
+
type: PropType<IconSet>;
|
|
454
|
+
default: undefined;
|
|
455
|
+
};
|
|
456
|
+
layout: {
|
|
457
|
+
type: PropType<ToolbarLayoutEntry[]>;
|
|
458
|
+
default: undefined;
|
|
459
|
+
};
|
|
460
|
+
}>> & Readonly<{}>, {
|
|
461
|
+
editor: Editor;
|
|
462
|
+
icons: IconSet;
|
|
463
|
+
layout: ToolbarLayoutEntry[];
|
|
464
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
465
|
+
|
|
466
|
+
interface DomternalBubbleMenuProps {
|
|
467
|
+
editor?: Editor;
|
|
468
|
+
shouldShow?: BubbleMenuOptions['shouldShow'];
|
|
469
|
+
placement?: 'top' | 'bottom';
|
|
470
|
+
offset?: number;
|
|
471
|
+
updateDelay?: number;
|
|
472
|
+
items?: string[];
|
|
473
|
+
contexts?: Record<string, string[] | true | null>;
|
|
474
|
+
}
|
|
475
|
+
declare const DomternalBubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
476
|
+
editor: {
|
|
477
|
+
type: PropType<Editor>;
|
|
478
|
+
default: undefined;
|
|
479
|
+
};
|
|
480
|
+
shouldShow: {
|
|
481
|
+
type: PropType<BubbleMenuOptions["shouldShow"]>;
|
|
482
|
+
default: undefined;
|
|
483
|
+
};
|
|
484
|
+
placement: {
|
|
485
|
+
type: PropType<"top" | "bottom">;
|
|
486
|
+
default: string;
|
|
487
|
+
};
|
|
488
|
+
offset: {
|
|
489
|
+
type: NumberConstructor;
|
|
490
|
+
default: number;
|
|
491
|
+
};
|
|
492
|
+
updateDelay: {
|
|
493
|
+
type: NumberConstructor;
|
|
494
|
+
default: number;
|
|
495
|
+
};
|
|
496
|
+
items: {
|
|
497
|
+
type: PropType<string[]>;
|
|
498
|
+
default: undefined;
|
|
499
|
+
};
|
|
500
|
+
contexts: {
|
|
501
|
+
type: PropType<Record<string, string[] | true | null>>;
|
|
502
|
+
default: undefined;
|
|
503
|
+
};
|
|
504
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
505
|
+
[key: string]: any;
|
|
506
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
507
|
+
editor: {
|
|
508
|
+
type: PropType<Editor>;
|
|
509
|
+
default: undefined;
|
|
510
|
+
};
|
|
511
|
+
shouldShow: {
|
|
512
|
+
type: PropType<BubbleMenuOptions["shouldShow"]>;
|
|
513
|
+
default: undefined;
|
|
514
|
+
};
|
|
515
|
+
placement: {
|
|
516
|
+
type: PropType<"top" | "bottom">;
|
|
517
|
+
default: string;
|
|
518
|
+
};
|
|
519
|
+
offset: {
|
|
520
|
+
type: NumberConstructor;
|
|
521
|
+
default: number;
|
|
522
|
+
};
|
|
523
|
+
updateDelay: {
|
|
524
|
+
type: NumberConstructor;
|
|
525
|
+
default: number;
|
|
526
|
+
};
|
|
527
|
+
items: {
|
|
528
|
+
type: PropType<string[]>;
|
|
529
|
+
default: undefined;
|
|
530
|
+
};
|
|
531
|
+
contexts: {
|
|
532
|
+
type: PropType<Record<string, string[] | true | null>>;
|
|
533
|
+
default: undefined;
|
|
534
|
+
};
|
|
535
|
+
}>> & Readonly<{}>, {
|
|
536
|
+
editor: Editor;
|
|
537
|
+
shouldShow: (props: {
|
|
538
|
+
editor: Editor;
|
|
539
|
+
view: prosemirror_view.EditorView;
|
|
540
|
+
state: prosemirror_state.EditorState;
|
|
541
|
+
from: number;
|
|
542
|
+
to: number;
|
|
543
|
+
}) => boolean;
|
|
544
|
+
placement: "top" | "bottom";
|
|
545
|
+
offset: number;
|
|
546
|
+
updateDelay: number;
|
|
547
|
+
items: string[];
|
|
548
|
+
contexts: Record<string, true | string[] | null>;
|
|
549
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
550
|
+
|
|
551
|
+
interface DomternalFloatingMenuProps {
|
|
552
|
+
editor?: Editor;
|
|
553
|
+
shouldShow?: FloatingMenuOptions['shouldShow'];
|
|
554
|
+
offset?: number;
|
|
555
|
+
}
|
|
556
|
+
declare const DomternalFloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
557
|
+
editor: {
|
|
558
|
+
type: PropType<Editor>;
|
|
559
|
+
default: undefined;
|
|
560
|
+
};
|
|
561
|
+
shouldShow: {
|
|
562
|
+
type: PropType<FloatingMenuOptions["shouldShow"]>;
|
|
563
|
+
default: undefined;
|
|
564
|
+
};
|
|
565
|
+
offset: {
|
|
566
|
+
type: NumberConstructor;
|
|
567
|
+
default: number;
|
|
568
|
+
};
|
|
569
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
570
|
+
[key: string]: any;
|
|
571
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
572
|
+
editor: {
|
|
573
|
+
type: PropType<Editor>;
|
|
574
|
+
default: undefined;
|
|
575
|
+
};
|
|
576
|
+
shouldShow: {
|
|
577
|
+
type: PropType<FloatingMenuOptions["shouldShow"]>;
|
|
578
|
+
default: undefined;
|
|
579
|
+
};
|
|
580
|
+
offset: {
|
|
581
|
+
type: NumberConstructor;
|
|
582
|
+
default: number;
|
|
583
|
+
};
|
|
584
|
+
}>> & Readonly<{}>, {
|
|
585
|
+
editor: Editor;
|
|
586
|
+
shouldShow: (props: {
|
|
587
|
+
editor: Editor;
|
|
588
|
+
view: prosemirror_view.EditorView;
|
|
589
|
+
state: prosemirror_state.EditorState;
|
|
590
|
+
}) => boolean;
|
|
591
|
+
offset: number;
|
|
592
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
593
|
+
|
|
594
|
+
interface EmojiPickerItem {
|
|
595
|
+
emoji: string;
|
|
596
|
+
name: string;
|
|
597
|
+
group: string;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
interface DomternalEmojiPickerProps {
|
|
601
|
+
editor?: Editor;
|
|
602
|
+
emojis: EmojiPickerItem[];
|
|
603
|
+
}
|
|
604
|
+
declare const DomternalEmojiPicker: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
605
|
+
editor: {
|
|
606
|
+
type: PropType<Editor>;
|
|
607
|
+
default: undefined;
|
|
608
|
+
};
|
|
609
|
+
emojis: {
|
|
610
|
+
type: PropType<EmojiPickerItem[]>;
|
|
611
|
+
required: true;
|
|
612
|
+
};
|
|
613
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
614
|
+
[key: string]: any;
|
|
615
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
616
|
+
editor: {
|
|
617
|
+
type: PropType<Editor>;
|
|
618
|
+
default: undefined;
|
|
619
|
+
};
|
|
620
|
+
emojis: {
|
|
621
|
+
type: PropType<EmojiPickerItem[]>;
|
|
622
|
+
required: true;
|
|
623
|
+
};
|
|
624
|
+
}>> & Readonly<{}>, {
|
|
625
|
+
editor: Editor;
|
|
626
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
627
|
+
|
|
628
|
+
/** ProseMirror node shape passed to node views. */
|
|
629
|
+
interface PMNode {
|
|
630
|
+
type: {
|
|
631
|
+
name: string;
|
|
632
|
+
spec: {
|
|
633
|
+
group?: string;
|
|
634
|
+
};
|
|
635
|
+
};
|
|
636
|
+
attrs: Record<string, unknown>;
|
|
637
|
+
textContent: string;
|
|
638
|
+
nodeSize: number;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Props passed to custom Vue node view components.
|
|
642
|
+
*/
|
|
643
|
+
interface VueNodeViewProps {
|
|
644
|
+
editor: Editor;
|
|
645
|
+
node: PMNode;
|
|
646
|
+
selected: boolean;
|
|
647
|
+
getPos: () => number | undefined;
|
|
648
|
+
updateAttributes: (attrs: Record<string, unknown>) => void;
|
|
649
|
+
deleteNode: () => void;
|
|
650
|
+
extension: {
|
|
651
|
+
name: string;
|
|
652
|
+
options: Record<string, unknown>;
|
|
653
|
+
};
|
|
654
|
+
decorations: readonly unknown[];
|
|
655
|
+
}
|
|
656
|
+
interface VueNodeViewRendererOptions {
|
|
657
|
+
/** Wrapper element tag. @default 'div' for block, 'span' for inline */
|
|
658
|
+
as?: string;
|
|
659
|
+
/** Additional CSS class on the wrapper element. */
|
|
660
|
+
className?: string;
|
|
661
|
+
/** Tag for the content DOM element. Set to null for no editable content. @default 'div' */
|
|
662
|
+
contentDOMElement?: string | null;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Converts a Vue component into a ProseMirror NodeView constructor.
|
|
666
|
+
*
|
|
667
|
+
* Uses Vue's low-level `render(h(), el)` API with appContext forwarding
|
|
668
|
+
* so that provide/inject from the parent component tree works inside
|
|
669
|
+
* node view components.
|
|
670
|
+
*
|
|
671
|
+
* @example
|
|
672
|
+
* ```ts
|
|
673
|
+
* const ImageExtension = Image.extend({
|
|
674
|
+
* addNodeView() {
|
|
675
|
+
* return VueNodeViewRenderer(ImageComponent);
|
|
676
|
+
* }
|
|
677
|
+
* });
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
declare function VueNodeViewRenderer(component: Component, options?: VueNodeViewRendererOptions): (node: PMNode, _view: unknown, getPos: () => number | undefined, decorations: readonly unknown[]) => VueNodeView | {
|
|
681
|
+
dom: HTMLElement;
|
|
682
|
+
update: () => boolean;
|
|
683
|
+
destroy: () => void;
|
|
684
|
+
};
|
|
685
|
+
interface VueNodeViewInit {
|
|
686
|
+
editor: Editor;
|
|
687
|
+
node: PMNode;
|
|
688
|
+
getPos: () => number | undefined;
|
|
689
|
+
decorations: readonly unknown[];
|
|
690
|
+
extension: {
|
|
691
|
+
name: string;
|
|
692
|
+
options: Record<string, unknown>;
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
declare class VueNodeView {
|
|
696
|
+
dom: HTMLElement;
|
|
697
|
+
contentDOM: HTMLElement | null;
|
|
698
|
+
private props;
|
|
699
|
+
private editor;
|
|
700
|
+
private appContext;
|
|
701
|
+
constructor(component: Component, init: VueNodeViewInit, options: VueNodeViewRendererOptions, appContext: AppContext);
|
|
702
|
+
update(node: PMNode, decorations: readonly unknown[]): boolean;
|
|
703
|
+
selectNode(): void;
|
|
704
|
+
deselectNode(): void;
|
|
705
|
+
destroy(): void;
|
|
706
|
+
ignoreMutation(mutation: MutationRecord | {
|
|
707
|
+
type: 'selection';
|
|
708
|
+
target: Node;
|
|
709
|
+
}): boolean;
|
|
710
|
+
stopEvent(): boolean;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Container component for custom Vue node view UIs.
|
|
715
|
+
* Must wrap the root element of every VueNodeViewRenderer component.
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```vue
|
|
719
|
+
* <template>
|
|
720
|
+
* <NodeViewWrapper as="div">
|
|
721
|
+
* <img :src="node.attrs.src" />
|
|
722
|
+
* </NodeViewWrapper>
|
|
723
|
+
* </template>
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
declare const NodeViewWrapper: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
727
|
+
as: {
|
|
728
|
+
type: StringConstructor;
|
|
729
|
+
default: string;
|
|
730
|
+
};
|
|
731
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
732
|
+
[key: string]: any;
|
|
733
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
734
|
+
as: {
|
|
735
|
+
type: StringConstructor;
|
|
736
|
+
default: string;
|
|
737
|
+
};
|
|
738
|
+
}>> & Readonly<{}>, {
|
|
739
|
+
as: string;
|
|
740
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Placeholder for editable nested content within a node view.
|
|
744
|
+
* ProseMirror manages the content DOM - do not render children inside this component.
|
|
745
|
+
*
|
|
746
|
+
* @example
|
|
747
|
+
* ```vue
|
|
748
|
+
* <template>
|
|
749
|
+
* <NodeViewWrapper>
|
|
750
|
+
* <h3>Custom heading</h3>
|
|
751
|
+
* <NodeViewContent />
|
|
752
|
+
* </NodeViewWrapper>
|
|
753
|
+
* </template>
|
|
754
|
+
* ```
|
|
755
|
+
*/
|
|
756
|
+
declare const NodeViewContent: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
757
|
+
as: {
|
|
758
|
+
type: StringConstructor;
|
|
759
|
+
default: string;
|
|
760
|
+
};
|
|
761
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
762
|
+
[key: string]: any;
|
|
763
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
764
|
+
as: {
|
|
765
|
+
type: StringConstructor;
|
|
766
|
+
default: string;
|
|
767
|
+
};
|
|
768
|
+
}>> & Readonly<{}>, {
|
|
769
|
+
as: string;
|
|
770
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Convenience composable for accessing node view context.
|
|
774
|
+
* Use inside custom node view components built with VueNodeViewRenderer.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```ts
|
|
778
|
+
* const { onDragStart, nodeViewContentRef } = useVueNodeView();
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
declare function useVueNodeView(): {
|
|
782
|
+
onDragStart: ((event: DragEvent) => void) | undefined;
|
|
783
|
+
nodeViewContentRef: ((el: HTMLElement | null) => void) | undefined;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
export { DEFAULT_EXTENSIONS, Domternal, DomternalBubbleMenu, type DomternalBubbleMenuProps, DomternalEditor, type DomternalEditorProps, DomternalEmojiPicker, type DomternalEmojiPickerProps, DomternalFloatingMenu, type DomternalFloatingMenuProps, type DomternalProps, DomternalToolbar, type DomternalToolbarProps, EDITOR_KEY, EditorContent, type EditorState, type EmojiPickerItem, NodeViewContent, NodeViewWrapper, type UseEditorOptions, type VueNodeViewProps, VueNodeViewRenderer, type VueNodeViewRendererOptions, provideEditor, useCurrentEditor, useEditor, useEditorState, useVueNodeView };
|