@tiptap/vue-2 3.23.6 → 3.25.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/dist/index.cjs +30 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/dist/menus/index.cjs +54 -13
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.js +54 -13
- package/dist/menus/index.js.map +1 -1
- package/package.json +24 -25
- package/src/NodeViewContent.ts +16 -0
- package/src/VueNodeViewRenderer.ts +38 -3
- package/src/VueRenderer.ts +1 -1
package/package.json
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/vue-2",
|
|
3
|
+
"version": "3.25.0",
|
|
3
4
|
"description": "Vue components for tiptap",
|
|
4
|
-
"version": "3.23.6",
|
|
5
|
-
"homepage": "https://tiptap.dev",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"tiptap",
|
|
8
7
|
"tiptap vue components"
|
|
9
8
|
],
|
|
9
|
+
"homepage": "https://tiptap.dev",
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
14
|
+
"directory": "packages/vue-2"
|
|
15
|
+
},
|
|
11
16
|
"funding": {
|
|
12
17
|
"type": "github",
|
|
13
18
|
"url": "https://github.com/sponsors/ueberdosis"
|
|
14
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"main": "dist/index.cjs",
|
|
27
|
+
"module": "dist/index.js",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
15
29
|
"exports": {
|
|
16
30
|
".": {
|
|
17
31
|
"types": {
|
|
@@ -30,39 +44,24 @@
|
|
|
30
44
|
"require": "./dist/menus/index.cjs"
|
|
31
45
|
}
|
|
32
46
|
},
|
|
33
|
-
"main": "dist/index.cjs",
|
|
34
|
-
"module": "dist/index.js",
|
|
35
|
-
"types": "dist/index.d.ts",
|
|
36
|
-
"type": "module",
|
|
37
|
-
"files": [
|
|
38
|
-
"src",
|
|
39
|
-
"dist"
|
|
40
|
-
],
|
|
41
47
|
"dependencies": {
|
|
42
48
|
"vue-ts-types": "1.6.2"
|
|
43
49
|
},
|
|
44
50
|
"devDependencies": {
|
|
45
51
|
"vue": "^2.7.16",
|
|
46
|
-
"@tiptap/
|
|
47
|
-
"@tiptap/
|
|
48
|
-
},
|
|
49
|
-
"optionalDependencies": {
|
|
50
|
-
"@tiptap/extension-bubble-menu": "^3.23.6",
|
|
51
|
-
"@tiptap/extension-floating-menu": "^3.23.6"
|
|
52
|
+
"@tiptap/core": "^3.25.0",
|
|
53
|
+
"@tiptap/pm": "^3.25.0"
|
|
52
54
|
},
|
|
53
55
|
"peerDependencies": {
|
|
54
56
|
"vue": "^2.6.0",
|
|
55
|
-
"@tiptap/core": "3.
|
|
56
|
-
"@tiptap/pm": "3.
|
|
57
|
+
"@tiptap/core": "3.25.0",
|
|
58
|
+
"@tiptap/pm": "3.25.0"
|
|
57
59
|
},
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"directory": "packages/vue-2"
|
|
60
|
+
"optionalDependencies": {
|
|
61
|
+
"@tiptap/extension-bubble-menu": "^3.25.0",
|
|
62
|
+
"@tiptap/extension-floating-menu": "^3.25.0"
|
|
62
63
|
},
|
|
63
|
-
"sideEffects": false,
|
|
64
64
|
"scripts": {
|
|
65
|
-
"build": "tsup"
|
|
66
|
-
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
|
|
65
|
+
"build": "tsup"
|
|
67
66
|
}
|
|
68
67
|
}
|
package/src/NodeViewContent.ts
CHANGED
|
@@ -13,6 +13,22 @@ export const NodeViewContent: Component = {
|
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
|
|
16
|
+
inject: {
|
|
17
|
+
nodeViewContentRef: { default: undefined },
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
mounted(this: any) {
|
|
21
|
+
if (this.nodeViewContentRef && this.$el) {
|
|
22
|
+
this.nodeViewContentRef(this.$el)
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
beforeDestroy(this: any) {
|
|
27
|
+
if (this.nodeViewContentRef) {
|
|
28
|
+
this.nodeViewContentRef(null)
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
16
32
|
render(this: NodeViewContentInterface, createElement: CreateElement) {
|
|
17
33
|
return createElement(this.as, {
|
|
18
34
|
style: {
|
|
@@ -47,6 +47,15 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
47
47
|
value: string
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The element that holds the rich-text content of the node.
|
|
52
|
+
* Always created for non-leaf nodes to guarantee a valid contentDOM,
|
|
53
|
+
* even when the user's component does not include a NodeViewContent.
|
|
54
|
+
* Must NOT have an initializer because class field initializers run
|
|
55
|
+
* after super() and would overwrite the value set by mount().
|
|
56
|
+
*/
|
|
57
|
+
contentDOMElement!: HTMLElement | null
|
|
58
|
+
|
|
50
59
|
private currentPos: number | undefined
|
|
51
60
|
|
|
52
61
|
constructor(
|
|
@@ -70,6 +79,9 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
70
79
|
this.renderer.updateProps({ getPos: () => this.getPos() })
|
|
71
80
|
}
|
|
72
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Called when the node view is mounted.
|
|
84
|
+
*/
|
|
73
85
|
mount() {
|
|
74
86
|
const props: Record<string, any> = {
|
|
75
87
|
editor: this.editor,
|
|
@@ -94,7 +106,7 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
94
106
|
})
|
|
95
107
|
|
|
96
108
|
// @ts-ignore
|
|
97
|
-
const vue = this.editor.contentComponent?.$options._base ?? Vue //
|
|
109
|
+
const vue = this.editor.contentComponent?.$options._base ?? Vue // oxlint-disable-line
|
|
98
110
|
|
|
99
111
|
const Component = vue.extend(this.component).extend({
|
|
100
112
|
props: Object.keys(props),
|
|
@@ -102,6 +114,14 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
102
114
|
return {
|
|
103
115
|
onDragStart,
|
|
104
116
|
decorationClasses: this.decorationClasses,
|
|
117
|
+
nodeViewContentRef: (el: HTMLElement | null) => {
|
|
118
|
+
if (!this.contentDOMElement) return
|
|
119
|
+
|
|
120
|
+
if (el && el.firstChild !== this.contentDOMElement) {
|
|
121
|
+
// NodeViewContent mounted: move the contentDOMElement inside it
|
|
122
|
+
el.appendChild(this.contentDOMElement)
|
|
123
|
+
}
|
|
124
|
+
},
|
|
105
125
|
}
|
|
106
126
|
},
|
|
107
127
|
})
|
|
@@ -111,6 +131,15 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
111
131
|
|
|
112
132
|
this.currentPos = this.getPos()
|
|
113
133
|
|
|
134
|
+
if (!this.node.isLeaf) {
|
|
135
|
+
this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div')
|
|
136
|
+
this.contentDOMElement.style.whiteSpace = 'inherit'
|
|
137
|
+
// Use a distinct attribute to avoid clashing with the user's
|
|
138
|
+
// <node-view-content> element (which carries data-node-view-content).
|
|
139
|
+
// Matches React's data-node-view-content-react convention.
|
|
140
|
+
this.contentDOMElement.dataset.nodeViewContentVue = ''
|
|
141
|
+
}
|
|
142
|
+
|
|
114
143
|
this.renderer = new VueRenderer(Component, {
|
|
115
144
|
parent: this.editor.contentComponent,
|
|
116
145
|
propsData: mountProps,
|
|
@@ -138,7 +167,7 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
138
167
|
return null
|
|
139
168
|
}
|
|
140
169
|
|
|
141
|
-
return this.
|
|
170
|
+
return this.contentDOMElement
|
|
142
171
|
}
|
|
143
172
|
|
|
144
173
|
/**
|
|
@@ -178,7 +207,11 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
178
207
|
* On update, update the React component.
|
|
179
208
|
* To prevent unnecessary updates, the `update` option can be used.
|
|
180
209
|
*/
|
|
181
|
-
update(
|
|
210
|
+
update(
|
|
211
|
+
node: ProseMirrorNode,
|
|
212
|
+
decorations: readonly Decoration[],
|
|
213
|
+
innerDecorations: DecorationSource,
|
|
214
|
+
): boolean {
|
|
182
215
|
const rerenderComponent = (props?: Record<string, any>) => {
|
|
183
216
|
this.decorationClasses.value = this.getDecorationClasses()
|
|
184
217
|
this.renderer.updateProps(props)
|
|
@@ -282,6 +315,8 @@ class VueNodeView extends NodeView<Vue | VueConstructor, Editor, VueNodeViewRend
|
|
|
282
315
|
if (this.options.trackNodeViewPosition) {
|
|
283
316
|
this.editor.off('update', this.handlePositionUpdate)
|
|
284
317
|
}
|
|
318
|
+
|
|
319
|
+
this.contentDOMElement = null
|
|
285
320
|
}
|
|
286
321
|
}
|
|
287
322
|
|
package/src/VueRenderer.ts
CHANGED
|
@@ -25,7 +25,7 @@ export class VueRenderer {
|
|
|
25
25
|
|
|
26
26
|
// prevents `Avoid mutating a prop directly` error message
|
|
27
27
|
// Fix: `VueNodeViewRenderer` change vue Constructor `config.silent` not working
|
|
28
|
-
const currentVueConstructor = this.ref.$props.editor?.contentComponent?.$options._base ?? Vue //
|
|
28
|
+
const currentVueConstructor = this.ref.$props.editor?.contentComponent?.$options._base ?? Vue // oxlint-disable-line
|
|
29
29
|
const originalSilent = currentVueConstructor.config.silent
|
|
30
30
|
|
|
31
31
|
currentVueConstructor.config.silent = true
|