tiptap/packages/extension-typography/index.ts

37 lines
713 B
TypeScript
Raw Normal View History

2020-11-01 07:28:46 +08:00
import { createExtension } from '@tiptap/core'
import {
emDash,
ellipsis,
openDoubleQuote,
closeDoubleQuote,
openSingleQuote,
closeSingleQuote,
2020-11-06 05:50:07 +08:00
InputRule,
2020-11-01 07:28:46 +08:00
} from 'prosemirror-inputrules'
2020-11-06 05:50:07 +08:00
export const leftwardsArrow = new InputRule(/<-$/, '←')
export const rightwardsArrow = new InputRule(/->$/, '→')
2020-11-01 07:28:46 +08:00
const Typography = createExtension({
addInputRules() {
return [
emDash,
ellipsis,
openDoubleQuote,
closeDoubleQuote,
openSingleQuote,
closeSingleQuote,
2020-11-06 05:50:07 +08:00
leftwardsArrow,
rightwardsArrow,
2020-11-01 07:28:46 +08:00
]
},
})
export default Typography
declare module '@tiptap/core/src/Editor' {
interface AllExtensions {
Typography: typeof Typography,
}
}