mirror of
https://github.com/docmost/docmost.git
synced 2025-11-10 07:02:06 +10:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { TableHeader as TiptapTableHeader } from "@tiptap/extension-table-header";
|
|
|
|
export const TableHeader = TiptapTableHeader.extend({
|
|
name: "tableHeader",
|
|
content: "paragraph+",
|
|
|
|
addAttributes() {
|
|
return {
|
|
...this.parent?.(),
|
|
backgroundColor: {
|
|
default: null,
|
|
parseHTML: (element) => element.style.backgroundColor || null,
|
|
renderHTML: (attributes) => {
|
|
if (!attributes.backgroundColor) {
|
|
return {};
|
|
}
|
|
return {
|
|
style: `background-color: ${attributes.backgroundColor}`,
|
|
'data-background-color': attributes.backgroundColor,
|
|
};
|
|
},
|
|
},
|
|
backgroundColorName: {
|
|
default: null,
|
|
parseHTML: (element) => element.getAttribute('data-background-color-name') || null,
|
|
renderHTML: (attributes) => {
|
|
if (!attributes.backgroundColorName) {
|
|
return {};
|
|
}
|
|
return {
|
|
'data-background-color-name': attributes.backgroundColorName.toLowerCase(),
|
|
};
|
|
},
|
|
},
|
|
};
|
|
},
|
|
}); |