Skip to content

Commit b18ab8b

Browse files
committed
chore(table): Remove dead code from table node classes
Signed-off-by: Jonas <[email protected]>
1 parent 81482c0 commit b18ab8b

File tree

5 files changed

+4
-123
lines changed

5 files changed

+4
-123
lines changed

src/nodes/Table/Table.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -73,54 +73,6 @@ function findSameCellInNextRow($cell) {
7373
}
7474
}
7575

76-
/**
77-
*
78-
* @param {Node} node - Table node
79-
*/
80-
/*
81-
function getColumns(node) {
82-
const columns = []
83-
84-
node.content.forEach((row) => {
85-
row.content.forEach((cell, offset, columnIndex) => {
86-
if (!columns[columnIndex]) {
87-
columns[columnIndex] = []
88-
}
89-
columns[columnIndex].push(cell)
90-
})
91-
})
92-
93-
return columns
94-
}
95-
*/
96-
97-
/**
98-
*
99-
* @param {Array} columns - Columns of table
100-
*/
101-
/*
102-
function calculateColumnWidths(columns) {
103-
const widths = []
104-
105-
columns.forEach((column) => {
106-
let maxWidth = 0
107-
108-
column.forEach((cell) => {
109-
let cellWidth = 0
110-
cell.content.forEach((node) => {
111-
cellWidth += node.text?.length || 6
112-
if (node.text?.includes('|')) cellWidth += 1
113-
})
114-
maxWidth = Math.max(maxWidth, cellWidth)
115-
})
116-
117-
widths.push(maxWidth)
118-
})
119-
120-
return widths
121-
}
122-
*/
123-
12476
export default Table.extend({
12577
content: 'tableCaption? tableHeadRow tableRow*',
12678

src/nodes/Table/TableCell.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,7 @@ import { Plugin } from '@tiptap/pm/state'
1111
export default TableCell.extend({
1212
content: '(paragraph|list|codeBlock|image)+',
1313

14-
toMarkdown(state, node) {
15-
/*
16-
state.write(' ')
17-
const backup = state.options?.escapeExtraCharacters
18-
const columnIndex = state.options.currentColumnIndex
19-
state.options.escapeExtraCharacters = /\|/
20-
21-
let cellRenderedContentLength = 0
22-
node.content.forEach((childNode, offset, index) => {
23-
cellRenderedContentLength += childNode.text?.length || 6
24-
if (childNode.text?.includes('|')) cellRenderedContentLength += 1
25-
if (childNode.attrs.syntax === ' ')
26-
node.child(index).attrs.syntax = 'html'
27-
})
28-
const columnWidth = state.options.columnWidths[columnIndex]
29-
const align = node.attrs?.textAlign || 'left'
30-
const space = columnWidth - cellRenderedContentLength
31-
const leftPadding = Math.floor(space / 2)
32-
const rightPadding = Math.ceil(space / 2)
33-
34-
if (align === 'center') state.write(' '.repeat(leftPadding))
35-
if (align === 'right') state.write(' '.repeat(space))
36-
state.renderInline(node)
37-
if (align === 'center') state.write(' '.repeat(rightPadding))
38-
if (align === 'left') state.write(' '.repeat(space))
39-
40-
state.options.escapeExtraCharacters = backup
41-
state.write(' |')
42-
state.options.currentColumnIndex++
43-
*/
44-
},
14+
toMarkdown() {},
4515

4616
parseHTML() {
4717
return [

src/nodes/Table/TableHeadRow.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,7 @@ export default TableRow.extend({
1010
content: 'tableHeader+',
1111
allowGapCursor: false,
1212

13-
toMarkdown(state, node) {
14-
/*
15-
state.write('|')
16-
state.renderInline(node)
17-
state.ensureNewLine()
18-
state.write('|')
19-
node.forEach((cell, offset, index) => {
20-
let row = state.repeat('-', state.options.columnWidths[index] + 2)
21-
const align = cell.attrs?.textAlign
22-
if (align === 'center' || align === 'left') row = ':' + row.slice(1)
23-
if (align === 'center' || align === 'right') row = row.slice(0, -1) + ':'
24-
state.write(row)
25-
state.write('|')
26-
})
27-
state.ensureNewLine()
28-
*/
29-
},
13+
toMarkdown() {},
3014

3115
parseHTML() {
3216
return [{ tag: 'tr:first-of-type', priority: 80 }]

src/nodes/Table/TableHeader.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,7 @@ import { TableHeader } from '@tiptap/extension-table-header'
99
export default TableHeader.extend({
1010
content: 'inline*',
1111

12-
toMarkdown(state, node) {
13-
/*
14-
const headerIndex = state.options.currentHeaderIndex
15-
const columnWidth = state.options.columnWidths[headerIndex]
16-
const align = node.attrs?.textAlign || 'left'
17-
const space = columnWidth - node.content.size
18-
const leftPadding = Math.floor(space / 2)
19-
const rightPadding = Math.ceil(space / 2)
20-
21-
state.write(' ')
22-
if (align === 'center') state.write(' '.repeat(leftPadding))
23-
if (align === 'right') state.write(' '.repeat(space))
24-
state.renderInline(node)
25-
if (align === 'center') state.write(' '.repeat(rightPadding))
26-
if (align === 'left') state.write(' '.repeat(space))
27-
state.write(' |')
28-
state.options.currentHeaderIndex++
29-
*/
30-
},
12+
toMarkdown() {},
3113

3214
parseHTML() {
3315
return [

src/nodes/Table/TableRow.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ export default TableRow.extend({
99
content: 'tableCell*',
1010
allowGapCursor: false,
1111

12-
toMarkdown(state, node) {
13-
/*
14-
state.write('|')
15-
state.options.currentColumnIndex = 0
16-
state.renderInline(node)
17-
state.ensureNewLine()
18-
*/
19-
},
12+
toMarkdown() {},
2013

2114
parseHTML() {
2215
return [{ tag: 'tr', priority: 70 }]

0 commit comments

Comments
 (0)