roosterjs-content-model-api 9.58.0 → 9.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/modelApi/block/setModelDirection.d.ts +5 -0
- package/lib/modelApi/block/setModelDirection.js +21 -24
- package/lib/modelApi/block/setModelDirection.js.map +1 -1
- package/lib/modelApi/table/insertTableColumn.js +2 -1
- package/lib/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib/modelApi/table/insertTableRow.js +2 -1
- package/lib/modelApi/table/insertTableRow.js.map +1 -1
- package/lib/modelApi/table/mergeTableCells.js +36 -2
- package/lib/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib/modelApi/table/mergeTableColumn.js +1 -2
- package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib/modelApi/table/mergeTableRow.js +1 -2
- package/lib/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib/publicApi/table/applyTableBorderFormat.d.ts +1 -0
- package/lib/publicApi/table/applyTableBorderFormat.js +104 -26
- package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-amd/index.d.ts +1 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/modelApi/block/setModelDirection.d.ts +5 -0
- package/lib-amd/modelApi/block/setModelDirection.js +21 -24
- package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-amd/modelApi/table/insertTableColumn.js +2 -1
- package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/insertTableRow.js +2 -1
- package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableCells.js +37 -2
- package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableColumn.js +2 -2
- package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib-amd/modelApi/table/mergeTableRow.js +2 -2
- package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib-amd/publicApi/table/applyTableBorderFormat.d.ts +1 -0
- package/lib-amd/publicApi/table/applyTableBorderFormat.js +104 -26
- package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/lib-mjs/index.d.ts +1 -0
- package/lib-mjs/index.js +1 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/modelApi/block/setModelDirection.d.ts +5 -0
- package/lib-mjs/modelApi/block/setModelDirection.js +19 -23
- package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
- package/lib-mjs/modelApi/table/insertTableColumn.js +2 -1
- package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/insertTableRow.js +2 -1
- package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableCells.js +36 -2
- package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableColumn.js +1 -2
- package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
- package/lib-mjs/modelApi/table/mergeTableRow.js +1 -2
- package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
- package/lib-mjs/publicApi/table/applyTableBorderFormat.d.ts +1 -0
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js +106 -28
- package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
- package/package.json +3 -3
- package/lib/modelApi/table/canMergeCells.d.ts +0 -5
- package/lib/modelApi/table/canMergeCells.js +0 -57
- package/lib/modelApi/table/canMergeCells.js.map +0 -1
- package/lib-amd/modelApi/table/canMergeCells.d.ts +0 -5
- package/lib-amd/modelApi/table/canMergeCells.js +0 -59
- package/lib-amd/modelApi/table/canMergeCells.js.map +0 -1
- package/lib-mjs/modelApi/table/canMergeCells.d.ts +0 -5
- package/lib-mjs/modelApi/table/canMergeCells.js +0 -53
- package/lib-mjs/modelApi/table/canMergeCells.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"setModelDirection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts"],"names":[],"mappings":";;;;IAkBA,IAAM,uBAAuB,GAAG,IAAI,MAAM,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;IAC1E,IAAM,cAAc,GAAG,IAAI,MAAM,CAC7B,kGAAkG,EAClG,GAAG,CACN,CAAC;IAEF;;OAEG;IACH,SAAgB,iBAAiB,CAC7B,KAAmC,EACnC,SAAiC;QAEjC,IAAA,uDAA0B,EAAC,KAAK,CAAC,CAAC;QAElC,IAAM,0BAA0B,GAAG,IAAA,kDAAoB,EACnD,KAAK,EACL,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,CAAC,CAChB,CAAC;QAEF,0BAA0B,CAAC,OAAO,CAAC,UAAC,EAAS;gBAAP,KAAK,WAAA;YACvC,IAAI,aAA4B,CAAC;YACjC,IAAI,SAAS,KAAK,MAAM,EAAE;gBACtB,aAAa,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;aACjD;iBAAM;gBACH,aAAa,GAAG,SAAS,CAAC;aAC7B;YACD,IAAI,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;gBAC7D,IAAM,KAAK,GAAG,IAAA,qDAAyB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAEtD,KAAK,CAAC,OAAO,CAAC,UAAA,YAAY;oBACtB,IAAM,IAAI,GAAG,IAAA,yCAAW,EAAC,YAAY,CAAC,CAAC;oBAEvC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;wBACrB,KAAK,CAAC,MAA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AC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChG,CAAC;IAJD,4CAIC;IAED,yHAAyH;IACzH,SAAS,sBAAsB,CAAC,KAAgC;QAC5D,OAAO,gBAAgB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC;IAC5D,CAAC;IAED,SAAS,cAAc,CAAC,KAAgC;QACpD,IAAI,KAAK,CAAC,SAAS,KAAK,WAAW,EAAE;YACjC,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CACxB,UAAC,IAAI,EAAE,OAAO,IAAK,OAAA,IAAI,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAA3D,CAA2D,EAC9E,EAAE,CACL,CAAC;SACL;aAAM,IAAI,IAAA,gDAAkB,EAAuB,KAAK,EAAE,UAAU,CAAC,EAAE;YACpE,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,UAAU,IAAK,OAAA,IAAI,GAAG,cAAc,CAAC,UAAU,CAAC,EAAjC,CAAiC,EAAE,EAAE,CAAC,CAAC;SAC3F;aAAM;YACH,OAAO,EAAE,CAAC;SACb;IACL,CAAC","sourcesContent":["import { findListItemsInSameThread } from '../list/findListItemsInSameThread';\nimport { splitSelectedParagraphByBr } from './splitSelectedParagraphByBr';\nimport {\n applyTableFormat,\n getOperationalBlocks,\n isBlockGroupOfType,\n mutateBlock,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type {\n BorderFormat,\n ContentModelListItem,\n MarginFormat,\n PaddingFormat,\n ReadonlyContentModelBlock,\n ReadonlyContentModelDocument,\n} from 'roosterjs-content-model-types';\n\nconst FIRST_STRONG_CHAR_REGEX = new RegExp('[\\\\p{L}\\\\u200E\\\\u200F]', 'u');\nconst RTL_CHAR_REGEX = new RegExp(\n '[\\\\u0590-\\\\u08FF\\\\u200F\\\\uFB1D-\\\\uFDFF\\\\uFE70-\\\\uFEFF\\\\u{10840}-\\\\u{10FFF}\\\\u{1E800}-\\\\u{1E95F}]',\n 'u'\n);\n\n/**\n * @internal\n */\nexport function setModelDirection(\n model: ReadonlyContentModelDocument,\n direction: 'ltr' | 'rtl' | 'auto'\n) {\n splitSelectedParagraphByBr(model);\n\n const paragraphOrListItemOrTable = getOperationalBlocks<ContentModelListItem>(\n model,\n ['ListItem'],\n ['TableCell']\n );\n\n paragraphOrListItemOrTable.forEach(({ block }) => {\n let calcDirection: 'ltr' | 'rtl';\n if (direction === 'auto') {\n calcDirection = determineTextDirection(block);\n } else {\n calcDirection = direction;\n }\n if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n const items = findListItemsInSameThread(model, block);\n\n items.forEach(readonlyItem => {\n const item = mutateBlock(readonlyItem);\n\n item.levels.forEach(level => {\n level.format.direction = calcDirection;\n });\n\n // We already set direction on levels, no need to keep it on list item level\n delete item.format.direction;\n\n // Remove textAlign to let it be calculated based on direction change\n delete item.format.textAlign;\n\n item.blocks.forEach(block => internalSetDirection(block, calcDirection));\n });\n } else if (block) {\n internalSetDirection(block, calcDirection);\n }\n });\n\n return paragraphOrListItemOrTable.length > 0;\n}\n\nfunction internalSetDirection(block: ReadonlyContentModelBlock, direction: 'ltr' | 'rtl') {\n const wasRtl = block.format.direction == 'rtl';\n const isRtl = direction == 'rtl';\n\n if (wasRtl != isRtl) {\n const { format } = mutateBlock(block);\n format.direction = direction;\n\n // Adjust margin when change direction\n const marginLeft = format.marginLeft;\n const paddingLeft = format.paddingLeft;\n\n setProperty(format, 'marginLeft', format.marginRight);\n setProperty(format, 'marginRight', marginLeft);\n setProperty(format, 'paddingLeft', format.paddingRight);\n setProperty(format, 'paddingRight', paddingLeft);\n\n // If whole Table direction changed, flip cell side borders\n if (block && block.blockType == 'Table') {\n block.rows.forEach(row => {\n row.cells.forEach(cell => {\n // Optimise by skipping cells with unchanged borders\n updateTableCellMetadata(mutateBlock(cell), metadata => {\n if (metadata?.borderOverride) {\n const storeBorderLeft = cell.format.borderLeft;\n setProperty(cell.format, 'borderLeft', cell.format.borderRight);\n setProperty(cell.format, 'borderRight', storeBorderLeft);\n }\n return metadata;\n });\n });\n });\n\n // Apply changed borders\n applyTableFormat(block, undefined /* newFormat */, true /* keepCellShade*/);\n }\n }\n}\n\nfunction setProperty(\n format: MarginFormat & PaddingFormat & BorderFormat,\n key: keyof (MarginFormat & PaddingFormat & BorderFormat),\n value: string | undefined\n) {\n if (value) {\n format[key] = value;\n } else {\n delete format[key];\n }\n}\n\n/**\n * Determine text direction from the first strong directional character\n * @param text Text to scan\n */\nexport function getTextDirection(text: string): 'ltr' | 'rtl' | undefined {\n const firstStrongChar = text.match(FIRST_STRONG_CHAR_REGEX)?.[0];\n\n return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;\n}\n\n// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character\nfunction determineTextDirection(block: ReadonlyContentModelBlock): 'ltr' | 'rtl' {\n return getTextDirection(getTextContent(block)) || 'ltr';\n}\n\nfunction getTextContent(block: ReadonlyContentModelBlock): string {\n if (block.blockType === 'Paragraph') {\n return block.segments.reduce(\n (text, segment) => text + (segment.segmentType === 'Text' ? segment.text : ''),\n ''\n );\n } else if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {\n return block.blocks.reduce((text, childBlock) => text + getTextContent(childBlock), '');\n } else {\n return '';\n }\n}\n"]}
|
|
@@ -15,7 +15,8 @@ define(["require", "exports", "./clearSelectedCells", "./copyPreviousCellSegment
|
|
|
15
15
|
for (var i = sel === null || sel === void 0 ? void 0 : sel.firstColumn; i <= sel.lastColumn; i++) {
|
|
16
16
|
table.rows.forEach(function (row) {
|
|
17
17
|
var cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];
|
|
18
|
-
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(
|
|
18
|
+
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(false, //spanLeft
|
|
19
|
+
cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
|
|
19
20
|
(0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
|
|
20
21
|
newCell.isSelected = true;
|
|
21
22
|
row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,iBAAiB,CAC7B,KAAsC,EACtC,SAAyC;QAEzC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACrD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAEtE,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,
|
|
1
|
+
{"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH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AAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAC9D,CAAC;aACL;SACJ;IACL,CAAC;IAhCD,8CAgCC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n false, //spanLeft\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
|
|
@@ -17,7 +17,8 @@ define(["require", "exports", "tslib", "./clearSelectedCells", "./copyPreviousCe
|
|
|
17
17
|
table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {
|
|
18
18
|
format: (0, tslib_1.__assign)({}, sourceRow.format),
|
|
19
19
|
cells: sourceRow.cells.map(function (cell) {
|
|
20
|
-
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft,
|
|
20
|
+
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, false, //spanAbove
|
|
21
|
+
cell.isHeader, cell.format, cell.dataset);
|
|
21
22
|
(0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
|
|
22
23
|
newCell.isSelected = true;
|
|
23
24
|
return newCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,cAAc,CAC1B,KAAsC,EACtC,SAAuC;QAEvC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;QAE/C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAE/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;oBAC/D,MAAM,4BAAO,SAAS,CAAC,MAAM,CAAE;oBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;wBAC3B,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,
|
|
1
|
+
{"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/ins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electedCells } from './clearSelectedCells';\nimport { copyPreviousCellSegmentFormat } from './copyPreviousCellSegmentFormat';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n false, //spanAbove\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n copyPreviousCellSegmentFormat(cell, newCell);\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_dom_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.mergeTableCells = void 0;
|
|
@@ -8,7 +8,16 @@ define(["require", "exports", "./canMergeCells", "roosterjs-content-model-dom"],
|
|
|
8
8
|
function mergeTableCells(table) {
|
|
9
9
|
var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(table);
|
|
10
10
|
if (sel &&
|
|
11
|
-
(0,
|
|
11
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, sel.firstRow, sel.firstColumn, sel.lastRow, sel.lastColumn)) {
|
|
12
|
+
var firstCell = (0, roosterjs_content_model_dom_1.mutateBlock)(table.rows[sel.firstRow].cells[sel.firstColumn]);
|
|
13
|
+
var borderTop = getHorizontalBorder(table, sel.firstRow, sel, 'borderTop');
|
|
14
|
+
var borderRight = getVerticalBorder(table, sel.lastColumn, sel, 'borderRight');
|
|
15
|
+
var borderBottom = getHorizontalBorder(table, sel.lastRow, sel, 'borderBottom');
|
|
16
|
+
var borderLeft = getVerticalBorder(table, sel.firstColumn, sel, 'borderLeft');
|
|
17
|
+
setBorder(firstCell.format, 'borderTop', borderTop);
|
|
18
|
+
setBorder(firstCell.format, 'borderRight', borderRight);
|
|
19
|
+
setBorder(firstCell.format, 'borderBottom', borderBottom);
|
|
20
|
+
setBorder(firstCell.format, 'borderLeft', borderLeft);
|
|
12
21
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
13
22
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
14
23
|
var cell = table.rows[rowIndex].cells[colIndex];
|
|
@@ -22,5 +31,31 @@ define(["require", "exports", "./canMergeCells", "roosterjs-content-model-dom"],
|
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
exports.mergeTableCells = mergeTableCells;
|
|
34
|
+
function getHorizontalBorder(table, rowIndex, sel, borderKey) {
|
|
35
|
+
var border = table.rows[rowIndex].cells[sel.firstColumn].format[borderKey];
|
|
36
|
+
return border &&
|
|
37
|
+
table.rows[rowIndex].cells
|
|
38
|
+
.slice(sel.firstColumn, sel.lastColumn + 1)
|
|
39
|
+
.every(function (cell) { return cell.format[borderKey] == border; })
|
|
40
|
+
? border
|
|
41
|
+
: undefined;
|
|
42
|
+
}
|
|
43
|
+
function getVerticalBorder(table, columnIndex, sel, borderKey) {
|
|
44
|
+
var border = table.rows[sel.firstRow].cells[columnIndex].format[borderKey];
|
|
45
|
+
return border &&
|
|
46
|
+
table.rows
|
|
47
|
+
.slice(sel.firstRow, sel.lastRow + 1)
|
|
48
|
+
.every(function (row) { return row.cells[columnIndex].format[borderKey] == border; })
|
|
49
|
+
? border
|
|
50
|
+
: undefined;
|
|
51
|
+
}
|
|
52
|
+
function setBorder(format, borderKey, border) {
|
|
53
|
+
if (border) {
|
|
54
|
+
format[borderKey] = border;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
delete format[borderKey];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
25
60
|
});
|
|
26
61
|
//# sourceMappingURL=mergeTableCells.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTableCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableCells.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"mergeTableCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableCells.ts"],"names":[],"mappings":";;;;IAOA;;OAEG;IACH,SAAgB,eAAe,CAAC,KAAsC;QAClE,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IACI,GAAG;YACH,IAAA,2CAAa,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,EACvF;YACE,IAAM,SAAS,GAAG,IAAA,yCAAW,EAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;YAC/E,IAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;YAC7E,IAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;YACjF,IAAM,YAAY,GAAG,mBAAmB,CAA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AAC,WAAW,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE7E,OAAO,MAAM;YACT,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK;iBACrB,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC;iBAC1C,KAAK,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,EAAhC,CAAgC,CAAC;YACpD,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAC;IACpB,CAAC;IAED,SAAS,iBAAiB,CACtB,KAAsC,EACtC,WAAmB,EACnB,GAA0C,EAC1C,SAAoB;QAEpB,IAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE7E,OAAO,MAAM;YACT,KAAK,CAAC,IAAI;iBACL,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC;iBACpC,KAAK,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,EAAlD,CAAkD,CAAC;YACrE,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAC;IACpB,CAAC;IAED,SAAS,SAAS,CACd,MAAmC,EACnC,SAAoB,EACpB,MAA0B;QAE1B,IAAI,MAAM,EAAE;YACR,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;SAC9B;aAAM;YACH,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC;SAC5B;IACL,CAAC","sourcesContent":["import { getSelectedCells, mutateBlock, canMergeCells } from 'roosterjs-content-model-dom';\nimport type {\n BorderKey,\n ContentModelTableCellFormat,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableCells(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (\n sel &&\n canMergeCells(table.rows, sel.firstRow, sel.firstColumn, sel.lastRow, sel.lastColumn)\n ) {\n const firstCell = mutateBlock(table.rows[sel.firstRow].cells[sel.firstColumn]);\n const borderTop = getHorizontalBorder(table, sel.firstRow, sel, 'borderTop');\n const borderRight = getVerticalBorder(table, sel.lastColumn, sel, 'borderRight');\n const borderBottom = getHorizontalBorder(table, sel.lastRow, sel, 'borderBottom');\n const borderLeft = getVerticalBorder(table, sel.firstColumn, sel, 'borderLeft');\n\n setBorder(firstCell.format, 'borderTop', borderTop);\n setBorder(firstCell.format, 'borderRight', borderRight);\n setBorder(firstCell.format, 'borderBottom', borderBottom);\n setBorder(firstCell.format, 'borderLeft', borderLeft);\n\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = table.rows[rowIndex].cells[colIndex];\n\n if (cell) {\n const mutableCell = mutateBlock(cell);\n\n mutableCell.spanLeft = colIndex > sel.firstColumn;\n mutableCell.spanAbove = rowIndex > sel.firstRow;\n }\n }\n }\n }\n}\n\nfunction getHorizontalBorder(\n table: ShallowMutableContentModelTable,\n rowIndex: number,\n sel: { firstColumn: number; lastColumn: number },\n borderKey: BorderKey\n) {\n const border = table.rows[rowIndex].cells[sel.firstColumn].format[borderKey];\n\n return border &&\n table.rows[rowIndex].cells\n .slice(sel.firstColumn, sel.lastColumn + 1)\n .every(cell => cell.format[borderKey] == border)\n ? border\n : undefined;\n}\n\nfunction getVerticalBorder(\n table: ShallowMutableContentModelTable,\n columnIndex: number,\n sel: { firstRow: number; lastRow: number },\n borderKey: BorderKey\n) {\n const border = table.rows[sel.firstRow].cells[columnIndex].format[borderKey];\n\n return border &&\n table.rows\n .slice(sel.firstRow, sel.lastRow + 1)\n .every(row => row.cells[columnIndex].format[borderKey] == border)\n ? border\n : undefined;\n}\n\nfunction setBorder(\n format: ContentModelTableCellFormat,\n borderKey: BorderKey,\n border: string | undefined\n) {\n if (border) {\n format[borderKey] = border;\n } else {\n delete format[borderKey];\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_dom_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.mergeTableColumn = void 0;
|
|
@@ -15,7 +15,7 @@ define(["require", "exports", "./canMergeCells", "roosterjs-content-model-dom"],
|
|
|
15
15
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
16
16
|
var cell = (_a = table.rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells[mergingColIndex];
|
|
17
17
|
if (cell &&
|
|
18
|
-
(0,
|
|
18
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, rowIndex, mergingColIndex - 1, rowIndex, mergingColIndex)) {
|
|
19
19
|
(0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanLeft = true;
|
|
20
20
|
var newSelectedCol = mergingColIndex;
|
|
21
21
|
while ((_c = (_b = table.rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[newSelectedCol]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableColumn.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"mergeTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableColumn.ts"],"names":[],"mappings":";;;;IAMA;;OAEG;IACH,SAAgB,gBAAgB,CAC5B,KA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;4BACT,IAAA,yCAAW,EAAC,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;yBAC1C;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IAzCD,4CAyCC","sourcesContent":["import { getSelectedCells, mutateBlock, canMergeCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalMergeOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalMergeOperation\n) {\n const sel = getSelectedCells(table);\n const mergeLeft = operation == 'mergeLeft';\n\n if (sel) {\n const mergingColIndex = mergeLeft ? sel.firstColumn : sel.lastColumn + 1;\n\n if (mergingColIndex > 0 && mergingColIndex < table.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = table.rows[rowIndex]?.cells[mergingColIndex];\n\n if (\n cell &&\n canMergeCells(\n table.rows,\n rowIndex,\n mergingColIndex - 1,\n rowIndex,\n mergingColIndex\n )\n ) {\n mutateBlock(cell).spanLeft = true;\n\n let newSelectedCol = mergingColIndex;\n\n while (table.rows[rowIndex]?.cells[newSelectedCol]?.spanLeft) {\n mutateBlock(table.rows[rowIndex].cells[newSelectedCol]);\n newSelectedCol--;\n }\n\n const newCell = table.rows[rowIndex]?.cells[newSelectedCol];\n if (newCell) {\n mutateBlock(newCell).isSelected = true;\n }\n }\n }\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_dom_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.mergeTableRow = void 0;
|
|
@@ -15,7 +15,7 @@ define(["require", "exports", "./canMergeCells", "roosterjs-content-model-dom"],
|
|
|
15
15
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
16
16
|
var cell = table.rows[mergingRowIndex].cells[colIndex];
|
|
17
17
|
if (cell &&
|
|
18
|
-
(0,
|
|
18
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, mergingRowIndex - 1, colIndex, mergingRowIndex, colIndex)) {
|
|
19
19
|
(0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanAbove = true;
|
|
20
20
|
var newSelectedRow = mergingRowIndex;
|
|
21
21
|
while ((_b = (_a = table.rows[newSelectedRow]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableRow.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"mergeTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableRow.ts"],"names":[],"mappings":";;;;IAMA;;OAEG;IACH,SAAgB,aAAa,CACzB,KAAsC,EACtC,SAAsC;;QAEtC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAM,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC;YAEpE,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5D,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE;oBACzE,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAEzD,IACI,IAAI;wBACJ,IAAA,2CAAa,EACT,KAAK,CAAC,IAAI,EACV,eAAe,GAAG,CAAC,EACnB,QAAQ,EACR,eAAe,EACf,QAAQ,CACX,EACH;wBACE,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC;wBAEnC,IAAI,cAAc,GAAG,eAAe,CAAC;wBAErC,OAAO,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,EAAE;4BAC3D,IAAA,yCAAW,EAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;4BACxD,cAAc,EAAE,CAAC;yBACpB;wBAED,IAAM,OAAO,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;wBAE5D,IAAI,OAAO,EAAE;4BACT,IAAA,yCAAW,EAAC,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;yBAC1C;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IA1CD,sCA0CC","sourcesContent":["import { getSelectedCells, mutateBlock, canMergeCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalMergeOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalMergeOperation\n) {\n const sel = getSelectedCells(table);\n const mergeAbove = operation == 'mergeAbove';\n\n if (sel) {\n const mergingRowIndex = mergeAbove ? sel.firstRow : sel.lastRow + 1;\n\n if (mergingRowIndex > 0 && mergingRowIndex < table.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = table.rows[mergingRowIndex].cells[colIndex];\n\n if (\n cell &&\n canMergeCells(\n table.rows,\n mergingRowIndex - 1,\n colIndex,\n mergingRowIndex,\n colIndex\n )\n ) {\n mutateBlock(cell).spanAbove = true;\n\n let newSelectedRow = mergingRowIndex;\n\n while (table.rows[newSelectedRow]?.cells[colIndex]?.spanAbove) {\n mutateBlock(table.rows[newSelectedRow].cells[colIndex]);\n newSelectedRow--;\n }\n\n const newCell = table.rows[newSelectedRow]?.cells[colIndex];\n\n if (newCell) {\n mutateBlock(newCell).isSelected = true;\n }\n }\n }\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IEditor, Border, BorderOperations } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Operations to apply border
|
|
4
|
+
* Remove the targeted borders instead if they all already match the requested format.
|
|
4
5
|
* @param editor The editor instance
|
|
5
6
|
* @param border The border to apply
|
|
6
7
|
* @param operation The operation to apply
|
|
@@ -4,13 +4,15 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
4
4
|
exports.applyTableBorderFormat = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* Operations to apply border
|
|
7
|
+
* Remove the targeted borders instead if they all already match the requested format.
|
|
7
8
|
* @param editor The editor instance
|
|
8
9
|
* @param border The border to apply
|
|
9
10
|
* @param operation The operation to apply
|
|
10
11
|
*/
|
|
11
12
|
function applyTableBorderFormat(editor, border, operation) {
|
|
12
13
|
editor.formatContentModel(function (model) {
|
|
13
|
-
var
|
|
14
|
+
var e_1, _a;
|
|
15
|
+
var _b = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 1), tableModel = _b[0];
|
|
14
16
|
if (tableModel) {
|
|
15
17
|
var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(tableModel);
|
|
16
18
|
var perimeter = {
|
|
@@ -54,6 +56,10 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
54
56
|
// undefined is treated as Left to Right
|
|
55
57
|
var isRtl = tableModel.format.direction == 'rtl';
|
|
56
58
|
if (sel) {
|
|
59
|
+
var borderUpdates_2 = [];
|
|
60
|
+
var collectBorderFormat = function (cell, positions) {
|
|
61
|
+
borderUpdates_2.push({ cell: cell, positions: positions });
|
|
62
|
+
};
|
|
57
63
|
var operations = [operation];
|
|
58
64
|
while (operations.length) {
|
|
59
65
|
switch (operations.pop()) {
|
|
@@ -73,7 +79,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
73
79
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
74
80
|
var cell = tableModel.rows[rowIndex].cells[colIndex];
|
|
75
81
|
// Format cells - All borders
|
|
76
|
-
|
|
82
|
+
collectBorderFormat(cell, allBorders);
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
// Format perimeter
|
|
@@ -87,7 +93,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
87
93
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
88
94
|
var cell = tableModel.rows[rowIndex].cells[isRtl ? sel.lastColumn : sel.firstColumn];
|
|
89
95
|
// Format cells - Left border
|
|
90
|
-
|
|
96
|
+
collectBorderFormat(cell, leftBorder);
|
|
91
97
|
}
|
|
92
98
|
// Format perimeter
|
|
93
99
|
isRtl ? (perimeter.Right = true) : (perimeter.Left = true);
|
|
@@ -97,7 +103,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
97
103
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
98
104
|
var cell = tableModel.rows[rowIndex].cells[isRtl ? sel.firstColumn : sel.lastColumn];
|
|
99
105
|
// Format cells - Right border
|
|
100
|
-
|
|
106
|
+
collectBorderFormat(cell, rightBorder);
|
|
101
107
|
}
|
|
102
108
|
// Format perimeter
|
|
103
109
|
isRtl ? (perimeter.Left = true) : (perimeter.Right = true);
|
|
@@ -107,7 +113,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
107
113
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
108
114
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
109
115
|
// Format cells - Top border
|
|
110
|
-
|
|
116
|
+
collectBorderFormat(cell, topBorder);
|
|
111
117
|
}
|
|
112
118
|
// Format perimeter
|
|
113
119
|
perimeter.Top = true;
|
|
@@ -117,7 +123,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
117
123
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
118
124
|
var cell = tableModel.rows[sel.lastRow].cells[colIndex];
|
|
119
125
|
// Format cells - Bottom border
|
|
120
|
-
|
|
126
|
+
collectBorderFormat(cell, bottomBorder);
|
|
121
127
|
}
|
|
122
128
|
// Format perimeter
|
|
123
129
|
perimeter.Bottom = true;
|
|
@@ -132,43 +138,37 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
132
138
|
}
|
|
133
139
|
// Single column selection
|
|
134
140
|
if (singleCol) {
|
|
135
|
-
|
|
141
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstColumn], ['borderBottom']);
|
|
136
142
|
for (var rowIndex = sel.firstRow + 1; rowIndex <= sel.lastRow - 1; rowIndex++) {
|
|
137
143
|
var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
|
|
138
|
-
|
|
139
|
-
'borderTop',
|
|
140
|
-
'borderBottom',
|
|
141
|
-
]);
|
|
144
|
+
collectBorderFormat(cell, ['borderTop', 'borderBottom']);
|
|
142
145
|
}
|
|
143
|
-
|
|
146
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[sel.firstColumn], ['borderTop']);
|
|
144
147
|
break;
|
|
145
148
|
}
|
|
146
149
|
// Single row selection
|
|
147
150
|
if (singleRow) {
|
|
148
|
-
|
|
151
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderRight']);
|
|
149
152
|
for (var colIndex = sel.firstColumn + 1; colIndex <= sel.lastColumn - 1; colIndex++) {
|
|
150
153
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
151
|
-
|
|
152
|
-
'borderLeft',
|
|
153
|
-
'borderRight',
|
|
154
|
-
]);
|
|
154
|
+
collectBorderFormat(cell, ['borderLeft', 'borderRight']);
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderLeft']);
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
159
|
// For multiple rows and columns selections
|
|
160
160
|
// Top left cell
|
|
161
|
-
|
|
161
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderBottom', 'borderRight']);
|
|
162
162
|
// Top right cell
|
|
163
|
-
|
|
163
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderBottom', 'borderLeft']);
|
|
164
164
|
// Bottom left cell
|
|
165
|
-
|
|
165
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderTop', 'borderRight']);
|
|
166
166
|
// Bottom right cell
|
|
167
|
-
|
|
167
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderTop', 'borderLeft']);
|
|
168
168
|
// First row
|
|
169
169
|
for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
|
|
170
170
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
171
|
-
|
|
171
|
+
collectBorderFormat(cell, [
|
|
172
172
|
'borderBottom',
|
|
173
173
|
'borderLeft',
|
|
174
174
|
'borderRight',
|
|
@@ -177,7 +177,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
177
177
|
// Last row
|
|
178
178
|
for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
|
|
179
179
|
var cell = tableModel.rows[sel.lastRow].cells[colIndex];
|
|
180
|
-
|
|
180
|
+
collectBorderFormat(cell, [
|
|
181
181
|
'borderTop',
|
|
182
182
|
'borderLeft',
|
|
183
183
|
'borderRight',
|
|
@@ -186,7 +186,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
186
186
|
// First column
|
|
187
187
|
for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
|
|
188
188
|
var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
|
|
189
|
-
|
|
189
|
+
collectBorderFormat(cell, [
|
|
190
190
|
'borderTop',
|
|
191
191
|
'borderBottom',
|
|
192
192
|
isRtl ? 'borderLeft' : 'borderRight',
|
|
@@ -195,7 +195,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
195
195
|
// Last column
|
|
196
196
|
for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
|
|
197
197
|
var cell = tableModel.rows[rowIndex].cells[sel.lastColumn];
|
|
198
|
-
|
|
198
|
+
collectBorderFormat(cell, [
|
|
199
199
|
'borderTop',
|
|
200
200
|
'borderBottom',
|
|
201
201
|
isRtl ? 'borderRight' : 'borderLeft',
|
|
@@ -219,6 +219,26 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
219
219
|
break;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
+
// Compare before changing any cells, and only consider borders targeted by
|
|
223
|
+
// this operation. Normalize CSS so DOM colors (rgb) also match hex input.
|
|
224
|
+
if (operation != 'noBorders' &&
|
|
225
|
+
borderUpdates_2.length > 0 &&
|
|
226
|
+
hasMatchingBorders(borderUpdates_2, borderFormat)) {
|
|
227
|
+
borderFormat = '';
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
for (var borderUpdates_1 = (0, tslib_1.__values)(borderUpdates_2), borderUpdates_1_1 = borderUpdates_1.next(); !borderUpdates_1_1.done; borderUpdates_1_1 = borderUpdates_1.next()) {
|
|
231
|
+
var _c = borderUpdates_1_1.value, cell = _c.cell, positions = _c.positions;
|
|
232
|
+
applyBorderFormat(cell, borderFormat, positions);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
236
|
+
finally {
|
|
237
|
+
try {
|
|
238
|
+
if (borderUpdates_1_1 && !borderUpdates_1_1.done && (_a = borderUpdates_1.return)) _a.call(borderUpdates_1);
|
|
239
|
+
}
|
|
240
|
+
finally { if (e_1) throw e_1.error; }
|
|
241
|
+
}
|
|
222
242
|
//Format perimeter if necessary or possible
|
|
223
243
|
modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);
|
|
224
244
|
}
|
|
@@ -237,6 +257,64 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
|
|
|
237
257
|
});
|
|
238
258
|
}
|
|
239
259
|
exports.applyTableBorderFormat = applyTableBorderFormat;
|
|
260
|
+
/**
|
|
261
|
+
* Check targeted borders without repeatedly parsing identical CSS values.
|
|
262
|
+
* @param borderUpdates The borders to compare
|
|
263
|
+
* @param borderFormat The requested border format
|
|
264
|
+
*/
|
|
265
|
+
function hasMatchingBorders(borderUpdates, borderFormat) {
|
|
266
|
+
var e_2, _a, e_3, _b;
|
|
267
|
+
var matchingBorders = new Set();
|
|
268
|
+
try {
|
|
269
|
+
for (var borderUpdates_3 = (0, tslib_1.__values)(borderUpdates), borderUpdates_3_1 = borderUpdates_3.next(); !borderUpdates_3_1.done; borderUpdates_3_1 = borderUpdates_3.next()) {
|
|
270
|
+
var _c = borderUpdates_3_1.value, cell = _c.cell, positions = _c.positions;
|
|
271
|
+
try {
|
|
272
|
+
for (var positions_1 = (e_3 = void 0, (0, tslib_1.__values)(positions)), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
|
|
273
|
+
var pos = positions_1_1.value;
|
|
274
|
+
var value = cell.format[pos] || '';
|
|
275
|
+
// Exact matches need no CSS parsing. Equivalent values are parsed only once.
|
|
276
|
+
if (value == borderFormat || matchingBorders.has(value)) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (!areSameBorders(value, borderFormat)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
matchingBorders.add(value);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
286
|
+
finally {
|
|
287
|
+
try {
|
|
288
|
+
if (positions_1_1 && !positions_1_1.done && (_b = positions_1.return)) _b.call(positions_1);
|
|
289
|
+
}
|
|
290
|
+
finally { if (e_3) throw e_3.error; }
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
295
|
+
finally {
|
|
296
|
+
try {
|
|
297
|
+
if (borderUpdates_3_1 && !borderUpdates_3_1.done && (_a = borderUpdates_3.return)) _a.call(borderUpdates_3);
|
|
298
|
+
}
|
|
299
|
+
finally { if (e_2) throw e_2.error; }
|
|
300
|
+
}
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Compare border components, parsing colors to account for equivalent hex and RGB values.
|
|
305
|
+
*/
|
|
306
|
+
function areSameBorders(border1, border2) {
|
|
307
|
+
var values1 = (0, roosterjs_content_model_dom_1.extractBorderValues)(border1);
|
|
308
|
+
var values2 = (0, roosterjs_content_model_dom_1.extractBorderValues)(border2);
|
|
309
|
+
var color1 = values1.color || '';
|
|
310
|
+
var color2 = values2.color || '';
|
|
311
|
+
var rgb1 = (0, roosterjs_content_model_dom_1.parseColor)(color1);
|
|
312
|
+
var rgb2 = (0, roosterjs_content_model_dom_1.parseColor)(color2);
|
|
313
|
+
return (values1.width == values2.width &&
|
|
314
|
+
values1.style == values2.style &&
|
|
315
|
+
(color1 == color2 ||
|
|
316
|
+
(!!rgb1 && !!rgb2 && rgb1[0] == rgb2[0] && rgb1[1] == rgb2[1] && rgb1[2] == rgb2[2])));
|
|
317
|
+
}
|
|
240
318
|
/**
|
|
241
319
|
* @internal
|
|
242
320
|
* Apply border format to a cell
|