Welcome to mirror list, hosted at ThFree Co, Russian Federation.

EditableTable.js « nodes « src - github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e24b680036f71c0b3e6703d13d3f60f1de8bbb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Table from './Table.js'
import TableCaption from './TableCaption.js'
import TableCell from './TableCell.js'
import TableHeader from './TableHeader.js'
import TableHeadRow from './TableHeadRow.js'
import TableRow from './TableRow.js'
import { VueNodeViewRenderer } from '@tiptap/vue-2'
import TableView from './TableView.vue'
import TableCellView from './TableCellView.vue'
import TableHeaderView from './TableHeaderView.vue'

/**
 * Add the node view to the node.
 * The node views include buttons to enable editing the table.
 *
 * @param {object} node - the node to add the view to.
 * @param {object} view - the node view to add to the node.
 */
function extendNodeWithView(node, view) {
	return node.extend({
		addNodeView() {
			return VueNodeViewRenderer(view)
		},
	})
}

export default Table.extend({

	addNodeView() {
		return VueNodeViewRenderer(TableView)
	},

	addExtensions() {
		return [
			TableCaption,
			extendNodeWithView(TableCell, TableCellView),
			extendNodeWithView(TableHeader, TableHeaderView),
			TableHeadRow,
			TableRow,
		]
	},
})