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