tiptap/packages/extension-table-row/src/table-row.ts

34 lines
605 B
TypeScript
Raw Normal View History

2021-01-21 06:53:53 +08:00
import { Node, mergeAttributes } from '@tiptap/core'
export interface TableRowOptions {
HTMLAttributes: {
[key: string]: any
},
}
2021-01-21 06:42:01 +08:00
export const TableRow = Node.create({
name: 'table_row',
2021-01-21 06:53:53 +08:00
defaultOptions: <TableRowOptions>{
HTMLAttributes: {},
},
2021-01-22 07:16:58 +08:00
content: '(table_cell | table_header)*',
2021-01-21 06:53:53 +08:00
tableRole: 'row',
2021-01-21 06:53:53 +08:00
parseHTML() {
return [{ tag: 'tr' }]
},
renderHTML({ HTMLAttributes }) {
return ['tr', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
},
2021-01-21 06:42:01 +08:00
})
declare module '@tiptap/core' {
interface AllExtensions {
TableRow: typeof TableRow,
}
}