move docs to own folder

This commit is contained in:
Philipp Kühn
2020-04-17 12:51:49 +02:00
parent 4574b74864
commit 3c0727fd59
32 changed files with 360 additions and 1148 deletions

View File

@@ -0,0 +1,32 @@
<template>
<editor-content :editor="editor" />
</template>
<script>
import { Editor } from '@tiptap/core'
import { EditorContent } from '@tiptap/vue'
import extensions from '@tiptap/starter-kit'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
content: '<p>foo</p>',
extensions: extensions(),
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>

View File

@@ -0,0 +1,3 @@
.bla {
color: black;
}

View File

@@ -0,0 +1,67 @@
<template>
<div>
<div v-if="editor">
<button @click="editor.focus().removeMarks()">
clear formatting
</button>
<button @click="editor.focus().undo()">
undo
</button>
<button @click="editor.focus().redo()">
redo
</button>
<button @click="editor.focus().bold()" :class="{ 'is-active': editor.isActive('bold') }">
bold
</button>
<button @click="editor.focus().italic()" :class="{ 'is-active': editor.isActive('italic') }">
italic
</button>
</div>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor } from '@tiptap/core'
import { EditorContent } from '@tiptap/vue'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import History from '@tiptap/extension-history'
import Bold from '@tiptap/extension-bold'
import Italic from '@tiptap/extension-italic'
import Code from '@tiptap/extension-code'
import CodeBlock from '@tiptap/extension-codeblock'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
content: '<p>This editor is based on Prosemirror, fully extendable and renderless. You can easily add custom nodes as Vue components.</p>',
extensions: [
new Document(),
new Paragraph(),
new Text(),
new CodeBlock(),
new History(),
new Bold(),
new Italic(),
new Code(),
],
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>

View File

@@ -0,0 +1,40 @@
import React, { Component } from 'react'
import { Editor } from '@tiptap/core'
import extensions from '@tiptap/starter-kit'
export default class TestComponent extends Component {
constructor() {
super()
this.editorNode = React.createRef()
}
componentDidMount() {
this.editor = new Editor({
element: this.editorNode.current,
content: '<p>rendered in <strong>react</strong>!</p>',
extensions: extensions(),
})
this.forceUpdate()
}
render() {
return (
<div>
{this.editor &&
<div>
<button onClick={() => this.editor.focus().removeMarks()}>
clear formatting
</button>
<button
onClick={() => this.editor.focus().bold()}
className={`${this.editor.isActive('bold') ? 'is-active' : ''}`}
>
bold
</button>
</div>
}
<div ref={this.editorNode} />
</div>
)
}
}