add bg color name

This commit is contained in:
Philipinho
2025-07-14 13:43:43 -07:00
parent bcca52fa70
commit 07d5833695
4 changed files with 51 additions and 19 deletions

View File

@ -16,6 +16,19 @@ export const TableCell = TiptapTableCell.extend({
}
return {
style: `background-color: ${attributes.backgroundColor}`,
'data-background-color': attributes.backgroundColor,
};
},
},
backgroundColorName: {
default: null,
parseHTML: (element) => element.getAttribute('data-color-name') || null,
renderHTML: (attributes) => {
if (!attributes.backgroundColorName) {
return {};
}
return {
'data-color-name': attributes.backgroundColorName.toLowerCase(),
};
},
},

View File

@ -16,6 +16,19 @@ export const TableHeader = TiptapTableHeader.extend({
}
return {
style: `background-color: ${attributes.backgroundColor}`,
'data-background-color': attributes.backgroundColor,
};
},
},
backgroundColorName: {
default: null,
parseHTML: (element) => element.getAttribute('data-color-name') || null,
renderHTML: (attributes) => {
if (!attributes.backgroundColorName) {
return {};
}
return {
'data-color-name': attributes.backgroundColorName.toLowerCase(),
};
},
},