@tiptap/vue-3 3.0.0-next.8 → 3.0.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/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/menus/index.cjs +127 -22
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.d.cts +21 -5
- package/dist/menus/index.d.ts +21 -5
- package/dist/menus/index.js +124 -19
- package/dist/menus/index.js.map +1 -1
- package/package.json +9 -9
- package/src/VueMarkViewRenderer.ts +19 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { MarkViewProps, MarkViewRenderer, MarkViewRendererOptions } from '@tiptap/core'
|
|
3
3
|
import { MarkView } from '@tiptap/core'
|
|
4
4
|
import type { Component, PropType } from 'vue'
|
|
5
|
-
import { defineComponent, h } from 'vue'
|
|
5
|
+
import { defineComponent, h, toRaw } from 'vue'
|
|
6
6
|
|
|
7
7
|
import type { Editor } from './Editor.js'
|
|
8
8
|
import { VueRenderer } from './VueRenderer.js'
|
|
@@ -34,6 +34,14 @@ export const markViewProps = {
|
|
|
34
34
|
type: Object as PropType<MarkViewProps['view']>,
|
|
35
35
|
required: true as const,
|
|
36
36
|
},
|
|
37
|
+
updateAttributes: {
|
|
38
|
+
type: Function as PropType<MarkViewProps['updateAttributes']>,
|
|
39
|
+
required: true as const,
|
|
40
|
+
},
|
|
41
|
+
HTMLAttributes: {
|
|
42
|
+
type: Object as PropType<MarkViewProps['HTMLAttributes']>,
|
|
43
|
+
required: true as const,
|
|
44
|
+
},
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
export const MarkViewContent = defineComponent({
|
|
@@ -62,10 +70,12 @@ export class VueMarkView extends MarkView<Component, VueMarkViewRendererOptions>
|
|
|
62
70
|
constructor(component: Component, props: MarkViewProps, options?: Partial<VueMarkViewRendererOptions>) {
|
|
63
71
|
super(component, props, options)
|
|
64
72
|
|
|
73
|
+
const componentProps = { ...props, updateAttributes: this.updateAttributes.bind(this) } satisfies MarkViewProps
|
|
74
|
+
|
|
65
75
|
// Create extended component with provide
|
|
66
76
|
const extendedComponent = defineComponent({
|
|
67
77
|
extends: { ...component },
|
|
68
|
-
props: Object.keys(
|
|
78
|
+
props: Object.keys(componentProps),
|
|
69
79
|
template: (this.component as any).template,
|
|
70
80
|
setup: reactiveProps => {
|
|
71
81
|
return (component as any).setup?.(reactiveProps, {
|
|
@@ -80,7 +90,7 @@ export class VueMarkView extends MarkView<Component, VueMarkViewRendererOptions>
|
|
|
80
90
|
})
|
|
81
91
|
this.renderer = new VueRenderer(extendedComponent, {
|
|
82
92
|
editor: this.editor,
|
|
83
|
-
props,
|
|
93
|
+
props: componentProps,
|
|
84
94
|
})
|
|
85
95
|
}
|
|
86
96
|
|
|
@@ -92,6 +102,12 @@ export class VueMarkView extends MarkView<Component, VueMarkViewRendererOptions>
|
|
|
92
102
|
return this.dom.querySelector('[data-mark-view-content]') as HTMLElement | null
|
|
93
103
|
}
|
|
94
104
|
|
|
105
|
+
updateAttributes(attrs: Record<string, any>): void {
|
|
106
|
+
// since this.mark is now an proxy, we need to get the actual mark from it
|
|
107
|
+
const unproxiedMark = toRaw(this.mark)
|
|
108
|
+
super.updateAttributes(attrs, unproxiedMark)
|
|
109
|
+
}
|
|
110
|
+
|
|
95
111
|
destroy() {
|
|
96
112
|
this.renderer.destroy()
|
|
97
113
|
}
|