roosterjs 9.59.0 → 9.61.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-amd-min.js +1 -1
- package/dist/rooster-amd-min.js.map +1 -1
- package/dist/rooster-amd.d.ts +23 -1
- package/dist/rooster-amd.js +470 -175
- 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.js +92 -92
- package/dist/rooster-react.js.map +1 -1
- package/dist/rooster.d.ts +23 -1
- package/dist/rooster.js +470 -175
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
package/dist/rooster-amd.js
CHANGED
|
@@ -4915,73 +4915,6 @@ function alignTableCellInternal(table, callback) {
|
|
|
4915
4915
|
}
|
|
4916
4916
|
|
|
4917
4917
|
|
|
4918
|
-
/***/ },
|
|
4919
|
-
|
|
4920
|
-
/***/ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts"
|
|
4921
|
-
/*!**********************************************************************************!*\
|
|
4922
|
-
!*** ./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts ***!
|
|
4923
|
-
\**********************************************************************************/
|
|
4924
|
-
(__unused_webpack_module, exports) {
|
|
4925
|
-
|
|
4926
|
-
"use strict";
|
|
4927
|
-
|
|
4928
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4929
|
-
exports.canMergeCells = void 0;
|
|
4930
|
-
/**
|
|
4931
|
-
* @internal
|
|
4932
|
-
*/
|
|
4933
|
-
function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
|
|
4934
|
-
var noSpanAbove = firstCol == lastCol ||
|
|
4935
|
-
rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
|
|
4936
|
-
var noSpanLeft = firstRow == lastRow ||
|
|
4937
|
-
rows.every(function (row, rowIndex) {
|
|
4938
|
-
return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
|
|
4939
|
-
});
|
|
4940
|
-
var noDifferentBelowSpan = rows[lastRow].cells
|
|
4941
|
-
.map(function (_, colIndex) {
|
|
4942
|
-
return colIndex >= firstCol && colIndex <= lastCol
|
|
4943
|
-
? getBelowSpanCount(rows, lastRow, colIndex)
|
|
4944
|
-
: -1;
|
|
4945
|
-
})
|
|
4946
|
-
.every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
|
|
4947
|
-
var noDifferentRightSpan = rows
|
|
4948
|
-
.map(function (_, rowIndex) {
|
|
4949
|
-
return rowIndex >= firstRow && rowIndex <= lastRow
|
|
4950
|
-
? getRightSpanCount(rows, rowIndex, lastCol)
|
|
4951
|
-
: -1;
|
|
4952
|
-
})
|
|
4953
|
-
.every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
|
|
4954
|
-
return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
|
|
4955
|
-
}
|
|
4956
|
-
exports.canMergeCells = canMergeCells;
|
|
4957
|
-
function getBelowSpanCount(rows, rowIndex, colIndex) {
|
|
4958
|
-
var _a, _b;
|
|
4959
|
-
var spanCount = 0;
|
|
4960
|
-
for (var row = rowIndex + 1; row < rows.length; row++) {
|
|
4961
|
-
if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
4962
|
-
spanCount++;
|
|
4963
|
-
}
|
|
4964
|
-
else {
|
|
4965
|
-
break;
|
|
4966
|
-
}
|
|
4967
|
-
}
|
|
4968
|
-
return spanCount;
|
|
4969
|
-
}
|
|
4970
|
-
function getRightSpanCount(rows, rowIndex, colIndex) {
|
|
4971
|
-
var _a, _b, _c;
|
|
4972
|
-
var spanCount = 0;
|
|
4973
|
-
for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
|
|
4974
|
-
if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
|
|
4975
|
-
spanCount++;
|
|
4976
|
-
}
|
|
4977
|
-
else {
|
|
4978
|
-
break;
|
|
4979
|
-
}
|
|
4980
|
-
}
|
|
4981
|
-
return spanCount;
|
|
4982
|
-
}
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
4918
|
/***/ },
|
|
4986
4919
|
|
|
4987
4920
|
/***/ "./packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"
|
|
@@ -5341,7 +5274,6 @@ exports.insertTableRow = insertTableRow;
|
|
|
5341
5274
|
|
|
5342
5275
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5343
5276
|
exports.mergeTableCells = void 0;
|
|
5344
|
-
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts");
|
|
5345
5277
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
5346
5278
|
/**
|
|
5347
5279
|
* @internal
|
|
@@ -5349,7 +5281,16 @@ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-mo
|
|
|
5349
5281
|
function mergeTableCells(table) {
|
|
5350
5282
|
var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(table);
|
|
5351
5283
|
if (sel &&
|
|
5352
|
-
(0,
|
|
5284
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, sel.firstRow, sel.firstColumn, sel.lastRow, sel.lastColumn)) {
|
|
5285
|
+
var firstCell = (0, roosterjs_content_model_dom_1.mutateBlock)(table.rows[sel.firstRow].cells[sel.firstColumn]);
|
|
5286
|
+
var borderTop = getHorizontalBorder(table, sel.firstRow, sel, 'borderTop');
|
|
5287
|
+
var borderRight = getVerticalBorder(table, sel.lastColumn, sel, 'borderRight');
|
|
5288
|
+
var borderBottom = getHorizontalBorder(table, sel.lastRow, sel, 'borderBottom');
|
|
5289
|
+
var borderLeft = getVerticalBorder(table, sel.firstColumn, sel, 'borderLeft');
|
|
5290
|
+
setBorder(firstCell.format, 'borderTop', borderTop);
|
|
5291
|
+
setBorder(firstCell.format, 'borderRight', borderRight);
|
|
5292
|
+
setBorder(firstCell.format, 'borderBottom', borderBottom);
|
|
5293
|
+
setBorder(firstCell.format, 'borderLeft', borderLeft);
|
|
5353
5294
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
5354
5295
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
5355
5296
|
var cell = table.rows[rowIndex].cells[colIndex];
|
|
@@ -5363,6 +5304,32 @@ function mergeTableCells(table) {
|
|
|
5363
5304
|
}
|
|
5364
5305
|
}
|
|
5365
5306
|
exports.mergeTableCells = mergeTableCells;
|
|
5307
|
+
function getHorizontalBorder(table, rowIndex, sel, borderKey) {
|
|
5308
|
+
var border = table.rows[rowIndex].cells[sel.firstColumn].format[borderKey];
|
|
5309
|
+
return border &&
|
|
5310
|
+
table.rows[rowIndex].cells
|
|
5311
|
+
.slice(sel.firstColumn, sel.lastColumn + 1)
|
|
5312
|
+
.every(function (cell) { return cell.format[borderKey] == border; })
|
|
5313
|
+
? border
|
|
5314
|
+
: undefined;
|
|
5315
|
+
}
|
|
5316
|
+
function getVerticalBorder(table, columnIndex, sel, borderKey) {
|
|
5317
|
+
var border = table.rows[sel.firstRow].cells[columnIndex].format[borderKey];
|
|
5318
|
+
return border &&
|
|
5319
|
+
table.rows
|
|
5320
|
+
.slice(sel.firstRow, sel.lastRow + 1)
|
|
5321
|
+
.every(function (row) { return row.cells[columnIndex].format[borderKey] == border; })
|
|
5322
|
+
? border
|
|
5323
|
+
: undefined;
|
|
5324
|
+
}
|
|
5325
|
+
function setBorder(format, borderKey, border) {
|
|
5326
|
+
if (border) {
|
|
5327
|
+
format[borderKey] = border;
|
|
5328
|
+
}
|
|
5329
|
+
else {
|
|
5330
|
+
delete format[borderKey];
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5366
5333
|
|
|
5367
5334
|
|
|
5368
5335
|
/***/ },
|
|
@@ -5377,7 +5344,6 @@ exports.mergeTableCells = mergeTableCells;
|
|
|
5377
5344
|
|
|
5378
5345
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5379
5346
|
exports.mergeTableColumn = void 0;
|
|
5380
|
-
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts");
|
|
5381
5347
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
5382
5348
|
/**
|
|
5383
5349
|
* @internal
|
|
@@ -5392,7 +5358,7 @@ function mergeTableColumn(table, operation) {
|
|
|
5392
5358
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
5393
5359
|
var cell = (_a = table.rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells[mergingColIndex];
|
|
5394
5360
|
if (cell &&
|
|
5395
|
-
(0,
|
|
5361
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, rowIndex, mergingColIndex - 1, rowIndex, mergingColIndex)) {
|
|
5396
5362
|
(0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanLeft = true;
|
|
5397
5363
|
var newSelectedCol = mergingColIndex;
|
|
5398
5364
|
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 +5389,6 @@ exports.mergeTableColumn = mergeTableColumn;
|
|
|
5423
5389
|
|
|
5424
5390
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5425
5391
|
exports.mergeTableRow = void 0;
|
|
5426
|
-
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts");
|
|
5427
5392
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
5428
5393
|
/**
|
|
5429
5394
|
* @internal
|
|
@@ -5438,7 +5403,7 @@ function mergeTableRow(table, operation) {
|
|
|
5438
5403
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
5439
5404
|
var cell = table.rows[mergingRowIndex].cells[colIndex];
|
|
5440
5405
|
if (cell &&
|
|
5441
|
-
(0,
|
|
5406
|
+
(0, roosterjs_content_model_dom_1.canMergeCells)(table.rows, mergingRowIndex - 1, colIndex, mergingRowIndex, colIndex)) {
|
|
5442
5407
|
(0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanAbove = true;
|
|
5443
5408
|
var newSelectedRow = mergingRowIndex;
|
|
5444
5409
|
while ((_b = (_a = table.rows[newSelectedRow]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
@@ -6504,7 +6469,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
6504
6469
|
exports.insertLink = void 0;
|
|
6505
6470
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
6506
6471
|
var adjustTrailingSpaceSelection_1 = __webpack_require__(/*! ../../modelApi/selection/adjustTrailingSpaceSelection */ "./packages/roosterjs-content-model-api/lib/modelApi/selection/adjustTrailingSpaceSelection.ts");
|
|
6507
|
-
var checkXss_1 = __webpack_require__(/*! ../utils/checkXss */ "./packages/roosterjs-content-model-api/lib/publicApi/utils/checkXss.ts");
|
|
6508
6472
|
var matchLink_1 = __webpack_require__(/*! ../../modelApi/link/matchLink */ "./packages/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts");
|
|
6509
6473
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
6510
6474
|
// Regex matching Uri scheme
|
|
@@ -6528,7 +6492,7 @@ var FTP_REGEX = /^ftp\./i;
|
|
|
6528
6492
|
*/
|
|
6529
6493
|
function insertLink(editor, link, anchorTitle, displayText, target) {
|
|
6530
6494
|
editor.focus();
|
|
6531
|
-
var url = ((0,
|
|
6495
|
+
var url = ((0, roosterjs_content_model_dom_1.isUnsafeUrl)(link) ? '' : link || '').trim();
|
|
6532
6496
|
if (url) {
|
|
6533
6497
|
var linkData_1 = (0, matchLink_1.matchLink)(url);
|
|
6534
6498
|
var linkUrl_1 = linkData_1 ? linkData_1.normalizedUrl : applyLinkPrefix(url);
|
|
@@ -7420,13 +7384,15 @@ var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.m
|
|
|
7420
7384
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
7421
7385
|
/**
|
|
7422
7386
|
* Operations to apply border
|
|
7387
|
+
* Remove the targeted borders instead if they all already match the requested format.
|
|
7423
7388
|
* @param editor The editor instance
|
|
7424
7389
|
* @param border The border to apply
|
|
7425
7390
|
* @param operation The operation to apply
|
|
7426
7391
|
*/
|
|
7427
7392
|
function applyTableBorderFormat(editor, border, operation) {
|
|
7428
7393
|
editor.formatContentModel(function (model) {
|
|
7429
|
-
var
|
|
7394
|
+
var e_1, _a;
|
|
7395
|
+
var _b = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 1), tableModel = _b[0];
|
|
7430
7396
|
if (tableModel) {
|
|
7431
7397
|
var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(tableModel);
|
|
7432
7398
|
var perimeter = {
|
|
@@ -7470,6 +7436,10 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7470
7436
|
// undefined is treated as Left to Right
|
|
7471
7437
|
var isRtl = tableModel.format.direction == 'rtl';
|
|
7472
7438
|
if (sel) {
|
|
7439
|
+
var borderUpdates_2 = [];
|
|
7440
|
+
var collectBorderFormat = function (cell, positions) {
|
|
7441
|
+
borderUpdates_2.push({ cell: cell, positions: positions });
|
|
7442
|
+
};
|
|
7473
7443
|
var operations = [operation];
|
|
7474
7444
|
while (operations.length) {
|
|
7475
7445
|
switch (operations.pop()) {
|
|
@@ -7489,7 +7459,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7489
7459
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
7490
7460
|
var cell = tableModel.rows[rowIndex].cells[colIndex];
|
|
7491
7461
|
// Format cells - All borders
|
|
7492
|
-
|
|
7462
|
+
collectBorderFormat(cell, allBorders);
|
|
7493
7463
|
}
|
|
7494
7464
|
}
|
|
7495
7465
|
// Format perimeter
|
|
@@ -7503,7 +7473,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7503
7473
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
7504
7474
|
var cell = tableModel.rows[rowIndex].cells[isRtl ? sel.lastColumn : sel.firstColumn];
|
|
7505
7475
|
// Format cells - Left border
|
|
7506
|
-
|
|
7476
|
+
collectBorderFormat(cell, leftBorder);
|
|
7507
7477
|
}
|
|
7508
7478
|
// Format perimeter
|
|
7509
7479
|
isRtl ? (perimeter.Right = true) : (perimeter.Left = true);
|
|
@@ -7513,7 +7483,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7513
7483
|
for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
|
|
7514
7484
|
var cell = tableModel.rows[rowIndex].cells[isRtl ? sel.firstColumn : sel.lastColumn];
|
|
7515
7485
|
// Format cells - Right border
|
|
7516
|
-
|
|
7486
|
+
collectBorderFormat(cell, rightBorder);
|
|
7517
7487
|
}
|
|
7518
7488
|
// Format perimeter
|
|
7519
7489
|
isRtl ? (perimeter.Left = true) : (perimeter.Right = true);
|
|
@@ -7523,7 +7493,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7523
7493
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
7524
7494
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
7525
7495
|
// Format cells - Top border
|
|
7526
|
-
|
|
7496
|
+
collectBorderFormat(cell, topBorder);
|
|
7527
7497
|
}
|
|
7528
7498
|
// Format perimeter
|
|
7529
7499
|
perimeter.Top = true;
|
|
@@ -7533,7 +7503,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7533
7503
|
for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
|
|
7534
7504
|
var cell = tableModel.rows[sel.lastRow].cells[colIndex];
|
|
7535
7505
|
// Format cells - Bottom border
|
|
7536
|
-
|
|
7506
|
+
collectBorderFormat(cell, bottomBorder);
|
|
7537
7507
|
}
|
|
7538
7508
|
// Format perimeter
|
|
7539
7509
|
perimeter.Bottom = true;
|
|
@@ -7548,43 +7518,37 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7548
7518
|
}
|
|
7549
7519
|
// Single column selection
|
|
7550
7520
|
if (singleCol) {
|
|
7551
|
-
|
|
7521
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstColumn], ['borderBottom']);
|
|
7552
7522
|
for (var rowIndex = sel.firstRow + 1; rowIndex <= sel.lastRow - 1; rowIndex++) {
|
|
7553
7523
|
var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
|
|
7554
|
-
|
|
7555
|
-
'borderTop',
|
|
7556
|
-
'borderBottom',
|
|
7557
|
-
]);
|
|
7524
|
+
collectBorderFormat(cell, ['borderTop', 'borderBottom']);
|
|
7558
7525
|
}
|
|
7559
|
-
|
|
7526
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[sel.firstColumn], ['borderTop']);
|
|
7560
7527
|
break;
|
|
7561
7528
|
}
|
|
7562
7529
|
// Single row selection
|
|
7563
7530
|
if (singleRow) {
|
|
7564
|
-
|
|
7531
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderRight']);
|
|
7565
7532
|
for (var colIndex = sel.firstColumn + 1; colIndex <= sel.lastColumn - 1; colIndex++) {
|
|
7566
7533
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
7567
|
-
|
|
7568
|
-
'borderLeft',
|
|
7569
|
-
'borderRight',
|
|
7570
|
-
]);
|
|
7534
|
+
collectBorderFormat(cell, ['borderLeft', 'borderRight']);
|
|
7571
7535
|
}
|
|
7572
|
-
|
|
7536
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderLeft']);
|
|
7573
7537
|
break;
|
|
7574
7538
|
}
|
|
7575
7539
|
// For multiple rows and columns selections
|
|
7576
7540
|
// Top left cell
|
|
7577
|
-
|
|
7541
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderBottom', 'borderRight']);
|
|
7578
7542
|
// Top right cell
|
|
7579
|
-
|
|
7543
|
+
collectBorderFormat(tableModel.rows[sel.firstRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderBottom', 'borderLeft']);
|
|
7580
7544
|
// Bottom left cell
|
|
7581
|
-
|
|
7545
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[isRtl ? sel.lastColumn : sel.firstColumn], ['borderTop', 'borderRight']);
|
|
7582
7546
|
// Bottom right cell
|
|
7583
|
-
|
|
7547
|
+
collectBorderFormat(tableModel.rows[sel.lastRow].cells[isRtl ? sel.firstColumn : sel.lastColumn], ['borderTop', 'borderLeft']);
|
|
7584
7548
|
// First row
|
|
7585
7549
|
for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
|
|
7586
7550
|
var cell = tableModel.rows[sel.firstRow].cells[colIndex];
|
|
7587
|
-
|
|
7551
|
+
collectBorderFormat(cell, [
|
|
7588
7552
|
'borderBottom',
|
|
7589
7553
|
'borderLeft',
|
|
7590
7554
|
'borderRight',
|
|
@@ -7593,7 +7557,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7593
7557
|
// Last row
|
|
7594
7558
|
for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
|
|
7595
7559
|
var cell = tableModel.rows[sel.lastRow].cells[colIndex];
|
|
7596
|
-
|
|
7560
|
+
collectBorderFormat(cell, [
|
|
7597
7561
|
'borderTop',
|
|
7598
7562
|
'borderLeft',
|
|
7599
7563
|
'borderRight',
|
|
@@ -7602,7 +7566,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7602
7566
|
// First column
|
|
7603
7567
|
for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
|
|
7604
7568
|
var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
|
|
7605
|
-
|
|
7569
|
+
collectBorderFormat(cell, [
|
|
7606
7570
|
'borderTop',
|
|
7607
7571
|
'borderBottom',
|
|
7608
7572
|
isRtl ? 'borderLeft' : 'borderRight',
|
|
@@ -7611,7 +7575,7 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7611
7575
|
// Last column
|
|
7612
7576
|
for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
|
|
7613
7577
|
var cell = tableModel.rows[rowIndex].cells[sel.lastColumn];
|
|
7614
|
-
|
|
7578
|
+
collectBorderFormat(cell, [
|
|
7615
7579
|
'borderTop',
|
|
7616
7580
|
'borderBottom',
|
|
7617
7581
|
isRtl ? 'borderRight' : 'borderLeft',
|
|
@@ -7635,6 +7599,26 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7635
7599
|
break;
|
|
7636
7600
|
}
|
|
7637
7601
|
}
|
|
7602
|
+
// Compare before changing any cells, and only consider borders targeted by
|
|
7603
|
+
// this operation. Normalize CSS so DOM colors (rgb) also match hex input.
|
|
7604
|
+
if (operation != 'noBorders' &&
|
|
7605
|
+
borderUpdates_2.length > 0 &&
|
|
7606
|
+
hasMatchingBorders(borderUpdates_2, borderFormat)) {
|
|
7607
|
+
borderFormat = '';
|
|
7608
|
+
}
|
|
7609
|
+
try {
|
|
7610
|
+
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()) {
|
|
7611
|
+
var _c = borderUpdates_1_1.value, cell = _c.cell, positions = _c.positions;
|
|
7612
|
+
applyBorderFormat(cell, borderFormat, positions);
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7616
|
+
finally {
|
|
7617
|
+
try {
|
|
7618
|
+
if (borderUpdates_1_1 && !borderUpdates_1_1.done && (_a = borderUpdates_1.return)) _a.call(borderUpdates_1);
|
|
7619
|
+
}
|
|
7620
|
+
finally { if (e_1) throw e_1.error; }
|
|
7621
|
+
}
|
|
7638
7622
|
//Format perimeter if necessary or possible
|
|
7639
7623
|
modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);
|
|
7640
7624
|
}
|
|
@@ -7653,6 +7637,64 @@ function applyTableBorderFormat(editor, border, operation) {
|
|
|
7653
7637
|
});
|
|
7654
7638
|
}
|
|
7655
7639
|
exports.applyTableBorderFormat = applyTableBorderFormat;
|
|
7640
|
+
/**
|
|
7641
|
+
* Check targeted borders without repeatedly parsing identical CSS values.
|
|
7642
|
+
* @param borderUpdates The borders to compare
|
|
7643
|
+
* @param borderFormat The requested border format
|
|
7644
|
+
*/
|
|
7645
|
+
function hasMatchingBorders(borderUpdates, borderFormat) {
|
|
7646
|
+
var e_2, _a, e_3, _b;
|
|
7647
|
+
var matchingBorders = new Set();
|
|
7648
|
+
try {
|
|
7649
|
+
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()) {
|
|
7650
|
+
var _c = borderUpdates_3_1.value, cell = _c.cell, positions = _c.positions;
|
|
7651
|
+
try {
|
|
7652
|
+
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()) {
|
|
7653
|
+
var pos = positions_1_1.value;
|
|
7654
|
+
var value = cell.format[pos] || '';
|
|
7655
|
+
// Exact matches need no CSS parsing. Equivalent values are parsed only once.
|
|
7656
|
+
if (value == borderFormat || matchingBorders.has(value)) {
|
|
7657
|
+
continue;
|
|
7658
|
+
}
|
|
7659
|
+
if (!areSameBorders(value, borderFormat)) {
|
|
7660
|
+
return false;
|
|
7661
|
+
}
|
|
7662
|
+
matchingBorders.add(value);
|
|
7663
|
+
}
|
|
7664
|
+
}
|
|
7665
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
7666
|
+
finally {
|
|
7667
|
+
try {
|
|
7668
|
+
if (positions_1_1 && !positions_1_1.done && (_b = positions_1.return)) _b.call(positions_1);
|
|
7669
|
+
}
|
|
7670
|
+
finally { if (e_3) throw e_3.error; }
|
|
7671
|
+
}
|
|
7672
|
+
}
|
|
7673
|
+
}
|
|
7674
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7675
|
+
finally {
|
|
7676
|
+
try {
|
|
7677
|
+
if (borderUpdates_3_1 && !borderUpdates_3_1.done && (_a = borderUpdates_3.return)) _a.call(borderUpdates_3);
|
|
7678
|
+
}
|
|
7679
|
+
finally { if (e_2) throw e_2.error; }
|
|
7680
|
+
}
|
|
7681
|
+
return true;
|
|
7682
|
+
}
|
|
7683
|
+
/**
|
|
7684
|
+
* Compare border components, parsing colors to account for equivalent hex and RGB values.
|
|
7685
|
+
*/
|
|
7686
|
+
function areSameBorders(border1, border2) {
|
|
7687
|
+
var values1 = (0, roosterjs_content_model_dom_1.extractBorderValues)(border1);
|
|
7688
|
+
var values2 = (0, roosterjs_content_model_dom_1.extractBorderValues)(border2);
|
|
7689
|
+
var color1 = values1.color || '';
|
|
7690
|
+
var color2 = values2.color || '';
|
|
7691
|
+
var rgb1 = (0, roosterjs_content_model_dom_1.parseColor)(color1);
|
|
7692
|
+
var rgb2 = (0, roosterjs_content_model_dom_1.parseColor)(color2);
|
|
7693
|
+
return (values1.width == values2.width &&
|
|
7694
|
+
values1.style == values2.style &&
|
|
7695
|
+
(color1 == color2 ||
|
|
7696
|
+
(!!rgb1 && !!rgb2 && rgb1[0] == rgb2[0] && rgb1[1] == rgb2[1] && rgb1[2] == rgb2[2])));
|
|
7697
|
+
}
|
|
7656
7698
|
/**
|
|
7657
7699
|
* @internal
|
|
7658
7700
|
* Apply border format to a cell
|
|
@@ -8006,31 +8048,6 @@ function setTableCellShade(editor, color) {
|
|
|
8006
8048
|
exports.setTableCellShade = setTableCellShade;
|
|
8007
8049
|
|
|
8008
8050
|
|
|
8009
|
-
/***/ },
|
|
8010
|
-
|
|
8011
|
-
/***/ "./packages/roosterjs-content-model-api/lib/publicApi/utils/checkXss.ts"
|
|
8012
|
-
/*!******************************************************************************!*\
|
|
8013
|
-
!*** ./packages/roosterjs-content-model-api/lib/publicApi/utils/checkXss.ts ***!
|
|
8014
|
-
\******************************************************************************/
|
|
8015
|
-
(__unused_webpack_module, exports) {
|
|
8016
|
-
|
|
8017
|
-
"use strict";
|
|
8018
|
-
|
|
8019
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8020
|
-
exports.checkXss = void 0;
|
|
8021
|
-
/**
|
|
8022
|
-
* @internal Check if there is XSS attack in the link
|
|
8023
|
-
* @param link The link to be checked
|
|
8024
|
-
* @returns The safe link, or empty string if there is XSS attack
|
|
8025
|
-
* @remarks This function checks for patterns like s\nc\nr\ni\np\nt: to prevent XSS attacks. This may block some valid links,
|
|
8026
|
-
* but it is necessary for security reasons. We treat the word "script" as safe if there are "/" before it.
|
|
8027
|
-
*/
|
|
8028
|
-
function checkXss(link) {
|
|
8029
|
-
return link.match(/^[^\/]*s\n*c\n*r\n*i\n*p\n*t\n*:/i) ? '' : link;
|
|
8030
|
-
}
|
|
8031
|
-
exports.checkXss = checkXss;
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
8051
|
/***/ },
|
|
8035
8052
|
|
|
8036
8053
|
/***/ "./packages/roosterjs-content-model-api/lib/publicApi/utils/createEditorContextForEntity.ts"
|
|
@@ -8813,7 +8830,6 @@ exports.AllowedTags = [
|
|
|
8813
8830
|
'ul',
|
|
8814
8831
|
'var',
|
|
8815
8832
|
'wbr',
|
|
8816
|
-
'xmp',
|
|
8817
8833
|
];
|
|
8818
8834
|
/**
|
|
8819
8835
|
* @internal
|
|
@@ -8998,7 +9014,7 @@ function createSanitizedElement(doc, tag, attributes, styleSanitizers, attribute
|
|
|
8998
9014
|
var attribute = attributes[i];
|
|
8999
9015
|
var name_1 = attribute.name.toLowerCase().trim();
|
|
9000
9016
|
var value = attribute.value;
|
|
9001
|
-
var sanitizer = attributeSanitizers
|
|
9017
|
+
var sanitizer = getOwnValue(attributeSanitizers, name_1);
|
|
9002
9018
|
var newValue = name_1 == 'style'
|
|
9003
9019
|
? processStyles(tag, value, styleSanitizers)
|
|
9004
9020
|
: typeof sanitizer == 'function'
|
|
@@ -9010,10 +9026,7 @@ function createSanitizedElement(doc, tag, attributes, styleSanitizers, attribute
|
|
|
9010
9026
|
: AllowedAttributes.indexOf(name_1) >= 0 || name_1.indexOf('data-') == 0
|
|
9011
9027
|
? value
|
|
9012
9028
|
: null;
|
|
9013
|
-
if (newValue !== null &&
|
|
9014
|
-
newValue !== undefined &&
|
|
9015
|
-
!newValue.match(/s\n*c\n*r\n*i\n*p\n*t\n*:/i) // match script: with any NewLine inside. Browser will ignore those NewLine char and still treat it as script prefix
|
|
9016
|
-
) {
|
|
9029
|
+
if (newValue !== null && newValue !== undefined && !(0, roosterjs_content_model_dom_1.isUnsafeUrl)(newValue)) {
|
|
9017
9030
|
element.setAttribute(name_1, newValue);
|
|
9018
9031
|
}
|
|
9019
9032
|
}
|
|
@@ -9031,7 +9044,7 @@ function processStyles(tagName, value, styleSanitizers) {
|
|
|
9031
9044
|
if (isCssVariable(value)) {
|
|
9032
9045
|
value = processCssVariable(value);
|
|
9033
9046
|
}
|
|
9034
|
-
var sanitizer = styleSanitizers
|
|
9047
|
+
var sanitizer = getOwnValue(styleSanitizers, name);
|
|
9035
9048
|
var sanitizedValue = typeof sanitizer == 'function'
|
|
9036
9049
|
? sanitizer(value, tagName)
|
|
9037
9050
|
: sanitizer === false
|
|
@@ -9042,7 +9055,7 @@ function processStyles(tagName, value, styleSanitizers) {
|
|
|
9042
9055
|
sanitizedValue != 'initial' &&
|
|
9043
9056
|
sanitizedValue.indexOf('expression') < 0 &&
|
|
9044
9057
|
!name.startsWith('-') &&
|
|
9045
|
-
DefaultStyleValue
|
|
9058
|
+
getOwnValue(DefaultStyleValue, name) != sanitizedValue) {
|
|
9046
9059
|
result.push(name + ":" + sanitizedValue);
|
|
9047
9060
|
}
|
|
9048
9061
|
}
|
|
@@ -9053,6 +9066,12 @@ function processCssVariable(value) {
|
|
|
9053
9066
|
var match = VARIABLE_REGEX.exec(value);
|
|
9054
9067
|
return (match === null || match === void 0 ? void 0 : match[2]) || ''; // Without fallback value, we don't know what does the original value mean, so ignore it
|
|
9055
9068
|
}
|
|
9069
|
+
// Attribute and style names come from the pasted content, so a name such as "valueOf" or
|
|
9070
|
+
// "hasOwnProperty" would otherwise resolve to the inherited member of Object.prototype and be
|
|
9071
|
+
// invoked as if it were a sanitizer, which throws and fails the whole conversion.
|
|
9072
|
+
function getOwnValue(map, name) {
|
|
9073
|
+
return map && Object.prototype.hasOwnProperty.call(map, name) ? map[name] : undefined;
|
|
9074
|
+
}
|
|
9056
9075
|
function isCssVariable(value) {
|
|
9057
9076
|
return value.indexOf(VARIABLE_PREFIX) == 0;
|
|
9058
9077
|
}
|
|
@@ -20587,6 +20606,48 @@ function isNodeOfType(node, expectedType) {
|
|
|
20587
20606
|
exports.isNodeOfType = isNodeOfType;
|
|
20588
20607
|
|
|
20589
20608
|
|
|
20609
|
+
/***/ },
|
|
20610
|
+
|
|
20611
|
+
/***/ "./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts"
|
|
20612
|
+
/*!**************************************************************************!*\
|
|
20613
|
+
!*** ./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts ***!
|
|
20614
|
+
\**************************************************************************/
|
|
20615
|
+
(__unused_webpack_module, exports) {
|
|
20616
|
+
|
|
20617
|
+
"use strict";
|
|
20618
|
+
|
|
20619
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
20620
|
+
exports.isUnsafeUrl = void 0;
|
|
20621
|
+
var UnsafeProtocols = ['javascript', 'vbscript', 'livescript', 'jscript', 'mocha', 'script'];
|
|
20622
|
+
var IgnoredCharacters = /[\t\n\r]/g;
|
|
20623
|
+
var MaxControlCharCode = 0x20;
|
|
20624
|
+
/**
|
|
20625
|
+
* Check whether the given URL uses a protocol that can execute script, such as "javascript:"
|
|
20626
|
+
* @param url The URL to check
|
|
20627
|
+
* @returns True if the URL can execute script when navigated to, otherwise false
|
|
20628
|
+
* @remarks Browsers remove every TAB, LF and CR character from a URL and ignore any leading control
|
|
20629
|
+
* character or space before they resolve its protocol. Those characters must be removed before the
|
|
20630
|
+
* protocol is checked here, otherwise a value such as "java	script:" or "javascr ipt:" would
|
|
20631
|
+
* be treated as safe but still executed by the browser.
|
|
20632
|
+
*/
|
|
20633
|
+
function isUnsafeUrl(url) {
|
|
20634
|
+
if (!url) {
|
|
20635
|
+
return false;
|
|
20636
|
+
}
|
|
20637
|
+
var normalizedUrl = trimControlCharacters(url.replace(IgnoredCharacters, '')).toLowerCase();
|
|
20638
|
+
var colonIndex = normalizedUrl.indexOf(':');
|
|
20639
|
+
return colonIndex >= 0 && UnsafeProtocols.indexOf(normalizedUrl.substring(0, colonIndex)) >= 0;
|
|
20640
|
+
}
|
|
20641
|
+
exports.isUnsafeUrl = isUnsafeUrl;
|
|
20642
|
+
function trimControlCharacters(url) {
|
|
20643
|
+
var start = 0;
|
|
20644
|
+
while (start < url.length && url.charCodeAt(start) <= MaxControlCharCode) {
|
|
20645
|
+
start++;
|
|
20646
|
+
}
|
|
20647
|
+
return url.substring(start);
|
|
20648
|
+
}
|
|
20649
|
+
|
|
20650
|
+
|
|
20590
20651
|
/***/ },
|
|
20591
20652
|
|
|
20592
20653
|
/***/ "./packages/roosterjs-content-model-dom/lib/domUtils/isWhiteSpacePreserved.ts"
|
|
@@ -23352,6 +23413,7 @@ exports.letterSpacingFormatHandler = {
|
|
|
23352
23413
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
23353
23414
|
exports.linkFormatHandler = void 0;
|
|
23354
23415
|
var isElementOfType_1 = __webpack_require__(/*! ../../domUtils/isElementOfType */ "./packages/roosterjs-content-model-dom/lib/domUtils/isElementOfType.ts");
|
|
23416
|
+
var isUnsafeUrl_1 = __webpack_require__(/*! ../../domUtils/isUnsafeUrl */ "./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts");
|
|
23355
23417
|
/**
|
|
23356
23418
|
* @internal
|
|
23357
23419
|
*/
|
|
@@ -23368,7 +23430,7 @@ exports.linkFormatHandler = {
|
|
|
23368
23430
|
if (name_1) {
|
|
23369
23431
|
format.name = name_1;
|
|
23370
23432
|
}
|
|
23371
|
-
if (href) {
|
|
23433
|
+
if (href && !(0, isUnsafeUrl_1.isUnsafeUrl)(href)) {
|
|
23372
23434
|
format.href = href;
|
|
23373
23435
|
}
|
|
23374
23436
|
if (target) {
|
|
@@ -23390,7 +23452,7 @@ exports.linkFormatHandler = {
|
|
|
23390
23452
|
},
|
|
23391
23453
|
apply: function (format, element) {
|
|
23392
23454
|
if ((0, isElementOfType_1.isElementOfType)(element, 'a') && (format.href || format.name)) {
|
|
23393
|
-
if (format.href) {
|
|
23455
|
+
if (format.href && !(0, isUnsafeUrl_1.isUnsafeUrl)(format.href)) {
|
|
23394
23456
|
element.href = format.href;
|
|
23395
23457
|
}
|
|
23396
23458
|
if (format.name) {
|
|
@@ -24155,10 +24217,10 @@ exports.shouldSetValue = shouldSetValue;
|
|
|
24155
24217
|
"use strict";
|
|
24156
24218
|
|
|
24157
24219
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24158
|
-
exports.
|
|
24159
|
-
exports.
|
|
24160
|
-
exports.
|
|
24161
|
-
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;
|
|
24220
|
+
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.isUnsafeUrl = 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;
|
|
24221
|
+
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 = exports.createImage = void 0;
|
|
24222
|
+
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 = exports.getDOMInsertPointRect = void 0;
|
|
24223
|
+
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 = exports.retrieveModelFormatState = void 0;
|
|
24162
24224
|
var domToContentModel_1 = __webpack_require__(/*! ./domToModel/domToContentModel */ "./packages/roosterjs-content-model-dom/lib/domToModel/domToContentModel.ts");
|
|
24163
24225
|
Object.defineProperty(exports, "domToContentModel", ({ enumerable: true, get: function () { return domToContentModel_1.domToContentModel; } }));
|
|
24164
24226
|
var contentModelToDom_1 = __webpack_require__(/*! ./modelToDom/contentModelToDom */ "./packages/roosterjs-content-model-dom/lib/modelToDom/contentModelToDom.ts");
|
|
@@ -24193,6 +24255,8 @@ var isNodeOfType_1 = __webpack_require__(/*! ./domUtils/isNodeOfType */ "./packa
|
|
|
24193
24255
|
Object.defineProperty(exports, "isNodeOfType", ({ enumerable: true, get: function () { return isNodeOfType_1.isNodeOfType; } }));
|
|
24194
24256
|
var isElementOfType_1 = __webpack_require__(/*! ./domUtils/isElementOfType */ "./packages/roosterjs-content-model-dom/lib/domUtils/isElementOfType.ts");
|
|
24195
24257
|
Object.defineProperty(exports, "isElementOfType", ({ enumerable: true, get: function () { return isElementOfType_1.isElementOfType; } }));
|
|
24258
|
+
var isUnsafeUrl_1 = __webpack_require__(/*! ./domUtils/isUnsafeUrl */ "./packages/roosterjs-content-model-dom/lib/domUtils/isUnsafeUrl.ts");
|
|
24259
|
+
Object.defineProperty(exports, "isUnsafeUrl", ({ enumerable: true, get: function () { return isUnsafeUrl_1.isUnsafeUrl; } }));
|
|
24196
24260
|
var getObjectKeys_1 = __webpack_require__(/*! ./domUtils/getObjectKeys */ "./packages/roosterjs-content-model-dom/lib/domUtils/getObjectKeys.ts");
|
|
24197
24261
|
Object.defineProperty(exports, "getObjectKeys", ({ enumerable: true, get: function () { return getObjectKeys_1.getObjectKeys; } }));
|
|
24198
24262
|
var getSafeIdSelector_1 = __webpack_require__(/*! ./domUtils/getSafeIdSelector */ "./packages/roosterjs-content-model-dom/lib/domUtils/getSafeIdSelector.ts");
|
|
@@ -24394,6 +24458,8 @@ Object.defineProperty(exports, "setSelection", ({ enumerable: true, get: functio
|
|
|
24394
24458
|
var cloneModel_1 = __webpack_require__(/*! ./modelApi/editing/cloneModel */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/cloneModel.ts");
|
|
24395
24459
|
Object.defineProperty(exports, "cloneModel", ({ enumerable: true, get: function () { return cloneModel_1.cloneModel; } }));
|
|
24396
24460
|
Object.defineProperty(exports, "cloneModelForPaste", ({ enumerable: true, get: function () { return cloneModel_1.cloneModelForPaste; } }));
|
|
24461
|
+
var canMergeCells_1 = __webpack_require__(/*! ./modelApi/editing/canMergeCells */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts");
|
|
24462
|
+
Object.defineProperty(exports, "canMergeCells", ({ enumerable: true, get: function () { return canMergeCells_1.canMergeCells; } }));
|
|
24397
24463
|
var mergeModel_1 = __webpack_require__(/*! ./modelApi/editing/mergeModel */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/mergeModel.ts");
|
|
24398
24464
|
Object.defineProperty(exports, "mergeModel", ({ enumerable: true, get: function () { return mergeModel_1.mergeModel; } }));
|
|
24399
24465
|
var deleteSelection_1 = __webpack_require__(/*! ./modelApi/editing/deleteSelection */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/deleteSelection.ts");
|
|
@@ -26515,6 +26581,78 @@ function getBorderStyleFromColor(color) {
|
|
|
26515
26581
|
}
|
|
26516
26582
|
|
|
26517
26583
|
|
|
26584
|
+
/***/ },
|
|
26585
|
+
|
|
26586
|
+
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts"
|
|
26587
|
+
/*!************************************************************************************!*\
|
|
26588
|
+
!*** ./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts ***!
|
|
26589
|
+
\************************************************************************************/
|
|
26590
|
+
(__unused_webpack_module, exports) {
|
|
26591
|
+
|
|
26592
|
+
"use strict";
|
|
26593
|
+
|
|
26594
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
26595
|
+
exports.canMergeCells = void 0;
|
|
26596
|
+
/**
|
|
26597
|
+
* Check whether the given range of table cells can be merged without splitting existing spans.
|
|
26598
|
+
* @param rows The table rows to check
|
|
26599
|
+
* @param firstRow The first row index of the range
|
|
26600
|
+
* @param firstCol The first column index of the range
|
|
26601
|
+
* @param lastRow The last row index of the range
|
|
26602
|
+
* @param lastCol The last column index of the range
|
|
26603
|
+
*/
|
|
26604
|
+
function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
|
|
26605
|
+
var noSpanAbove = firstCol == lastCol ||
|
|
26606
|
+
rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
|
|
26607
|
+
var noSpanLeft = firstRow == lastRow ||
|
|
26608
|
+
rows.every(function (row, rowIndex) {
|
|
26609
|
+
return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
|
|
26610
|
+
});
|
|
26611
|
+
var noDifferentBelowSpan = rows[lastRow].cells
|
|
26612
|
+
.map(function (_, colIndex) {
|
|
26613
|
+
return colIndex >= firstCol && colIndex <= lastCol
|
|
26614
|
+
? getBelowSpanCount(rows, lastRow, colIndex)
|
|
26615
|
+
: -1;
|
|
26616
|
+
})
|
|
26617
|
+
.every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
|
|
26618
|
+
var noDifferentRightSpan = rows
|
|
26619
|
+
.map(function (_, rowIndex) {
|
|
26620
|
+
return rowIndex >= firstRow && rowIndex <= lastRow
|
|
26621
|
+
? getRightSpanCount(rows, rowIndex, lastCol)
|
|
26622
|
+
: -1;
|
|
26623
|
+
})
|
|
26624
|
+
.every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
|
|
26625
|
+
return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
|
|
26626
|
+
}
|
|
26627
|
+
exports.canMergeCells = canMergeCells;
|
|
26628
|
+
function getBelowSpanCount(rows, rowIndex, colIndex) {
|
|
26629
|
+
var _a, _b;
|
|
26630
|
+
var spanCount = 0;
|
|
26631
|
+
for (var row = rowIndex + 1; row < rows.length; row++) {
|
|
26632
|
+
if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
|
|
26633
|
+
spanCount++;
|
|
26634
|
+
}
|
|
26635
|
+
else {
|
|
26636
|
+
break;
|
|
26637
|
+
}
|
|
26638
|
+
}
|
|
26639
|
+
return spanCount;
|
|
26640
|
+
}
|
|
26641
|
+
function getRightSpanCount(rows, rowIndex, colIndex) {
|
|
26642
|
+
var _a, _b, _c;
|
|
26643
|
+
var spanCount = 0;
|
|
26644
|
+
for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
|
|
26645
|
+
if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
|
|
26646
|
+
spanCount++;
|
|
26647
|
+
}
|
|
26648
|
+
else {
|
|
26649
|
+
break;
|
|
26650
|
+
}
|
|
26651
|
+
}
|
|
26652
|
+
return spanCount;
|
|
26653
|
+
}
|
|
26654
|
+
|
|
26655
|
+
|
|
26518
26656
|
/***/ },
|
|
26519
26657
|
|
|
26520
26658
|
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/cloneModel.ts"
|
|
@@ -27914,6 +28052,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
27914
28052
|
exports.retrieveModelFormatState = void 0;
|
|
27915
28053
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
27916
28054
|
var borderValues_1 = __webpack_require__(/*! ../../domUtils/style/borderValues */ "./packages/roosterjs-content-model-dom/lib/domUtils/style/borderValues.ts");
|
|
28055
|
+
var canMergeCells_1 = __webpack_require__(/*! ./canMergeCells */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/canMergeCells.ts");
|
|
27917
28056
|
var getClosestAncestorBlockGroupIndex_1 = __webpack_require__(/*! ./getClosestAncestorBlockGroupIndex */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/getClosestAncestorBlockGroupIndex.ts");
|
|
27918
28057
|
var updateImageMetadata_1 = __webpack_require__(/*! ../metadata/updateImageMetadata */ "./packages/roosterjs-content-model-dom/lib/modelApi/metadata/updateImageMetadata.ts");
|
|
27919
28058
|
var updateTableMetadata_1 = __webpack_require__(/*! ../metadata/updateTableMetadata */ "./packages/roosterjs-content-model-dom/lib/modelApi/metadata/updateTableMetadata.ts");
|
|
@@ -27934,6 +28073,7 @@ var parseValueWithUnit_1 = __webpack_require__(/*! ../../formatHandlers/utils/pa
|
|
|
27934
28073
|
function retrieveModelFormatState(model, pendingFormat, formatState, conflictSolution, domHelper, isInDarkMode, colorHandler) {
|
|
27935
28074
|
if (conflictSolution === void 0) { conflictSolution = 'remove'; }
|
|
27936
28075
|
var firstTableContext;
|
|
28076
|
+
var lastTableContext;
|
|
27937
28077
|
var firstBlock;
|
|
27938
28078
|
var isFirst = true;
|
|
27939
28079
|
var isFirstImage = true;
|
|
@@ -28005,7 +28145,7 @@ function retrieveModelFormatState(model, pendingFormat, formatState, conflictSol
|
|
|
28005
28145
|
// Merge table format
|
|
28006
28146
|
if (tableContext.table == table &&
|
|
28007
28147
|
(tableContext.colIndex != colIndex || tableContext.rowIndex != rowIndex)) {
|
|
28008
|
-
|
|
28148
|
+
lastTableContext = tableContext;
|
|
28009
28149
|
formatState.isMultilineSelection = true;
|
|
28010
28150
|
}
|
|
28011
28151
|
}
|
|
@@ -28018,6 +28158,9 @@ function retrieveModelFormatState(model, pendingFormat, formatState, conflictSol
|
|
|
28018
28158
|
}, {
|
|
28019
28159
|
includeListFormatHolder: 'never',
|
|
28020
28160
|
});
|
|
28161
|
+
if (firstTableContext && lastTableContext) {
|
|
28162
|
+
formatState.canMergeTableCell = (0, canMergeCells_1.canMergeCells)(firstTableContext.table.rows, firstTableContext.rowIndex, firstTableContext.colIndex, lastTableContext.rowIndex, lastTableContext.colIndex);
|
|
28163
|
+
}
|
|
28021
28164
|
if (formatState.fontSize) {
|
|
28022
28165
|
formatState.fontSize = px2Pt(formatState.fontSize);
|
|
28023
28166
|
}
|
|
@@ -36285,6 +36428,9 @@ function handleTabOnParagraph(model, paragraph, rawEvent, context) {
|
|
|
36285
36428
|
return false;
|
|
36286
36429
|
}
|
|
36287
36430
|
}
|
|
36431
|
+
else {
|
|
36432
|
+
return false;
|
|
36433
|
+
}
|
|
36288
36434
|
}
|
|
36289
36435
|
}
|
|
36290
36436
|
}
|
|
@@ -41054,6 +41200,7 @@ var setProcessor_1 = __webpack_require__(/*! ../utils/setProcessor */ "./package
|
|
|
41054
41200
|
var wordContainerParser_1 = __webpack_require__(/*! ../parsers/wordContainerParser */ "./packages/roosterjs-content-model-plugins/lib/paste/parsers/wordContainerParser.ts");
|
|
41055
41201
|
var wordTableParser_1 = __webpack_require__(/*! ../parsers/wordTableParser */ "./packages/roosterjs-content-model-plugins/lib/paste/parsers/wordTableParser.ts");
|
|
41056
41202
|
var removeListParagraphMargins_1 = __webpack_require__(/*! ./removeListParagraphMargins */ "./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/removeListParagraphMargins.ts");
|
|
41203
|
+
var wordBorderParser_1 = __webpack_require__(/*! ./wordBorderParser */ "./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/wordBorderParser.ts");
|
|
41057
41204
|
/**
|
|
41058
41205
|
* @internal
|
|
41059
41206
|
* Handles pasted content when the source is Word Desktop.
|
|
@@ -41073,6 +41220,7 @@ function processPastedContentFromWordDesktop(domToModelOption, htmlString, globa
|
|
|
41073
41220
|
(0, addParser_1.addParser)(domToModelOption, 'listLevel', listLevelParser_1.listLevelParser);
|
|
41074
41221
|
(0, addParser_1.addParser)(domToModelOption, 'container', wordContainerParser_1.wordContainerParser);
|
|
41075
41222
|
(0, addParser_1.addParser)(domToModelOption, 'table', wordTableParser_1.wordTableParser);
|
|
41223
|
+
(0, addParser_1.addParser)(domToModelOption, 'tableBorder', wordBorderParser_1.wordBorderParser);
|
|
41076
41224
|
}
|
|
41077
41225
|
exports.processPastedContentFromWordDesktop = processPastedContentFromWordDesktop;
|
|
41078
41226
|
var wordDesktopElementProcessor = function (metadataKey) {
|
|
@@ -41171,18 +41319,23 @@ function processWordList(styles, group, element, context, metadata) {
|
|
|
41171
41319
|
(listFormat.wordList && listFormat.wordKnownLevels.get(listFormat.wordList)) || [];
|
|
41172
41320
|
}
|
|
41173
41321
|
if (wordListStyle && group && typeof listFormat.wordLevel === 'number') {
|
|
41174
|
-
var
|
|
41322
|
+
var wordLevel_1 = listFormat.wordLevel, wordList = listFormat.wordList;
|
|
41175
41323
|
// Retrieve the Fake bullet on the element and also the list type
|
|
41176
41324
|
var listMetadata_1 = metadata.get(lNumber + ":" + level);
|
|
41177
41325
|
var listType_1 = ((_a = listMetadata_1 === null || listMetadata_1 === void 0 ? void 0 : listMetadata_1['mso-level-number-format']) === null || _a === void 0 ? void 0 : _a.toLowerCase()) != BULLET_METADATA
|
|
41178
41326
|
? 'OL'
|
|
41179
41327
|
: 'UL';
|
|
41180
41328
|
// Create the new level of the list item and parse the format
|
|
41181
|
-
(0, customListUtils_1.setupListFormat)(listType_1, element, context,
|
|
41329
|
+
(0, customListUtils_1.setupListFormat)(listType_1, element, context, wordLevel_1, listFormat, group, [
|
|
41182
41330
|
wordListPaddingParser,
|
|
41183
41331
|
]);
|
|
41184
|
-
listFormat.levels[listFormat.levels.length - 1]
|
|
41185
|
-
.format
|
|
41332
|
+
var currentLevelFormat = listFormat.levels[listFormat.levels.length - 1]
|
|
41333
|
+
.format;
|
|
41334
|
+
currentLevelFormat.wordList = wordList;
|
|
41335
|
+
if (wordLevel_1 > 1) {
|
|
41336
|
+
delete currentLevelFormat.paddingLeft;
|
|
41337
|
+
delete currentLevelFormat.paddingRight;
|
|
41338
|
+
}
|
|
41186
41339
|
var bullet = getBulletFromMetadata(listMetadata_1, listType_1);
|
|
41187
41340
|
var listFormatMetadata = bullet
|
|
41188
41341
|
? {
|
|
@@ -41191,6 +41344,10 @@ function processWordList(styles, group, element, context, metadata) {
|
|
|
41191
41344
|
}
|
|
41192
41345
|
: undefined;
|
|
41193
41346
|
(0, customListUtils_1.processAsListItem)(context, element, group, listFormatMetadata, getBulletElement(element), function (listItem) {
|
|
41347
|
+
if (wordLevel_1 > 1) {
|
|
41348
|
+
delete listItem.format.marginLeft;
|
|
41349
|
+
delete listItem.format.marginRight;
|
|
41350
|
+
}
|
|
41194
41351
|
if (listType_1 == 'OL') {
|
|
41195
41352
|
setStartNumber(listItem, context, listMetadata_1, element);
|
|
41196
41353
|
}
|
|
@@ -41363,35 +41520,108 @@ var WORD_LIST_PARAGRAPH_SELECTORS = new Set([
|
|
|
41363
41520
|
]);
|
|
41364
41521
|
/**
|
|
41365
41522
|
* @internal
|
|
41366
|
-
* Strips
|
|
41523
|
+
* Strips horizontal margin properties from a CSS property string while preserving
|
|
41524
|
+
* vertical values from the margin shorthand.
|
|
41367
41525
|
* Empty tokens produced by a trailing semicolon are preserved so that the
|
|
41368
41526
|
* resulting string still ends with ";" and remains safe to concatenate.
|
|
41369
|
-
* For example, "margin
|
|
41370
|
-
|
|
41371
|
-
|
|
41372
|
-
|
|
41373
|
-
|
|
41374
|
-
|
|
41375
|
-
var
|
|
41376
|
-
|
|
41377
|
-
|
|
41378
|
-
|
|
41379
|
-
|
|
41527
|
+
* For example, "margin: 1pt 2pt 3pt 4pt; color: red;" becomes
|
|
41528
|
+
* "margin-top: 1pt; margin-bottom: 3pt; color: red;".
|
|
41529
|
+
*/
|
|
41530
|
+
function removeHorizontalMarginProperties(cssText) {
|
|
41531
|
+
var result = [];
|
|
41532
|
+
cssText.split(';').forEach(function (prop) {
|
|
41533
|
+
var _a, _b;
|
|
41534
|
+
var separatorIndex = prop.indexOf(':');
|
|
41535
|
+
var name = prop
|
|
41536
|
+
.substring(0, separatorIndex < 0 ? prop.length : separatorIndex)
|
|
41537
|
+
.trim()
|
|
41538
|
+
.toLowerCase();
|
|
41539
|
+
if (name == 'margin-left' ||
|
|
41540
|
+
name == 'margin-right' ||
|
|
41541
|
+
name == 'margin-inline' ||
|
|
41542
|
+
name == 'margin-inline-start' ||
|
|
41543
|
+
name == 'margin-inline-end') {
|
|
41544
|
+
return;
|
|
41545
|
+
}
|
|
41546
|
+
if (name == 'margin' && separatorIndex >= 0) {
|
|
41547
|
+
var value = prop.substring(separatorIndex + 1).trim();
|
|
41548
|
+
var importantMatch = value.match(/\s*!important\s*$/i);
|
|
41549
|
+
var important = importantMatch ? ' !important' : '';
|
|
41550
|
+
var values = splitCssValue(value.substring(0, (_a = importantMatch === null || importantMatch === void 0 ? void 0 : importantMatch.index) !== null && _a !== void 0 ? _a : value.length));
|
|
41551
|
+
if (values.length >= 1 && values.length <= 4) {
|
|
41552
|
+
var leadingWhitespace = ((_b = prop.match(/^\s*/)) === null || _b === void 0 ? void 0 : _b[0]) || '';
|
|
41553
|
+
var top_1 = values[0];
|
|
41554
|
+
var bottom = values.length >= 3 ? values[2] : values[0];
|
|
41555
|
+
result.push(leadingWhitespace + "margin-top: " + top_1 + important);
|
|
41556
|
+
result.push(" margin-bottom: " + bottom + important);
|
|
41557
|
+
return;
|
|
41558
|
+
}
|
|
41559
|
+
}
|
|
41560
|
+
result.push(prop);
|
|
41561
|
+
});
|
|
41562
|
+
return result.join(';');
|
|
41563
|
+
}
|
|
41564
|
+
function splitCssValue(value) {
|
|
41565
|
+
var result = [];
|
|
41566
|
+
var current = '';
|
|
41567
|
+
var quote = null;
|
|
41568
|
+
var parenthesisDepth = 0;
|
|
41569
|
+
for (var i = 0; i < value.length; i++) {
|
|
41570
|
+
var char = value[i];
|
|
41571
|
+
if (quote) {
|
|
41572
|
+
current += char;
|
|
41573
|
+
if (char == '\\') {
|
|
41574
|
+
i++;
|
|
41575
|
+
current += value[i] || '';
|
|
41576
|
+
}
|
|
41577
|
+
else if (char == quote) {
|
|
41578
|
+
quote = null;
|
|
41579
|
+
}
|
|
41580
|
+
}
|
|
41581
|
+
else if (char == '"' || char == "'") {
|
|
41582
|
+
current += char;
|
|
41583
|
+
quote = char;
|
|
41584
|
+
}
|
|
41585
|
+
else if (char == '(') {
|
|
41586
|
+
current += char;
|
|
41587
|
+
parenthesisDepth++;
|
|
41588
|
+
}
|
|
41589
|
+
else if (char == ')') {
|
|
41590
|
+
current += char;
|
|
41591
|
+
parenthesisDepth = Math.max(0, parenthesisDepth - 1);
|
|
41592
|
+
}
|
|
41593
|
+
else if (parenthesisDepth == 0 && /\s/.test(char)) {
|
|
41594
|
+
if (current) {
|
|
41595
|
+
result.push(current);
|
|
41596
|
+
current = '';
|
|
41597
|
+
}
|
|
41598
|
+
}
|
|
41599
|
+
else {
|
|
41600
|
+
current += char;
|
|
41601
|
+
}
|
|
41602
|
+
}
|
|
41603
|
+
if (current) {
|
|
41604
|
+
result.push(current);
|
|
41605
|
+
}
|
|
41606
|
+
return result;
|
|
41380
41607
|
}
|
|
41381
41608
|
/**
|
|
41382
41609
|
* @internal
|
|
41383
|
-
* Removes margin properties from global CSS rules that target Word list
|
|
41384
|
-
* classes (p.MsoListParagraph, p.MsoListParagraphCxSpFirst, etc.).
|
|
41610
|
+
* Removes horizontal margin properties from global CSS rules that target Word list
|
|
41611
|
+
* paragraph classes (p.MsoListParagraph, p.MsoListParagraphCxSpFirst, etc.).
|
|
41385
41612
|
*
|
|
41386
41613
|
* Word Desktop pastes a global stylesheet that typically includes rules like:
|
|
41387
41614
|
* p.MsoListParagraph { margin: 0in; margin-bottom: .0001pt; ... }
|
|
41388
|
-
*
|
|
41389
|
-
* indentation when the CSS is converted to inline styles via convertInlineCss.
|
|
41615
|
+
* Horizontal margins conflict with RoosterJS's own list indentation, causing double
|
|
41616
|
+
* indentation when the CSS is converted to inline styles via convertInlineCss. The
|
|
41617
|
+
* vertical margins are preserved so Word's margin-top: 0 is not replaced by the
|
|
41618
|
+
* browser's default paragraph margin when the list level is created.
|
|
41390
41619
|
*
|
|
41391
|
-
* When a rule's selectors are exclusively list paragraph classes the
|
|
41392
|
-
* removed in place.
|
|
41393
|
-
* the rule is split: the non-list selectors keep the original text, and a
|
|
41394
|
-
* is inserted for the list paragraph selectors with margins
|
|
41620
|
+
* When a rule's selectors are exclusively list paragraph classes the horizontal
|
|
41621
|
+
* margins are removed in place. When a rule groups list paragraph classes with other
|
|
41622
|
+
* selectors the rule is split: the non-list selectors keep the original text, and a
|
|
41623
|
+
* new rule is inserted for the list paragraph selectors with horizontal margins
|
|
41624
|
+
* stripped.
|
|
41395
41625
|
*
|
|
41396
41626
|
* The array is mutated in place so the changes are reflected when convertInlineCss
|
|
41397
41627
|
* subsequently processes the same array reference.
|
|
@@ -41406,17 +41636,16 @@ function removeListParagraphMargins(globalCssRules) {
|
|
|
41406
41636
|
}
|
|
41407
41637
|
var nonMatchingSelectors = rule.selectors.filter(function (s) { return !WORD_LIST_PARAGRAPH_SELECTORS.has(s); });
|
|
41408
41638
|
if (nonMatchingSelectors.length === 0) {
|
|
41409
|
-
// All selectors target list paragraphs — strip margins directly.
|
|
41410
|
-
rule.text =
|
|
41639
|
+
// All selectors target list paragraphs — strip horizontal margins directly.
|
|
41640
|
+
rule.text = removeHorizontalMarginProperties(rule.text);
|
|
41411
41641
|
}
|
|
41412
41642
|
else {
|
|
41413
41643
|
// Mixed rule: keep the non-list selectors on the original entry, then
|
|
41414
|
-
// insert a new entry immediately after for the list paragraph selectors
|
|
41415
|
-
// with margins removed.
|
|
41644
|
+
// insert a new entry immediately after for the list paragraph selectors.
|
|
41416
41645
|
rule.selectors = nonMatchingSelectors;
|
|
41417
41646
|
globalCssRules.splice(i + 1, 0, {
|
|
41418
41647
|
selectors: matchingSelectors,
|
|
41419
|
-
text:
|
|
41648
|
+
text: removeHorizontalMarginProperties(rule.text),
|
|
41420
41649
|
});
|
|
41421
41650
|
}
|
|
41422
41651
|
}
|
|
@@ -41424,6 +41653,63 @@ function removeListParagraphMargins(globalCssRules) {
|
|
|
41424
41653
|
exports.removeListParagraphMargins = removeListParagraphMargins;
|
|
41425
41654
|
|
|
41426
41655
|
|
|
41656
|
+
/***/ },
|
|
41657
|
+
|
|
41658
|
+
/***/ "./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/wordBorderParser.ts"
|
|
41659
|
+
/*!********************************************************************************************!*\
|
|
41660
|
+
!*** ./packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/wordBorderParser.ts ***!
|
|
41661
|
+
\********************************************************************************************/
|
|
41662
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
41663
|
+
|
|
41664
|
+
"use strict";
|
|
41665
|
+
|
|
41666
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
41667
|
+
exports.wordBorderParser = void 0;
|
|
41668
|
+
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
41669
|
+
var BorderStyleNames = new Map([
|
|
41670
|
+
['border-top', 'borderTop'],
|
|
41671
|
+
['border-right', 'borderRight'],
|
|
41672
|
+
['border-bottom', 'borderBottom'],
|
|
41673
|
+
['border-left', 'borderLeft'],
|
|
41674
|
+
]);
|
|
41675
|
+
/**
|
|
41676
|
+
* @internal
|
|
41677
|
+
*/
|
|
41678
|
+
var wordBorderParser = function (format, element) {
|
|
41679
|
+
var style = element.getAttribute('style');
|
|
41680
|
+
if (style) {
|
|
41681
|
+
var noBorder_1 = new Map();
|
|
41682
|
+
style.split(';').forEach(function (declaration) {
|
|
41683
|
+
var separatorIndex = declaration.indexOf(':');
|
|
41684
|
+
if (separatorIndex < 0) {
|
|
41685
|
+
return;
|
|
41686
|
+
}
|
|
41687
|
+
var name = declaration.substring(0, separatorIndex).trim().toLowerCase();
|
|
41688
|
+
var value = declaration
|
|
41689
|
+
.substring(separatorIndex + 1)
|
|
41690
|
+
.trim()
|
|
41691
|
+
.toLowerCase();
|
|
41692
|
+
var isNone = /^none(?:\s|$|!important)/.test(value);
|
|
41693
|
+
if (name == 'border') {
|
|
41694
|
+
roosterjs_content_model_dom_1.BorderKeys.forEach(function (key) { return noBorder_1.set(key, isNone); });
|
|
41695
|
+
}
|
|
41696
|
+
else {
|
|
41697
|
+
var key = BorderStyleNames.get(name);
|
|
41698
|
+
if (key) {
|
|
41699
|
+
noBorder_1.set(key, isNone);
|
|
41700
|
+
}
|
|
41701
|
+
}
|
|
41702
|
+
});
|
|
41703
|
+
noBorder_1.forEach(function (isNone, key) {
|
|
41704
|
+
if (isNone) {
|
|
41705
|
+
format[key] = 'none';
|
|
41706
|
+
}
|
|
41707
|
+
});
|
|
41708
|
+
}
|
|
41709
|
+
};
|
|
41710
|
+
exports.wordBorderParser = wordBorderParser;
|
|
41711
|
+
|
|
41712
|
+
|
|
41427
41713
|
/***/ },
|
|
41428
41714
|
|
|
41429
41715
|
/***/ "./packages/roosterjs-content-model-plugins/lib/paste/oneNote/processPastedContentFromOneNote.ts"
|
|
@@ -41728,18 +42014,23 @@ var INVALID_LINKS_REGEX = /^file:\/\/\/[a-zA-Z\/]/i;
|
|
|
41728
42014
|
* @internal
|
|
41729
42015
|
*/
|
|
41730
42016
|
var parseLink = function (format, element) {
|
|
42017
|
+
var _a;
|
|
41731
42018
|
if (!(0, roosterjs_content_model_dom_1.isElementOfType)(element, 'a')) {
|
|
41732
42019
|
return;
|
|
41733
42020
|
}
|
|
42021
|
+
// On an SVG anchor "href" is an SVGAnimatedString instead of a resolved URL string. Passing it
|
|
42022
|
+
// to the URL constructor always throws, which used to skip the protocol check altogether.
|
|
42023
|
+
var href = typeof element.href == 'string' ? element.href : (_a = element.getAttribute('href')) !== null && _a !== void 0 ? _a : '';
|
|
41734
42024
|
var url;
|
|
41735
42025
|
try {
|
|
41736
|
-
url = new URL(
|
|
42026
|
+
url = new URL(href);
|
|
41737
42027
|
}
|
|
41738
|
-
catch (
|
|
42028
|
+
catch (_b) {
|
|
41739
42029
|
url = undefined;
|
|
41740
42030
|
}
|
|
41741
|
-
if ((
|
|
41742
|
-
|
|
42031
|
+
if ((0, roosterjs_content_model_dom_1.isUnsafeUrl)(href) ||
|
|
42032
|
+
(url && SUPPORTED_PROTOCOLS.indexOf(url.protocol) === -1) ||
|
|
42033
|
+
INVALID_LINKS_REGEX.test(href)) {
|
|
41743
42034
|
element.removeAttribute('href');
|
|
41744
42035
|
format.href = '';
|
|
41745
42036
|
}
|
|
@@ -42401,8 +42692,12 @@ function processAsListItem(context, element, group, listFormatMetadata, bulletEl
|
|
|
42401
42692
|
if (listFormatMetadata && lastLevel) {
|
|
42402
42693
|
(0, roosterjs_content_model_dom_1.updateListMetadata)(lastLevel, function (metadata) { return Object.assign({}, metadata, listFormatMetadata); });
|
|
42403
42694
|
}
|
|
42404
|
-
|
|
42695
|
+
// Parse the list item element's own segment format (e.g. font family/size) into
|
|
42696
|
+
// context.segmentFormat *before* creating the list item, so the format holder
|
|
42697
|
+
// (used to render the list bullet/number) reflects this list item's own font instead
|
|
42698
|
+
// of whatever was left over from the previously processed element.
|
|
42405
42699
|
(0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
42700
|
+
var listItem = (0, roosterjs_content_model_dom_1.createListItem)(listFormat.levels, context.segmentFormat);
|
|
42406
42701
|
(0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.listItemElement, listItem.format, context);
|
|
42407
42702
|
(0, roosterjs_content_model_dom_1.parseFormat)(element, [removeNegativeTextIndentParser_1.removeNegativeTextIndentParser, nonListElementParser], listItem.format, context);
|
|
42408
42703
|
if (bulletElement) {
|