add table editing plugin and allow table to be resizeable
This commit is contained in:
@@ -39,6 +39,15 @@
|
|||||||
<button @click="editor.chain().focus().toggleHeaderCell().run()">
|
<button @click="editor.chain().focus().toggleHeaderCell().run()">
|
||||||
✅ toggleHeaderCell
|
✅ toggleHeaderCell
|
||||||
</button>
|
</button>
|
||||||
|
<button disabled>
|
||||||
|
⚠️ fixTables
|
||||||
|
</button>
|
||||||
|
<button disabled>
|
||||||
|
⚠️ toggleCellMerge
|
||||||
|
</button>
|
||||||
|
<button disabled>
|
||||||
|
⚠️ setCellAttr
|
||||||
|
</button>
|
||||||
<editor-content :editor="editor" />
|
<editor-content :editor="editor" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -71,7 +80,9 @@ export default {
|
|||||||
Document,
|
Document,
|
||||||
Paragraph,
|
Paragraph,
|
||||||
Text,
|
Text,
|
||||||
Table,
|
Table.configure({
|
||||||
|
resizable: true,
|
||||||
|
}),
|
||||||
TableRow,
|
TableRow,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableCell,
|
TableCell,
|
||||||
@@ -82,8 +93,7 @@ export default {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Test</th>
|
<th>Test</th>
|
||||||
<th>Test</th>
|
<th colspan="2">Test</th>
|
||||||
<th>Test</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Test</td>
|
<td>Test</td>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||||
import {
|
import {
|
||||||
// tableEditing,
|
tableEditing,
|
||||||
// columnResizing,
|
columnResizing,
|
||||||
// goToNextCell,
|
// goToNextCell,
|
||||||
addColumnBefore,
|
addColumnBefore,
|
||||||
addColumnAfter,
|
addColumnAfter,
|
||||||
@@ -23,6 +23,7 @@ export interface TableOptions {
|
|||||||
HTMLAttributes: {
|
HTMLAttributes: {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
},
|
},
|
||||||
|
resizable: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Table = Node.create({
|
export const Table = Node.create({
|
||||||
@@ -30,6 +31,7 @@ export const Table = Node.create({
|
|||||||
|
|
||||||
defaultOptions: <TableOptions>{
|
defaultOptions: <TableOptions>{
|
||||||
HTMLAttributes: {},
|
HTMLAttributes: {},
|
||||||
|
resizable: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
content: 'table_row+',
|
content: 'table_row+',
|
||||||
@@ -126,6 +128,13 @@ export const Table = Node.create({
|
|||||||
// setCellAttr: ({ name, value }) => setCellAttr(name, value),
|
// setCellAttr: ({ name, value }) => setCellAttr(name, value),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addProseMirrorPlugins() {
|
||||||
|
return [
|
||||||
|
...(this.options.resizable ? [columnResizing({})] : []),
|
||||||
|
tableEditing({}),
|
||||||
|
]
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
|
|||||||
Reference in New Issue
Block a user