mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-28 15:49:23 +08:00
add arrows to the typography extension
This commit is contained in:
parent
44865a2ea7
commit
7a7e517577
@ -44,4 +44,16 @@ context('/api/extensions/typography', () => {
|
||||
.type("'closeSingleQuote'")
|
||||
.should('contain', 'closeSingleQuote’')
|
||||
})
|
||||
|
||||
it('should make a leftwards arrow', () => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('<- leftwardsArrow')
|
||||
.should('contain', '← leftwardsArrow')
|
||||
})
|
||||
|
||||
it('should make a rightwards arrow', () => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('-> rightwardsArrow')
|
||||
.should('contain', '→ rightwardsArrow')
|
||||
})
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Typography
|
||||
This extension tries to help with common text patterns with the correct typographic character.
|
||||
This extension tries to help with common text patterns with the correct typographic character. Under the hood all rules are input rules.
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
@ -19,6 +19,8 @@ yarn add @tiptap/typography
|
||||
| closeDoubleQuote | “Smart`”` closing double quotes. |
|
||||
| openSingleQuote | `‘`Smart’ opening single quotes. |
|
||||
| closeSingleQuote | ‘Smart`’` closing single quotes. |
|
||||
| leftwardsArrow | Converts <code><‐</code> to an arrow `←`. |
|
||||
| leftwardsArrow | Converts <code>‐></code> to an arrow `→`. |
|
||||
|
||||
## Source code
|
||||
[packages/typography/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/typography/)
|
||||
|
@ -6,8 +6,12 @@ import {
|
||||
closeDoubleQuote,
|
||||
openSingleQuote,
|
||||
closeSingleQuote,
|
||||
InputRule,
|
||||
} from 'prosemirror-inputrules'
|
||||
|
||||
export const leftwardsArrow = new InputRule(/<-$/, '←')
|
||||
export const rightwardsArrow = new InputRule(/->$/, '→')
|
||||
|
||||
const Typography = createExtension({
|
||||
addInputRules() {
|
||||
return [
|
||||
@ -17,6 +21,8 @@ const Typography = createExtension({
|
||||
closeDoubleQuote,
|
||||
openSingleQuote,
|
||||
closeSingleQuote,
|
||||
leftwardsArrow,
|
||||
rightwardsArrow,
|
||||
]
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user