fix build for now

This commit is contained in:
Philipp Kühn
2020-11-10 16:29:31 +01:00
parent 960368db0e
commit d3b4e7a1d4
77 changed files with 28 additions and 64 deletions

View File

@@ -0,0 +1,67 @@
import {
Command, createMark, markInputRule, markPasteRule,
} from '@tiptap/core'
export const starInputRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/gm
export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm
export const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm
const Italic = createMark({
name: 'italic',
parseHTML() {
return [
{
tag: 'em',
},
{
tag: 'i',
getAttrs: node => (node as HTMLElement).style.fontStyle !== 'normal' && null,
},
{
style: 'font-style=italic',
},
]
},
renderHTML({ attributes }) {
return ['em', attributes, 0]
},
addCommands() {
return {
italic: (): Command => ({ commands }) => {
return commands.toggleMark('italic')
},
}
},
addKeyboardShortcuts() {
return {
'Mod-i': () => this.editor.italic(),
}
},
addInputRules() {
return [
markInputRule(starInputRegex, this.type),
markInputRule(underscoreInputRegex, this.type),
]
},
addPasteRules() {
return [
markPasteRule(starPasteRegex, this.type),
markPasteRule(underscorePasteRegex, this.type),
]
},
})
export default Italic
declare module '@tiptap/core/src/Editor' {
interface AllExtensions {
Italic: typeof Italic,
}
}