-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathRecommendation.js
More file actions
50 lines (40 loc) · 960 Bytes
/
Recommendation.js
File metadata and controls
50 lines (40 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { mergeAttributes, Node } from '@tiptap/core'
import { VueNodeViewRenderer } from '@tiptap/vue-3'
import RecommendationView from './views/RecommendationView.vue'
export const Recommendation = Node.create({
name: 'recommendation',
group: 'block',
draggable: true,
addOptions() {
return {
HTMLAttributes: {
class: `node-${this.name}`,
},
}
},
addAttributes() {
return {
id: {
default: undefined,
parseHTML: element => element.getAttribute('data-id'),
renderHTML: attributes => ({
'data-id': attributes.id,
}),
},
}
},
parseHTML() {
return [
{
tag: `div.node-${this.name}`,
},
]
},
renderHTML({ HTMLAttributes }) {
return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]
},
addNodeView() {
return VueNodeViewRenderer(RecommendationView)
},
})
export default Recommendation