Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typography): require spaces after divisions to not break dates #4696

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions demos/src/Extensions/Typography/React/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ context('/src/Extensions/Typography/React/', () => {
})
})

it('should keep dates as they are', () => {
cy.get('.tiptap').type('1/4/2024').should('contain', '1/4/2024')
})

it('should make a fraction only with spaces afterwards', () => {
cy.get('.tiptap').type('1/4').should('contain', '1/4')
cy.get('.tiptap').type('{selectall}{backspace}1/4 ').should('contain', '¼')
})

it('should make an em dash from two dashes', () => {
cy.get('.tiptap').type('-- emDash').should('contain', '— emDash')
})
Expand Down
6 changes: 3 additions & 3 deletions packages/extension-typography/src/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const registeredTrademark = (override?: string) => textInputRule({
})

export const oneHalf = (override?: string) => textInputRule({
find: /(?:^|\s)(1\/2)$/,
find: /(?:^|\s)(1\/2)\s$/,
replace: override ?? '½',
})

Expand Down Expand Up @@ -126,12 +126,12 @@ export const superscriptThree = (override?: string) => textInputRule({
})

export const oneQuarter = (override?: string) => textInputRule({
find: /(?:^|\s)(1\/4)$/,
find: /(?:^|\s)(1\/4)\s$/,
replace: override ?? '¼',
})

export const threeQuarters = (override?: string) => textInputRule({
find: /(?:^|\s)(3\/4)$/,
find: /(?:^|\s)(3\/4)\s$/,
replace: override ?? '¾',
})

Expand Down
Loading