mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 22:36:14 +08:00
revert some magic
This commit is contained in:
parent
e03d108423
commit
ca16a31e75
@ -39,7 +39,7 @@ export default abstract class Extension {
|
||||
return []
|
||||
}
|
||||
|
||||
keys(): string | { [key: string]: Function } {
|
||||
keys(): { [key: string]: Function } {
|
||||
return {}
|
||||
}
|
||||
|
||||
|
@ -79,17 +79,7 @@ export default class ExtensionManager {
|
||||
|
||||
get keymaps() {
|
||||
return collect(this.extensions)
|
||||
.map(extension => {
|
||||
const keys = extension.keys()
|
||||
|
||||
if (typeof keys === 'string') {
|
||||
return {
|
||||
[keys]: () => this.editor.command(extension.name)
|
||||
}
|
||||
}
|
||||
|
||||
return keys
|
||||
})
|
||||
.map(extension => extension.keys())
|
||||
.filter(keys => !!Object.keys(keys).length)
|
||||
.map(keys => keymap(keys))
|
||||
.toArray()
|
||||
|
@ -42,41 +42,41 @@ export default class Bold extends Mark {
|
||||
}
|
||||
|
||||
keys() {
|
||||
return 'Mod-b'
|
||||
return {
|
||||
'Mod-b': () => this.editor.bold()
|
||||
}
|
||||
}
|
||||
|
||||
inputRules() {
|
||||
return ['**', '__'].map(character => {
|
||||
return markInputRule(
|
||||
VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
.endOfLine(),
|
||||
this.type,
|
||||
)
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
.endOfLine()
|
||||
|
||||
return markInputRule(regex, this.type)
|
||||
})
|
||||
}
|
||||
|
||||
pasteRules() {
|
||||
return ['**', '__'].map(character => {
|
||||
return markPasteRule(
|
||||
VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture(),
|
||||
this.type,
|
||||
)
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
|
||||
return markPasteRule(regex, this.type)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -33,38 +33,38 @@ export default class Code extends Mark {
|
||||
}
|
||||
|
||||
keys() {
|
||||
return 'Mod-`'
|
||||
return {
|
||||
'Mod-`': () => this.editor.code()
|
||||
}
|
||||
}
|
||||
|
||||
inputRules() {
|
||||
return markInputRule(
|
||||
VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find('`')
|
||||
.beginCapture()
|
||||
.somethingBut('`')
|
||||
.endCapture()
|
||||
.find('`')
|
||||
.endCapture()
|
||||
.endOfLine(),
|
||||
this.type,
|
||||
)
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find('`')
|
||||
.beginCapture()
|
||||
.somethingBut('`')
|
||||
.endCapture()
|
||||
.find('`')
|
||||
.endCapture()
|
||||
.endOfLine()
|
||||
|
||||
return markInputRule(regex, this.type)
|
||||
}
|
||||
|
||||
pasteRules() {
|
||||
return markPasteRule(
|
||||
VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find('`')
|
||||
.beginCapture()
|
||||
.somethingBut('`')
|
||||
.endCapture()
|
||||
.find('`')
|
||||
.endCapture(),
|
||||
this.type,
|
||||
)
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find('`')
|
||||
.beginCapture()
|
||||
.somethingBut('`')
|
||||
.endCapture()
|
||||
.find('`')
|
||||
.endCapture()
|
||||
|
||||
return markPasteRule(regex, this.type)
|
||||
}
|
||||
|
||||
}
|
@ -34,41 +34,41 @@ export default class Italic extends Mark {
|
||||
}
|
||||
|
||||
keys() {
|
||||
return 'Mod-i'
|
||||
return {
|
||||
'Mod-i': () => this.editor.italic()
|
||||
}
|
||||
}
|
||||
|
||||
inputRules() {
|
||||
return ['*', '_'].map(character => {
|
||||
return markInputRule(
|
||||
VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
.endOfLine(),
|
||||
this.type,
|
||||
)
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
.endOfLine()
|
||||
|
||||
return markInputRule(regex, this.type)
|
||||
})
|
||||
}
|
||||
|
||||
pasteRules() {
|
||||
return ['*', '_'].map(character => {
|
||||
return markPasteRule(
|
||||
VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture(),
|
||||
this.type,
|
||||
)
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
|
||||
return markPasteRule(regex, this.type)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user