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