From bd3829949895c1065ec51e68102fded3bedc9293 Mon Sep 17 00:00:00 2001 From: Arthur McGregor Date: Thu, 22 Jul 2021 10:36:08 +1200 Subject: [PATCH 1/2] Add additional input rules to typography extension superscriptTwo superscriptThree oneQuarter threeQuarters --- packages/extension-typography/src/typography.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/extension-typography/src/typography.ts b/packages/extension-typography/src/typography.ts index f0caf7df..aac79e58 100644 --- a/packages/extension-typography/src/typography.ts +++ b/packages/extension-typography/src/typography.ts @@ -19,6 +19,10 @@ 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+$/, '×') +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({ name: 'typography', @@ -41,6 +45,10 @@ export const Typography = Extension.create({ laquo, raquo, multiplication, + superscriptTwo, + superscriptThree, + oneQuarter, + threeQuarters, ] }, }) From 2d1e91a95bdeff0df3d82dd98fa3a1c385ae78f1 Mon Sep 17 00:00:00 2001 From: Arthur McGregor Date: Thu, 22 Jul 2021 10:39:48 +1200 Subject: [PATCH 2/2] Update docs with additional typography rules --- docs/src/docPages/api/extensions/typography.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/src/docPages/api/extensions/typography.md b/docs/src/docPages/api/extensions/typography.md index 7e93ad28..5fa5a917 100644 --- a/docs/src/docPages/api/extensions/typography.md +++ b/docs/src/docPages/api/extensions/typography.md @@ -27,11 +27,15 @@ yarn add @tiptap/extension-typography | copyright | Converts `(c)` to a copyright sign `©`. | | registeredTrademark | Converts `(r)` to registered trademark sign `®`. | | 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 `±`. | | notEqual | Converts != to a not equal sign `≠`. | | laquo | Converts `<<` to left-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 * `Backspace` reverts the applied input rule