2021-01-21 06:53:53 +08:00
|
|
|
import { Node, mergeAttributes } from '@tiptap/core'
|
2021-01-21 06:42:01 +08:00
|
|
|
|
2021-01-21 06:53:53 +08:00
|
|
|
export interface TableCellOptions {
|
|
|
|
HTMLAttributes: {
|
|
|
|
[key: string]: any
|
|
|
|
},
|
|
|
|
}
|
2021-01-21 06:42:01 +08:00
|
|
|
export const TableCell = Node.create({
|
|
|
|
name: 'tableCell',
|
2021-01-21 06:53:53 +08:00
|
|
|
|
|
|
|
defaultOptions: <TableCellOptions>{
|
|
|
|
HTMLAttributes: {},
|
|
|
|
},
|
|
|
|
|
|
|
|
// content: options.cellContent,
|
|
|
|
content: 'block+',
|
|
|
|
// attrs: cellAttrs,
|
|
|
|
// tableRole: 'cell',
|
|
|
|
isolating: true,
|
|
|
|
|
|
|
|
parseHTML() {
|
|
|
|
// return [{ tag: 'td', getAttrs: dom => getCellAttrs(dom, extraAttrs) }]
|
|
|
|
return [{ tag: 'td' }]
|
|
|
|
},
|
|
|
|
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
|
|
// toDOM(node) { return ["td", setCellAttrs(node, extraAttrs), 0] }
|
|
|
|
return ['td', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
|
|
|
|
},
|
|
|
|
|
2021-01-21 06:42:01 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
declare module '@tiptap/core' {
|
|
|
|
interface AllExtensions {
|
|
|
|
TableCell: typeof TableCell,
|
|
|
|
}
|
|
|
|
}
|