11<!--
2- - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
2+ - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
33 - SPDX-License-Identifier: AGPL-3.0-or-later
44-->
55
66<template >
7- <NodeViewWrapper data-text-el =" table-cell " as =" td " :dir = " dir " :style = " align " >
8- <div class =" container " >
9- < NodeViewContent class = " content " / >
10- <NcActions v-if =" isEditable " data-text-table-actions =" row" size =" small" >
7+ <NodeViewWrapper data-text-el =" table-row " as =" tr " >
8+ <NodeViewContent class =" table-row-cells " / >
9+ < td v-if = " isEditable " class = " row-actions " >
10+ <NcActions v-if =" isDataRow " data-text-table-actions =" row" size =" small" >
1111 <NcActionButton
1212 data-text-table-action =" add-row-before"
1313 close-after-click
3636 {{ t('text', 'Delete this row') }}
3737 </NcActionButton >
3838 </NcActions >
39- </div >
39+ </td >
4040 </NodeViewWrapper >
4141</template >
4242
@@ -52,114 +52,115 @@ import {
5252} from ' ../../components/icons.js'
5353
5454export default {
55- name: ' TableCellView ' ,
55+ name: ' TableRowView ' ,
5656 components: {
5757 NcActionButton,
5858 NcActions,
5959 NodeViewWrapper,
6060 NodeViewContent,
61- TableAddRowBefore,
6261 TableAddRowAfter,
62+ TableAddRowBefore,
6363 TrashCan,
6464 },
65+
6566 props: {
6667 editor: {
6768 type: Object ,
6869 required: true ,
6970 },
71+
7072 getPos: {
7173 type: Function ,
7274 required: true ,
7375 },
76+
77+ node: {
78+ type: Object ,
79+ required: true ,
80+ },
7481 },
82+
7583 data () {
7684 return {
7785 isEditable: false ,
7886 }
7987 },
88+
8089 computed: {
81- align () {
82- return { ' text-align' : this .node .attrs .align }
83- },
84- dir () {
85- return this .node .attrs .dir || ' '
90+ isDataRow () {
91+ return this .node .type .name === ' tableRow'
8692 },
8793 },
94+
8895 beforeMount () {
8996 this .isEditable = this .editor .isEditable
9097 this .editor .on (' update' , ({ editor }) => {
9198 this .isEditable = editor .isEditable
9299 })
93100 },
101+
94102 methods: {
95103 deleteRow () {
96104 this .editor
97105 .chain ()
98106 .focus ()
99- .setTextSelection (this .getPos ())
107+ .setTextSelection (this .getPos () + 1 )
100108 .deleteRow ()
101109 .run ()
102110 },
111+
103112 addRowBefore () {
104113 this .editor
105114 .chain ()
106115 .focus ()
107- .setTextSelection (this .getPos ())
116+ .setTextSelection (this .getPos () + 1 )
108117 .addRowBefore ()
109118 .run ()
110119 },
120+
111121 addRowAfter () {
112122 this .editor
113123 .chain ()
114124 .focus ()
115- .setTextSelection (this .getPos ())
125+ .setTextSelection (this .getPos () + 1 )
116126 .addRowAfter ()
117127 .run ()
118128 },
129+
119130 t,
120131 },
121132}
122133 </script >
123134
124135<style scoped lang="scss">
125- td {
126- position : relative ;
127-
128- .container {
129- display : flex ;
130- flex-wrap : wrap ;
131- }
136+ .table-row-cells {
137+ display : contents ;
138+ }
132139
133- .content {
134- flex : 1 1 0 ;
135- margin : 0 ;
136- padding : calc (
137- (var (--default-clickable-area ) - var (--default-font-size ) * 1.5 ) / 2
138- )
139- 0.75em ;
140- }
140+ td .row-actions {
141+ position : sticky ;
142+ right : 0 ;
143+ z-index : 4 ;
144+ background-color : var (--color-main-background );
145+ width : calc (var (--clickable-area-small ) + var (--default-grid-baseline ));
146+ padding : 0 ;
147+ // Required to prevent focus outline from being cut off
148+ padding-right : 2px ;
149+ padding-left : var (--default-grid-baseline );
150+ vertical-align : middle ;
151+ border : none ;
152+ border-radius : 0 ;
141153
142154 .action-item {
143- position : absolute ;
144- right : calc ((var (--clickable-area-small ) * -1 ) - 4px );
145- flex : 0 1 auto ;
146- display : none ;
147- top : calc ((var (--default-clickable-area ) - var (--clickable-area-small )) / 2 );
155+ opacity : 0.5 ;
148156 }
149157
150- & :last-child {
158+ & :hover ,
159+ & :active ,
160+ & :focus ,
161+ & :focus-within {
151162 .action-item {
152- display : block ;
153- opacity : 50% ;
154- }
155-
156- & :hover ,
157- & :active ,
158- & :focus ,
159- & :focus-within {
160- .action-item {
161- opacity : 100% ;
162- }
163+ opacity : 1 ;
163164 }
164165 }
165166}
0 commit comments