Merge branch 'main' into feature/blockquote-extension
This commit is contained in:
@@ -29,7 +29,7 @@ export default new Mark()
|
||||
],
|
||||
toDOM: () => ['strong', 0],
|
||||
}))
|
||||
.commands(({ editor, name, type }) => ({
|
||||
.commands(({ editor, name }) => ({
|
||||
bold: next => () => {
|
||||
editor.toggleMark(name)
|
||||
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"
|
||||
}
|
||||
}
|
||||
32
packages/extension-underline/index.ts
Normal file
32
packages/extension-underline/index.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Mark } from '@tiptap/core'
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface Editor {
|
||||
underline(): Editor,
|
||||
}
|
||||
}
|
||||
|
||||
export default new Mark()
|
||||
.name('underline')
|
||||
.schema(() => ({
|
||||
parseDOM: [
|
||||
{
|
||||
tag: 'u',
|
||||
},
|
||||
{
|
||||
style: 'text-decoration',
|
||||
getAttrs: node => node === 'underline' ? {} : false,
|
||||
},
|
||||
],
|
||||
toDOM: () => ['u', 0],
|
||||
}))
|
||||
.commands(({ editor, name }) => ({
|
||||
underline: next => () => {
|
||||
editor.toggleMark(name)
|
||||
next()
|
||||
},
|
||||
}))
|
||||
.keys(({ editor }) => ({
|
||||
'Mod-u': () => editor.underline()
|
||||
}))
|
||||
.create()
|
||||
17
packages/extension-underline/package.json
Normal file
17
packages/extension-underline/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@tiptap/extension-underline",
|
||||
"version": "1.0.0",
|
||||
"source": "index.ts",
|
||||
"main": "dist/tiptap-extension-underline.js",
|
||||
"umd:main": "dist/tiptap-extension-underline.umd.js",
|
||||
"module": "dist/tiptap-extension-underline.mjs",
|
||||
"unpkg": "dist/tiptap-extension-underline.js",
|
||||
"jsdelivr": "dist/tiptap-extension-underline.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "2.x"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user