mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-05 18:14:01 +08:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { createExtension } from '@tiptap/core'
|
||
import {
|
||
emDash,
|
||
ellipsis,
|
||
openDoubleQuote,
|
||
closeDoubleQuote,
|
||
openSingleQuote,
|
||
closeSingleQuote,
|
||
InputRule,
|
||
} from 'prosemirror-inputrules'
|
||
|
||
export const leftArrow = new InputRule(/<-$/, '←')
|
||
export const rightArrow = new InputRule(/->$/, '→')
|
||
export const copyright = new InputRule(/\(c\)$/, '©')
|
||
export const registeredTrademark = new InputRule(/\(r\)$/, '®')
|
||
export const oneHalf = new InputRule(/1\/2$/, '½')
|
||
export const plusMinus = new InputRule(/\+\/-$/, '±')
|
||
export const notEqual = new InputRule(/!=$/, '≠')
|
||
export const laquo = new InputRule(/<<$/, '«')
|
||
export const raquo = new InputRule(/>>$/, '»')
|
||
export const multiplication = new InputRule(/\d+\s?([*x])\s?\d+$/, '×')
|
||
|
||
const Typography = createExtension({
|
||
addInputRules() {
|
||
return [
|
||
emDash,
|
||
ellipsis,
|
||
openDoubleQuote,
|
||
closeDoubleQuote,
|
||
openSingleQuote,
|
||
closeSingleQuote,
|
||
leftArrow,
|
||
rightArrow,
|
||
copyright,
|
||
registeredTrademark,
|
||
oneHalf,
|
||
plusMinus,
|
||
notEqual,
|
||
laquo,
|
||
raquo,
|
||
multiplication,
|
||
]
|
||
},
|
||
})
|
||
|
||
export default Typography
|
||
|
||
declare module '@tiptap/core/src/Editor' {
|
||
interface AllExtensions {
|
||
Typography: typeof Typography,
|
||
}
|
||
}
|