@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
30 lines (29 loc) • 1.12 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCellIndex = void 0;
exports.hasMergedColumns = hasMergedColumns;
exports.hasMergedRows = hasMergedRows;
exports.isRootCol = isRootCol;
exports.isRootRow = isRootRow;
var getCellIndex = function getCellIndex(map, row, col) {
return row * map.width + col;
};
exports.getCellIndex = getCellIndex;
function hasMergedColumns(map, row, col) {
var index = getCellIndex(map, row, col);
return col > 0 && map.map[index - 1] === map.map[index] || col < map.width - 1 && map.map[index + 1] === map.map[index];
}
function hasMergedRows(map, row, col) {
var index = getCellIndex(map, row, col);
return row > 0 && map.map[index - map.width] !== map.map[index] || row < map.height - 1 && map.map[index + map.width] === map.map[index];
}
function isRootRow(map, row, col) {
var index = getCellIndex(map, row, col);
return row > 0 ? map.map[index - map.width] !== map.map[index] : true;
}
function isRootCol(map, row, col) {
var index = getCellIndex(map, row, col);
return row > 0 ? map.map[index - 1] !== map.map[index] : true;
}
;