fix build for now
This commit is contained in:
56
packages/extension-code/src/index.ts
Normal file
56
packages/extension-code/src/index.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import {
|
||||
Command, createMark, markInputRule, markPasteRule,
|
||||
} from '@tiptap/core'
|
||||
|
||||
export const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/gm
|
||||
|
||||
const Code = createMark({
|
||||
name: 'code',
|
||||
|
||||
excludes: '_',
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{ tag: 'code' },
|
||||
]
|
||||
},
|
||||
|
||||
renderHTML({ attributes }) {
|
||||
return ['code', attributes, 0]
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
code: (): Command => ({ commands }) => {
|
||||
return commands.toggleMark('code')
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
addKeyboardShortcuts() {
|
||||
return {
|
||||
'Mod-`': () => this.editor.code(),
|
||||
}
|
||||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
markInputRule(inputRegex, this.type),
|
||||
]
|
||||
},
|
||||
|
||||
addPasteRules() {
|
||||
return [
|
||||
markPasteRule(inputRegex, this.type),
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Code
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Code: typeof Code,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user