Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
392 changes: 196 additions & 196 deletions package-lock.json

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,38 @@
"@nextcloud/sharing": "^0.4.0",
"@nextcloud/vue": "^8.37.0",
"@quartzy/markdown-it-mentions": "^0.2.0",
"@tiptap/core": "^3.20.4",
"@tiptap/extension-blockquote": "^3.20.4",
"@tiptap/extension-bold": "^3.20.4",
"@tiptap/extension-code": "^3.20.4",
"@tiptap/extension-code-block": "^3.20.4",
"@tiptap/extension-code-block-lowlight": "^3.20.4",
"@tiptap/extension-collaboration": "^3.20.4",
"@tiptap/extension-collaboration-caret": "^3.20.4",
"@tiptap/extension-document": "^3.20.4",
"@tiptap/extension-drag-handle": "^3.20.4",
"@tiptap/extension-drag-handle-vue-2": "^3.20.4",
"@tiptap/extension-hard-break": "^3.20.4",
"@tiptap/extension-heading": "^3.20.4",
"@tiptap/extension-highlight": "^3.20.4",
"@tiptap/extension-horizontal-rule": "^3.20.4",
"@tiptap/extension-image": "^3.20.4",
"@tiptap/extension-italic": "^3.20.4",
"@tiptap/extension-link": "^3.20.4",
"@tiptap/extension-list": "^3.20.4",
"@tiptap/extension-mathematics": "^3.20.4",
"@tiptap/extension-mention": "^3.20.4",
"@tiptap/extension-paragraph": "^3.20.4",
"@tiptap/extension-placeholder": "^3.20.4",
"@tiptap/extension-strike": "^3.20.4",
"@tiptap/extension-table": "^3.20.4",
"@tiptap/extension-text": "^3.20.4",
"@tiptap/extension-typography": "^3.20.4",
"@tiptap/extension-underline": "^3.20.4",
"@tiptap/extensions": "^3.20.4",
"@tiptap/pm": "^3.20.4",
"@tiptap/suggestion": "^3.20.4",
"@tiptap/vue-2": "^3.20.4",
"@tiptap/core": "^3.22.0",
"@tiptap/extension-blockquote": "^3.22.0",
"@tiptap/extension-bold": "^3.22.0",
"@tiptap/extension-code": "^3.22.0",
"@tiptap/extension-code-block": "^3.22.0",
"@tiptap/extension-code-block-lowlight": "^3.22.0",
"@tiptap/extension-collaboration": "^3.22.0",
"@tiptap/extension-collaboration-caret": "^3.22.0",
"@tiptap/extension-document": "^3.22.0",
"@tiptap/extension-drag-handle": "^3.22.0",
"@tiptap/extension-drag-handle-vue-2": "^3.22.0",
"@tiptap/extension-hard-break": "^3.22.0",
"@tiptap/extension-heading": "^3.22.0",
"@tiptap/extension-highlight": "^3.22.0",
"@tiptap/extension-horizontal-rule": "^3.22.0",
"@tiptap/extension-image": "^3.22.0",
"@tiptap/extension-italic": "^3.22.0",
"@tiptap/extension-link": "^3.22.0",
"@tiptap/extension-list": "^3.22.0",
"@tiptap/extension-mathematics": "^3.22.0",
"@tiptap/extension-mention": "^3.22.0",
"@tiptap/extension-paragraph": "^3.22.0",
"@tiptap/extension-placeholder": "^3.22.0",
"@tiptap/extension-strike": "^3.22.0",
"@tiptap/extension-table": "^3.22.0",
"@tiptap/extension-text": "^3.22.0",
"@tiptap/extension-typography": "^3.22.0",
"@tiptap/extension-underline": "^3.22.0",
"@tiptap/extensions": "^3.22.0",
"@tiptap/pm": "^3.22.0",
"@tiptap/suggestion": "^3.22.0",
"@tiptap/vue-2": "^3.22.0",
"@vueuse/shared": "^11.3.0",
"debounce": "^3.0.0",
"escape-html": "^1.0.3",
Expand Down
8 changes: 4 additions & 4 deletions src/nodes/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export default Table.extend({
for (let i = 0; i < lastRow.childCount; i++) {
tr.setNodeAttribute(
pos,
'textAlign',
lastRow.child(i).attrs.textAlign,
'align',
lastRow.child(i).attrs.align,
)
pos += newRow.child(i).nodeSize
}
Expand All @@ -129,8 +129,8 @@ export default Table.extend({
for (let i = 0; i < lastRow.childCount; i++) {
tr.setNodeAttribute(
pos,
'textAlign',
lastRow.child(i).attrs.textAlign,
'align',
lastRow.child(i).attrs.align,
)
pos += newRow.child(i).nodeSize
}
Expand Down
19 changes: 0 additions & 19 deletions src/nodes/Table/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,6 @@ export default TableCell.extend({
]
},

addAttributes() {
return {
...this.parent?.(),
textAlign: {
rendered: true,
default: null,
renderHTML: (attributes) => {
if (!attributes.textAlign) {
return {}
}
return {
style: `text-align: ${attributes.textAlign}`,
}
},
parseHTML: (element) => element.style.textAlign || null,
},
}
},

renderHTML({ HTMLAttributes }) {
const attributes = mergeAttributes(
this.options.HTMLAttributes,
Expand Down
6 changes: 3 additions & 3 deletions src/nodes/Table/TableCellView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-->

<template>
<NodeViewWrapper data-text-el="table-cell" as="td" :dir="dir" :style="textAlign">
<NodeViewWrapper data-text-el="table-cell" as="td" :dir="dir" :style="align">
<div class="container">
<NodeViewContent class="content" />
<NcActions v-if="isEditable" data-text-table-actions="row" size="small">
Expand Down Expand Up @@ -78,8 +78,8 @@ export default {
}
},
computed: {
textAlign() {
return { 'text-align': this.node.attrs.textAlign }
align() {
return { 'text-align': this.node.attrs.align }
},
dir() {
return this.node.attrs.dir || ''
Expand Down
19 changes: 0 additions & 19 deletions src/nodes/Table/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,4 @@ export default TableHeader.extend({
}
return ['th', attributes, 0]
},

addAttributes() {
return {
...this.parent?.(),
textAlign: {
rendered: true,
default: null,
renderHTML: (attributes) => {
if (!attributes.textAlign) {
return {}
}
return {
style: `text-align: ${attributes.textAlign}`,
}
},
parseHTML: (element) => element.style.textAlign || null,
},
}
},
})
40 changes: 18 additions & 22 deletions src/nodes/Table/TableHeaderView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
-->

<template>
<NodeViewWrapper
data-text-el="table-header"
as="th"
:dir="dir"
:style="textAlign">
<NodeViewWrapper data-text-el="table-header" as="th" :dir="dir" :style="align">
<div>
<NodeViewContent class="content" />
<NcActions
Expand All @@ -23,8 +19,8 @@
:aria-label="t('text', 'Left align column')"
type="radio"
value="left"
:model-value="node.attrs.textAlign"
@click="alignLeft">
:model-value="node.attrs.align"
@click="setAlignLeft">
<template #icon>
<AlignHorizontalLeft />
</template>
Expand All @@ -34,8 +30,8 @@
:aria-label="t('text', 'Center align column')"
type="radio"
value="center"
:model-value="node.attrs.textAlign"
@click="alignCenter">
:model-value="node.attrs.align"
@click="setAlignCenter">
<template #icon>
<AlignHorizontalCenter />
</template>
Expand All @@ -45,8 +41,8 @@
:aria-label="t('text', 'Right align column')"
type="radio"
value="right"
:model-value="node.attrs.textAlign"
@click="alignRight">
:model-value="node.attrs.align"
@click="setAlignRight">
<template #icon>
<AlignHorizontalRight />
</template>
Expand Down Expand Up @@ -134,8 +130,8 @@ export default {
}
},
computed: {
textAlign() {
return { 'text-align': this.node.attrs.textAlign }
align() {
return { 'text-align': this.node.attrs.align }
},
dir() {
return this.node.attrs.dir || ''
Expand All @@ -148,24 +144,24 @@ export default {
})
},
methods: {
alignCenter() {
this.align('center')
setAlignCenter() {
this.setAlign('center')
},
alignLeft() {
this.align('left')
setAlignLeft() {
this.setAlign('left')
},
alignRight() {
this.align('right')
setAlignRight() {
this.setAlign('right')
},
align(textAlign) {
setAlign(align) {
this.editor
.chain()
.focus()
.setTextSelection(this.getPos())
.setCellAttribute('textAlign', textAlign)
.setCellAttribute('align', align)
.run()
while (this.editor.commands.goToNextRow()) {
this.editor.commands.setCellAttribute('textAlign', textAlign)
this.editor.commands.setCellAttribute('align', align)
}
// Set focus back to first row
this.editor.chain().setTextSelection(this.getPos()).focus().run()
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/Table/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function tableToMarkdown(state: MarkdownSerializerState, node: Node) {
row.length = Math.max(row.length, lines.length)
const lineLength = Math.max(...lines.map((line) => line.length))
columnWidths[cellIdx] = Math.max(columnWidths[cellIdx], lineLength)
const align = node.attrs?.textAlign ?? ''
const align = node.attrs?.align ?? ''
row.cells.push({ md, lines, nodeTypes, align })
})
})
Expand Down
28 changes: 8 additions & 20 deletions src/tests/nodes/Table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,13 @@ describe('Table extension', () => {
editor.state.doc,
table(
thead(
th({ dir: 'ltr', textAlign: 'center' }, 'heading'),
th({ dir: 'ltr', textAlign: 'right' }, 'heading 2'),
th({ dir: 'ltr', align: 'center' }, 'heading'),
th({ dir: 'ltr', align: 'right' }, 'heading 2'),
th({ dir: 'ltr' }, 'heading 3'),
),
tr(
td(
{ dir: 'ltr', textAlign: 'center' },
p({ dir: 'ltr' }, 'center'),
),
td(
{ dir: 'ltr', textAlign: 'right' },
p({ dir: 'ltr' }, 'right'),
),
td({ dir: 'ltr', align: 'center' }, p({ dir: 'ltr' }, 'center')),
td({ dir: 'ltr', align: 'right' }, p({ dir: 'ltr' }, 'right')),
td(
{ dir: 'ltr' },
p(
Expand All @@ -148,19 +142,13 @@ describe('Table extension', () => {
editor.state.doc,
table(
thead(
th({ dir: 'ltr', textAlign: 'center' }, 'heading'),
th({ dir: 'ltr', textAlign: 'right' }, 'heading 2'),
th({ dir: 'ltr', align: 'center' }, 'heading'),
th({ dir: 'ltr', align: 'right' }, 'heading 2'),
th({ dir: 'ltr' }, 'heading 3'),
),
tr(
td(
{ dir: 'ltr', textAlign: 'center' },
p({ dir: 'ltr' }, 'center'),
),
td(
{ dir: 'ltr', textAlign: 'right' },
p({ dir: 'ltr' }, 'right'),
),
td({ dir: 'ltr', align: 'center' }, p({ dir: 'ltr' }, 'center')),
td({ dir: 'ltr', align: 'right' }, p({ dir: 'ltr' }, 'right')),
td(
{ dir: 'ltr' },
p(
Expand Down
Loading