-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathindex.vue
More file actions
117 lines (102 loc) · 2.48 KB
/
index.vue
File metadata and controls
117 lines (102 loc) · 2.48 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<drag-handle v-if="editor" :editor="editor">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 9h16.5m-16.5 6.75h16.5" />
</svg>
</drag-handle>
<editor-content :editor="editor" />
</template>
<script>
import { DragHandle } from '@tiptap/extension-drag-handle-vue-3'
import StarterKit from '@tiptap/starter-kit'
import { Editor, EditorContent } from '@tiptap/vue-3'
import { Recommendation } from './extensions/recommendation/Recommendation.js'
export default {
components: {
EditorContent,
DragHandle,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [StarterKit, Recommendation],
content: `
<h1>
Drag to reorder — watch the position update instantly
</h1>
<p>
Drag any recommendation block below to a new position. The <code>pos:</code> value should update immediately.
</p>
<div class="node-recommendation" data-id="1"></div>
<div class="node-recommendation" data-id="2"></div>
<div class="node-recommendation" data-id="3"></div>
<div class="node-recommendation" data-id="4"></div>
<div class="node-recommendation" data-id="5"></div>
`,
})
},
beforeUnmount() {
this.editor?.destroy()
},
}
</script>
<style lang="scss">
.ProseMirror {
padding-inline: 4rem;
> * + * {
margin-top: 0.75em;
}
[data-id] {
border: 3px solid #0d0d0d;
border-radius: 0.5rem;
margin: 1rem 0;
position: relative;
margin-top: 1.5rem;
padding: 2rem 1rem 1rem;
&::before {
content: attr(data-id);
background-color: #0d0d0d;
font-size: 0.6rem;
letter-spacing: 1px;
font-weight: bold;
text-transform: uppercase;
color: #fff;
position: absolute;
top: 0;
padding: 0.25rem 0.75rem;
border-radius: 0 0 0.5rem 0.5rem;
}
}
}
.drag-handle {
align-items: center;
background: #f0f0f0;
border-radius: 0.25rem;
border: 1px solid rgba(0, 0, 0, 0.1);
cursor: grab;
display: flex;
height: 1.5rem;
justify-content: center;
width: 1.5rem;
svg {
width: 1.25rem;
height: 1.25rem;
}
}
.node-recommendation {
padding: 0.5rem;
border-radius: 0.5rem;
border: 0.15rem solid #000;
.title {
font-size: 0.875rem;
color: #777;
}
p {
margin: 0;
}
}
</style>