add starter kit
This commit is contained in:
8
content/posts/extensions.md
Normal file
8
content/posts/extensions.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: Handle Extensions
|
||||
slug: handle-extensions
|
||||
---
|
||||
|
||||
Use a custom list of extensions.
|
||||
|
||||
<demo name="HandleExtensions" />
|
||||
13
packages/tiptap-starter-kit/index.ts
Normal file
13
packages/tiptap-starter-kit/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import Document from '@tiptap/document-extension'
|
||||
import History from '@tiptap/history-extension'
|
||||
import Paragraph from '@tiptap/paragraph-extension'
|
||||
import Text from '@tiptap/text-extension'
|
||||
|
||||
export default function extensions() {
|
||||
return [
|
||||
new Document(),
|
||||
new History(),
|
||||
new Paragraph(),
|
||||
new Text(),
|
||||
]
|
||||
}
|
||||
20
packages/tiptap-starter-kit/package.json
Normal file
20
packages/tiptap-starter-kit/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@tiptap/starter-kit",
|
||||
"version": "1.0.0",
|
||||
"source": "index.ts",
|
||||
"main": "dist/tiptap-starter-kit.js",
|
||||
"umd:main": "dist/tiptap-starter-kit.umd.js",
|
||||
"module": "dist/tiptap-starter-kit.mjs",
|
||||
"unpkg": "dist/tiptap-starter-kit.js",
|
||||
"jsdelivr": "dist/tiptap-starter-kit.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@tiptap/document-extension": "1.x",
|
||||
"@tiptap/history-extension": "1.x",
|
||||
"@tiptap/paragraph-extension": "1.x",
|
||||
"@tiptap/text-extension": "1.x"
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,10 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="editor">
|
||||
<button @click="editor.undo().focus()">
|
||||
undo
|
||||
</button>
|
||||
<button @click="editor.redo().focus()">
|
||||
redo
|
||||
</button>
|
||||
</div>
|
||||
<div ref="editor"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Editor from '@tiptap/core'
|
||||
import Document from '@tiptap/document-extension'
|
||||
import Paragraph from '@tiptap/paragraph-extension'
|
||||
import Text from '@tiptap/text-extension'
|
||||
import History from '@tiptap/history-extension'
|
||||
import extensions from '@tiptap/starter-kit'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -30,12 +17,7 @@ export default {
|
||||
this.editor = new Editor({
|
||||
element: this.$refs.editor,
|
||||
content: '<p>foo</p>',
|
||||
extensions: [
|
||||
new Document(),
|
||||
new Paragraph(),
|
||||
new Text(),
|
||||
new History(),
|
||||
],
|
||||
extensions: extensions(),
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
46
src/demos/HandleExtensions/index.vue
Normal file
46
src/demos/HandleExtensions/index.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="editor">
|
||||
<button @click="editor.undo().focus()">
|
||||
undo
|
||||
</button>
|
||||
<button @click="editor.redo().focus()">
|
||||
redo
|
||||
</button>
|
||||
</div>
|
||||
<div ref="editor"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Editor from '@tiptap/core'
|
||||
import Document from '@tiptap/document-extension'
|
||||
import Paragraph from '@tiptap/paragraph-extension'
|
||||
import Text from '@tiptap/text-extension'
|
||||
import History from '@tiptap/history-extension'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
editor: null,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.editor = new Editor({
|
||||
element: this.$refs.editor,
|
||||
content: '<p>foo</p>',
|
||||
extensions: [
|
||||
new Document(),
|
||||
new Paragraph(),
|
||||
new Text(),
|
||||
new History(),
|
||||
],
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user