Merge pull request #1624 from arthurmcgregor/additional-input-rules-for-typography

Additional input rules for typography
This commit is contained in:
Hans Pagel
2021-07-22 09:07:15 +02:00
committed by GitHub
2 changed files with 13 additions and 1 deletions

View File

@@ -27,11 +27,15 @@ yarn add @tiptap/extension-typography
| copyright | Converts `(c)` to a copyright sign `©`. | | copyright | Converts `(c)` to a copyright sign `©`. |
| registeredTrademark | Converts `(r)` to registered trademark sign `®`. | | registeredTrademark | Converts `(r)` to registered trademark sign `®`. |
| oneHalf | Converts `1/2` to one half `½`. | | oneHalf | Converts `1/2` to one half `½`. |
| oneQuarter | Converts `1/4` to one quarter `¼`. |
| threeQuarters | Converts `3/4` to three quarters `¾`. |
| plusMinus | Converts `+/-` to plus/minus sign `±`. | | plusMinus | Converts `+/-` to plus/minus sign `±`. |
| notEqual | Converts <code style="font-variant-ligatures: none;">!=</code> to a not equal sign `≠`. | | notEqual | Converts <code style="font-variant-ligatures: none;">!=</code> to a not equal sign `≠`. |
| laquo | Converts `<<` to left-pointing double angle quotation mark `«`. | | laquo | Converts `<<` to left-pointing double angle quotation mark `«`. |
| raquo | Converts `>>` to right-pointing double angle quotation mark `»`. | | raquo | Converts `>>` to right-pointing double angle quotation mark `»`. |
| multiplication | Converts `2 * 3` or `2x3` to a multiplcation sign `2×3`. | | multiplication | Converts `2 * 3` or `2x3` to a multiplcation sign `2×3`. |
| superscriptTwo | Converts `^2` a superscript two `²`. |
| superscriptThree | Converts `^3` a superscript three `³`. |
## Keyboard shortcuts ## Keyboard shortcuts
* `Backspace` reverts the applied input rule * `Backspace` reverts the applied input rule

View File

@@ -19,6 +19,10 @@ export const notEqual = new InputRule(/!=$/, '≠')
export const laquo = new InputRule(/<<$/, '«') export const laquo = new InputRule(/<<$/, '«')
export const raquo = new InputRule(/>>$/, '»') export const raquo = new InputRule(/>>$/, '»')
export const multiplication = new InputRule(/\d+\s?([*x])\s?\d+$/, '×') export const multiplication = new InputRule(/\d+\s?([*x])\s?\d+$/, '×')
export const superscriptTwo = new InputRule(/\^2$/, '²')
export const superscriptThree = new InputRule(/\^3$/, '³')
export const oneQuarter = new InputRule(/1\/4$/, '¼')
export const threeQuarters = new InputRule(/3\/4$/, '¾')
export const Typography = Extension.create({ export const Typography = Extension.create({
name: 'typography', name: 'typography',
@@ -41,6 +45,10 @@ export const Typography = Extension.create({
laquo, laquo,
raquo, raquo,
multiplication, multiplication,
superscriptTwo,
superscriptThree,
oneQuarter,
threeQuarters,
] ]
}, },
}) })