fix(textStyle): Null-safe parseHTML getting no color/fontFamily from HTMLElement styles (#2825)

* fix(color): parseHTML getting no color get replace of undefined

* fix(fontFamily): Null-safe at parseHTML, replace of undefined
This commit is contained in:
Ruben Robles
2022-06-06 17:36:08 +02:00
committed by GitHub
parent 50083f3be1
commit 18bcc64aa7
2 changed files with 2 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ export const Color = Extension.create<ColorOptions>({
attributes: { attributes: {
color: { color: {
default: null, default: null,
parseHTML: element => element.style.color.replace(/['"]+/g, ''), parseHTML: element => element.style.color?.replace(/['"]+/g, ''),
renderHTML: attributes => { renderHTML: attributes => {
if (!attributes.color) { if (!attributes.color) {
return {} return {}

View File

@@ -36,7 +36,7 @@ export const FontFamily = Extension.create<FontFamilyOptions>({
attributes: { attributes: {
fontFamily: { fontFamily: {
default: null, default: null,
parseHTML: element => element.style.fontFamily.replace(/['"]+/g, ''), parseHTML: element => element.style.fontFamily?.replace(/['"]+/g, ''),
renderHTML: attributes => { renderHTML: attributes => {
if (!attributes.fontFamily) { if (!attributes.fontFamily) {
return {} return {}