roosterjs 8.16.0 → 8.17.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/README.md +9 -1
- package/dist/rooster-amd-min.js +1 -1
- package/dist/rooster-amd-min.js.map +1 -1
- package/dist/rooster-amd.d.ts +11 -5
- package/dist/rooster-amd.js +342 -255
- 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.d.ts +11 -5
- package/dist/rooster.js +342 -255
- package/dist/rooster.js.map +1 -1
- package/lib-amd/createEditor.d.ts +10 -0
- package/lib-amd/index.d.ts +7 -0
- package/package.json +6 -6
- package/test/createEditorTest.d.ts +1 -0
- package/tsconfig.child.tsbuildinfo +1 -1
package/dist/rooster.js
CHANGED
|
@@ -3018,6 +3018,7 @@ exports.default = rotateElement;
|
|
|
3018
3018
|
|
|
3019
3019
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3020
3020
|
var execCommand_1 = __webpack_require__(/*! ../utils/execCommand */ "./packages/roosterjs-editor-api/lib/utils/execCommand.ts");
|
|
3021
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
3021
3022
|
/**
|
|
3022
3023
|
* Set content alignment
|
|
3023
3024
|
* @param editor The editor instance
|
|
@@ -3025,8 +3026,52 @@ var execCommand_1 = __webpack_require__(/*! ../utils/execCommand */ "./packages/
|
|
|
3025
3026
|
* Alignment.Center, Alignment.Left, Alignment.Right
|
|
3026
3027
|
*/
|
|
3027
3028
|
function setAlignment(editor, alignment) {
|
|
3028
|
-
var
|
|
3029
|
+
var selection = editor.getSelectionRangeEx();
|
|
3030
|
+
var isATable = selection && selection.type === 1 /* TableSelection */;
|
|
3031
|
+
editor.addUndoSnapshot(function () {
|
|
3032
|
+
if (editor.isFeatureEnabled("TableAlignment" /* TableAlignment */) &&
|
|
3033
|
+
isATable &&
|
|
3034
|
+
isWholeTableSelected(selection)) {
|
|
3035
|
+
alignTable(selection, alignment);
|
|
3036
|
+
}
|
|
3037
|
+
else {
|
|
3038
|
+
alignText(editor, alignment);
|
|
3039
|
+
}
|
|
3040
|
+
}, "Format" /* Format */);
|
|
3041
|
+
}
|
|
3042
|
+
exports.default = setAlignment;
|
|
3043
|
+
/**
|
|
3044
|
+
* Align text using the margins
|
|
3045
|
+
* @param editor
|
|
3046
|
+
* @param element
|
|
3047
|
+
* @param alignment
|
|
3048
|
+
* @param addUndoSnapshot
|
|
3049
|
+
* @returns
|
|
3050
|
+
*/
|
|
3051
|
+
function alignTable(selection, alignment) {
|
|
3052
|
+
var table = selection.table;
|
|
3053
|
+
if (alignment == 1 /* Center */) {
|
|
3054
|
+
table.style.marginLeft = 'auto';
|
|
3055
|
+
table.style.marginRight = 'auto';
|
|
3056
|
+
}
|
|
3057
|
+
else if (alignment == 2 /* Right */) {
|
|
3058
|
+
table.style.marginLeft = 'auto';
|
|
3059
|
+
table.style.marginRight = '';
|
|
3060
|
+
}
|
|
3061
|
+
else {
|
|
3062
|
+
table.style.marginLeft = '';
|
|
3063
|
+
table.style.marginRight = 'auto';
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
/**
|
|
3067
|
+
* Align text using the text-align
|
|
3068
|
+
* @param editor
|
|
3069
|
+
* @param alignment
|
|
3070
|
+
* @returns
|
|
3071
|
+
*/
|
|
3072
|
+
function alignText(editor, alignment) {
|
|
3029
3073
|
var align = 'left';
|
|
3074
|
+
var command = "justifyLeft" /* JustifyLeft */;
|
|
3030
3075
|
if (alignment == 1 /* Center */) {
|
|
3031
3076
|
command = "justifyCenter" /* JustifyCenter */;
|
|
3032
3077
|
align = 'center';
|
|
@@ -3035,12 +3080,28 @@ function setAlignment(editor, alignment) {
|
|
|
3035
3080
|
command = "justifyRight" /* JustifyRight */;
|
|
3036
3081
|
align = 'right';
|
|
3037
3082
|
}
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3083
|
+
(0, execCommand_1.default)(editor, command);
|
|
3084
|
+
editor.queryElements('[align]', 1 /* OnSelection */, function (node) { return (node.style.textAlign = align); });
|
|
3085
|
+
}
|
|
3086
|
+
/**
|
|
3087
|
+
* Check if the whole table is selected
|
|
3088
|
+
* @param selection
|
|
3089
|
+
* @returns
|
|
3090
|
+
*/
|
|
3091
|
+
function isWholeTableSelected(selection) {
|
|
3092
|
+
if (!selection) {
|
|
3093
|
+
return false;
|
|
3094
|
+
}
|
|
3095
|
+
var vTable = new roosterjs_editor_dom_1.VTable(selection.table);
|
|
3096
|
+
var _a = selection.coordinates, firstCell = _a.firstCell, lastCell = _a.lastCell;
|
|
3097
|
+
var rowsLength = vTable.cells.length - 1;
|
|
3098
|
+
var colIndex = vTable.cells[rowsLength].length - 1;
|
|
3099
|
+
var firstX = firstCell.x;
|
|
3100
|
+
var firstY = firstCell.y;
|
|
3101
|
+
var lastX = lastCell.x;
|
|
3102
|
+
var lastY = lastCell.y;
|
|
3103
|
+
return firstX == 0 && firstY == 0 && lastX == colIndex && lastY == rowsLength;
|
|
3042
3104
|
}
|
|
3043
|
-
exports.default = setAlignment;
|
|
3044
3105
|
|
|
3045
3106
|
|
|
3046
3107
|
/***/ }),
|
|
@@ -3849,6 +3910,8 @@ function editTable(editor, operation) {
|
|
|
3849
3910
|
var vtable = new roosterjs_editor_dom_1.VTable(td);
|
|
3850
3911
|
vtable.edit(operation);
|
|
3851
3912
|
vtable.writeBack();
|
|
3913
|
+
//Adding replaceNode to transform color when the theme is switched to dark.
|
|
3914
|
+
editor.replaceNode(vtable.table, vtable.table, true /**transformColorForDarkMode*/);
|
|
3852
3915
|
editor.focus();
|
|
3853
3916
|
var cellToSelect = calculateCellToSelect(operation, vtable.row, vtable.col);
|
|
3854
3917
|
editor.select(vtable.getCell(cellToSelect.newRow, cellToSelect.newCol).td, 0 /* Begin */);
|
|
@@ -3908,6 +3971,8 @@ function formatTable(editor, format, table) {
|
|
|
3908
3971
|
var vtable = new roosterjs_editor_dom_1.VTable(table);
|
|
3909
3972
|
vtable.applyFormat(format);
|
|
3910
3973
|
vtable.writeBack();
|
|
3974
|
+
//Adding replaceNode to transform color when the theme is switched to dark.
|
|
3975
|
+
editor.replaceNode(vtable.table, vtable.table, true /**transformColorForDarkMode*/);
|
|
3911
3976
|
editor.focus();
|
|
3912
3977
|
editor.select(start, end);
|
|
3913
3978
|
}, "Format" /* Format */);
|
|
@@ -5676,7 +5741,8 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
5676
5741
|
var range = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
|
|
5677
5742
|
shadowEditSelectionPath = range && (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range);
|
|
5678
5743
|
shadowEditTableSelectionPath =
|
|
5679
|
-
selection
|
|
5744
|
+
(selection === null || selection === void 0 ? void 0 : selection.type) == 1 /* TableSelection */ &&
|
|
5745
|
+
selection.ranges.map(function (range) { return (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range); });
|
|
5680
5746
|
shadowEditFragment = core.contentDiv.ownerDocument.createDocumentFragment();
|
|
5681
5747
|
(0, roosterjs_editor_dom_1.moveChildNodes)(shadowEditFragment, contentDiv);
|
|
5682
5748
|
shadowEditFragment.normalize();
|
|
@@ -13934,7 +14000,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13934
14000
|
return __assign.apply(this, arguments);
|
|
13935
14001
|
};
|
|
13936
14002
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13937
|
-
var applyTableFormat_1 = __webpack_require__(/*!
|
|
14003
|
+
var applyTableFormat_1 = __webpack_require__(/*! ./applyTableFormat */ "./packages/roosterjs-editor-dom/lib/table/applyTableFormat.ts");
|
|
13938
14004
|
var moveChildNodes_1 = __webpack_require__(/*! ../utils/moveChildNodes */ "./packages/roosterjs-editor-dom/lib/utils/moveChildNodes.ts");
|
|
13939
14005
|
var normalizeRect_1 = __webpack_require__(/*! ../utils/normalizeRect */ "./packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts");
|
|
13940
14006
|
var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
|
|
@@ -14005,8 +14071,10 @@ var VTable = /** @class */ (function () {
|
|
|
14005
14071
|
}
|
|
14006
14072
|
/**
|
|
14007
14073
|
* Write the virtual table back to DOM tree to represent the change of VTable
|
|
14074
|
+
* @param skipApplyFormat Do not reapply table format when write back.
|
|
14075
|
+
* Only use this parameter when you are pretty sure there is no format or table structure change during the process.
|
|
14008
14076
|
*/
|
|
14009
|
-
VTable.prototype.writeBack = function () {
|
|
14077
|
+
VTable.prototype.writeBack = function (skipApplyFormat) {
|
|
14010
14078
|
var _this = this;
|
|
14011
14079
|
if (this.cells) {
|
|
14012
14080
|
(0, moveChildNodes_1.default)(this.table);
|
|
@@ -14020,7 +14088,7 @@ var VTable = /** @class */ (function () {
|
|
|
14020
14088
|
}
|
|
14021
14089
|
});
|
|
14022
14090
|
});
|
|
14023
|
-
if (this.formatInfo) {
|
|
14091
|
+
if (this.formatInfo && !skipApplyFormat) {
|
|
14024
14092
|
(0, tableFormatInfo_1.saveTableInfo)(this.table, this.formatInfo);
|
|
14025
14093
|
(0, applyTableFormat_1.default)(this.table, this.cells, this.formatInfo);
|
|
14026
14094
|
}
|
|
@@ -14041,7 +14109,7 @@ var VTable = /** @class */ (function () {
|
|
|
14041
14109
|
this.deleteCellShadeDataset(this.cells);
|
|
14042
14110
|
};
|
|
14043
14111
|
/**
|
|
14044
|
-
* Remove the
|
|
14112
|
+
* Remove the cellShade dataset to apply a new style format at the cell.
|
|
14045
14113
|
* @param cells
|
|
14046
14114
|
*/
|
|
14047
14115
|
VTable.prototype.deleteCellShadeDataset = function (cells) {
|
|
@@ -14473,224 +14541,9 @@ function cloneNode(node) {
|
|
|
14473
14541
|
|
|
14474
14542
|
/***/ }),
|
|
14475
14543
|
|
|
14476
|
-
/***/ "./packages/roosterjs-editor-dom/lib/table/
|
|
14477
|
-
/*!********************************************************************!*\
|
|
14478
|
-
!*** ./packages/roosterjs-editor-dom/lib/table/tableFormatInfo.ts ***!
|
|
14479
|
-
\********************************************************************/
|
|
14480
|
-
/*! no static exports found */
|
|
14481
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
14482
|
-
|
|
14483
|
-
"use strict";
|
|
14484
|
-
|
|
14485
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14486
|
-
exports.saveTableInfo = exports.getTableFormatInfo = void 0;
|
|
14487
|
-
var TABLE_STYLE_INFO = 'roosterTableInfo';
|
|
14488
|
-
/**
|
|
14489
|
-
* @internal
|
|
14490
|
-
* Get the format info of a table
|
|
14491
|
-
* If the table does not have a info saved, it will be retrieved from the css styles
|
|
14492
|
-
* @param table The table that has the info
|
|
14493
|
-
*/
|
|
14494
|
-
function getTableFormatInfo(table) {
|
|
14495
|
-
var obj = safeParseJSON(table === null || table === void 0 ? void 0 : table.dataset[TABLE_STYLE_INFO]);
|
|
14496
|
-
return checkIfTableFormatIsValid(obj) ? obj : null;
|
|
14497
|
-
}
|
|
14498
|
-
exports.getTableFormatInfo = getTableFormatInfo;
|
|
14499
|
-
/**
|
|
14500
|
-
* @internal
|
|
14501
|
-
* Save the format info of a table
|
|
14502
|
-
* @param table The table the info will be saved
|
|
14503
|
-
* @param format The format of the table
|
|
14504
|
-
*/
|
|
14505
|
-
function saveTableInfo(table, format) {
|
|
14506
|
-
if (table && format) {
|
|
14507
|
-
table.dataset[TABLE_STYLE_INFO] = JSON.stringify(format);
|
|
14508
|
-
}
|
|
14509
|
-
}
|
|
14510
|
-
exports.saveTableInfo = saveTableInfo;
|
|
14511
|
-
function checkIfTableFormatIsValid(format) {
|
|
14512
|
-
if (!format) {
|
|
14513
|
-
return false;
|
|
14514
|
-
}
|
|
14515
|
-
var topBorderColor = format.topBorderColor, verticalBorderColor = format.verticalBorderColor, bottomBorderColor = format.bottomBorderColor, bgColorOdd = format.bgColorOdd, bgColorEven = format.bgColorEven, hasBandedColumns = format.hasBandedColumns, hasBandedRows = format.hasBandedRows, hasFirstColumn = format.hasFirstColumn, hasHeaderRow = format.hasHeaderRow, tableBorderFormat = format.tableBorderFormat;
|
|
14516
|
-
var colorsValues = [
|
|
14517
|
-
topBorderColor,
|
|
14518
|
-
verticalBorderColor,
|
|
14519
|
-
bottomBorderColor,
|
|
14520
|
-
bgColorOdd,
|
|
14521
|
-
bgColorEven,
|
|
14522
|
-
];
|
|
14523
|
-
var stateValues = [hasBandedColumns, hasBandedRows, hasFirstColumn, hasHeaderRow];
|
|
14524
|
-
if (colorsValues.some(function (key) { return !isAValidColor(key); }) ||
|
|
14525
|
-
stateValues.some(function (key) { return !isBoolean(key); }) ||
|
|
14526
|
-
!isAValidTableBorderType(tableBorderFormat)) {
|
|
14527
|
-
return false;
|
|
14528
|
-
}
|
|
14529
|
-
return true;
|
|
14530
|
-
}
|
|
14531
|
-
function isAValidColor(color) {
|
|
14532
|
-
if (color === null || color === undefined || typeof color === 'string') {
|
|
14533
|
-
return true;
|
|
14534
|
-
}
|
|
14535
|
-
return false;
|
|
14536
|
-
}
|
|
14537
|
-
function isBoolean(a) {
|
|
14538
|
-
if (typeof a === 'boolean') {
|
|
14539
|
-
return true;
|
|
14540
|
-
}
|
|
14541
|
-
return false;
|
|
14542
|
-
}
|
|
14543
|
-
function isAValidTableBorderType(border) {
|
|
14544
|
-
if (-1 < border && border < 8) {
|
|
14545
|
-
return true;
|
|
14546
|
-
}
|
|
14547
|
-
return false;
|
|
14548
|
-
}
|
|
14549
|
-
function safeParseJSON(json) {
|
|
14550
|
-
if (!json) {
|
|
14551
|
-
return null;
|
|
14552
|
-
}
|
|
14553
|
-
try {
|
|
14554
|
-
return JSON.parse(json);
|
|
14555
|
-
}
|
|
14556
|
-
catch (_a) {
|
|
14557
|
-
return null;
|
|
14558
|
-
}
|
|
14559
|
-
}
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
/***/ }),
|
|
14563
|
-
|
|
14564
|
-
/***/ "./packages/roosterjs-editor-dom/lib/utils/Browser.ts":
|
|
14565
|
-
/*!************************************************************!*\
|
|
14566
|
-
!*** ./packages/roosterjs-editor-dom/lib/utils/Browser.ts ***!
|
|
14567
|
-
\************************************************************/
|
|
14568
|
-
/*! no static exports found */
|
|
14569
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
14570
|
-
|
|
14571
|
-
"use strict";
|
|
14572
|
-
|
|
14573
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14574
|
-
exports.Browser = exports.getBrowserInfo = void 0;
|
|
14575
|
-
var isAndroidRegex = /android/i;
|
|
14576
|
-
/**
|
|
14577
|
-
* Get current browser information from user agent string
|
|
14578
|
-
* @param userAgent The userAgent string of a browser
|
|
14579
|
-
* @param appVersion The appVersion string of a browser
|
|
14580
|
-
* @returns The BrowserInfo object calculated from the given userAgent and appVersion
|
|
14581
|
-
*/
|
|
14582
|
-
function getBrowserInfo(userAgent, appVersion) {
|
|
14583
|
-
// checks whether the browser is running in IE
|
|
14584
|
-
// IE11 will use rv in UA instead of MSIE. Unfortunately Firefox also uses this. We should also look for "Trident" to confirm this.
|
|
14585
|
-
// There have been cases where companies using older version of IE and custom UserAgents have broken this logic (e.g. IE 10 and KellyServices)
|
|
14586
|
-
// therefore we should check that the Trident/rv combo is not just from an older IE browser
|
|
14587
|
-
var isIE11OrGreater = userAgent.indexOf('rv:') != -1 && userAgent.indexOf('Trident') != -1;
|
|
14588
|
-
var isIE = userAgent.indexOf('MSIE') != -1 || isIE11OrGreater;
|
|
14589
|
-
// IE11+ may also have 'Chrome', 'Firefox' and 'Safari' in user agent. But it will have 'trident' as well
|
|
14590
|
-
var isChrome = false;
|
|
14591
|
-
var isFirefox = false;
|
|
14592
|
-
var isSafari = false;
|
|
14593
|
-
var isEdge = false;
|
|
14594
|
-
var isWebKit = userAgent.indexOf('WebKit') != -1;
|
|
14595
|
-
if (!isIE) {
|
|
14596
|
-
isChrome = userAgent.indexOf('Chrome') != -1;
|
|
14597
|
-
isFirefox = userAgent.indexOf('Firefox') != -1;
|
|
14598
|
-
if (userAgent.indexOf('Safari') != -1) {
|
|
14599
|
-
// Android and Chrome have Safari in the user string
|
|
14600
|
-
isSafari = userAgent.indexOf('Chrome') == -1 && userAgent.indexOf('Android') == -1;
|
|
14601
|
-
}
|
|
14602
|
-
// Sample Edge UA: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10121
|
|
14603
|
-
isEdge = userAgent.indexOf('Edge') != -1;
|
|
14604
|
-
// When it is edge, it should not be chrome or firefox. and it is also not webkit
|
|
14605
|
-
if (isEdge) {
|
|
14606
|
-
isWebKit = isChrome = isFirefox = false;
|
|
14607
|
-
}
|
|
14608
|
-
}
|
|
14609
|
-
var isMac = appVersion.indexOf('Mac') != -1;
|
|
14610
|
-
var isWin = appVersion.indexOf('Win') != -1 || appVersion.indexOf('NT') != -1;
|
|
14611
|
-
var isAndroid = isAndroidRegex.test(userAgent);
|
|
14612
|
-
return {
|
|
14613
|
-
isMac: isMac,
|
|
14614
|
-
isWin: isWin,
|
|
14615
|
-
isWebKit: isWebKit,
|
|
14616
|
-
isIE: isIE,
|
|
14617
|
-
isIE11OrGreater: isIE11OrGreater,
|
|
14618
|
-
isSafari: isSafari,
|
|
14619
|
-
isChrome: isChrome,
|
|
14620
|
-
isFirefox: isFirefox,
|
|
14621
|
-
isEdge: isEdge,
|
|
14622
|
-
isIEOrEdge: isIE || isEdge,
|
|
14623
|
-
isAndroid: isAndroid,
|
|
14624
|
-
};
|
|
14625
|
-
}
|
|
14626
|
-
exports.getBrowserInfo = getBrowserInfo;
|
|
14627
|
-
/**
|
|
14628
|
-
* Browser object contains browser and operating system information of current environment
|
|
14629
|
-
*/
|
|
14630
|
-
exports.Browser = window
|
|
14631
|
-
? getBrowserInfo(window.navigator.userAgent, window.navigator.appVersion)
|
|
14632
|
-
: {};
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
/***/ }),
|
|
14636
|
-
|
|
14637
|
-
/***/ "./packages/roosterjs-editor-dom/lib/utils/applyFormat.ts":
|
|
14638
|
-
/*!****************************************************************!*\
|
|
14639
|
-
!*** ./packages/roosterjs-editor-dom/lib/utils/applyFormat.ts ***!
|
|
14640
|
-
\****************************************************************/
|
|
14641
|
-
/*! no static exports found */
|
|
14642
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
14643
|
-
|
|
14644
|
-
"use strict";
|
|
14645
|
-
|
|
14646
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14647
|
-
var setColor_1 = __webpack_require__(/*! ./setColor */ "./packages/roosterjs-editor-dom/lib/utils/setColor.ts");
|
|
14648
|
-
/**
|
|
14649
|
-
* Apply format to an HTML element
|
|
14650
|
-
* @param element The HTML element to apply format to
|
|
14651
|
-
* @param format The format to apply
|
|
14652
|
-
*/
|
|
14653
|
-
function applyFormat(element, format, isDarkMode) {
|
|
14654
|
-
if (format) {
|
|
14655
|
-
var elementStyle = element.style;
|
|
14656
|
-
var fontFamily = format.fontFamily, fontSize = format.fontSize, textColor = format.textColor, textColors = format.textColors, backgroundColor = format.backgroundColor, backgroundColors = format.backgroundColors, bold = format.bold, italic = format.italic, underline = format.underline;
|
|
14657
|
-
if (fontFamily) {
|
|
14658
|
-
elementStyle.fontFamily = fontFamily;
|
|
14659
|
-
}
|
|
14660
|
-
if (fontSize) {
|
|
14661
|
-
elementStyle.fontSize = fontSize;
|
|
14662
|
-
}
|
|
14663
|
-
if (textColors) {
|
|
14664
|
-
(0, setColor_1.default)(element, textColors, false /*isBackground*/, isDarkMode);
|
|
14665
|
-
}
|
|
14666
|
-
else if (textColor) {
|
|
14667
|
-
(0, setColor_1.default)(element, textColor, false /*isBackground*/, isDarkMode);
|
|
14668
|
-
}
|
|
14669
|
-
if (backgroundColors) {
|
|
14670
|
-
(0, setColor_1.default)(element, backgroundColors, true /*isBackground*/, isDarkMode);
|
|
14671
|
-
}
|
|
14672
|
-
else if (backgroundColor) {
|
|
14673
|
-
(0, setColor_1.default)(element, backgroundColor, true /*isBackground*/, isDarkMode);
|
|
14674
|
-
}
|
|
14675
|
-
if (bold) {
|
|
14676
|
-
elementStyle.fontWeight = 'bold';
|
|
14677
|
-
}
|
|
14678
|
-
if (italic) {
|
|
14679
|
-
elementStyle.fontStyle = 'italic';
|
|
14680
|
-
}
|
|
14681
|
-
if (underline) {
|
|
14682
|
-
elementStyle.textDecoration = 'underline';
|
|
14683
|
-
}
|
|
14684
|
-
}
|
|
14685
|
-
}
|
|
14686
|
-
exports.default = applyFormat;
|
|
14687
|
-
|
|
14688
|
-
|
|
14689
|
-
/***/ }),
|
|
14690
|
-
|
|
14691
|
-
/***/ "./packages/roosterjs-editor-dom/lib/utils/applyTableFormat.ts":
|
|
14544
|
+
/***/ "./packages/roosterjs-editor-dom/lib/table/applyTableFormat.ts":
|
|
14692
14545
|
/*!*********************************************************************!*\
|
|
14693
|
-
!*** ./packages/roosterjs-editor-dom/lib/
|
|
14546
|
+
!*** ./packages/roosterjs-editor-dom/lib/table/applyTableFormat.ts ***!
|
|
14694
14547
|
\*********************************************************************/
|
|
14695
14548
|
/*! no static exports found */
|
|
14696
14549
|
/***/ (function(module, exports, __webpack_require__) {
|
|
@@ -14698,7 +14551,8 @@ exports.default = applyFormat;
|
|
|
14698
14551
|
"use strict";
|
|
14699
14552
|
|
|
14700
14553
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14701
|
-
var changeElementTag_1 = __webpack_require__(/*!
|
|
14554
|
+
var changeElementTag_1 = __webpack_require__(/*! ../utils/changeElementTag */ "./packages/roosterjs-editor-dom/lib/utils/changeElementTag.ts");
|
|
14555
|
+
var setColor_1 = __webpack_require__(/*! ../utils/setColor */ "./packages/roosterjs-editor-dom/lib/utils/setColor.ts");
|
|
14702
14556
|
var TRANSPARENT = 'transparent';
|
|
14703
14557
|
var TABLE_CELL_TAG_NAME = 'TD';
|
|
14704
14558
|
var TABLE_HEADER_TAG_NAME = 'TH';
|
|
@@ -14714,7 +14568,7 @@ function applyTableFormat(table, cells, format) {
|
|
|
14714
14568
|
}
|
|
14715
14569
|
table.style.borderCollapse = 'collapse';
|
|
14716
14570
|
setBordersType(cells, format);
|
|
14717
|
-
|
|
14571
|
+
setCellColor(cells, format);
|
|
14718
14572
|
setFirstColumnFormat(cells, format);
|
|
14719
14573
|
setHeaderRowFormat(cells, format);
|
|
14720
14574
|
}
|
|
@@ -14735,7 +14589,7 @@ function hasCellShade(cell) {
|
|
|
14735
14589
|
* Set color to the table
|
|
14736
14590
|
* @param format the format that must be applied
|
|
14737
14591
|
*/
|
|
14738
|
-
function
|
|
14592
|
+
function setCellColor(cells, format) {
|
|
14739
14593
|
var color = function (index) { return (index % 2 === 0 ? format.bgColorEven : format.bgColorOdd); };
|
|
14740
14594
|
var hasBandedRows = format.hasBandedRows, hasBandedColumns = format.hasBandedColumns, bgColorOdd = format.bgColorOdd, bgColorEven = format.bgColorEven;
|
|
14741
14595
|
var shouldColorWholeTable = !hasBandedRows && bgColorOdd === bgColorEven ? true : false;
|
|
@@ -14744,13 +14598,13 @@ function setColor(cells, format) {
|
|
|
14744
14598
|
if (cell.td && !hasCellShade(cell)) {
|
|
14745
14599
|
if (hasBandedRows) {
|
|
14746
14600
|
var backgroundColor = color(index);
|
|
14747
|
-
cell.td
|
|
14601
|
+
(0, setColor_1.default)(cell.td, backgroundColor || TRANSPARENT, true /** isBackgroundColor*/);
|
|
14748
14602
|
}
|
|
14749
14603
|
else if (shouldColorWholeTable) {
|
|
14750
|
-
cell.td
|
|
14604
|
+
(0, setColor_1.default)(cell.td, format.bgColorOdd || TRANSPARENT, true /** isBackgroundColor*/);
|
|
14751
14605
|
}
|
|
14752
14606
|
else {
|
|
14753
|
-
cell.td
|
|
14607
|
+
(0, setColor_1.default)(cell.td, TRANSPARENT, true /** isBackgroundColor*/);
|
|
14754
14608
|
}
|
|
14755
14609
|
}
|
|
14756
14610
|
});
|
|
@@ -14760,7 +14614,7 @@ function setColor(cells, format) {
|
|
|
14760
14614
|
row.forEach(function (cell, index) {
|
|
14761
14615
|
var backgroundColor = color(index);
|
|
14762
14616
|
if (cell.td && backgroundColor && !hasCellShade(cell)) {
|
|
14763
|
-
cell.td
|
|
14617
|
+
(0, setColor_1.default)(cell.td, backgroundColor, true /** isBackgroundColor*/);
|
|
14764
14618
|
}
|
|
14765
14619
|
});
|
|
14766
14620
|
});
|
|
@@ -14927,7 +14781,7 @@ function setFirstColumnFormat(cells, format) {
|
|
|
14927
14781
|
if (cell.td && cellIndex === 0) {
|
|
14928
14782
|
if (rowIndex !== 0) {
|
|
14929
14783
|
cell.td.style.borderTopColor = TRANSPARENT;
|
|
14930
|
-
cell.td
|
|
14784
|
+
(0, setColor_1.default)(cell.td, TRANSPARENT, true /** isBackgroundColor*/);
|
|
14931
14785
|
}
|
|
14932
14786
|
if (rowIndex !== cells.length - 1 && rowIndex !== 0) {
|
|
14933
14787
|
cell.td.style.borderBottomColor = TRANSPARENT;
|
|
@@ -14956,7 +14810,7 @@ function setHeaderRowFormat(cells, format) {
|
|
|
14956
14810
|
}
|
|
14957
14811
|
(_b = cells[0]) === null || _b === void 0 ? void 0 : _b.forEach(function (cell) {
|
|
14958
14812
|
if (cell.td && format.headerRowColor) {
|
|
14959
|
-
cell.td
|
|
14813
|
+
(0, setColor_1.default)(cell.td, format.headerRowColor, true /** isBackgroundColor*/);
|
|
14960
14814
|
cell.td.style.borderRightColor = format.headerRowColor;
|
|
14961
14815
|
cell.td.style.borderLeftColor = format.headerRowColor;
|
|
14962
14816
|
cell.td.style.borderTopColor = format.headerRowColor;
|
|
@@ -14971,6 +14825,221 @@ function getBorderStyle(style) {
|
|
|
14971
14825
|
}
|
|
14972
14826
|
|
|
14973
14827
|
|
|
14828
|
+
/***/ }),
|
|
14829
|
+
|
|
14830
|
+
/***/ "./packages/roosterjs-editor-dom/lib/table/tableFormatInfo.ts":
|
|
14831
|
+
/*!********************************************************************!*\
|
|
14832
|
+
!*** ./packages/roosterjs-editor-dom/lib/table/tableFormatInfo.ts ***!
|
|
14833
|
+
\********************************************************************/
|
|
14834
|
+
/*! no static exports found */
|
|
14835
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
14836
|
+
|
|
14837
|
+
"use strict";
|
|
14838
|
+
|
|
14839
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14840
|
+
exports.saveTableInfo = exports.getTableFormatInfo = void 0;
|
|
14841
|
+
var TABLE_STYLE_INFO = 'roosterTableInfo';
|
|
14842
|
+
/**
|
|
14843
|
+
* @internal
|
|
14844
|
+
* Get the format info of a table
|
|
14845
|
+
* If the table does not have a info saved, it will be retrieved from the css styles
|
|
14846
|
+
* @param table The table that has the info
|
|
14847
|
+
*/
|
|
14848
|
+
function getTableFormatInfo(table) {
|
|
14849
|
+
var obj = safeParseJSON(table === null || table === void 0 ? void 0 : table.dataset[TABLE_STYLE_INFO]);
|
|
14850
|
+
return checkIfTableFormatIsValid(obj) ? obj : null;
|
|
14851
|
+
}
|
|
14852
|
+
exports.getTableFormatInfo = getTableFormatInfo;
|
|
14853
|
+
/**
|
|
14854
|
+
* @internal
|
|
14855
|
+
* Save the format info of a table
|
|
14856
|
+
* @param table The table the info will be saved
|
|
14857
|
+
* @param format The format of the table
|
|
14858
|
+
*/
|
|
14859
|
+
function saveTableInfo(table, format) {
|
|
14860
|
+
if (table && format) {
|
|
14861
|
+
table.dataset[TABLE_STYLE_INFO] = JSON.stringify(format);
|
|
14862
|
+
}
|
|
14863
|
+
}
|
|
14864
|
+
exports.saveTableInfo = saveTableInfo;
|
|
14865
|
+
function checkIfTableFormatIsValid(format) {
|
|
14866
|
+
if (!format) {
|
|
14867
|
+
return false;
|
|
14868
|
+
}
|
|
14869
|
+
var topBorderColor = format.topBorderColor, verticalBorderColor = format.verticalBorderColor, bottomBorderColor = format.bottomBorderColor, bgColorOdd = format.bgColorOdd, bgColorEven = format.bgColorEven, hasBandedColumns = format.hasBandedColumns, hasBandedRows = format.hasBandedRows, hasFirstColumn = format.hasFirstColumn, hasHeaderRow = format.hasHeaderRow, tableBorderFormat = format.tableBorderFormat;
|
|
14870
|
+
var colorsValues = [
|
|
14871
|
+
topBorderColor,
|
|
14872
|
+
verticalBorderColor,
|
|
14873
|
+
bottomBorderColor,
|
|
14874
|
+
bgColorOdd,
|
|
14875
|
+
bgColorEven,
|
|
14876
|
+
];
|
|
14877
|
+
var stateValues = [hasBandedColumns, hasBandedRows, hasFirstColumn, hasHeaderRow];
|
|
14878
|
+
if (colorsValues.some(function (key) { return !isAValidColor(key); }) ||
|
|
14879
|
+
stateValues.some(function (key) { return !isBoolean(key); }) ||
|
|
14880
|
+
!isAValidTableBorderType(tableBorderFormat)) {
|
|
14881
|
+
return false;
|
|
14882
|
+
}
|
|
14883
|
+
return true;
|
|
14884
|
+
}
|
|
14885
|
+
function isAValidColor(color) {
|
|
14886
|
+
if (color === null || color === undefined || typeof color === 'string') {
|
|
14887
|
+
return true;
|
|
14888
|
+
}
|
|
14889
|
+
return false;
|
|
14890
|
+
}
|
|
14891
|
+
function isBoolean(a) {
|
|
14892
|
+
if (typeof a === 'boolean') {
|
|
14893
|
+
return true;
|
|
14894
|
+
}
|
|
14895
|
+
return false;
|
|
14896
|
+
}
|
|
14897
|
+
function isAValidTableBorderType(border) {
|
|
14898
|
+
if (-1 < border && border < 8) {
|
|
14899
|
+
return true;
|
|
14900
|
+
}
|
|
14901
|
+
return false;
|
|
14902
|
+
}
|
|
14903
|
+
function safeParseJSON(json) {
|
|
14904
|
+
if (!json) {
|
|
14905
|
+
return null;
|
|
14906
|
+
}
|
|
14907
|
+
try {
|
|
14908
|
+
return JSON.parse(json);
|
|
14909
|
+
}
|
|
14910
|
+
catch (_a) {
|
|
14911
|
+
return null;
|
|
14912
|
+
}
|
|
14913
|
+
}
|
|
14914
|
+
|
|
14915
|
+
|
|
14916
|
+
/***/ }),
|
|
14917
|
+
|
|
14918
|
+
/***/ "./packages/roosterjs-editor-dom/lib/utils/Browser.ts":
|
|
14919
|
+
/*!************************************************************!*\
|
|
14920
|
+
!*** ./packages/roosterjs-editor-dom/lib/utils/Browser.ts ***!
|
|
14921
|
+
\************************************************************/
|
|
14922
|
+
/*! no static exports found */
|
|
14923
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
14924
|
+
|
|
14925
|
+
"use strict";
|
|
14926
|
+
|
|
14927
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14928
|
+
exports.Browser = exports.getBrowserInfo = void 0;
|
|
14929
|
+
var isAndroidRegex = /android/i;
|
|
14930
|
+
/**
|
|
14931
|
+
* Get current browser information from user agent string
|
|
14932
|
+
* @param userAgent The userAgent string of a browser
|
|
14933
|
+
* @param appVersion The appVersion string of a browser
|
|
14934
|
+
* @returns The BrowserInfo object calculated from the given userAgent and appVersion
|
|
14935
|
+
*/
|
|
14936
|
+
function getBrowserInfo(userAgent, appVersion) {
|
|
14937
|
+
// checks whether the browser is running in IE
|
|
14938
|
+
// IE11 will use rv in UA instead of MSIE. Unfortunately Firefox also uses this. We should also look for "Trident" to confirm this.
|
|
14939
|
+
// There have been cases where companies using older version of IE and custom UserAgents have broken this logic (e.g. IE 10 and KellyServices)
|
|
14940
|
+
// therefore we should check that the Trident/rv combo is not just from an older IE browser
|
|
14941
|
+
var isIE11OrGreater = userAgent.indexOf('rv:') != -1 && userAgent.indexOf('Trident') != -1;
|
|
14942
|
+
var isIE = userAgent.indexOf('MSIE') != -1 || isIE11OrGreater;
|
|
14943
|
+
// IE11+ may also have 'Chrome', 'Firefox' and 'Safari' in user agent. But it will have 'trident' as well
|
|
14944
|
+
var isChrome = false;
|
|
14945
|
+
var isFirefox = false;
|
|
14946
|
+
var isSafari = false;
|
|
14947
|
+
var isEdge = false;
|
|
14948
|
+
var isWebKit = userAgent.indexOf('WebKit') != -1;
|
|
14949
|
+
if (!isIE) {
|
|
14950
|
+
isChrome = userAgent.indexOf('Chrome') != -1;
|
|
14951
|
+
isFirefox = userAgent.indexOf('Firefox') != -1;
|
|
14952
|
+
if (userAgent.indexOf('Safari') != -1) {
|
|
14953
|
+
// Android and Chrome have Safari in the user string
|
|
14954
|
+
isSafari = userAgent.indexOf('Chrome') == -1 && userAgent.indexOf('Android') == -1;
|
|
14955
|
+
}
|
|
14956
|
+
// Sample Edge UA: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10121
|
|
14957
|
+
isEdge = userAgent.indexOf('Edge') != -1;
|
|
14958
|
+
// When it is edge, it should not be chrome or firefox. and it is also not webkit
|
|
14959
|
+
if (isEdge) {
|
|
14960
|
+
isWebKit = isChrome = isFirefox = false;
|
|
14961
|
+
}
|
|
14962
|
+
}
|
|
14963
|
+
var isMac = appVersion.indexOf('Mac') != -1;
|
|
14964
|
+
var isWin = appVersion.indexOf('Win') != -1 || appVersion.indexOf('NT') != -1;
|
|
14965
|
+
var isAndroid = isAndroidRegex.test(userAgent);
|
|
14966
|
+
return {
|
|
14967
|
+
isMac: isMac,
|
|
14968
|
+
isWin: isWin,
|
|
14969
|
+
isWebKit: isWebKit,
|
|
14970
|
+
isIE: isIE,
|
|
14971
|
+
isIE11OrGreater: isIE11OrGreater,
|
|
14972
|
+
isSafari: isSafari,
|
|
14973
|
+
isChrome: isChrome,
|
|
14974
|
+
isFirefox: isFirefox,
|
|
14975
|
+
isEdge: isEdge,
|
|
14976
|
+
isIEOrEdge: isIE || isEdge,
|
|
14977
|
+
isAndroid: isAndroid,
|
|
14978
|
+
};
|
|
14979
|
+
}
|
|
14980
|
+
exports.getBrowserInfo = getBrowserInfo;
|
|
14981
|
+
/**
|
|
14982
|
+
* Browser object contains browser and operating system information of current environment
|
|
14983
|
+
*/
|
|
14984
|
+
exports.Browser = window
|
|
14985
|
+
? getBrowserInfo(window.navigator.userAgent, window.navigator.appVersion)
|
|
14986
|
+
: {};
|
|
14987
|
+
|
|
14988
|
+
|
|
14989
|
+
/***/ }),
|
|
14990
|
+
|
|
14991
|
+
/***/ "./packages/roosterjs-editor-dom/lib/utils/applyFormat.ts":
|
|
14992
|
+
/*!****************************************************************!*\
|
|
14993
|
+
!*** ./packages/roosterjs-editor-dom/lib/utils/applyFormat.ts ***!
|
|
14994
|
+
\****************************************************************/
|
|
14995
|
+
/*! no static exports found */
|
|
14996
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
14997
|
+
|
|
14998
|
+
"use strict";
|
|
14999
|
+
|
|
15000
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15001
|
+
var setColor_1 = __webpack_require__(/*! ./setColor */ "./packages/roosterjs-editor-dom/lib/utils/setColor.ts");
|
|
15002
|
+
/**
|
|
15003
|
+
* Apply format to an HTML element
|
|
15004
|
+
* @param element The HTML element to apply format to
|
|
15005
|
+
* @param format The format to apply
|
|
15006
|
+
*/
|
|
15007
|
+
function applyFormat(element, format, isDarkMode) {
|
|
15008
|
+
if (format) {
|
|
15009
|
+
var elementStyle = element.style;
|
|
15010
|
+
var fontFamily = format.fontFamily, fontSize = format.fontSize, textColor = format.textColor, textColors = format.textColors, backgroundColor = format.backgroundColor, backgroundColors = format.backgroundColors, bold = format.bold, italic = format.italic, underline = format.underline;
|
|
15011
|
+
if (fontFamily) {
|
|
15012
|
+
elementStyle.fontFamily = fontFamily;
|
|
15013
|
+
}
|
|
15014
|
+
if (fontSize) {
|
|
15015
|
+
elementStyle.fontSize = fontSize;
|
|
15016
|
+
}
|
|
15017
|
+
if (textColors) {
|
|
15018
|
+
(0, setColor_1.default)(element, textColors, false /*isBackground*/, isDarkMode);
|
|
15019
|
+
}
|
|
15020
|
+
else if (textColor) {
|
|
15021
|
+
(0, setColor_1.default)(element, textColor, false /*isBackground*/, isDarkMode);
|
|
15022
|
+
}
|
|
15023
|
+
if (backgroundColors) {
|
|
15024
|
+
(0, setColor_1.default)(element, backgroundColors, true /*isBackground*/, isDarkMode);
|
|
15025
|
+
}
|
|
15026
|
+
else if (backgroundColor) {
|
|
15027
|
+
(0, setColor_1.default)(element, backgroundColor, true /*isBackground*/, isDarkMode);
|
|
15028
|
+
}
|
|
15029
|
+
if (bold) {
|
|
15030
|
+
elementStyle.fontWeight = 'bold';
|
|
15031
|
+
}
|
|
15032
|
+
if (italic) {
|
|
15033
|
+
elementStyle.fontStyle = 'italic';
|
|
15034
|
+
}
|
|
15035
|
+
if (underline) {
|
|
15036
|
+
elementStyle.textDecoration = 'underline';
|
|
15037
|
+
}
|
|
15038
|
+
}
|
|
15039
|
+
}
|
|
15040
|
+
exports.default = applyFormat;
|
|
15041
|
+
|
|
15042
|
+
|
|
14974
15043
|
/***/ }),
|
|
14975
15044
|
|
|
14976
15045
|
/***/ "./packages/roosterjs-editor-dom/lib/utils/arrayPush.ts":
|
|
@@ -22155,11 +22224,12 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
22155
22224
|
if (selection.type == 1 /* TableSelection */) {
|
|
22156
22225
|
this.tableRange = selection.coordinates;
|
|
22157
22226
|
this.firstTable = selection.table;
|
|
22227
|
+
this.tableSelection = true;
|
|
22158
22228
|
this.editor.select(selection.table, null);
|
|
22159
22229
|
}
|
|
22160
22230
|
break;
|
|
22161
22231
|
case 18 /* LeavingShadowEdit */:
|
|
22162
|
-
if (this.firstTable && this.tableRange) {
|
|
22232
|
+
if (this.firstTable && this.tableSelection && this.tableRange) {
|
|
22163
22233
|
var table = this.editor.queryElements('#' + this.firstTable.id);
|
|
22164
22234
|
if (table.length == 1) {
|
|
22165
22235
|
this.firstTable = table[0];
|
|
@@ -22311,6 +22381,7 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
22311
22381
|
: -3 /* After */);
|
|
22312
22382
|
var sel = this.editor.getDocument().defaultView.getSelection();
|
|
22313
22383
|
var anchorNode = sel.anchorNode, anchorOffset = sel.anchorOffset;
|
|
22384
|
+
this.editor.select(sel.getRangeAt(0));
|
|
22314
22385
|
sel.setBaseAndExtent(anchorNode, anchorOffset, position.node, position.offset);
|
|
22315
22386
|
this.lastTarget = position.node;
|
|
22316
22387
|
event.rawEvent.preventDefault();
|
|
@@ -22943,7 +23014,7 @@ function createCellResizer(td, zoomScale, isRTL, isHorizontal, onStart, onEnd) {
|
|
|
22943
23014
|
return { node: td, div: div, featureHandler: featureHandler };
|
|
22944
23015
|
}
|
|
22945
23016
|
exports.default = createCellResizer;
|
|
22946
|
-
function onDragStart(context
|
|
23017
|
+
function onDragStart(context) {
|
|
22947
23018
|
var td = context.td, isRTL = context.isRTL, zoomScale = context.zoomScale, onStart = context.onStart;
|
|
22948
23019
|
var vTable = new roosterjs_editor_dom_1.VTable(td, true /*normalizeSize*/, zoomScale);
|
|
22949
23020
|
var rect = (0, roosterjs_editor_dom_1.normalizeRect)(td.getBoundingClientRect());
|
|
@@ -22972,10 +23043,11 @@ function onDraggingHorizontal(context, event, initValue, deltaX, deltaY) {
|
|
|
22972
23043
|
cell.td.style.height = cell.td == td ? cell.height / zoomScale + deltaY + "px" : null;
|
|
22973
23044
|
}
|
|
22974
23045
|
});
|
|
22975
|
-
|
|
23046
|
+
// To avoid apply format styles when the table is being resizing, the skipApplyFormat is set to true.
|
|
23047
|
+
vTable.writeBack(true /**skipApplyFormat*/);
|
|
22976
23048
|
return true;
|
|
22977
23049
|
}
|
|
22978
|
-
function onDraggingVertical(context, event, initValue
|
|
23050
|
+
function onDraggingVertical(context, event, initValue) {
|
|
22979
23051
|
var isRTL = context.isRTL, zoomScale = context.zoomScale;
|
|
22980
23052
|
var vTable = initValue.vTable, nextCells = initValue.nextCells, currentCells = initValue.currentCells;
|
|
22981
23053
|
if (!canResizeColumns(event.pageX, currentCells, nextCells, isRTL, zoomScale)) {
|
|
@@ -23011,7 +23083,8 @@ function onDraggingVertical(context, event, initValue, deltaX, deltaY) {
|
|
|
23011
23083
|
td.style.width = null;
|
|
23012
23084
|
});
|
|
23013
23085
|
}
|
|
23014
|
-
|
|
23086
|
+
// To avoid apply format styles when the table is being resizing, the skipApplyFormat is set to true.
|
|
23087
|
+
vTable.writeBack(true /**skipApplyFormat*/);
|
|
23015
23088
|
return true;
|
|
23016
23089
|
}
|
|
23017
23090
|
function getHorizontalDistance(rect, pos, toLeft) {
|
|
@@ -23126,14 +23199,18 @@ var TableEditor = /** @class */ (function () {
|
|
|
23126
23199
|
this.table = table;
|
|
23127
23200
|
this.onChanged = onChanged;
|
|
23128
23201
|
this.onFinishEditing = function () {
|
|
23202
|
+
_this.editor.focus();
|
|
23129
23203
|
_this.editor.select(_this.start, _this.end);
|
|
23130
23204
|
_this.editor.addUndoSnapshot(null /*callback*/, "Format" /* Format */);
|
|
23131
|
-
_this.editor.focus();
|
|
23132
23205
|
_this.onChanged();
|
|
23133
23206
|
return false;
|
|
23134
23207
|
};
|
|
23208
|
+
this.onStartTableResize = function () {
|
|
23209
|
+
_this.onStartResize();
|
|
23210
|
+
};
|
|
23135
23211
|
this.onStartCellResize = function () {
|
|
23136
23212
|
_this.disposeTableResizer();
|
|
23213
|
+
_this.onStartResize();
|
|
23137
23214
|
};
|
|
23138
23215
|
this.onInserted = function () {
|
|
23139
23216
|
_this.disposeTableResizer();
|
|
@@ -23164,12 +23241,8 @@ var TableEditor = /** @class */ (function () {
|
|
|
23164
23241
|
}
|
|
23165
23242
|
};
|
|
23166
23243
|
this.isRTL = (0, roosterjs_editor_dom_1.getComputedStyle)(table, 'direction') == 'rtl';
|
|
23167
|
-
this.tableResizer = (0, TableResizer_1.default)(table, editor.getZoomScale(), this.isRTL, this.onFinishEditing);
|
|
23244
|
+
this.tableResizer = (0, TableResizer_1.default)(table, editor.getZoomScale(), this.isRTL, this.onStartTableResize, this.onFinishEditing);
|
|
23168
23245
|
this.tableSelector = (0, TableSelector_1.default)(table, editor.getZoomScale(), this.onSelect);
|
|
23169
|
-
this.editor.addUndoSnapshot(function (start, end) {
|
|
23170
|
-
_this.start = start;
|
|
23171
|
-
_this.end = end;
|
|
23172
|
-
});
|
|
23173
23246
|
}
|
|
23174
23247
|
TableEditor.prototype.dispose = function () {
|
|
23175
23248
|
this.disposeTableResizer();
|
|
@@ -23273,6 +23346,14 @@ var TableEditor = /** @class */ (function () {
|
|
|
23273
23346
|
this.tableSelector = null;
|
|
23274
23347
|
}
|
|
23275
23348
|
};
|
|
23349
|
+
TableEditor.prototype.onStartResize = function () {
|
|
23350
|
+
var range = this.editor.getSelectionRange();
|
|
23351
|
+
if (range) {
|
|
23352
|
+
this.start = roosterjs_editor_dom_1.Position.getStart(range);
|
|
23353
|
+
this.end = roosterjs_editor_dom_1.Position.getEnd(range);
|
|
23354
|
+
}
|
|
23355
|
+
this.editor.addUndoSnapshot();
|
|
23356
|
+
};
|
|
23276
23357
|
return TableEditor;
|
|
23277
23358
|
}());
|
|
23278
23359
|
exports.default = TableEditor;
|
|
@@ -23345,29 +23426,31 @@ function createTableInserter(editor, td, isRTL, isHorizontal, onInsert) {
|
|
|
23345
23426
|
div.firstChild.style.height = tableRect.bottom - tableRect.top + "px";
|
|
23346
23427
|
}
|
|
23347
23428
|
document_1.body.appendChild(div);
|
|
23348
|
-
var handler = new TableInsertHandler(div, td, isHorizontal, editor
|
|
23429
|
+
var handler = new TableInsertHandler(div, td, isHorizontal, editor, onInsert);
|
|
23349
23430
|
return { div: div, featureHandler: handler, node: td };
|
|
23350
23431
|
}
|
|
23351
23432
|
}
|
|
23352
23433
|
exports.default = createTableInserter;
|
|
23353
23434
|
var TableInsertHandler = /** @class */ (function () {
|
|
23354
|
-
function TableInsertHandler(div, td, isHorizontal,
|
|
23435
|
+
function TableInsertHandler(div, td, isHorizontal, editor, onInsert) {
|
|
23355
23436
|
var _this = this;
|
|
23356
23437
|
this.div = div;
|
|
23357
23438
|
this.td = td;
|
|
23358
23439
|
this.isHorizontal = isHorizontal;
|
|
23359
|
-
this.
|
|
23440
|
+
this.editor = editor;
|
|
23360
23441
|
this.onInsert = onInsert;
|
|
23361
23442
|
this.insertTd = function () {
|
|
23362
23443
|
var vtable = new roosterjs_editor_dom_1.VTable(_this.td);
|
|
23363
23444
|
if (!_this.isHorizontal) {
|
|
23364
|
-
vtable.normalizeTableCellSize(_this.
|
|
23445
|
+
vtable.normalizeTableCellSize(_this.editor.getZoomScale());
|
|
23365
23446
|
// Since adding new column will cause table width to change, we need to remove width properties
|
|
23366
23447
|
vtable.table.removeAttribute('width');
|
|
23367
23448
|
vtable.table.style.width = null;
|
|
23368
23449
|
}
|
|
23369
23450
|
vtable.edit(_this.isHorizontal ? 1 /* InsertBelow */ : 3 /* InsertRight */);
|
|
23370
23451
|
vtable.writeBack();
|
|
23452
|
+
//Adding replaceNode to transform color when the theme is switched to dark.
|
|
23453
|
+
_this.editor.replaceNode(vtable.table, vtable.table, true /**transformColorForDarkMode*/);
|
|
23371
23454
|
_this.onInsert();
|
|
23372
23455
|
};
|
|
23373
23456
|
this.div.addEventListener('click', this.insertTd);
|
|
@@ -23375,6 +23458,7 @@ var TableInsertHandler = /** @class */ (function () {
|
|
|
23375
23458
|
TableInsertHandler.prototype.dispose = function () {
|
|
23376
23459
|
this.div.removeEventListener('click', this.insertTd);
|
|
23377
23460
|
this.div = null;
|
|
23461
|
+
this.editor = null;
|
|
23378
23462
|
};
|
|
23379
23463
|
return TableInsertHandler;
|
|
23380
23464
|
}());
|
|
@@ -23418,7 +23502,7 @@ var MIN_CELL_HEIGHT = 20;
|
|
|
23418
23502
|
/**
|
|
23419
23503
|
* @internal
|
|
23420
23504
|
*/
|
|
23421
|
-
function createTableResizer(table, zoomScale, isRTL, onDragEnd) {
|
|
23505
|
+
function createTableResizer(table, zoomScale, isRTL, onStart, onDragEnd) {
|
|
23422
23506
|
var document = table.ownerDocument;
|
|
23423
23507
|
var div = (0, roosterjs_editor_dom_1.createElement)(isRTL
|
|
23424
23508
|
? 10 /* TableResizerRTL */
|
|
@@ -23430,6 +23514,7 @@ function createTableResizer(table, zoomScale, isRTL, onDragEnd) {
|
|
|
23430
23514
|
isRTL: isRTL,
|
|
23431
23515
|
table: table,
|
|
23432
23516
|
zoomScale: zoomScale,
|
|
23517
|
+
onStart: onStart,
|
|
23433
23518
|
};
|
|
23434
23519
|
setResizeDivPosition(context, div);
|
|
23435
23520
|
var featureHandler = new DragAndDropHelper_1.default(div, context, setResizeDivPosition, {
|
|
@@ -23440,7 +23525,8 @@ function createTableResizer(table, zoomScale, isRTL, onDragEnd) {
|
|
|
23440
23525
|
return { node: table, div: div, featureHandler: featureHandler };
|
|
23441
23526
|
}
|
|
23442
23527
|
exports.default = createTableResizer;
|
|
23443
|
-
function onDragStart(context
|
|
23528
|
+
function onDragStart(context) {
|
|
23529
|
+
context.onStart();
|
|
23444
23530
|
return {
|
|
23445
23531
|
originalRect: context.table.getBoundingClientRect(),
|
|
23446
23532
|
vTable: new roosterjs_editor_dom_1.VTable(context.table, true /*normalizeTable*/, context.zoomScale),
|
|
@@ -23485,7 +23571,8 @@ function onDragging(context, event, initValue, deltaX, deltaY) {
|
|
|
23485
23571
|
}
|
|
23486
23572
|
}
|
|
23487
23573
|
}
|
|
23488
|
-
|
|
23574
|
+
// To avoid apply format styles when the table is being resizing, the skipApplyFormat is set to true.
|
|
23575
|
+
vTable.writeBack(true /**skipApplyFormat*/);
|
|
23489
23576
|
return true;
|
|
23490
23577
|
}
|
|
23491
23578
|
else {
|