File size: 811 Bytes
89ce340 |
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 |
import { computed, type Ref } from 'vue'
import type { TableCell } from '@/types/slides'
// 计算无效的单元格位置(被合并的单元格位置)集合
export default (cells: Ref<TableCell[][]>) => {
const hideCells = computed(() => {
const hideCells = []
for (let i = 0; i < cells.value.length; i++) {
const rowCells = cells.value[i]
for (let j = 0; j < rowCells.length; j++) {
const cell = rowCells[j]
if (cell.colspan > 1 || cell.rowspan > 1) {
for (let row = i; row < i + cell.rowspan; row++) {
for (let col = row === i ? j + 1 : j; col < j + cell.colspan; col++) {
hideCells.push(`${row}_${col}`)
}
}
}
}
}
return hideCells
})
return {
hideCells,
}
} |