-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
56 lines (52 loc) · 1.62 KB
/
app.vue
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
<template>
<div class="editor-container max-w-3xl mx-auto my-8 flex flex-col">
<ExportButtons :editor="editor" class="mt-4 self-end" />
<Toolbar :editor="editor" />
<editor-content :editor="editor" class="prose max-w-none" />
</div>
</template>
<script setup lang="ts">
import { Color } from "@tiptap/extension-color";
import TextStyle from "@tiptap/extension-text-style";
import StarterKit from "@tiptap/starter-kit";
import { useEditor, EditorContent, VueNodeViewRenderer } from "@tiptap/vue-3";
import { common, createLowlight } from "lowlight";
import Placeholder from "@tiptap/extension-placeholder";
import Commands from "~/extensions/Commands";
import suggestion from "~/extensions/Suggestion";
import ImageUpload from "~/extensions/ImageUpload";
import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
import CodeBlock from "./components/CodeBlock.vue";
import Image from "@tiptap/extension-image";
import ExportButtons from "~/components/ExportButtons.vue";
import { initialContent } from "~/data/initialContent";
const lowlight = createLowlight(common);
const editor = useEditor({
content: initialContent,
extensions: [
StarterKit.configure({
heading: {
levels: [1, 2, 3],
},
}),
Color,
Image,
TextStyle,
ImageUpload,
CodeBlockLowlight.extend({
addNodeView() {
return VueNodeViewRenderer(CodeBlock);
},
}).configure({ lowlight }),
Commands.configure({
suggestion,
}),
Placeholder.configure({
placeholder: "Type '/' for commands",
}),
],
});
onBeforeUnmount(() => {
editor.value?.destroy();
});
</script>