roosterjs 9.58.0 → 9.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rooster-adapter-amd-min.js +1 -1
- package/dist/rooster-adapter-amd-min.js.map +1 -1
- package/dist/rooster-adapter-amd.js +1 -1
- package/dist/rooster-adapter-amd.js.map +1 -1
- package/dist/rooster-adapter-min.js +1 -1
- package/dist/rooster-adapter-min.js.map +1 -1
- package/dist/rooster-adapter.js +1 -1
- package/dist/rooster-adapter.js.map +1 -1
- package/dist/rooster-amd-min.js +1 -1
- package/dist/rooster-amd-min.js.map +1 -1
- package/dist/rooster-amd.d.ts +85 -8
- package/dist/rooster-amd.js +548 -188
- package/dist/rooster-amd.js.map +1 -1
- package/dist/rooster-min.js +1 -1
- package/dist/rooster-min.js.map +1 -1
- package/dist/rooster-react-amd-min.js +1 -1
- package/dist/rooster-react-amd-min.js.map +1 -1
- package/dist/rooster-react-amd.d.ts +1 -1
- package/dist/rooster-react-amd.js +60 -62
- package/dist/rooster-react-amd.js.map +1 -1
- package/dist/rooster-react-min.js +1 -1
- package/dist/rooster-react-min.js.map +1 -1
- package/dist/rooster-react.d.ts +1 -1
- package/dist/rooster-react.js +97 -99
- package/dist/rooster-react.js.map +1 -1
- package/dist/rooster.d.ts +85 -8
- package/dist/rooster.js +548 -188
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
package/dist/rooster-amd.js
CHANGED
|
@@ -2550,7 +2550,7 @@ exports["default"] = getDarkColor;
|
|
|
2550
2550
|
|
|
2551
2551
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2552
2552
|
exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = exports.formatTableWithContentModel = exports.createEditorContextForEntity = exports.clearSelectedCells = exports.insertTableColumn = exports.insertTableRow = exports.insertEntity = exports.toggleCode = exports.setParagraphMargin = exports.adjustImageSelection = exports.setImageAltText = exports.adjustLinkSelection = exports.removeLink = exports.insertLink = exports.clearFormat = exports.getFormatState = exports.changeImage = exports.setImageBoxShadow = exports.setImageBorder = exports.setSpacing = exports.toggleBlockQuote = exports.setHeadingLevel = exports.setDirection = exports.setAlignment = exports.setIndentation = exports.setListStartNumber = exports.setListStyle = exports.insertImage = exports.splitTextSegment = exports.changeCapitalization = exports.applySegmentFormat = exports.changeFontSize = exports.setTextColor = exports.setFontSize = exports.setFontName = exports.setBackgroundColor = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleUnderline = exports.toggleItalic = exports.toggleBold = exports.toggleNumbering = exports.toggleBullet = exports.applyTableBorderFormat = exports.editTable = exports.setTableCellShade = exports.formatTable = exports.insertTable = void 0;
|
|
2553
|
-
exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = void 0;
|
|
2553
|
+
exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.getTextDirection = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = void 0;
|
|
2554
2554
|
var insertTable_1 = __webpack_require__(/*! ./publicApi/table/insertTable */ "./packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts");
|
|
2555
2555
|
Object.defineProperty(exports, "insertTable", ({ enumerable: true, get: function () { return insertTable_1.insertTable; } }));
|
|
2556
2556
|
var formatTable_1 = __webpack_require__(/*! ./publicApi/table/formatTable */ "./packages/roosterjs-content-model-api/lib/publicApi/table/formatTable.ts");
|
|
@@ -2667,6 +2667,8 @@ var findListItemsInSameThread_1 = __webpack_require__(/*! ./modelApi/list/findLi
|
|
|
2667
2667
|
Object.defineProperty(exports, "findListItemsInSameThread", ({ enumerable: true, get: function () { return findListItemsInSameThread_1.findListItemsInSameThread; } }));
|
|
2668
2668
|
var setModelIndentation_1 = __webpack_require__(/*! ./modelApi/block/setModelIndentation */ "./packages/roosterjs-content-model-api/lib/modelApi/block/setModelIndentation.ts");
|
|
2669
2669
|
Object.defineProperty(exports, "setModelIndentation", ({ enumerable: true, get: function () { return setModelIndentation_1.setModelIndentation; } }));
|
|
2670
|
+
var setModelDirection_1 = __webpack_require__(/*! ./modelApi/block/setModelDirection */ "./packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts");
|
|
2671
|
+
Object.defineProperty(exports, "getTextDirection", ({ enumerable: true, get: function () { return setModelDirection_1.getTextDirection; } }));
|
|
2670
2672
|
var matchLink_1 = __webpack_require__(/*! ./modelApi/link/matchLink */ "./packages/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts");
|
|
2671
2673
|
Object.defineProperty(exports, "matchLink", ({ enumerable: true, get: function () { return matchLink_1.matchLink; } }));
|
|
2672
2674
|
var promoteLink_1 = __webpack_require__(/*! ./modelApi/link/promoteLink */ "./packages/roosterjs-content-model-api/lib/modelApi/link/promoteLink.ts");
|
|
@@ -2767,15 +2769,12 @@ exports.setModelAlignment = setModelAlignment;
|
|
|
2767
2769
|
"use strict";
|
|
2768
2770
|
|
|
2769
2771
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2770
|
-
exports.setModelDirection = void 0;
|
|
2772
|
+
exports.getTextDirection = exports.setModelDirection = void 0;
|
|
2771
2773
|
var findListItemsInSameThread_1 = __webpack_require__(/*! ../list/findListItemsInSameThread */ "./packages/roosterjs-content-model-api/lib/modelApi/list/findListItemsInSameThread.ts");
|
|
2772
2774
|
var splitSelectedParagraphByBr_1 = __webpack_require__(/*! ./splitSelectedParagraphByBr */ "./packages/roosterjs-content-model-api/lib/modelApi/block/splitSelectedParagraphByBr.ts");
|
|
2773
2775
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
var RTL_CHAR_REGEX = /[\u0590-\u05FF\u0600-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/g;
|
|
2777
|
-
var URL_CHAR_REGEX = /http\S+|www\S+|https\S+|<a\s+(?:[^>]*?\s+)?href=(["']).*?\1.*?>.*?<\/a>/g;
|
|
2778
|
-
var WHITESPACE_REGEX = /\s/g;
|
|
2776
|
+
var FIRST_STRONG_CHAR_REGEX = new RegExp('[\\p{L}\\u200E\\u200F]', 'u');
|
|
2777
|
+
var RTL_CHAR_REGEX = new RegExp('[\\u0590-\\u08FF\\u200F\\uFB1D-\\uFDFF\\uFE70-\\uFEFF\\u{10840}-\\u{10FFF}\\u{1E800}-\\u{1E95F}]', 'u');
|
|
2779
2778
|
/**
|
|
2780
2779
|
* @internal
|
|
2781
2780
|
*/
|
|
@@ -2853,29 +2852,29 @@ function setProperty(format, key, value) {
|
|
|
2853
2852
|
delete format[key];
|
|
2854
2853
|
}
|
|
2855
2854
|
}
|
|
2855
|
+
/**
|
|
2856
|
+
* Determine text direction from the first strong directional character
|
|
2857
|
+
* @param text Text to scan
|
|
2858
|
+
*/
|
|
2859
|
+
function getTextDirection(text) {
|
|
2860
|
+
var _a;
|
|
2861
|
+
var firstStrongChar = (_a = text.match(FIRST_STRONG_CHAR_REGEX)) === null || _a === void 0 ? void 0 : _a[0];
|
|
2862
|
+
return firstStrongChar ? (RTL_CHAR_REGEX.test(firstStrongChar) ? 'rtl' : 'ltr') : undefined;
|
|
2863
|
+
}
|
|
2864
|
+
exports.getTextDirection = getTextDirection;
|
|
2856
2865
|
// Designed to match browser's 'auto' detection, by scanning over the inner text until it hits a strong LTR/RTL character
|
|
2857
2866
|
function determineTextDirection(block) {
|
|
2867
|
+
return getTextDirection(getTextContent(block)) || 'ltr';
|
|
2868
|
+
}
|
|
2869
|
+
function getTextContent(block) {
|
|
2858
2870
|
if (block.blockType === 'Paragraph') {
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
if (!!innerText) {
|
|
2864
|
-
// Remove links
|
|
2865
|
-
innerText = innerText.replace(URL_CHAR_REGEX, '');
|
|
2866
|
-
// Remove whitespace
|
|
2867
|
-
innerText = innerText.replace(WHITESPACE_REGEX, '');
|
|
2868
|
-
var rtlMatches = innerText.match(RTL_CHAR_REGEX);
|
|
2869
|
-
var rtlCount = rtlMatches ? rtlMatches.length : 0;
|
|
2870
|
-
var ltrCount = innerText.length - rtlCount;
|
|
2871
|
-
return rtlCount > ltrCount ? 'rtl' : 'ltr';
|
|
2872
|
-
}
|
|
2873
|
-
else {
|
|
2874
|
-
return 'ltr'; // Default to LTR if no text is found
|
|
2875
|
-
}
|
|
2871
|
+
return block.segments.reduce(function (text, segment) { return text + (segment.segmentType === 'Text' ? segment.text : ''); }, '');
|
|
2872
|
+
}
|
|
2873
|
+
else if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(block, 'ListItem')) {
|
|
2874
|
+
return block.blocks.reduce(function (text, childBlock) { return text + getTextContent(childBlock); }, '');
|
|
2876
2875
|
}
|
|
2877
2876
|
else {
|
|
2878
|
-
return '
|
|
2877
|
+
return '';
|
|
2879
2878
|
}
|
|
2880
2879
|
}
|
|
2881
2880
|
|
|
@@ -5272,7 +5271,8 @@ function insertTableColumn(table, operation) {
|
|
|
5272
5271
|
for (var i = sel === null || sel === void 0 ? void 0 : sel.firstColumn; i <= sel.lastColumn; i++) {
|
|
5273
5272
|
table.rows.forEach(function (row) {
|
|
5274
5273
|
var cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];
|
|
5275
|
-
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(
|
|
5274
|
+
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(false, //spanLeft
|
|
5275
|
+
cell.spanAbove, cell.isHeader, cell.format, cell.dataset);
|
|
5276
5276
|
(0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
|
|
5277
5277
|
newCell.isSelected = true;
|
|
5278
5278
|
row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);
|
|
@@ -5315,7 +5315,8 @@ function insertTableRow(table, operation) {
|
|
|
5315
5315
|
table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {
|
|
5316
5316
|
format: (0, tslib_1.__assign)({}, sourceRow.format),
|
|
5317
5317
|
cells: sourceRow.cells.map(function (cell) {
|
|
5318
|
-
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft,
|
|
5318
|
+
var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, false, //spanAbove
|
|
5319
|
+
cell.isHeader, cell.format, cell.dataset);
|
|
5319
5320
|
(0, copyPreviousCellSegmentFormat_1.copyPreviousCellSegmentFormat)(cell, newCell);
|
|
5320
5321
|
newCell.isSelected = true;
|
|
5321
5322
|
return newCell;
|
|
@@ -9247,7 +9248,7 @@ function exportContent(editor, mode, optionsOrCallbacks) {
|
|
|
9247
9248
|
var clonedRoot = editor.getDOMHelper().getClonedRoot();
|
|
9248
9249
|
if (editor.isDarkMode()) {
|
|
9249
9250
|
(0, roosterjs_content_model_dom_1.transformColor)(clonedRoot, false /*includeSelf*/, 'darkToLight', editor.getColorManager(), {
|
|
9250
|
-
tableBorders:
|
|
9251
|
+
tableBorders: true,
|
|
9251
9252
|
});
|
|
9252
9253
|
}
|
|
9253
9254
|
return getHTMLFromDOM(editor, clonedRoot);
|
|
@@ -10609,7 +10610,7 @@ function restoreSnapshotColors(core, snapshot) {
|
|
|
10609
10610
|
core.darkColorHandler.updateKnownColor(isDarkMode); // Pass no parameter to force update all colors
|
|
10610
10611
|
if (!!snapshot.isDarkMode != !!isDarkMode) {
|
|
10611
10612
|
(0, roosterjs_content_model_dom_1.transformColor)(core.physicalRoot, false /*includeSelf*/, isDarkMode ? 'lightToDark' : 'darkToLight', core.darkColorHandler, {
|
|
10612
|
-
tableBorders:
|
|
10613
|
+
tableBorders: true,
|
|
10613
10614
|
});
|
|
10614
10615
|
}
|
|
10615
10616
|
}
|
|
@@ -11538,12 +11539,13 @@ exports.switchShadowEdit = switchShadowEdit;
|
|
|
11538
11539
|
/*!****************************************************************************************!*\
|
|
11539
11540
|
!*** ./packages/roosterjs-content-model-core/lib/coreApi/triggerEvent/triggerEvent.ts ***!
|
|
11540
11541
|
\****************************************************************************************/
|
|
11541
|
-
(__unused_webpack_module, exports) {
|
|
11542
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
11542
11543
|
|
|
11543
11544
|
"use strict";
|
|
11544
11545
|
|
|
11545
11546
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11546
11547
|
exports.triggerEvent = void 0;
|
|
11548
|
+
var devtoolsHook_1 = __webpack_require__(/*! ../../utils/devtoolsHook */ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts");
|
|
11547
11549
|
var allowedEventsInShadowEdit = [
|
|
11548
11550
|
'editorReady',
|
|
11549
11551
|
'beforeDispose',
|
|
@@ -11567,6 +11569,7 @@ var triggerEvent = function (core, pluginEvent, broadcast) {
|
|
|
11567
11569
|
}
|
|
11568
11570
|
});
|
|
11569
11571
|
}
|
|
11572
|
+
(0, devtoolsHook_1.notifyDevToolsPluginEvent)(core, pluginEvent);
|
|
11570
11573
|
};
|
|
11571
11574
|
exports.triggerEvent = triggerEvent;
|
|
11572
11575
|
function handledExclusively(event, plugin) {
|
|
@@ -13385,7 +13388,7 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
13385
13388
|
};
|
|
13386
13389
|
if (editor.isDarkMode()) {
|
|
13387
13390
|
(0, roosterjs_content_model_dom_1.transformColor)(wrapper, true /*includeSelf*/, 'lightToDark', editor.getColorManager(), {
|
|
13388
|
-
tableBorders:
|
|
13391
|
+
tableBorders: true,
|
|
13389
13392
|
});
|
|
13390
13393
|
}
|
|
13391
13394
|
}
|
|
@@ -15716,6 +15719,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
15716
15719
|
exports.Editor = void 0;
|
|
15717
15720
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
15718
15721
|
var createEditorCore_1 = __webpack_require__(/*! ./core/createEditorCore */ "./packages/roosterjs-content-model-core/lib/editor/core/createEditorCore.ts");
|
|
15722
|
+
var devtoolsHook_1 = __webpack_require__(/*! ../utils/devtoolsHook */ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts");
|
|
15719
15723
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
15720
15724
|
/**
|
|
15721
15725
|
* The main editor class based on Content Model
|
|
@@ -15739,7 +15743,7 @@ var Editor = /** @class */ (function () {
|
|
|
15739
15743
|
if (_this.isDarkMode()) {
|
|
15740
15744
|
var colorHandler = _this.getColorManager();
|
|
15741
15745
|
(0, roosterjs_content_model_dom_1.transformColor)(result, true /*includeSelf*/, 'darkToLight', colorHandler, {
|
|
15742
|
-
tableBorders:
|
|
15746
|
+
tableBorders: true,
|
|
15743
15747
|
});
|
|
15744
15748
|
result.style.color = result.style.color || 'inherit';
|
|
15745
15749
|
result.style.backgroundColor = result.style.backgroundColor || 'inherit';
|
|
@@ -15750,6 +15754,7 @@ var Editor = /** @class */ (function () {
|
|
|
15750
15754
|
var initialModel = (_a = options.initialModel) !== null && _a !== void 0 ? _a : (0, roosterjs_content_model_dom_1.createEmptyModel)(this.core.format.defaultFormat);
|
|
15751
15755
|
this.core.api.setContentModel(this.core, initialModel, { ignoreSelection: true }, undefined /*onNodeCreated*/, true /*isInitializing*/);
|
|
15752
15756
|
this.core.plugins.forEach(function (plugin) { return plugin.initialize(_this); });
|
|
15757
|
+
(0, devtoolsHook_1.notifyDevToolsEditorCreated)(this, this.core);
|
|
15753
15758
|
}
|
|
15754
15759
|
/**
|
|
15755
15760
|
* Dispose this editor, dispose all plugins and custom data
|
|
@@ -15757,6 +15762,7 @@ var Editor = /** @class */ (function () {
|
|
|
15757
15762
|
Editor.prototype.dispose = function () {
|
|
15758
15763
|
var _a;
|
|
15759
15764
|
var core = this.getCore();
|
|
15765
|
+
(0, devtoolsHook_1.notifyDevToolsEditorDisposed)(this, core);
|
|
15760
15766
|
for (var i = core.plugins.length - 1; i >= 0; i--) {
|
|
15761
15767
|
var plugin = core.plugins[i];
|
|
15762
15768
|
try {
|
|
@@ -15941,7 +15947,7 @@ var Editor = /** @class */ (function () {
|
|
|
15941
15947
|
var core = this.getCore();
|
|
15942
15948
|
if (!!isDarkMode != core.lifecycle.isDarkMode) {
|
|
15943
15949
|
(0, roosterjs_content_model_dom_1.transformColor)(core.physicalRoot, false /*includeSelf*/, isDarkMode ? 'lightToDark' : 'darkToLight', core.darkColorHandler, {
|
|
15944
|
-
tableBorders:
|
|
15950
|
+
tableBorders: true,
|
|
15945
15951
|
}, core.format.defaultFormat.textColor);
|
|
15946
15952
|
core.lifecycle.isDarkMode = !!isDarkMode;
|
|
15947
15953
|
core.api.triggerEvent(core, {
|
|
@@ -16390,10 +16396,11 @@ function createEditorCore(contentDiv, options) {
|
|
|
16390
16396
|
}
|
|
16391
16397
|
exports.createEditorCore = createEditorCore;
|
|
16392
16398
|
function createEditorEnvironment(contentDiv, options) {
|
|
16393
|
-
var _a, _b
|
|
16394
|
-
var
|
|
16395
|
-
var
|
|
16396
|
-
var
|
|
16399
|
+
var _a, _b;
|
|
16400
|
+
var defaultView = contentDiv.ownerDocument.defaultView;
|
|
16401
|
+
var navigator = defaultView === null || defaultView === void 0 ? void 0 : defaultView.navigator;
|
|
16402
|
+
var userAgent = (_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) !== null && _a !== void 0 ? _a : '';
|
|
16403
|
+
var appVersion = (_b = navigator === null || navigator === void 0 ? void 0 : navigator.appVersion) !== null && _b !== void 0 ? _b : '';
|
|
16397
16404
|
return {
|
|
16398
16405
|
document: contentDiv.ownerDocument,
|
|
16399
16406
|
domToModelSettings: (0, createEditorDefaultSettings_1.createDomToModelSettings)(options),
|
|
@@ -16405,6 +16412,7 @@ function createEditorEnvironment(contentDiv, options) {
|
|
|
16405
16412
|
userAgent.indexOf('Chrome') < 0 &&
|
|
16406
16413
|
userAgent.indexOf('Android') < 0,
|
|
16407
16414
|
isMobileOrTablet: getIsMobileOrTablet(userAgent),
|
|
16415
|
+
isTouchSupported: !!defaultView && ('ontouchstart' in defaultView || !!(navigator === null || navigator === void 0 ? void 0 : navigator.maxTouchPoints)),
|
|
16408
16416
|
};
|
|
16409
16417
|
}
|
|
16410
16418
|
function getIsMobileOrTablet(userAgent) {
|
|
@@ -16504,7 +16512,7 @@ exports.createModelToDomSettings = createModelToDomSettings;
|
|
|
16504
16512
|
"use strict";
|
|
16505
16513
|
|
|
16506
16514
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
16507
|
-
exports.getContentForCopy = exports.paste = exports.redo = exports.undo = exports.exportContent = exports.createModelFromHtml = exports.Editor = void 0;
|
|
16515
|
+
exports.RoosterJsDevToolsHookVersion = exports.getContentForCopy = exports.paste = exports.redo = exports.undo = exports.exportContent = exports.createModelFromHtml = exports.Editor = void 0;
|
|
16508
16516
|
// Editor
|
|
16509
16517
|
var Editor_1 = __webpack_require__(/*! ./editor/Editor */ "./packages/roosterjs-content-model-core/lib/editor/Editor.ts");
|
|
16510
16518
|
Object.defineProperty(exports, "Editor", ({ enumerable: true, get: function () { return Editor_1.Editor; } }));
|
|
@@ -16519,9 +16527,12 @@ var redo_1 = __webpack_require__(/*! ./command/redo/redo */ "./packages/roosterj
|
|
|
16519
16527
|
Object.defineProperty(exports, "redo", ({ enumerable: true, get: function () { return redo_1.redo; } }));
|
|
16520
16528
|
var paste_1 = __webpack_require__(/*! ./command/paste/paste */ "./packages/roosterjs-content-model-core/lib/command/paste/paste.ts");
|
|
16521
16529
|
Object.defineProperty(exports, "paste", ({ enumerable: true, get: function () { return paste_1.paste; } }));
|
|
16522
|
-
//Editor copy helper
|
|
16530
|
+
// Editor copy helper
|
|
16523
16531
|
var getContentForCopy_1 = __webpack_require__(/*! ./command/cutCopy/getContentForCopy */ "./packages/roosterjs-content-model-core/lib/command/cutCopy/getContentForCopy.ts");
|
|
16524
16532
|
Object.defineProperty(exports, "getContentForCopy", ({ enumerable: true, get: function () { return getContentForCopy_1.getContentForCopy; } }));
|
|
16533
|
+
// Editor devtools
|
|
16534
|
+
var devtoolsHook_1 = __webpack_require__(/*! ./utils/devtoolsHook */ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts");
|
|
16535
|
+
Object.defineProperty(exports, "RoosterJsDevToolsHookVersion", ({ enumerable: true, get: function () { return devtoolsHook_1.RoosterJsDevToolsHookVersion; } }));
|
|
16525
16536
|
|
|
16526
16537
|
|
|
16527
16538
|
/***/ },
|
|
@@ -16897,6 +16908,105 @@ function createAriaLiveElement(document) {
|
|
|
16897
16908
|
exports.createAriaLiveElement = createAriaLiveElement;
|
|
16898
16909
|
|
|
16899
16910
|
|
|
16911
|
+
/***/ },
|
|
16912
|
+
|
|
16913
|
+
/***/ "./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts"
|
|
16914
|
+
/*!*************************************************************************!*\
|
|
16915
|
+
!*** ./packages/roosterjs-content-model-core/lib/utils/devtoolsHook.ts ***!
|
|
16916
|
+
\*************************************************************************/
|
|
16917
|
+
(__unused_webpack_module, exports) {
|
|
16918
|
+
|
|
16919
|
+
"use strict";
|
|
16920
|
+
|
|
16921
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
16922
|
+
exports.notifyDevToolsPluginEvent = exports.notifyDevToolsEditorDisposed = exports.notifyDevToolsEditorCreated = exports.RoosterJsDevToolsHookVersion = void 0;
|
|
16923
|
+
/**
|
|
16924
|
+
* The current version of the RoosterJS DevTools hook contract (see
|
|
16925
|
+
* {@link RoosterJsDevToolsHook}). The editor stamps this onto the installed hook so a developer
|
|
16926
|
+
* tool can adapt to the editor's capabilities. Bump this whenever the shape of the contract changes
|
|
16927
|
+
* in a way tools may need to detect.
|
|
16928
|
+
*
|
|
16929
|
+
* History:
|
|
16930
|
+
* - 1: onEditorCreated, onEditorDisposed, onPluginEvent
|
|
16931
|
+
*/
|
|
16932
|
+
exports.RoosterJsDevToolsHookVersion = 1;
|
|
16933
|
+
// Maps an editor core back to its IEditor wrapper, so plugin events (which only carry the core)
|
|
16934
|
+
// can be attributed to the right editor when forwarded to developer tools.
|
|
16935
|
+
var coreToEditor = new WeakMap();
|
|
16936
|
+
/**
|
|
16937
|
+
* @internal
|
|
16938
|
+
* Notify developer tools that an editor has been created. Failures are swallowed so developer
|
|
16939
|
+
* tools can never break the editor.
|
|
16940
|
+
* @param editor The editor that was created
|
|
16941
|
+
* @param core The editor core, used to attribute later plugin events to this editor
|
|
16942
|
+
*/
|
|
16943
|
+
function notifyDevToolsEditorCreated(editor, core) {
|
|
16944
|
+
safeCall(function () {
|
|
16945
|
+
var _a, _b;
|
|
16946
|
+
coreToEditor.set(core, editor);
|
|
16947
|
+
var win = editor.getDocument().defaultView;
|
|
16948
|
+
if (win) {
|
|
16949
|
+
var editors = (_a = win.__ROOSTERJS_DEVTOOLS_EDITORS__) !== null && _a !== void 0 ? _a : [];
|
|
16950
|
+
editors.push(editor);
|
|
16951
|
+
win.__ROOSTERJS_DEVTOOLS_EDITORS__ = editors;
|
|
16952
|
+
var hook = win.__ROOSTERJS_DEVTOOLS_HOOK__;
|
|
16953
|
+
if (hook) {
|
|
16954
|
+
hook.version = exports.RoosterJsDevToolsHookVersion;
|
|
16955
|
+
(_b = hook.onEditorCreated) === null || _b === void 0 ? void 0 : _b.call(hook, editor);
|
|
16956
|
+
}
|
|
16957
|
+
}
|
|
16958
|
+
});
|
|
16959
|
+
}
|
|
16960
|
+
exports.notifyDevToolsEditorCreated = notifyDevToolsEditorCreated;
|
|
16961
|
+
/**
|
|
16962
|
+
* @internal
|
|
16963
|
+
* Notify developer tools that an editor is about to be disposed. Failures are swallowed so
|
|
16964
|
+
* developer tools can never break the editor.
|
|
16965
|
+
* @param editor The editor that is being disposed
|
|
16966
|
+
* @param core The editor core to stop tracking
|
|
16967
|
+
*/
|
|
16968
|
+
function notifyDevToolsEditorDisposed(editor, core) {
|
|
16969
|
+
safeCall(function () {
|
|
16970
|
+
var _a, _b;
|
|
16971
|
+
coreToEditor.delete(core);
|
|
16972
|
+
var win = editor.getDocument().defaultView;
|
|
16973
|
+
if (win) {
|
|
16974
|
+
var editors = win.__ROOSTERJS_DEVTOOLS_EDITORS__;
|
|
16975
|
+
var index = editors ? editors.indexOf(editor) : -1;
|
|
16976
|
+
if (editors && index >= 0) {
|
|
16977
|
+
editors.splice(index, 1);
|
|
16978
|
+
}
|
|
16979
|
+
(_b = (_a = win.__ROOSTERJS_DEVTOOLS_HOOK__) === null || _a === void 0 ? void 0 : _a.onEditorDisposed) === null || _b === void 0 ? void 0 : _b.call(_a, editor);
|
|
16980
|
+
}
|
|
16981
|
+
});
|
|
16982
|
+
}
|
|
16983
|
+
exports.notifyDevToolsEditorDisposed = notifyDevToolsEditorDisposed;
|
|
16984
|
+
/**
|
|
16985
|
+
* @internal
|
|
16986
|
+
* Forward a plugin event to developer tools, if a hook is installed. Failures are swallowed so
|
|
16987
|
+
* developer tools can never break the editor.
|
|
16988
|
+
* @param core The editor core that dispatched the event
|
|
16989
|
+
* @param event The plugin event being dispatched
|
|
16990
|
+
*/
|
|
16991
|
+
function notifyDevToolsPluginEvent(core, event) {
|
|
16992
|
+
safeCall(function () {
|
|
16993
|
+
var _a, _b;
|
|
16994
|
+
var editor = coreToEditor.get(core);
|
|
16995
|
+
var win = editor === null || editor === void 0 ? void 0 : editor.getDocument().defaultView;
|
|
16996
|
+
if (editor && win) {
|
|
16997
|
+
(_b = (_a = win.__ROOSTERJS_DEVTOOLS_HOOK__) === null || _a === void 0 ? void 0 : _a.onPluginEvent) === null || _b === void 0 ? void 0 : _b.call(_a, editor, event);
|
|
16998
|
+
}
|
|
16999
|
+
});
|
|
17000
|
+
}
|
|
17001
|
+
exports.notifyDevToolsPluginEvent = notifyDevToolsPluginEvent;
|
|
17002
|
+
function safeCall(callback) {
|
|
17003
|
+
try {
|
|
17004
|
+
callback();
|
|
17005
|
+
}
|
|
17006
|
+
catch (_a) { }
|
|
17007
|
+
}
|
|
17008
|
+
|
|
17009
|
+
|
|
16900
17010
|
/***/ },
|
|
16901
17011
|
|
|
16902
17012
|
/***/ "./packages/roosterjs-content-model-core/lib/utils/domCreator.ts"
|
|
@@ -17071,6 +17181,9 @@ exports.defaultHTMLStyleMap = {
|
|
|
17071
17181
|
marginBottom: '1em',
|
|
17072
17182
|
},
|
|
17073
17183
|
dt: blockElement,
|
|
17184
|
+
del: {
|
|
17185
|
+
textDecoration: 'line-through',
|
|
17186
|
+
},
|
|
17074
17187
|
em: {
|
|
17075
17188
|
fontStyle: 'italic',
|
|
17076
17189
|
},
|
|
@@ -22057,41 +22170,35 @@ var DEFAULT_COLOR = '#000000';
|
|
|
22057
22170
|
*/
|
|
22058
22171
|
exports.borderColorFormatHandler = {
|
|
22059
22172
|
parse: function (format, element, context) {
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
|
|
22065
|
-
|
|
22066
|
-
var
|
|
22067
|
-
|
|
22068
|
-
|
|
22069
|
-
|
|
22070
|
-
|
|
22071
|
-
|
|
22072
|
-
|
|
22073
|
-
|
|
22074
|
-
}
|
|
22075
|
-
});
|
|
22076
|
-
}
|
|
22173
|
+
borderKeys_1.BorderKeys.forEach(function (key) {
|
|
22174
|
+
var width = element.style.getPropertyValue(BorderWidthKeyMap[key]);
|
|
22175
|
+
var style = element.style.getPropertyValue(BorderStyleKeyMap[key]);
|
|
22176
|
+
var color = (0, color_1.retrieveElementColor)(element, key);
|
|
22177
|
+
var borderColor = color == 'initial' ? DEFAULT_COLOR : color;
|
|
22178
|
+
if (borderColor) {
|
|
22179
|
+
var lightModeColor = (0, color_1.getLightModeColor)(borderColor, !!context.isDarkMode, context.darkColorHandler);
|
|
22180
|
+
format[key] = (0, borderValues_1.combineBorderValue)({
|
|
22181
|
+
width: width,
|
|
22182
|
+
style: style,
|
|
22183
|
+
color: lightModeColor,
|
|
22184
|
+
});
|
|
22185
|
+
}
|
|
22186
|
+
});
|
|
22077
22187
|
},
|
|
22078
22188
|
apply: function (format, element, context) {
|
|
22079
|
-
|
|
22080
|
-
|
|
22081
|
-
|
|
22082
|
-
var
|
|
22083
|
-
|
|
22084
|
-
|
|
22085
|
-
var
|
|
22086
|
-
if (
|
|
22087
|
-
|
|
22088
|
-
if (transformedColor) {
|
|
22089
|
-
element.style.setProperty(borderColorProperty, transformedColor);
|
|
22090
|
-
}
|
|
22189
|
+
borderKeys_1.BorderKeys.forEach(function (key) {
|
|
22190
|
+
var value = format[key];
|
|
22191
|
+
if (value) {
|
|
22192
|
+
var borderValues = (0, borderValues_1.extractBorderValues)(value);
|
|
22193
|
+
var borderColorProperty = borderKeys_1.BorderColorKeyMap[key];
|
|
22194
|
+
if (borderValues.color) {
|
|
22195
|
+
var transformedColor = (0, color_1.adaptColor)(element, borderValues.color, 'border', !!context.isDarkMode, context.darkColorHandler);
|
|
22196
|
+
if (transformedColor) {
|
|
22197
|
+
element.style.setProperty(borderColorProperty, transformedColor);
|
|
22091
22198
|
}
|
|
22092
22199
|
}
|
|
22093
|
-
}
|
|
22094
|
-
}
|
|
22200
|
+
}
|
|
22201
|
+
});
|
|
22095
22202
|
},
|
|
22096
22203
|
};
|
|
22097
22204
|
|
|
@@ -25994,12 +26101,102 @@ function applyTableFormat(table, newFormat, keepCellShade) {
|
|
|
25994
26101
|
var effectiveMetadata = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, DEFAULT_FORMAT), format), newFormat);
|
|
25995
26102
|
var metaOverrides = updateOverrides(rows, !keepCellShade);
|
|
25996
26103
|
formatCells(rows, effectiveMetadata, metaOverrides);
|
|
26104
|
+
if ((format === null || format === void 0 ? void 0 : format.hasFirstColumn) &&
|
|
26105
|
+
(!effectiveMetadata.hasFirstColumn || (newFormat === null || newFormat === void 0 ? void 0 : newFormat.firstColumnCustomStyles) !== undefined)) {
|
|
26106
|
+
clearFirstColumnTextFormat(rows, format.firstColumnCustomStyles);
|
|
26107
|
+
}
|
|
26108
|
+
if ((format === null || format === void 0 ? void 0 : format.hasHeaderRow) &&
|
|
26109
|
+
(!effectiveMetadata.hasHeaderRow || (newFormat === null || newFormat === void 0 ? void 0 : newFormat.headerRowCustomStyles) !== undefined)) {
|
|
26110
|
+
clearHeaderRowTextFormat(rows, format.headerRowCustomStyles);
|
|
26111
|
+
}
|
|
25997
26112
|
setFirstColumnFormatBorders(rows, effectiveMetadata);
|
|
25998
26113
|
setHeaderRowFormat(rows, effectiveMetadata, metaOverrides);
|
|
25999
26114
|
return effectiveMetadata;
|
|
26000
26115
|
});
|
|
26001
26116
|
}
|
|
26002
26117
|
exports.applyTableFormat = applyTableFormat;
|
|
26118
|
+
function clearFirstColumnTextFormat(rows, customStyles) {
|
|
26119
|
+
var _a;
|
|
26120
|
+
var fontWeight = (_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _a !== void 0 ? _a : 'bold';
|
|
26121
|
+
rows.forEach(function (row) {
|
|
26122
|
+
var e_1, _a, e_2, _b;
|
|
26123
|
+
var cell = row.cells[0] && (0, mutate_1.mutateBlock)(row.cells[0]);
|
|
26124
|
+
if (cell) {
|
|
26125
|
+
clearStyleIfMatch(cell.format, 'fontWeight', fontWeight);
|
|
26126
|
+
clearStyleIfMatch(cell.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26127
|
+
try {
|
|
26128
|
+
for (var _c = (0, tslib_1.__values)(cell.blocks), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
26129
|
+
var block = _d.value;
|
|
26130
|
+
if (block.blockType == 'Paragraph') {
|
|
26131
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26132
|
+
try {
|
|
26133
|
+
for (var _e = (e_2 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
26134
|
+
var cellSegment = _f.value;
|
|
26135
|
+
clearStyleIfMatch(cellSegment.format, 'fontWeight', fontWeight);
|
|
26136
|
+
clearStyleIfMatch(cellSegment.format, 'italic', customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic);
|
|
26137
|
+
}
|
|
26138
|
+
}
|
|
26139
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
26140
|
+
finally {
|
|
26141
|
+
try {
|
|
26142
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
26143
|
+
}
|
|
26144
|
+
finally { if (e_2) throw e_2.error; }
|
|
26145
|
+
}
|
|
26146
|
+
clearStyleIfMatch(block.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26147
|
+
}
|
|
26148
|
+
}
|
|
26149
|
+
}
|
|
26150
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
26151
|
+
finally {
|
|
26152
|
+
try {
|
|
26153
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
26154
|
+
}
|
|
26155
|
+
finally { if (e_1) throw e_1.error; }
|
|
26156
|
+
}
|
|
26157
|
+
}
|
|
26158
|
+
});
|
|
26159
|
+
}
|
|
26160
|
+
function clearHeaderRowTextFormat(rows, customStyles) {
|
|
26161
|
+
var _a, _b;
|
|
26162
|
+
var fontWeight = (_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _a !== void 0 ? _a : 'bold';
|
|
26163
|
+
(_b = rows[0]) === null || _b === void 0 ? void 0 : _b.cells.forEach(function (readonlyCell) {
|
|
26164
|
+
var e_3, _a, e_4, _b;
|
|
26165
|
+
var cell = (0, mutate_1.mutateBlock)(readonlyCell);
|
|
26166
|
+
clearStyleIfMatch(cell.format, 'fontWeight', fontWeight);
|
|
26167
|
+
clearStyleIfMatch(cell.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26168
|
+
try {
|
|
26169
|
+
for (var _c = (0, tslib_1.__values)(cell.blocks), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
26170
|
+
var block = _d.value;
|
|
26171
|
+
if (block.blockType == 'Paragraph') {
|
|
26172
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26173
|
+
try {
|
|
26174
|
+
for (var _e = (e_4 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
26175
|
+
var cellSegment = _f.value;
|
|
26176
|
+
clearStyleIfMatch(cellSegment.format, 'fontWeight', fontWeight);
|
|
26177
|
+
clearStyleIfMatch(cellSegment.format, 'italic', customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic);
|
|
26178
|
+
}
|
|
26179
|
+
}
|
|
26180
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
26181
|
+
finally {
|
|
26182
|
+
try {
|
|
26183
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
26184
|
+
}
|
|
26185
|
+
finally { if (e_4) throw e_4.error; }
|
|
26186
|
+
}
|
|
26187
|
+
clearStyleIfMatch(block.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26188
|
+
}
|
|
26189
|
+
}
|
|
26190
|
+
}
|
|
26191
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
26192
|
+
finally {
|
|
26193
|
+
try {
|
|
26194
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
26195
|
+
}
|
|
26196
|
+
finally { if (e_3) throw e_3.error; }
|
|
26197
|
+
}
|
|
26198
|
+
});
|
|
26199
|
+
}
|
|
26003
26200
|
function updateOverrides(rows, removeCellShade) {
|
|
26004
26201
|
var overrides = {
|
|
26005
26202
|
bgColorOverrides: [],
|
|
@@ -26160,7 +26357,8 @@ function setFirstColumnFormatBorders(rows, format) {
|
|
|
26160
26357
|
var customStyles = format.hasFirstColumn ? format.firstColumnCustomStyles : undefined;
|
|
26161
26358
|
rows.forEach(function (row, rowIndex) {
|
|
26162
26359
|
row.cells.forEach(function (readonlyCell, cellIndex) {
|
|
26163
|
-
var
|
|
26360
|
+
var e_5, _a, e_6, _b;
|
|
26361
|
+
var _c, _d;
|
|
26164
26362
|
var cell = (0, mutate_1.mutateBlock)(readonlyCell);
|
|
26165
26363
|
if (cellIndex === 0) {
|
|
26166
26364
|
if (rowIndex == 0) {
|
|
@@ -26177,44 +26375,47 @@ function setFirstColumnFormatBorders(rows, format) {
|
|
|
26177
26375
|
}
|
|
26178
26376
|
}
|
|
26179
26377
|
try {
|
|
26180
|
-
for (var
|
|
26181
|
-
var block =
|
|
26378
|
+
for (var _e = (0, tslib_1.__values)(cell.blocks), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
26379
|
+
var block = _f.value;
|
|
26182
26380
|
if (block.blockType == 'Paragraph') {
|
|
26381
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26183
26382
|
try {
|
|
26184
|
-
for (var
|
|
26185
|
-
var
|
|
26186
|
-
(
|
|
26187
|
-
|
|
26188
|
-
|
|
26189
|
-
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
setStyleIfDefined(cellSegment.format, 'italic', customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic);
|
|
26383
|
+
for (var _g = (e_6 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
26384
|
+
var cellSegment = _h.value;
|
|
26385
|
+
if (format.hasFirstColumn) {
|
|
26386
|
+
setStyleIfDefined(cellSegment.format, 'fontWeight', (_c = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _c !== void 0 ? _c : 'bold');
|
|
26387
|
+
setStyleIfDefined(cell.format, 'textAlign', customStyles === null || customStyles === void 0 ? void 0 : customStyles.textAlign);
|
|
26388
|
+
setStyleIfDefined(cell.format, 'fontWeight', (_d = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _d !== void 0 ? _d : 'bold');
|
|
26389
|
+
if (customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) {
|
|
26390
|
+
cellSegment.format.italic = true;
|
|
26193
26391
|
}
|
|
26194
|
-
else if (
|
|
26195
|
-
|
|
26196
|
-
delete cellSegment.format.fontWeight;
|
|
26197
|
-
delete cell.format.fontWeight;
|
|
26392
|
+
else if ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) === false) {
|
|
26393
|
+
delete cellSegment.format.italic;
|
|
26198
26394
|
}
|
|
26199
|
-
}
|
|
26395
|
+
}
|
|
26396
|
+
else if (cellSegment.format.fontWeight == 'bold' &&
|
|
26397
|
+
cell.format.fontWeight == 'bold') {
|
|
26398
|
+
delete cellSegment.format.fontWeight;
|
|
26399
|
+
delete cell.format.fontWeight;
|
|
26400
|
+
}
|
|
26200
26401
|
}
|
|
26201
26402
|
}
|
|
26202
|
-
catch (
|
|
26403
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
26203
26404
|
finally {
|
|
26204
26405
|
try {
|
|
26205
|
-
if (
|
|
26406
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
26206
26407
|
}
|
|
26207
|
-
finally { if (
|
|
26408
|
+
finally { if (e_6) throw e_6.error; }
|
|
26208
26409
|
}
|
|
26209
26410
|
}
|
|
26210
26411
|
}
|
|
26211
26412
|
}
|
|
26212
|
-
catch (
|
|
26413
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
26213
26414
|
finally {
|
|
26214
26415
|
try {
|
|
26215
|
-
if (
|
|
26416
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
26216
26417
|
}
|
|
26217
|
-
finally { if (
|
|
26418
|
+
finally { if (e_5) throw e_5.error; }
|
|
26218
26419
|
}
|
|
26219
26420
|
}
|
|
26220
26421
|
});
|
|
@@ -26231,6 +26432,11 @@ function setStyleIfDefined(format, key, value) {
|
|
|
26231
26432
|
format[key] = value;
|
|
26232
26433
|
}
|
|
26233
26434
|
}
|
|
26435
|
+
function clearStyleIfMatch(format, key, value) {
|
|
26436
|
+
if (value !== undefined && format[key] === value) {
|
|
26437
|
+
delete format[key];
|
|
26438
|
+
}
|
|
26439
|
+
}
|
|
26234
26440
|
function setHeaderRowFormat(rows, format, metaOverrides) {
|
|
26235
26441
|
var _a;
|
|
26236
26442
|
if (!format.hasHeaderRow) {
|
|
@@ -26239,11 +26445,12 @@ function setHeaderRowFormat(rows, format, metaOverrides) {
|
|
|
26239
26445
|
var rowIndex = 0;
|
|
26240
26446
|
var customStyles = format.headerRowCustomStyles;
|
|
26241
26447
|
(_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.forEach(function (readonlyCell, cellIndex) {
|
|
26242
|
-
var
|
|
26448
|
+
var e_7, _a, e_8, _b;
|
|
26243
26449
|
var _c, _d, _e, _f;
|
|
26244
26450
|
var cell = (0, mutate_1.mutateBlock)(readonlyCell);
|
|
26451
|
+
var fontWeight = (_c = customStyles === null || customStyles === void 0 ? void 0 : customStyles.fontWeight) !== null && _c !== void 0 ? _c : 'bold';
|
|
26245
26452
|
cell.isHeader = true;
|
|
26246
|
-
cell.format.fontWeight =
|
|
26453
|
+
cell.format.fontWeight = fontWeight;
|
|
26247
26454
|
if (format.headerRowColor) {
|
|
26248
26455
|
if (!metaOverrides.bgColorOverrides[rowIndex][cellIndex]) {
|
|
26249
26456
|
(0, setTableCellBackgroundColor_1.setTableCellBackgroundColor)(cell, format.headerRowColor, false /*isColorOverride*/, true /*applyToSegments*/);
|
|
@@ -26255,40 +26462,40 @@ function setHeaderRowFormat(rows, format, metaOverrides) {
|
|
|
26255
26462
|
if (customStyles) {
|
|
26256
26463
|
setStyleIfDefined(cell.format, 'textAlign', customStyles.textAlign);
|
|
26257
26464
|
setBorderColorIfExists(cell.format, 'borderBottom', customStyles.borderBottomColor);
|
|
26258
|
-
|
|
26259
|
-
|
|
26260
|
-
|
|
26261
|
-
|
|
26262
|
-
|
|
26263
|
-
|
|
26264
|
-
|
|
26265
|
-
|
|
26266
|
-
|
|
26267
|
-
|
|
26268
|
-
|
|
26269
|
-
|
|
26270
|
-
delete cellSegment.format.italic;
|
|
26271
|
-
}
|
|
26272
|
-
});
|
|
26465
|
+
}
|
|
26466
|
+
try {
|
|
26467
|
+
for (var _g = (0, tslib_1.__values)(cell.blocks), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
26468
|
+
var block = _h.value;
|
|
26469
|
+
if (block.blockType == 'Paragraph') {
|
|
26470
|
+
var mutateParagraph = (0, mutate_1.mutateBlock)(block);
|
|
26471
|
+
try {
|
|
26472
|
+
for (var _j = (e_8 = void 0, (0, tslib_1.__values)(mutateParagraph.segments)), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
26473
|
+
var cellSegment = _k.value;
|
|
26474
|
+
cellSegment.format.fontWeight = fontWeight;
|
|
26475
|
+
if (customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) {
|
|
26476
|
+
cellSegment.format.italic = true;
|
|
26273
26477
|
}
|
|
26274
|
-
|
|
26275
|
-
|
|
26276
|
-
finally {
|
|
26277
|
-
try {
|
|
26278
|
-
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
26478
|
+
else if ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.italic) === false) {
|
|
26479
|
+
delete cellSegment.format.italic;
|
|
26279
26480
|
}
|
|
26280
|
-
finally { if (e_4) throw e_4.error; }
|
|
26281
26481
|
}
|
|
26282
26482
|
}
|
|
26483
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
26484
|
+
finally {
|
|
26485
|
+
try {
|
|
26486
|
+
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
26487
|
+
}
|
|
26488
|
+
finally { if (e_8) throw e_8.error; }
|
|
26489
|
+
}
|
|
26283
26490
|
}
|
|
26284
26491
|
}
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
finally { if (e_3) throw e_3.error; }
|
|
26492
|
+
}
|
|
26493
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
26494
|
+
finally {
|
|
26495
|
+
try {
|
|
26496
|
+
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
26291
26497
|
}
|
|
26498
|
+
finally { if (e_7) throw e_7.error; }
|
|
26292
26499
|
}
|
|
26293
26500
|
});
|
|
26294
26501
|
}
|
|
@@ -27257,7 +27464,7 @@ function mergeTables(markerPosition, newTable, source) {
|
|
|
27257
27464
|
var newColIndex = currentColCount + col;
|
|
27258
27465
|
for (var k = 0; k < table.rows.length; k++) {
|
|
27259
27466
|
var leftCell = (_b = table.rows[k]) === null || _b === void 0 ? void 0 : _b.cells[newColIndex - 1];
|
|
27260
|
-
table.rows[k].cells[newColIndex] = (0, createTableCell_1.createTableCell)(false /*spanLeft*/,
|
|
27467
|
+
table.rows[k].cells[newColIndex] = (0, createTableCell_1.createTableCell)(false /*spanLeft*/, leftCell === null || leftCell === void 0 ? void 0 : leftCell.spanAbove, leftCell === null || leftCell === void 0 ? void 0 : leftCell.isHeader, leftCell === null || leftCell === void 0 ? void 0 : leftCell.format);
|
|
27261
27468
|
}
|
|
27262
27469
|
}
|
|
27263
27470
|
}
|
|
@@ -27275,7 +27482,7 @@ function mergeTables(markerPosition, newTable, source) {
|
|
|
27275
27482
|
};
|
|
27276
27483
|
for (var k = 0; k < colCount; k++) {
|
|
27277
27484
|
var aboveCell = (_d = table.rows[newRowIndex - 1]) === null || _d === void 0 ? void 0 : _d.cells[k];
|
|
27278
|
-
table.rows[newRowIndex].cells[k] = (0, createTableCell_1.createTableCell)(
|
|
27485
|
+
table.rows[newRowIndex].cells[k] = (0, createTableCell_1.createTableCell)(aboveCell === null || aboveCell === void 0 ? void 0 : aboveCell.spanLeft, false /*spanAbove*/, false /*isHeader*/, aboveCell === null || aboveCell === void 0 ? void 0 : aboveCell.format);
|
|
27279
27486
|
}
|
|
27280
27487
|
}
|
|
27281
27488
|
}
|
|
@@ -27319,10 +27526,43 @@ function mergeTables(markerPosition, newTable, source) {
|
|
|
27319
27526
|
(0, normalizeTable_1.normalizeTable)(table, markerPosition.marker.format);
|
|
27320
27527
|
(0, applyTableFormat_1.applyTableFormat)(table, undefined /*newFormat*/, true /*keepCellShade*/);
|
|
27321
27528
|
}
|
|
27322
|
-
else {
|
|
27529
|
+
else if (!mergeTableAfterPreviousTable(markerPosition, newTable)) {
|
|
27323
27530
|
insertBlock(markerPosition, newTable);
|
|
27324
27531
|
}
|
|
27325
27532
|
}
|
|
27533
|
+
function mergeTableAfterPreviousTable(markerPosition, newTable) {
|
|
27534
|
+
var _a;
|
|
27535
|
+
var _b, _c;
|
|
27536
|
+
var marker = markerPosition.marker, paragraph = markerPosition.paragraph, path = markerPosition.path;
|
|
27537
|
+
var parent = path[0];
|
|
27538
|
+
var paragraphIndex = parent.blocks.indexOf(paragraph);
|
|
27539
|
+
var previousBlock = parent.blocks[paragraphIndex - 1];
|
|
27540
|
+
if (paragraphIndex > 0 &&
|
|
27541
|
+
paragraph.segments.indexOf(marker) == 0 &&
|
|
27542
|
+
(previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.blockType) == 'Table' &&
|
|
27543
|
+
((_b = previousBlock.rows[0]) === null || _b === void 0 ? void 0 : _b.cells.length) > 0 &&
|
|
27544
|
+
((_c = newTable.rows[0]) === null || _c === void 0 ? void 0 : _c.cells.length) > 0) {
|
|
27545
|
+
var table = (0, mutate_1.mutateBlock)(previousBlock);
|
|
27546
|
+
var columnCount = Math.max.apply(Math, (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(table.rows.map(function (row) { return row.cells.length; })), false), (0, tslib_1.__read)(newTable.rows.map(function (row) { return row.cells.length; })), false));
|
|
27547
|
+
extendTableRows(table, columnCount);
|
|
27548
|
+
extendTableRows(newTable, columnCount);
|
|
27549
|
+
(_a = table.rows).push.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(newTable.rows), false));
|
|
27550
|
+
return true;
|
|
27551
|
+
}
|
|
27552
|
+
return false;
|
|
27553
|
+
}
|
|
27554
|
+
function extendTableRows(table, columnCount) {
|
|
27555
|
+
table.rows.forEach(function (row) {
|
|
27556
|
+
var currentColumnCount = row.cells.length;
|
|
27557
|
+
var lastCell = row.cells[currentColumnCount - 1];
|
|
27558
|
+
if (lastCell) {
|
|
27559
|
+
for (var col = currentColumnCount; col < columnCount; col++) {
|
|
27560
|
+
var spanCell = (0, createTableCell_1.createTableCell)(true /* spanLeft */, false /* spanAbove */, lastCell.isHeader, lastCell.format, lastCell.dataset);
|
|
27561
|
+
row.cells.push(spanCell);
|
|
27562
|
+
}
|
|
27563
|
+
}
|
|
27564
|
+
});
|
|
27565
|
+
}
|
|
27326
27566
|
function mergeList(markerPosition, newList) {
|
|
27327
27567
|
splitParagraph(markerPosition, newList.format);
|
|
27328
27568
|
var path = markerPosition.path, paragraph = markerPosition.paragraph;
|
|
@@ -32915,6 +33155,7 @@ var DefaultOptions = {
|
|
|
32915
33155
|
autoOrdinals: false,
|
|
32916
33156
|
removeListMargins: false,
|
|
32917
33157
|
autoHorizontalLine: false,
|
|
33158
|
+
autoDirection: false,
|
|
32918
33159
|
};
|
|
32919
33160
|
/**
|
|
32920
33161
|
* Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
|
|
@@ -32934,12 +33175,14 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
32934
33175
|
* - autoTel: A boolean that enables or disables automatic hyperlink telephone numbers transformation. Defaults to false.
|
|
32935
33176
|
* - autoMailto: A boolean that enables or disables automatic hyperlink email address transformation. Defaults to false.
|
|
32936
33177
|
* - autoHorizontalLine: A boolean that enables or disables automatic horizontal line creation. Defaults to false.
|
|
33178
|
+
* - autoDirection: A boolean that enables or disables automatic text direction. Defaults to false.
|
|
32937
33179
|
*/
|
|
32938
33180
|
function AutoFormatPlugin(options) {
|
|
32939
33181
|
var _this = this;
|
|
32940
33182
|
if (options === void 0) { options = DefaultOptions; }
|
|
32941
33183
|
this.options = options;
|
|
32942
33184
|
this.editor = null;
|
|
33185
|
+
this.blockDirections = new WeakMap();
|
|
32943
33186
|
this.autoLink = {
|
|
32944
33187
|
enabled: !!(this.options.autoLink || this.options.autoTel || this.options.autoMailto),
|
|
32945
33188
|
transformFunction: function (_model, previousSegment, paragraph, context) {
|
|
@@ -33074,6 +33317,9 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
33074
33317
|
case 'input':
|
|
33075
33318
|
this.handleEditorInputEvent(this.editor, event);
|
|
33076
33319
|
break;
|
|
33320
|
+
case 'compositionEnd':
|
|
33321
|
+
this.handleCompositionEndEvent(this.editor, event.rawEvent.data);
|
|
33322
|
+
break;
|
|
33077
33323
|
case 'keyDown':
|
|
33078
33324
|
this.handleKeyDownEvent(this.editor, event);
|
|
33079
33325
|
break;
|
|
@@ -33138,9 +33384,41 @@ var AutoFormatPlugin = /** @class */ (function () {
|
|
|
33138
33384
|
case ' ':
|
|
33139
33385
|
this.handleKeyboardEvents(editor, this.features);
|
|
33140
33386
|
break;
|
|
33387
|
+
default:
|
|
33388
|
+
this.handleAutoDirection(editor, rawEvent.data, selection.range);
|
|
33389
|
+
break;
|
|
33141
33390
|
}
|
|
33142
33391
|
}
|
|
33143
33392
|
};
|
|
33393
|
+
AutoFormatPlugin.prototype.handleCompositionEndEvent = function (editor, insertedText) {
|
|
33394
|
+
var selection = editor.getDOMSelection();
|
|
33395
|
+
if ((selection === null || selection === void 0 ? void 0 : selection.type) === 'range' && selection.range.collapsed) {
|
|
33396
|
+
this.handleAutoDirection(editor, insertedText, selection.range);
|
|
33397
|
+
}
|
|
33398
|
+
};
|
|
33399
|
+
AutoFormatPlugin.prototype.handleAutoDirection = function (editor, insertedText, range) {
|
|
33400
|
+
var _a;
|
|
33401
|
+
if (!this.options.autoDirection || !insertedText || !(0, roosterjs_content_model_api_1.getTextDirection)(insertedText)) {
|
|
33402
|
+
return;
|
|
33403
|
+
}
|
|
33404
|
+
var block = editor.getDOMHelper().findClosestBlockElement(range.startContainer);
|
|
33405
|
+
var expectedDirection = (0, roosterjs_content_model_api_1.getTextDirection)(block.textContent || '');
|
|
33406
|
+
var inlineDirection = block.style.direction;
|
|
33407
|
+
var cachedDirection = inlineDirection === 'ltr' || inlineDirection === 'rtl'
|
|
33408
|
+
? inlineDirection
|
|
33409
|
+
: this.blockDirections.get(block);
|
|
33410
|
+
if (!expectedDirection || cachedDirection === expectedDirection) {
|
|
33411
|
+
return;
|
|
33412
|
+
}
|
|
33413
|
+
var currentDirection = cachedDirection || ((_a = block.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(block).direction);
|
|
33414
|
+
if (currentDirection === 'ltr' || currentDirection === 'rtl') {
|
|
33415
|
+
this.blockDirections.set(block, currentDirection);
|
|
33416
|
+
}
|
|
33417
|
+
if (currentDirection !== expectedDirection) {
|
|
33418
|
+
this.blockDirections.set(block, expectedDirection);
|
|
33419
|
+
(0, roosterjs_content_model_api_1.setDirection)(editor, 'auto');
|
|
33420
|
+
}
|
|
33421
|
+
};
|
|
33144
33422
|
AutoFormatPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
33145
33423
|
var rawEvent = event.rawEvent;
|
|
33146
33424
|
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
@@ -37764,7 +38042,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37764
38042
|
if (this.imageEditInfo) {
|
|
37765
38043
|
this.startEditing(editor, image, ['resize', 'rotate']);
|
|
37766
38044
|
if (this.selectedImage && this.imageEditInfo && this.wrapper && this.clonedImage) {
|
|
37767
|
-
var
|
|
38045
|
+
var _c = editor.getEnvironment(), isMobileOrTablet = _c.isMobileOrTablet, isTouchSupported = _c.isTouchSupported;
|
|
37768
38046
|
this.dndHelpers = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.ResizeHandle, resizerContext_1.Resizer, function () {
|
|
37769
38047
|
if (_this.imageEditInfo &&
|
|
37770
38048
|
_this.selectedImage &&
|
|
@@ -37773,7 +38051,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37773
38051
|
(0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, _this.resizers, undefined /* croppers */, isRTL);
|
|
37774
38052
|
_this.wasImageResized = true;
|
|
37775
38053
|
}
|
|
37776
|
-
}, this.zoomScale,
|
|
38054
|
+
}, this.zoomScale, !!isMobileOrTablet, !!isTouchSupported)), false), (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.RotateHandle, rotatorContext_1.Rotator, function () {
|
|
37777
38055
|
var _a, _b;
|
|
37778
38056
|
if (_this.imageEditInfo &&
|
|
37779
38057
|
_this.selectedImage &&
|
|
@@ -37783,7 +38061,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37783
38061
|
_this.updateRotateHandleState(editor, _this.selectedImage, _this.wrapper, _this.rotators, (_a = _this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad, !!((_b = _this.options) === null || _b === void 0 ? void 0 : _b.disableSideResize));
|
|
37784
38062
|
_this.updateResizeHandleDirection(_this.resizers, _this.imageEditInfo.angleRad);
|
|
37785
38063
|
}
|
|
37786
|
-
}, this.zoomScale,
|
|
38064
|
+
}, this.zoomScale, !!isMobileOrTablet, !!isTouchSupported)), false);
|
|
37787
38065
|
(0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, this.resizers, undefined /* croppers */, isRTL);
|
|
37788
38066
|
this.updateRotateHandleState(editor, this.selectedImage, this.wrapper, this.rotators, (_a = this.imageEditInfo) === null || _a === void 0 ? void 0 : _a.angleRad, !!((_b = this.options) === null || _b === void 0 ? void 0 : _b.disableSideResize));
|
|
37789
38067
|
}
|
|
@@ -37829,7 +38107,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37829
38107
|
(0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined /* resizers */, _this.croppers, isRTL);
|
|
37830
38108
|
_this.isCropMode = true;
|
|
37831
38109
|
}
|
|
37832
|
-
}, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet)), false);
|
|
38110
|
+
}, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet, !!editor.getEnvironment().isTouchSupported)), false);
|
|
37833
38111
|
(0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, undefined /* resizers */, this.croppers, isRTL);
|
|
37834
38112
|
}
|
|
37835
38113
|
}
|
|
@@ -39048,7 +39326,7 @@ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-mo
|
|
|
39048
39326
|
/**
|
|
39049
39327
|
* @internal
|
|
39050
39328
|
*/
|
|
39051
|
-
function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper, updateWrapper, zoomScale,
|
|
39329
|
+
function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper, updateWrapper, zoomScale, forceMobile, isTouchSupported) {
|
|
39052
39330
|
return getEditElements(wrapper, elementClass).map(function (element) {
|
|
39053
39331
|
return new DragAndDropHelper_1.DragAndDropHelper(element, {
|
|
39054
39332
|
editInfo: editInfo,
|
|
@@ -39056,7 +39334,7 @@ function getDropAndDragHelpers(wrapper, editInfo, options, elementClass, helper,
|
|
|
39056
39334
|
elementClass: elementClass,
|
|
39057
39335
|
x: element.dataset.x,
|
|
39058
39336
|
y: element.dataset.y,
|
|
39059
|
-
}, updateWrapper, helper, zoomScale,
|
|
39337
|
+
}, updateWrapper, helper, zoomScale, forceMobile, isTouchSupported);
|
|
39060
39338
|
});
|
|
39061
39339
|
}
|
|
39062
39340
|
exports.getDropAndDragHelpers = getDropAndDragHelpers;
|
|
@@ -42629,7 +42907,7 @@ var MOUSE_EVENT_INFO_DESKTOP = (function () {
|
|
|
42629
42907
|
MOUSEDOWN: 'mousedown',
|
|
42630
42908
|
MOUSEMOVE: 'mousemove',
|
|
42631
42909
|
MOUSEUP: 'mouseup',
|
|
42632
|
-
|
|
42910
|
+
normalizeEvent: normalizeMouseEvent,
|
|
42633
42911
|
};
|
|
42634
42912
|
})();
|
|
42635
42913
|
var MOUSE_EVENT_INFO_MOBILE = (function () {
|
|
@@ -42637,21 +42915,37 @@ var MOUSE_EVENT_INFO_MOBILE = (function () {
|
|
|
42637
42915
|
MOUSEDOWN: 'touchstart',
|
|
42638
42916
|
MOUSEMOVE: 'touchmove',
|
|
42639
42917
|
MOUSEUP: 'touchend',
|
|
42640
|
-
|
|
42918
|
+
normalizeEvent: normalizeTouchEvent,
|
|
42641
42919
|
};
|
|
42642
42920
|
})();
|
|
42643
|
-
function
|
|
42644
|
-
|
|
42645
|
-
|
|
42646
|
-
|
|
42647
|
-
|
|
42648
|
-
|
|
42649
|
-
|
|
42650
|
-
|
|
42651
|
-
|
|
42652
|
-
|
|
42653
|
-
}
|
|
42654
|
-
|
|
42921
|
+
function normalizeMouseEvent(event) {
|
|
42922
|
+
var mouseEvent = event;
|
|
42923
|
+
return {
|
|
42924
|
+
clientX: mouseEvent.clientX,
|
|
42925
|
+
clientY: mouseEvent.clientY,
|
|
42926
|
+
pageX: mouseEvent.pageX,
|
|
42927
|
+
pageY: mouseEvent.pageY,
|
|
42928
|
+
target: mouseEvent.target,
|
|
42929
|
+
shiftKey: mouseEvent.shiftKey,
|
|
42930
|
+
altKey: mouseEvent.altKey,
|
|
42931
|
+
};
|
|
42932
|
+
}
|
|
42933
|
+
function normalizeTouchEvent(event) {
|
|
42934
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
42935
|
+
var touchEvent = event;
|
|
42936
|
+
var touch = (_b = (_a = touchEvent.targetTouches) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : (_c = touchEvent.changedTouches) === null || _c === void 0 ? void 0 : _c[0];
|
|
42937
|
+
var clientX = (_d = touch === null || touch === void 0 ? void 0 : touch.clientX) !== null && _d !== void 0 ? _d : 0;
|
|
42938
|
+
var clientY = (_e = touch === null || touch === void 0 ? void 0 : touch.clientY) !== null && _e !== void 0 ? _e : 0;
|
|
42939
|
+
var document = (_g = (_f = touchEvent.view) === null || _f === void 0 ? void 0 : _f.document) !== null && _g !== void 0 ? _g : (_h = event.target) === null || _h === void 0 ? void 0 : _h.ownerDocument;
|
|
42940
|
+
return {
|
|
42941
|
+
clientX: clientX,
|
|
42942
|
+
clientY: clientY,
|
|
42943
|
+
pageX: (_j = touch === null || touch === void 0 ? void 0 : touch.pageX) !== null && _j !== void 0 ? _j : 0,
|
|
42944
|
+
pageY: (_k = touch === null || touch === void 0 ? void 0 : touch.pageY) !== null && _k !== void 0 ? _k : 0,
|
|
42945
|
+
target: touch ? (_l = document === null || document === void 0 ? void 0 : document.elementFromPoint(clientX, clientY)) !== null && _l !== void 0 ? _l : event.target : event.target,
|
|
42946
|
+
shiftKey: false,
|
|
42947
|
+
altKey: false,
|
|
42948
|
+
};
|
|
42655
42949
|
}
|
|
42656
42950
|
/**
|
|
42657
42951
|
* @internal
|
|
@@ -42668,8 +42962,9 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42668
42962
|
* @param handler The event handler object, see DragAndDropHandler interface for more information
|
|
42669
42963
|
* @param zoomScale The zoom scale of the editor
|
|
42670
42964
|
* @param forceMobile A boolean to force the use of touch controls for the helper
|
|
42965
|
+
* @param isTouchSupported Whether the current browser supports touch input
|
|
42671
42966
|
*/
|
|
42672
|
-
function DragAndDropHelper(trigger, context, onSubmit, handler, zoomScale, forceMobile) {
|
|
42967
|
+
function DragAndDropHelper(trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) {
|
|
42673
42968
|
var _this = this;
|
|
42674
42969
|
this.trigger = trigger;
|
|
42675
42970
|
this.context = context;
|
|
@@ -42679,23 +42974,29 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42679
42974
|
this.initX = 0;
|
|
42680
42975
|
this.initY = 0;
|
|
42681
42976
|
this.initValue = undefined;
|
|
42977
|
+
this.dndMouse = MOUSE_EVENT_INFO_DESKTOP;
|
|
42682
42978
|
this.onMouseDown = function (e) {
|
|
42683
42979
|
var _a;
|
|
42684
42980
|
var _b, _c;
|
|
42685
42981
|
e.preventDefault();
|
|
42686
42982
|
e.stopPropagation();
|
|
42983
|
+
_this.dndMouse =
|
|
42984
|
+
e.type == MOUSE_EVENT_INFO_MOBILE.MOUSEDOWN
|
|
42985
|
+
? MOUSE_EVENT_INFO_MOBILE
|
|
42986
|
+
: MOUSE_EVENT_INFO_DESKTOP;
|
|
42687
42987
|
_this.addDocumentEvents();
|
|
42688
|
-
|
|
42689
|
-
|
|
42988
|
+
var event = _this.dndMouse.normalizeEvent(e);
|
|
42989
|
+
_a = (0, tslib_1.__read)([event.pageX, event.pageY], 2), _this.initX = _a[0], _this.initY = _a[1];
|
|
42990
|
+
_this.initValue = (_c = (_b = _this.handler).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, _this.context, event);
|
|
42690
42991
|
};
|
|
42691
42992
|
this.onMouseMove = function (e) {
|
|
42692
42993
|
var _a, _b, _c;
|
|
42693
42994
|
e.preventDefault();
|
|
42694
|
-
var
|
|
42695
|
-
var deltaX = (pageX - _this.initX) / _this.zoomScale;
|
|
42696
|
-
var deltaY = (pageY - _this.initY) / _this.zoomScale;
|
|
42995
|
+
var event = _this.dndMouse.normalizeEvent(e);
|
|
42996
|
+
var deltaX = (event.pageX - _this.initX) / _this.zoomScale;
|
|
42997
|
+
var deltaY = (event.pageY - _this.initY) / _this.zoomScale;
|
|
42697
42998
|
if (_this.initValue &&
|
|
42698
|
-
((_b = (_a = _this.handler).onDragging) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context,
|
|
42999
|
+
((_b = (_a = _this.handler).onDragging) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, event, _this.initValue, deltaX, deltaY))) {
|
|
42699
43000
|
(_c = _this.onSubmit) === null || _c === void 0 ? void 0 : _c.call(_this, _this.context, _this.trigger);
|
|
42700
43001
|
}
|
|
42701
43002
|
};
|
|
@@ -42703,18 +43004,33 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42703
43004
|
var _a, _b, _c;
|
|
42704
43005
|
e.preventDefault();
|
|
42705
43006
|
_this.removeDocumentEvents();
|
|
42706
|
-
if ((_b = (_a = _this.handler).onDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, e, _this.initValue)) {
|
|
43007
|
+
if ((_b = (_a = _this.handler).onDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, _this.dndMouse.normalizeEvent(e), _this.initValue)) {
|
|
42707
43008
|
(_c = _this.onSubmit) === null || _c === void 0 ? void 0 : _c.call(_this, _this.context, _this.trigger);
|
|
42708
43009
|
}
|
|
42709
43010
|
};
|
|
42710
|
-
this.
|
|
42711
|
-
|
|
43011
|
+
this.dndMouseList = forceMobile
|
|
43012
|
+
? [MOUSE_EVENT_INFO_MOBILE]
|
|
43013
|
+
: isTouchSupported
|
|
43014
|
+
? [MOUSE_EVENT_INFO_DESKTOP, MOUSE_EVENT_INFO_MOBILE]
|
|
43015
|
+
: [MOUSE_EVENT_INFO_DESKTOP];
|
|
43016
|
+
this.dndMouse = this.dndMouseList[0];
|
|
43017
|
+
this.originalTouchAction = trigger.style.touchAction;
|
|
43018
|
+
if (this.dndMouseList.indexOf(MOUSE_EVENT_INFO_MOBILE) >= 0) {
|
|
43019
|
+
trigger.style.touchAction = 'none';
|
|
43020
|
+
}
|
|
43021
|
+
this.dndMouseList.forEach(function (eventInfo) {
|
|
43022
|
+
return trigger.addEventListener(eventInfo.MOUSEDOWN, _this.onMouseDown, { passive: false });
|
|
43023
|
+
});
|
|
42712
43024
|
}
|
|
42713
43025
|
/**
|
|
42714
43026
|
* Dispose this object, remove all event listeners that has been attached
|
|
42715
43027
|
*/
|
|
42716
43028
|
DragAndDropHelper.prototype.dispose = function () {
|
|
42717
|
-
|
|
43029
|
+
var _this = this;
|
|
43030
|
+
this.dndMouseList.forEach(function (eventInfo) {
|
|
43031
|
+
return _this.trigger.removeEventListener(eventInfo.MOUSEDOWN, _this.onMouseDown);
|
|
43032
|
+
});
|
|
43033
|
+
this.trigger.style.touchAction = this.originalTouchAction;
|
|
42718
43034
|
this.removeDocumentEvents();
|
|
42719
43035
|
};
|
|
42720
43036
|
Object.defineProperty(DragAndDropHelper.prototype, "mouseType", {
|
|
@@ -42726,8 +43042,14 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
42726
43042
|
});
|
|
42727
43043
|
DragAndDropHelper.prototype.addDocumentEvents = function () {
|
|
42728
43044
|
var doc = this.trigger.ownerDocument;
|
|
42729
|
-
doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove,
|
|
42730
|
-
|
|
43045
|
+
doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, {
|
|
43046
|
+
capture: true,
|
|
43047
|
+
passive: false,
|
|
43048
|
+
});
|
|
43049
|
+
doc.addEventListener(this.dndMouse.MOUSEUP, this.onMouseUp, {
|
|
43050
|
+
capture: true,
|
|
43051
|
+
passive: false,
|
|
43052
|
+
});
|
|
42731
43053
|
};
|
|
42732
43054
|
DragAndDropHelper.prototype.removeDocumentEvents = function () {
|
|
42733
43055
|
var doc = this.trigger.ownerDocument;
|
|
@@ -43265,32 +43587,23 @@ var TableEditPlugin = /** @class */ (function () {
|
|
|
43265
43587
|
}
|
|
43266
43588
|
};
|
|
43267
43589
|
this.onMouseMove = function (event) {
|
|
43268
|
-
var _a
|
|
43590
|
+
var _a;
|
|
43269
43591
|
var e = event;
|
|
43270
43592
|
var editorWindow = (_a = _this.editor) === null || _a === void 0 ? void 0 : _a.getDocument().defaultView;
|
|
43271
43593
|
if (e.buttons > 0 || !editorWindow) {
|
|
43272
43594
|
return;
|
|
43273
43595
|
}
|
|
43274
|
-
_this.ensureTableRects();
|
|
43275
43596
|
var x = e.pageX - editorWindow.scrollX;
|
|
43276
43597
|
var y = e.pageY - editorWindow.scrollY;
|
|
43277
|
-
|
|
43278
|
-
|
|
43279
|
-
|
|
43280
|
-
|
|
43281
|
-
|
|
43282
|
-
|
|
43283
|
-
|
|
43284
|
-
|
|
43285
|
-
y >= rect.top - TABLE_RESIZER_LENGTH &&
|
|
43286
|
-
y <= rect.bottom + TABLE_RESIZER_LENGTH) {
|
|
43287
|
-
currentTable = entry;
|
|
43288
|
-
break;
|
|
43289
|
-
}
|
|
43290
|
-
}
|
|
43598
|
+
_this.updateTableEditor(x, y, event, true /* updateHoveredFeature */);
|
|
43599
|
+
};
|
|
43600
|
+
this.onTouchStart = function (event) {
|
|
43601
|
+
var _a;
|
|
43602
|
+
var touchEvent = event;
|
|
43603
|
+
var touch = (_a = touchEvent.targetTouches[0]) !== null && _a !== void 0 ? _a : touchEvent.changedTouches[0];
|
|
43604
|
+
if (touch) {
|
|
43605
|
+
_this.updateTableEditor(touch.clientX, touch.clientY, event, false /* updateHoveredFeature */);
|
|
43291
43606
|
}
|
|
43292
|
-
_this.setTableEditor(currentTable, e);
|
|
43293
|
-
(_b = _this.tableEditor) === null || _b === void 0 ? void 0 : _b.onMouseMove(x, y);
|
|
43294
43607
|
};
|
|
43295
43608
|
this.invalidateTableRects = function () {
|
|
43296
43609
|
_this.tableRectMap = null;
|
|
@@ -43310,6 +43623,7 @@ var TableEditPlugin = /** @class */ (function () {
|
|
|
43310
43623
|
this.editor = editor;
|
|
43311
43624
|
this.onMouseMoveDisposer = this.editor.attachDomEvent({
|
|
43312
43625
|
mousemove: { beforeDispatch: this.onMouseMove },
|
|
43626
|
+
touchstart: { beforeDispatch: this.onTouchStart },
|
|
43313
43627
|
});
|
|
43314
43628
|
var scrollContainer = this.editor.getScrollContainer();
|
|
43315
43629
|
scrollContainer.addEventListener('mouseout', this.onMouseOut);
|
|
@@ -43343,6 +43657,32 @@ var TableEditPlugin = /** @class */ (function () {
|
|
|
43343
43657
|
break;
|
|
43344
43658
|
}
|
|
43345
43659
|
};
|
|
43660
|
+
TableEditPlugin.prototype.updateTableEditor = function (x, y, event, updateHoveredFeature) {
|
|
43661
|
+
var _a, _b;
|
|
43662
|
+
this.ensureTableRects();
|
|
43663
|
+
var currentTable = null;
|
|
43664
|
+
//Find table in range of mouse
|
|
43665
|
+
if (this.tableRectMap) {
|
|
43666
|
+
for (var i = this.tableRectMap.length - 1; i >= 0; i--) {
|
|
43667
|
+
var entry = this.tableRectMap[i];
|
|
43668
|
+
var rect = entry.rect;
|
|
43669
|
+
if (x >= rect.left - TABLE_RESIZER_LENGTH &&
|
|
43670
|
+
x <= rect.right + TABLE_RESIZER_LENGTH &&
|
|
43671
|
+
y >= rect.top - TABLE_RESIZER_LENGTH &&
|
|
43672
|
+
y <= rect.bottom + TABLE_RESIZER_LENGTH) {
|
|
43673
|
+
currentTable = entry;
|
|
43674
|
+
break;
|
|
43675
|
+
}
|
|
43676
|
+
}
|
|
43677
|
+
}
|
|
43678
|
+
this.setTableEditor(currentTable, event);
|
|
43679
|
+
if (updateHoveredFeature) {
|
|
43680
|
+
(_a = this.tableEditor) === null || _a === void 0 ? void 0 : _a.onMouseMove(x, y);
|
|
43681
|
+
}
|
|
43682
|
+
else {
|
|
43683
|
+
(_b = this.tableEditor) === null || _b === void 0 ? void 0 : _b.onTouchStart(x, y);
|
|
43684
|
+
}
|
|
43685
|
+
};
|
|
43346
43686
|
/**
|
|
43347
43687
|
* @internal Public only for unit test
|
|
43348
43688
|
* @param entry Table to use when setting the Editors
|
|
@@ -43677,6 +44017,26 @@ var TableEditor = /** @class */ (function () {
|
|
|
43677
44017
|
// Create Mover and Resizer
|
|
43678
44018
|
this.setEditorFeatures();
|
|
43679
44019
|
};
|
|
44020
|
+
/**
|
|
44021
|
+
* Public only for testing purposes
|
|
44022
|
+
*/
|
|
44023
|
+
TableEditor.prototype.onTouchStart = function (x, y) {
|
|
44024
|
+
for (var rowIndex = 0; rowIndex < this.table.rows.length; rowIndex++) {
|
|
44025
|
+
var row = this.table.rows[rowIndex];
|
|
44026
|
+
for (var cellIndex = 0; cellIndex < row.cells.length; cellIndex++) {
|
|
44027
|
+
var td = row.cells[cellIndex];
|
|
44028
|
+
var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(td.getBoundingClientRect());
|
|
44029
|
+
if (rect &&
|
|
44030
|
+
x >= rect.left &&
|
|
44031
|
+
x <= rect.right &&
|
|
44032
|
+
y >= rect.top &&
|
|
44033
|
+
y <= rect.bottom) {
|
|
44034
|
+
!this.isFeatureDisabled('CellResizer') && this.setResizingTd(td);
|
|
44035
|
+
return;
|
|
44036
|
+
}
|
|
44037
|
+
}
|
|
44038
|
+
}
|
|
44039
|
+
};
|
|
43680
44040
|
TableEditor.prototype.setEditorFeatures = function () {
|
|
43681
44041
|
var disableSelector = this.isFeatureDisabled('TableSelector');
|
|
43682
44042
|
var disableMovement = this.isFeatureDisabled('TableMover');
|
|
@@ -43838,14 +44198,14 @@ function createCellResizer(editor, td, table, isRTL, isHorizontal, onStart, onEn
|
|
|
43838
44198
|
onDragging: isHorizontal ? onDraggingHorizontal : onDraggingVertical,
|
|
43839
44199
|
onDragEnd: onEnd,
|
|
43840
44200
|
};
|
|
43841
|
-
var featureHandler = new CellResizer(div, context, setPosition, handler, zoomScale, editor.getEnvironment().isMobileOrTablet, onTableEditorCreated);
|
|
44201
|
+
var featureHandler = new CellResizer(div, context, setPosition, handler, zoomScale, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported, onTableEditorCreated);
|
|
43842
44202
|
return { node: td, div: div, featureHandler: featureHandler };
|
|
43843
44203
|
}
|
|
43844
44204
|
exports.createCellResizer = createCellResizer;
|
|
43845
44205
|
var CellResizer = /** @class */ (function (_super) {
|
|
43846
44206
|
(0, tslib_1.__extends)(CellResizer, _super);
|
|
43847
|
-
function CellResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, onTableEditorCreated) {
|
|
43848
|
-
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
44207
|
+
function CellResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported, onTableEditorCreated) {
|
|
44208
|
+
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
43849
44209
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated('CellResizer', trigger);
|
|
43850
44210
|
return _this;
|
|
43851
44211
|
}
|
|
@@ -44274,14 +44634,14 @@ function createTableMover(table, editor, isRTL, onFinishDragging, onStart, onEnd
|
|
|
44274
44634
|
onDragStart: onDragStart,
|
|
44275
44635
|
onDragging: onDragging,
|
|
44276
44636
|
onDragEnd: onDragEnd,
|
|
44277
|
-
}, context.zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet);
|
|
44637
|
+
}, context.zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported);
|
|
44278
44638
|
return { node: table, div: div, featureHandler: featureHandler };
|
|
44279
44639
|
}
|
|
44280
44640
|
exports.createTableMover = createTableMover;
|
|
44281
44641
|
var TableMoverFeature = /** @class */ (function (_super) {
|
|
44282
44642
|
(0, tslib_1.__extends)(TableMoverFeature, _super);
|
|
44283
|
-
function TableMoverFeature(div, context, onSubmit, handler, zoomScale, onTableEditorCreated, forceMobile) {
|
|
44284
|
-
var _this = _super.call(this, div, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
44643
|
+
function TableMoverFeature(div, context, onSubmit, handler, zoomScale, onTableEditorCreated, forceMobile, isTouchSupported) {
|
|
44644
|
+
var _this = _super.call(this, div, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
44285
44645
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated('TableMover', div);
|
|
44286
44646
|
return _this;
|
|
44287
44647
|
}
|
|
@@ -44511,14 +44871,14 @@ function createTableResizer(table, editor, isRTL, onStart, onEnd, contentDiv, an
|
|
|
44511
44871
|
onDragStart: onDragStart,
|
|
44512
44872
|
onDragging: onDragging,
|
|
44513
44873
|
onDragEnd: onDragEnd,
|
|
44514
|
-
}, zoomScale, editor.getEnvironment().isMobileOrTablet, onTableEditorCreated);
|
|
44874
|
+
}, zoomScale, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported, onTableEditorCreated);
|
|
44515
44875
|
return { node: table, div: div, featureHandler: featureHandler };
|
|
44516
44876
|
}
|
|
44517
44877
|
exports.createTableResizer = createTableResizer;
|
|
44518
44878
|
var TableResizer = /** @class */ (function (_super) {
|
|
44519
44879
|
(0, tslib_1.__extends)(TableResizer, _super);
|
|
44520
|
-
function TableResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, onTableEditorCreated) {
|
|
44521
|
-
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
44880
|
+
function TableResizer(trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported, onTableEditorCreated) {
|
|
44881
|
+
var _this = _super.call(this, trigger, context, onSubmit, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
44522
44882
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated('TableResizer', trigger);
|
|
44523
44883
|
return _this;
|
|
44524
44884
|
}
|
|
@@ -44705,7 +45065,7 @@ function createTableRowColumnSelector(editor, table, isRowSelector, anchorContai
|
|
|
44705
45065
|
onDragStart: onDragStart,
|
|
44706
45066
|
onDragging: onDragging,
|
|
44707
45067
|
onDragEnd: onDragEnd,
|
|
44708
|
-
}, zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet);
|
|
45068
|
+
}, zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet, editor.getEnvironment().isTouchSupported);
|
|
44709
45069
|
handlers.push(handler);
|
|
44710
45070
|
}
|
|
44711
45071
|
});
|
|
@@ -44720,8 +45080,8 @@ function createTableRowColumnSelector(editor, table, isRowSelector, anchorContai
|
|
|
44720
45080
|
exports.createTableRowColumnSelector = createTableRowColumnSelector;
|
|
44721
45081
|
var TableRowColumnSelectorHandler = /** @class */ (function (_super) {
|
|
44722
45082
|
(0, tslib_1.__extends)(TableRowColumnSelectorHandler, _super);
|
|
44723
|
-
function TableRowColumnSelectorHandler(div, isRow, context, handler, zoomScale, onTableEditorCreated, forceMobile) {
|
|
44724
|
-
var _this = _super.call(this, div, context, function () { }, handler, zoomScale, forceMobile) || this;
|
|
45083
|
+
function TableRowColumnSelectorHandler(div, isRow, context, handler, zoomScale, onTableEditorCreated, forceMobile, isTouchSupported) {
|
|
45084
|
+
var _this = _super.call(this, div, context, function () { }, handler, zoomScale, forceMobile, isTouchSupported) || this;
|
|
44725
45085
|
_this.isRow = isRow;
|
|
44726
45086
|
_this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated(_this.isRow ? 'TableRowSelector' : 'TableColumnSelector', div);
|
|
44727
45087
|
return _this;
|