Merge branch 'main' of github.com:ueberdosis/tiptap-next into main

This commit is contained in:
Hans Pagel 2020-09-10 11:22:45 +02:00
commit e17f1b6b4b
3 changed files with 65 additions and 1 deletions

View File

@ -29,7 +29,7 @@ export default new Mark()
],
toDOM: () => ['strong', 0],
}))
.commands(({ editor, name, type }) => ({
.commands(({ editor, name }) => ({
bold: next => () => {
editor.toggleMark(name)
next()

View File

@ -0,0 +1,47 @@
import { Mark, markInputRule, markPasteRule } from '@tiptap/core'
declare module '@tiptap/core/src/Editor' {
interface Editor {
strike(): Editor,
}
}
export const inputRegex = /(?:^|\s)((?:~)((?:[^~]+))(?:~))$/gm
export const pasteRegex = /(?:^|\s)((?:~)((?:[^~]+))(?:~))/gm
export default new Mark()
.name('strike')
.schema(() => ({
parseDOM: [
{
tag: 's',
},
{
tag: 'del',
},
{
tag: 'strike',
},
{
style: 'text-decoration',
getAttrs: node => node === 'line-through' ? {} : false,
},
],
toDOM: () => ['s', 0],
}))
.commands(({ editor, name }) => ({
strike: next => () => {
editor.toggleMark(name)
next()
},
}))
.keys(({ editor }) => ({
'Mod-d': () => editor.strike()
}))
.inputRules(({ type }) => [
markInputRule(inputRegex, type)
])
.pasteRules(({ type }) => [
markPasteRule(inputRegex, type)
])
.create()

View File

@ -0,0 +1,17 @@
{
"name": "@tiptap/extension-strike",
"version": "1.0.0",
"source": "index.ts",
"main": "dist/tiptap-extension-strike.js",
"umd:main": "dist/tiptap-extension-strike.umd.js",
"module": "dist/tiptap-extension-strike.mjs",
"unpkg": "dist/tiptap-extension-strike.js",
"jsdelivr": "dist/tiptap-extension-strike.js",
"files": [
"src",
"dist"
],
"peerDependencies": {
"@tiptap/core": "2.x"
}
}