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

This commit is contained in:
bdbch 2023-12-14 15:10:08 +01:00 committed by GitHub
parent e66160d774
commit f6d7e00a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -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')
})

View File

@ -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 ?? '½',
})
@ -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 ?? '¾',
})