add extension demos

This commit is contained in:
Philipp Kühn
2021-08-25 18:03:42 +02:00
parent 6ab708b1a2
commit 88804668ff
44 changed files with 1695 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div id="app"></div>
<script type="module">
import setup from '../../../../setup/vue.ts'
import source from '@source'
setup('Extensions/CharacterCount', source)
</script>
</body>
</html>

View File

@@ -0,0 +1,66 @@
<template>
<div>
<editor-content :editor="editor" />
<div class="character-count" v-if="editor">
{{ editor.getCharacterCount() }}/{{ limit }} characters
</div>
</div>
</template>
<script>
import { Editor, EditorContent } from '@tiptap/vue-3'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import CharacterCount from '@tiptap/extension-character-count'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
limit: 280,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document,
Paragraph,
Text,
CharacterCount.configure({
limit: this.limit,
}),
],
content: `
<p>
Lets make sure people cant write more than 280 characters. I bet you could build one of the biggest social networks on that idea.
</p>
`,
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
.character-count {
margin-top: 1rem;
color: #868e96;
}
</style>