roosterjs 8.30.0 → 8.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rooster-amd-min.js +1 -1
- package/dist/rooster-amd-min.js.map +1 -1
- package/dist/rooster-amd.d.ts +77 -56
- package/dist/rooster-amd.js +908 -412
- package/dist/rooster-amd.js.map +1 -1
- package/dist/rooster-min.js +1 -1
- package/dist/rooster-min.js.map +1 -1
- package/dist/rooster.d.ts +77 -56
- package/dist/rooster.js +908 -412
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
- package/tsconfig.child.tsbuildinfo +1 -1
package/dist/rooster-amd.js
CHANGED
|
@@ -2175,36 +2175,6 @@ function getDarkColor(color) {
|
|
|
2175
2175
|
exports.default = getDarkColor;
|
|
2176
2176
|
|
|
2177
2177
|
|
|
2178
|
-
/***/ }),
|
|
2179
|
-
|
|
2180
|
-
/***/ "./packages/roosterjs-editor-api/lib/experiment/experimentCommitListChains.ts":
|
|
2181
|
-
/*!************************************************************************************!*\
|
|
2182
|
-
!*** ./packages/roosterjs-editor-api/lib/experiment/experimentCommitListChains.ts ***!
|
|
2183
|
-
\************************************************************************************/
|
|
2184
|
-
/*! no static exports found */
|
|
2185
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
2186
|
-
|
|
2187
|
-
"use strict";
|
|
2188
|
-
|
|
2189
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2190
|
-
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
2191
|
-
/**
|
|
2192
|
-
* Commit changes of all list changes when experiment features are allowed
|
|
2193
|
-
* @param editor The Editor object
|
|
2194
|
-
* @param chains List chains to commit
|
|
2195
|
-
*/
|
|
2196
|
-
function experimentCommitListChains(editor, chains) {
|
|
2197
|
-
if ((chains === null || chains === void 0 ? void 0 : chains.length) > 0) {
|
|
2198
|
-
var range = editor.getSelectionRange();
|
|
2199
|
-
var start = range && roosterjs_editor_dom_1.Position.getStart(range);
|
|
2200
|
-
var end = range && roosterjs_editor_dom_1.Position.getEnd(range);
|
|
2201
|
-
chains.forEach(function (chain) { return chain.commit(); });
|
|
2202
|
-
editor.select(start, end);
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2205
|
-
exports.default = experimentCommitListChains;
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
2178
|
/***/ }),
|
|
2209
2179
|
|
|
2210
2180
|
/***/ "./packages/roosterjs-editor-api/lib/format/changeCapitalization.ts":
|
|
@@ -3878,7 +3848,7 @@ exports.default = toggleUnderline;
|
|
|
3878
3848
|
"use strict";
|
|
3879
3849
|
|
|
3880
3850
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3881
|
-
exports.experimentCommitListChains = exports.blockFormat = exports.toggleListType = exports.applyCellShading = exports.toggleHeader = exports.toggleUnderline = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleCodeBlock = exports.toggleBlockQuote = exports.setOrderedListNumbering = exports.toggleNumbering = exports.toggleItalic = exports.toggleBullet = exports.toggleBold = exports.changeCapitalization = exports.setIndentation = exports.setImageAltText = exports.setFontSize = exports.setFontName = exports.setDirection = exports.setTextColor = exports.setBackgroundColor = exports.setAlignment = exports.rotateElement = exports.replaceWithNode = exports.removeLink = exports.formatTable = exports.editTable = exports.insertTable = exports.insertImage = exports.insertEntity = exports.getElementBasedFormatState = exports.getFormatState = exports.createLink = exports.clearFormat = exports.clearBlockFormat = exports.FONT_SIZES = exports.changeFontSize = void 0;
|
|
3851
|
+
exports.experimentCommitListChains = exports.commitListChains = exports.blockFormat = exports.toggleListType = exports.applyCellShading = exports.toggleHeader = exports.toggleUnderline = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleCodeBlock = exports.toggleBlockQuote = exports.setOrderedListNumbering = exports.toggleNumbering = exports.toggleItalic = exports.toggleBullet = exports.toggleBold = exports.changeCapitalization = exports.setIndentation = exports.setImageAltText = exports.setFontSize = exports.setFontName = exports.setDirection = exports.setTextColor = exports.setBackgroundColor = exports.setAlignment = exports.rotateElement = exports.replaceWithNode = exports.removeLink = exports.formatTable = exports.editTable = exports.insertTable = exports.insertImage = exports.insertEntity = exports.getElementBasedFormatState = exports.getFormatState = exports.createLink = exports.clearFormat = exports.clearBlockFormat = exports.FONT_SIZES = exports.changeFontSize = void 0;
|
|
3882
3852
|
var changeFontSize_1 = __webpack_require__(/*! ./format/changeFontSize */ "./packages/roosterjs-editor-api/lib/format/changeFontSize.ts");
|
|
3883
3853
|
Object.defineProperty(exports, "changeFontSize", { enumerable: true, get: function () { return changeFontSize_1.default; } });
|
|
3884
3854
|
Object.defineProperty(exports, "FONT_SIZES", { enumerable: true, get: function () { return changeFontSize_1.FONT_SIZES; } });
|
|
@@ -3955,8 +3925,9 @@ var toggleListType_1 = __webpack_require__(/*! ./utils/toggleListType */ "./pack
|
|
|
3955
3925
|
Object.defineProperty(exports, "toggleListType", { enumerable: true, get: function () { return toggleListType_1.default; } });
|
|
3956
3926
|
var blockFormat_1 = __webpack_require__(/*! ./utils/blockFormat */ "./packages/roosterjs-editor-api/lib/utils/blockFormat.ts");
|
|
3957
3927
|
Object.defineProperty(exports, "blockFormat", { enumerable: true, get: function () { return blockFormat_1.default; } });
|
|
3958
|
-
var
|
|
3959
|
-
Object.defineProperty(exports, "
|
|
3928
|
+
var commitListChains_1 = __webpack_require__(/*! ./utils/commitListChains */ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts");
|
|
3929
|
+
Object.defineProperty(exports, "commitListChains", { enumerable: true, get: function () { return commitListChains_1.default; } });
|
|
3930
|
+
Object.defineProperty(exports, "experimentCommitListChains", { enumerable: true, get: function () { return commitListChains_1.experimentCommitListChains; } });
|
|
3960
3931
|
|
|
3961
3932
|
|
|
3962
3933
|
/***/ }),
|
|
@@ -4319,7 +4290,7 @@ function applyStyleToListItems(parentNodes, styles) {
|
|
|
4319
4290
|
"use strict";
|
|
4320
4291
|
|
|
4321
4292
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4322
|
-
var
|
|
4293
|
+
var commitListChains_1 = __webpack_require__(/*! ../utils/commitListChains */ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts");
|
|
4323
4294
|
var formatUndoSnapshot_1 = __webpack_require__(/*! ./formatUndoSnapshot */ "./packages/roosterjs-editor-api/lib/utils/formatUndoSnapshot.ts");
|
|
4324
4295
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
4325
4296
|
/**
|
|
@@ -4333,7 +4304,7 @@ function blockFormat(editor, callback, beforeRunCallback, apiName) {
|
|
|
4333
4304
|
var regions = editor.getSelectedRegions();
|
|
4334
4305
|
var chains_1 = roosterjs_editor_dom_1.VListChain.createListChains(regions, start === null || start === void 0 ? void 0 : start.node);
|
|
4335
4306
|
regions.forEach(function (region) { return callback(region, start, end, chains_1); });
|
|
4336
|
-
(0,
|
|
4307
|
+
(0, commitListChains_1.default)(editor, chains_1);
|
|
4337
4308
|
}
|
|
4338
4309
|
if (selection.type == 0 /* Normal */) {
|
|
4339
4310
|
editor.select(start, end);
|
|
@@ -4438,6 +4409,42 @@ function isEmptyBlockUnderTR(block) {
|
|
|
4438
4409
|
}
|
|
4439
4410
|
|
|
4440
4411
|
|
|
4412
|
+
/***/ }),
|
|
4413
|
+
|
|
4414
|
+
/***/ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts":
|
|
4415
|
+
/*!*********************************************************************!*\
|
|
4416
|
+
!*** ./packages/roosterjs-editor-api/lib/utils/commitListChains.ts ***!
|
|
4417
|
+
\*********************************************************************/
|
|
4418
|
+
/*! no static exports found */
|
|
4419
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
4420
|
+
|
|
4421
|
+
"use strict";
|
|
4422
|
+
|
|
4423
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4424
|
+
exports.experimentCommitListChains = void 0;
|
|
4425
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
4426
|
+
/**
|
|
4427
|
+
* Commit changes of all list changes when experiment features are allowed
|
|
4428
|
+
* @param editor The Editor object
|
|
4429
|
+
* @param chains List chains to commit
|
|
4430
|
+
*/
|
|
4431
|
+
function commitListChains(editor, chains) {
|
|
4432
|
+
if ((chains === null || chains === void 0 ? void 0 : chains.length) > 0) {
|
|
4433
|
+
var range = editor.getSelectionRange();
|
|
4434
|
+
var start = range && roosterjs_editor_dom_1.Position.getStart(range);
|
|
4435
|
+
var end = range && roosterjs_editor_dom_1.Position.getEnd(range);
|
|
4436
|
+
chains.forEach(function (chain) { return chain.commit(); });
|
|
4437
|
+
editor.select(start, end);
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
exports.default = commitListChains;
|
|
4441
|
+
/**
|
|
4442
|
+
* @deprecated
|
|
4443
|
+
* Same with commitListChains, keep this export just for backward compatibility
|
|
4444
|
+
*/
|
|
4445
|
+
exports.experimentCommitListChains = commitListChains;
|
|
4446
|
+
|
|
4447
|
+
|
|
4441
4448
|
/***/ }),
|
|
4442
4449
|
|
|
4443
4450
|
/***/ "./packages/roosterjs-editor-api/lib/utils/execCommand.ts":
|
|
@@ -4901,7 +4908,7 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4901
4908
|
.replace(/\r/g, '')
|
|
4902
4909
|
.replace(/ {2}/g, ' ' + NBSP_HTML);
|
|
4903
4910
|
if (line.includes('\t')) {
|
|
4904
|
-
line = transformTabCharacters(line, index === 0 ? position.offset : 0);
|
|
4911
|
+
line = transformTabCharacters(line, index === 0 ? position === null || position === void 0 ? void 0 : position.offset : 0);
|
|
4905
4912
|
}
|
|
4906
4913
|
var textNode = document.createTextNode(line);
|
|
4907
4914
|
// There are 3 scenarios:
|
|
@@ -4928,7 +4935,7 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4928
4935
|
// Step 5. Sanitize the fragment before paste to make sure the content is safe
|
|
4929
4936
|
var sanitizer = new roosterjs_editor_dom_1.HtmlSanitizer(event.sanitizingOption);
|
|
4930
4937
|
sanitizer.convertGlobalCssToInlineCss(fragment);
|
|
4931
|
-
sanitizer.sanitize(fragment, position
|
|
4938
|
+
sanitizer.sanitize(fragment, position ? (0, roosterjs_editor_dom_1.getInheritableStyles)(position.element) : undefined);
|
|
4932
4939
|
return fragment;
|
|
4933
4940
|
};
|
|
4934
4941
|
exports.createPasteFragment = createPasteFragment;
|
|
@@ -5225,6 +5232,12 @@ var PendableStyleCheckers = {
|
|
|
5225
5232
|
isBold: function (tag, style) {
|
|
5226
5233
|
return tag == 'B' ||
|
|
5227
5234
|
tag == 'STRONG' ||
|
|
5235
|
+
tag == 'H1' ||
|
|
5236
|
+
tag == 'H2' ||
|
|
5237
|
+
tag == 'H3' ||
|
|
5238
|
+
tag == 'H4' ||
|
|
5239
|
+
tag == 'H5' ||
|
|
5240
|
+
tag == 'H6' ||
|
|
5228
5241
|
parseInt(style.fontWeight) >= 700 ||
|
|
5229
5242
|
['bold', 'bolder'].indexOf(style.fontWeight) >= 0;
|
|
5230
5243
|
},
|
|
@@ -5555,6 +5568,9 @@ var insertNode = function (core, node, option) {
|
|
|
5555
5568
|
}
|
|
5556
5569
|
core.api.transformColor(core, node, true /*includeSelf*/, function () {
|
|
5557
5570
|
var _a, _b;
|
|
5571
|
+
if (!option) {
|
|
5572
|
+
return;
|
|
5573
|
+
}
|
|
5558
5574
|
switch (option.position) {
|
|
5559
5575
|
case 0 /* Begin */:
|
|
5560
5576
|
case 1 /* End */: {
|
|
@@ -6152,7 +6168,9 @@ var ColorAttributeName = [
|
|
|
6152
6168
|
* Pass true to this value to force do color transformation even editor core is in light mode
|
|
6153
6169
|
*/
|
|
6154
6170
|
var transformColor = function (core, rootNode, includeSelf, callback, direction, forceTransform) {
|
|
6155
|
-
var elements = forceTransform || core.lifecycle.isDarkMode
|
|
6171
|
+
var elements = rootNode && (forceTransform || core.lifecycle.isDarkMode)
|
|
6172
|
+
? getAll(rootNode, includeSelf)
|
|
6173
|
+
: [];
|
|
6156
6174
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
6157
6175
|
if (direction == 1 /* DarkToLight */) {
|
|
6158
6176
|
transformToLightMode(elements);
|
|
@@ -6307,6 +6325,8 @@ function handledExclusively(event, plugin) {
|
|
|
6307
6325
|
"use strict";
|
|
6308
6326
|
|
|
6309
6327
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6328
|
+
var forEachSelectedCell_1 = __webpack_require__(/*! ./utils/forEachSelectedCell */ "./packages/roosterjs-editor-core/lib/corePlugins/utils/forEachSelectedCell.ts");
|
|
6329
|
+
var removeCellsOutsideSelection_1 = __webpack_require__(/*! ./utils/removeCellsOutsideSelection */ "./packages/roosterjs-editor-core/lib/corePlugins/utils/removeCellsOutsideSelection.ts");
|
|
6310
6330
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
6311
6331
|
/**
|
|
6312
6332
|
* @internal
|
|
@@ -6319,20 +6339,22 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6319
6339
|
*/
|
|
6320
6340
|
function CopyPastePlugin(options) {
|
|
6321
6341
|
var _this = this;
|
|
6342
|
+
this.editor = null;
|
|
6343
|
+
this.disposer = null;
|
|
6322
6344
|
this.onPaste = function (event) {
|
|
6323
|
-
var _a;
|
|
6324
6345
|
var range;
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6346
|
+
if (_this.editor) {
|
|
6347
|
+
(0, roosterjs_editor_dom_1.extractClipboardEvent)(event, function (clipboardData) { return _this.editor.paste(clipboardData); }, {
|
|
6348
|
+
allowedCustomPasteType: _this.state.allowedCustomPasteType,
|
|
6349
|
+
getTempDiv: function () {
|
|
6350
|
+
range = _this.editor.getSelectionRange();
|
|
6351
|
+
return _this.getTempDiv(_this.editor);
|
|
6352
|
+
},
|
|
6353
|
+
removeTempDiv: function (div) {
|
|
6354
|
+
_this.cleanUpAndRestoreSelection(div, range, false /* isCopy */);
|
|
6355
|
+
},
|
|
6356
|
+
}, _this.editor.getSelectionRange());
|
|
6357
|
+
}
|
|
6336
6358
|
};
|
|
6337
6359
|
this.state = {
|
|
6338
6360
|
allowedCustomPasteType: options.allowedCustomPasteType || [],
|
|
@@ -6352,7 +6374,7 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6352
6374
|
var _this = this;
|
|
6353
6375
|
this.editor = editor;
|
|
6354
6376
|
this.disposer = this.editor.addDomEventHandler({
|
|
6355
|
-
paste:
|
|
6377
|
+
paste: function (e) { return _this.onPaste(e); },
|
|
6356
6378
|
copy: function (e) { return _this.onCutCopy(e, false /*isCut*/); },
|
|
6357
6379
|
cut: function (e) { return _this.onCutCopy(e, true /*isCut*/); },
|
|
6358
6380
|
});
|
|
@@ -6361,7 +6383,9 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6361
6383
|
* Dispose this plugin
|
|
6362
6384
|
*/
|
|
6363
6385
|
CopyPastePlugin.prototype.dispose = function () {
|
|
6364
|
-
this.disposer
|
|
6386
|
+
if (this.disposer) {
|
|
6387
|
+
this.disposer();
|
|
6388
|
+
}
|
|
6365
6389
|
this.disposer = null;
|
|
6366
6390
|
this.editor = null;
|
|
6367
6391
|
};
|
|
@@ -6373,40 +6397,55 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6373
6397
|
};
|
|
6374
6398
|
CopyPastePlugin.prototype.onCutCopy = function (event, isCut) {
|
|
6375
6399
|
var _this = this;
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
if (newRange) {
|
|
6391
|
-
(0, roosterjs_editor_dom_1.addRangeToSelection)(newRange);
|
|
6392
|
-
}
|
|
6393
|
-
this.editor.runAsync(function (editor) {
|
|
6394
|
-
_this.cleanUpAndRestoreSelection(tempDiv_1, selection, !isCut /* isCopy */);
|
|
6395
|
-
if (isCut) {
|
|
6396
|
-
editor.addUndoSnapshot(function () {
|
|
6397
|
-
var position = _this.editor.deleteSelectedContent();
|
|
6398
|
-
editor.focus();
|
|
6399
|
-
editor.select(position);
|
|
6400
|
-
}, "Cut" /* Cut */);
|
|
6400
|
+
if (this.editor) {
|
|
6401
|
+
var selection_1 = this.editor.getSelectionRangeEx();
|
|
6402
|
+
if (selection_1 && !selection_1.areAllCollapsed) {
|
|
6403
|
+
var html = this.editor.getContent(2 /* RawHTMLWithSelection */);
|
|
6404
|
+
var tempDiv_1 = this.getTempDiv(this.editor, true /*forceInLightMode*/);
|
|
6405
|
+
var metadata = (0, roosterjs_editor_dom_1.setHtmlWithMetadata)(tempDiv_1, html, this.editor.getTrustedHTMLHandler());
|
|
6406
|
+
var newRange = void 0;
|
|
6407
|
+
if (selection_1.type === 1 /* TableSelection */ &&
|
|
6408
|
+
selection_1.coordinates) {
|
|
6409
|
+
var table = tempDiv_1.querySelector("#" + selection_1.table.id);
|
|
6410
|
+
newRange = this.createTableRange(table, selection_1.coordinates);
|
|
6411
|
+
if (isCut) {
|
|
6412
|
+
this.deleteTableContent(this.editor, selection_1.table, selection_1.coordinates);
|
|
6413
|
+
}
|
|
6401
6414
|
}
|
|
6402
|
-
|
|
6415
|
+
else {
|
|
6416
|
+
newRange =
|
|
6417
|
+
(metadata === null || metadata === void 0 ? void 0 : metadata.type) === 0 /* Normal */
|
|
6418
|
+
? (0, roosterjs_editor_dom_1.createRange)(tempDiv_1, metadata.start, metadata.end)
|
|
6419
|
+
: null;
|
|
6420
|
+
}
|
|
6421
|
+
if (newRange) {
|
|
6422
|
+
var cutCopyEvent = this.editor.triggerPluginEvent(9 /* BeforeCutCopy */, {
|
|
6423
|
+
clonedRoot: tempDiv_1,
|
|
6424
|
+
range: newRange,
|
|
6425
|
+
rawEvent: event,
|
|
6426
|
+
isCut: isCut,
|
|
6427
|
+
});
|
|
6428
|
+
if (cutCopyEvent.range) {
|
|
6429
|
+
(0, roosterjs_editor_dom_1.addRangeToSelection)(newRange);
|
|
6430
|
+
}
|
|
6431
|
+
this.editor.runAsync(function (editor) {
|
|
6432
|
+
_this.cleanUpAndRestoreSelection(tempDiv_1, selection_1, !isCut /* isCopy */);
|
|
6433
|
+
if (isCut) {
|
|
6434
|
+
editor.addUndoSnapshot(function () {
|
|
6435
|
+
var position = _this.editor.deleteSelectedContent();
|
|
6436
|
+
editor.focus();
|
|
6437
|
+
editor.select(position);
|
|
6438
|
+
}, "Cut" /* Cut */);
|
|
6439
|
+
}
|
|
6440
|
+
});
|
|
6441
|
+
}
|
|
6442
|
+
}
|
|
6403
6443
|
}
|
|
6404
6444
|
};
|
|
6405
|
-
CopyPastePlugin.prototype.getTempDiv = function (forceInLightMode) {
|
|
6406
|
-
var
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
_this.editor.insertNode(tempDiv, {
|
|
6445
|
+
CopyPastePlugin.prototype.getTempDiv = function (editor, forceInLightMode) {
|
|
6446
|
+
var div = editor.getCustomData('CopyPasteTempDiv', function () {
|
|
6447
|
+
var tempDiv = (0, roosterjs_editor_dom_1.createElement)(3 /* CopyPasteTempDiv */, editor.getDocument());
|
|
6448
|
+
editor.insertNode(tempDiv, {
|
|
6410
6449
|
position: 4 /* Outside */,
|
|
6411
6450
|
});
|
|
6412
6451
|
return tempDiv;
|
|
@@ -6425,7 +6464,9 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6425
6464
|
var selection = range;
|
|
6426
6465
|
switch (selection.type) {
|
|
6427
6466
|
case 1 /* TableSelection */:
|
|
6428
|
-
this.editor
|
|
6467
|
+
if (this.editor && selection.table && selection.coordinates) {
|
|
6468
|
+
this.editor.select(selection.table, selection.coordinates);
|
|
6469
|
+
}
|
|
6429
6470
|
break;
|
|
6430
6471
|
case 0 /* Normal */:
|
|
6431
6472
|
var range_1 = (_b = selection.ranges) === null || _b === void 0 ? void 0 : _b[0];
|
|
@@ -6442,13 +6483,43 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6442
6483
|
(0, roosterjs_editor_dom_1.moveChildNodes)(tempDiv);
|
|
6443
6484
|
};
|
|
6444
6485
|
CopyPastePlugin.prototype.restoreRange = function (range, isCopy) {
|
|
6445
|
-
if (range) {
|
|
6486
|
+
if (range && this.editor) {
|
|
6446
6487
|
if (isCopy && roosterjs_editor_dom_1.Browser.isAndroid) {
|
|
6447
6488
|
range.collapse();
|
|
6448
6489
|
}
|
|
6449
6490
|
this.editor.select(range);
|
|
6450
6491
|
}
|
|
6451
6492
|
};
|
|
6493
|
+
CopyPastePlugin.prototype.createTableRange = function (table, selection) {
|
|
6494
|
+
var clonedVTable = new roosterjs_editor_dom_1.VTable(table);
|
|
6495
|
+
clonedVTable.selection = selection;
|
|
6496
|
+
(0, removeCellsOutsideSelection_1.removeCellsOutsideSelection)(clonedVTable);
|
|
6497
|
+
clonedVTable.writeBack();
|
|
6498
|
+
return (0, roosterjs_editor_dom_1.createRange)(clonedVTable.table);
|
|
6499
|
+
};
|
|
6500
|
+
CopyPastePlugin.prototype.deleteTableContent = function (editor, table, selection) {
|
|
6501
|
+
var selectedVTable = new roosterjs_editor_dom_1.VTable(table);
|
|
6502
|
+
selectedVTable.selection = selection;
|
|
6503
|
+
(0, forEachSelectedCell_1.forEachSelectedCell)(selectedVTable, function (cell) {
|
|
6504
|
+
if (cell === null || cell === void 0 ? void 0 : cell.td) {
|
|
6505
|
+
cell.td.innerHTML = editor.getTrustedHTMLHandler()('<br>');
|
|
6506
|
+
}
|
|
6507
|
+
});
|
|
6508
|
+
var wholeTableSelected = (0, roosterjs_editor_dom_1.isWholeTableSelected)(selectedVTable, selection);
|
|
6509
|
+
var isWholeColumnSelected = table.rows.length - 1 === selection.lastCell.y && selection.firstCell.y === 0;
|
|
6510
|
+
if (wholeTableSelected) {
|
|
6511
|
+
selectedVTable.edit(4 /* DeleteTable */);
|
|
6512
|
+
selectedVTable.writeBack();
|
|
6513
|
+
}
|
|
6514
|
+
else if (isWholeColumnSelected) {
|
|
6515
|
+
selectedVTable.edit(5 /* DeleteColumn */);
|
|
6516
|
+
selectedVTable.writeBack();
|
|
6517
|
+
}
|
|
6518
|
+
if (wholeTableSelected || isWholeColumnSelected) {
|
|
6519
|
+
table.style.removeProperty('width');
|
|
6520
|
+
table.style.removeProperty('height');
|
|
6521
|
+
}
|
|
6522
|
+
};
|
|
6452
6523
|
return CopyPastePlugin;
|
|
6453
6524
|
}());
|
|
6454
6525
|
exports.default = CopyPastePlugin;
|
|
@@ -7454,6 +7525,7 @@ var NormalizeTablePlugin = /** @class */ (function () {
|
|
|
7454
7525
|
case 11 /* EditorReady */:
|
|
7455
7526
|
case 7 /* ContentChanged */:
|
|
7456
7527
|
this.normalizeTables(this.editor.queryElements('table'));
|
|
7528
|
+
this.normalizeBlockquotes(this.editor.queryElements('blockquote'));
|
|
7457
7529
|
break;
|
|
7458
7530
|
case 10 /* BeforePaste */:
|
|
7459
7531
|
this.normalizeTables((0, roosterjs_editor_dom_1.toArray)(event.fragment.querySelectorAll('table')));
|
|
@@ -7494,9 +7566,31 @@ var NormalizeTablePlugin = /** @class */ (function () {
|
|
|
7494
7566
|
}
|
|
7495
7567
|
}
|
|
7496
7568
|
};
|
|
7569
|
+
NormalizeTablePlugin.prototype.normalizeBlockquotes = function (elements) {
|
|
7570
|
+
elements.forEach(function (quote) {
|
|
7571
|
+
var centeredElement = quote.querySelector('[style^="text-align: center"]');
|
|
7572
|
+
if (centeredElement) {
|
|
7573
|
+
if (isRTL(centeredElement)) {
|
|
7574
|
+
delete quote.style.marginInlineEnd;
|
|
7575
|
+
quote.style.marginInlineStart = 'auto';
|
|
7576
|
+
}
|
|
7577
|
+
else {
|
|
7578
|
+
delete quote.style.marginInlineStart;
|
|
7579
|
+
quote.style.marginInlineEnd = 'auto';
|
|
7580
|
+
}
|
|
7581
|
+
}
|
|
7582
|
+
else {
|
|
7583
|
+
delete quote.style.marginInlineStart;
|
|
7584
|
+
delete quote.style.marginInlineEnd;
|
|
7585
|
+
}
|
|
7586
|
+
});
|
|
7587
|
+
};
|
|
7497
7588
|
return NormalizeTablePlugin;
|
|
7498
7589
|
}());
|
|
7499
7590
|
exports.default = NormalizeTablePlugin;
|
|
7591
|
+
function isRTL(el) {
|
|
7592
|
+
return (0, roosterjs_editor_dom_1.getComputedStyle)(el, 'direction') == 'rtl' || el.getAttribute('dir') == 'rtl';
|
|
7593
|
+
}
|
|
7500
7594
|
function normalizeTables(tables) {
|
|
7501
7595
|
var isDOMChanged = false;
|
|
7502
7596
|
tables.forEach(function (table) {
|
|
@@ -8053,6 +8147,87 @@ function getPluginState(corePlugins) {
|
|
|
8053
8147
|
exports.getPluginState = getPluginState;
|
|
8054
8148
|
|
|
8055
8149
|
|
|
8150
|
+
/***/ }),
|
|
8151
|
+
|
|
8152
|
+
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/utils/forEachSelectedCell.ts":
|
|
8153
|
+
/*!*************************************************************************************!*\
|
|
8154
|
+
!*** ./packages/roosterjs-editor-core/lib/corePlugins/utils/forEachSelectedCell.ts ***!
|
|
8155
|
+
\*************************************************************************************/
|
|
8156
|
+
/*! no static exports found */
|
|
8157
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
8158
|
+
|
|
8159
|
+
"use strict";
|
|
8160
|
+
|
|
8161
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8162
|
+
exports.forEachSelectedCell = void 0;
|
|
8163
|
+
/**
|
|
8164
|
+
* @internal
|
|
8165
|
+
* Executes an action to all the cells within the selection range.
|
|
8166
|
+
* @param callback action to apply on each selected cell
|
|
8167
|
+
* @returns the amount of cells modified
|
|
8168
|
+
*/
|
|
8169
|
+
var forEachSelectedCell = function (vTable, callback) {
|
|
8170
|
+
var _a;
|
|
8171
|
+
if (vTable.selection) {
|
|
8172
|
+
var _b = vTable.selection, lastCell = _b.lastCell, firstCell = _b.firstCell;
|
|
8173
|
+
for (var y = firstCell.y; y <= lastCell.y; y++) {
|
|
8174
|
+
for (var x = firstCell.x; x <= lastCell.x; x++) {
|
|
8175
|
+
if (vTable.cells && ((_a = vTable.cells[y][x]) === null || _a === void 0 ? void 0 : _a.td)) {
|
|
8176
|
+
callback(vTable.cells[y][x]);
|
|
8177
|
+
}
|
|
8178
|
+
}
|
|
8179
|
+
}
|
|
8180
|
+
}
|
|
8181
|
+
};
|
|
8182
|
+
exports.forEachSelectedCell = forEachSelectedCell;
|
|
8183
|
+
|
|
8184
|
+
|
|
8185
|
+
/***/ }),
|
|
8186
|
+
|
|
8187
|
+
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/utils/removeCellsOutsideSelection.ts":
|
|
8188
|
+
/*!*********************************************************************************************!*\
|
|
8189
|
+
!*** ./packages/roosterjs-editor-core/lib/corePlugins/utils/removeCellsOutsideSelection.ts ***!
|
|
8190
|
+
\*********************************************************************************************/
|
|
8191
|
+
/*! no static exports found */
|
|
8192
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
8193
|
+
|
|
8194
|
+
"use strict";
|
|
8195
|
+
|
|
8196
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8197
|
+
exports.removeCellsOutsideSelection = void 0;
|
|
8198
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
8199
|
+
/**
|
|
8200
|
+
* @internal
|
|
8201
|
+
* Remove the cells outside of the selection.
|
|
8202
|
+
* @param vTable VTable to remove selection
|
|
8203
|
+
*/
|
|
8204
|
+
var removeCellsOutsideSelection = function (vTable) {
|
|
8205
|
+
if (vTable.selection) {
|
|
8206
|
+
if ((0, roosterjs_editor_dom_1.isWholeTableSelected)(vTable, vTable.selection)) {
|
|
8207
|
+
return;
|
|
8208
|
+
}
|
|
8209
|
+
vTable.table.style.removeProperty('width');
|
|
8210
|
+
vTable.table.style.removeProperty('height');
|
|
8211
|
+
var _a = vTable.selection, firstCell = _a.firstCell, lastCell = _a.lastCell;
|
|
8212
|
+
var resultCells_1 = [];
|
|
8213
|
+
var firstX_1 = firstCell.x;
|
|
8214
|
+
var firstY_1 = firstCell.y;
|
|
8215
|
+
var lastX_1 = lastCell.x;
|
|
8216
|
+
var lastY_1 = lastCell.y;
|
|
8217
|
+
if (vTable.cells) {
|
|
8218
|
+
vTable.cells.forEach(function (row, y) {
|
|
8219
|
+
row = row.filter(function (_, x) { return y >= firstY_1 && y <= lastY_1 && x >= firstX_1 && x <= lastX_1; });
|
|
8220
|
+
if (row.length > 0) {
|
|
8221
|
+
resultCells_1.push(row);
|
|
8222
|
+
}
|
|
8223
|
+
});
|
|
8224
|
+
vTable.cells = resultCells_1;
|
|
8225
|
+
}
|
|
8226
|
+
}
|
|
8227
|
+
};
|
|
8228
|
+
exports.removeCellsOutsideSelection = removeCellsOutsideSelection;
|
|
8229
|
+
|
|
8230
|
+
|
|
8056
8231
|
/***/ }),
|
|
8057
8232
|
|
|
8058
8233
|
/***/ "./packages/roosterjs-editor-core/lib/editor/Editor.ts":
|
|
@@ -8092,6 +8267,8 @@ var Editor = /** @class */ (function () {
|
|
|
8092
8267
|
function Editor(contentDiv, options) {
|
|
8093
8268
|
var _this = this;
|
|
8094
8269
|
if (options === void 0) { options = {}; }
|
|
8270
|
+
var _a;
|
|
8271
|
+
this.core = null;
|
|
8095
8272
|
// 1. Make sure all parameters are valid
|
|
8096
8273
|
if ((0, roosterjs_editor_dom_1.getTagOfNode)(contentDiv) != 'DIV') {
|
|
8097
8274
|
throw new Error('contentDiv must be an HTML DIV element');
|
|
@@ -8101,13 +8278,15 @@ var Editor = /** @class */ (function () {
|
|
|
8101
8278
|
var plugins = [];
|
|
8102
8279
|
(0, roosterjs_editor_dom_1.getObjectKeys)(corePlugins).forEach(function (name) {
|
|
8103
8280
|
if (name == '_placeholder') {
|
|
8104
|
-
|
|
8281
|
+
if (options.plugins) {
|
|
8282
|
+
(0, roosterjs_editor_dom_1.arrayPush)(plugins, options.plugins);
|
|
8283
|
+
}
|
|
8105
8284
|
}
|
|
8106
8285
|
else {
|
|
8107
8286
|
plugins.push(corePlugins[name]);
|
|
8108
8287
|
}
|
|
8109
8288
|
});
|
|
8110
|
-
var zoomScale = options.zoomScale > 0 ? options.zoomScale : 1;
|
|
8289
|
+
var zoomScale = ((_a = options.zoomScale) !== null && _a !== void 0 ? _a : -1) > 0 ? options.zoomScale : 1;
|
|
8111
8290
|
this.core = __assign(__assign({ contentDiv: contentDiv, api: __assign(__assign({}, coreApiMap_1.coreApiMap), (options.coreApiOverride || {})), originalApi: coreApiMap_1.coreApiMap, plugins: plugins.filter(function (x) { return !!x; }) }, (0, createCorePlugins_1.getPluginState)(corePlugins)), { trustedHTMLHandler: options.trustedHTMLHandler || (function (html) { return html; }), zoomScale: zoomScale, sizeTransformer: options.sizeTransformer || (function (size) { return size / zoomScale; }) });
|
|
8112
8291
|
// 3. Initialize plugins
|
|
8113
8292
|
this.core.plugins.forEach(function (plugin) { return plugin.initialize(_this); });
|
|
@@ -8118,8 +8297,9 @@ var Editor = /** @class */ (function () {
|
|
|
8118
8297
|
* Dispose this editor, dispose all plugins and custom data
|
|
8119
8298
|
*/
|
|
8120
8299
|
Editor.prototype.dispose = function () {
|
|
8121
|
-
|
|
8122
|
-
|
|
8300
|
+
var core = this.getCore();
|
|
8301
|
+
for (var i = core.plugins.length - 1; i >= 0; i--) {
|
|
8302
|
+
core.plugins[i].dispose();
|
|
8123
8303
|
}
|
|
8124
8304
|
this.core = null;
|
|
8125
8305
|
};
|
|
@@ -8143,7 +8323,8 @@ var Editor = /** @class */ (function () {
|
|
|
8143
8323
|
* @returns true if node is inserted. Otherwise false
|
|
8144
8324
|
*/
|
|
8145
8325
|
Editor.prototype.insertNode = function (node, option) {
|
|
8146
|
-
|
|
8326
|
+
var core = this.getCore();
|
|
8327
|
+
return node ? core.api.insertNode(core, node, option !== null && option !== void 0 ? option : null) : false;
|
|
8147
8328
|
};
|
|
8148
8329
|
/**
|
|
8149
8330
|
* Delete a node from editor content
|
|
@@ -8152,7 +8333,7 @@ var Editor = /** @class */ (function () {
|
|
|
8152
8333
|
*/
|
|
8153
8334
|
Editor.prototype.deleteNode = function (node) {
|
|
8154
8335
|
// Only remove the node when it falls within editor
|
|
8155
|
-
if (node && this.contains(node)) {
|
|
8336
|
+
if (node && this.contains(node) && node.parentNode) {
|
|
8156
8337
|
node.parentNode.removeChild(node);
|
|
8157
8338
|
return true;
|
|
8158
8339
|
}
|
|
@@ -8166,9 +8347,10 @@ var Editor = /** @class */ (function () {
|
|
|
8166
8347
|
* @returns true if node is replaced. Otherwise false
|
|
8167
8348
|
*/
|
|
8168
8349
|
Editor.prototype.replaceNode = function (existingNode, toNode, transformColorForDarkMode) {
|
|
8350
|
+
var core = this.getCore();
|
|
8169
8351
|
// Only replace the node when it falls within editor
|
|
8170
8352
|
if (this.contains(existingNode) && toNode) {
|
|
8171
|
-
|
|
8353
|
+
core.api.transformColor(core, transformColorForDarkMode ? toNode : null, true /*includeSelf*/, function () { var _a; return (_a = existingNode.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(toNode, existingNode); }, 0 /* LightToDark */);
|
|
8172
8354
|
return true;
|
|
8173
8355
|
}
|
|
8174
8356
|
return false;
|
|
@@ -8179,25 +8361,25 @@ var Editor = /** @class */ (function () {
|
|
|
8179
8361
|
* @returns The BlockElement result
|
|
8180
8362
|
*/
|
|
8181
8363
|
Editor.prototype.getBlockElementAtNode = function (node) {
|
|
8182
|
-
return (0, roosterjs_editor_dom_1.getBlockElementAtNode)(this.
|
|
8364
|
+
return (0, roosterjs_editor_dom_1.getBlockElementAtNode)(this.getCore().contentDiv, node);
|
|
8183
8365
|
};
|
|
8184
8366
|
Editor.prototype.contains = function (arg) {
|
|
8185
|
-
return (0, roosterjs_editor_dom_1.contains)(this.
|
|
8367
|
+
return (0, roosterjs_editor_dom_1.contains)(this.getCore().contentDiv, arg);
|
|
8186
8368
|
};
|
|
8187
8369
|
Editor.prototype.queryElements = function (selector, scopeOrCallback, callback) {
|
|
8188
|
-
var _this = this;
|
|
8189
8370
|
if (scopeOrCallback === void 0) { scopeOrCallback = 0 /* Body */; }
|
|
8371
|
+
var core = this.getCore();
|
|
8190
8372
|
var result = [];
|
|
8191
8373
|
var scope = scopeOrCallback instanceof Function ? 0 /* Body */ : scopeOrCallback;
|
|
8192
8374
|
callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;
|
|
8193
8375
|
var selectionEx = scope == 0 /* Body */ ? null : this.getSelectionRangeEx();
|
|
8194
8376
|
if (selectionEx) {
|
|
8195
8377
|
selectionEx.ranges.forEach(function (range) {
|
|
8196
|
-
result.push.apply(result, (0, roosterjs_editor_dom_1.queryElements)(
|
|
8378
|
+
result.push.apply(result, (0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, range));
|
|
8197
8379
|
});
|
|
8198
8380
|
}
|
|
8199
8381
|
else {
|
|
8200
|
-
return (0, roosterjs_editor_dom_1.queryElements)(
|
|
8382
|
+
return (0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, undefined /* range */);
|
|
8201
8383
|
}
|
|
8202
8384
|
return result;
|
|
8203
8385
|
};
|
|
@@ -8213,7 +8395,7 @@ var Editor = /** @class */ (function () {
|
|
|
8213
8395
|
* otherwise just return start and end
|
|
8214
8396
|
*/
|
|
8215
8397
|
Editor.prototype.collapseNodes = function (start, end, canSplitParent) {
|
|
8216
|
-
return (0, roosterjs_editor_dom_1.collapseNodes)(this.
|
|
8398
|
+
return (0, roosterjs_editor_dom_1.collapseNodes)(this.getCore().contentDiv, start, end, canSplitParent);
|
|
8217
8399
|
};
|
|
8218
8400
|
//#endregion
|
|
8219
8401
|
//#region Content API
|
|
@@ -8223,7 +8405,7 @@ var Editor = /** @class */ (function () {
|
|
|
8223
8405
|
* @returns True if there's no visible content, otherwise false
|
|
8224
8406
|
*/
|
|
8225
8407
|
Editor.prototype.isEmpty = function (trim) {
|
|
8226
|
-
return (0, roosterjs_editor_dom_1.isNodeEmpty)(this.
|
|
8408
|
+
return (0, roosterjs_editor_dom_1.isNodeEmpty)(this.getCore().contentDiv, trim);
|
|
8227
8409
|
};
|
|
8228
8410
|
/**
|
|
8229
8411
|
* Get current editor content as HTML string
|
|
@@ -8232,7 +8414,8 @@ var Editor = /** @class */ (function () {
|
|
|
8232
8414
|
*/
|
|
8233
8415
|
Editor.prototype.getContent = function (mode) {
|
|
8234
8416
|
if (mode === void 0) { mode = 0 /* CleanHTML */; }
|
|
8235
|
-
|
|
8417
|
+
var core = this.getCore();
|
|
8418
|
+
return core.api.getContent(core, mode);
|
|
8236
8419
|
};
|
|
8237
8420
|
/**
|
|
8238
8421
|
* Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
|
|
@@ -8241,7 +8424,8 @@ var Editor = /** @class */ (function () {
|
|
|
8241
8424
|
*/
|
|
8242
8425
|
Editor.prototype.setContent = function (content, triggerContentChangedEvent) {
|
|
8243
8426
|
if (triggerContentChangedEvent === void 0) { triggerContentChangedEvent = true; }
|
|
8244
|
-
this.
|
|
8427
|
+
var core = this.getCore();
|
|
8428
|
+
core.api.setContent(core, content, triggerContentChangedEvent);
|
|
8245
8429
|
};
|
|
8246
8430
|
/**
|
|
8247
8431
|
* Insert HTML content into editor
|
|
@@ -8256,7 +8440,7 @@ var Editor = /** @class */ (function () {
|
|
|
8256
8440
|
var _a;
|
|
8257
8441
|
if (content) {
|
|
8258
8442
|
var doc = this.getDocument();
|
|
8259
|
-
var body = (_a = new DOMParser().parseFromString(this.
|
|
8443
|
+
var body = (_a = new DOMParser().parseFromString(this.getCore().trustedHTMLHandler(content), 'text/html')) === null || _a === void 0 ? void 0 : _a.body;
|
|
8260
8444
|
var allNodes = (body === null || body === void 0 ? void 0 : body.childNodes) ? (0, roosterjs_editor_dom_1.toArray)(body.childNodes) : [];
|
|
8261
8445
|
// If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with
|
|
8262
8446
|
// a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped
|
|
@@ -8274,7 +8458,10 @@ var Editor = /** @class */ (function () {
|
|
|
8274
8458
|
*/
|
|
8275
8459
|
Editor.prototype.deleteSelectedContent = function () {
|
|
8276
8460
|
var range = this.getSelectionRange();
|
|
8277
|
-
|
|
8461
|
+
if (range && !range.collapsed) {
|
|
8462
|
+
return (0, roosterjs_editor_dom_1.deleteSelectedContent)(this.getCore().contentDiv, range);
|
|
8463
|
+
}
|
|
8464
|
+
return null;
|
|
8278
8465
|
};
|
|
8279
8466
|
/**
|
|
8280
8467
|
* Paste into editor using a clipboardData object
|
|
@@ -8285,6 +8472,9 @@ var Editor = /** @class */ (function () {
|
|
|
8285
8472
|
*/
|
|
8286
8473
|
Editor.prototype.paste = function (clipboardData, pasteAsText, applyCurrentFormat) {
|
|
8287
8474
|
var _this = this;
|
|
8475
|
+
if (pasteAsText === void 0) { pasteAsText = false; }
|
|
8476
|
+
if (applyCurrentFormat === void 0) { applyCurrentFormat = false; }
|
|
8477
|
+
var core = this.getCore();
|
|
8288
8478
|
if (!clipboardData) {
|
|
8289
8479
|
return;
|
|
8290
8480
|
}
|
|
@@ -8297,11 +8487,13 @@ var Editor = /** @class */ (function () {
|
|
|
8297
8487
|
}
|
|
8298
8488
|
var range = this.getSelectionRange();
|
|
8299
8489
|
var pos = range && roosterjs_editor_dom_1.Position.getStart(range);
|
|
8300
|
-
var fragment =
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8490
|
+
var fragment = core.api.createPasteFragment(core, clipboardData, pos, pasteAsText, applyCurrentFormat);
|
|
8491
|
+
if (fragment) {
|
|
8492
|
+
this.addUndoSnapshot(function () {
|
|
8493
|
+
_this.insertNode(fragment);
|
|
8494
|
+
return clipboardData;
|
|
8495
|
+
}, "Paste" /* Paste */);
|
|
8496
|
+
}
|
|
8305
8497
|
};
|
|
8306
8498
|
//#endregion
|
|
8307
8499
|
//#region Focus and Selection
|
|
@@ -8314,7 +8506,8 @@ var Editor = /** @class */ (function () {
|
|
|
8314
8506
|
*/
|
|
8315
8507
|
Editor.prototype.getSelectionRange = function (tryGetFromCache) {
|
|
8316
8508
|
if (tryGetFromCache === void 0) { tryGetFromCache = true; }
|
|
8317
|
-
|
|
8509
|
+
var core = this.getCore();
|
|
8510
|
+
return core.api.getSelectionRange(core, tryGetFromCache);
|
|
8318
8511
|
};
|
|
8319
8512
|
/**
|
|
8320
8513
|
* Get current selection range from Editor.
|
|
@@ -8324,7 +8517,8 @@ var Editor = /** @class */ (function () {
|
|
|
8324
8517
|
* @returns current selection range, or null if editor never got focus before
|
|
8325
8518
|
*/
|
|
8326
8519
|
Editor.prototype.getSelectionRangeEx = function () {
|
|
8327
|
-
|
|
8520
|
+
var core = this.getCore();
|
|
8521
|
+
return core.api.getSelectionRangeEx(core);
|
|
8328
8522
|
};
|
|
8329
8523
|
/**
|
|
8330
8524
|
* Get current selection in a serializable format
|
|
@@ -8333,40 +8527,42 @@ var Editor = /** @class */ (function () {
|
|
|
8333
8527
|
*/
|
|
8334
8528
|
Editor.prototype.getSelectionPath = function () {
|
|
8335
8529
|
var range = this.getSelectionRange();
|
|
8336
|
-
return range && (0, roosterjs_editor_dom_1.getSelectionPath)(this.
|
|
8530
|
+
return range && (0, roosterjs_editor_dom_1.getSelectionPath)(this.getCore().contentDiv, range);
|
|
8337
8531
|
};
|
|
8338
8532
|
/**
|
|
8339
8533
|
* Check if focus is in editor now
|
|
8340
8534
|
* @returns true if focus is in editor, otherwise false
|
|
8341
8535
|
*/
|
|
8342
8536
|
Editor.prototype.hasFocus = function () {
|
|
8343
|
-
|
|
8537
|
+
var core = this.getCore();
|
|
8538
|
+
return core.api.hasFocus(core);
|
|
8344
8539
|
};
|
|
8345
8540
|
/**
|
|
8346
8541
|
* Focus to this editor, the selection was restored to where it was before, no unexpected scroll.
|
|
8347
8542
|
*/
|
|
8348
8543
|
Editor.prototype.focus = function () {
|
|
8349
|
-
this.
|
|
8544
|
+
var core = this.getCore();
|
|
8545
|
+
core.api.focus(core);
|
|
8350
8546
|
};
|
|
8351
8547
|
Editor.prototype.select = function (arg1, arg2, arg3, arg4) {
|
|
8352
|
-
var
|
|
8353
|
-
if (
|
|
8354
|
-
var selection =
|
|
8355
|
-
|
|
8548
|
+
var core = this.getCore();
|
|
8549
|
+
if (arg1 && 'rows' in arg1) {
|
|
8550
|
+
var selection = core.api.selectTable(core, arg1, arg2);
|
|
8551
|
+
core.domEvent.tableSelectionRange = selection;
|
|
8356
8552
|
return !!selection;
|
|
8357
8553
|
}
|
|
8358
8554
|
else {
|
|
8359
|
-
|
|
8360
|
-
|
|
8555
|
+
core.api.selectTable(core, null);
|
|
8556
|
+
core.domEvent.tableSelectionRange = null;
|
|
8361
8557
|
}
|
|
8362
8558
|
var range = !arg1
|
|
8363
8559
|
? null
|
|
8364
8560
|
: (0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'Range')
|
|
8365
8561
|
? arg1
|
|
8366
|
-
:
|
|
8367
|
-
? (0, roosterjs_editor_dom_1.createRange)(
|
|
8562
|
+
: 'start' in arg1 && Array.isArray(arg1.end)
|
|
8563
|
+
? (0, roosterjs_editor_dom_1.createRange)(core.contentDiv, arg1.start, arg1.end)
|
|
8368
8564
|
: (0, roosterjs_editor_dom_1.createRange)(arg1, arg2, arg3, arg4);
|
|
8369
|
-
return this.contains(range) &&
|
|
8565
|
+
return !!range && this.contains(range) && core.api.selectRange(core, range);
|
|
8370
8566
|
};
|
|
8371
8567
|
/**
|
|
8372
8568
|
* Get current focused position. Return null if editor doesn't have focus at this time.
|
|
@@ -8374,7 +8570,7 @@ var Editor = /** @class */ (function () {
|
|
|
8374
8570
|
Editor.prototype.getFocusedPosition = function () {
|
|
8375
8571
|
var _a;
|
|
8376
8572
|
var sel = (_a = this.getDocument().defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
8377
|
-
if (
|
|
8573
|
+
if ((sel === null || sel === void 0 ? void 0 : sel.focusNode) && this.contains(sel.focusNode)) {
|
|
8378
8574
|
return new roosterjs_editor_dom_1.Position(sel.focusNode, sel.focusOffset);
|
|
8379
8575
|
}
|
|
8380
8576
|
var range = this.getSelectionRange();
|
|
@@ -8397,14 +8593,16 @@ var Editor = /** @class */ (function () {
|
|
|
8397
8593
|
*/
|
|
8398
8594
|
Editor.prototype.getElementAtCursor = function (selector, startFrom, event) {
|
|
8399
8595
|
var _this = this;
|
|
8400
|
-
|
|
8401
|
-
|
|
8596
|
+
var _a;
|
|
8597
|
+
event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result
|
|
8598
|
+
return ((_a = (0, roosterjs_editor_dom_1.cacheGetEventData)(event !== null && event !== void 0 ? event : null, 'GET_ELEMENT_AT_CURSOR_' + selector, function () {
|
|
8402
8599
|
if (!startFrom) {
|
|
8403
8600
|
var position = _this.getFocusedPosition();
|
|
8404
|
-
startFrom = position
|
|
8601
|
+
startFrom = position === null || position === void 0 ? void 0 : position.node;
|
|
8405
8602
|
}
|
|
8406
|
-
return (startFrom &&
|
|
8407
|
-
|
|
8603
|
+
return (startFrom &&
|
|
8604
|
+
(0, roosterjs_editor_dom_1.findClosestElementAncestor)(startFrom, _this.getCore().contentDiv, selector));
|
|
8605
|
+
})) !== null && _a !== void 0 ? _a : null);
|
|
8408
8606
|
};
|
|
8409
8607
|
/**
|
|
8410
8608
|
* Check if this position is at beginning of the editor.
|
|
@@ -8413,18 +8611,18 @@ var Editor = /** @class */ (function () {
|
|
|
8413
8611
|
* @returns True if position is at beginning of the editor, otherwise false
|
|
8414
8612
|
*/
|
|
8415
8613
|
Editor.prototype.isPositionAtBeginning = function (position) {
|
|
8416
|
-
return (0, roosterjs_editor_dom_1.isPositionAtBeginningOf)(position, this.
|
|
8614
|
+
return (0, roosterjs_editor_dom_1.isPositionAtBeginningOf)(position, this.getCore().contentDiv);
|
|
8417
8615
|
};
|
|
8418
8616
|
/**
|
|
8419
8617
|
* Get impacted regions from selection
|
|
8420
8618
|
*/
|
|
8421
8619
|
Editor.prototype.getSelectedRegions = function (type) {
|
|
8422
|
-
var _this = this;
|
|
8423
8620
|
if (type === void 0) { type = 0 /* Table */; }
|
|
8424
8621
|
var selection = this.getSelectionRangeEx();
|
|
8425
8622
|
var result = [];
|
|
8623
|
+
var contentDiv = this.getCore().contentDiv;
|
|
8426
8624
|
selection.ranges.forEach(function (range) {
|
|
8427
|
-
result.push.apply(result, (range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(
|
|
8625
|
+
result.push.apply(result, (range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(contentDiv, range, type) : []));
|
|
8428
8626
|
});
|
|
8429
8627
|
return result.filter(function (value, index, self) {
|
|
8430
8628
|
return self.indexOf(value) === index;
|
|
@@ -8435,7 +8633,8 @@ var Editor = /** @class */ (function () {
|
|
|
8435
8633
|
Editor.prototype.addDomEventHandler = function (nameOrMap, handler) {
|
|
8436
8634
|
var _a;
|
|
8437
8635
|
var eventsToMap = typeof nameOrMap == 'string' ? (_a = {}, _a[nameOrMap] = handler, _a) : nameOrMap;
|
|
8438
|
-
|
|
8636
|
+
var core = this.getCore();
|
|
8637
|
+
return core.api.attachDomEvent(core, eventsToMap);
|
|
8439
8638
|
};
|
|
8440
8639
|
/**
|
|
8441
8640
|
* Trigger an event to be dispatched to all plugins
|
|
@@ -8447,8 +8646,10 @@ var Editor = /** @class */ (function () {
|
|
|
8447
8646
|
* the result of this function provides a chance to read the modified result
|
|
8448
8647
|
*/
|
|
8449
8648
|
Editor.prototype.triggerPluginEvent = function (eventType, data, broadcast) {
|
|
8649
|
+
if (broadcast === void 0) { broadcast = false; }
|
|
8650
|
+
var core = this.getCore();
|
|
8450
8651
|
var event = __assign({ eventType: eventType }, data);
|
|
8451
|
-
|
|
8652
|
+
core.api.triggerEvent(core, event, broadcast);
|
|
8452
8653
|
return event;
|
|
8453
8654
|
};
|
|
8454
8655
|
/**
|
|
@@ -8470,14 +8671,16 @@ var Editor = /** @class */ (function () {
|
|
|
8470
8671
|
*/
|
|
8471
8672
|
Editor.prototype.undo = function () {
|
|
8472
8673
|
this.focus();
|
|
8473
|
-
this.
|
|
8674
|
+
var core = this.getCore();
|
|
8675
|
+
core.api.restoreUndoSnapshot(core, -1 /*step*/);
|
|
8474
8676
|
};
|
|
8475
8677
|
/**
|
|
8476
8678
|
* Redo next edit operation
|
|
8477
8679
|
*/
|
|
8478
8680
|
Editor.prototype.redo = function () {
|
|
8479
8681
|
this.focus();
|
|
8480
|
-
this.
|
|
8682
|
+
var core = this.getCore();
|
|
8683
|
+
core.api.restoreUndoSnapshot(core, 1 /*step*/);
|
|
8481
8684
|
};
|
|
8482
8685
|
/**
|
|
8483
8686
|
* Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger
|
|
@@ -8490,13 +8693,14 @@ var Editor = /** @class */ (function () {
|
|
|
8490
8693
|
* @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
|
|
8491
8694
|
*/
|
|
8492
8695
|
Editor.prototype.addUndoSnapshot = function (callback, changeSource, canUndoByBackspace, additionalData) {
|
|
8493
|
-
this.
|
|
8696
|
+
var core = this.getCore();
|
|
8697
|
+
core.api.addUndoSnapshot(core, callback !== null && callback !== void 0 ? callback : null, changeSource !== null && changeSource !== void 0 ? changeSource : null, canUndoByBackspace !== null && canUndoByBackspace !== void 0 ? canUndoByBackspace : false, additionalData);
|
|
8494
8698
|
};
|
|
8495
8699
|
/**
|
|
8496
8700
|
* Whether there is an available undo/redo snapshot
|
|
8497
8701
|
*/
|
|
8498
8702
|
Editor.prototype.getUndoState = function () {
|
|
8499
|
-
var _a = this.
|
|
8703
|
+
var _a = this.getCore().undo, hasNewContent = _a.hasNewContent, snapshotsService = _a.snapshotsService;
|
|
8500
8704
|
return {
|
|
8501
8705
|
canUndo: hasNewContent || snapshotsService.canMove(-1 /*previousSnapshot*/),
|
|
8502
8706
|
canRedo: snapshotsService.canMove(1 /*nextSnapshot*/),
|
|
@@ -8509,13 +8713,13 @@ var Editor = /** @class */ (function () {
|
|
|
8509
8713
|
* @returns The HTML document which contains this editor
|
|
8510
8714
|
*/
|
|
8511
8715
|
Editor.prototype.getDocument = function () {
|
|
8512
|
-
return this.
|
|
8716
|
+
return this.getCore().contentDiv.ownerDocument;
|
|
8513
8717
|
};
|
|
8514
8718
|
/**
|
|
8515
8719
|
* Get the scroll container of the editor
|
|
8516
8720
|
*/
|
|
8517
8721
|
Editor.prototype.getScrollContainer = function () {
|
|
8518
|
-
return this.
|
|
8722
|
+
return this.getCore().domEvent.scrollContainer;
|
|
8519
8723
|
};
|
|
8520
8724
|
/**
|
|
8521
8725
|
* Get custom data related to this editor
|
|
@@ -8526,7 +8730,8 @@ var Editor = /** @class */ (function () {
|
|
|
8526
8730
|
* dispose editor.
|
|
8527
8731
|
*/
|
|
8528
8732
|
Editor.prototype.getCustomData = function (key, getter, disposer) {
|
|
8529
|
-
|
|
8733
|
+
var core = this.getCore();
|
|
8734
|
+
return (core.lifecycle.customData[key] = core.lifecycle.customData[key] || {
|
|
8530
8735
|
value: getter ? getter() : undefined,
|
|
8531
8736
|
disposer: disposer,
|
|
8532
8737
|
}).value;
|
|
@@ -8536,48 +8741,57 @@ var Editor = /** @class */ (function () {
|
|
|
8536
8741
|
* @returns True if editor is in IME input sequence, otherwise false
|
|
8537
8742
|
*/
|
|
8538
8743
|
Editor.prototype.isInIME = function () {
|
|
8539
|
-
return this.
|
|
8744
|
+
return this.getCore().domEvent.isInIME;
|
|
8540
8745
|
};
|
|
8541
8746
|
/**
|
|
8542
8747
|
* Get default format of this editor
|
|
8543
8748
|
* @returns Default format object of this editor
|
|
8544
8749
|
*/
|
|
8545
8750
|
Editor.prototype.getDefaultFormat = function () {
|
|
8546
|
-
return this.
|
|
8751
|
+
return this.getCore().lifecycle.defaultFormat;
|
|
8547
8752
|
};
|
|
8548
8753
|
/**
|
|
8549
8754
|
* Get a content traverser for the whole editor
|
|
8550
8755
|
* @param startNode The node to start from. If not passed, it will start from the beginning of the body
|
|
8551
8756
|
*/
|
|
8552
8757
|
Editor.prototype.getBodyTraverser = function (startNode) {
|
|
8553
|
-
return roosterjs_editor_dom_1.ContentTraverser.createBodyTraverser(this.
|
|
8758
|
+
return roosterjs_editor_dom_1.ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);
|
|
8554
8759
|
};
|
|
8555
8760
|
/**
|
|
8556
8761
|
* Get a content traverser for current selection
|
|
8762
|
+
* @returns A content traverser, or null if editor never got focus before
|
|
8557
8763
|
*/
|
|
8558
8764
|
Editor.prototype.getSelectionTraverser = function (range) {
|
|
8559
|
-
|
|
8560
|
-
|
|
8765
|
+
var _a;
|
|
8766
|
+
range = (_a = range !== null && range !== void 0 ? range : this.getSelectionRange()) !== null && _a !== void 0 ? _a : undefined;
|
|
8767
|
+
return range
|
|
8768
|
+
? roosterjs_editor_dom_1.ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)
|
|
8769
|
+
: null;
|
|
8561
8770
|
};
|
|
8562
8771
|
/**
|
|
8563
8772
|
* Get a content traverser for current block element start from specified position
|
|
8564
8773
|
* @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart
|
|
8774
|
+
* @returns A content traverser, or null if editor never got focus before
|
|
8565
8775
|
*/
|
|
8566
8776
|
Editor.prototype.getBlockTraverser = function (startFrom) {
|
|
8567
8777
|
if (startFrom === void 0) { startFrom = 3 /* SelectionStart */; }
|
|
8568
8778
|
var range = this.getSelectionRange();
|
|
8569
|
-
return
|
|
8779
|
+
return range
|
|
8780
|
+
? roosterjs_editor_dom_1.ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)
|
|
8781
|
+
: null;
|
|
8570
8782
|
};
|
|
8571
8783
|
/**
|
|
8572
8784
|
* Get a text traverser of current selection
|
|
8573
8785
|
* @param event Optional, if specified, editor will try to get cached result from the event object first.
|
|
8574
8786
|
* If it is not cached before, query from DOM and cache the result into the event object
|
|
8787
|
+
* @returns A content traverser, or null if editor never got focus before
|
|
8575
8788
|
*/
|
|
8576
8789
|
Editor.prototype.getContentSearcherOfCursor = function (event) {
|
|
8577
8790
|
var _this = this;
|
|
8578
|
-
return (0, roosterjs_editor_dom_1.cacheGetEventData)(event, 'ContentSearcher', function () {
|
|
8791
|
+
return (0, roosterjs_editor_dom_1.cacheGetEventData)(event !== null && event !== void 0 ? event : null, 'ContentSearcher', function () {
|
|
8579
8792
|
var range = _this.getSelectionRange();
|
|
8580
|
-
return (range &&
|
|
8793
|
+
return (range &&
|
|
8794
|
+
new roosterjs_editor_dom_1.PositionContentSearcher(_this.getCore().contentDiv, roosterjs_editor_dom_1.Position.getStart(range)));
|
|
8581
8795
|
});
|
|
8582
8796
|
};
|
|
8583
8797
|
/**
|
|
@@ -8587,7 +8801,7 @@ var Editor = /** @class */ (function () {
|
|
|
8587
8801
|
*/
|
|
8588
8802
|
Editor.prototype.runAsync = function (callback) {
|
|
8589
8803
|
var _this = this;
|
|
8590
|
-
var win = this.
|
|
8804
|
+
var win = this.getCore().contentDiv.ownerDocument.defaultView || window;
|
|
8591
8805
|
var handle = win.requestAnimationFrame(function () {
|
|
8592
8806
|
if (!_this.isDisposed() && callback) {
|
|
8593
8807
|
callback(_this);
|
|
@@ -8604,18 +8818,18 @@ var Editor = /** @class */ (function () {
|
|
|
8604
8818
|
*/
|
|
8605
8819
|
Editor.prototype.setEditorDomAttribute = function (name, value) {
|
|
8606
8820
|
if (value === null) {
|
|
8607
|
-
this.
|
|
8821
|
+
this.getCore().contentDiv.removeAttribute(name);
|
|
8608
8822
|
}
|
|
8609
8823
|
else {
|
|
8610
|
-
this.
|
|
8824
|
+
this.getCore().contentDiv.setAttribute(name, value);
|
|
8611
8825
|
}
|
|
8612
8826
|
};
|
|
8613
8827
|
/**
|
|
8614
|
-
*
|
|
8828
|
+
* Get DOM attribute of editor content DIV, null if there is no such attribute.
|
|
8615
8829
|
* @param name Name of the attribute
|
|
8616
8830
|
*/
|
|
8617
8831
|
Editor.prototype.getEditorDomAttribute = function (name) {
|
|
8618
|
-
return this.
|
|
8832
|
+
return this.getCore().contentDiv.getAttribute(name);
|
|
8619
8833
|
};
|
|
8620
8834
|
/**
|
|
8621
8835
|
* Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.
|
|
@@ -8626,7 +8840,7 @@ var Editor = /** @class */ (function () {
|
|
|
8626
8840
|
*/
|
|
8627
8841
|
Editor.prototype.getRelativeDistanceToEditor = function (element, addScroll) {
|
|
8628
8842
|
if (this.contains(element)) {
|
|
8629
|
-
var contentDiv = this.
|
|
8843
|
+
var contentDiv = this.getCore().contentDiv;
|
|
8630
8844
|
var editorRect = contentDiv.getBoundingClientRect();
|
|
8631
8845
|
var elementRect = element.getBoundingClientRect();
|
|
8632
8846
|
if (editorRect && elementRect) {
|
|
@@ -8646,22 +8860,24 @@ var Editor = /** @class */ (function () {
|
|
|
8646
8860
|
* @param feature The feature to add
|
|
8647
8861
|
*/
|
|
8648
8862
|
Editor.prototype.addContentEditFeature = function (feature) {
|
|
8649
|
-
var
|
|
8863
|
+
var core = this.getCore();
|
|
8650
8864
|
feature === null || feature === void 0 ? void 0 : feature.keys.forEach(function (key) {
|
|
8651
|
-
var array =
|
|
8865
|
+
var array = core.edit.features[key] || [];
|
|
8652
8866
|
array.push(feature);
|
|
8653
|
-
|
|
8867
|
+
core.edit.features[key] = array;
|
|
8654
8868
|
});
|
|
8655
8869
|
};
|
|
8656
8870
|
/**
|
|
8657
8871
|
* Get style based format state from current selection, including font name/size and colors
|
|
8658
8872
|
*/
|
|
8659
8873
|
Editor.prototype.getStyleBasedFormatState = function (node) {
|
|
8874
|
+
var _a;
|
|
8660
8875
|
if (!node) {
|
|
8661
8876
|
var range = this.getSelectionRange();
|
|
8662
|
-
node = range && roosterjs_editor_dom_1.Position.getStart(range).normalize().node;
|
|
8877
|
+
node = (_a = (range && roosterjs_editor_dom_1.Position.getStart(range).normalize().node)) !== null && _a !== void 0 ? _a : undefined;
|
|
8663
8878
|
}
|
|
8664
|
-
|
|
8879
|
+
var core = this.getCore();
|
|
8880
|
+
return core.api.getStyleBasedFormatState(core, node !== null && node !== void 0 ? node : null);
|
|
8665
8881
|
};
|
|
8666
8882
|
/**
|
|
8667
8883
|
* Get the pendable format such as underline and bold
|
|
@@ -8669,7 +8885,9 @@ var Editor = /** @class */ (function () {
|
|
|
8669
8885
|
* @returns The pending format state
|
|
8670
8886
|
*/
|
|
8671
8887
|
Editor.prototype.getPendableFormatState = function (forceGetStateFromDOM) {
|
|
8672
|
-
|
|
8888
|
+
if (forceGetStateFromDOM === void 0) { forceGetStateFromDOM = false; }
|
|
8889
|
+
var core = this.getCore();
|
|
8890
|
+
return core.api.getPendableFormatState(core, forceGetStateFromDOM);
|
|
8673
8891
|
};
|
|
8674
8892
|
/**
|
|
8675
8893
|
* Ensure user will type into a container element rather than into the editor content DIV directly
|
|
@@ -8677,7 +8895,8 @@ var Editor = /** @class */ (function () {
|
|
|
8677
8895
|
* @param keyboardEvent Optional keyboard event object
|
|
8678
8896
|
*/
|
|
8679
8897
|
Editor.prototype.ensureTypeInContainer = function (position, keyboardEvent) {
|
|
8680
|
-
this.
|
|
8898
|
+
var core = this.getCore();
|
|
8899
|
+
core.api.ensureTypeInContainer(core, position, keyboardEvent);
|
|
8681
8900
|
};
|
|
8682
8901
|
//#endregion
|
|
8683
8902
|
//#region Dark mode APIs
|
|
@@ -8689,7 +8908,8 @@ var Editor = /** @class */ (function () {
|
|
|
8689
8908
|
if (this.isDarkMode() == !!nextDarkMode) {
|
|
8690
8909
|
return;
|
|
8691
8910
|
}
|
|
8692
|
-
|
|
8911
|
+
var core = this.getCore();
|
|
8912
|
+
core.api.transformColor(core, core.contentDiv, false /*includeSelf*/, null /*callback*/, nextDarkMode
|
|
8693
8913
|
? 0 /* LightToDark */
|
|
8694
8914
|
: 1 /* DarkToLight */, true /*forceTransform*/);
|
|
8695
8915
|
this.triggerContentChangedEvent(nextDarkMode ? "SwitchToDarkMode" /* SwitchToDarkMode */ : "SwitchToLightMode" /* SwitchToLightMode */);
|
|
@@ -8699,14 +8919,15 @@ var Editor = /** @class */ (function () {
|
|
|
8699
8919
|
* @returns True if the editor is in dark mode, otherwise false
|
|
8700
8920
|
*/
|
|
8701
8921
|
Editor.prototype.isDarkMode = function () {
|
|
8702
|
-
return this.
|
|
8922
|
+
return this.getCore().lifecycle.isDarkMode;
|
|
8703
8923
|
};
|
|
8704
8924
|
/**
|
|
8705
8925
|
* Transform the given node and all its child nodes to dark mode color if editor is in dark mode
|
|
8706
8926
|
* @param node The node to transform
|
|
8707
8927
|
*/
|
|
8708
8928
|
Editor.prototype.transformToDarkColor = function (node) {
|
|
8709
|
-
this.
|
|
8929
|
+
var core = this.getCore();
|
|
8930
|
+
core.api.transformColor(core, node, true /*includeSelf*/, null /*callback*/, 0 /* LightToDark */);
|
|
8710
8931
|
};
|
|
8711
8932
|
/**
|
|
8712
8933
|
* Make the editor in "Shadow Edit" mode.
|
|
@@ -8717,26 +8938,28 @@ var Editor = /** @class */ (function () {
|
|
|
8717
8938
|
* use this function to do more shadow edit operation.
|
|
8718
8939
|
*/
|
|
8719
8940
|
Editor.prototype.startShadowEdit = function () {
|
|
8720
|
-
this.
|
|
8941
|
+
var core = this.getCore();
|
|
8942
|
+
core.api.switchShadowEdit(core, true /*isOn*/);
|
|
8721
8943
|
};
|
|
8722
8944
|
/**
|
|
8723
8945
|
* Leave "Shadow Edit" mode, all changes made during shadow edit will be discarded
|
|
8724
8946
|
*/
|
|
8725
8947
|
Editor.prototype.stopShadowEdit = function () {
|
|
8726
|
-
this.
|
|
8948
|
+
var core = this.getCore();
|
|
8949
|
+
core.api.switchShadowEdit(core, false /*isOn*/);
|
|
8727
8950
|
};
|
|
8728
8951
|
/**
|
|
8729
8952
|
* Check if editor is in Shadow Edit mode
|
|
8730
8953
|
*/
|
|
8731
8954
|
Editor.prototype.isInShadowEdit = function () {
|
|
8732
|
-
return !!this.
|
|
8955
|
+
return !!this.getCore().lifecycle.shadowEditFragment;
|
|
8733
8956
|
};
|
|
8734
8957
|
/**
|
|
8735
8958
|
* Check if the given experimental feature is enabled
|
|
8736
8959
|
* @param feature The feature to check
|
|
8737
8960
|
*/
|
|
8738
8961
|
Editor.prototype.isFeatureEnabled = function (feature) {
|
|
8739
|
-
return this.
|
|
8962
|
+
return this.getCore().lifecycle.experimentalFeatures.indexOf(feature) >= 0;
|
|
8740
8963
|
};
|
|
8741
8964
|
/**
|
|
8742
8965
|
* Get a function to convert HTML string to trusted HTML string.
|
|
@@ -8745,13 +8968,13 @@ var Editor = /** @class */ (function () {
|
|
|
8745
8968
|
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
8746
8969
|
*/
|
|
8747
8970
|
Editor.prototype.getTrustedHTMLHandler = function () {
|
|
8748
|
-
return this.
|
|
8971
|
+
return this.getCore().trustedHTMLHandler;
|
|
8749
8972
|
};
|
|
8750
8973
|
/**
|
|
8751
8974
|
* @deprecated Use getZoomScale() instead
|
|
8752
8975
|
*/
|
|
8753
8976
|
Editor.prototype.getSizeTransformer = function () {
|
|
8754
|
-
return this.
|
|
8977
|
+
return this.getCore().sizeTransformer;
|
|
8755
8978
|
};
|
|
8756
8979
|
/**
|
|
8757
8980
|
* Get current zoom scale, default value is 1
|
|
@@ -8760,7 +8983,7 @@ var Editor = /** @class */ (function () {
|
|
|
8760
8983
|
* @returns current zoom scale number
|
|
8761
8984
|
*/
|
|
8762
8985
|
Editor.prototype.getZoomScale = function () {
|
|
8763
|
-
return this.
|
|
8986
|
+
return this.getCore().zoomScale;
|
|
8764
8987
|
};
|
|
8765
8988
|
/**
|
|
8766
8989
|
* Set current zoom scale, default value is 1
|
|
@@ -8769,9 +8992,10 @@ var Editor = /** @class */ (function () {
|
|
|
8769
8992
|
* @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.
|
|
8770
8993
|
*/
|
|
8771
8994
|
Editor.prototype.setZoomScale = function (scale) {
|
|
8995
|
+
var core = this.getCore();
|
|
8772
8996
|
if (scale > 0 && scale <= 10) {
|
|
8773
|
-
var oldValue =
|
|
8774
|
-
|
|
8997
|
+
var oldValue = core.zoomScale;
|
|
8998
|
+
core.zoomScale = scale;
|
|
8775
8999
|
if (oldValue != scale) {
|
|
8776
9000
|
this.triggerPluginEvent(21 /* ZoomChanged */, {
|
|
8777
9001
|
oldZoomScale: oldValue,
|
|
@@ -8780,6 +9004,16 @@ var Editor = /** @class */ (function () {
|
|
|
8780
9004
|
}
|
|
8781
9005
|
}
|
|
8782
9006
|
};
|
|
9007
|
+
/**
|
|
9008
|
+
* @returns the current EditorCore object
|
|
9009
|
+
* @throws a standard Error if there's no core object
|
|
9010
|
+
*/
|
|
9011
|
+
Editor.prototype.getCore = function () {
|
|
9012
|
+
if (!this.core) {
|
|
9013
|
+
throw new Error('Editor is already disposed');
|
|
9014
|
+
}
|
|
9015
|
+
return this.core;
|
|
9016
|
+
};
|
|
8783
9017
|
return Editor;
|
|
8784
9018
|
}());
|
|
8785
9019
|
exports.default = Editor;
|
|
@@ -13121,7 +13355,7 @@ var NEGATIVE_MARGIN = '-.25in';
|
|
|
13121
13355
|
*/
|
|
13122
13356
|
exports.ListStyleDefinitionMetadata = (0, definitionCreators_1.createObjectDefinition)({
|
|
13123
13357
|
orderedStyleType: (0, definitionCreators_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 20 /* Max */),
|
|
13124
|
-
unorderedStyleType: (0, definitionCreators_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */,
|
|
13358
|
+
unorderedStyleType: (0, definitionCreators_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 8 /* Max */),
|
|
13125
13359
|
}, true /** isOptional */, true /** allowNull */);
|
|
13126
13360
|
/**
|
|
13127
13361
|
* !!! Never directly create instance of this class. It should be created within VList class !!!
|
|
@@ -13348,10 +13582,8 @@ var VListItem = /** @class */ (function () {
|
|
|
13348
13582
|
this.node.style.setProperty('display', this.dummy ? 'block' : null);
|
|
13349
13583
|
// 4. Inherit styles of the child element to the li, so we are able to apply the styles to the ::marker
|
|
13350
13584
|
if (this.listTypes.length > 1) {
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
(0, setListItemStyle_1.default)(this.node, stylesToInherit);
|
|
13354
|
-
}
|
|
13585
|
+
var stylesToInherit = ['font-size', 'font-family', 'color'];
|
|
13586
|
+
(0, setListItemStyle_1.default)(this.node, stylesToInherit);
|
|
13355
13587
|
}
|
|
13356
13588
|
// 5. If this is not a list item now, need to unwrap the LI node and do proper handling
|
|
13357
13589
|
if (this.listTypes.length <= 1) {
|
|
@@ -13781,6 +14013,7 @@ var bulletListStyle = (_a = {},
|
|
|
13781
14013
|
_a[3 /* Square */] = 'square',
|
|
13782
14014
|
_a[2 /* Dash */] = '- ',
|
|
13783
14015
|
_a[5 /* LongArrow */] = '→ ',
|
|
14016
|
+
_a[8 /* DoubleLongArrow */] = '→ ',
|
|
13784
14017
|
_a[4 /* ShortArrow */] = '➢ ',
|
|
13785
14018
|
_a[6 /* UnfilledArrow */] = '➪ ',
|
|
13786
14019
|
_a[7 /* Hyphen */] = '— ',
|
|
@@ -13811,7 +14044,7 @@ var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roos
|
|
|
13811
14044
|
* @param styles The styles that should be applied to the element.
|
|
13812
14045
|
*/
|
|
13813
14046
|
function setListItemStyle(element, styles) {
|
|
13814
|
-
var elementsStyles = getInlineChildElementsStyle(element);
|
|
14047
|
+
var elementsStyles = getInlineChildElementsStyle(element, styles);
|
|
13815
14048
|
var stylesToApply = (0, getStyles_1.default)(element);
|
|
13816
14049
|
styles.forEach(function (styleName) {
|
|
13817
14050
|
var styleValues = elementsStyles.map(function (style) {
|
|
@@ -13826,21 +14059,41 @@ function setListItemStyle(element, styles) {
|
|
|
13826
14059
|
(0, setStyles_1.default)(element, stylesToApply);
|
|
13827
14060
|
}
|
|
13828
14061
|
exports.default = setListItemStyle;
|
|
13829
|
-
function getInlineChildElementsStyle(element) {
|
|
14062
|
+
function getInlineChildElementsStyle(element, styles) {
|
|
14063
|
+
var _a;
|
|
13830
14064
|
var result = [];
|
|
13831
14065
|
var contentTraverser = ContentTraverser_1.default.createBodyTraverser(element);
|
|
13832
14066
|
var currentInlineElement = null;
|
|
13833
|
-
|
|
14067
|
+
var _loop_1 = function () {
|
|
13834
14068
|
currentInlineElement = contentTraverser.currentInlineElement;
|
|
13835
14069
|
var currentNode = (currentInlineElement === null || currentInlineElement === void 0 ? void 0 : currentInlineElement.getContainerNode()) || null;
|
|
14070
|
+
var currentStyle = {};
|
|
13836
14071
|
currentNode = currentNode ? (0, findClosestElementAncestor_1.default)(currentNode) : null;
|
|
13837
|
-
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
14072
|
+
// we should consider of when it is the single childnode of element, the parentNode's style should add
|
|
14073
|
+
// such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
|
|
14074
|
+
while (currentNode &&
|
|
14075
|
+
currentNode !== element &&
|
|
14076
|
+
(0, safeInstanceOf_1.default)(currentNode, 'HTMLElement')) {
|
|
14077
|
+
styles.forEach(function (styleName) {
|
|
14078
|
+
var styleValue = currentNode.style.getPropertyValue(styleName);
|
|
14079
|
+
if (styleValue && !currentStyle[styleName]) {
|
|
14080
|
+
currentStyle[styleName] = styleValue;
|
|
14081
|
+
}
|
|
14082
|
+
});
|
|
14083
|
+
if (((_a = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _a === void 0 ? void 0 : _a.childNodes.length) === 1) {
|
|
14084
|
+
currentNode = currentNode.parentNode;
|
|
14085
|
+
}
|
|
14086
|
+
else {
|
|
14087
|
+
currentNode = null;
|
|
13841
14088
|
}
|
|
13842
14089
|
}
|
|
14090
|
+
if (currentStyle) {
|
|
14091
|
+
result.push(currentStyle);
|
|
14092
|
+
}
|
|
13843
14093
|
contentTraverser.getNextInlineElement();
|
|
14094
|
+
};
|
|
14095
|
+
while (contentTraverser.currentInlineElement != currentInlineElement) {
|
|
14096
|
+
_loop_1();
|
|
13844
14097
|
}
|
|
13845
14098
|
return result;
|
|
13846
14099
|
}
|
|
@@ -14812,7 +15065,7 @@ function getEndOffset(node) {
|
|
|
14812
15065
|
if (node.nodeType == 3 /* Text */) {
|
|
14813
15066
|
return ((_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
14814
15067
|
}
|
|
14815
|
-
else if (node.nodeType == 1 /* Element */) {
|
|
15068
|
+
else if (node.nodeType == 1 /* Element */ || node.nodeType == 11 /* DocumentFragment */) {
|
|
14816
15069
|
return node.childNodes.length;
|
|
14817
15070
|
}
|
|
14818
15071
|
else {
|
|
@@ -15317,6 +15570,10 @@ function addSnapshot(snapshots, snapshot, isAutoCompleteSnapshot, getLength, com
|
|
|
15317
15570
|
snapshots.autoCompleteIndex = snapshots.currentIndex;
|
|
15318
15571
|
}
|
|
15319
15572
|
}
|
|
15573
|
+
else if (currentSnapshot && compare(snapshot, currentSnapshot)) {
|
|
15574
|
+
// replace the currentSnapshot, to update other data such as metadata
|
|
15575
|
+
snapshots.snapshots.splice(snapshots.currentIndex, 1, snapshot);
|
|
15576
|
+
}
|
|
15320
15577
|
}
|
|
15321
15578
|
exports.default = addSnapshot;
|
|
15322
15579
|
/**
|
|
@@ -15587,6 +15844,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15587
15844
|
};
|
|
15588
15845
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15589
15846
|
var applyTableFormat_1 = __webpack_require__(/*! ./applyTableFormat */ "./packages/roosterjs-editor-dom/lib/table/applyTableFormat.ts");
|
|
15847
|
+
var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
|
|
15590
15848
|
var moveChildNodes_1 = __webpack_require__(/*! ../utils/moveChildNodes */ "./packages/roosterjs-editor-dom/lib/utils/moveChildNodes.ts");
|
|
15591
15849
|
var normalizeRect_1 = __webpack_require__(/*! ../utils/normalizeRect */ "./packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts");
|
|
15592
15850
|
var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
|
|
@@ -15623,15 +15881,12 @@ var VTable = /** @class */ (function () {
|
|
|
15623
15881
|
* Virtual cells
|
|
15624
15882
|
*/
|
|
15625
15883
|
this.cells = null;
|
|
15626
|
-
/**
|
|
15627
|
-
* Selected range of cells with the coordinates of the first and last cell selected.
|
|
15628
|
-
*/
|
|
15629
|
-
this.selection = null;
|
|
15630
15884
|
/**
|
|
15631
15885
|
* Current format of the table
|
|
15632
15886
|
*/
|
|
15633
15887
|
this.formatInfo = null;
|
|
15634
15888
|
this.trs = [];
|
|
15889
|
+
this.tableSelection = null;
|
|
15635
15890
|
this.table = (0, safeInstanceOf_1.default)(node, 'HTMLTableElement') ? node : getTableFromTd(node);
|
|
15636
15891
|
if (this.table) {
|
|
15637
15892
|
var currentTd_1 = (0, safeInstanceOf_1.default)(node, 'HTMLTableElement') ? null : node;
|
|
@@ -15671,6 +15926,24 @@ var VTable = /** @class */ (function () {
|
|
|
15671
15926
|
}
|
|
15672
15927
|
}
|
|
15673
15928
|
}
|
|
15929
|
+
Object.defineProperty(VTable.prototype, "selection", {
|
|
15930
|
+
/**
|
|
15931
|
+
* Selected range of cells with the coordinates of the first and last cell selected.
|
|
15932
|
+
*/
|
|
15933
|
+
get: function () {
|
|
15934
|
+
return this.tableSelection || null;
|
|
15935
|
+
},
|
|
15936
|
+
set: function (value) {
|
|
15937
|
+
if (value) {
|
|
15938
|
+
var firstCell = value.firstCell;
|
|
15939
|
+
this.row = firstCell === null || firstCell === void 0 ? void 0 : firstCell.y;
|
|
15940
|
+
this.col = firstCell === null || firstCell === void 0 ? void 0 : firstCell.x;
|
|
15941
|
+
}
|
|
15942
|
+
this.tableSelection = value;
|
|
15943
|
+
},
|
|
15944
|
+
enumerable: false,
|
|
15945
|
+
configurable: true
|
|
15946
|
+
});
|
|
15674
15947
|
/**
|
|
15675
15948
|
* Write the virtual table back to DOM tree to represent the change of VTable
|
|
15676
15949
|
* @param skipApplyFormat Do not reapply table format when write back.
|
|
@@ -15688,6 +15961,7 @@ var VTable = /** @class */ (function () {
|
|
|
15688
15961
|
row.forEach(function (cell, c) {
|
|
15689
15962
|
if (cell.td) {
|
|
15690
15963
|
_this.recalculateSpans(r, c);
|
|
15964
|
+
_this.recalculateCellHeight(cell.td);
|
|
15691
15965
|
tr.appendChild(cell.td);
|
|
15692
15966
|
}
|
|
15693
15967
|
});
|
|
@@ -15702,6 +15976,14 @@ var VTable = /** @class */ (function () {
|
|
|
15702
15976
|
(_a = this.table.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.table);
|
|
15703
15977
|
}
|
|
15704
15978
|
};
|
|
15979
|
+
VTable.prototype.recalculateCellHeight = function (td) {
|
|
15980
|
+
if (this.isEmptyCell(td) && td.rowSpan > 1) {
|
|
15981
|
+
for (var i = 1; i < td.rowSpan; i++) {
|
|
15982
|
+
var br = document.createElement('br');
|
|
15983
|
+
td.appendChild(br);
|
|
15984
|
+
}
|
|
15985
|
+
}
|
|
15986
|
+
};
|
|
15705
15987
|
/**
|
|
15706
15988
|
* Apply the given table format to this virtual table
|
|
15707
15989
|
* @param format Table format to apply
|
|
@@ -15982,7 +16264,7 @@ var VTable = /** @class */ (function () {
|
|
|
15982
16264
|
? ((_a = cell.td) === null || _a === void 0 ? void 0 : _a.rowSpan) === ((_b = nextCell.td) === null || _b === void 0 ? void 0 : _b.rowSpan) && !cell.spanLeft
|
|
15983
16265
|
: ((_c = cell.td) === null || _c === void 0 ? void 0 : _c.colSpan) === ((_d = nextCell.td) === null || _d === void 0 ? void 0 : _d.colSpan) && !cell.spanAbove;
|
|
15984
16266
|
if (cell.td && nextCell.td && checkSpans) {
|
|
15985
|
-
|
|
16267
|
+
this.mergeCellContents(cell.td, nextCell.td);
|
|
15986
16268
|
nextCell.td = null;
|
|
15987
16269
|
if (horizontally) {
|
|
15988
16270
|
nextCell.spanLeft = true;
|
|
@@ -15992,6 +16274,19 @@ var VTable = /** @class */ (function () {
|
|
|
15992
16274
|
}
|
|
15993
16275
|
}
|
|
15994
16276
|
};
|
|
16277
|
+
VTable.prototype.isEmptyCell = function (td) {
|
|
16278
|
+
return td.childElementCount === 1 && (0, getTagOfNode_1.default)(td.firstChild) === 'BR';
|
|
16279
|
+
};
|
|
16280
|
+
VTable.prototype.mergeCellContents = function (cellTd, nextCellTd) {
|
|
16281
|
+
if (this.isEmptyCell(nextCellTd)) {
|
|
16282
|
+
(0, moveChildNodes_1.default)(cellTd, nextCellTd, false /*keepExistingChildren*/);
|
|
16283
|
+
}
|
|
16284
|
+
else {
|
|
16285
|
+
var br = document.createElement('br');
|
|
16286
|
+
cellTd.appendChild(br);
|
|
16287
|
+
(0, moveChildNodes_1.default)(cellTd, nextCellTd, true /*keepExistingChildren*/);
|
|
16288
|
+
}
|
|
16289
|
+
};
|
|
15995
16290
|
/**
|
|
15996
16291
|
* Loop each cell of current column and invoke a callback function
|
|
15997
16292
|
* @param callback The callback function to invoke
|
|
@@ -16590,8 +16885,8 @@ var TableFormatMetadata = (0, definitionCreators_1.createObjectDefinition)({
|
|
|
16590
16885
|
hasBandedRows: BooleanDefinition,
|
|
16591
16886
|
bgColorEven: NullStringDefinition,
|
|
16592
16887
|
bgColorOdd: NullStringDefinition,
|
|
16593
|
-
tableBorderFormat: (0, definitionCreators_1.createNumberDefinition)(false /** isOptional */, undefined /* value */, 0 /*
|
|
16594
|
-
keepCellShade:
|
|
16888
|
+
tableBorderFormat: (0, definitionCreators_1.createNumberDefinition)(false /** isOptional */, undefined /* value */, 0 /* DEFAULT */, 8 /* CLEAR */),
|
|
16889
|
+
keepCellShade: (0, definitionCreators_1.createBooleanDefinition)(true /** isOptional */),
|
|
16595
16890
|
}, false /* isOptional */, true /** allowNull */);
|
|
16596
16891
|
/**
|
|
16597
16892
|
* Get the format info of a table
|
|
@@ -16655,11 +16950,11 @@ function getBrowserInfo(userAgent, appVersion, vendor) {
|
|
|
16655
16950
|
// The default regex on the website doesn't consider tablet.
|
|
16656
16951
|
// To support tablet, add |android|ipad|playbook|silk to the first regex according to the info in /about page
|
|
16657
16952
|
(function (userAgentOrVendor) {
|
|
16658
|
-
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(userAgentOrVendor)
|
|
16659
|
-
|
|
16953
|
+
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(userAgentOrVendor) ||
|
|
16954
|
+
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(userAgentOrVendor.substr(0, 4))) {
|
|
16660
16955
|
isMobileOrTablet = true;
|
|
16661
16956
|
}
|
|
16662
|
-
})(userAgent || vendor ||
|
|
16957
|
+
})(userAgent || vendor || '');
|
|
16663
16958
|
if (!isIE) {
|
|
16664
16959
|
isChrome = userAgent.indexOf('Chrome') != -1;
|
|
16665
16960
|
isFirefox = userAgent.indexOf('Firefox') != -1;
|
|
@@ -16696,7 +16991,7 @@ exports.getBrowserInfo = getBrowserInfo;
|
|
|
16696
16991
|
/**
|
|
16697
16992
|
* Browser object contains browser and operating system information of current environment
|
|
16698
16993
|
*/
|
|
16699
|
-
exports.Browser = window
|
|
16994
|
+
exports.Browser = typeof window !== 'undefined' && window
|
|
16700
16995
|
? getBrowserInfo(window.navigator.userAgent, window.navigator.appVersion, window.navigator.vendor)
|
|
16701
16996
|
: {};
|
|
16702
16997
|
|
|
@@ -18769,6 +19064,13 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
18769
19064
|
this.trigger.removeEventListener(this.dndMouse.MOUSEDOWN, this.onMouseDown);
|
|
18770
19065
|
this.removeDocumentEvents();
|
|
18771
19066
|
};
|
|
19067
|
+
Object.defineProperty(DragAndDropHelper.prototype, "mouseType", {
|
|
19068
|
+
get: function () {
|
|
19069
|
+
return this.dndMouse == MOUSE_EVENT_INFO_MOBILE ? 'touch' : 'mouse';
|
|
19070
|
+
},
|
|
19071
|
+
enumerable: false,
|
|
19072
|
+
configurable: true
|
|
19073
|
+
});
|
|
18772
19074
|
DragAndDropHelper.prototype.addDocumentEvents = function () {
|
|
18773
19075
|
var doc = this.trigger.ownerDocument;
|
|
18774
19076
|
doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, true /*useCapture*/);
|
|
@@ -19375,7 +19677,7 @@ var MaintainListChainWhenDelete = {
|
|
|
19375
19677
|
},
|
|
19376
19678
|
handleEvent: function (event, editor) {
|
|
19377
19679
|
var chains = getListChains(editor);
|
|
19378
|
-
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.
|
|
19680
|
+
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.commitListChains)(editor, chains); });
|
|
19379
19681
|
},
|
|
19380
19682
|
};
|
|
19381
19683
|
/**
|
|
@@ -19535,7 +19837,7 @@ var MaintainListChain = {
|
|
|
19535
19837
|
},
|
|
19536
19838
|
handleEvent: function (event, editor) {
|
|
19537
19839
|
var chains = getListChains(editor);
|
|
19538
|
-
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.
|
|
19840
|
+
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.commitListChains)(editor, chains); });
|
|
19539
19841
|
},
|
|
19540
19842
|
};
|
|
19541
19843
|
function getListChains(editor) {
|
|
@@ -20396,7 +20698,7 @@ var bulletListType = {
|
|
|
20396
20698
|
'-': 2 /* Dash */,
|
|
20397
20699
|
'--': 3 /* Square */,
|
|
20398
20700
|
'->': 5 /* LongArrow */,
|
|
20399
|
-
'-->':
|
|
20701
|
+
'-->': 8 /* DoubleLongArrow */,
|
|
20400
20702
|
'=>': 6 /* UnfilledArrow */,
|
|
20401
20703
|
'>': 4 /* ShortArrow */,
|
|
20402
20704
|
'—': 7 /* Hyphen */,
|
|
@@ -20872,7 +21174,7 @@ var CutPasteListChain = /** @class */ (function () {
|
|
|
20872
21174
|
break;
|
|
20873
21175
|
case 7 /* ContentChanged */:
|
|
20874
21176
|
if (((_a = this.chains) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.expectedChangeSource == event.source) {
|
|
20875
|
-
(0, roosterjs_editor_api_1.
|
|
21177
|
+
(0, roosterjs_editor_api_1.commitListChains)(this.editor, this.chains);
|
|
20876
21178
|
this.chains = null;
|
|
20877
21179
|
this.expectedChangeSource = null;
|
|
20878
21180
|
}
|
|
@@ -22709,22 +23011,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22709
23011
|
var convertPasteContentForSingleImage_1 = __webpack_require__(/*! ./imageConverter/convertPasteContentForSingleImage */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/imageConverter/convertPasteContentForSingleImage.ts");
|
|
22710
23012
|
var convertPastedContentForLI_1 = __webpack_require__(/*! ./commonConverter/convertPastedContentForLI */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/commonConverter/convertPastedContentForLI.ts");
|
|
22711
23013
|
var convertPastedContentFromExcel_1 = __webpack_require__(/*! ./excelConverter/convertPastedContentFromExcel */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/excelConverter/convertPastedContentFromExcel.ts");
|
|
23014
|
+
var convertPastedContentFromOfficeOnline_1 = __webpack_require__(/*! ./officeOnlineConverter/convertPastedContentFromOfficeOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromOfficeOnline.ts");
|
|
22712
23015
|
var convertPastedContentFromPowerPoint_1 = __webpack_require__(/*! ./pptConverter/convertPastedContentFromPowerPoint */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/pptConverter/convertPastedContentFromPowerPoint.ts");
|
|
22713
23016
|
var convertPastedContentFromWord_1 = __webpack_require__(/*! ./wordConverter/convertPastedContentFromWord */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/wordConverter/convertPastedContentFromWord.ts");
|
|
23017
|
+
var getPasteSource_1 = __webpack_require__(/*! ./sourceValidations/getPasteSource */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/getPasteSource.ts");
|
|
22714
23018
|
var handleLineMerge_1 = __webpack_require__(/*! ./lineMerge/handleLineMerge */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/lineMerge/handleLineMerge.ts");
|
|
22715
23019
|
var sanitizeHtmlColorsFromPastedContent_1 = __webpack_require__(/*! ./sanitizeHtmlColorsFromPastedContent/sanitizeHtmlColorsFromPastedContent */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sanitizeHtmlColorsFromPastedContent/sanitizeHtmlColorsFromPastedContent.ts");
|
|
22716
|
-
var
|
|
22717
|
-
var convertPastedContentFromWordOnline_1 = __webpack_require__(/*! ./officeOnlineConverter/convertPastedContentFromWordOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts");
|
|
22718
|
-
var WORD_ATTRIBUTE_NAME = 'xmlns:w';
|
|
22719
|
-
var WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';
|
|
22720
|
-
var WORD_PROG_ID = 'Word.Document';
|
|
22721
|
-
var EXCEL_ATTRIBUTE_NAME = 'xmlns:x';
|
|
22722
|
-
var EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';
|
|
22723
|
-
var PROG_ID_NAME = 'ProgId';
|
|
22724
|
-
var EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';
|
|
22725
|
-
var POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';
|
|
22726
|
-
var GOOGLE_SHEET_NODE_NAME = 'google-sheets-html-origin';
|
|
22727
|
-
var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer';
|
|
23020
|
+
var constants_1 = __webpack_require__(/*! ./sourceValidations/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
22728
23021
|
/**
|
|
22729
23022
|
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
22730
23023
|
* 1. Content copied from Word
|
|
@@ -22764,48 +23057,34 @@ var Paste = /** @class */ (function () {
|
|
|
22764
23057
|
* @param event PluginEvent object
|
|
22765
23058
|
*/
|
|
22766
23059
|
Paste.prototype.onPluginEvent = function (event) {
|
|
22767
|
-
var _a;
|
|
22768
23060
|
if (event.eventType == 10 /* BeforePaste */) {
|
|
22769
|
-
var
|
|
23061
|
+
var fragment = event.fragment, sanitizingOption = event.sanitizingOption;
|
|
22770
23062
|
var trustedHTMLHandler = this.editor.getTrustedHTMLHandler();
|
|
22771
|
-
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
}
|
|
22797
|
-
}
|
|
22798
|
-
else if (fragment.querySelector(GOOGLE_SHEET_NODE_NAME)) {
|
|
22799
|
-
sanitizingOption.additionalTagReplacements[GOOGLE_SHEET_NODE_NAME] = '*';
|
|
22800
|
-
}
|
|
22801
|
-
else if (this.editor.isFeatureEnabled("ConvertSingleImageBody" /* ConvertSingleImageBody */) &&
|
|
22802
|
-
((_a = clipboardData.htmlFirstLevelChildTags) === null || _a === void 0 ? void 0 : _a.length) == 1 &&
|
|
22803
|
-
clipboardData.htmlFirstLevelChildTags[0] == 'IMG') {
|
|
22804
|
-
(0, convertPasteContentForSingleImage_1.default)(event, trustedHTMLHandler);
|
|
22805
|
-
}
|
|
22806
|
-
else {
|
|
22807
|
-
(0, convertPastedContentForLI_1.default)(fragment);
|
|
22808
|
-
(0, handleLineMerge_1.default)(fragment);
|
|
23063
|
+
switch ((0, getPasteSource_1.default)(event, this.editor)) {
|
|
23064
|
+
case 0 /* WordDesktop */:
|
|
23065
|
+
// Handle HTML copied from Word
|
|
23066
|
+
(0, convertPastedContentFromWord_1.default)(event);
|
|
23067
|
+
break;
|
|
23068
|
+
case 1 /* ExcelDesktop */:
|
|
23069
|
+
// Handle HTML copied from Excel
|
|
23070
|
+
(0, convertPastedContentFromExcel_1.default)(event, trustedHTMLHandler);
|
|
23071
|
+
break;
|
|
23072
|
+
case 2 /* PowerPointDesktop */:
|
|
23073
|
+
(0, convertPastedContentFromPowerPoint_1.default)(event, trustedHTMLHandler);
|
|
23074
|
+
break;
|
|
23075
|
+
case 4 /* WacComponents */:
|
|
23076
|
+
(0, convertPastedContentFromOfficeOnline_1.default)(fragment);
|
|
23077
|
+
break;
|
|
23078
|
+
case 3 /* GoogleSheets */:
|
|
23079
|
+
sanitizingOption.additionalTagReplacements[constants_1.GOOGLE_SHEET_NODE_NAME] = '*';
|
|
23080
|
+
break;
|
|
23081
|
+
case 6 /* SingleImage */:
|
|
23082
|
+
(0, convertPasteContentForSingleImage_1.default)(event, trustedHTMLHandler);
|
|
23083
|
+
break;
|
|
23084
|
+
case 5 /* Default */:
|
|
23085
|
+
(0, convertPastedContentForLI_1.default)(fragment);
|
|
23086
|
+
(0, handleLineMerge_1.default)(fragment);
|
|
23087
|
+
break;
|
|
22809
23088
|
}
|
|
22810
23089
|
(0, sanitizeHtmlColorsFromPastedContent_1.default)(sanitizingOption);
|
|
22811
23090
|
// Replace unknown tags with SPAN
|
|
@@ -22815,10 +23094,6 @@ var Paste = /** @class */ (function () {
|
|
|
22815
23094
|
return Paste;
|
|
22816
23095
|
}());
|
|
22817
23096
|
exports.default = Paste;
|
|
22818
|
-
function isWordDocument(htmlAttributes) {
|
|
22819
|
-
return (htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||
|
|
22820
|
-
htmlAttributes[PROG_ID_NAME] == WORD_PROG_ID);
|
|
22821
|
-
}
|
|
22822
23097
|
|
|
22823
23098
|
|
|
22824
23099
|
/***/ }),
|
|
@@ -23099,22 +23374,57 @@ exports.createListItemBlock = createListItemBlock;
|
|
|
23099
23374
|
|
|
23100
23375
|
/***/ }),
|
|
23101
23376
|
|
|
23102
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/
|
|
23103
|
-
|
|
23104
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/
|
|
23105
|
-
|
|
23377
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromOfficeOnline.ts":
|
|
23378
|
+
/*!***************************************************************************************************************************!*\
|
|
23379
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromOfficeOnline.ts ***!
|
|
23380
|
+
\***************************************************************************************************************************/
|
|
23106
23381
|
/*! no static exports found */
|
|
23107
23382
|
/***/ (function(module, exports, __webpack_require__) {
|
|
23108
23383
|
|
|
23109
23384
|
"use strict";
|
|
23110
23385
|
|
|
23111
23386
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23112
|
-
|
|
23113
|
-
var
|
|
23114
|
-
|
|
23115
|
-
|
|
23116
|
-
|
|
23117
|
-
|
|
23387
|
+
var constants_1 = __webpack_require__(/*! ../sourceValidations/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
23388
|
+
var convertPastedContentFromWordOnline_1 = __webpack_require__(/*! ./convertPastedContentFromWordOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts");
|
|
23389
|
+
/**
|
|
23390
|
+
* @internal
|
|
23391
|
+
* Convert pasted content from Office Online
|
|
23392
|
+
* Once it is known that the document is from WAC
|
|
23393
|
+
* We need to remove the display property and margin from all the list item
|
|
23394
|
+
* @param event The BeforePaste event
|
|
23395
|
+
*/
|
|
23396
|
+
function convertPastedContentFromOfficeOnline(fragment) {
|
|
23397
|
+
fragment.querySelectorAll(constants_1.WAC_IDENTIFY_SELECTOR).forEach(function (el) {
|
|
23398
|
+
el.style.display = null;
|
|
23399
|
+
el.style.margin = null;
|
|
23400
|
+
});
|
|
23401
|
+
// call conversion function if the pasted content is from word online and
|
|
23402
|
+
// has list element in the pasted content.
|
|
23403
|
+
if ((0, convertPastedContentFromWordOnline_1.isWordOnlineWithList)(fragment)) {
|
|
23404
|
+
(0, convertPastedContentFromWordOnline_1.default)(fragment);
|
|
23405
|
+
}
|
|
23406
|
+
}
|
|
23407
|
+
exports.default = convertPastedContentFromOfficeOnline;
|
|
23408
|
+
|
|
23409
|
+
|
|
23410
|
+
/***/ }),
|
|
23411
|
+
|
|
23412
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts":
|
|
23413
|
+
/*!*************************************************************************************************************************!*\
|
|
23414
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts ***!
|
|
23415
|
+
\*************************************************************************************************************************/
|
|
23416
|
+
/*! no static exports found */
|
|
23417
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23418
|
+
|
|
23419
|
+
"use strict";
|
|
23420
|
+
|
|
23421
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23422
|
+
exports.isWordOnlineWithList = void 0;
|
|
23423
|
+
var ListItemBlock_1 = __webpack_require__(/*! ./ListItemBlock */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/ListItemBlock.ts");
|
|
23424
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
23425
|
+
var WORD_ONLINE_IDENTIFYING_SELECTOR = 'div.ListContainerWrapper>ul[class^="BulletListStyle"],div.ListContainerWrapper>ol[class^="NumberListStyle"],span.WACImageContainer > img';
|
|
23426
|
+
var LIST_CONTAINER_ELEMENT_CLASS_NAME = 'ListContainerWrapper';
|
|
23427
|
+
var IMAGE_CONTAINER_ELEMENT_CLASS_NAME = 'WACImageContainer';
|
|
23118
23428
|
//When the list style is a symbol and the value is not in the clipboard, WordOnline
|
|
23119
23429
|
var VALID_LIST_STYLE_CHAR_CODES = [
|
|
23120
23430
|
'111',
|
|
@@ -23520,6 +23830,255 @@ function sanitizeHtmlColorsFromPastedContent(sanitizingOption) {
|
|
|
23520
23830
|
exports.default = sanitizeHtmlColorsFromPastedContent;
|
|
23521
23831
|
|
|
23522
23832
|
|
|
23833
|
+
/***/ }),
|
|
23834
|
+
|
|
23835
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts":
|
|
23836
|
+
/*!********************************************************************************************!*\
|
|
23837
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts ***!
|
|
23838
|
+
\********************************************************************************************/
|
|
23839
|
+
/*! no static exports found */
|
|
23840
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23841
|
+
|
|
23842
|
+
"use strict";
|
|
23843
|
+
|
|
23844
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23845
|
+
exports.WAC_IDENTIFY_SELECTOR = exports.PROG_ID_NAME = exports.GOOGLE_SHEET_NODE_NAME = void 0;
|
|
23846
|
+
/**
|
|
23847
|
+
* @internal
|
|
23848
|
+
* Node attribute used to identify if the content is from Google Sheets.
|
|
23849
|
+
*/
|
|
23850
|
+
exports.GOOGLE_SHEET_NODE_NAME = 'google-sheets-html-origin';
|
|
23851
|
+
/**
|
|
23852
|
+
* @internal
|
|
23853
|
+
* Name of the HTMLMeta Property that provides the Office App Source of the pasted content
|
|
23854
|
+
*/
|
|
23855
|
+
exports.PROG_ID_NAME = 'ProgId';
|
|
23856
|
+
/**
|
|
23857
|
+
* @internal
|
|
23858
|
+
* Selector used to identify Wac Elements
|
|
23859
|
+
*/
|
|
23860
|
+
exports.WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer';
|
|
23861
|
+
|
|
23862
|
+
|
|
23863
|
+
/***/ }),
|
|
23864
|
+
|
|
23865
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/documentContainWacElements.ts":
|
|
23866
|
+
/*!*************************************************************************************************************!*\
|
|
23867
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/documentContainWacElements.ts ***!
|
|
23868
|
+
\*************************************************************************************************************/
|
|
23869
|
+
/*! no static exports found */
|
|
23870
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23871
|
+
|
|
23872
|
+
"use strict";
|
|
23873
|
+
|
|
23874
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23875
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
23876
|
+
/**
|
|
23877
|
+
* @internal
|
|
23878
|
+
* Check whether the fragment provided contain Wac Elements
|
|
23879
|
+
* @param props Properties related to the PasteEvent
|
|
23880
|
+
* @returns
|
|
23881
|
+
*/
|
|
23882
|
+
var documentContainWacElements = function (props) {
|
|
23883
|
+
var fragment = props.fragment;
|
|
23884
|
+
return !!fragment.querySelector(constants_1.WAC_IDENTIFY_SELECTOR);
|
|
23885
|
+
};
|
|
23886
|
+
exports.default = documentContainWacElements;
|
|
23887
|
+
|
|
23888
|
+
|
|
23889
|
+
/***/ }),
|
|
23890
|
+
|
|
23891
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/getPasteSource.ts":
|
|
23892
|
+
/*!*************************************************************************************************!*\
|
|
23893
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/getPasteSource.ts ***!
|
|
23894
|
+
\*************************************************************************************************/
|
|
23895
|
+
/*! no static exports found */
|
|
23896
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23897
|
+
|
|
23898
|
+
"use strict";
|
|
23899
|
+
|
|
23900
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23901
|
+
var documentContainWacElements_1 = __webpack_require__(/*! ./documentContainWacElements */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/documentContainWacElements.ts");
|
|
23902
|
+
var isExcelDesktopDocument_1 = __webpack_require__(/*! ./isExcelDesktopDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isExcelDesktopDocument.ts");
|
|
23903
|
+
var isGoogleSheetDocument_1 = __webpack_require__(/*! ./isGoogleSheetDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isGoogleSheetDocument.ts");
|
|
23904
|
+
var isPowerPointDesktopDocument_1 = __webpack_require__(/*! ./isPowerPointDesktopDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isPowerPointDesktopDocument.ts");
|
|
23905
|
+
var isWordDesktopDocument_1 = __webpack_require__(/*! ./isWordDesktopDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isWordDesktopDocument.ts");
|
|
23906
|
+
var shouldConvertToSingleImage_1 = __webpack_require__(/*! ./shouldConvertToSingleImage */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/shouldConvertToSingleImage.ts");
|
|
23907
|
+
var getSourceFunctions = new Map([
|
|
23908
|
+
[0 /* WordDesktop */, isWordDesktopDocument_1.default],
|
|
23909
|
+
[1 /* ExcelDesktop */, isExcelDesktopDocument_1.default],
|
|
23910
|
+
[2 /* PowerPointDesktop */, isPowerPointDesktopDocument_1.default],
|
|
23911
|
+
[4 /* WacComponents */, documentContainWacElements_1.default],
|
|
23912
|
+
[3 /* GoogleSheets */, isGoogleSheetDocument_1.default],
|
|
23913
|
+
[6 /* SingleImage */, shouldConvertToSingleImage_1.default],
|
|
23914
|
+
]);
|
|
23915
|
+
/**
|
|
23916
|
+
* @internal
|
|
23917
|
+
* This function tries to get the source of the Pasted content
|
|
23918
|
+
* @param event the before paste event
|
|
23919
|
+
* @param editor editor instance
|
|
23920
|
+
* @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}
|
|
23921
|
+
*/
|
|
23922
|
+
function getPasteSource(event, editor) {
|
|
23923
|
+
var htmlAttributes = event.htmlAttributes, clipboardData = event.clipboardData, fragment = event.fragment;
|
|
23924
|
+
var result = null;
|
|
23925
|
+
var param = {
|
|
23926
|
+
htmlAttributes: htmlAttributes,
|
|
23927
|
+
fragment: fragment,
|
|
23928
|
+
editor: editor,
|
|
23929
|
+
clipboardData: clipboardData,
|
|
23930
|
+
};
|
|
23931
|
+
getSourceFunctions.forEach(function (func, key) {
|
|
23932
|
+
if (!result && func(param)) {
|
|
23933
|
+
result = key;
|
|
23934
|
+
}
|
|
23935
|
+
});
|
|
23936
|
+
return result !== null && result !== void 0 ? result : 5 /* Default */;
|
|
23937
|
+
}
|
|
23938
|
+
exports.default = getPasteSource;
|
|
23939
|
+
|
|
23940
|
+
|
|
23941
|
+
/***/ }),
|
|
23942
|
+
|
|
23943
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isExcelDesktopDocument.ts":
|
|
23944
|
+
/*!*********************************************************************************************************!*\
|
|
23945
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isExcelDesktopDocument.ts ***!
|
|
23946
|
+
\*********************************************************************************************************/
|
|
23947
|
+
/*! no static exports found */
|
|
23948
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23949
|
+
|
|
23950
|
+
"use strict";
|
|
23951
|
+
|
|
23952
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23953
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
23954
|
+
var EXCEL_ATTRIBUTE_NAME = 'xmlns:x';
|
|
23955
|
+
var EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';
|
|
23956
|
+
var EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';
|
|
23957
|
+
/**
|
|
23958
|
+
* @internal
|
|
23959
|
+
* Checks whether the Array provided contains strings that identify Excel Desktop documents
|
|
23960
|
+
* @param props Properties related to the PasteEvent
|
|
23961
|
+
* @returns
|
|
23962
|
+
*/
|
|
23963
|
+
var isExcelDesktopDocument = function (props) {
|
|
23964
|
+
var htmlAttributes = props.htmlAttributes;
|
|
23965
|
+
return (htmlAttributes[EXCEL_ATTRIBUTE_NAME] == EXCEL_ATTRIBUTE_VALUE ||
|
|
23966
|
+
htmlAttributes[constants_1.PROG_ID_NAME] == EXCEL_ONLINE_ATTRIBUTE_VALUE);
|
|
23967
|
+
};
|
|
23968
|
+
exports.default = isExcelDesktopDocument;
|
|
23969
|
+
|
|
23970
|
+
|
|
23971
|
+
/***/ }),
|
|
23972
|
+
|
|
23973
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isGoogleSheetDocument.ts":
|
|
23974
|
+
/*!********************************************************************************************************!*\
|
|
23975
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isGoogleSheetDocument.ts ***!
|
|
23976
|
+
\********************************************************************************************************/
|
|
23977
|
+
/*! no static exports found */
|
|
23978
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23979
|
+
|
|
23980
|
+
"use strict";
|
|
23981
|
+
|
|
23982
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23983
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
23984
|
+
/**
|
|
23985
|
+
* @internal
|
|
23986
|
+
* Checks whether the fragment provided contain elements from Google sheets
|
|
23987
|
+
* @param props Properties related to the PasteEvent
|
|
23988
|
+
* @returns
|
|
23989
|
+
*/
|
|
23990
|
+
var isGoogleSheetDocument = function (props) {
|
|
23991
|
+
var fragment = props.fragment;
|
|
23992
|
+
return !!fragment.querySelector(constants_1.GOOGLE_SHEET_NODE_NAME);
|
|
23993
|
+
};
|
|
23994
|
+
exports.default = isGoogleSheetDocument;
|
|
23995
|
+
|
|
23996
|
+
|
|
23997
|
+
/***/ }),
|
|
23998
|
+
|
|
23999
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isPowerPointDesktopDocument.ts":
|
|
24000
|
+
/*!**************************************************************************************************************!*\
|
|
24001
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isPowerPointDesktopDocument.ts ***!
|
|
24002
|
+
\**************************************************************************************************************/
|
|
24003
|
+
/*! no static exports found */
|
|
24004
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24005
|
+
|
|
24006
|
+
"use strict";
|
|
24007
|
+
|
|
24008
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24009
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
24010
|
+
var POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';
|
|
24011
|
+
/**
|
|
24012
|
+
* @internal
|
|
24013
|
+
* Checks whether the Array provided contains strings that identify Power Point Desktop documents
|
|
24014
|
+
* @param props Properties related to the PasteEvent
|
|
24015
|
+
* @returns
|
|
24016
|
+
*/
|
|
24017
|
+
var isPowerPointDesktopDocument = function (props) {
|
|
24018
|
+
return props.htmlAttributes[constants_1.PROG_ID_NAME] == POWERPOINT_ATTRIBUTE_VALUE;
|
|
24019
|
+
};
|
|
24020
|
+
exports.default = isPowerPointDesktopDocument;
|
|
24021
|
+
|
|
24022
|
+
|
|
24023
|
+
/***/ }),
|
|
24024
|
+
|
|
24025
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isWordDesktopDocument.ts":
|
|
24026
|
+
/*!********************************************************************************************************!*\
|
|
24027
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isWordDesktopDocument.ts ***!
|
|
24028
|
+
\********************************************************************************************************/
|
|
24029
|
+
/*! no static exports found */
|
|
24030
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24031
|
+
|
|
24032
|
+
"use strict";
|
|
24033
|
+
|
|
24034
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24035
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
24036
|
+
var WORD_ATTRIBUTE_NAME = 'xmlns:w';
|
|
24037
|
+
var WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';
|
|
24038
|
+
var WORD_PROG_ID = 'Word.Document';
|
|
24039
|
+
/**
|
|
24040
|
+
* @internal
|
|
24041
|
+
* Checks whether the Array provided contains strings that identify Word Desktop documents
|
|
24042
|
+
* @param props Properties related to the PasteEvent
|
|
24043
|
+
* @returns
|
|
24044
|
+
*/
|
|
24045
|
+
var isWordDesktopDocument = function (props) {
|
|
24046
|
+
var htmlAttributes = props.htmlAttributes;
|
|
24047
|
+
return (htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||
|
|
24048
|
+
htmlAttributes[constants_1.PROG_ID_NAME] == WORD_PROG_ID);
|
|
24049
|
+
};
|
|
24050
|
+
exports.default = isWordDesktopDocument;
|
|
24051
|
+
|
|
24052
|
+
|
|
24053
|
+
/***/ }),
|
|
24054
|
+
|
|
24055
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/shouldConvertToSingleImage.ts":
|
|
24056
|
+
/*!*************************************************************************************************************!*\
|
|
24057
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/shouldConvertToSingleImage.ts ***!
|
|
24058
|
+
\*************************************************************************************************************/
|
|
24059
|
+
/*! no static exports found */
|
|
24060
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24061
|
+
|
|
24062
|
+
"use strict";
|
|
24063
|
+
|
|
24064
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24065
|
+
/**
|
|
24066
|
+
* @internal
|
|
24067
|
+
* Checks whether the fragment only contains a single image to paste
|
|
24068
|
+
* and the editor have the ConvertSingleImageBody Experimental feature
|
|
24069
|
+
* @param props Properties related to the PasteEvent
|
|
24070
|
+
* @returns
|
|
24071
|
+
*/
|
|
24072
|
+
var shouldConvertToSingleImage = function (props) {
|
|
24073
|
+
var _a;
|
|
24074
|
+
var editor = props.editor, clipboardData = props.clipboardData;
|
|
24075
|
+
return (editor.isFeatureEnabled("ConvertSingleImageBody" /* ConvertSingleImageBody */) &&
|
|
24076
|
+
((_a = clipboardData.htmlFirstLevelChildTags) === null || _a === void 0 ? void 0 : _a.length) == 1 &&
|
|
24077
|
+
clipboardData.htmlFirstLevelChildTags[0] == 'IMG');
|
|
24078
|
+
};
|
|
24079
|
+
exports.default = shouldConvertToSingleImage;
|
|
24080
|
+
|
|
24081
|
+
|
|
23523
24082
|
/***/ }),
|
|
23524
24083
|
|
|
23525
24084
|
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/wordConverter/LevelLists.ts":
|
|
@@ -24806,9 +25365,8 @@ Object.defineProperty(exports, "PickerPlugin", { enumerable: true, get: function
|
|
|
24806
25365
|
|
|
24807
25366
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24808
25367
|
var normalizeTableSelection_1 = __webpack_require__(/*! ./utils/normalizeTableSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/utils/normalizeTableSelection.ts");
|
|
24809
|
-
var
|
|
25368
|
+
var DeleteTableContents_1 = __webpack_require__(/*! ./features/DeleteTableContents */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/features/DeleteTableContents.ts");
|
|
24810
25369
|
var getCellCoordinates_1 = __webpack_require__(/*! ./utils/getCellCoordinates */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/utils/getCellCoordinates.ts");
|
|
24811
|
-
var removeCellsOutsideSelection_1 = __webpack_require__(/*! ./utils/removeCellsOutsideSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/utils/removeCellsOutsideSelection.ts");
|
|
24812
25370
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
24813
25371
|
var TABLE_CELL_SELECTOR = 'td,th';
|
|
24814
25372
|
var LEFT_CLICK = 1;
|
|
@@ -24878,30 +25436,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
24878
25436
|
_this.removeMouseUpEventListener();
|
|
24879
25437
|
}
|
|
24880
25438
|
};
|
|
24881
|
-
//#endregion
|
|
24882
|
-
//#region Content Edit Features
|
|
24883
|
-
/**
|
|
24884
|
-
* When press Backspace, delete the contents inside of the selection, if it is Table Selection
|
|
24885
|
-
*/
|
|
24886
|
-
this.DeleteTableContents = {
|
|
24887
|
-
keys: [46 /* DELETE */, 8 /* BACKSPACE */],
|
|
24888
|
-
shouldHandleEvent: function (_, editor) {
|
|
24889
|
-
var selection = editor.getSelectionRangeEx();
|
|
24890
|
-
return selection.type == 1 /* TableSelection */;
|
|
24891
|
-
},
|
|
24892
|
-
handleEvent: function (_, editor) {
|
|
24893
|
-
var selection = editor.getSelectionRangeEx();
|
|
24894
|
-
if (selection.type == 1 /* TableSelection */) {
|
|
24895
|
-
editor.addUndoSnapshot(function () {
|
|
24896
|
-
editor.getSelectedRegions().forEach(function (region) {
|
|
24897
|
-
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(region.rootNode, 'HTMLTableCellElement')) {
|
|
24898
|
-
deleteNodeContents(region.rootNode, editor);
|
|
24899
|
-
}
|
|
24900
|
-
});
|
|
24901
|
-
});
|
|
24902
|
-
}
|
|
24903
|
-
},
|
|
24904
|
-
};
|
|
24905
25439
|
this.lastTarget = null;
|
|
24906
25440
|
this.firstTarget = null;
|
|
24907
25441
|
this.tableSelection = false;
|
|
@@ -24923,7 +25457,7 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
24923
25457
|
*/
|
|
24924
25458
|
TableCellSelection.prototype.initialize = function (editor) {
|
|
24925
25459
|
this.editor = editor;
|
|
24926
|
-
this.editor.addContentEditFeature(
|
|
25460
|
+
this.editor.addContentEditFeature(DeleteTableContents_1.DeleteTableContents);
|
|
24927
25461
|
};
|
|
24928
25462
|
/**
|
|
24929
25463
|
* Dispose this plugin
|
|
@@ -24958,9 +25492,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
24958
25492
|
}
|
|
24959
25493
|
}
|
|
24960
25494
|
break;
|
|
24961
|
-
case 9 /* BeforeCutCopy */:
|
|
24962
|
-
this.handleBeforeCutCopy(event);
|
|
24963
|
-
break;
|
|
24964
25495
|
case 5 /* MouseDown */:
|
|
24965
25496
|
if (!this.startedSelection) {
|
|
24966
25497
|
this.handleMouseDownEvent(event);
|
|
@@ -25017,33 +25548,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
25017
25548
|
this.restoreSelection();
|
|
25018
25549
|
}
|
|
25019
25550
|
};
|
|
25020
|
-
/**
|
|
25021
|
-
* Handles the Before Copy Event.
|
|
25022
|
-
* Clear the selection range from the cloned Root.
|
|
25023
|
-
* @param event plugin event
|
|
25024
|
-
*/
|
|
25025
|
-
TableCellSelection.prototype.handleBeforeCutCopy = function (event) {
|
|
25026
|
-
var _this = this;
|
|
25027
|
-
var selection = this.editor.getSelectionRangeEx();
|
|
25028
|
-
if (selection.type == 1 /* TableSelection */) {
|
|
25029
|
-
var clonedTable = event.clonedRoot.querySelector('table#' + selection.table.id);
|
|
25030
|
-
if (clonedTable) {
|
|
25031
|
-
this.tableRange = selection.coordinates;
|
|
25032
|
-
var clonedVTable = new roosterjs_editor_dom_1.VTable(clonedTable);
|
|
25033
|
-
clonedVTable.selection = this.tableRange;
|
|
25034
|
-
(0, removeCellsOutsideSelection_1.removeCellsOutsideSelection)(clonedVTable);
|
|
25035
|
-
clonedVTable.writeBack();
|
|
25036
|
-
event.range.selectNode(clonedTable);
|
|
25037
|
-
if (event.isCut) {
|
|
25038
|
-
(0, forEachSelectedCell_1.forEachSelectedCell)(this.vTable, function (cell) {
|
|
25039
|
-
if (cell === null || cell === void 0 ? void 0 : cell.td) {
|
|
25040
|
-
deleteNodeContents(cell.td, _this.editor);
|
|
25041
|
-
}
|
|
25042
|
-
});
|
|
25043
|
-
}
|
|
25044
|
-
}
|
|
25045
|
-
}
|
|
25046
|
-
};
|
|
25047
25551
|
//#region Key events
|
|
25048
25552
|
/**
|
|
25049
25553
|
* Handles the on key event.
|
|
@@ -25398,12 +25902,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
25398
25902
|
return TableCellSelection;
|
|
25399
25903
|
}());
|
|
25400
25904
|
exports.default = TableCellSelection;
|
|
25401
|
-
function deleteNodeContents(element, editor) {
|
|
25402
|
-
var range = new Range();
|
|
25403
|
-
range.selectNodeContents(element);
|
|
25404
|
-
range.deleteContents();
|
|
25405
|
-
element.appendChild(editor.getDocument().createElement('br'));
|
|
25406
|
-
}
|
|
25407
25905
|
function updateSelection(editor, start, offset, end, endOffset) {
|
|
25408
25906
|
var selection = editor.getDocument().defaultView.getSelection();
|
|
25409
25907
|
end = end || start;
|
|
@@ -25426,52 +25924,64 @@ function getTableAtCursor(editor, node) {
|
|
|
25426
25924
|
|
|
25427
25925
|
/***/ }),
|
|
25428
25926
|
|
|
25429
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25430
|
-
|
|
25431
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25432
|
-
|
|
25927
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/features/DeleteTableContents.ts":
|
|
25928
|
+
/*!**********************************************************************************************************!*\
|
|
25929
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/features/DeleteTableContents.ts ***!
|
|
25930
|
+
\**********************************************************************************************************/
|
|
25433
25931
|
/*! no static exports found */
|
|
25434
25932
|
/***/ (function(module, exports, __webpack_require__) {
|
|
25435
25933
|
|
|
25436
25934
|
"use strict";
|
|
25437
25935
|
|
|
25438
25936
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25439
|
-
exports.
|
|
25440
|
-
var
|
|
25441
|
-
|
|
25937
|
+
exports.DeleteTableContents = void 0;
|
|
25938
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
25939
|
+
/**
|
|
25940
|
+
* @internal
|
|
25941
|
+
* Feature that when Backspace is pressed and there is Table Selection, delete the contents inside of the selection
|
|
25942
|
+
*/
|
|
25943
|
+
exports.DeleteTableContents = {
|
|
25944
|
+
keys: [46 /* DELETE */, 8 /* BACKSPACE */],
|
|
25945
|
+
shouldHandleEvent: function (_, editor) {
|
|
25946
|
+
var selection = editor.getSelectionRangeEx();
|
|
25947
|
+
return selection.type == 1 /* TableSelection */;
|
|
25948
|
+
},
|
|
25949
|
+
handleEvent: function (_, editor) {
|
|
25950
|
+
var selection = editor.getSelectionRangeEx();
|
|
25951
|
+
if (selection.type == 1 /* TableSelection */) {
|
|
25952
|
+
editor.addUndoSnapshot(function () {
|
|
25953
|
+
editor.getSelectedRegions().forEach(function (region) {
|
|
25954
|
+
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(region.rootNode, 'HTMLTableCellElement')) {
|
|
25955
|
+
deleteNodeContents(region.rootNode, editor);
|
|
25956
|
+
}
|
|
25957
|
+
});
|
|
25958
|
+
});
|
|
25959
|
+
}
|
|
25960
|
+
},
|
|
25961
|
+
};
|
|
25962
|
+
function deleteNodeContents(element, editor) {
|
|
25963
|
+
var range = new Range();
|
|
25964
|
+
range.selectNodeContents(element);
|
|
25965
|
+
range.deleteContents();
|
|
25966
|
+
element.appendChild(editor.getDocument().createElement('br'));
|
|
25967
|
+
}
|
|
25442
25968
|
|
|
25443
25969
|
|
|
25444
25970
|
/***/ }),
|
|
25445
25971
|
|
|
25446
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25447
|
-
|
|
25448
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25449
|
-
|
|
25972
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/index.ts":
|
|
25973
|
+
/*!***********************************************************************************!*\
|
|
25974
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/index.ts ***!
|
|
25975
|
+
\***********************************************************************************/
|
|
25450
25976
|
/*! no static exports found */
|
|
25451
25977
|
/***/ (function(module, exports, __webpack_require__) {
|
|
25452
25978
|
|
|
25453
25979
|
"use strict";
|
|
25454
25980
|
|
|
25455
25981
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25456
|
-
exports.
|
|
25457
|
-
|
|
25458
|
-
|
|
25459
|
-
* Executes an action to all the cells within the selection range.
|
|
25460
|
-
* @param callback action to apply on each selected cell
|
|
25461
|
-
* @returns the amount of cells modified
|
|
25462
|
-
*/
|
|
25463
|
-
function forEachSelectedCell(vTable, callback) {
|
|
25464
|
-
var _a;
|
|
25465
|
-
var _b = vTable.selection, lastCell = _b.lastCell, firstCell = _b.firstCell;
|
|
25466
|
-
for (var y = firstCell.y; y <= lastCell.y; y++) {
|
|
25467
|
-
for (var x = firstCell.x; x <= lastCell.x; x++) {
|
|
25468
|
-
if ((_a = vTable.cells[y][x]) === null || _a === void 0 ? void 0 : _a.td) {
|
|
25469
|
-
callback(vTable.cells[y][x]);
|
|
25470
|
-
}
|
|
25471
|
-
}
|
|
25472
|
-
}
|
|
25473
|
-
}
|
|
25474
|
-
exports.forEachSelectedCell = forEachSelectedCell;
|
|
25982
|
+
exports.TableCellSelection = void 0;
|
|
25983
|
+
var TableCellSelection_1 = __webpack_require__(/*! ./TableCellSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/TableCellSelection.ts");
|
|
25984
|
+
Object.defineProperty(exports, "TableCellSelection", { enumerable: true, get: function () { return TableCellSelection_1.default; } });
|
|
25475
25985
|
|
|
25476
25986
|
|
|
25477
25987
|
/***/ }),
|
|
@@ -25567,46 +26077,6 @@ function normalizeTableSelection(vTable) {
|
|
|
25567
26077
|
exports.default = normalizeTableSelection;
|
|
25568
26078
|
|
|
25569
26079
|
|
|
25570
|
-
/***/ }),
|
|
25571
|
-
|
|
25572
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/utils/removeCellsOutsideSelection.ts":
|
|
25573
|
-
/*!***************************************************************************************************************!*\
|
|
25574
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/utils/removeCellsOutsideSelection.ts ***!
|
|
25575
|
-
\***************************************************************************************************************/
|
|
25576
|
-
/*! no static exports found */
|
|
25577
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
25578
|
-
|
|
25579
|
-
"use strict";
|
|
25580
|
-
|
|
25581
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25582
|
-
exports.removeCellsOutsideSelection = void 0;
|
|
25583
|
-
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
25584
|
-
/**
|
|
25585
|
-
* @internal
|
|
25586
|
-
* Remove the cells outside of the selection.
|
|
25587
|
-
* @param vTable VTable to remove selection
|
|
25588
|
-
*/
|
|
25589
|
-
function removeCellsOutsideSelection(vTable) {
|
|
25590
|
-
if ((0, roosterjs_editor_dom_1.isWholeTableSelected)(vTable, vTable.selection)) {
|
|
25591
|
-
return;
|
|
25592
|
-
}
|
|
25593
|
-
var _a = vTable.selection, firstCell = _a.firstCell, lastCell = _a.lastCell;
|
|
25594
|
-
var resultCells = [];
|
|
25595
|
-
var firstX = firstCell.x;
|
|
25596
|
-
var firstY = firstCell.y;
|
|
25597
|
-
var lastX = lastCell.x;
|
|
25598
|
-
var lastY = lastCell.y;
|
|
25599
|
-
vTable.cells.forEach(function (row, y) {
|
|
25600
|
-
row = row.filter(function (_, x) { return y >= firstY && y <= lastY && x >= firstX && x <= lastX; });
|
|
25601
|
-
if (row.length > 0) {
|
|
25602
|
-
resultCells.push(row);
|
|
25603
|
-
}
|
|
25604
|
-
});
|
|
25605
|
-
vTable.cells = resultCells;
|
|
25606
|
-
}
|
|
25607
|
-
exports.removeCellsOutsideSelection = removeCellsOutsideSelection;
|
|
25608
|
-
|
|
25609
|
-
|
|
25610
26080
|
/***/ }),
|
|
25611
26081
|
|
|
25612
26082
|
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableResize/TableResize.ts":
|
|
@@ -25983,6 +26453,10 @@ var TableEditor = /** @class */ (function () {
|
|
|
25983
26453
|
_this.disposeTableResizer();
|
|
25984
26454
|
_this.onFinishEditing();
|
|
25985
26455
|
};
|
|
26456
|
+
/**
|
|
26457
|
+
* Public only for testing purposes
|
|
26458
|
+
* @param table the table to select
|
|
26459
|
+
*/
|
|
25986
26460
|
this.onSelect = function (table) {
|
|
25987
26461
|
_this.editor.focus();
|
|
25988
26462
|
if (table) {
|
|
@@ -26030,14 +26504,18 @@ var TableEditor = /** @class */ (function () {
|
|
|
26030
26504
|
var j = 0;
|
|
26031
26505
|
for (; j < tr.cells.length; j++) {
|
|
26032
26506
|
var td = tr.cells[j];
|
|
26507
|
+
var tableRect = (0, roosterjs_editor_dom_1.normalizeRect)(this.table.getBoundingClientRect());
|
|
26033
26508
|
var tdRect = (0, roosterjs_editor_dom_1.normalizeRect)(td.getBoundingClientRect());
|
|
26034
|
-
if (!tdRect) {
|
|
26509
|
+
if (!tdRect || !tableRect) {
|
|
26035
26510
|
continue;
|
|
26036
26511
|
}
|
|
26037
26512
|
var lessThanBottom = y <= tdRect.bottom;
|
|
26038
26513
|
var lessThanRight = this.isRTL ? x >= tdRect.right : x <= tdRect.right;
|
|
26039
26514
|
if (lessThanRight && lessThanBottom) {
|
|
26040
|
-
|
|
26515
|
+
var isOnLeftOrRight = this.isRTL
|
|
26516
|
+
? tdRect.right <= tableRect.right && tdRect.right >= tableRect.right - 1
|
|
26517
|
+
: tdRect.left >= tableRect.left && tdRect.left <= tableRect.left + 1;
|
|
26518
|
+
if (i === 0 && y <= tdRect.top + INSERTER_HOVER_OFFSET) {
|
|
26041
26519
|
var center = (tdRect.left + tdRect.right) / 2;
|
|
26042
26520
|
var isOnRightHalf = this.isRTL ? x < center : x > center;
|
|
26043
26521
|
this.setInserterTd(isOnRightHalf ? td : tr.cells[j - 1], false /*isHorizontal*/);
|
|
@@ -26045,10 +26523,20 @@ var TableEditor = /** @class */ (function () {
|
|
|
26045
26523
|
else if (j == 0 &&
|
|
26046
26524
|
(this.isRTL
|
|
26047
26525
|
? x >= tdRect.right - INSERTER_HOVER_OFFSET
|
|
26048
|
-
: x <= tdRect.left + INSERTER_HOVER_OFFSET)
|
|
26049
|
-
|
|
26050
|
-
|
|
26051
|
-
|
|
26526
|
+
: x <= tdRect.left + INSERTER_HOVER_OFFSET) &&
|
|
26527
|
+
isOnLeftOrRight) {
|
|
26528
|
+
var tdAbove = (_a = this.table.rows[i - 1]) === null || _a === void 0 ? void 0 : _a.cells[0];
|
|
26529
|
+
var tdAboveRect = tdAbove
|
|
26530
|
+
? (0, roosterjs_editor_dom_1.normalizeRect)(tdAbove.getBoundingClientRect())
|
|
26531
|
+
: null;
|
|
26532
|
+
var isTdNotAboveMerged = !tdAboveRect
|
|
26533
|
+
? null
|
|
26534
|
+
: this.isRTL
|
|
26535
|
+
? tdAboveRect.right === tdRect.right
|
|
26536
|
+
: tdAboveRect.left === tdRect.left;
|
|
26537
|
+
this.setInserterTd(y < (tdRect.top + tdRect.bottom) / 2 && isTdNotAboveMerged
|
|
26538
|
+
? tdAbove
|
|
26539
|
+
: td, true /*isHorizontal*/);
|
|
26052
26540
|
}
|
|
26053
26541
|
else {
|
|
26054
26542
|
this.setInserterTd(null);
|
|
@@ -26216,7 +26704,7 @@ function createTableInserter(editor, td, isRTL, isHorizontal, onInsert, onShowHe
|
|
|
26216
26704
|
div.firstChild.style.width = tableRect.right - tableRect.left + "px";
|
|
26217
26705
|
}
|
|
26218
26706
|
else {
|
|
26219
|
-
div.style.left = (isRTL ? tdRect.left : tdRect.right - 8) + "px";
|
|
26707
|
+
div.style.left = (isRTL ? tdRect.left - 8 : tdRect.right - 8) + "px";
|
|
26220
26708
|
div.style.top = tdRect.top - (INSERTER_SIDE_LENGTH - 1 + 2 * INSERTER_BORDER_SIZE) + "px";
|
|
26221
26709
|
div.firstChild.style.height = tableRect.bottom - tableRect.top + "px";
|
|
26222
26710
|
}
|
|
@@ -26489,10 +26977,11 @@ var Watermark = /** @class */ (function () {
|
|
|
26489
26977
|
* Create an instance of Watermark plugin
|
|
26490
26978
|
* @param watermark The watermark string
|
|
26491
26979
|
*/
|
|
26492
|
-
function Watermark(watermark, format) {
|
|
26980
|
+
function Watermark(watermark, format, customClass) {
|
|
26493
26981
|
var _this = this;
|
|
26494
26982
|
this.watermark = watermark;
|
|
26495
26983
|
this.format = format;
|
|
26984
|
+
this.customClass = customClass;
|
|
26496
26985
|
this.showHideWatermark = function () {
|
|
26497
26986
|
var hasFocus = _this.editor.hasFocus();
|
|
26498
26987
|
var watermarks = _this.editor.queryElements((0, roosterjs_editor_dom_1.getEntitySelector)(ENTITY_TYPE));
|
|
@@ -26502,7 +26991,10 @@ var Watermark = /** @class */ (function () {
|
|
|
26502
26991
|
_this.editor.focus();
|
|
26503
26992
|
}
|
|
26504
26993
|
else if (!hasFocus && !isShowing && _this.editor.isEmpty()) {
|
|
26505
|
-
(0, roosterjs_editor_api_1.insertEntity)(_this.editor, ENTITY_TYPE, _this.editor.getDocument().createTextNode(_this.watermark), false /*isBlock*/, false /*isReadonly*/, 0 /* Begin */);
|
|
26994
|
+
var newEntity = (0, roosterjs_editor_api_1.insertEntity)(_this.editor, ENTITY_TYPE, _this.editor.getDocument().createTextNode(_this.watermark), false /*isBlock*/, false /*isReadonly*/, 0 /* Begin */);
|
|
26995
|
+
if (_this.customClass) {
|
|
26996
|
+
newEntity.wrapper.classList.add(_this.customClass);
|
|
26997
|
+
}
|
|
26506
26998
|
}
|
|
26507
26999
|
};
|
|
26508
27000
|
this.removeWatermark = function (wrapper) {
|
|
@@ -26704,7 +27196,7 @@ var CompatibleBulletListType;
|
|
|
26704
27196
|
*/
|
|
26705
27197
|
CompatibleBulletListType[CompatibleBulletListType["ShortArrow"] = 4] = "ShortArrow";
|
|
26706
27198
|
/**
|
|
26707
|
-
* Bullet triggered by ->
|
|
27199
|
+
* Bullet triggered by ->
|
|
26708
27200
|
*/
|
|
26709
27201
|
CompatibleBulletListType[CompatibleBulletListType["LongArrow"] = 5] = "LongArrow";
|
|
26710
27202
|
/**
|
|
@@ -26715,10 +27207,14 @@ var CompatibleBulletListType;
|
|
|
26715
27207
|
* Bullet triggered by —
|
|
26716
27208
|
*/
|
|
26717
27209
|
CompatibleBulletListType[CompatibleBulletListType["Hyphen"] = 7] = "Hyphen";
|
|
27210
|
+
/**
|
|
27211
|
+
* Bullet triggered by -->
|
|
27212
|
+
*/
|
|
27213
|
+
CompatibleBulletListType[CompatibleBulletListType["DoubleLongArrow"] = 8] = "DoubleLongArrow";
|
|
26718
27214
|
/**
|
|
26719
27215
|
* Maximum value of the enum
|
|
26720
27216
|
*/
|
|
26721
|
-
CompatibleBulletListType[CompatibleBulletListType["Max"] =
|
|
27217
|
+
CompatibleBulletListType[CompatibleBulletListType["Max"] = 8] = "Max";
|
|
26722
27218
|
})(CompatibleBulletListType = exports.CompatibleBulletListType || (exports.CompatibleBulletListType = {}));
|
|
26723
27219
|
|
|
26724
27220
|
|
|
@@ -27537,7 +28033,7 @@ var CompatibleExperimentalFeatures;
|
|
|
27537
28033
|
*/
|
|
27538
28034
|
CompatibleExperimentalFeatures["ImageRotate"] = "ImageRotate";
|
|
27539
28035
|
/**
|
|
27540
|
-
*
|
|
28036
|
+
* @deprecated This feature is always enabled
|
|
27541
28037
|
*/
|
|
27542
28038
|
CompatibleExperimentalFeatures["ImageCrop"] = "ImageCrop";
|
|
27543
28039
|
/**
|