add typography extension

This commit is contained in:
Philipp Kühn 2020-11-01 00:28:46 +01:00
parent 4ce0eef6c0
commit 97831ea8e5
3 changed files with 56 additions and 1 deletions

View File

@ -68,6 +68,7 @@
<script> <script>
import { Editor, EditorContent, defaultExtensions } from '@tiptap/vue-starter-kit' import { Editor, EditorContent, defaultExtensions } from '@tiptap/vue-starter-kit'
import Typography from '@tiptap/extension-typography'
export default { export default {
components: { components: {
@ -82,7 +83,10 @@ export default {
mounted() { mounted() {
this.editor = new Editor({ this.editor = new Editor({
extensions: defaultExtensions(), extensions: [
...defaultExtensions(),
Typography(),
],
content: ` content: `
<h2> <h2>
Hi there, Hi there,

View File

@ -0,0 +1,30 @@
import { createExtension } from '@tiptap/core'
import {
emDash,
ellipsis,
openDoubleQuote,
closeDoubleQuote,
openSingleQuote,
closeSingleQuote,
} from 'prosemirror-inputrules'
const Typography = createExtension({
addInputRules() {
return [
emDash,
ellipsis,
openDoubleQuote,
closeDoubleQuote,
openSingleQuote,
closeSingleQuote,
]
},
})
export default Typography
declare module '@tiptap/core/src/Editor' {
interface AllExtensions {
Typography: typeof Typography,
}
}

View File

@ -0,0 +1,21 @@
{
"name": "@tiptap/extension-typography",
"version": "1.0.0",
"source": "index.ts",
"main": "dist/tiptap-extension-typography.js",
"umd:main": "dist/tiptap-extension-typography.umd.js",
"module": "dist/tiptap-extension-typography.mjs",
"unpkg": "dist/tiptap-extension-typography.js",
"jsdelivr": "dist/tiptap-extension-typography.js",
"files": [
"src",
"dist"
],
"peerDependencies": {
"@tiptap/core": "2.x"
},
"dependencies": {
"@types/prosemirror-inputrules": "^1.0.3",
"prosemirror-inputrules": "^1.1.3"
}
}