fix: add clear mark parse rules to bold & italic marks (#5705)

This commit is contained in:
Markus Greystone 2024-10-19 23:23:33 -04:00 committed by GitHub
parent bfcf6d94e8
commit 6fae240f88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
"@tiptap/extension-italic": patch
"@tiptap/extension-bold": patch
---
Add parse rules that reset bold & italic marks

View File

@ -75,6 +75,10 @@ export const Bold = Mark.create<BoldOptions>({
tag: 'b', tag: 'b',
getAttrs: node => (node as HTMLElement).style.fontWeight !== 'normal' && null, getAttrs: node => (node as HTMLElement).style.fontWeight !== 'normal' && null,
}, },
{
style: 'font-weight=400',
clearMark: mark => mark.type.name === this.name,
},
{ {
style: 'font-weight', style: 'font-weight',
getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value as string) && null, getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value as string) && null,

View File

@ -78,6 +78,10 @@ export const Italic = Mark.create<ItalicOptions>({
tag: 'i', tag: 'i',
getAttrs: node => (node as HTMLElement).style.fontStyle !== 'normal' && null, getAttrs: node => (node as HTMLElement).style.fontStyle !== 'normal' && null,
}, },
{
style: 'font-style=normal',
clearMark: mark => mark.type.name === this.name,
},
{ {
style: 'font-style=italic', style: 'font-style=italic',
}, },