Skip to content

Commit

Permalink
Merge pull request #5858 from nextcloud/backport/5856/stable28
Browse files Browse the repository at this point in the history
[stable28] fix(table): Fix readonly detection in vue components
  • Loading branch information
mejo- authored Jun 3, 2024
2 parents f90be2e + 2a21523 commit f99f020
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/nodes/Table/TableCellView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<NodeViewWrapper data-text-el="table-cell" as="td" :style="textAlign">
<div class="container">
<NodeViewContent class="content" />
<NcActions v-if="editor.isEditable"
<NcActions v-if="isEditable"
data-text-table-actions="row">
<NcActionButton data-text-table-action="add-row-before"
close-after-click
Expand Down Expand Up @@ -81,11 +81,22 @@ export default {
required: true,
},
},
data() {
return {
isEditable: false,
}
},
computed: {
textAlign() {
return { 'text-align': this.node.attrs.textAlign }
},
},
beforeMount() {
this.isEditable = this.editor.isEditable
this.editor.on('update', ({ editor }) => {
this.isEditable = editor.isEditable
})
},
methods: {
deleteRow() {
this.editor.chain()
Expand Down
13 changes: 12 additions & 1 deletion src/nodes/Table/TableHeaderView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<NodeViewWrapper data-text-el="table-header" as="th" :style="textAlign">
<div>
<NodeViewContent class="content" />
<NcActions v-if="editor.isEditable"
<NcActions v-if="isEditable"
ref="menu"
data-text-table-actions="header">
<NcActionButtonGroup>
Expand Down Expand Up @@ -130,11 +130,22 @@ export default {
required: true,
},
},
data() {
return {
isEditable: false,
}
},
computed: {
textAlign() {
return { 'text-align': this.node.attrs.textAlign }
},
},
beforeMount() {
this.isEditable = this.editor.isEditable
this.editor.on('update', ({ editor }) => {
this.isEditable = editor.isEditable
})
},
methods: {
alignCenter() {
this.align('center')
Expand Down
13 changes: 12 additions & 1 deletion src/nodes/Table/TableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<template>
<NodeViewWrapper data-text-el="table-view" class="table-wrapper">
<NcActions v-if="editor.isEditable"
<NcActions v-if="isEditable"
force-menu
data-text-table-actions="settings"
class="table-settings">
Expand Down Expand Up @@ -68,6 +68,17 @@ export default {
required: true,
},
},
data() {
return {
isEditable: false,
}
},
beforeMount() {
this.isEditable = this.editor.isEditable
this.editor.on('update', ({ editor }) => {
this.isEditable = editor.isEditable
})
},
}
</script>

Expand Down

0 comments on commit f99f020

Please sign in to comment.