roosterjs 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/dist/rooster-adapter-amd-min.js +1 -1
- package/dist/rooster-adapter-amd-min.js.map +1 -1
- package/dist/rooster-adapter-amd.js +1 -1
- package/dist/rooster-adapter-amd.js.map +1 -1
- package/dist/rooster-adapter-min.js +1 -1
- package/dist/rooster-adapter-min.js.map +1 -1
- package/dist/rooster-adapter.js +1 -1
- package/dist/rooster-adapter.js.map +1 -1
- package/dist/rooster-amd-min.js +1 -1
- package/dist/rooster-amd-min.js.map +1 -1
- package/dist/rooster-amd.d.ts +96 -8
- package/dist/rooster-amd.js +772 -290
- package/dist/rooster-amd.js.map +1 -1
- package/dist/rooster-min.js +1 -1
- package/dist/rooster-min.js.map +1 -1
- package/dist/rooster-react-amd-min.js +1 -1
- package/dist/rooster-react-amd-min.js.map +1 -1
- package/dist/rooster-react-amd.d.ts +1 -1
- package/dist/rooster-react-amd.js +5 -7
- package/dist/rooster-react-amd.js.map +1 -1
- package/dist/rooster-react-min.js +1 -1
- package/dist/rooster-react-min.js.map +1 -1
- package/dist/rooster-react.d.ts +1 -1
- package/dist/rooster-react.js +58 -60
- package/dist/rooster-react.js.map +1 -1
- package/dist/rooster.d.ts +96 -8
- package/dist/rooster.js +772 -290
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
package/dist/rooster-amd.js
CHANGED
|
@@ -2550,7 +2550,7 @@ exports["default"] = getDarkColor;
|
|
|
2550
2550
|
|
|
2551
2551
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2552
2552
|
exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = exports.formatTableWithContentModel = exports.createEditorContextForEntity = exports.clearSelectedCells = exports.insertTableColumn = exports.insertTableRow = exports.insertEntity = exports.toggleCode = exports.setParagraphMargin = exports.adjustImageSelection = exports.setImageAltText = exports.adjustLinkSelection = exports.removeLink = exports.insertLink = exports.clearFormat = exports.getFormatState = exports.changeImage = exports.setImageBoxShadow = exports.setImageBorder = exports.setSpacing = exports.toggleBlockQuote = exports.setHeadingLevel = exports.setDirection = exports.setAlignment = exports.setIndentation = exports.setListStartNumber = exports.setListStyle = exports.insertImage = exports.splitTextSegment = exports.changeCapitalization = exports.applySegmentFormat = exports.changeFontSize = exports.setTextColor = exports.setFontSize = exports.setFontName = exports.setBackgroundColor = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleUnderline = exports.toggleItalic = exports.toggleBold = exports.toggleNumbering = exports.toggleBullet = exports.applyTableBorderFormat = exports.editTable = exports.setTableCellShade = exports.formatTable = exports.insertTable = void 0;
|
|
2553
|
-
exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = void 0;
|
|
2553
|
+
exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.getTextDirection = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = void 0;
|
|
2554
2554
|
var insertTable_1 = __webpack_require__(/*! ./publicApi/table/insertTable */ "./packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts");
|
|
2555
2555
|
Object.defineProperty(exports, "insertTable", ({ enumerable: true, get: function () { return insertTable_1.insertTable; } }));
|
|
2556
2556
|
var formatTable_1 = __webpack_require__(/*! ./publicApi/table/formatTable */ "./packages/roosterjs-content-model-api/lib/publicApi/table/formatTable.ts");
|
|
@@ -2667,6 +2667,8 @@ var findListItemsInSameThread_1 = __webpack_require__(/*! ./modelApi/list/findLi
|
|
|
2667
2667
|
Object.defineProperty(exports, "findListItemsInSameThread", ({ enumerable: true, get: function () { return findListItemsInSameThread_1.findListItemsInSameThread; } }));
|
|
2668
2668
|
var setModelIndentation_1 = __webpack_require__(/*! ./modelApi/block/setModelIndentation */ "./packages/roosterjs-content-model-api/lib/modelApi/block/setModelIndentation.ts");
|
|
2669
2669
|
Object.defineProperty(exports, "setModelIndentation", ({ enumerable: true, get: function () { return setModelIndentation_1.setModelIndentation; } }));
|
|
2670
|
+
var setModelDirection_1 = __webpack_require__(/*! ./modelApi/block/setModelDirection */ "./packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts");
|
|
2671
|
+
Object.defineProperty(exports, "getTextDirection", ({ enumerable: true, get: function () { return setModelDirection_1.getTextDirection; } }));
|
|
2670
2672
|
var matchLink_1 = __webpack_require__(/*! ./modelApi/link/matchLink */ "./packages/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts");
|
|
2671
2673
|
Object.defineProperty(exports, "matchLink", ({ enumerable: true, get: function () { return matchLink_1.matchLink; } }));
|
|
2672
2674
|
var promoteLink_1 = __webpack_require__(/*! ./modelApi/link/promoteLink */ "./packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts");
|
|
@@ -2767,15 +2769,12 @@ exports.setModelAlignment = setModelAlignment;
|
|
|
2767
2769
|
"use strict";
|
|
2768
2770
|
|
|
2769
2771
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2770
|
-
exports.setModelDirection = void 0;
|
|
2772
|
+
exports.getTextDirection = exports.setModelDirection = void 0;
|
|
2771
2773
|
var findListItemsInSameThread_1 = __webpack_require__(/*! ../list/findListItemsInSameThread */ "./packages/roosterjs-content-model-api/lib/modelApi/list/findListItemsInSameThread.ts");
|
|
2772
2774
|
var splitSelectedParagraphByBr_1 = __webpack_require__(/*! ./splitSelectedParagraphByBr */ "./packages/roosterjs-content-model-api/lib/modelApi/block/splitSelectedParagraphByBr.ts");
|
|
2773
2775
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
var RTL_CHAR_REGEX = /[\u0590-\u05FF\u0600-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/g;
|
|
2777
|
-
var URL_CHAR_REGEX = /http\S+|www\S+|https\S+|<a\s+(?:[^>]*?\s+)?href=(["']).*?\1.*?>.*?<\/a>/g;
|
|
2778
|
-
var WHITESPACE_REGEX = /\s/g;
|
|
2776
|
+
var FIRST_STRONG_CHAR_REGEX = new RegExp('[\\p{L}\\u200E\\u200F]', 'u');
|
|
2777
|
+
var RTL_CHAR_REGEX = new RegExp('[\\u0590-\\u08FF\\u200F\\uFB1D-\\uFDFF\\uFE70-\\uFEFF\\u{10840}-\\u{10FFF}\\u{1E800}-\\u{1E95F}]', 'u');
|
|
2779
2778
|
/**
|
|
2780
2779
|
* @internal
|
|
2781
2780
|
*/
|
|
@@ -2853,29 +2852,29 @@ function setProperty(format, key, value) {
|
|
|
2853
2852
|
delete format[key];
|
|
2854
2853
|
}
|
|
2855
2854
|
}
|
|
2855
|
+
/**
|
|
2856
|
+
* Determine text direction from the first strong directional character
|
|
2857
|
+
* @param text Text to scan
|
|
2858
|
+
*/
|
|
2859
|
+
function getTextDirection(text) {
|
|
2860
|
+
var _a;
|
|
2861
|
+
var firstStrongChar = (_a = text.match(FIRST_STRONG_CHAR_REGEX)) === null || _a === void 0 ? void 0 : _a[0];
|
|
2862
|
+
return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;
|
|
2863
|
+
}
|
|
2864
|
+
exports.getTextDirection = getTextDirection;
|
|
2856
2865
|
// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character
|
|
2857
2866
|
function determineTextDirection(block) {
|
|
2867
|
+
return getTextDirection(getTextContent(block)) || 'ltr';
|
|
2868
|
+
}
|
|
2869
|
+
function getTextContent(block) {
|
|
2858
2870
|
if (block.blockType === 'Paragraph') {
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
if (!!innerText) {
|
|
2864
|
-
// Remove links
|
|
2865
|
-
innerText = innerText.replace(URL_CHAR_REGEX, '');
|
|
2866
|
-
// Remove whitespace
|
|
2867
|
-
innerText = innerText.replace(WHITESPACE_REGEX, '');
|
|
2868
|
-
var rtlMatches = innerText.match(RTL_CHAR_REGEX);
|
|
2869
|
-
var rtlCount = rtlMatches ? rtlMatches.length : 0;
|
|
2870
|
-
var ltrCount = innerText.length - rtlCount;
|
|
2871
|
-
return rtlCount > ltrCount ? 'rtl' : 'ltr';
|
|
2872
|
-
}
|
|
2873
|
-
else {
|
|
2874
|
-
return 'ltr'; // Default to LTR if no text is found
|
|
2875
|
-
}
|
|
2871
|
+
return block.segments.reduce(function (text, segment) { return text + (segment.segmentType === 'Text' ? segment.text : ''); }, '');
|
|
2872
|
+
}
|
|
2873
|
+
else if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(block, 'ListItem')) {
|
|
2874
|
+
return block.blocks.reduce(function (text, childBlock) { return text + getTextContent(childBlock); }, '');
|
|
2876
2875
|
}
|
|
2877
2876
|
else {
|
|
2878
|
-
return '
|
|
2877
|
+
return '';
|
|
2879
2878
|
}
|
|
2880
2879
|
}
|
|
2881
2880
|
|
|
@@ -4916,73 +4915,6 @@ function alignTableCellInternal(table, callback) {
|
|
|
4916
4915
|
}
|
|
4917
4916
|
|
|
4918
4917
|
|
|
4919
|
-
/***/ },
|
|
4920
|
-
|
|
4921
|
-
/***/ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts"
|
|
4922
|
-
/*!**********************************************************************************!*\
|
|
4923
|
-
!*** ./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts ***!
|
|
4924
|
-
\**********************************************************************************/
|
|
4925
|
-
(__unused_webpack_module, exports) {
|
|
4926
|
-
|
|
4927
|
-
"use strict";
|
|
4928
|
-
|
|
4929
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4930
|
-
exports.canMergeCells = void 0;
|
|
4931
|
-
/**
|
|
4932
|
-
* @internal
|
|
4933
|
-
*/
|
|
4934
|
-
function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
|
|
4935
|
-
var noSpanAbove = firstCol == lastCol ||
|
|
4936
|
-
rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
|
|
4937
|
-
var noSpanLeft = firstRow == lastRow ||
|
|
4938
|
-
rows.every(function (row, rowIndex) {
|
|
4939
|
-
return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
|
|
4940
|
-
});
|
|
4941
|
-
var noDifferentBelowSpan = rows[lastRow].cells
|
|
4942
|
-
.map(function (_, colIndex) {
|
|
4943
|
-
return colIndex >= firstCol && colIndex <= lastCol
|
|
4944
|
-
? getBelowSpanCount(rows, lastRow, colIndex)
|
|
4945
|
-
: -1;
|
|
4946
|
-
})
|
|
4947
|
-
.every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
|
|
4948
|
-
var noDifferentRightSpan = rows
|
|
4949
|
-
.map(function (_, rowIndex) {
|
|
4950
|
-
return rowIndex >= firstRow && rowIndex <= lastRow
|
|
4951
|
-
? getRightSpanCount(rows, rowIndex, lastCol)
|
|
4952
|
-
: -1;
|
|
4953
|
-
})
|
|
4954
|
-
.every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
|
|
4955
|
-
return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
|
|
4956
|
-
}
|
|
4957
|
-
exports.canMergeCells = canMergeCells;
|
|
4958
|
-
function getBelowSpanCount(rows, rowIndex, colIndex) {
|
|
4959
|
-
var _a, _b;
|
|
4960
|
-
var spanCount = 0;
|
|
4961
|
-
for (var row = rowIndex + 1; row < rows.length; row++) {
|
|
4962
|
-
if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
4963
|
-
spanCount++;
|
|
4964
|
-
}
|
|
4965
|
-
else {
|
|
4966
|
-
break;
|
|
4967
|
-
}
|
|
4968
|
-
}
|
|
4969
|
-
return spanCount;
|
|
4970
|
-
}
|
|
4971
|
-
function getRightSpanCount(rows, rowIndex, colIndex) {
|
|
4972
|
-
var _a, _b, _c;
|
|
4973
|
-
var spanCount = 0;
|
|
4974
|
-
for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
|
|
4975
|
-
if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
|
|
4976
|
-
spanCount++;
|
|
4977
|
-
}
|
|
4978
|
-
else {
|
|
4979
|
-
break;
|
|
4980
|
-
}
|
|
4981
|
-
}
|
|
4982
|
-
return spanCount;
|
|
4983
|
-
}
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
4918
|
/***/ },
|
|
4987
4919
|
|
|
4988
4920
|
/***/ "./packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"
|
|
@@ -5272,7 +5204,8 @@ function insertTableColumn(table, operation) {
|
|
|
5272
5204
|
for (var i = sel === null || sel === void 0 ? void 0 : sel.firstColumn; i <= sel.lastColumn; i++) {
|
|
5273
5205
|
table.rows.forEach(function (row) {
|
|
5274
5206
|
var cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];
|
|
5275
|
-
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(
|
|
5207
|
+
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(false, //spanLeft
|
|
5208
|
+
cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
|
|
5276
5209
|
(0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
|
|
5277
5210
|
newCell.isSelected = true;
|
|
5278
5211
|
row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);
|
|
@@ -5315,7 +5248,8 @@ function insertTableRow(table, operation) {
|
|
|
5315
5248
|
table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {
|
|
5316
5249
|
format: (0, tslib_1.__assign)({}, sourceRow.format),
|
|
5317
5250
|
cells: sourceRow.cells.map(function (cell) {
|
|
5318
|
-
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft,
|
|
5251
|
+
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, false, //spanAbove
|
|
5252
|
+
cell.isHeader, cell.format, cell.dataset);
|
|
5319
5253
|
(0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
|
|
5320
5254
|
newCell.isSelected = true;
|
|
5321
5255
|
return newCell;
|
|
@@ -5340,7 +5274,6 @@ exports.insertTableRow = insertTableRow;
|
|
|
5340
5274
|
|
|
5341
5275
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5342
5276
|
exports.mergeTableCells = void 0;
|
|
5343
|
-
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts");
|
|
5344
5277
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
5345
5278
|
/**
|
|
5346
5279
|
* @internal
|
|
@@ -5348,7 +5281,16 @@ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-mo
|
|
|
5348
5281
|
function mergeTableCells(table) {
|
|
5349
5282
|
var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(table);
|
|
5350
5283
|
if (sel &&
|
|
5351
|
-
(0,
|
|
5284
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, sel.firstRow, sel.firstColumn, sel.lastRow, sel.lastColumn)) {
|
|
5285
|
+
var firstCell = (0, roosterjs_content_model_dom_1.mutateBlock)(table.rows[sel.firstRow].cells[sel.firstColumn]);
|
|
5286
|
+
var borderTop = getHorizontalBorder(table, sel.firstRow, sel, 'borderTop');
|
|
5287
|
+
var borderRight = getVerticalBorder(table, sel.lastColumn, sel, 'borderRight');
|
|
5288
|
+
var borderBottom = getHorizontalBorder(table, sel.lastRow, sel, 'borderBottom');
|
|
5289
|
+
var borderLeft = getVerticalBorder(table, sel.firstColumn, sel, 'borderLeft');
|
|
5290
|
+
setBorder(firstCell.format, 'borderTop', borderTop);
|
|
5291
|
+
setBorder(firstCell.format, 'borderRight', borderRight);
|
|
5292
|
+
setBorder(firstCell.format, 'borderBottom', borderBottom);
|
|
5293
|
+
setBorder(firstCell.format, 'borderLeft', borderLeft);
|
|
5352
5294
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
5353
5295
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
5354
5296
|
var cell = table.rows[rowIndex].cells[colIndex];
|
|
@@ -5362,6 +5304,32 @@ function mergeTableCells(table) {
|
|
|
5362
5304
|
}
|
|
5363
5305
|
}
|
|
5364
5306
|
exports.mergeTableCells = mergeTableCells;
|
|
5307
|
+
function getHorizontalBorder(table, rowIndex, sel, borderKey) {
|
|
5308
|
+
var border = table.rows[rowIndex].cells[sel.firstColumn].format[borderKey];
|
|
5309
|
+
return border &&
|
|
5310
|
+
table.rows[rowIndex].cells
|
|
5311
|
+
.slice(sel.firstColumn, sel.lastColumn + 1)
|
|
5312
|
+
.every(function (cell) { return cell.format[borderKey] == border; })
|
|
5313
|
+
? border
|
|
5314
|
+
: undefined;
|
|
5315
|
+
}
|
|
5316
|
+
function getVerticalBorder(table, columnIndex, sel, borderKey) {
|
|
5317
|
+
var border = table.rows[sel.firstRow].cells[columnIndex].format[borderKey];
|
|
5318
|
+
return border &&
|
|
5319
|
+
table.rows
|
|
5320
|
+
.slice(sel.firstRow, sel.lastRow + 1)
|
|
5321
|
+
.every(function (row) { return row.cells[columnIndex].format[borderKey] == border; })
|
|
5322
|
+
? border
|
|
5323
|
+
: undefined;
|
|
5324
|
+
}
|
|
5325
|
+
function setBorder(format, borderKey, border) {
|
|
5326
|
+
if (border) {
|
|
5327
|
+
format[borderKey] = border;
|
|
5328
|
+
}
|
|
5329
|
+
else {
|
|
5330
|
+
delete format[borderKey];
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5365
5333
|
|
|
5366
5334
|
|
|
5367
5335
|
/***/ },
|
|
@@ -5376,7 +5344,6 @@ exports.mergeTableCells = mergeTableCells;
|
|
|
5376
5344
|
|
|
5377
5345
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5378
5346
|
exports.mergeTableColumn = void 0;
|
|
5379
|
-
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts");
|
|
5380
5347
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
5381
5348
|
/**
|
|
5382
5349
|
* @internal
|
|
@@ -5391,7 +5358,7 @@ function mergeTableColumn(table, operation) {
|
|
|
5391
5358
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
5392
5359
|
var cell = (_a = table.rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells[mergingColIndex];
|
|
5393
5360
|
if (cell &&
|
|
5394
|
-
(0,
|
|
5361
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, rowIndex, mergingColIndex - 1, rowIndex, mergingColIndex)) {
|
|
5395
5362
|
(0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanLeft = true;
|
|
5396
5363
|
var newSelectedCol = mergingColIndex;
|
|
5397
5364
|
while ((_c = (_b = table.rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[newSelectedCol]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
|
|
@@ -5422,7 +5389,6 @@ exports.mergeTableColumn = mergeTableColumn;
|
|
|
5422
5389
|
|
|
5423
5390
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5424
5391
|
exports.mergeTableRow = void 0;
|
|
5425
|
-
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts");
|
|
5426
5392
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
5427
5393
|
/**
|
|
5428
5394
|
* @internal
|
|
@@ -5437,7 +5403,7 @@ function mergeTableRow(table, operation) {
|
|
|
5437
5403
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
5438
5404
|
var cell = table.rows[mergingRowIndex].cells[colIndex];
|
|
5439
5405
|
if (cell &&
|
|
5440
|
-
(0,
|
|
5406
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, mergingRowIndex - 1, colIndex, mergingRowIndex, colIndex)) {
|
|
5441
5407
|
(0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanAbove = true;
|
|
5442
5408
|
var newSelectedRow = mergingRowIndex;
|
|
5443
5409
|
while ((_b = (_a = table.rows[newSelectedRow]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
@@ -7419,13 +7385,15 @@ var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.m
|
|
|
7419
7385
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
7420
7386
|
/**
|
|
7421
7387
|
* Operations to apply border
|
|
7388
|
+
* Remove the targeted borders instead if they all already match the requested format.
|
|
7422
7389
|
* @param editor The editor instance
|
|
7423
7390
|
* @param border The border to apply
|
|
7424
7391
|
* @param operation The operation to apply
|
|
7425
7392
|
*/
|
|
7426
7393
|
function applyTableBorderFormat(editor, border, operation) {
|
|
7427
7394
|
editor.formatContentModel(function (model) {
|
|
7428
|
-
var
|
|
7395
|
+
var e_1, _a;
|
|
7396
|
+
var _b = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 1), tableModel = _b[0];
|
|
7429
7397
|
if (tableModel) {
|
|
7430
7398
|
var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(tableModel);
|
|
7431
7399
|
var perimeter = {
|
|
@@ -7469,6 +7437,10 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7469
7437
|
// undefined is treated as Left to Right
|
|
7470
7438
|
var isRtl = tableModel.format.direction == 'rtl';
|
|
7471
7439
|
if (sel) {
|
|
7440
|
+
var borderUpdates_2 = [];
|
|
7441
|
+
var collectBorderFormat = function (cell, positions) {
|
|
7442
|
+
borderUpdates_2.push({ cell: cell, positions: positions });
|
|
7443
|
+
};
|
|
7472
7444
|
var operations = [operation];
|
|
7473
7445
|
while (operations.length) {
|
|
7474
7446
|
switch (operations.pop()) {
|
|
@@ -7488,7 +7460,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7488
7460
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
7489
7461
|
var cell = tableModel.rows[rowIndex].cells[colIndex];
|
|
7490
7462
|
// Format cells - All borders
|
|
7491
|
-
|
|
7463
|
+
collectBorderFormat(cell, allBorders);
|
|
7492
7464
|
}
|
|
7493
7465
|
}
|
|
7494
7466
|
// Format perimeter
|
|
@@ -7502,7 +7474,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7502
7474
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
7503
7475
|
var cell = tableModel.rows[rowIndex].cells[isRtl ? sel.lastColumn : sel.firstColumn];
|
|
7504
7476
|
// Format cells - Left border
|
|
7505
|
-
|
|
7477
|
+
collectBorderFormat(cell, leftBorder);
|
|
7506
7478
|
}
|
|
7507
7479
|
// Format perimeter
|
|
7508
7480
|
isRtl ? (perimeter.Right = true) : (perimeter.Left = true);
|
|
@@ -7512,7 +7484,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7512
7484
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
7513
7485
|
var cell = tableModel.rows[rowIndex].cells[isRtl ? sel.firstColumn : sel.lastColumn];
|
|
7514
7486
|
// Format cells - Right border
|
|
7515
|
-
|
|
7487
|
+
collectBorderFormat(cell, rightBorder);
|
|
7516
7488
|
}
|
|
7517
7489
|
// Format perimeter
|
|
7518
7490
|
isRtl ? (perimeter.Left = true) : (perimeter.Right = true);
|
|
@@ -7522,7 +7494,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7522
7494
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
7523
7495
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
7524
7496
|
// Format cells - Top border
|
|
7525
|
-
|
|
7497
|
+
collectBorderFormat(cell, topBorder);
|
|
7526
7498
|
}
|
|
7527
7499
|
// Format perimeter
|
|
7528
7500
|
perimeter.Top = true;
|
|
@@ -7532,7 +7504,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7532
7504
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
7533
7505
|
var cell = tableModel.rows[sel.lastRow].cells[colIndex];
|
|
7534
7506
|
// Format cells - Bottom border
|
|
7535
|
-
|
|
7507
|
+
collectBorderFormat(cell, bottomBorder);
|
|
7536
7508
|
}
|
|
7537
7509
|
// Format perimeter
|
|
7538
7510
|
perimeter.Bottom = true;
|
|
@@ -7547,43 +7519,37 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7547
7519
|
}
|
|
7548
7520
|
// Single column selection
|
|
7549
7521
|
if (singleCol) {
|
|
7550
|
-
|
|
7522
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstColumn], ['borderBottom']);
|
|
7551
7523
|
for (var rowIndex = sel.firstRow + 1; rowIndex <= sel.lastRow - 1; rowIndex++) {
|
|
7552
7524
|
var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
|
|
7553
|
-
|
|
7554
|
-
'borderTop',
|
|
7555
|
-
'borderBottom',
|
|
7556
|
-
]);
|
|
7525
|
+
collectBorderFormat(cell, ['borderTop', 'borderBottom']);
|
|
7557
7526
|
}
|
|
7558
|
-
|
|
7527
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[sel.firstColumn], ['borderTop']);
|
|
7559
7528
|
break;
|
|
7560
7529
|
}
|
|
7561
7530
|
// Single row selection
|
|
7562
7531
|
if (singleRow) {
|
|
7563
|
-
|
|
7532
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderRight']);
|
|
7564
7533
|
for (var colIndex = sel.firstColumn + 1; colIndex <= sel.lastColumn - 1; colIndex++) {
|
|
7565
7534
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
7566
|
-
|
|
7567
|
-
'borderLeft',
|
|
7568
|
-
'borderRight',
|
|
7569
|
-
]);
|
|
7535
|
+
collectBorderFormat(cell, ['borderLeft', 'borderRight']);
|
|
7570
7536
|
}
|
|
7571
|
-
|
|
7537
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderLeft']);
|
|
7572
7538
|
break;
|
|
7573
7539
|
}
|
|
7574
7540
|
// For multiple rows and columns selections
|
|
7575
7541
|
// Top left cell
|
|
7576
|
-
|
|
7542
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderBottom', 'borderRight']);
|
|
7577
7543
|
// Top right cell
|
|
7578
|
-
|
|
7544
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderBottom', 'borderLeft']);
|
|
7579
7545
|
// Bottom left cell
|
|
7580
|
-
|
|
7546
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderTop', 'borderRight']);
|
|
7581
7547
|
// Bottom right cell
|
|
7582
|
-
|
|
7548
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderTop', 'borderLeft']);
|
|
7583
7549
|
// First row
|
|
7584
7550
|
for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
|
|
7585
7551
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
7586
|
-
|
|
7552
|
+
collectBorderFormat(cell, [
|
|
7587
7553
|
'borderBottom',
|
|
7588
7554
|
'borderLeft',
|
|
7589
7555
|
'borderRight',
|
|
@@ -7592,7 +7558,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7592
7558
|
// Last row
|
|
7593
7559
|
for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
|
|
7594
7560
|
var cell = tableModel.rows[sel.lastRow].cells[colIndex];
|
|
7595
|
-
|
|
7561
|
+
collectBorderFormat(cell, [
|
|
7596
7562
|
'borderTop',
|
|
7597
7563
|
'borderLeft',
|
|
7598
7564
|
'borderRight',
|
|
@@ -7601,7 +7567,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7601
7567
|
// First column
|
|
7602
7568
|
for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
|
|
7603
7569
|
var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
|
|
7604
|
-
|
|
7570
|
+
collectBorderFormat(cell, [
|
|
7605
7571
|
'borderTop',
|
|
7606
7572
|
'borderBottom',
|
|
7607
7573
|
isRtl ? 'borderLeft' : 'borderRight',
|
|
@@ -7610,7 +7576,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7610
7576
|
// Last column
|
|
7611
7577
|
for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
|
|
7612
7578
|
var cell = tableModel.rows[rowIndex].cells[sel.lastColumn];
|
|
7613
|
-
|
|
7579
|
+
collectBorderFormat(cell, [
|
|
7614
7580
|
'borderTop',
|
|
7615
7581
|
'borderBottom',
|
|
7616
7582
|
isRtl ? 'borderRight' : 'borderLeft',
|
|
@@ -7634,6 +7600,26 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7634
7600
|
break;
|
|
7635
7601
|
}
|
|
7636
7602
|
}
|
|
7603
|
+
// Compare before changing any cells, and only consider borders targeted by
|
|
7604
|
+
// this operation. Normalize CSS so DOM colors (rgb) also match hex input.
|
|
7605
|
+
if (operation != 'noBorders' &&
|
|
7606
|
+
borderUpdates_2.length > 0 &&
|
|
7607
|
+
hasMatchingBorders(borderUpdates_2, borderFormat)) {
|
|
7608
|
+
borderFormat = '';
|
|
7609
|
+
}
|
|
7610
|
+
try {
|
|
7611
|
+
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()) {
|
|
7612
|
+
var _c = borderUpdates_1_1.value, cell = _c.cell, positions = _c.positions;
|
|
7613
|
+
applyBorderFormat(cell, borderFormat, positions);
|
|
7614
|
+
}
|
|
7615
|
+
}
|
|
7616
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7617
|
+
finally {
|
|
7618
|
+
try {
|
|
7619
|
+
if (borderUpdates_1_1 && !borderUpdates_1_1.done && (_a = borderUpdates_1.return)) _a.call(borderUpdates_1);
|
|
7620
|
+
}
|
|
7621
|
+
finally { if (e_1) throw e_1.error; }
|
|
7622
|
+
}
|
|
7637
7623
|
//Format perimeter if necessary or possible
|
|
7638
7624
|
modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);
|
|
7639
7625
|
}
|
|
@@ -7652,6 +7638,64 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7652
7638
|
});
|
|
7653
7639
|
}
|
|
7654
7640
|
exports.applyTableBorderFormat = applyTableBorderFormat;
|
|
7641
|
+
/**
|
|
7642
|
+
* Check targeted borders without repeatedly parsing identical CSS values.
|
|
7643
|
+
* @param borderUpdates The borders to compare
|
|
7644
|
+
* @param borderFormat The requested border format
|
|
7645
|
+
*/
|
|
7646
|
+
function hasMatchingBorders(borderUpdates, borderFormat) {
|
|
7647
|
+
var e_2, _a, e_3, _b;
|
|
7648
|
+
var matchingBorders = new Set();
|
|
7649
|
+
try {
|
|
7650
|
+
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()) {
|
|
7651
|
+
var _c = borderUpdates_3_1.value, cell = _c.cell, positions = _c.positions;
|
|
7652
|
+
try {
|
|
7653
|
+
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()) {
|
|
7654
|
+
var pos = positions_1_1.value;
|
|
7655
|
+
var value = cell.format[pos] || '';
|
|
7656
|
+
// Exact matches need no CSS parsing. Equivalent values are parsed only once.
|
|
7657
|
+
if (value == borderFormat || matchingBorders.has(value)) {
|
|
7658
|
+
continue;
|
|
7659
|
+
}
|
|
7660
|
+
if (!areSameBorders(value, borderFormat)) {
|
|
7661
|
+
return false;
|
|
7662
|
+
}
|
|
7663
|
+
matchingBorders.add(value);
|
|
7664
|
+
}
|
|
7665
|
+
}
|
|
7666
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
7667
|
+
finally {
|
|
7668
|
+
try {
|
|
7669
|
+
if (positions_1_1 && !positions_1_1.done && (_b = positions_1.return)) _b.call(positions_1);
|
|
7670
|
+
}
|
|
7671
|
+
finally { if (e_3) throw e_3.error; }
|
|
7672
|
+
}
|
|
7673
|
+
}
|
|
7674
|
+
}
|
|
7675
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7676
|
+
finally {
|
|
7677
|
+
try {
|
|
7678
|
+
if (borderUpdates_3_1 && !borderUpdates_3_1.done && (_a = borderUpdates_3.return)) _a.call(borderUpdates_3);
|
|
7679
|
+
}
|
|
7680
|
+
finally { if (e_2) throw e_2.error; }
|
|
7681
|
+
}
|
|
7682
|
+
return true;
|
|
7683
|
+
}
|
|
7684
|
+
/**
|
|
7685
|
+
* Compare border components, parsing colors to account for equivalent hex and RGB values.
|
|
7686
|
+
*/
|
|
7687
|
+
function areSameBorders(border1, border2) {
|
|
7688
|
+
var values1 = (0, roosterjs_content_model_dom_1.extractBorderValues)(border1);
|
|
7689
|
+
var values2 = (0, roosterjs_content_model_dom_1.extractBorderValues)(border2);
|
|
7690
|
+
var color1 = values1.color || '';
|
|
7691
|
+
var color2 = values2.color || '';
|
|
7692
|
+
var rgb1 = (0, roosterjs_content_model_dom_1.parseColor)(color1);
|
|
7693
|
+
var rgb2 = (0, roosterjs_content_model_dom_1.parseColor)(color2);
|
|
7694
|
+
return (values1.width == values2.width &&
|
|
7695
|
+
values1.style == values2.style &&
|
|
7696
|
+
(color1 == color2 ||
|
|
7697
|
+
(!!rgb1 && !!rgb2 && rgb1[0] == rgb2[0] && rgb1[1] == rgb2[1] && rgb1[2] == rgb2[2])));
|
|
7698
|
+
}
|
|
7655
7699
|
/**
|
|
7656
7700
|
* @internal
|
|
7657
7701
|
* Apply border format to a cell
|
|
@@ -9247,7 +9291,7 @@ function exportContent(editor, mode, optionsOrCallbacks) {
|
|
|
9247
9291
|
var clonedRoot = editor.getDOMHelper().getClonedRoot();
|
|
9248
9292
|
if (editor.isDarkMode()) {
|
|
9249
9293
|
(0, roosterjs_content_model_dom_1.transformColor)(clonedRoot, false /*includeSelf*/, 'darkToLight', editor.getColorManager(), {
|
|
9250
|
-
tableBorders:
|
|
9294
|
+
tableBorders: true,
|
|
9251
9295
|
});
|
|
9252
9296
|
}
|
|
9253
9297
|
return getHTMLFromDOM(editor, clonedRoot);
|
|
@@ -10609,7 +10653,7 @@ function restoreSnapshotColors(core, snapshot) {
|
|
|
10609
10653
|
core.darkColorHandler.updateKnownColor(isDarkMode); // Pass no parameter to force update all colors
|
|
10610
10654
|
if (!!snapshot.isDarkMode != !!isDarkMode) {
|
|
10611
10655
|
(0, roosterjs_content_model_dom_1.transformColor)(core.physicalRoot, false /*includeSelf*/, isDarkMode ? 'lightToDark' : 'darkToLight', core.darkColorHandler, {
|
|
10612
|
-
tableBorders:
|
|
10656
|
+
tableBorders: true,
|
|
10613
10657
|
});
|
|
10614
10658
|
}
|
|
10615
10659
|
}
|
|
@@ -11538,12 +11582,13 @@ exports.switchShadowEdit = switchShadowEdit;
|
|
|
11538
11582
|
/*!****************************************************************************************!*\
|
|
11539
11583
|
!*** ./packages/roosterjs-content-model-core/lib/coreApi/triggerEvent/triggerEvent.ts ***!
|
|
11540
11584
|
\****************************************************************************************/
|
|
11541
|
-
(__unused_webpack_module, exports) {
|
|
11585
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
11542
11586
|
|
|
11543
11587
|
"use strict";
|
|
11544
11588
|
|
|
11545
11589
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11546
11590
|
exports.triggerEvent = void 0;
|
|
11591
|
+
var devtoolsHook_1 = __webpack_require__(/*! ../../utils/devtoolsHook */ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts");
|
|
11547
11592
|
var allowedEventsInShadowEdit = [
|
|
11548
11593
|
'editorReady',
|
|
11549
11594
|
'beforeDispose',
|
|
@@ -11567,6 +11612,7 @@ var triggerEvent = function (core, pluginEvent, broadcast) {
|
|
|
11567
11612
|
}
|
|
11568
11613
|
});
|
|
11569
11614
|
}
|
|
11615
|
+
(0, devtoolsHook_1.notifyDevToolsPluginEvent)(core, pluginEvent);
|
|
11570
11616
|
};
|
|
11571
11617
|
exports.triggerEvent = triggerEvent;
|
|
11572
11618
|
function handledExclusively(event, plugin) {
|
|
@@ -13385,7 +13431,7 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
13385
13431
|
};
|
|
13386
13432
|
if (editor.isDarkMode()) {
|
|
13387
13433
|
(0, roosterjs_content_model_dom_1.transformColor)(wrapper, true /*includeSelf*/, 'lightToDark', editor.getColorManager(), {
|
|
13388
|
-
tableBorders:
|
|
13434
|
+
tableBorders: true,
|
|
13389
13435
|
});
|
|
13390
13436
|
}
|
|
13391
13437
|
}
|
|
@@ -15716,6 +15762,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
15716
15762
|
exports.Editor = void 0;
|
|
15717
15763
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
15718
15764
|
var createEditorCore_1 = __webpack_require__(/*! ./core/createEditorCore */ "./packages/roosterjs-content-model-core/lib/editor/core/createEditorCore.ts");
|
|
15765
|
+
var devtoolsHook_1 = __webpack_require__(/*! ../utils/devtoolsHook */ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts");
|
|
15719
15766
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
15720
15767
|
/**
|
|
15721
15768
|
* The main editor class based on Content Model
|
|
@@ -15739,7 +15786,7 @@ var Editor = /** @class */ (function () {
|
|
|
15739
15786
|
if (_this.isDarkMode()) {
|
|
15740
15787
|
var colorHandler = _this.getColorManager();
|
|
15741
15788
|
(0, roosterjs_content_model_dom_1.transformColor)(result, true /*includeSelf*/, 'darkToLight', colorHandler, {
|
|
15742
|
-
tableBorders:
|
|
15789
|
+
tableBorders: true,
|
|
15743
15790
|
});
|
|
15744
15791
|
result.style.color = result.style.color || 'inherit';
|
|
15745
15792
|
result.style.backgroundColor = result.style.backgroundColor || 'inherit';
|
|
@@ -15750,6 +15797,7 @@ var Editor = /** @class */ (function () {
|
|
|
15750
15797
|
var initialModel = (_a = options.initialModel) !== null && _a !== void 0 ? _a : (0, roosterjs_content_model_dom_1.createEmptyModel)(this.core.format.defaultFormat);
|
|
15751
15798
|
this.core.api.setContentModel(this.core, initialModel, { ignoreSelection: true }, undefined /*onNodeCreated*/, true /*isInitializing*/);
|
|
15752
15799
|
this.core.plugins.forEach(function (plugin) { return plugin.initialize(_this); });
|
|
15800
|
+
(0, devtoolsHook_1.notifyDevToolsEditorCreated)(this, this.core);
|
|
15753
15801
|
}
|
|
15754
15802
|
/**
|
|
15755
15803
|
* Dispose this editor, dispose all plugins and custom data
|
|
@@ -15757,6 +15805,7 @@ var Editor = /** @class */ (function () {
|
|
|
15757
15805
|
Editor.prototype.dispose = function () {
|
|
15758
15806
|
var _a;
|
|
15759
15807
|
var core = this.getCore();
|
|
15808
|
+
(0, devtoolsHook_1.notifyDevToolsEditorDisposed)(this, core);
|
|
15760
15809
|
for (var i = core.plugins.length - 1; i >= 0; i--) {
|
|
15761
15810
|
var plugin = core.plugins[i];
|
|
15762
15811
|
try {
|
|
@@ -15941,7 +15990,7 @@ var Editor = /** @class */ (function () {
|
|
|
15941
15990
|
var core = this.getCore();
|
|
15942
15991
|
if (!!isDarkMode != core.lifecycle.isDarkMode) {
|
|
15943
15992
|
(0, roosterjs_content_model_dom_1.transformColor)(core.physicalRoot, false /*includeSelf*/, isDarkMode ? 'lightToDark' : 'darkToLight', core.darkColorHandler, {
|
|
15944
|
-
tableBorders:
|
|
15993
|
+
tableBorders: true,
|
|
15945
15994
|
}, core.format.defaultFormat.textColor);
|
|
15946
15995
|
core.lifecycle.isDarkMode = !!isDarkMode;
|
|
15947
15996
|
core.api.triggerEvent(core, {
|
|
@@ -16390,10 +16439,11 @@ function createEditorCore(contentDiv, options) {
|
|
|
16390
16439
|
}
|
|
16391
16440
|
exports.createEditorCore = createEditorCore;
|
|
16392
16441
|
function createEditorEnvironment(contentDiv, options) {
|
|
16393
|
-
var _a, _b
|
|
16394
|
-
var
|
|
16395
|
-
var
|
|
16396
|
-
var
|
|
16442
|
+
var _a, _b;
|
|
16443
|
+
var defaultView = contentDiv.ownerDocument.defaultView;
|
|
16444
|
+
var navigator = defaultView === null || defaultView === void 0 ? void 0 : defaultView.navigator;
|
|
16445
|
+
var userAgent = (_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) !== null && _a !== void 0 ? _a : '';
|
|
16446
|
+
var appVersion = (_b = navigator === null || navigator === void 0 ? void 0 : navigator.appVersion) !== null && _b !== void 0 ? _b : '';
|
|
16397
16447
|
return {
|
|
16398
16448
|
document: contentDiv.ownerDocument,
|
|
16399
16449
|
domToModelSettings: (0, createEditorDefaultSettings_1.createDomToModelSettings)(options),
|
|
@@ -16405,6 +16455,7 @@ function createEditorEnvironment(contentDiv, options) {
|
|
|
16405
16455
|
userAgent.indexOf('Chrome') < 0 &&
|
|
16406
16456
|
userAgent.indexOf('Android') < 0,
|
|
16407
16457
|
isMobileOrTablet: getIsMobileOrTablet(userAgent),
|
|
16458
|
+
isTouchSupported: !!defaultView && ('ontouchstart' in defaultView || !!(navigator === null || navigator === void 0 ? void 0 : navigator.maxTouchPoints)),
|
|
16408
16459
|
};
|
|
16409
16460
|
}
|
|
16410
16461
|
function getIsMobileOrTablet(userAgent) {
|
|
@@ -16504,7 +16555,7 @@ exports.createModelToDomSettings = createModelToDomSettings;
|
|
|
16504
16555
|
"use strict";
|
|
16505
16556
|
|
|
16506
16557
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
16507
|
-
exports.getContentForCopy = exports.paste = exports.redo = exports.undo = exports.exportContent = exports.createModelFromHtml = exports.Editor = void 0;
|
|
16558
|
+
exports.RoosterJsDevToolsHookVersion = exports.getContentForCopy = exports.paste = exports.redo = exports.undo = exports.exportContent = exports.createModelFromHtml = exports.Editor = void 0;
|
|
16508
16559
|
// Editor
|
|
16509
16560
|
var Editor_1 = __webpack_require__(/*! ./editor/Editor */ "./packages/roosterjs-content-model-core/lib/editor/Editor.ts");
|
|
16510
16561
|
Object.defineProperty(exports, "Editor", ({ enumerable: true, get: function () { return Editor_1.Editor; } }));
|
|
@@ -16519,9 +16570,12 @@ var redo_1 = __webpack_require__(/*! ./command/redo/redo */ "./packages/roosterj
|
|
|
16519
16570
|
Object.defineProperty(exports, "redo", ({ enumerable: true, get: function () { return redo_1.redo; } }));
|
|
16520
16571
|
var paste_1 = __webpack_require__(/*! ./command/paste/paste */ "./packages/roosterjs-content-model-core/lib/command/paste/paste.ts");
|
|
16521
16572
|
Object.defineProperty(exports, "paste", ({ enumerable: true, get: function () { return paste_1.paste; } }));
|
|
16522
|
-
//Editor copy helper
|
|
16573
|
+
// Editor copy helper
|
|
16523
16574
|
var getContentForCopy_1 = __webpack_require__(/*! ./command/cutCopy/getContentForCopy */ "./packages/roosterjs-content-model-core/lib/command/cutCopy/getContentForCopy.ts");
|
|
16524
16575
|
Object.defineProperty(exports, "getContentForCopy", ({ enumerable: true, get: function () { return getContentForCopy_1.getContentForCopy; } }));
|
|
16576
|
+
// Editor devtools
|
|
16577
|
+
var devtoolsHook_1 = __webpack_require__(/*! ./utils/devtoolsHook */ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts");
|
|
16578
|
+
Object.defineProperty(exports, "RoosterJsDevToolsHookVersion", ({ enumerable: true, get: function () { return devtoolsHook_1.RoosterJsDevToolsHookVersion; } }));
|
|
16525
16579
|
|
|
16526
16580
|
|
|
16527
16581
|
/***/ },
|
|
@@ -16897,6 +16951,105 @@ function createAriaLiveElement(document) {
|
|
|
16897
16951
|
exports.createAriaLiveElement = createAriaLiveElement;
|
|
16898
16952
|
|
|
16899
16953
|
|
|
16954
|
+
/***/ },
|
|
16955
|
+
|
|
16956
|
+
/***/ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts"
|
|
16957
|
+
/*!*************************************************************************!*\
|
|
16958
|
+
!*** ./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts ***!
|
|
16959
|
+
\*************************************************************************/
|
|
16960
|
+
(__unused_webpack_module, exports) {
|
|
16961
|
+
|
|
16962
|
+
"use strict";
|
|
16963
|
+
|
|
16964
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
16965
|
+
exports.notifyDevToolsPluginEvent = exports.notifyDevToolsEditorDisposed = exports.notifyDevToolsEditorCreated = exports.RoosterJsDevToolsHookVersion = void 0;
|
|
16966
|
+
/**
|
|
16967
|
+
* The current version of the RoosterJS DevTools hook contract (see
|
|
16968
|
+
* {@link RoosterJsDevToolsHook}). The editor stamps this onto the installed hook so a developer
|
|
16969
|
+
* tool can adapt to the editor's capabilities. Bump this whenever the shape of the contract changes
|
|
16970
|
+
* in a way tools may need to detect.
|
|
16971
|
+
*
|
|
16972
|
+
* History:
|
|
16973
|
+
* - 1: onEditorCreated, onEditorDisposed, onPluginEvent
|
|
16974
|
+
*/
|
|
16975
|
+
exports.RoosterJsDevToolsHookVersion = 1;
|
|
16976
|
+
// Maps an editor core back to its IEditor wrapper, so plugin events (which only carry the core)
|
|
16977
|
+
// can be attributed to the right editor when forwarded to developer tools.
|
|
16978
|
+
var coreToEditor = new WeakMap();
|
|
16979
|
+
/**
|
|
16980
|
+
* @internal
|
|
16981
|
+
* Notify developer tools that an editor has been created. Failures are swallowed so developer
|
|
16982
|
+
* tools can never break the editor.
|
|
16983
|
+
* @param editor The editor that was created
|
|
16984
|
+
* @param core The editor core, used to attribute later plugin events to this editor
|
|
16985
|
+
*/
|
|
16986
|
+
function notifyDevToolsEditorCreated(editor, core) {
|
|
16987
|
+
safeCall(function () {
|
|
16988
|
+
var _a, _b;
|
|
16989
|
+
coreToEditor.set(core, editor);
|
|
16990
|
+
var win = editor.getDocument().defaultView;
|
|
16991
|
+
if (win) {
|
|
16992
|
+
var editors = (_a = win.__ROOSTERJS_DEVTOOLS_EDITORS__) !== null && _a !== void 0 ? _a : [];
|
|
16993
|
+
editors.push(editor);
|
|
16994
|
+
win.__ROOSTERJS_DEVTOOLS_EDITORS__ = editors;
|
|
16995
|
+
var hook = win.__ROOSTERJS_DEVTOOLS_HOOK__;
|
|
16996
|
+
if (hook) {
|
|
16997
|
+
hook.version = exports.RoosterJsDevToolsHookVersion;
|
|
16998
|
+
(_b = hook.onEditorCreated) === null || _b === void 0 ? void 0 : _b.call(hook, editor);
|
|
16999
|
+
}
|
|
17000
|
+
}
|
|
17001
|
+
});
|
|
17002
|
+
}
|
|
17003
|
+
exports.notifyDevToolsEditorCreated = notifyDevToolsEditorCreated;
|
|
17004
|
+
/**
|
|
17005
|
+
* @internal
|
|
17006
|
+
* Notify developer tools that an editor is about to be disposed. Failures are swallowed so
|
|
17007
|
+
* developer tools can never break the editor.
|
|
17008
|
+
* @param editor The editor that is being disposed
|
|
17009
|
+
* @param core The editor core to stop tracking
|
|
17010
|
+
*/
|
|
17011
|
+
function notifyDevToolsEditorDisposed(editor, core) {
|
|
17012
|
+
safeCall(function () {
|
|
17013
|
+
var _a, _b;
|
|
17014
|
+
coreToEditor.delete(core);
|
|
17015
|
+
var win = editor.getDocument().defaultView;
|
|
17016
|
+
if (win) {
|
|
17017
|
+
var editors = win.__ROOSTERJS_DEVTOOLS_EDITORS__;
|
|
17018
|
+
var index = editors ? editors.indexOf(editor) : -1;
|
|
17019
|
+
if (editors && index >= 0) {
|
|
17020
|
+
editors.splice(index, 1);
|
|
17021
|
+
}
|
|
17022
|
+
(_b = (_a = win.__ROOSTERJS_DEVTOOLS_HOOK__) === null || _a === void 0 ? void 0 : _a.onEditorDisposed) === null || _b === void 0 ? void 0 : _b.call(_a, editor);
|
|
17023
|
+
}
|
|
17024
|
+
});
|
|
17025
|
+
}
|
|
17026
|
+
exports.notifyDevToolsEditorDisposed = notifyDevToolsEditorDisposed;
|
|
17027
|
+
/**
|
|
17028
|
+
* @internal
|
|
17029
|
+
* Forward a plugin event to developer tools, if a hook is installed. Failures are swallowed so
|
|
17030
|
+
* developer tools can never break the editor.
|
|
17031
|
+
* @param core The editor core that dispatched the event
|
|
17032
|
+
* @param event The plugin event being dispatched
|
|
17033
|
+
*/
|
|
17034
|
+
function notifyDevToolsPluginEvent(core, event) {
|
|
17035
|
+
safeCall(function () {
|
|
17036
|
+
var _a, _b;
|
|
17037
|
+
var editor = coreToEditor.get(core);
|
|
17038
|
+
var win = editor === null || editor === void 0 ? void 0 : editor.getDocument().defaultView;
|
|
17039
|
+
if (editor && win) {
|
|
17040
|
+
(_b = (_a = win.__ROOSTERJS_DEVTOOLS_HOOK__) === null || _a === void 0 ? void 0 : _a.onPluginEvent) === null || _b === void 0 ? void 0 : _b.call(_a, editor, event);
|
|
17041
|
+
}
|
|
17042
|
+
});
|
|
17043
|
+
}
|
|
17044
|
+
exports.notifyDevToolsPluginEvent = notifyDevToolsPluginEvent;
|
|
17045
|
+
function safeCall(callback) {
|
|
17046
|
+
try {
|
|
17047
|
+
callback();
|
|
17048
|
+
}
|
|
17049
|
+
catch (_a) { }
|
|
17050
|
+
}
|
|
17051
|
+
|
|
17052
|
+
|
|
16900
17053
|
/***/ },
|
|
16901
17054
|
|
|
16902
17055
|
/***/ "./packages/roosterjs-content-model-core/lib/utils/domCreator.ts"
|
|
@@ -17071,6 +17224,9 @@ exports.defaultHTMLStyleMap = {
|
|
|
17071
17224
|
marginBottom: '1em',
|
|
17072
17225
|
},
|
|
17073
17226
|
dt: blockElement,
|
|
17227
|
+
del: {
|
|
17228
|
+
textDecoration: 'line-through',
|
|
17229
|
+
},
|
|
17074
17230
|
em: {
|
|
17075
17231
|
fontStyle: 'italic',
|
|
17076
17232
|
},
|
|
@@ -22057,41 +22213,35 @@ var DEFAULT_COLOR = '#000000';
|
|
|
22057
22213
|
*/
|
|
22058
22214
|
exports.borderColorFormatHandler = {
|
|
22059
22215
|
parse: function (format, element, context) {
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
|
|
22065
|
-
|
|
22066
|
-
var
|
|
22067
|
-
|
|
22068
|
-
|
|
22069
|
-
|
|
22070
|
-
|
|
22071
|
-
|
|
22072
|
-
|
|
22073
|
-
|
|
22074
|
-
}
|
|
22075
|
-
});
|
|
22076
|
-
}
|
|
22216
|
+
borderKeys_1.BorderKeys.forEach(function (key) {
|
|
22217
|
+
var width = element.style.getPropertyValue(BorderWidthKeyMap[key]);
|
|
22218
|
+
var style = element.style.getPropertyValue(BorderStyleKeyMap[key]);
|
|
22219
|
+
var color = (0, color_1.retrieveElementColor)(element, key);
|
|
22220
|
+
var borderColor = color == 'initial' ? DEFAULT_COLOR : color;
|
|
22221
|
+
if (borderColor) {
|
|
22222
|
+
var lightModeColor = (0, color_1.getLightModeColor)(borderColor, !!context.isDarkMode, context.darkColorHandler);
|
|
22223
|
+
format[key] = (0, borderValues_1.combineBorderValue)({
|
|
22224
|
+
width: width,
|
|
22225
|
+
style: style,
|
|
22226
|
+
color: lightModeColor,
|
|
22227
|
+
});
|
|
22228
|
+
}
|
|
22229
|
+
});
|
|
22077
22230
|
},
|
|
22078
22231
|
apply: function (format, element, context) {
|
|
22079
|
-
|
|
22080
|
-
|
|
22081
|
-
|
|
22082
|
-
var
|
|
22083
|
-
|
|
22084
|
-
|
|
22085
|
-
var
|
|
22086
|
-
if (
|
|
22087
|
-
|
|
22088
|
-
if (transformedColor) {
|
|
22089
|
-
element.style.setProperty(borderColorProperty, transformedColor);
|
|
22090
|
-
}
|
|
22232
|
+
borderKeys_1.BorderKeys.forEach(function (key) {
|
|
22233
|
+
var value = format[key];
|
|
22234
|
+
if (value) {
|
|
22235
|
+
var borderValues = (0, borderValues_1.extractBorderValues)(value);
|
|
22236
|
+
var borderColorProperty = borderKeys_1.BorderColorKeyMap[key];
|
|
22237
|
+
if (borderValues.color) {
|
|
22238
|
+
var transformedColor = (0, color_1.adaptColor)(element, borderValues.color, 'border', !!context.isDarkMode, context.darkColorHandler);
|
|
22239
|
+
if (transformedColor) {
|
|
22240
|
+
element.style.setProperty(borderColorProperty, transformedColor);
|
|
22091
22241
|
}
|
|
22092
22242
|
}
|
|
22093
|
-
}
|
|
22094
|
-
}
|
|
22243
|
+
}
|
|
22244
|
+
});
|
|
22095
22245
|
},
|
|
22096
22246
|
};
|
|
22097
22247
|
|
|
@@ -24050,8 +24200,8 @@ exports.shouldSetValue = shouldSetValue;
|
|
|
24050
24200
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24051
24201
|
exports.createImage = exports.createText = exports.createTableCell = exports.createTable = exports.createSelectionMarker = exports.createParagraph = exports.createFormatContainer = exports.createListItem = exports.createBr = exports.isLinkUndeletable = exports.setLinkUndeletable = exports.scrollRectIntoView = exports.normalizeRect = exports.isWhiteSpacePreserved = exports.reuseCachedElement = exports.findClosestBlockEntityContainer = exports.isBlockEntityContainer = exports.isEntityDelimiter = exports.addDelimiters = exports.generateEntityClassNames = exports.parseEntityFormat = exports.getAllEntityWrappers = exports.findClosestEntityWrapper = exports.isEntityElement = exports.unwrap = exports.wrap = exports.wrapAllChildNodes = exports.moveChildNodes = exports.toArray = exports.getSafeIdSelector = exports.getObjectKeys = exports.isElementOfType = exports.isNodeOfType = exports.hasMetadata = exports.getMetadata = exports.updateMetadata = exports.buildSelectionMarker = exports.isBlockElement = exports.areSameFormats = exports.parseFormat = exports.getRegularSelectionOffsets = exports.formatContainerProcessor = exports.tableProcessor = exports.entityProcessor = exports.processChildNode = exports.handleRegularSelection = exports.childProcessor = exports.contentModelToText = exports.contentModelToDom = exports.domToContentModel = void 0;
|
|
24052
24202
|
exports.getDOMInsertPointRect = exports.getSelectionRootNode = exports.isBold = exports.createModelToDomConfig = exports.createModelToDomContextWithConfig = exports.createModelToDomContext = exports.createDomToModelConfig = exports.createDomToModelContextWithConfig = exports.createDomToModelContext = exports.defaultGenerateColorKey = exports.parseColor = exports.setColor = exports.getColor = exports.DeprecatedColors = exports.BorderKeys = exports.parseValueWithUnit = exports.getAutoListStyleType = exports.getOrderedListNumberStr = exports.ParagraphFormats = exports.ListFormatsToMove = exports.ListFormatsToKeep = exports.ListFormats = exports.copyFormat = exports.setParagraphNotImplicit = exports.normalizeSegmentFormat = exports.mergeTextSegments = exports.normalizeSingleSegment = exports.isEmpty = exports.addSegment = exports.unwrapBlock = exports.isGeneralSegment = exports.normalizeContentModel = exports.normalizeParagraph = exports.addTextSegment = exports.addLink = exports.addData = exports.addCode = exports.addBlock = exports.mutateSegment = exports.mutateSegments = exports.mutateBlock = exports.createTableRow = exports.createEmptyModel = exports.createListLevel = exports.createDivider = exports.createEntity = exports.createGeneralBlock = exports.createGeneralSegment = exports.createParagraphDecorator = exports.createContentModelDocument = void 0;
|
|
24053
|
-
exports.
|
|
24054
|
-
exports.EmptySegmentFormat = exports.UnorderedListStyleMap = exports.OrderedListStyleMap = exports.TableBorderFormat = exports.NumberingListType = exports.BulletListType = exports.ChangeSource = exports.ListMetadataDefinition = exports.getListMetadata = exports.updateListMetadata = exports.getTableMetadata = exports.updateTableMetadata = exports.getTableCellMetadata = exports.updateTableCellMetadata = exports.getImageMetadata = exports.updateImageMetadata = exports.runEditSteps = exports.getClosestAncestorBlockGroupIndex = exports.getSegmentTextFormat = void 0;
|
|
24203
|
+
exports.retrieveModelFormatState = exports.setTableCellBackgroundColor = exports.MIN_ALLOWED_TABLE_CELL_HEIGHT = exports.MIN_ALLOWED_TABLE_CELL_WIDTH = exports.normalizeTable = exports.setFirstColumnFormatBorders = exports.applyTableFormat = exports.deleteBlock = exports.deleteSegment = exports.deleteSelection = exports.mergeModel = exports.canMergeCells = exports.cloneModelForPaste = exports.cloneModel = exports.setSelection = exports.hasSelectionInBlockGroup = exports.hasSelectionInSegment = exports.hasSelectionInBlock = exports.getSelectedCells = exports.getSelectedSegmentsAndParagraphs = exports.getSelectedSegments = exports.getSelectedParagraphs = exports.getOperationalBlocks = exports.getFirstSelectedTable = exports.getFirstSelectedListItem = exports.iterateSelections = exports.isBlockGroupOfType = exports.getRangesByText = exports.getImageState = exports.setImageState = exports.getParagraphMarker = exports.setParagraphMarker = exports.cacheGetEventData = exports.createPasteFragment = exports.extractClipboardItems = exports.normalizeFontFamily = exports.transformColor = exports.retrieveDocumentMetadata = exports.readFile = exports.parseTableCells = exports.normalizeText = exports.isSpace = exports.isPunctuation = exports.extractBorderValues = exports.combineBorderValue = exports.getNodePositionFromEvent = exports.isCursorMovingKey = exports.isModifierKey = exports.isCharacterValue = exports.trimModelForSelection = void 0;
|
|
24204
|
+
exports.EmptySegmentFormat = exports.UnorderedListStyleMap = exports.OrderedListStyleMap = exports.TableBorderFormat = exports.NumberingListType = exports.BulletListType = exports.ChangeSource = exports.ListMetadataDefinition = exports.getListMetadata = exports.updateListMetadata = exports.getTableMetadata = exports.updateTableMetadata = exports.getTableCellMetadata = exports.updateTableCellMetadata = exports.getImageMetadata = exports.updateImageMetadata = exports.runEditSteps = exports.getClosestAncestorBlockGroupIndex = exports.getSegmentTextFormat = exports.getListStyleTypeFromString = void 0;
|
|
24055
24205
|
var domToContentModel_1 = __webpack_require__(/*! ./domToModel/domToContentModel */ "./packages/roosterjs-content-model-dom/lib/domToModel/domToContentModel.ts");
|
|
24056
24206
|
Object.defineProperty(exports, "domToContentModel", ({ enumerable: true, get: function () { return domToContentModel_1.domToContentModel; } }));
|
|
24057
24207
|
var contentModelToDom_1 = __webpack_require__(/*! ./modelToDom/contentModelToDom */ "./packages/roosterjs-content-model-dom/lib/modelToDom/contentModelToDom.ts");
|
|
@@ -24287,6 +24437,8 @@ Object.defineProperty(exports, "setSelection", ({ enumerable: true, get: functio
|
|
|
24287
24437
|
var cloneModel_1 = __webpack_require__(/*! ./modelApi/editing/cloneModel */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/cloneModel.ts");
|
|
24288
24438
|
Object.defineProperty(exports, "cloneModel", ({ enumerable: true, get: function () { return cloneModel_1.cloneModel; } }));
|
|
24289
24439
|
Object.defineProperty(exports, "cloneModelForPaste", ({ enumerable: true, get: function () { return cloneModel_1.cloneModelForPaste; } }));
|
|
24440
|
+
var canMergeCells_1 = __webpack_require__(/*! ./modelApi/editing/canMergeCells */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts");
|
|
24441
|
+
Object.defineProperty(exports, "canMergeCells", ({ enumerable: true, get: function () { return canMergeCells_1.canMergeCells; } }));
|
|
24290
24442
|
var mergeModel_1 = __webpack_require__(/*! ./modelApi/editing/mergeModel */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/mergeModel.ts");
|
|
24291
24443
|
Object.defineProperty(exports, "mergeModel", ({ enumerable: true, get: function () { return mergeModel_1.mergeModel; } }));
|
|
24292
24444
|
var deleteSelection_1 = __webpack_require__(/*! ./modelApi/editing/deleteSelection */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/deleteSelection.ts");
|
|
@@ -25994,12 +26146,102 @@ function applyTableFormat(table, newFormat, keepCellShade) {
|
|
|
25994
26146
|
var effectiveMetadata = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, DEFAULT_FORMAT), format), newFormat);
|
|
25995
26147
|
var metaOverrides = updateOverrides(rows, !keepCellShade);
|
|
25996
26148
|
formatCells(rows, effectiveMetadata, metaOverrides);
|
|
26149
|
+
if ((format === null || format === void 0 ? void 0 : format.hasFirstColumn) &&
|
|
26150
|
+
(!effectiveMetadata.hasFirstColumn || (newFormat === null || newFormat === void 0 ? void 0 : newFormat.firstColumnCustomStyles) !== undefined)) {
|
|
26151
|
+
clearFirstColumnTextFormat(rows, format.firstColumnCustomStyles);
|
|
26152
|
+
}
|
|
26153
|
+
if ((format === null || format === void 0 ? void 0 : format.hasHeaderRow) &&
|
|
26154
|
+
(!effectiveMetadata.hasHeaderRow || (newFormat === null || newFormat === void 0 ? void 0 : newFormat.headerRowCustomStyles) !== undefined)) {
|
|
26155
|
+
clearHeaderRowTextFormat(rows, format.headerRowCustomStyles);
|
|
26156
|
+
}
|
|
25997
26157
|
setFirstColumnFormatBorders(rows, effectiveMetadata);
|
|
25998
26158
|
setHeaderRowFormat(rows, effectiveMetadata, metaOverrides);
|
|
25999
26159
|
return effectiveMetadata;
|
|
26000
26160
|
});
|
|
26001
26161
|
}
|
|
26002
26162
|
exports.applyTableFormat = applyTableFormat;
|
|
26163
|
+
function clearFirstColumnTextFormat(rows, customStyles) {
|
|
26164
|
+
var _a;
|
|
26165
|
+
var fontWeight = (_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _a !== void 0 ? _a : 'bold';
|
|
26166
|
+
rows.forEach(function (row) {
|
|
26167
|
+
var e_1, _a, e_2, _b;
|
|
26168
|
+
var cell = row.cells[0] && (0, mutate_1.mutateBlock)(row.cells[0]);
|
|
26169
|
+
if (cell) {
|
|
26170
|
+
clearStyleIfMatch(cell.format, 'fontWeight', fontWeight);
|
|
26171
|
+
clearStyleIfMatch(cell.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26172
|
+
try {
|
|
26173
|
+
for (var _c = (0, tslib_1.__values)(cell.blocks), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
26174
|
+
var block = _d.value;
|
|
26175
|
+
if (block.blockType == 'Paragraph') {
|
|
26176
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26177
|
+
try {
|
|
26178
|
+
for (var _e = (e_2 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
26179
|
+
var cellSegment = _f.value;
|
|
26180
|
+
clearStyleIfMatch(cellSegment.format, 'fontWeight', fontWeight);
|
|
26181
|
+
clearStyleIfMatch(cellSegment.format, 'italic', customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic);
|
|
26182
|
+
}
|
|
26183
|
+
}
|
|
26184
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
26185
|
+
finally {
|
|
26186
|
+
try {
|
|
26187
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
26188
|
+
}
|
|
26189
|
+
finally { if (e_2) throw e_2.error; }
|
|
26190
|
+
}
|
|
26191
|
+
clearStyleIfMatch(block.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26192
|
+
}
|
|
26193
|
+
}
|
|
26194
|
+
}
|
|
26195
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
26196
|
+
finally {
|
|
26197
|
+
try {
|
|
26198
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
26199
|
+
}
|
|
26200
|
+
finally { if (e_1) throw e_1.error; }
|
|
26201
|
+
}
|
|
26202
|
+
}
|
|
26203
|
+
});
|
|
26204
|
+
}
|
|
26205
|
+
function clearHeaderRowTextFormat(rows, customStyles) {
|
|
26206
|
+
var _a, _b;
|
|
26207
|
+
var fontWeight = (_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _a !== void 0 ? _a : 'bold';
|
|
26208
|
+
(_b = rows[0]) === null || _b === void 0 ? void 0 : _b.cells.forEach(function (readonlyCell) {
|
|
26209
|
+
var e_3, _a, e_4, _b;
|
|
26210
|
+
var cell = (0, mutate_1.mutateBlock)(readonlyCell);
|
|
26211
|
+
clearStyleIfMatch(cell.format, 'fontWeight', fontWeight);
|
|
26212
|
+
clearStyleIfMatch(cell.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26213
|
+
try {
|
|
26214
|
+
for (var _c = (0, tslib_1.__values)(cell.blocks), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
26215
|
+
var block = _d.value;
|
|
26216
|
+
if (block.blockType == 'Paragraph') {
|
|
26217
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26218
|
+
try {
|
|
26219
|
+
for (var _e = (e_4 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
26220
|
+
var cellSegment = _f.value;
|
|
26221
|
+
clearStyleIfMatch(cellSegment.format, 'fontWeight', fontWeight);
|
|
26222
|
+
clearStyleIfMatch(cellSegment.format, 'italic', customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic);
|
|
26223
|
+
}
|
|
26224
|
+
}
|
|
26225
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
26226
|
+
finally {
|
|
26227
|
+
try {
|
|
26228
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
26229
|
+
}
|
|
26230
|
+
finally { if (e_4) throw e_4.error; }
|
|
26231
|
+
}
|
|
26232
|
+
clearStyleIfMatch(block.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26233
|
+
}
|
|
26234
|
+
}
|
|
26235
|
+
}
|
|
26236
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
26237
|
+
finally {
|
|
26238
|
+
try {
|
|
26239
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
26240
|
+
}
|
|
26241
|
+
finally { if (e_3) throw e_3.error; }
|
|
26242
|
+
}
|
|
26243
|
+
});
|
|
26244
|
+
}
|
|
26003
26245
|
function updateOverrides(rows, removeCellShade) {
|
|
26004
26246
|
var overrides = {
|
|
26005
26247
|
bgColorOverrides: [],
|
|
@@ -26160,7 +26402,8 @@ function setFirstColumnFormatBorders(rows, format) {
|
|
|
26160
26402
|
var customStyles = format.hasFirstColumn ? format.firstColumnCustomStyles : undefined;
|
|
26161
26403
|
rows.forEach(function (row, rowIndex) {
|
|
26162
26404
|
row.cells.forEach(function (readonlyCell, cellIndex) {
|
|
26163
|
-
var
|
|
26405
|
+
var e_5, _a, e_6, _b;
|
|
26406
|
+
var _c, _d;
|
|
26164
26407
|
var cell = (0, mutate_1.mutateBlock)(readonlyCell);
|
|
26165
26408
|
if (cellIndex === 0) {
|
|
26166
26409
|
if (rowIndex == 0) {
|
|
@@ -26177,44 +26420,47 @@ function setFirstColumnFormatBorders(rows, format) {
|
|
|
26177
26420
|
}
|
|
26178
26421
|
}
|
|
26179
26422
|
try {
|
|
26180
|
-
for (var
|
|
26181
|
-
var block =
|
|
26423
|
+
for (var _e = (0, tslib_1.__values)(cell.blocks), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
26424
|
+
var block = _f.value;
|
|
26182
26425
|
if (block.blockType == 'Paragraph') {
|
|
26426
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26183
26427
|
try {
|
|
26184
|
-
for (var
|
|
26185
|
-
var
|
|
26186
|
-
(
|
|
26187
|
-
|
|
26188
|
-
|
|
26189
|
-
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
setStyleIfDefined(cellSegment.format, 'italic', customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic);
|
|
26428
|
+
for (var _g = (e_6 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
26429
|
+
var cellSegment = _h.value;
|
|
26430
|
+
if (format.hasFirstColumn) {
|
|
26431
|
+
setStyleIfDefined(cellSegment.format, 'fontWeight', (_c = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _c !== void 0 ? _c : 'bold');
|
|
26432
|
+
setStyleIfDefined(cell.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26433
|
+
setStyleIfDefined(cell.format, 'fontWeight', (_d = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _d !== void 0 ? _d : 'bold');
|
|
26434
|
+
if (customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) {
|
|
26435
|
+
cellSegment.format.italic = true;
|
|
26193
26436
|
}
|
|
26194
|
-
else if (
|
|
26195
|
-
|
|
26196
|
-
delete cellSegment.format.fontWeight;
|
|
26197
|
-
delete cell.format.fontWeight;
|
|
26437
|
+
else if ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) === false) {
|
|
26438
|
+
delete cellSegment.format.italic;
|
|
26198
26439
|
}
|
|
26199
|
-
}
|
|
26440
|
+
}
|
|
26441
|
+
else if (cellSegment.format.fontWeight == 'bold' &&
|
|
26442
|
+
cell.format.fontWeight == 'bold') {
|
|
26443
|
+
delete cellSegment.format.fontWeight;
|
|
26444
|
+
delete cell.format.fontWeight;
|
|
26445
|
+
}
|
|
26200
26446
|
}
|
|
26201
26447
|
}
|
|
26202
|
-
catch (
|
|
26448
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
26203
26449
|
finally {
|
|
26204
26450
|
try {
|
|
26205
|
-
if (
|
|
26451
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
26206
26452
|
}
|
|
26207
|
-
finally { if (
|
|
26453
|
+
finally { if (e_6) throw e_6.error; }
|
|
26208
26454
|
}
|
|
26209
26455
|
}
|
|
26210
26456
|
}
|
|
26211
26457
|
}
|
|
26212
|
-
catch (
|
|
26458
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
26213
26459
|
finally {
|
|
26214
26460
|
try {
|
|
26215
|
-
if (
|
|
26461
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
26216
26462
|
}
|
|
26217
|
-
finally { if (
|
|
26463
|
+
finally { if (e_5) throw e_5.error; }
|
|
26218
26464
|
}
|
|
26219
26465
|
}
|
|
26220
26466
|
});
|
|
@@ -26231,6 +26477,11 @@ function setStyleIfDefined(format, key, value) {
|
|
|
26231
26477
|
format[key] = value;
|
|
26232
26478
|
}
|
|
26233
26479
|
}
|
|
26480
|
+
function clearStyleIfMatch(format, key, value) {
|
|
26481
|
+
if (value !== undefined && format[key] === value) {
|
|
26482
|
+
delete format[key];
|
|
26483
|
+
}
|
|
26484
|
+
}
|
|
26234
26485
|
function setHeaderRowFormat(rows, format, metaOverrides) {
|
|
26235
26486
|
var _a;
|
|
26236
26487
|
if (!format.hasHeaderRow) {
|
|
@@ -26239,11 +26490,12 @@ function setHeaderRowFormat(rows, format, metaOverrides) {
|
|
|
26239
26490
|
var rowIndex = 0;
|
|
26240
26491
|
var customStyles = format.headerRowCustomStyles;
|
|
26241
26492
|
(_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.forEach(function (readonlyCell, cellIndex) {
|
|
26242
|
-
var
|
|
26493
|
+
var e_7, _a, e_8, _b;
|
|
26243
26494
|
var _c, _d, _e, _f;
|
|
26244
26495
|
var cell = (0, mutate_1.mutateBlock)(readonlyCell);
|
|
26496
|
+
var fontWeight = (_c = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _c !== void 0 ? _c : 'bold';
|
|
26245
26497
|
cell.isHeader = true;
|
|
26246
|
-
cell.format.fontWeight =
|
|
26498
|
+
cell.format.fontWeight = fontWeight;
|
|
26247
26499
|
if (format.headerRowColor) {
|
|
26248
26500
|
if (!metaOverrides.bgColorOverrides[rowIndex][cellIndex]) {
|
|
26249
26501
|
(0, setTableCellBackgroundColor_1.setTableCellBackgroundColor)(cell, format.headerRowColor, false /*isColorOverride*/, true /*applyToSegments*/);
|
|
@@ -26255,40 +26507,40 @@ function setHeaderRowFormat(rows, format, metaOverrides) {
|
|
|
26255
26507
|
if (customStyles) {
|
|
26256
26508
|
setStyleIfDefined(cell.format, 'textAlign', customStyles.textAlign);
|
|
26257
26509
|
setBorderColorIfExists(cell.format, 'borderBottom', customStyles.borderBottomColor);
|
|
26258
|
-
|
|
26259
|
-
|
|
26260
|
-
|
|
26261
|
-
|
|
26262
|
-
|
|
26263
|
-
|
|
26264
|
-
|
|
26265
|
-
|
|
26266
|
-
|
|
26267
|
-
|
|
26268
|
-
|
|
26269
|
-
|
|
26270
|
-
delete cellSegment.format.italic;
|
|
26271
|
-
}
|
|
26272
|
-
});
|
|
26510
|
+
}
|
|
26511
|
+
try {
|
|
26512
|
+
for (var _g = (0, tslib_1.__values)(cell.blocks), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
26513
|
+
var block = _h.value;
|
|
26514
|
+
if (block.blockType == 'Paragraph') {
|
|
26515
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26516
|
+
try {
|
|
26517
|
+
for (var _j = (e_8 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
26518
|
+
var cellSegment = _k.value;
|
|
26519
|
+
cellSegment.format.fontWeight = fontWeight;
|
|
26520
|
+
if (customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) {
|
|
26521
|
+
cellSegment.format.italic = true;
|
|
26273
26522
|
}
|
|
26274
|
-
|
|
26275
|
-
|
|
26276
|
-
finally {
|
|
26277
|
-
try {
|
|
26278
|
-
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
26523
|
+
else if ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) === false) {
|
|
26524
|
+
delete cellSegment.format.italic;
|
|
26279
26525
|
}
|
|
26280
|
-
finally { if (e_4) throw e_4.error; }
|
|
26281
26526
|
}
|
|
26282
26527
|
}
|
|
26528
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
26529
|
+
finally {
|
|
26530
|
+
try {
|
|
26531
|
+
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
26532
|
+
}
|
|
26533
|
+
finally { if (e_8) throw e_8.error; }
|
|
26534
|
+
}
|
|
26283
26535
|
}
|
|
26284
26536
|
}
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
finally { if (e_3) throw e_3.error; }
|
|
26537
|
+
}
|
|
26538
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
26539
|
+
finally {
|
|
26540
|
+
try {
|
|
26541
|
+
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
26291
26542
|
}
|
|
26543
|
+
finally { if (e_7) throw e_7.error; }
|
|
26292
26544
|
}
|
|
26293
26545
|
});
|
|
26294
26546
|
}
|
|
@@ -26308,6 +26560,78 @@ function getBorderStyleFromColor(color) {
|
|
|
26308
26560
|
}
|
|
26309
26561
|
|
|
26310
26562
|
|
|
26563
|
+
/***/ },
|
|
26564
|
+
|
|
26565
|
+
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts"
|
|
26566
|
+
/*!************************************************************************************!*\
|
|
26567
|
+
!*** ./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts ***!
|
|
26568
|
+
\************************************************************************************/
|
|
26569
|
+
(__unused_webpack_module, exports) {
|
|
26570
|
+
|
|
26571
|
+
"use strict";
|
|
26572
|
+
|
|
26573
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
26574
|
+
exports.canMergeCells = void 0;
|
|
26575
|
+
/**
|
|
26576
|
+
* Check whether the given range of table cells can be merged without splitting existing spans.
|
|
26577
|
+
* @param rows The table rows to check
|
|
26578
|
+
* @param firstRow The first row index of the range
|
|
26579
|
+
* @param firstCol The first column index of the range
|
|
26580
|
+
* @param lastRow The last row index of the range
|
|
26581
|
+
* @param lastCol The last column index of the range
|
|
26582
|
+
*/
|
|
26583
|
+
function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
|
|
26584
|
+
var noSpanAbove = firstCol == lastCol ||
|
|
26585
|
+
rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
|
|
26586
|
+
var noSpanLeft = firstRow == lastRow ||
|
|
26587
|
+
rows.every(function (row, rowIndex) {
|
|
26588
|
+
return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
|
|
26589
|
+
});
|
|
26590
|
+
var noDifferentBelowSpan = rows[lastRow].cells
|
|
26591
|
+
.map(function (_, colIndex) {
|
|
26592
|
+
return colIndex >= firstCol && colIndex <= lastCol
|
|
26593
|
+
? getBelowSpanCount(rows, lastRow, colIndex)
|
|
26594
|
+
: -1;
|
|
26595
|
+
})
|
|
26596
|
+
.every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
|
|
26597
|
+
var noDifferentRightSpan = rows
|
|
26598
|
+
.map(function (_, rowIndex) {
|
|
26599
|
+
return rowIndex >= firstRow && rowIndex <= lastRow
|
|
26600
|
+
? getRightSpanCount(rows, rowIndex, lastCol)
|
|
26601
|
+
: -1;
|
|
26602
|
+
})
|
|
26603
|
+
.every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
|
|
26604
|
+
return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
|
|
26605
|
+
}
|
|
26606
|
+
exports.canMergeCells = canMergeCells;
|
|
26607
|
+
function getBelowSpanCount(rows, rowIndex, colIndex) {
|
|
26608
|
+
var _a, _b;
|
|
26609
|
+
var spanCount = 0;
|
|
26610
|
+
for (var row = rowIndex + 1; row < rows.length; row++) {
|
|
26611
|
+
if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
26612
|
+
spanCount++;
|
|
26613
|
+
}
|
|
26614
|
+
else {
|
|
26615
|
+
break;
|
|
26616
|
+
}
|
|
26617
|
+
}
|
|
26618
|
+
return spanCount;
|
|
26619
|
+
}
|
|
26620
|
+
function getRightSpanCount(rows, rowIndex, colIndex) {
|
|
26621
|
+
var _a, _b, _c;
|
|
26622
|
+
var spanCount = 0;
|
|
26623
|
+
for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
|
|
26624
|
+
if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
|
|
26625
|
+
spanCount++;
|
|
26626
|
+
}
|
|
26627
|
+
else {
|
|
26628
|
+
break;
|
|
26629
|
+
}
|
|
26630
|
+
}
|
|
26631
|
+
return spanCount;
|
|
26632
|
+
}
|
|
26633
|
+
|
|
26634
|
+
|
|
26311
26635
|
/***/ },
|
|
26312
26636
|
|
|
26313
26637
|
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/cloneModel.ts"
|
|
@@ -27257,7 +27581,7 @@ function mergeTables(markerPosition, newTable, source) {
|
|
|
27257
27581
|
var newColIndex = currentColCount + col;
|
|
27258
27582
|
for (var k = 0; k < table.rows.length; k++) {
|
|
27259
27583
|
var leftCell = (_b = table.rows[k]) === null || _b === void 0 ? void 0 : _b.cells[newColIndex - 1];
|
|
27260
|
-
table.rows[k].cells[newColIndex] = (0, createTableCell_1.createTableCell)(false /*spanLeft*/,
|
|
27584
|
+
table.rows[k].cells[newColIndex] = (0, createTableCell_1.createTableCell)(false /*spanLeft*/, leftCell === null || leftCell === void 0 ? void 0 : leftCell.spanAbove, leftCell === null || leftCell === void 0 ? void 0 : leftCell.isHeader, leftCell === null || leftCell === void 0 ? void 0 : leftCell.format);
|
|
27261
27585
|
}
|
|
27262
27586
|
}
|
|
27263
27587
|
}
|
|
@@ -27275,7 +27599,7 @@ function mergeTables(markerPosition, newTable, source) {
|
|
|
27275
27599
|
};
|
|
27276
27600
|
for (var k = 0; k < colCount; k++) {
|
|
27277
27601
|
var aboveCell = (_d = table.rows[newRowIndex - 1]) === null || _d === void 0 ? void 0 : _d.cells[k];
|
|
27278
|
-
table.rows[newRowIndex].cells[k] = (0, createTableCell_1.createTableCell)(
|
|
27602
|
+
table.rows[newRowIndex].cells[k] = (0, createTableCell_1.createTableCell)(aboveCell === null || aboveCell === void 0 ? void 0 : aboveCell.spanLeft, false /*spanAbove*/, false /*isHeader*/, aboveCell === null || aboveCell === void 0 ? void 0 : aboveCell.format);
|
|
27279
27603
|
}
|
|
27280
27604
|
}
|
|
27281
27605
|
}
|
|
@@ -27319,10 +27643,43 @@ function mergeTables(markerPosition, newTable, source) {
|
|
|
27319
27643
|
(0, normalizeTable_1.normalizeTable)(table, markerPosition.marker.format);
|
|
27320
27644
|
(0, applyTableFormat_1.applyTableFormat)(table, undefined /*newFormat*/, true /*keepCellShade*/);
|
|
27321
27645
|
}
|
|
27322
|
-
else {
|
|
27646
|
+
else if (!mergeTableAfterPreviousTable(markerPosition, newTable)) {
|
|
27323
27647
|
insertBlock(markerPosition, newTable);
|
|
27324
27648
|
}
|
|
27325
27649
|
}
|
|
27650
|
+
function mergeTableAfterPreviousTable(markerPosition, newTable) {
|
|
27651
|
+
var _a;
|
|
27652
|
+
var _b, _c;
|
|
27653
|
+
var marker = markerPosition.marker, paragraph = markerPosition.paragraph, path = markerPosition.path;
|
|
27654
|
+
var parent = path[0];
|
|
27655
|
+
var paragraphIndex = parent.blocks.indexOf(paragraph);
|
|
27656
|
+
var previousBlock = parent.blocks[paragraphIndex - 1];
|
|
27657
|
+
if (paragraphIndex > 0 &&
|
|
27658
|
+
paragraph.segments.indexOf(marker) == 0 &&
|
|
27659
|
+
(previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.blockType) == 'Table' &&
|
|
27660
|
+
((_b = previousBlock.rows[0]) === null || _b === void 0 ? void 0 : _b.cells.length) > 0 &&
|
|
27661
|
+
((_c = newTable.rows[0]) === null || _c === void 0 ? void 0 : _c.cells.length) > 0) {
|
|
27662
|
+
var table = (0, mutate_1.mutateBlock)(previousBlock);
|
|
27663
|
+
var columnCount = Math.max.apply(Math, (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(table.rows.map(function (row) { return row.cells.length; })), false), (0, tslib_1.__read)(newTable.rows.map(function (row) { return row.cells.length; })), false));
|
|
27664
|
+
extendTableRows(table, columnCount);
|
|
27665
|
+
extendTableRows(newTable, columnCount);
|
|
27666
|
+
(_a = table.rows).push.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(newTable.rows), false));
|
|
27667
|
+
return true;
|
|
27668
|
+
}
|
|
27669
|
+
return false;
|
|
27670
|
+
}
|
|
27671
|
+
function extendTableRows(table, columnCount) {
|
|
27672
|
+
table.rows.forEach(function (row) {
|
|
27673
|
+
var currentColumnCount = row.cells.length;
|
|
27674
|
+
var lastCell = row.cells[currentColumnCount - 1];
|
|
27675
|
+
if (lastCell) {
|
|
27676
|
+
for (var col = currentColumnCount; col < columnCount; col++) {
|
|
27677
|
+
var spanCell = (0, createTableCell_1.createTableCell)(true /* spanLeft */, false /* spanAbove */, lastCell.isHeader, lastCell.format, lastCell.dataset);
|
|
27678
|
+
row.cells.push(spanCell);
|
|
27679
|
+
}
|
|
27680
|
+
}
|
|
27681
|
+
});
|
|
27682
|
+
}
|
|
27326
27683
|
function mergeList(markerPosition, newList) {
|
|
27327
27684
|
splitParagraph(markerPosition, newList.format);
|
|
27328
27685
|
var path = markerPosition.path, paragraph = markerPosition.paragraph;
|
|
@@ -27674,6 +28031,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
27674
28031
|
exports.retrieveModelFormatState = void 0;
|
|
27675
28032
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
27676
28033
|
var borderValues_1 = __webpack_require__(/*! ../../domUtils/style/borderValues */ "./packages/roosterjs-content-model-dom/lib/domUtils/style/borderValues.ts");
|
|
28034
|
+
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts");
|
|
27677
28035
|
var getClosestAncestorBlockGroupIndex_1 = __webpack_require__(/*! ./getClosestAncestorBlockGroupIndex */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/getClosestAncestorBlockGroupIndex.ts");
|
|
27678
28036
|
var updateImageMetadata_1 = __webpack_require__(/*! ../metadata/updateImageMetadata */ "./packages/roosterjs-content-model-dom/lib/modelApi/metadata/updateImageMetadata.ts");
|
|
27679
28037
|
var updateTableMetadata_1 = __webpack_require__(/*! ../metadata/updateTableMetadata */ "./packages/roosterjs-content-model-dom/lib/modelApi/metadata/updateTableMetadata.ts");
|
|
@@ -27694,6 +28052,7 @@ var parseValueWithUnit_1 = __webpack_require__(/*! ../../formatHandlers/utils/pa
|
|
|
27694
28052
|
function retrieveModelFormatState(model, pendingFormat, formatState, conflictSolution, domHelper, isInDarkMode, colorHandler) {
|
|
27695
28053
|
if (conflictSolution === void 0) { conflictSolution = 'remove'; }
|
|
27696
28054
|
var firstTableContext;
|
|
28055
|
+
var lastTableContext;
|
|
27697
28056
|
var firstBlock;
|
|
27698
28057
|
var isFirst = true;
|
|
27699
28058
|
var isFirstImage = true;
|
|
@@ -27765,7 +28124,7 @@ function retrieveModelFormatState(model, pendingFormat, formatState, conflictSol
|
|
|
27765
28124
|
// Merge table format
|
|
27766
28125
|
if (tableContext.table == table &&
|
|
27767
28126
|
(tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)) {
|
|
27768
|
-
|
|
28127
|
+
lastTableContext = tableContext;
|
|
27769
28128
|
formatState.isMultilineSelection = true;
|
|
27770
28129
|
}
|
|
27771
28130
|
}
|
|
@@ -27778,6 +28137,9 @@ function retrieveModelFormatState(model, pendingFormat, formatState, conflictSol
|
|
|
27778
28137
|
}, {
|
|
27779
28138
|
includeListFormatHolder: 'never',
|
|
27780
28139
|
});
|
|
28140
|
+
if (firstTableContext && lastTableContext) {
|
|
28141
|
+
formatState.canMergeTableCell = (0, canMergeCells_1.canMergeCells)(firstTableContext.table.rows, firstTableContext.rowIndex, firstTableContext.colIndex, lastTableContext.rowIndex, lastTableContext.colIndex);
|
|
28142
|
+
}
|
|
27781
28143
|
if (formatState.fontSize) {
|
|
27782
28144
|
formatState.fontSize = px2Pt(formatState.fontSize);
|
|
27783
28145
|
}
|
|
@@ -32915,6 +33277,7 @@ var DefaultOptions = {
|
|
|
32915
33277
|
autoOrdinals: false,
|
|
32916
33278
|
removeListMargins: false,
|
|
32917
33279
|
autoHorizontalLine: false,
|
|
33280
|
+
autoDirection: false,
|
|
32918
33281
|
};
|
|
32919
33282
|
/**
|
|
32920
33283
|
* Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
|
|
@@ -32934,12 +33297,14 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
32934
33297
|
* - autoTel: A boolean that enables or disables automatic hyperlink telephone numbers transformation. Defaults to false.
|
|
32935
33298
|
* - autoMailto: A boolean that enables or disables automatic hyperlink email address transformation. Defaults to false.
|
|
32936
33299
|
* - autoHorizontalLine: A boolean that enables or disables automatic horizontal line creation. Defaults to false.
|
|
33300
|
+
* - autoDirection: A boolean that enables or disables automatic text direction. Defaults to false.
|
|
32937
33301
|
*/
|
|
32938
33302
|
function AutoFormatPlugin(options) {
|
|
32939
33303
|
var _this = this;
|
|
32940
33304
|
if (options === void 0) { options = DefaultOptions; }
|
|
32941
33305
|
this.options = options;
|
|
32942
33306
|
this.editor = null;
|
|
33307
|
+
this.blockDirections = new WeakMap();
|
|
32943
33308
|
this.autoLink = {
|
|
32944
33309
|
enabled: !!(this.options.autoLink || this.options.autoTel || this.options.autoMailto),
|
|
32945
33310
|
transformFunction: function (_model, previousSegment, paragraph, context) {
|
|
@@ -33074,6 +33439,9 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
33074
33439
|
case 'input':
|
|
33075
33440
|
this.handleEditorInputEvent(this.editor, event);
|
|
33076
33441
|
break;
|
|
33442
|
+
case 'compositionEnd':
|
|
33443
|
+
this.handleCompositionEndEvent(this.editor, event.rawEvent.data);
|
|
33444
|
+
break;
|
|
33077
33445
|
case 'keyDown':
|
|
33078
33446
|
this.handleKeyDownEvent(this.editor, event);
|
|
33079
33447
|
break;
|
|
@@ -33138,9 +33506,41 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
33138
33506
|
case ' ':
|
|
33139
33507
|
this.handleKeyboardEvents(editor, this.features);
|
|
33140
33508
|
break;
|
|
33509
|
+
default:
|
|
33510
|
+
this.handleAutoDirection(editor, rawEvent.data, selection.range);
|
|
33511
|
+
break;
|
|
33141
33512
|
}
|
|
33142
33513
|
}
|
|
33143
33514
|
};
|
|
33515
|
+
AutoFormatPlugin.prototype.handleCompositionEndEvent = function (editor, insertedText) {
|
|
33516
|
+
var selection = editor.getDOMSelection();
|
|
33517
|
+
if ((selection === null || selection === void 0 ? void 0 : selection.type) === 'range' && selection.range.collapsed) {
|
|
33518
|
+
this.handleAutoDirection(editor, insertedText, selection.range);
|
|
33519
|
+
}
|
|
33520
|
+
};
|
|
33521
|
+
AutoFormatPlugin.prototype.handleAutoDirection = function (editor, insertedText, range) {
|
|
33522
|
+
var _a;
|
|
33523
|
+
if (!this.options.autoDirection || !insertedText || !(0, roosterjs_content_model_api_1.getTextDirection)(insertedText)) {
|
|
33524
|
+
return;
|
|
33525
|
+
}
|
|
33526
|
+
var block = editor.getDOMHelper().findClosestBlockElement(range.startContainer);
|
|
33527
|
+
var expectedDirection = (0, roosterjs_content_model_api_1.getTextDirection)(block.textContent || '');
|
|
33528
|
+
var inlineDirection = block.style.direction;
|
|
33529
|
+
var cachedDirection = inlineDirection === 'ltr' || inlineDirection === 'rtl'
|
|
33530
|
+
? inlineDirection
|
|
33531
|
+
: this.blockDirections.get(block);
|
|
33532
|
+
if (!expectedDirection || cachedDirection === expectedDirection) {
|
|
33533
|
+
return;
|
|
33534
|
+
}
|
|
33535
|
+
var currentDirection = cachedDirection || ((_a = block.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(block).direction);
|
|
33536
|
+
if (currentDirection === 'ltr' || currentDirection === 'rtl') {
|
|
33537
|
+
this.blockDirections.set(block, currentDirection);
|
|
33538
|
+
}
|
|
33539
|
+
if (currentDirection !== expectedDirection) {
|
|
33540
|
+
this.blockDirections.set(block, expectedDirection);
|
|
33541
|
+
(0, roosterjs_content_model_api_1.setDirection)(editor, 'auto');
|
|
33542
|
+
}
|
|
33543
|
+
};
|
|
33144
33544
|
AutoFormatPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
33145
33545
|
var rawEvent = event.rawEvent;
|
|
33146
33546
|
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
@@ -37764,7 +38164,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37764
38164
|
if (this.imageEditInfo) {
|
|
37765
38165
|
this.startEditing(editor, image, ['resize', 'rotate']);
|
|
37766
38166
|
if (this.selectedImage && this.imageEditInfo && this.wrapper && this.clonedImage) {
|
|
37767
|
-
var
|
|
38167
|
+
var _c = editor.getEnvironment(), isMobileOrTablet = _c.isMobileOrTablet, isTouchSupported = _c.isTouchSupported;
|
|
37768
38168
|
this.dndHelpers = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.ResizeHandle, resizerContext_1.Resizer, function () {
|
|
37769
38169
|
if (_this.imageEditInfo &&
|
|
37770
38170
|
_this.selectedImage &&
|
|
@@ -37773,7 +38173,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37773
38173
|
(0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, _this.resizers, undefined /* croppers */, isRTL);
|
|
37774
38174
|
_this.wasImageResized = true;
|
|
37775
38175
|
}
|
|
37776
|
-
}, this.zoomScale,
|
|
38176
|
+
}, this.zoomScale, !!isMobileOrTablet, !!isTouchSupported)), false), (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.RotateHandle, rotatorContext_1.Rotator, function () {
|
|
37777
38177
|
var _a, _b;
|
|
37778
38178
|
if (_this.imageEditInfo &&
|
|
37779
38179
|
_this.selectedImage &&
|
|
@@ -37783,7 +38183,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37783
38183
|
_this.updateRotateHandleState(editor, _this.selectedImage, _this.wrapper, _this.rotators, (_a = _this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad, !!((_b = _this.options) === null || _b === void 0 ? void 0 : _b.disableSideResize));
|
|
37784
38184
|
_this.updateResizeHandleDirection(_this.resizers, _this.imageEditInfo.angleRad);
|
|
37785
38185
|
}
|
|
37786
|
-
}, this.zoomScale,
|
|
38186
|
+
}, this.zoomScale, !!isMobileOrTablet, !!isTouchSupported)), false);
|
|
37787
38187
|
(0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, this.resizers, undefined /* croppers */, isRTL);
|
|
37788
38188
|
this.updateRotateHandleState(editor, this.selectedImage, this.wrapper, this.rotators, (_a = this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad, !!((_b = this.options) === null || _b === void 0 ? void 0 : _b.disableSideResize));
|
|
37789
38189
|
}
|
|
@@ -37829,7 +38229,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37829
38229
|
(0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined /* resizers */, _this.croppers, isRTL);
|
|
37830
38230
|
_this.isCropMode = true;
|
|
37831
38231
|
}
|
|
37832
|
-
}, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet)), false);
|
|
38232
|
+
}, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet, !!editor.getEnvironment().isTouchSupported)), false);
|
|
37833
38233
|
(0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, undefined /* resizers */, this.croppers, isRTL);
|
|
37834
38234
|
}
|
|
37835
38235
|
}
|
|
@@ -39048,7 +39448,7 @@ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-mo
|
|
|
39048
39448
|
/**
|
|
39049
39449
|
* @internal
|
|
39050
39450
|
*/
|
|
39051
|
-
function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper, updateWrapper, zoomScale,
|
|
39451
|
+
function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper, updateWrapper, zoomScale, forceMobile, isTouchSupported) {
|
|
39052
39452
|
return getEditElements(wrapper, elementClass).map(function (element) {
|
|
39053
39453
|
return new DragAndDropHelper_1.DragAndDropHelper(element, {
|
|
39054
39454
|
editInfo: editInfo,
|
|
@@ -39056,7 +39456,7 @@ function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper,
|
|
|
39056
39456
|
elementClass: elementClass,
|
|
39057
39457
|
x: element.dataset.x,
|
|
39058
39458
|
y: element.dataset.y,
|
|
39059
|
-
}, updateWrapper, helper, zoomScale,
|
|
39459
|
+
}, updateWrapper, helper, zoomScale, forceMobile, isTouchSupported);
|
|
39060
39460
|
});
|
|
39061
39461
|
}
|
|
39062
39462
|
exports.getDropAndDragHelpers = getDropAndDragHelpers;
|
|
@@ -42629,7 +43029,7 @@ var MOUSE_EVENT_INFO_DESKTOP = (function () {
|
|
|
42629
43029
|
MOUSEDOWN: 'mousedown',
|
|
42630
43030
|
MOUSEMOVE: 'mousemove',
|
|
42631
43031
|
MOUSEUP: 'mouseup',
|
|
42632
|
-
|
|
43032
|
+
normalizeEvent: normalizeMouseEvent,
|
|
42633
43033
|
};
|
|
42634
43034
|
})();
|
|
42635
43035
|
var MOUSE_EVENT_INFO_MOBILE = (function () {
|
|
@@ -42637,21 +43037,37 @@ var MOUSE_EVENT_INFO_MOBILE = (function () {
|
|
|
42637
43037
|
MOUSEDOWN: 'touchstart',
|
|
42638
43038
|
MOUSEMOVE: 'touchmove',
|
|
42639
43039
|
MOUSEUP: 'touchend',
|
|
42640
|
-
|
|
43040
|
+
normalizeEvent: normalizeTouchEvent,
|
|
42641
43041
|
};
|
|
42642
43042
|
})();
|
|
42643
|
-
function
|
|
42644
|
-
|
|
42645
|
-
|
|
42646
|
-
|
|
42647
|
-
|
|
42648
|
-
|
|
42649
|
-
|
|
42650
|
-
|
|
42651
|
-
|
|
42652
|
-
|
|
42653
|
-
}
|
|
42654
|
-
|
|
43043
|
+
function normalizeMouseEvent(event) {
|
|
43044
|
+
var mouseEvent = event;
|
|
43045
|
+
return {
|
|
43046
|
+
clientX: mouseEvent.clientX,
|
|
43047
|
+
clientY: mouseEvent.clientY,
|
|
43048
|
+
pageX: mouseEvent.pageX,
|
|
43049
|
+
pageY: mouseEvent.pageY,
|
|
43050
|
+
target: mouseEvent.target,
|
|
43051
|
+
shiftKey: mouseEvent.shiftKey,
|
|
43052
|
+
altKey: mouseEvent.altKey,
|
|
43053
|
+
};
|
|
43054
|
+
}
|
|
43055
|
+
function normalizeTouchEvent(event) {
|
|
43056
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
43057
|
+
var touchEvent = event;
|
|
43058
|
+
var touch = (_b = (_a = touchEvent.targetTouches) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : (_c = touchEvent.changedTouches) === null || _c === void 0 ? void 0 : _c[0];
|
|
43059
|
+
var clientX = (_d = touch === null || touch === void 0 ? void 0 : touch.clientX) !== null && _d !== void 0 ? _d : 0;
|
|
43060
|
+
var clientY = (_e = touch === null || touch === void 0 ? void 0 : touch.clientY) !== null && _e !== void 0 ? _e : 0;
|
|
43061
|
+
var document = (_g = (_f = touchEvent.view) === null || _f === void 0 ? void 0 : _f.document) !== null && _g !== void 0 ? _g : (_h = event.target) === null || _h === void 0 ? void 0 : _h.ownerDocument;
|
|
43062
|
+
return {
|
|
43063
|
+
clientX: clientX,
|
|
43064
|
+
clientY: clientY,
|
|
43065
|
+
pageX: (_j = touch === null || touch === void 0 ? void 0 : touch.pageX) !== null && _j !== void 0 ? _j : 0,
|
|
43066
|
+
pageY: (_k = touch === null || touch === void 0 ? void 0 : touch.pageY) !== null && _k !== void 0 ? _k : 0,
|
|
43067
|
+
target: touch ? (_l = document === null || document === void 0 ? void 0 : document.elementFromPoint(clientX, clientY)) !== null && _l !== void 0 ? _l : event.target : event.target,
|
|
43068
|
+
shiftKey: false,
|
|
43069
|
+
altKey: false,
|
|
43070
|
+
};
|
|
42655
43071
|
}
|
|
42656
43072
|
/**
|
|
42657
43073
|
* @internal
|
|
@@ -42668,8 +43084,9 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42668
43084
|
* @param handler The event handler object, see DragAndDropHandler interface for more information
|
|
42669
43085
|
* @param zoomScale The zoom scale of the editor
|
|
42670
43086
|
* @param forceMobile A boolean to force the use of touch controls for the helper
|
|
43087
|
+
* @param isTouchSupported Whether the current browser supports touch input
|
|
42671
43088
|
*/
|
|
42672
|
-
function DragAndDropHelper(trigger, context, onSubmit, handler, zoomScale, forceMobile) {
|
|
43089
|
+
function DragAndDropHelper(trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) {
|
|
42673
43090
|
var _this = this;
|
|
42674
43091
|
this.trigger = trigger;
|
|
42675
43092
|
this.context = context;
|
|
@@ -42679,23 +43096,29 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42679
43096
|
this.initX = 0;
|
|
42680
43097
|
this.initY = 0;
|
|
42681
43098
|
this.initValue = undefined;
|
|
43099
|
+
this.dndMouse = MOUSE_EVENT_INFO_DESKTOP;
|
|
42682
43100
|
this.onMouseDown = function (e) {
|
|
42683
43101
|
var _a;
|
|
42684
43102
|
var _b, _c;
|
|
42685
43103
|
e.preventDefault();
|
|
42686
43104
|
e.stopPropagation();
|
|
43105
|
+
_this.dndMouse =
|
|
43106
|
+
e.type == MOUSE_EVENT_INFO_MOBILE.MOUSEDOWN
|
|
43107
|
+
? MOUSE_EVENT_INFO_MOBILE
|
|
43108
|
+
: MOUSE_EVENT_INFO_DESKTOP;
|
|
42687
43109
|
_this.addDocumentEvents();
|
|
42688
|
-
|
|
42689
|
-
|
|
43110
|
+
var event = _this.dndMouse.normalizeEvent(e);
|
|
43111
|
+
_a = (0, tslib_1.__read)([event.pageX, event.pageY], 2), _this.initX = _a[0], _this.initY = _a[1];
|
|
43112
|
+
_this.initValue = (_c = (_b = _this.handler).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, _this.context, event);
|
|
42690
43113
|
};
|
|
42691
43114
|
this.onMouseMove = function (e) {
|
|
42692
43115
|
var _a, _b, _c;
|
|
42693
43116
|
e.preventDefault();
|
|
42694
|
-
var
|
|
42695
|
-
var deltaX = (pageX - _this.initX) / _this.zoomScale;
|
|
42696
|
-
var deltaY = (pageY - _this.initY) / _this.zoomScale;
|
|
43117
|
+
var event = _this.dndMouse.normalizeEvent(e);
|
|
43118
|
+
var deltaX = (event.pageX - _this.initX) / _this.zoomScale;
|
|
43119
|
+
var deltaY = (event.pageY - _this.initY) / _this.zoomScale;
|
|
42697
43120
|
if (_this.initValue &&
|
|
42698
|
-
((_b = (_a = _this.handler).onDragging) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context,
|
|
43121
|
+
((_b = (_a = _this.handler).onDragging) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, event, _this.initValue, deltaX, deltaY))) {
|
|
42699
43122
|
(_c = _this.onSubmit) === null || _c === void 0 ? void 0 : _c.call(_this, _this.context, _this.trigger);
|
|
42700
43123
|
}
|
|
42701
43124
|
};
|
|
@@ -42703,18 +43126,33 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42703
43126
|
var _a, _b, _c;
|
|
42704
43127
|
e.preventDefault();
|
|
42705
43128
|
_this.removeDocumentEvents();
|
|
42706
|
-
if ((_b = (_a = _this.handler).onDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, e, _this.initValue)) {
|
|
43129
|
+
if ((_b = (_a = _this.handler).onDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, _this.dndMouse.normalizeEvent(e), _this.initValue)) {
|
|
42707
43130
|
(_c = _this.onSubmit) === null || _c === void 0 ? void 0 : _c.call(_this, _this.context, _this.trigger);
|
|
42708
43131
|
}
|
|
42709
43132
|
};
|
|
42710
|
-
this.
|
|
42711
|
-
|
|
43133
|
+
this.dndMouseList = forceMobile
|
|
43134
|
+
? [MOUSE_EVENT_INFO_MOBILE]
|
|
43135
|
+
: isTouchSupported
|
|
43136
|
+
? [MOUSE_EVENT_INFO_DESKTOP, MOUSE_EVENT_INFO_MOBILE]
|
|
43137
|
+
: [MOUSE_EVENT_INFO_DESKTOP];
|
|
43138
|
+
this.dndMouse = this.dndMouseList[0];
|
|
43139
|
+
this.originalTouchAction = trigger.style.touchAction;
|
|
43140
|
+
if (this.dndMouseList.indexOf(MOUSE_EVENT_INFO_MOBILE) >= 0) {
|
|
43141
|
+
trigger.style.touchAction = 'none';
|
|
43142
|
+
}
|
|
43143
|
+
this.dndMouseList.forEach(function (eventInfo) {
|
|
43144
|
+
return trigger.addEventListener(eventInfo.MOUSEDOWN, _this.onMouseDown, { passive: false });
|
|
43145
|
+
});
|
|
42712
43146
|
}
|
|
42713
43147
|
/**
|
|
42714
43148
|
* Dispose this object, remove all event listeners that has been attached
|
|
42715
43149
|
*/
|
|
42716
43150
|
DragAndDropHelper.prototype.dispose = function () {
|
|
42717
|
-
|
|
43151
|
+
var _this = this;
|
|
43152
|
+
this.dndMouseList.forEach(function (eventInfo) {
|
|
43153
|
+
return _this.trigger.removeEventListener(eventInfo.MOUSEDOWN, _this.onMouseDown);
|
|
43154
|
+
});
|
|
43155
|
+
this.trigger.style.touchAction = this.originalTouchAction;
|
|
42718
43156
|
this.removeDocumentEvents();
|
|
42719
43157
|
};
|
|
42720
43158
|
Object.defineProperty(DragAndDropHelper.prototype, "mouseType", {
|
|
@@ -42726,8 +43164,14 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42726
43164
|
});
|
|
42727
43165
|
DragAndDropHelper.prototype.addDocumentEvents = function () {
|
|
42728
43166
|
var doc = this.trigger.ownerDocument;
|
|
42729
|
-
doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove,
|
|
42730
|
-
|
|
43167
|
+
doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, {
|
|
43168
|
+
capture: true,
|
|
43169
|
+
passive: false,
|
|
43170
|
+
});
|
|
43171
|
+
doc.addEventListener(this.dndMouse.MOUSEUP, this.onMouseUp, {
|
|
43172
|
+
capture: true,
|
|
43173
|
+
passive: false,
|
|
43174
|
+
});
|
|
42731
43175
|
};
|
|
42732
43176
|
DragAndDropHelper.prototype.removeDocumentEvents = function () {
|
|
42733
43177
|
var doc = this.trigger.ownerDocument;
|
|
@@ -43265,32 +43709,23 @@ var TableEditPlugin = /** @class */ (function () {
|
|
|
43265
43709
|
}
|
|
43266
43710
|
};
|
|
43267
43711
|
this.onMouseMove = function (event) {
|
|
43268
|
-
var _a
|
|
43712
|
+
var _a;
|
|
43269
43713
|
var e = event;
|
|
43270
43714
|
var editorWindow = (_a = _this.editor) === null || _a === void 0 ? void 0 : _a.getDocument().defaultView;
|
|
43271
43715
|
if (e.buttons > 0 || !editorWindow) {
|
|
43272
43716
|
return;
|
|
43273
43717
|
}
|
|
43274
|
-
_this.ensureTableRects();
|
|
43275
43718
|
var x = e.pageX - editorWindow.scrollX;
|
|
43276
43719
|
var y = e.pageY - editorWindow.scrollY;
|
|
43277
|
-
|
|
43278
|
-
|
|
43279
|
-
|
|
43280
|
-
|
|
43281
|
-
|
|
43282
|
-
|
|
43283
|
-
|
|
43284
|
-
|
|
43285
|
-
y >= rect.top - TABLE_RESIZER_LENGTH &&
|
|
43286
|
-
y <= rect.bottom + TABLE_RESIZER_LENGTH) {
|
|
43287
|
-
currentTable = entry;
|
|
43288
|
-
break;
|
|
43289
|
-
}
|
|
43290
|
-
}
|
|
43720
|
+
_this.updateTableEditor(x, y, event, true /* updateHoveredFeature */);
|
|
43721
|
+
};
|
|
43722
|
+
this.onTouchStart = function (event) {
|
|
43723
|
+
var _a;
|
|
43724
|
+
var touchEvent = event;
|
|
43725
|
+
var touch = (_a = touchEvent.targetTouches[0]) !== null && _a !== void 0 ? _a : touchEvent.changedTouches[0];
|
|
43726
|
+
if (touch) {
|
|
43727
|
+
_this.updateTableEditor(touch.clientX, touch.clientY, event, false /* updateHoveredFeature */);
|
|
43291
43728
|
}
|
|
43292
|
-
_this.setTableEditor(currentTable, e);
|
|
43293
|
-
(_b = _this.tableEditor) === null || _b === void 0 ? void 0 : _b.onMouseMove(x, y);
|
|
43294
43729
|
};
|
|
43295
43730
|
this.invalidateTableRects = function () {
|
|
43296
43731
|
_this.tableRectMap = null;
|
|
@@ -43310,6 +43745,7 @@ var TableEditPlugin = /** @class */ (function () {
|
|
|
43310
43745
|
this.editor = editor;
|
|
43311
43746
|
this.onMouseMoveDisposer = this.editor.attachDomEvent({
|
|
43312
43747
|
mousemove: { beforeDispatch: this.onMouseMove },
|
|
43748
|
+
touchstart: { beforeDispatch: this.onTouchStart },
|
|
43313
43749
|
});
|
|
43314
43750
|
var scrollContainer = this.editor.getScrollContainer();
|
|
43315
43751
|
scrollContainer.addEventListener('mouseout', this.onMouseOut);
|
|
@@ -43343,6 +43779,32 @@ var TableEditPlugin = /** @class */ (function () {
|
|
|
43343
43779
|
break;
|
|
43344
43780
|
}
|
|
43345
43781
|
};
|
|
43782
|
+
TableEditPlugin.prototype.updateTableEditor = function (x, y, event, updateHoveredFeature) {
|
|
43783
|
+
var _a, _b;
|
|
43784
|
+
this.ensureTableRects();
|
|
43785
|
+
var currentTable = null;
|
|
43786
|
+
//Find table in range of mouse
|
|
43787
|
+
if (this.tableRectMap) {
|
|
43788
|
+
for (var i = this.tableRectMap.length - 1; i >= 0; i--) {
|
|
43789
|
+
var entry = this.tableRectMap[i];
|
|
43790
|
+
var rect = entry.rect;
|
|
43791
|
+
if (x >= rect.left - TABLE_RESIZER_LENGTH &&
|
|
43792
|
+
x <= rect.right + TABLE_RESIZER_LENGTH &&
|
|
43793
|
+
y >= rect.top - TABLE_RESIZER_LENGTH &&
|
|
43794
|
+
y <= rect.bottom + TABLE_RESIZER_LENGTH) {
|
|
43795
|
+
currentTable = entry;
|
|
43796
|
+
break;
|
|
43797
|
+
}
|
|
43798
|
+
}
|
|
43799
|
+
}
|
|
43800
|
+
this.setTableEditor(currentTable, event);
|
|
43801
|
+
if (updateHoveredFeature) {
|
|
43802
|
+
(_a = this.tableEditor) === null || _a === void 0 ? void 0 : _a.onMouseMove(x, y);
|
|
43803
|
+
}
|
|
43804
|
+
else {
|
|
43805
|
+
(_b = this.tableEditor) === null || _b === void 0 ? void 0 : _b.onTouchStart(x, y);
|
|
43806
|
+
}
|
|
43807
|
+
};
|
|
43346
43808
|
/**
|
|
43347
43809
|
* @internal Public only for unit test
|
|
43348
43810
|
* @param entry Table to use when setting the Editors
|
|
@@ -43677,6 +44139,26 @@ var TableEditor = /** @class */ (function () {
|
|
|
43677
44139
|
// Create Mover and Resizer
|
|
43678
44140
|
this.setEditorFeatures();
|
|
43679
44141
|
};
|
|
44142
|
+
/**
|
|
44143
|
+
* Public only for testing purposes
|
|
44144
|
+
*/
|
|
44145
|
+
TableEditor.prototype.onTouchStart = function (x, y) {
|
|
44146
|
+
for (var rowIndex = 0; rowIndex < this.table.rows.length; rowIndex++) {
|
|
44147
|
+
var row = this.table.rows[rowIndex];
|
|
44148
|
+
for (var cellIndex = 0; cellIndex < row.cells.length; cellIndex++) {
|
|
44149
|
+
var td = row.cells[cellIndex];
|
|
44150
|
+
var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(td.getBoundingClientRect());
|
|
44151
|
+
if (rect &&
|
|
44152
|
+
x >= rect.left &&
|
|
44153
|
+
x <= rect.right &&
|
|
44154
|
+
y >= rect.top &&
|
|
44155
|
+
y <= rect.bottom) {
|
|
44156
|
+
!this.isFeatureDisabled('CellResizer') && this.setResizingTd(td);
|
|
44157
|
+
return;
|
|
44158
|
+
}
|
|
44159
|
+
}
|
|
44160
|
+
}
|
|
44161
|
+
};
|
|
43680
44162
|
TableEditor.prototype.setEditorFeatures = function () {
|
|
43681
44163
|
var disableSelector = this.isFeatureDisabled('TableSelector');
|
|
43682
44164
|
var disableMovement = this.isFeatureDisabled('TableMover');
|
|
@@ -43838,14 +44320,14 @@ function createCellResizer(editor, td, table, isRTL, isHorizontal, onStart, onEn
|
|
|
43838
44320
|
onDragging: isHorizontal ? onDraggingHorizontal : onDraggingVertical,
|
|
43839
44321
|
onDragEnd: onEnd,
|
|
43840
44322
|
};
|
|
43841
|
-
var featureHandler = new CellResizer(div, context, setPosition, handler, zoomScale, editor.getEnvironment().isMobileOrTablet, onTableEditorCreated);
|
|
44323
|
+
var featureHandler = new CellResizer(div, context, setPosition, handler, zoomScale, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported, onTableEditorCreated);
|
|
43842
44324
|
return { node: td, div: div, featureHandler: featureHandler };
|
|
43843
44325
|
}
|
|
43844
44326
|
exports.createCellResizer = createCellResizer;
|
|
43845
44327
|
var CellResizer = /** @class */ (function (_super) {
|
|
43846
44328
|
(0, tslib_1.__extends)(CellResizer, _super);
|
|
43847
|
-
function CellResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, onTableEditorCreated) {
|
|
43848
|
-
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
44329
|
+
function CellResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported, onTableEditorCreated) {
|
|
44330
|
+
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
43849
44331
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated('CellResizer', trigger);
|
|
43850
44332
|
return _this;
|
|
43851
44333
|
}
|
|
@@ -44274,14 +44756,14 @@ function createTableMover(table, editor, isRTL, onFinishDragging, onStart, onEnd
|
|
|
44274
44756
|
onDragStart: onDragStart,
|
|
44275
44757
|
onDragging: onDragging,
|
|
44276
44758
|
onDragEnd: onDragEnd,
|
|
44277
|
-
}, context.zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet);
|
|
44759
|
+
}, context.zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported);
|
|
44278
44760
|
return { node: table, div: div, featureHandler: featureHandler };
|
|
44279
44761
|
}
|
|
44280
44762
|
exports.createTableMover = createTableMover;
|
|
44281
44763
|
var TableMoverFeature = /** @class */ (function (_super) {
|
|
44282
44764
|
(0, tslib_1.__extends)(TableMoverFeature, _super);
|
|
44283
|
-
function TableMoverFeature(div, context, onSubmit, handler, zoomScale, onTableEditorCreated, forceMobile) {
|
|
44284
|
-
var _this = _super.call(this, div, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
44765
|
+
function TableMoverFeature(div, context, onSubmit, handler, zoomScale, onTableEditorCreated, forceMobile, isTouchSupported) {
|
|
44766
|
+
var _this = _super.call(this, div, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
44285
44767
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated('TableMover', div);
|
|
44286
44768
|
return _this;
|
|
44287
44769
|
}
|
|
@@ -44511,14 +44993,14 @@ function createTableResizer(table, editor, isRTL, onStart, onEnd, contentDiv, an
|
|
|
44511
44993
|
onDragStart: onDragStart,
|
|
44512
44994
|
onDragging: onDragging,
|
|
44513
44995
|
onDragEnd: onDragEnd,
|
|
44514
|
-
}, zoomScale, editor.getEnvironment().isMobileOrTablet, onTableEditorCreated);
|
|
44996
|
+
}, zoomScale, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported, onTableEditorCreated);
|
|
44515
44997
|
return { node: table, div: div, featureHandler: featureHandler };
|
|
44516
44998
|
}
|
|
44517
44999
|
exports.createTableResizer = createTableResizer;
|
|
44518
45000
|
var TableResizer = /** @class */ (function (_super) {
|
|
44519
45001
|
(0, tslib_1.__extends)(TableResizer, _super);
|
|
44520
|
-
function TableResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, onTableEditorCreated) {
|
|
44521
|
-
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
45002
|
+
function TableResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported, onTableEditorCreated) {
|
|
45003
|
+
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
44522
45004
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated('TableResizer', trigger);
|
|
44523
45005
|
return _this;
|
|
44524
45006
|
}
|
|
@@ -44705,7 +45187,7 @@ function createTableRowColumnSelector(editor, table, isRowSelector, anchorContai
|
|
|
44705
45187
|
onDragStart: onDragStart,
|
|
44706
45188
|
onDragging: onDragging,
|
|
44707
45189
|
onDragEnd: onDragEnd,
|
|
44708
|
-
}, zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet);
|
|
45190
|
+
}, zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported);
|
|
44709
45191
|
handlers.push(handler);
|
|
44710
45192
|
}
|
|
44711
45193
|
});
|
|
@@ -44720,8 +45202,8 @@ function createTableRowColumnSelector(editor, table, isRowSelector, anchorContai
|
|
|
44720
45202
|
exports.createTableRowColumnSelector = createTableRowColumnSelector;
|
|
44721
45203
|
var TableRowColumnSelectorHandler = /** @class */ (function (_super) {
|
|
44722
45204
|
(0, tslib_1.__extends)(TableRowColumnSelectorHandler, _super);
|
|
44723
|
-
function TableRowColumnSelectorHandler(div, isRow, context, handler, zoomScale, onTableEditorCreated, forceMobile) {
|
|
44724
|
-
var _this = _super.call(this, div, context, function () { }, handler, zoomScale, forceMobile) || this;
|
|
45205
|
+
function TableRowColumnSelectorHandler(div, isRow, context, handler, zoomScale, onTableEditorCreated, forceMobile, isTouchSupported) {
|
|
45206
|
+
var _this = _super.call(this, div, context, function () { }, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
44725
45207
|
_this.isRow = isRow;
|
|
44726
45208
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated(_this.isRow ? 'TableRowSelector' : 'TableColumnSelector', div);
|
|
44727
45209
|
return _this;
|