mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 11:49:02 +08:00
remove verbal expressions
This commit is contained in:
parent
fab2fce671
commit
ba744cf6d8
@ -27,8 +27,7 @@
|
||||
"prosemirror-state": "^1.3.3",
|
||||
"prosemirror-tables": "^1.1.1",
|
||||
"prosemirror-utils": "^0.9.6",
|
||||
"prosemirror-view": "^1.15.6",
|
||||
"verbal-expressions": "^1.0.2"
|
||||
"prosemirror-view": "^1.15.6"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "microbundle"
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { Mark, markInputRule, markPasteRule } from '@tiptap/core'
|
||||
import VerEx from 'verbal-expressions'
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface Editor {
|
||||
@ -7,6 +6,11 @@ declare module '@tiptap/core/src/Editor' {
|
||||
}
|
||||
}
|
||||
|
||||
export const starInputRegex = /(?:^|\s)((?:\*\*)((?:[^\*\*]+))(?:\*\*))$/gm
|
||||
export const starPasteRegex = /(?:^|\s)((?:\*\*)((?:[^\*\*]+))(?:\*\*))/gm
|
||||
export const underscoreInputRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/gm
|
||||
export const underscorePasteRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))/gm
|
||||
|
||||
export default new Mark()
|
||||
.name('bold')
|
||||
.schema(() => ({
|
||||
@ -34,35 +38,12 @@ export default new Mark()
|
||||
.keys(({ editor }) => ({
|
||||
'Mod-b': () => editor.bold()
|
||||
}))
|
||||
.inputRules(({ type }) => {
|
||||
return ['**', '__'].map(character => {
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
.endOfLine()
|
||||
|
||||
return markInputRule(regex, type)
|
||||
})
|
||||
})
|
||||
.pasteRules(({ type }) => {
|
||||
return ['**', '__'].map(character => {
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
|
||||
return markPasteRule(regex, type)
|
||||
})
|
||||
})
|
||||
.inputRules(({ type }) => [
|
||||
markInputRule(starInputRegex, type),
|
||||
markInputRule(underscoreInputRegex, type),
|
||||
])
|
||||
.pasteRules(({ type }) => [
|
||||
markPasteRule(starPasteRegex, type),
|
||||
markPasteRule(underscorePasteRegex, type),
|
||||
])
|
||||
.create()
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { Mark, markInputRule, markPasteRule } from '@tiptap/core'
|
||||
import VerEx from 'verbal-expressions'
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface Editor {
|
||||
@ -7,6 +6,9 @@ declare module '@tiptap/core/src/Editor' {
|
||||
}
|
||||
}
|
||||
|
||||
export const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/gm
|
||||
|
||||
export default new Mark()
|
||||
.name('code')
|
||||
.schema(() => ({
|
||||
@ -25,31 +27,10 @@ export default new Mark()
|
||||
.keys(({ editor }) => ({
|
||||
'Mod-`': () => editor.code()
|
||||
}))
|
||||
.inputRules(({ type }) => {
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find('`')
|
||||
.beginCapture()
|
||||
.somethingBut('`')
|
||||
.endCapture()
|
||||
.find('`')
|
||||
.endCapture()
|
||||
.endOfLine()
|
||||
|
||||
return [markInputRule(regex, type)]
|
||||
})
|
||||
.pasteRules(({ type }) => {
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find('`')
|
||||
.beginCapture()
|
||||
.somethingBut('`')
|
||||
.endCapture()
|
||||
.find('`')
|
||||
.endCapture()
|
||||
|
||||
return [markPasteRule(regex, type)]
|
||||
})
|
||||
.inputRules(({ type }) => [
|
||||
markInputRule(inputRegex, type)
|
||||
])
|
||||
.pasteRules(({ type }) => [
|
||||
markPasteRule(inputRegex, type)
|
||||
])
|
||||
.create()
|
||||
|
@ -1,6 +1,4 @@
|
||||
import { Node, CommandSpec } from '@tiptap/core'
|
||||
import { NodeSpec } from 'prosemirror-model'
|
||||
import VerEx from 'verbal-expressions'
|
||||
import { Node } from '@tiptap/core'
|
||||
import { textblockTypeInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
type Level = 1 | 2 | 3 | 4 | 5 | 6
|
||||
@ -45,14 +43,7 @@ export default new Node<HeadingOptions>()
|
||||
}))
|
||||
.inputRules(({ options, type }) => {
|
||||
return options.levels.map((level: Level) => {
|
||||
const regex = VerEx()
|
||||
.startOfLine()
|
||||
.find('#')
|
||||
.repeatPrevious(level)
|
||||
.whitespace()
|
||||
.endOfLine()
|
||||
|
||||
return textblockTypeInputRule(regex, type, { level })
|
||||
return textblockTypeInputRule(new RegExp(`^(?:#){${level}}\s$/gm`), type, { level })
|
||||
})
|
||||
})
|
||||
.create()
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { Mark, markInputRule, markPasteRule } from '@tiptap/core'
|
||||
import VerEx from 'verbal-expressions'
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface Editor {
|
||||
@ -7,6 +6,11 @@ declare module '@tiptap/core/src/Editor' {
|
||||
}
|
||||
}
|
||||
|
||||
export const starInputRegex = /(?:^|\s)((?:\*)((?:[^\*]+))(?:\*))$/gm
|
||||
export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^\*]+))(?:\*))/gm
|
||||
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm
|
||||
export const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm
|
||||
|
||||
export default new Mark()
|
||||
.name('italic')
|
||||
.schema(() => ({
|
||||
@ -26,35 +30,12 @@ export default new Mark()
|
||||
.keys(({ editor }) => ({
|
||||
'Mod-i': () => editor.italic()
|
||||
}))
|
||||
.inputRules(({ type }) => {
|
||||
return ['*', '_'].map(character => {
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
.endOfLine()
|
||||
|
||||
return markInputRule(regex, type)
|
||||
})
|
||||
})
|
||||
.pasteRules(({ type }) => {
|
||||
return ['*', '_'].map(character => {
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
|
||||
return markPasteRule(regex, type)
|
||||
})
|
||||
})
|
||||
.inputRules(({ type }) => [
|
||||
markInputRule(starInputRegex, type),
|
||||
markInputRule(underscoreInputRegex, type),
|
||||
])
|
||||
.pasteRules(({ type }) => [
|
||||
markPasteRule(starPasteRegex, type),
|
||||
markPasteRule(underscorePasteRegex, type),
|
||||
])
|
||||
.create()
|
||||
|
@ -13476,11 +13476,6 @@ vendors@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/vendors/-/vendors-1.0.4.tgz#e2b800a53e7a29b93506c3cf41100d16c4c4ad8e"
|
||||
integrity sha512-/juG65kTL4Cy2su4P8HjtkTxk6VmJDiOPBufWniqQ6wknac6jNiXS9vU+hO3wgusiyqWlzTbVHi0dyJqRONg3w==
|
||||
|
||||
verbal-expressions@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/verbal-expressions/-/verbal-expressions-1.0.2.tgz#1f2d28fdcf7169be270777ff5fadcdb2b3b905c5"
|
||||
integrity sha512-LV8eG4ckcg1iIhGjOF+j1jb0b58m1DgGywce+2U8kbRrB5wZnGe4XCyUyOujZR9D/+rJGXTmxnL30o3zAgmC4w==
|
||||
|
||||
verror@1.10.0:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
|
||||
|
Loading…
Reference in New Issue
Block a user