UNPKG

@edifice.io/tiptap-extensions

Version:
1 lines 1.31 kB
{"version":3,"file":"table-cell.cjs","sources":["../../src/table-cell/table-cell.ts"],"sourcesContent":["import { TableCell as TipTapTableCell } from '@tiptap/extension-table-cell';\n\n/**\n * This custom extension allows setting a background-color to table cells.\n * Apply with ̀`editor.chain().focus().setCellAttribute(\"backgroundColor\", color).run()`\n */\nexport const TableCell = TipTapTableCell.extend({\n addAttributes() {\n return {\n ...this.parent?.(),\n backgroundColor: {\n default: null,\n renderHTML: (attributes: { backgroundColor?: string }) => {\n if (!attributes.backgroundColor) {\n return {};\n }\n\n return {\n style: `background-color: ${attributes.backgroundColor}`,\n };\n },\n parseHTML: (element: { style?: { backgroundColor: string } }) => {\n return element.style?.backgroundColor?.replace(/['\"]+/g, '');\n },\n },\n };\n },\n});\n"],"names":["TipTapTableCell","_a"],"mappings":"iJAMa,UAAYA,mBAAAA,UAAgB,OAAO,CAC9C,eAAgB,QACd,MAAO,CACL,IAAG,QAAK,SAAL,0BACH,gBAAiB,CACf,QAAS,KACT,WAAa,YACN,WAAW,gBAIT,CACL,MAAO,qBAAqB,WAAW,eAAe,EAAA,EAJ/C,CAAA,EAOX,UAAY,SAAqD,YAC/D,OAAO,IAAAC,IAAA,QAAQ,QAAR,YAAAA,IAAe,kBAAf,eAAgC,QAAQ,SAAU,GAC3D,CAAA,CACF,CAEJ,CACF,CAAC"}