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