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:
@@ -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 {}
|
||||||
|
|||||||
@@ -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 {}
|
||||||
|
|||||||
Reference in New Issue
Block a user