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