@tiptap/vue-2 3.20.2 → 3.20.4
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/menus/index.cjs +55 -11
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.d.cts +9 -0
- package/dist/menus/index.d.ts +9 -0
- package/dist/menus/index.js +54 -10
- package/dist/menus/index.js.map +1 -1
- package/package.json +7 -7
- package/src/menus/BubbleMenu.ts +33 -4
- package/src/menus/FloatingMenu.ts +32 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/vue-2",
|
|
3
3
|
"description": "Vue components for tiptap",
|
|
4
|
-
"version": "3.20.
|
|
4
|
+
"version": "3.20.4",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"vue": "^2.7.16",
|
|
46
|
-
"@tiptap/core": "^3.20.
|
|
47
|
-
"@tiptap/pm": "^3.20.
|
|
46
|
+
"@tiptap/core": "^3.20.4",
|
|
47
|
+
"@tiptap/pm": "^3.20.4"
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"@tiptap/extension-bubble-menu": "^3.20.
|
|
51
|
-
"@tiptap/extension-floating-menu": "^3.20.
|
|
50
|
+
"@tiptap/extension-bubble-menu": "^3.20.4",
|
|
51
|
+
"@tiptap/extension-floating-menu": "^3.20.4"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"vue": "^2.6.0",
|
|
55
|
-
"@tiptap/core": "^3.20.
|
|
56
|
-
"@tiptap/pm": "^3.20.
|
|
55
|
+
"@tiptap/core": "^3.20.4",
|
|
56
|
+
"@tiptap/pm": "^3.20.4"
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
package/src/menus/BubbleMenu.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
|
|
2
2
|
import { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu'
|
|
3
|
+
import { PluginKey } from '@tiptap/pm/state'
|
|
3
4
|
import type { Component, CreateElement, PropType, VNode } from 'vue'
|
|
4
5
|
|
|
5
6
|
export interface BubbleMenuInterface {
|
|
6
7
|
$el: HTMLElement
|
|
8
|
+
$attrs: Record<string, any>
|
|
9
|
+
$listeners: Record<string, (...args: any[]) => unknown>
|
|
7
10
|
$nextTick: (callback: () => void) => void
|
|
8
11
|
$slots: { default?: VNode[] }
|
|
12
|
+
$vnode?: VNode
|
|
9
13
|
pluginKey: BubbleMenuPluginProps['pluginKey']
|
|
14
|
+
generatedPluginKey?: BubbleMenuPluginProps['pluginKey']
|
|
10
15
|
editor: BubbleMenuPluginProps['editor']
|
|
11
16
|
updateDelay: BubbleMenuPluginProps['updateDelay']
|
|
12
17
|
resizeDelay: BubbleMenuPluginProps['resizeDelay']
|
|
@@ -14,15 +19,18 @@ export interface BubbleMenuInterface {
|
|
|
14
19
|
shouldShow: BubbleMenuPluginProps['shouldShow']
|
|
15
20
|
getReferencedVirtualElement: BubbleMenuPluginProps['getReferencedVirtualElement']
|
|
16
21
|
options: BubbleMenuPluginProps['options']
|
|
22
|
+
getPluginKey: () => BubbleMenuPluginProps['pluginKey']
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
export const BubbleMenu: Component = {
|
|
20
26
|
name: 'BubbleMenu',
|
|
21
27
|
|
|
28
|
+
inheritAttrs: false,
|
|
29
|
+
|
|
22
30
|
props: {
|
|
23
31
|
pluginKey: {
|
|
24
32
|
type: [String, Object as PropType<Exclude<BubbleMenuPluginProps['pluginKey'], string>>],
|
|
25
|
-
default:
|
|
33
|
+
default: undefined,
|
|
26
34
|
},
|
|
27
35
|
|
|
28
36
|
editor: {
|
|
@@ -76,7 +84,7 @@ export const BubbleMenu: Component = {
|
|
|
76
84
|
options: this.options,
|
|
77
85
|
editor,
|
|
78
86
|
element: el,
|
|
79
|
-
pluginKey: this.
|
|
87
|
+
pluginKey: this.getPluginKey(),
|
|
80
88
|
appendTo: this.appendTo,
|
|
81
89
|
shouldShow: this.shouldShow,
|
|
82
90
|
getReferencedVirtualElement: this.getReferencedVirtualElement,
|
|
@@ -86,10 +94,31 @@ export const BubbleMenu: Component = {
|
|
|
86
94
|
},
|
|
87
95
|
|
|
88
96
|
render(this: BubbleMenuInterface, createElement: CreateElement) {
|
|
89
|
-
|
|
97
|
+
const vnodeData = (this.$vnode?.data ?? {}) as any
|
|
98
|
+
|
|
99
|
+
return createElement(
|
|
100
|
+
'div',
|
|
101
|
+
{
|
|
102
|
+
attrs: this.$attrs,
|
|
103
|
+
on: this.$listeners,
|
|
104
|
+
class: [vnodeData.staticClass, vnodeData.class],
|
|
105
|
+
style: [vnodeData.staticStyle, vnodeData.style],
|
|
106
|
+
},
|
|
107
|
+
this.$slots.default,
|
|
108
|
+
)
|
|
90
109
|
},
|
|
91
110
|
|
|
92
111
|
beforeDestroy(this: BubbleMenuInterface) {
|
|
93
|
-
this.editor.unregisterPlugin(this.
|
|
112
|
+
this.editor.unregisterPlugin(this.getPluginKey())
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
methods: {
|
|
116
|
+
getPluginKey(this: BubbleMenuInterface) {
|
|
117
|
+
if (!this.generatedPluginKey) {
|
|
118
|
+
this.generatedPluginKey = this.pluginKey ?? new PluginKey('bubbleMenu')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return this.generatedPluginKey
|
|
122
|
+
},
|
|
94
123
|
},
|
|
95
124
|
}
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import type { FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'
|
|
2
2
|
import { FloatingMenuPlugin } from '@tiptap/extension-floating-menu'
|
|
3
|
+
import { PluginKey } from '@tiptap/pm/state'
|
|
3
4
|
import type { Component, CreateElement, PropType } from 'vue'
|
|
4
5
|
import type Vue from 'vue'
|
|
5
6
|
|
|
6
7
|
export interface FloatingMenuInterface extends Vue {
|
|
8
|
+
$attrs: Record<string, any>
|
|
9
|
+
$listeners: Record<string, (...args: any[]) => unknown>
|
|
7
10
|
pluginKey: FloatingMenuPluginProps['pluginKey']
|
|
11
|
+
generatedPluginKey?: FloatingMenuPluginProps['pluginKey']
|
|
8
12
|
editor: FloatingMenuPluginProps['editor']
|
|
9
13
|
updateDelay: FloatingMenuPluginProps['updateDelay']
|
|
10
14
|
resizeDelay: FloatingMenuPluginProps['resizeDelay']
|
|
11
15
|
options: FloatingMenuPluginProps['options']
|
|
12
16
|
appendTo: FloatingMenuPluginProps['appendTo']
|
|
13
17
|
shouldShow: FloatingMenuPluginProps['shouldShow']
|
|
18
|
+
getPluginKey: () => FloatingMenuPluginProps['pluginKey']
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export const FloatingMenu: Component = {
|
|
17
22
|
name: 'FloatingMenu',
|
|
18
23
|
|
|
24
|
+
inheritAttrs: false,
|
|
25
|
+
|
|
19
26
|
props: {
|
|
20
27
|
pluginKey: {
|
|
21
28
|
type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
|
|
22
|
-
default:
|
|
29
|
+
default: undefined,
|
|
23
30
|
},
|
|
24
31
|
|
|
25
32
|
editor: {
|
|
@@ -71,7 +78,7 @@ export const FloatingMenu: Component = {
|
|
|
71
78
|
this.$nextTick(() => {
|
|
72
79
|
editor.registerPlugin(
|
|
73
80
|
FloatingMenuPlugin({
|
|
74
|
-
pluginKey: this.
|
|
81
|
+
pluginKey: this.getPluginKey(),
|
|
75
82
|
editor,
|
|
76
83
|
element: this.$el as HTMLElement,
|
|
77
84
|
updateDelay: this.updateDelay,
|
|
@@ -87,10 +94,31 @@ export const FloatingMenu: Component = {
|
|
|
87
94
|
},
|
|
88
95
|
|
|
89
96
|
render(this: FloatingMenuInterface, createElement: CreateElement) {
|
|
90
|
-
|
|
97
|
+
const vnodeData = (this.$vnode?.data ?? {}) as any
|
|
98
|
+
|
|
99
|
+
return createElement(
|
|
100
|
+
'div',
|
|
101
|
+
{
|
|
102
|
+
attrs: this.$attrs,
|
|
103
|
+
on: this.$listeners,
|
|
104
|
+
class: [vnodeData.staticClass, vnodeData.class],
|
|
105
|
+
style: [vnodeData.staticStyle, vnodeData.style],
|
|
106
|
+
},
|
|
107
|
+
this.$slots.default,
|
|
108
|
+
)
|
|
91
109
|
},
|
|
92
110
|
|
|
93
111
|
beforeDestroy(this: FloatingMenuInterface) {
|
|
94
|
-
this.editor.unregisterPlugin(this.
|
|
112
|
+
this.editor.unregisterPlugin(this.getPluginKey())
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
methods: {
|
|
116
|
+
getPluginKey(this: FloatingMenuInterface) {
|
|
117
|
+
if (!this.generatedPluginKey) {
|
|
118
|
+
this.generatedPluginKey = this.pluginKey ?? new PluginKey('floatingMenu')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return this.generatedPluginKey
|
|
122
|
+
},
|
|
95
123
|
},
|
|
96
124
|
}
|