mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-04 03:29:03 +08:00
Merge branch 'main' of github.com:ueberdosis/tiptap-next into main
This commit is contained in:
commit
e17f1b6b4b
@ -29,7 +29,7 @@ export default new Mark()
|
|||||||
],
|
],
|
||||||
toDOM: () => ['strong', 0],
|
toDOM: () => ['strong', 0],
|
||||||
}))
|
}))
|
||||||
.commands(({ editor, name, type }) => ({
|
.commands(({ editor, name }) => ({
|
||||||
bold: next => () => {
|
bold: next => () => {
|
||||||
editor.toggleMark(name)
|
editor.toggleMark(name)
|
||||||
next()
|
next()
|
||||||
|
47
packages/extension-strike/index.ts
Normal file
47
packages/extension-strike/index.ts
Normal 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()
|
17
packages/extension-strike/package.json
Normal file
17
packages/extension-strike/package.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user