Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 1x 1x 15x 75x 15x 15x 22x 38x 38x 24x 24x 24x 15x | import { parseTableCells } from 'roosterjs-content-model-dom'; import type { TableSelection } from 'roosterjs-content-model-types'; /** * @internal Export for test only * Create ranges from a table selection * @param selection The source table selection * @returns An array of DOM ranges of selected table cells */ export function createTableRanges(selection: TableSelection): Range[] { const result: Range[] = []; const { table, firstColumn, firstRow, lastColumn, lastRow } = selection; const cells = parseTableCells(table); for (let row = firstRow; row <= lastRow; row++) { for (let col = firstColumn; col <= lastColumn; col++) { const td = cells[row]?.[col]; if (typeof td == 'object') { const range = table.ownerDocument.createRange(); range.selectNode(td); result.push(range); } } } return result; } |