roosterjs 8.30.2 → 8.32.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 +256 -64
- package/dist/rooster-amd.js +1555 -575
- 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 +256 -64
- package/dist/rooster.js +1555 -575
- 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":
|
|
@@ -3092,6 +3062,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3092
3062
|
var blockFormat_1 = __webpack_require__(/*! ../utils/blockFormat */ "./packages/roosterjs-editor-api/lib/utils/blockFormat.ts");
|
|
3093
3063
|
var execCommand_1 = __webpack_require__(/*! ../utils/execCommand */ "./packages/roosterjs-editor-api/lib/utils/execCommand.ts");
|
|
3094
3064
|
var formatUndoSnapshot_1 = __webpack_require__(/*! ../utils/formatUndoSnapshot */ "./packages/roosterjs-editor-api/lib/utils/formatUndoSnapshot.ts");
|
|
3065
|
+
var normalizeBlockquote_1 = __webpack_require__(/*! ../utils/normalizeBlockquote */ "./packages/roosterjs-editor-api/lib/utils/normalizeBlockquote.ts");
|
|
3095
3066
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
3096
3067
|
/**
|
|
3097
3068
|
* Set content alignment
|
|
@@ -3160,7 +3131,14 @@ function alignText(editor, alignment) {
|
|
|
3160
3131
|
align = 'right';
|
|
3161
3132
|
}
|
|
3162
3133
|
(0, execCommand_1.default)(editor, command);
|
|
3163
|
-
editor.queryElements('[align]', 1 /* OnSelection */, function (node) {
|
|
3134
|
+
var elements = editor.queryElements('[align]', 1 /* OnSelection */, function (node) {
|
|
3135
|
+
node.style.textAlign = align;
|
|
3136
|
+
(0, normalizeBlockquote_1.default)(node);
|
|
3137
|
+
});
|
|
3138
|
+
if (elements.length == 0) {
|
|
3139
|
+
var node = editor.getElementAtCursor();
|
|
3140
|
+
(0, normalizeBlockquote_1.default)(node);
|
|
3141
|
+
}
|
|
3164
3142
|
}
|
|
3165
3143
|
function isList(element) {
|
|
3166
3144
|
return (0, roosterjs_editor_dom_1.findClosestElementAncestor)(element, undefined /** root */, 'LI');
|
|
@@ -3349,6 +3327,7 @@ exports.default = setImageAltText;
|
|
|
3349
3327
|
|
|
3350
3328
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3351
3329
|
var blockFormat_1 = __webpack_require__(/*! ../utils/blockFormat */ "./packages/roosterjs-editor-api/lib/utils/blockFormat.ts");
|
|
3330
|
+
var normalizeBlockquote_1 = __webpack_require__(/*! ../utils/normalizeBlockquote */ "./packages/roosterjs-editor-api/lib/utils/normalizeBlockquote.ts");
|
|
3352
3331
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
3353
3332
|
/**
|
|
3354
3333
|
* Set indentation at selection
|
|
@@ -3381,7 +3360,7 @@ function setIndentation(editor, indentation) {
|
|
|
3381
3360
|
indentation == 1 /* Decrease */
|
|
3382
3361
|
? vList.setIndentation(start, end, indentation, false /* softOutdent */, isTabKeyTextFeaturesEnabled /* preventItemRemoval */)
|
|
3383
3362
|
: vList.setIndentation(start, end, indentation);
|
|
3384
|
-
vList.writeBack();
|
|
3363
|
+
vList.writeBack(editor.isFeatureEnabled("ReuseAllAncestorListElements" /* ReuseAllAncestorListElements */));
|
|
3385
3364
|
blockGroups.push([]);
|
|
3386
3365
|
}
|
|
3387
3366
|
}
|
|
@@ -3405,12 +3384,14 @@ function setIndentation(editor, indentation) {
|
|
|
3405
3384
|
}
|
|
3406
3385
|
return true;
|
|
3407
3386
|
}, 'setIndentation');
|
|
3387
|
+
function indent(region, blocks) {
|
|
3388
|
+
var nodes = (0, roosterjs_editor_dom_1.collapseNodesInRegion)(region, blocks);
|
|
3389
|
+
(0, roosterjs_editor_dom_1.wrap)(nodes, 2 /* BlockquoteWrapper */);
|
|
3390
|
+
var quotesHandled = [];
|
|
3391
|
+
nodes.forEach(function (node) { return (0, normalizeBlockquote_1.default)(node, quotesHandled); });
|
|
3392
|
+
}
|
|
3408
3393
|
}
|
|
3409
3394
|
exports.default = setIndentation;
|
|
3410
|
-
function indent(region, blocks) {
|
|
3411
|
-
var nodes = (0, roosterjs_editor_dom_1.collapseNodesInRegion)(region, blocks);
|
|
3412
|
-
(0, roosterjs_editor_dom_1.wrap)(nodes, 2 /* BlockquoteWrapper */);
|
|
3413
|
-
}
|
|
3414
3395
|
function outdent(region, blocks) {
|
|
3415
3396
|
blocks.forEach(function (blockElement) {
|
|
3416
3397
|
var node = blockElement.collapseToSingleElement();
|
|
@@ -3467,7 +3448,7 @@ function setOrderedListNumbering(editor, separator, startNumber) {
|
|
|
3467
3448
|
var vList = (0, roosterjs_editor_dom_1.createVListFromRegion)(regions[0], false /*includeSiblingLists*/, separator);
|
|
3468
3449
|
if (vList) {
|
|
3469
3450
|
vList.split(separator, startNumber);
|
|
3470
|
-
vList.writeBack();
|
|
3451
|
+
vList.writeBack(editor.isFeatureEnabled("ReuseAllAncestorListElements" /* ReuseAllAncestorListElements */));
|
|
3471
3452
|
}
|
|
3472
3453
|
}
|
|
3473
3454
|
}, 'setOrderedListNumbering');
|
|
@@ -3879,7 +3860,7 @@ exports.default = toggleUnderline;
|
|
|
3879
3860
|
"use strict";
|
|
3880
3861
|
|
|
3881
3862
|
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;
|
|
3863
|
+
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
3864
|
var changeFontSize_1 = __webpack_require__(/*! ./format/changeFontSize */ "./packages/roosterjs-editor-api/lib/format/changeFontSize.ts");
|
|
3884
3865
|
Object.defineProperty(exports, "changeFontSize", { enumerable: true, get: function () { return changeFontSize_1.default; } });
|
|
3885
3866
|
Object.defineProperty(exports, "FONT_SIZES", { enumerable: true, get: function () { return changeFontSize_1.FONT_SIZES; } });
|
|
@@ -3956,8 +3937,9 @@ var toggleListType_1 = __webpack_require__(/*! ./utils/toggleListType */ "./pack
|
|
|
3956
3937
|
Object.defineProperty(exports, "toggleListType", { enumerable: true, get: function () { return toggleListType_1.default; } });
|
|
3957
3938
|
var blockFormat_1 = __webpack_require__(/*! ./utils/blockFormat */ "./packages/roosterjs-editor-api/lib/utils/blockFormat.ts");
|
|
3958
3939
|
Object.defineProperty(exports, "blockFormat", { enumerable: true, get: function () { return blockFormat_1.default; } });
|
|
3959
|
-
var
|
|
3960
|
-
Object.defineProperty(exports, "
|
|
3940
|
+
var commitListChains_1 = __webpack_require__(/*! ./utils/commitListChains */ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts");
|
|
3941
|
+
Object.defineProperty(exports, "commitListChains", { enumerable: true, get: function () { return commitListChains_1.default; } });
|
|
3942
|
+
Object.defineProperty(exports, "experimentCommitListChains", { enumerable: true, get: function () { return commitListChains_1.experimentCommitListChains; } });
|
|
3961
3943
|
|
|
3962
3944
|
|
|
3963
3945
|
/***/ }),
|
|
@@ -3974,8 +3956,6 @@ Object.defineProperty(exports, "experimentCommitListChains", { enumerable: true,
|
|
|
3974
3956
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3975
3957
|
var formatUndoSnapshot_1 = __webpack_require__(/*! ../utils/formatUndoSnapshot */ "./packages/roosterjs-editor-api/lib/utils/formatUndoSnapshot.ts");
|
|
3976
3958
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
3977
|
-
var TEMP_BACKGROUND_COLOR = 'originalBackgroundColor';
|
|
3978
|
-
var CELL_SHADE = 'cellShade';
|
|
3979
3959
|
/**
|
|
3980
3960
|
* Set background color of cells.
|
|
3981
3961
|
* @param editor The editor instance
|
|
@@ -3988,9 +3968,7 @@ function applyCellShading(editor, color) {
|
|
|
3988
3968
|
regions.forEach(function (region) {
|
|
3989
3969
|
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(region.rootNode, 'HTMLTableCellElement')) {
|
|
3990
3970
|
(0, roosterjs_editor_dom_1.setColor)(region.rootNode, color, true /* isBackgroundColor */, editor.isDarkMode(), true /** shouldAdaptFontColor */);
|
|
3991
|
-
region.rootNode
|
|
3992
|
-
region.rootNode.dataset[TEMP_BACKGROUND_COLOR] =
|
|
3993
|
-
region.rootNode.style.backgroundColor;
|
|
3971
|
+
(0, roosterjs_editor_dom_1.saveTableCellMetadata)(region.rootNode, { bgColorOverride: true });
|
|
3994
3972
|
}
|
|
3995
3973
|
});
|
|
3996
3974
|
}, 'applyCellShading');
|
|
@@ -4320,7 +4298,7 @@ function applyStyleToListItems(parentNodes, styles) {
|
|
|
4320
4298
|
"use strict";
|
|
4321
4299
|
|
|
4322
4300
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4323
|
-
var
|
|
4301
|
+
var commitListChains_1 = __webpack_require__(/*! ../utils/commitListChains */ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts");
|
|
4324
4302
|
var formatUndoSnapshot_1 = __webpack_require__(/*! ./formatUndoSnapshot */ "./packages/roosterjs-editor-api/lib/utils/formatUndoSnapshot.ts");
|
|
4325
4303
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
4326
4304
|
/**
|
|
@@ -4334,7 +4312,7 @@ function blockFormat(editor, callback, beforeRunCallback, apiName) {
|
|
|
4334
4312
|
var regions = editor.getSelectedRegions();
|
|
4335
4313
|
var chains_1 = roosterjs_editor_dom_1.VListChain.createListChains(regions, start === null || start === void 0 ? void 0 : start.node);
|
|
4336
4314
|
regions.forEach(function (region) { return callback(region, start, end, chains_1); });
|
|
4337
|
-
(0,
|
|
4315
|
+
(0, commitListChains_1.default)(editor, chains_1);
|
|
4338
4316
|
}
|
|
4339
4317
|
if (selection.type == 0 /* Normal */) {
|
|
4340
4318
|
editor.select(start, end);
|
|
@@ -4439,6 +4417,43 @@ function isEmptyBlockUnderTR(block) {
|
|
|
4439
4417
|
}
|
|
4440
4418
|
|
|
4441
4419
|
|
|
4420
|
+
/***/ }),
|
|
4421
|
+
|
|
4422
|
+
/***/ "./packages/roosterjs-editor-api/lib/utils/commitListChains.ts":
|
|
4423
|
+
/*!*********************************************************************!*\
|
|
4424
|
+
!*** ./packages/roosterjs-editor-api/lib/utils/commitListChains.ts ***!
|
|
4425
|
+
\*********************************************************************/
|
|
4426
|
+
/*! no static exports found */
|
|
4427
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
4428
|
+
|
|
4429
|
+
"use strict";
|
|
4430
|
+
|
|
4431
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4432
|
+
exports.experimentCommitListChains = void 0;
|
|
4433
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
4434
|
+
/**
|
|
4435
|
+
* Commit changes of all list changes when experiment features are allowed
|
|
4436
|
+
* @param editor The Editor object
|
|
4437
|
+
* @param chains List chains to commit
|
|
4438
|
+
*/
|
|
4439
|
+
function commitListChains(editor, chains) {
|
|
4440
|
+
if ((chains === null || chains === void 0 ? void 0 : chains.length) > 0) {
|
|
4441
|
+
var range = editor.getSelectionRange();
|
|
4442
|
+
var start = range && roosterjs_editor_dom_1.Position.getStart(range);
|
|
4443
|
+
var end = range && roosterjs_editor_dom_1.Position.getEnd(range);
|
|
4444
|
+
var shouldReuseAllAncestorListElements_1 = editor.isFeatureEnabled("ReuseAllAncestorListElements" /* ReuseAllAncestorListElements */);
|
|
4445
|
+
chains.forEach(function (chain) { return chain.commit(shouldReuseAllAncestorListElements_1); });
|
|
4446
|
+
editor.select(start, end);
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
exports.default = commitListChains;
|
|
4450
|
+
/**
|
|
4451
|
+
* @deprecated
|
|
4452
|
+
* Same with commitListChains, keep this export just for backward compatibility
|
|
4453
|
+
*/
|
|
4454
|
+
exports.experimentCommitListChains = commitListChains;
|
|
4455
|
+
|
|
4456
|
+
|
|
4442
4457
|
/***/ }),
|
|
4443
4458
|
|
|
4444
4459
|
/***/ "./packages/roosterjs-editor-api/lib/utils/execCommand.ts":
|
|
@@ -4526,6 +4541,61 @@ function formatUndoSnapshot(editor, callback, apiName) {
|
|
|
4526
4541
|
exports.default = formatUndoSnapshot;
|
|
4527
4542
|
|
|
4528
4543
|
|
|
4544
|
+
/***/ }),
|
|
4545
|
+
|
|
4546
|
+
/***/ "./packages/roosterjs-editor-api/lib/utils/normalizeBlockquote.ts":
|
|
4547
|
+
/*!************************************************************************!*\
|
|
4548
|
+
!*** ./packages/roosterjs-editor-api/lib/utils/normalizeBlockquote.ts ***!
|
|
4549
|
+
\************************************************************************/
|
|
4550
|
+
/*! no static exports found */
|
|
4551
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
4552
|
+
|
|
4553
|
+
"use strict";
|
|
4554
|
+
|
|
4555
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4556
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
4557
|
+
/**
|
|
4558
|
+
* @internal
|
|
4559
|
+
* @param node start node to normalize
|
|
4560
|
+
* @param quotesHandled Optional parameter to prevent already modified quotes to be rechecked.
|
|
4561
|
+
* @returns
|
|
4562
|
+
*/
|
|
4563
|
+
function normalizeBlockquote(node, quotesHandled) {
|
|
4564
|
+
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(node, 'HTMLElement')) {
|
|
4565
|
+
var alignment = node.style.textAlign;
|
|
4566
|
+
var quote = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(node, undefined /* root */, 'blockquote');
|
|
4567
|
+
var isNodeRTL = isRTL(node);
|
|
4568
|
+
if (quotesHandled) {
|
|
4569
|
+
if (quotesHandled.indexOf(quote) > -1) {
|
|
4570
|
+
return;
|
|
4571
|
+
}
|
|
4572
|
+
quotesHandled.push(quote);
|
|
4573
|
+
}
|
|
4574
|
+
while (quote) {
|
|
4575
|
+
if (alignment == 'center') {
|
|
4576
|
+
if (isNodeRTL) {
|
|
4577
|
+
delete quote.style.marginInlineEnd;
|
|
4578
|
+
quote.style.marginInlineStart = 'auto';
|
|
4579
|
+
}
|
|
4580
|
+
else {
|
|
4581
|
+
delete quote.style.marginInlineStart;
|
|
4582
|
+
quote.style.marginInlineEnd = 'auto';
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
else {
|
|
4586
|
+
delete quote.style.marginInlineStart;
|
|
4587
|
+
delete quote.style.marginInlineEnd;
|
|
4588
|
+
}
|
|
4589
|
+
quote = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(quote.parentElement, undefined /* root */, 'blockquote');
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
exports.default = normalizeBlockquote;
|
|
4594
|
+
function isRTL(el) {
|
|
4595
|
+
return (0, roosterjs_editor_dom_1.getComputedStyle)(el, 'direction') == 'rtl' || el.getAttribute('dir') == 'rtl';
|
|
4596
|
+
}
|
|
4597
|
+
|
|
4598
|
+
|
|
4529
4599
|
/***/ }),
|
|
4530
4600
|
|
|
4531
4601
|
/***/ "./packages/roosterjs-editor-api/lib/utils/toggleListType.ts":
|
|
@@ -4573,7 +4643,7 @@ function toggleListType(editor, listType, startNumber, includeSiblingLists, orde
|
|
|
4573
4643
|
if (editor.isFeatureEnabled("AutoFormatList" /* AutoFormatList */)) {
|
|
4574
4644
|
vList.setListStyleType(orderedStyle, unorderedStyle);
|
|
4575
4645
|
}
|
|
4576
|
-
vList.writeBack();
|
|
4646
|
+
vList.writeBack(editor.isFeatureEnabled("ReuseAllAncestorListElements" /* ReuseAllAncestorListElements */));
|
|
4577
4647
|
}
|
|
4578
4648
|
}, undefined /* beforeRunCallback */, apiNameOverride || 'toggleListType');
|
|
4579
4649
|
}
|
|
@@ -4759,6 +4829,7 @@ var getStyleBasedFormatState_1 = __webpack_require__(/*! ./getStyleBasedFormatSt
|
|
|
4759
4829
|
var hasFocus_1 = __webpack_require__(/*! ./hasFocus */ "./packages/roosterjs-editor-core/lib/coreApi/hasFocus.ts");
|
|
4760
4830
|
var insertNode_1 = __webpack_require__(/*! ./insertNode */ "./packages/roosterjs-editor-core/lib/coreApi/insertNode.ts");
|
|
4761
4831
|
var restoreUndoSnapshot_1 = __webpack_require__(/*! ./restoreUndoSnapshot */ "./packages/roosterjs-editor-core/lib/coreApi/restoreUndoSnapshot.ts");
|
|
4832
|
+
var selectImage_1 = __webpack_require__(/*! ./selectImage */ "./packages/roosterjs-editor-core/lib/coreApi/selectImage.ts");
|
|
4762
4833
|
var selectRange_1 = __webpack_require__(/*! ./selectRange */ "./packages/roosterjs-editor-core/lib/coreApi/selectRange.ts");
|
|
4763
4834
|
var selectTable_1 = __webpack_require__(/*! ./selectTable */ "./packages/roosterjs-editor-core/lib/coreApi/selectTable.ts");
|
|
4764
4835
|
var setContent_1 = __webpack_require__(/*! ./setContent */ "./packages/roosterjs-editor-core/lib/coreApi/setContent.ts");
|
|
@@ -4788,6 +4859,7 @@ exports.coreApiMap = {
|
|
|
4788
4859
|
transformColor: transformColor_1.transformColor,
|
|
4789
4860
|
triggerEvent: triggerEvent_1.triggerEvent,
|
|
4790
4861
|
selectTable: selectTable_1.selectTable,
|
|
4862
|
+
selectImage: selectImage_1.selectImage,
|
|
4791
4863
|
};
|
|
4792
4864
|
|
|
4793
4865
|
|
|
@@ -4902,7 +4974,7 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4902
4974
|
.replace(/\r/g, '')
|
|
4903
4975
|
.replace(/ {2}/g, ' ' + NBSP_HTML);
|
|
4904
4976
|
if (line.includes('\t')) {
|
|
4905
|
-
line = transformTabCharacters(line, index === 0 ? position.offset : 0);
|
|
4977
|
+
line = transformTabCharacters(line, index === 0 ? position === null || position === void 0 ? void 0 : position.offset : 0);
|
|
4906
4978
|
}
|
|
4907
4979
|
var textNode = document.createTextNode(line);
|
|
4908
4980
|
// There are 3 scenarios:
|
|
@@ -4929,7 +5001,7 @@ var createPasteFragment = function (core, clipboardData, position, pasteAsText,
|
|
|
4929
5001
|
// Step 5. Sanitize the fragment before paste to make sure the content is safe
|
|
4930
5002
|
var sanitizer = new roosterjs_editor_dom_1.HtmlSanitizer(event.sanitizingOption);
|
|
4931
5003
|
sanitizer.convertGlobalCssToInlineCss(fragment);
|
|
4932
|
-
sanitizer.sanitize(fragment, position
|
|
5004
|
+
sanitizer.sanitize(fragment, position ? (0, roosterjs_editor_dom_1.getInheritableStyles)(position.element) : undefined);
|
|
4933
5005
|
return fragment;
|
|
4934
5006
|
};
|
|
4935
5007
|
exports.createPasteFragment = createPasteFragment;
|
|
@@ -4969,11 +5041,14 @@ function getCurrentFormat(core, node) {
|
|
|
4969
5041
|
};
|
|
4970
5042
|
}
|
|
4971
5043
|
function createBeforePasteEvent(core, clipboardData) {
|
|
5044
|
+
var options = (0, roosterjs_editor_dom_1.createDefaultHtmlSanitizerOptions)();
|
|
5045
|
+
// Remove "caret-color" style generated by Safari to make sure caret shows in right color after paste
|
|
5046
|
+
options.cssStyleCallbacks['caret-color'] = function () { return false; };
|
|
4972
5047
|
return {
|
|
4973
5048
|
eventType: 10 /* BeforePaste */,
|
|
4974
5049
|
clipboardData: clipboardData,
|
|
4975
5050
|
fragment: core.contentDiv.ownerDocument.createDocumentFragment(),
|
|
4976
|
-
sanitizingOption:
|
|
5051
|
+
sanitizingOption: options,
|
|
4977
5052
|
htmlBefore: '',
|
|
4978
5053
|
htmlAfter: '',
|
|
4979
5054
|
htmlAttributes: {},
|
|
@@ -5226,6 +5301,12 @@ var PendableStyleCheckers = {
|
|
|
5226
5301
|
isBold: function (tag, style) {
|
|
5227
5302
|
return tag == 'B' ||
|
|
5228
5303
|
tag == 'STRONG' ||
|
|
5304
|
+
tag == 'H1' ||
|
|
5305
|
+
tag == 'H2' ||
|
|
5306
|
+
tag == 'H3' ||
|
|
5307
|
+
tag == 'H4' ||
|
|
5308
|
+
tag == 'H5' ||
|
|
5309
|
+
tag == 'H6' ||
|
|
5229
5310
|
parseInt(style.fontWeight) >= 700 ||
|
|
5230
5311
|
['bold', 'bolder'].indexOf(style.fontWeight) >= 0;
|
|
5231
5312
|
},
|
|
@@ -5351,10 +5432,10 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
|
|
|
5351
5432
|
* @returns A Range object of the selection range
|
|
5352
5433
|
*/
|
|
5353
5434
|
var getSelectionRangeEx = function (core) {
|
|
5354
|
-
var _a, _b;
|
|
5435
|
+
var _a, _b, _c;
|
|
5355
5436
|
var result = null;
|
|
5356
5437
|
if (core.lifecycle.shadowEditFragment) {
|
|
5357
|
-
var
|
|
5438
|
+
var _d = core.lifecycle, shadowEditTableSelectionPath = _d.shadowEditTableSelectionPath, shadowEditSelectionPath = _d.shadowEditSelectionPath, shadowEditImageSelectionPath = _d.shadowEditImageSelectionPath;
|
|
5358
5439
|
if (((shadowEditTableSelectionPath === null || shadowEditTableSelectionPath === void 0 ? void 0 : shadowEditTableSelectionPath.length) || 0) > 0) {
|
|
5359
5440
|
var ranges = core.lifecycle.shadowEditTableSelectionPath.map(function (path) {
|
|
5360
5441
|
return (0, roosterjs_editor_dom_1.createRange)(core.contentDiv, path.start, path.end);
|
|
@@ -5367,6 +5448,18 @@ var getSelectionRangeEx = function (core) {
|
|
|
5367
5448
|
coordinates: undefined,
|
|
5368
5449
|
};
|
|
5369
5450
|
}
|
|
5451
|
+
else if (((shadowEditImageSelectionPath === null || shadowEditImageSelectionPath === void 0 ? void 0 : shadowEditImageSelectionPath.length) || 0) > 0) {
|
|
5452
|
+
var ranges = core.lifecycle.shadowEditImageSelectionPath.map(function (path) {
|
|
5453
|
+
return (0, roosterjs_editor_dom_1.createRange)(core.contentDiv, path.start, path.end);
|
|
5454
|
+
});
|
|
5455
|
+
return {
|
|
5456
|
+
type: 2 /* ImageSelection */,
|
|
5457
|
+
ranges: ranges,
|
|
5458
|
+
areAllCollapsed: checkAllCollapsed(ranges),
|
|
5459
|
+
image: (0, roosterjs_editor_dom_1.findClosestElementAncestor)(ranges[0].startContainer, core.contentDiv, 'img'),
|
|
5460
|
+
imageId: undefined,
|
|
5461
|
+
};
|
|
5462
|
+
}
|
|
5370
5463
|
else {
|
|
5371
5464
|
var shadowRange = shadowEditSelectionPath &&
|
|
5372
5465
|
(0, roosterjs_editor_dom_1.createRange)(core.contentDiv, shadowEditSelectionPath.start, shadowEditSelectionPath.end);
|
|
@@ -5378,6 +5471,9 @@ var getSelectionRangeEx = function (core) {
|
|
|
5378
5471
|
if (core.domEvent.tableSelectionRange) {
|
|
5379
5472
|
return core.domEvent.tableSelectionRange;
|
|
5380
5473
|
}
|
|
5474
|
+
if (core.domEvent.imageSelectionRange) {
|
|
5475
|
+
return core.domEvent.imageSelectionRange;
|
|
5476
|
+
}
|
|
5381
5477
|
var selection = (_a = core.contentDiv.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
5382
5478
|
if (!result && selection && selection.rangeCount > 0) {
|
|
5383
5479
|
var range = selection.getRangeAt(0);
|
|
@@ -5386,7 +5482,7 @@ var getSelectionRangeEx = function (core) {
|
|
|
5386
5482
|
}
|
|
5387
5483
|
}
|
|
5388
5484
|
}
|
|
5389
|
-
return ((_b = core.domEvent.tableSelectionRange) !== null && _b !== void 0 ? _b : createNormalSelectionEx(core.domEvent.selectionRange ? [core.domEvent.selectionRange] : []));
|
|
5485
|
+
return ((_c = (_b = core.domEvent.tableSelectionRange) !== null && _b !== void 0 ? _b : core.domEvent.imageSelectionRange) !== null && _c !== void 0 ? _c : createNormalSelectionEx(core.domEvent.selectionRange ? [core.domEvent.selectionRange] : []));
|
|
5390
5486
|
}
|
|
5391
5487
|
};
|
|
5392
5488
|
exports.getSelectionRangeEx = getSelectionRangeEx;
|
|
@@ -5556,6 +5652,9 @@ var insertNode = function (core, node, option) {
|
|
|
5556
5652
|
}
|
|
5557
5653
|
core.api.transformColor(core, node, true /*includeSelf*/, function () {
|
|
5558
5654
|
var _a, _b;
|
|
5655
|
+
if (!option) {
|
|
5656
|
+
return;
|
|
5657
|
+
}
|
|
5559
5658
|
switch (option.position) {
|
|
5560
5659
|
case 0 /* Begin */:
|
|
5561
5660
|
case 1 /* End */: {
|
|
@@ -5693,6 +5792,71 @@ var restoreUndoSnapshot = function (core, step) {
|
|
|
5693
5792
|
exports.restoreUndoSnapshot = restoreUndoSnapshot;
|
|
5694
5793
|
|
|
5695
5794
|
|
|
5795
|
+
/***/ }),
|
|
5796
|
+
|
|
5797
|
+
/***/ "./packages/roosterjs-editor-core/lib/coreApi/selectImage.ts":
|
|
5798
|
+
/*!*******************************************************************!*\
|
|
5799
|
+
!*** ./packages/roosterjs-editor-core/lib/coreApi/selectImage.ts ***!
|
|
5800
|
+
\*******************************************************************/
|
|
5801
|
+
/*! no static exports found */
|
|
5802
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
5803
|
+
|
|
5804
|
+
"use strict";
|
|
5805
|
+
|
|
5806
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5807
|
+
exports.selectImage = void 0;
|
|
5808
|
+
var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
|
|
5809
|
+
var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
|
|
5810
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
5811
|
+
var IMAGE_ID = 'imageSelected';
|
|
5812
|
+
var CONTENT_DIV_ID = 'contentDiv_';
|
|
5813
|
+
var STYLE_ID = 'imageStyle';
|
|
5814
|
+
/**
|
|
5815
|
+
* @internal
|
|
5816
|
+
* Select a image and save data of the selected range
|
|
5817
|
+
* @param image Image to select
|
|
5818
|
+
* @returns Selected image information
|
|
5819
|
+
*/
|
|
5820
|
+
var selectImage = function (core, image) {
|
|
5821
|
+
unselect(core);
|
|
5822
|
+
if (image) {
|
|
5823
|
+
var range = (0, roosterjs_editor_dom_1.createRange)(image);
|
|
5824
|
+
(0, addUniqueId_1.default)(image, IMAGE_ID);
|
|
5825
|
+
(0, addUniqueId_1.default)(core.contentDiv, CONTENT_DIV_ID);
|
|
5826
|
+
select(core, image);
|
|
5827
|
+
return {
|
|
5828
|
+
type: 2 /* ImageSelection */,
|
|
5829
|
+
ranges: [range],
|
|
5830
|
+
image: image,
|
|
5831
|
+
areAllCollapsed: range.collapsed,
|
|
5832
|
+
};
|
|
5833
|
+
}
|
|
5834
|
+
return null;
|
|
5835
|
+
};
|
|
5836
|
+
exports.selectImage = selectImage;
|
|
5837
|
+
var select = function (core, image) {
|
|
5838
|
+
var borderCSS = buildBorderCSS(core, image.id);
|
|
5839
|
+
(0, addSelectionStyle_1.default)(core, borderCSS, STYLE_ID);
|
|
5840
|
+
};
|
|
5841
|
+
var buildBorderCSS = function (core, imageId) {
|
|
5842
|
+
var borderColor = core.imageSelectionBorderColor || '#DB626C';
|
|
5843
|
+
return ('#' +
|
|
5844
|
+
core.contentDiv.id +
|
|
5845
|
+
' #' +
|
|
5846
|
+
imageId +
|
|
5847
|
+
' { margin: -2px; border: 2px solid' +
|
|
5848
|
+
borderColor +
|
|
5849
|
+
' !important; }');
|
|
5850
|
+
};
|
|
5851
|
+
var unselect = function (core) {
|
|
5852
|
+
var doc = core.contentDiv.ownerDocument;
|
|
5853
|
+
var styleTag = doc.getElementById(STYLE_ID + core.contentDiv.id);
|
|
5854
|
+
if (styleTag) {
|
|
5855
|
+
doc.head.removeChild(styleTag);
|
|
5856
|
+
}
|
|
5857
|
+
};
|
|
5858
|
+
|
|
5859
|
+
|
|
5696
5860
|
/***/ }),
|
|
5697
5861
|
|
|
5698
5862
|
/***/ "./packages/roosterjs-editor-core/lib/coreApi/selectRange.ts":
|
|
@@ -5770,6 +5934,8 @@ function restorePendingFormatState(core) {
|
|
|
5770
5934
|
|
|
5771
5935
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5772
5936
|
exports.selectTable = void 0;
|
|
5937
|
+
var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
|
|
5938
|
+
var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
|
|
5773
5939
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
5774
5940
|
var TABLE_ID = 'tableSelected';
|
|
5775
5941
|
var CONTENT_DIV_ID = 'contentDiv_';
|
|
@@ -5787,8 +5953,8 @@ var selectTable = function (core, table, coordinates) {
|
|
|
5787
5953
|
var _a;
|
|
5788
5954
|
unselect(core);
|
|
5789
5955
|
if (areValidCoordinates(coordinates) && table) {
|
|
5790
|
-
|
|
5791
|
-
|
|
5956
|
+
(0, addUniqueId_1.default)(table, TABLE_ID);
|
|
5957
|
+
(0, addUniqueId_1.default)(core.contentDiv, CONTENT_DIV_ID);
|
|
5792
5958
|
var ranges = select(core, table, coordinates);
|
|
5793
5959
|
if (!isMergedCell(table, coordinates)) {
|
|
5794
5960
|
var cellToSelect = (_a = table.rows
|
|
@@ -5874,17 +6040,9 @@ function buildCss(table, coordinates, contentDivSelector) {
|
|
|
5874
6040
|
return { css: css, ranges: ranges };
|
|
5875
6041
|
}
|
|
5876
6042
|
function select(core, table, coordinates) {
|
|
5877
|
-
var _a;
|
|
5878
|
-
var doc = core.contentDiv.ownerDocument;
|
|
5879
6043
|
var contentDivSelector = '#' + core.contentDiv.id;
|
|
5880
|
-
var
|
|
5881
|
-
|
|
5882
|
-
if (!styleElement) {
|
|
5883
|
-
styleElement = doc.createElement('style');
|
|
5884
|
-
doc.head.appendChild(styleElement);
|
|
5885
|
-
styleElement.id = STYLE_ID + core.contentDiv.id;
|
|
5886
|
-
}
|
|
5887
|
-
(_a = styleElement.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(css);
|
|
6044
|
+
var _a = buildCss(table, coordinates, contentDivSelector), css = _a.css, ranges = _a.ranges;
|
|
6045
|
+
(0, addSelectionStyle_1.default)(core, css, STYLE_ID);
|
|
5888
6046
|
return ranges;
|
|
5889
6047
|
}
|
|
5890
6048
|
function unselect(core) {
|
|
@@ -5897,27 +6055,6 @@ function unselect(core) {
|
|
|
5897
6055
|
}
|
|
5898
6056
|
}
|
|
5899
6057
|
}
|
|
5900
|
-
function ensureUniqueId(el, idPrefix) {
|
|
5901
|
-
var doc = el.ownerDocument;
|
|
5902
|
-
if (!el.id) {
|
|
5903
|
-
var cont_1 = 0;
|
|
5904
|
-
var getElement = function () { return doc.getElementById(idPrefix + cont_1); };
|
|
5905
|
-
//Ensure that there are no elements with the same ID
|
|
5906
|
-
var element = getElement();
|
|
5907
|
-
while (element) {
|
|
5908
|
-
cont_1++;
|
|
5909
|
-
element = getElement();
|
|
5910
|
-
}
|
|
5911
|
-
el.id = idPrefix + cont_1;
|
|
5912
|
-
}
|
|
5913
|
-
else {
|
|
5914
|
-
var elements = doc.querySelectorAll("#" + el.id);
|
|
5915
|
-
if (elements.length > 1) {
|
|
5916
|
-
el.removeAttribute('id');
|
|
5917
|
-
ensureUniqueId(el, idPrefix);
|
|
5918
|
-
}
|
|
5919
|
-
}
|
|
5920
|
-
}
|
|
5921
6058
|
function generateCssFromCell(contentDivSelector, tableId, middleElSelector, rowIndex, cellTag, index) {
|
|
5922
6059
|
return (contentDivSelector +
|
|
5923
6060
|
' #' +
|
|
@@ -6053,20 +6190,23 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
|
|
|
6053
6190
|
*/
|
|
6054
6191
|
var switchShadowEdit = function (core, isOn) {
|
|
6055
6192
|
var lifecycle = core.lifecycle, contentDiv = core.contentDiv;
|
|
6056
|
-
var shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath;
|
|
6193
|
+
var shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath, shadowEditImageSelectionPath = lifecycle.shadowEditImageSelectionPath;
|
|
6057
6194
|
var wasInShadowEdit = !!shadowEditFragment;
|
|
6195
|
+
var getShadowEditSelectionPath = function (selectionType, shadowEditSelection) {
|
|
6196
|
+
return (((shadowEditSelection === null || shadowEditSelection === void 0 ? void 0 : shadowEditSelection.type) == selectionType &&
|
|
6197
|
+
shadowEditSelection.ranges
|
|
6198
|
+
.map(function (range) { return (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range); })
|
|
6199
|
+
.map(function (w) { return w; })) ||
|
|
6200
|
+
null);
|
|
6201
|
+
};
|
|
6058
6202
|
if (isOn) {
|
|
6059
6203
|
if (!wasInShadowEdit) {
|
|
6060
6204
|
var selection = core.api.getSelectionRangeEx(core);
|
|
6061
6205
|
var range = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
|
|
6062
6206
|
shadowEditSelectionPath = range && (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range);
|
|
6063
|
-
shadowEditTableSelectionPath =
|
|
6064
|
-
((selection === null || selection === void 0 ? void 0 : selection.type) == 1 /* TableSelection */ &&
|
|
6065
|
-
selection.ranges
|
|
6066
|
-
.map(function (range) { return (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range); })
|
|
6067
|
-
.map(function (w) { return w; })) ||
|
|
6068
|
-
null;
|
|
6207
|
+
shadowEditTableSelectionPath = getShadowEditSelectionPath(1 /* TableSelection */, selection);
|
|
6069
6208
|
shadowEditFragment = core.contentDiv.ownerDocument.createDocumentFragment();
|
|
6209
|
+
shadowEditImageSelectionPath = getShadowEditSelectionPath(2 /* ImageSelection */, selection);
|
|
6070
6210
|
(0, roosterjs_editor_dom_1.moveChildNodes)(shadowEditFragment, contentDiv);
|
|
6071
6211
|
shadowEditFragment.normalize();
|
|
6072
6212
|
core.api.triggerEvent(core, {
|
|
@@ -6077,6 +6217,7 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
6077
6217
|
lifecycle.shadowEditFragment = shadowEditFragment;
|
|
6078
6218
|
lifecycle.shadowEditSelectionPath = shadowEditSelectionPath;
|
|
6079
6219
|
lifecycle.shadowEditTableSelectionPath = shadowEditTableSelectionPath;
|
|
6220
|
+
lifecycle.shadowEditImageSelectionPath = shadowEditImageSelectionPath;
|
|
6080
6221
|
}
|
|
6081
6222
|
(0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
|
|
6082
6223
|
if (lifecycle.shadowEditFragment) {
|
|
@@ -6098,6 +6239,13 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
6098
6239
|
if (shadowEditSelectionPath) {
|
|
6099
6240
|
core.api.selectRange(core, (0, roosterjs_editor_dom_1.createRange)(contentDiv, shadowEditSelectionPath.start, shadowEditSelectionPath.end));
|
|
6100
6241
|
}
|
|
6242
|
+
if (core.domEvent.imageSelectionRange) {
|
|
6243
|
+
var image = core.domEvent.imageSelectionRange.image;
|
|
6244
|
+
var imageElement = core.contentDiv.querySelector('#' + image.id);
|
|
6245
|
+
if (imageElement) {
|
|
6246
|
+
core.domEvent.imageSelectionRange = core.api.selectImage(core, image);
|
|
6247
|
+
}
|
|
6248
|
+
}
|
|
6101
6249
|
if (core.domEvent.tableSelectionRange) {
|
|
6102
6250
|
var _a = core.domEvent.tableSelectionRange, table = _a.table, coordinates = _a.coordinates;
|
|
6103
6251
|
var tableId = table.id;
|
|
@@ -6153,7 +6301,9 @@ var ColorAttributeName = [
|
|
|
6153
6301
|
* Pass true to this value to force do color transformation even editor core is in light mode
|
|
6154
6302
|
*/
|
|
6155
6303
|
var transformColor = function (core, rootNode, includeSelf, callback, direction, forceTransform) {
|
|
6156
|
-
var elements = forceTransform || core.lifecycle.isDarkMode
|
|
6304
|
+
var elements = rootNode && (forceTransform || core.lifecycle.isDarkMode)
|
|
6305
|
+
? getAll(rootNode, includeSelf)
|
|
6306
|
+
: [];
|
|
6157
6307
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
6158
6308
|
if (direction == 1 /* DarkToLight */) {
|
|
6159
6309
|
transformToLightMode(elements);
|
|
@@ -6296,6 +6446,83 @@ function handledExclusively(event, plugin) {
|
|
|
6296
6446
|
}
|
|
6297
6447
|
|
|
6298
6448
|
|
|
6449
|
+
/***/ }),
|
|
6450
|
+
|
|
6451
|
+
/***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts":
|
|
6452
|
+
/*!*******************************************************************************!*\
|
|
6453
|
+
!*** ./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts ***!
|
|
6454
|
+
\*******************************************************************************/
|
|
6455
|
+
/*! no static exports found */
|
|
6456
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
6457
|
+
|
|
6458
|
+
"use strict";
|
|
6459
|
+
|
|
6460
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6461
|
+
/**
|
|
6462
|
+
* Add style to selected elements
|
|
6463
|
+
* @param core The Editor core object
|
|
6464
|
+
* @param cssRule The css rule that must added to the selection
|
|
6465
|
+
* @param styleId the ID of the style tag
|
|
6466
|
+
*/
|
|
6467
|
+
function addSelectionStyle(core, cssRule, styleId) {
|
|
6468
|
+
var _a;
|
|
6469
|
+
var styleTagId = styleId + core.contentDiv.id;
|
|
6470
|
+
var doc = core.contentDiv.ownerDocument;
|
|
6471
|
+
var styleTag = doc.getElementById(styleTagId);
|
|
6472
|
+
if (!styleTag) {
|
|
6473
|
+
styleTag = doc.createElement('style');
|
|
6474
|
+
styleTag.id = styleTagId;
|
|
6475
|
+
doc.head.appendChild(styleTag);
|
|
6476
|
+
}
|
|
6477
|
+
(_a = styleTag.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssRule);
|
|
6478
|
+
}
|
|
6479
|
+
exports.default = addSelectionStyle;
|
|
6480
|
+
|
|
6481
|
+
|
|
6482
|
+
/***/ }),
|
|
6483
|
+
|
|
6484
|
+
/***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts":
|
|
6485
|
+
/*!*************************************************************************!*\
|
|
6486
|
+
!*** ./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts ***!
|
|
6487
|
+
\*************************************************************************/
|
|
6488
|
+
/*! no static exports found */
|
|
6489
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
6490
|
+
|
|
6491
|
+
"use strict";
|
|
6492
|
+
|
|
6493
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6494
|
+
/**
|
|
6495
|
+
* Add an unique id to element and ensure that is unique
|
|
6496
|
+
* @param el The HTMLElement that will receive the id
|
|
6497
|
+
* @param idPrefix The prefix that will antecede the id (Ex: tableSelected01)
|
|
6498
|
+
*/
|
|
6499
|
+
function addUniqueId(el, idPrefix) {
|
|
6500
|
+
var doc = el.ownerDocument;
|
|
6501
|
+
if (!el.id) {
|
|
6502
|
+
applyId(el, idPrefix, doc);
|
|
6503
|
+
}
|
|
6504
|
+
else {
|
|
6505
|
+
var elements = doc.querySelectorAll("#" + el.id);
|
|
6506
|
+
if (elements.length > 1) {
|
|
6507
|
+
el.removeAttribute('id');
|
|
6508
|
+
applyId(el, idPrefix, doc);
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
exports.default = addUniqueId;
|
|
6513
|
+
function applyId(el, idPrefix, doc) {
|
|
6514
|
+
var cont = 0;
|
|
6515
|
+
var getElement = function () { return doc.getElementById(idPrefix + cont); };
|
|
6516
|
+
//Ensure that there are no elements with the same ID
|
|
6517
|
+
var element = getElement();
|
|
6518
|
+
while (element) {
|
|
6519
|
+
cont++;
|
|
6520
|
+
element = getElement();
|
|
6521
|
+
}
|
|
6522
|
+
el.id = idPrefix + cont;
|
|
6523
|
+
}
|
|
6524
|
+
|
|
6525
|
+
|
|
6299
6526
|
/***/ }),
|
|
6300
6527
|
|
|
6301
6528
|
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/CopyPastePlugin.ts":
|
|
@@ -6308,6 +6535,8 @@ function handledExclusively(event, plugin) {
|
|
|
6308
6535
|
"use strict";
|
|
6309
6536
|
|
|
6310
6537
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6538
|
+
var forEachSelectedCell_1 = __webpack_require__(/*! ./utils/forEachSelectedCell */ "./packages/roosterjs-editor-core/lib/corePlugins/utils/forEachSelectedCell.ts");
|
|
6539
|
+
var removeCellsOutsideSelection_1 = __webpack_require__(/*! ./utils/removeCellsOutsideSelection */ "./packages/roosterjs-editor-core/lib/corePlugins/utils/removeCellsOutsideSelection.ts");
|
|
6311
6540
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
6312
6541
|
/**
|
|
6313
6542
|
* @internal
|
|
@@ -6320,20 +6549,22 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6320
6549
|
*/
|
|
6321
6550
|
function CopyPastePlugin(options) {
|
|
6322
6551
|
var _this = this;
|
|
6552
|
+
this.editor = null;
|
|
6553
|
+
this.disposer = null;
|
|
6323
6554
|
this.onPaste = function (event) {
|
|
6324
|
-
var _a;
|
|
6325
6555
|
var range;
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6556
|
+
if (_this.editor) {
|
|
6557
|
+
(0, roosterjs_editor_dom_1.extractClipboardEvent)(event, function (clipboardData) { return _this.editor.paste(clipboardData); }, {
|
|
6558
|
+
allowedCustomPasteType: _this.state.allowedCustomPasteType,
|
|
6559
|
+
getTempDiv: function () {
|
|
6560
|
+
range = _this.editor.getSelectionRange();
|
|
6561
|
+
return _this.getTempDiv(_this.editor);
|
|
6562
|
+
},
|
|
6563
|
+
removeTempDiv: function (div) {
|
|
6564
|
+
_this.cleanUpAndRestoreSelection(div, range, false /* isCopy */);
|
|
6565
|
+
},
|
|
6566
|
+
}, _this.editor.getSelectionRange());
|
|
6567
|
+
}
|
|
6337
6568
|
};
|
|
6338
6569
|
this.state = {
|
|
6339
6570
|
allowedCustomPasteType: options.allowedCustomPasteType || [],
|
|
@@ -6353,7 +6584,7 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6353
6584
|
var _this = this;
|
|
6354
6585
|
this.editor = editor;
|
|
6355
6586
|
this.disposer = this.editor.addDomEventHandler({
|
|
6356
|
-
paste:
|
|
6587
|
+
paste: function (e) { return _this.onPaste(e); },
|
|
6357
6588
|
copy: function (e) { return _this.onCutCopy(e, false /*isCut*/); },
|
|
6358
6589
|
cut: function (e) { return _this.onCutCopy(e, true /*isCut*/); },
|
|
6359
6590
|
});
|
|
@@ -6362,7 +6593,9 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6362
6593
|
* Dispose this plugin
|
|
6363
6594
|
*/
|
|
6364
6595
|
CopyPastePlugin.prototype.dispose = function () {
|
|
6365
|
-
this.disposer
|
|
6596
|
+
if (this.disposer) {
|
|
6597
|
+
this.disposer();
|
|
6598
|
+
}
|
|
6366
6599
|
this.disposer = null;
|
|
6367
6600
|
this.editor = null;
|
|
6368
6601
|
};
|
|
@@ -6374,40 +6607,55 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6374
6607
|
};
|
|
6375
6608
|
CopyPastePlugin.prototype.onCutCopy = function (event, isCut) {
|
|
6376
6609
|
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 */);
|
|
6610
|
+
if (this.editor) {
|
|
6611
|
+
var selection_1 = this.editor.getSelectionRangeEx();
|
|
6612
|
+
if (selection_1 && !selection_1.areAllCollapsed) {
|
|
6613
|
+
var html = this.editor.getContent(2 /* RawHTMLWithSelection */);
|
|
6614
|
+
var tempDiv_1 = this.getTempDiv(this.editor, true /*forceInLightMode*/);
|
|
6615
|
+
var metadata = (0, roosterjs_editor_dom_1.setHtmlWithMetadata)(tempDiv_1, html, this.editor.getTrustedHTMLHandler());
|
|
6616
|
+
var newRange = void 0;
|
|
6617
|
+
if (selection_1.type === 1 /* TableSelection */ &&
|
|
6618
|
+
selection_1.coordinates) {
|
|
6619
|
+
var table = tempDiv_1.querySelector("#" + selection_1.table.id);
|
|
6620
|
+
newRange = this.createTableRange(table, selection_1.coordinates);
|
|
6621
|
+
if (isCut) {
|
|
6622
|
+
this.deleteTableContent(this.editor, selection_1.table, selection_1.coordinates);
|
|
6623
|
+
}
|
|
6402
6624
|
}
|
|
6403
|
-
|
|
6625
|
+
else {
|
|
6626
|
+
newRange =
|
|
6627
|
+
(metadata === null || metadata === void 0 ? void 0 : metadata.type) === 0 /* Normal */
|
|
6628
|
+
? (0, roosterjs_editor_dom_1.createRange)(tempDiv_1, metadata.start, metadata.end)
|
|
6629
|
+
: null;
|
|
6630
|
+
}
|
|
6631
|
+
if (newRange) {
|
|
6632
|
+
var cutCopyEvent = this.editor.triggerPluginEvent(9 /* BeforeCutCopy */, {
|
|
6633
|
+
clonedRoot: tempDiv_1,
|
|
6634
|
+
range: newRange,
|
|
6635
|
+
rawEvent: event,
|
|
6636
|
+
isCut: isCut,
|
|
6637
|
+
});
|
|
6638
|
+
if (cutCopyEvent.range) {
|
|
6639
|
+
(0, roosterjs_editor_dom_1.addRangeToSelection)(newRange);
|
|
6640
|
+
}
|
|
6641
|
+
this.editor.runAsync(function (editor) {
|
|
6642
|
+
_this.cleanUpAndRestoreSelection(tempDiv_1, selection_1, !isCut /* isCopy */);
|
|
6643
|
+
if (isCut) {
|
|
6644
|
+
editor.addUndoSnapshot(function () {
|
|
6645
|
+
var position = _this.editor.deleteSelectedContent();
|
|
6646
|
+
editor.focus();
|
|
6647
|
+
editor.select(position);
|
|
6648
|
+
}, "Cut" /* Cut */);
|
|
6649
|
+
}
|
|
6650
|
+
});
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6404
6653
|
}
|
|
6405
6654
|
};
|
|
6406
|
-
CopyPastePlugin.prototype.getTempDiv = function (forceInLightMode) {
|
|
6407
|
-
var
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
_this.editor.insertNode(tempDiv, {
|
|
6655
|
+
CopyPastePlugin.prototype.getTempDiv = function (editor, forceInLightMode) {
|
|
6656
|
+
var div = editor.getCustomData('CopyPasteTempDiv', function () {
|
|
6657
|
+
var tempDiv = (0, roosterjs_editor_dom_1.createElement)(3 /* CopyPasteTempDiv */, editor.getDocument());
|
|
6658
|
+
editor.insertNode(tempDiv, {
|
|
6411
6659
|
position: 4 /* Outside */,
|
|
6412
6660
|
});
|
|
6413
6661
|
return tempDiv;
|
|
@@ -6426,7 +6674,9 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6426
6674
|
var selection = range;
|
|
6427
6675
|
switch (selection.type) {
|
|
6428
6676
|
case 1 /* TableSelection */:
|
|
6429
|
-
this.editor
|
|
6677
|
+
if (this.editor && selection.table && selection.coordinates) {
|
|
6678
|
+
this.editor.select(selection.table, selection.coordinates);
|
|
6679
|
+
}
|
|
6430
6680
|
break;
|
|
6431
6681
|
case 0 /* Normal */:
|
|
6432
6682
|
var range_1 = (_b = selection.ranges) === null || _b === void 0 ? void 0 : _b[0];
|
|
@@ -6443,13 +6693,43 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6443
6693
|
(0, roosterjs_editor_dom_1.moveChildNodes)(tempDiv);
|
|
6444
6694
|
};
|
|
6445
6695
|
CopyPastePlugin.prototype.restoreRange = function (range, isCopy) {
|
|
6446
|
-
if (range) {
|
|
6696
|
+
if (range && this.editor) {
|
|
6447
6697
|
if (isCopy && roosterjs_editor_dom_1.Browser.isAndroid) {
|
|
6448
6698
|
range.collapse();
|
|
6449
6699
|
}
|
|
6450
6700
|
this.editor.select(range);
|
|
6451
6701
|
}
|
|
6452
6702
|
};
|
|
6703
|
+
CopyPastePlugin.prototype.createTableRange = function (table, selection) {
|
|
6704
|
+
var clonedVTable = new roosterjs_editor_dom_1.VTable(table);
|
|
6705
|
+
clonedVTable.selection = selection;
|
|
6706
|
+
(0, removeCellsOutsideSelection_1.removeCellsOutsideSelection)(clonedVTable);
|
|
6707
|
+
clonedVTable.writeBack();
|
|
6708
|
+
return (0, roosterjs_editor_dom_1.createRange)(clonedVTable.table);
|
|
6709
|
+
};
|
|
6710
|
+
CopyPastePlugin.prototype.deleteTableContent = function (editor, table, selection) {
|
|
6711
|
+
var selectedVTable = new roosterjs_editor_dom_1.VTable(table);
|
|
6712
|
+
selectedVTable.selection = selection;
|
|
6713
|
+
(0, forEachSelectedCell_1.forEachSelectedCell)(selectedVTable, function (cell) {
|
|
6714
|
+
if (cell === null || cell === void 0 ? void 0 : cell.td) {
|
|
6715
|
+
cell.td.innerHTML = editor.getTrustedHTMLHandler()('<br>');
|
|
6716
|
+
}
|
|
6717
|
+
});
|
|
6718
|
+
var wholeTableSelected = (0, roosterjs_editor_dom_1.isWholeTableSelected)(selectedVTable, selection);
|
|
6719
|
+
var isWholeColumnSelected = table.rows.length - 1 === selection.lastCell.y && selection.firstCell.y === 0;
|
|
6720
|
+
if (wholeTableSelected) {
|
|
6721
|
+
selectedVTable.edit(4 /* DeleteTable */);
|
|
6722
|
+
selectedVTable.writeBack();
|
|
6723
|
+
}
|
|
6724
|
+
else if (isWholeColumnSelected) {
|
|
6725
|
+
selectedVTable.edit(5 /* DeleteColumn */);
|
|
6726
|
+
selectedVTable.writeBack();
|
|
6727
|
+
}
|
|
6728
|
+
if (wholeTableSelected || isWholeColumnSelected) {
|
|
6729
|
+
table.style.removeProperty('width');
|
|
6730
|
+
table.style.removeProperty('height');
|
|
6731
|
+
}
|
|
6732
|
+
};
|
|
6453
6733
|
return CopyPastePlugin;
|
|
6454
6734
|
}());
|
|
6455
6735
|
exports.default = CopyPastePlugin;
|
|
@@ -6496,9 +6776,13 @@ var DOMEventPlugin = /** @class */ (function () {
|
|
|
6496
6776
|
};
|
|
6497
6777
|
this.onFocus = function () {
|
|
6498
6778
|
var _a = _this.state.tableSelectionRange || {}, table = _a.table, coordinates = _a.coordinates;
|
|
6779
|
+
var image = (_this.state.imageSelectionRange || {}).image;
|
|
6499
6780
|
if (table && coordinates) {
|
|
6500
6781
|
_this.editor.select(table, coordinates);
|
|
6501
6782
|
}
|
|
6783
|
+
else if (image) {
|
|
6784
|
+
_this.editor.select(image);
|
|
6785
|
+
}
|
|
6502
6786
|
else {
|
|
6503
6787
|
_this.editor.select(_this.state.selectionRange);
|
|
6504
6788
|
}
|
|
@@ -6562,6 +6846,7 @@ var DOMEventPlugin = /** @class */ (function () {
|
|
|
6562
6846
|
stopPrintableKeyboardEventPropagation: !options.allowKeyboardEventPropagation,
|
|
6563
6847
|
contextMenuProviders: ((_a = options.plugins) === null || _a === void 0 ? void 0 : _a.filter(isContextMenuProvider)) || [],
|
|
6564
6848
|
tableSelectionRange: null,
|
|
6849
|
+
imageSelectionRange: null,
|
|
6565
6850
|
};
|
|
6566
6851
|
}
|
|
6567
6852
|
/**
|
|
@@ -7198,6 +7483,7 @@ var LifecyclePlugin = /** @class */ (function () {
|
|
|
7198
7483
|
shadowEditFragment: null,
|
|
7199
7484
|
shadowEditSelectionPath: null,
|
|
7200
7485
|
shadowEditTableSelectionPath: null,
|
|
7486
|
+
shadowEditImageSelectionPath: null,
|
|
7201
7487
|
};
|
|
7202
7488
|
}
|
|
7203
7489
|
/**
|
|
@@ -8056,33 +8342,114 @@ exports.getPluginState = getPluginState;
|
|
|
8056
8342
|
|
|
8057
8343
|
/***/ }),
|
|
8058
8344
|
|
|
8059
|
-
/***/ "./packages/roosterjs-editor-core/lib/
|
|
8060
|
-
|
|
8061
|
-
!*** ./packages/roosterjs-editor-core/lib/
|
|
8062
|
-
|
|
8345
|
+
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/utils/forEachSelectedCell.ts":
|
|
8346
|
+
/*!*************************************************************************************!*\
|
|
8347
|
+
!*** ./packages/roosterjs-editor-core/lib/corePlugins/utils/forEachSelectedCell.ts ***!
|
|
8348
|
+
\*************************************************************************************/
|
|
8063
8349
|
/*! no static exports found */
|
|
8064
8350
|
/***/ (function(module, exports, __webpack_require__) {
|
|
8065
8351
|
|
|
8066
8352
|
"use strict";
|
|
8067
8353
|
|
|
8068
|
-
var __assign = (this && this.__assign) || function () {
|
|
8069
|
-
__assign = Object.assign || function(t) {
|
|
8070
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8071
|
-
s = arguments[i];
|
|
8072
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8073
|
-
t[p] = s[p];
|
|
8074
|
-
}
|
|
8075
|
-
return t;
|
|
8076
|
-
};
|
|
8077
|
-
return __assign.apply(this, arguments);
|
|
8078
|
-
};
|
|
8079
8354
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8080
|
-
|
|
8081
|
-
var coreApiMap_1 = __webpack_require__(/*! ../coreApi/coreApiMap */ "./packages/roosterjs-editor-core/lib/coreApi/coreApiMap.ts");
|
|
8082
|
-
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
8355
|
+
exports.forEachSelectedCell = void 0;
|
|
8083
8356
|
/**
|
|
8084
|
-
*
|
|
8085
|
-
|
|
8357
|
+
* @internal
|
|
8358
|
+
* Executes an action to all the cells within the selection range.
|
|
8359
|
+
* @param callback action to apply on each selected cell
|
|
8360
|
+
* @returns the amount of cells modified
|
|
8361
|
+
*/
|
|
8362
|
+
var forEachSelectedCell = function (vTable, callback) {
|
|
8363
|
+
var _a;
|
|
8364
|
+
if (vTable.selection) {
|
|
8365
|
+
var _b = vTable.selection, lastCell = _b.lastCell, firstCell = _b.firstCell;
|
|
8366
|
+
for (var y = firstCell.y; y <= lastCell.y; y++) {
|
|
8367
|
+
for (var x = firstCell.x; x <= lastCell.x; x++) {
|
|
8368
|
+
if (vTable.cells && ((_a = vTable.cells[y][x]) === null || _a === void 0 ? void 0 : _a.td)) {
|
|
8369
|
+
callback(vTable.cells[y][x]);
|
|
8370
|
+
}
|
|
8371
|
+
}
|
|
8372
|
+
}
|
|
8373
|
+
}
|
|
8374
|
+
};
|
|
8375
|
+
exports.forEachSelectedCell = forEachSelectedCell;
|
|
8376
|
+
|
|
8377
|
+
|
|
8378
|
+
/***/ }),
|
|
8379
|
+
|
|
8380
|
+
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/utils/removeCellsOutsideSelection.ts":
|
|
8381
|
+
/*!*********************************************************************************************!*\
|
|
8382
|
+
!*** ./packages/roosterjs-editor-core/lib/corePlugins/utils/removeCellsOutsideSelection.ts ***!
|
|
8383
|
+
\*********************************************************************************************/
|
|
8384
|
+
/*! no static exports found */
|
|
8385
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
8386
|
+
|
|
8387
|
+
"use strict";
|
|
8388
|
+
|
|
8389
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8390
|
+
exports.removeCellsOutsideSelection = void 0;
|
|
8391
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
8392
|
+
/**
|
|
8393
|
+
* @internal
|
|
8394
|
+
* Remove the cells outside of the selection.
|
|
8395
|
+
* @param vTable VTable to remove selection
|
|
8396
|
+
*/
|
|
8397
|
+
var removeCellsOutsideSelection = function (vTable) {
|
|
8398
|
+
if (vTable.selection) {
|
|
8399
|
+
if ((0, roosterjs_editor_dom_1.isWholeTableSelected)(vTable, vTable.selection)) {
|
|
8400
|
+
return;
|
|
8401
|
+
}
|
|
8402
|
+
vTable.table.style.removeProperty('width');
|
|
8403
|
+
vTable.table.style.removeProperty('height');
|
|
8404
|
+
var _a = vTable.selection, firstCell = _a.firstCell, lastCell = _a.lastCell;
|
|
8405
|
+
var resultCells_1 = [];
|
|
8406
|
+
var firstX_1 = firstCell.x;
|
|
8407
|
+
var firstY_1 = firstCell.y;
|
|
8408
|
+
var lastX_1 = lastCell.x;
|
|
8409
|
+
var lastY_1 = lastCell.y;
|
|
8410
|
+
if (vTable.cells) {
|
|
8411
|
+
vTable.cells.forEach(function (row, y) {
|
|
8412
|
+
row = row.filter(function (_, x) { return y >= firstY_1 && y <= lastY_1 && x >= firstX_1 && x <= lastX_1; });
|
|
8413
|
+
if (row.length > 0) {
|
|
8414
|
+
resultCells_1.push(row);
|
|
8415
|
+
}
|
|
8416
|
+
});
|
|
8417
|
+
vTable.cells = resultCells_1;
|
|
8418
|
+
}
|
|
8419
|
+
}
|
|
8420
|
+
};
|
|
8421
|
+
exports.removeCellsOutsideSelection = removeCellsOutsideSelection;
|
|
8422
|
+
|
|
8423
|
+
|
|
8424
|
+
/***/ }),
|
|
8425
|
+
|
|
8426
|
+
/***/ "./packages/roosterjs-editor-core/lib/editor/Editor.ts":
|
|
8427
|
+
/*!*************************************************************!*\
|
|
8428
|
+
!*** ./packages/roosterjs-editor-core/lib/editor/Editor.ts ***!
|
|
8429
|
+
\*************************************************************/
|
|
8430
|
+
/*! no static exports found */
|
|
8431
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
8432
|
+
|
|
8433
|
+
"use strict";
|
|
8434
|
+
|
|
8435
|
+
var __assign = (this && this.__assign) || function () {
|
|
8436
|
+
__assign = Object.assign || function(t) {
|
|
8437
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8438
|
+
s = arguments[i];
|
|
8439
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8440
|
+
t[p] = s[p];
|
|
8441
|
+
}
|
|
8442
|
+
return t;
|
|
8443
|
+
};
|
|
8444
|
+
return __assign.apply(this, arguments);
|
|
8445
|
+
};
|
|
8446
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8447
|
+
var createCorePlugins_1 = __webpack_require__(/*! ../corePlugins/createCorePlugins */ "./packages/roosterjs-editor-core/lib/corePlugins/createCorePlugins.ts");
|
|
8448
|
+
var coreApiMap_1 = __webpack_require__(/*! ../coreApi/coreApiMap */ "./packages/roosterjs-editor-core/lib/coreApi/coreApiMap.ts");
|
|
8449
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
8450
|
+
/**
|
|
8451
|
+
* RoosterJs core editor class
|
|
8452
|
+
*/
|
|
8086
8453
|
var Editor = /** @class */ (function () {
|
|
8087
8454
|
//#region Lifecycle
|
|
8088
8455
|
/**
|
|
@@ -8093,6 +8460,8 @@ var Editor = /** @class */ (function () {
|
|
|
8093
8460
|
function Editor(contentDiv, options) {
|
|
8094
8461
|
var _this = this;
|
|
8095
8462
|
if (options === void 0) { options = {}; }
|
|
8463
|
+
var _a;
|
|
8464
|
+
this.core = null;
|
|
8096
8465
|
// 1. Make sure all parameters are valid
|
|
8097
8466
|
if ((0, roosterjs_editor_dom_1.getTagOfNode)(contentDiv) != 'DIV') {
|
|
8098
8467
|
throw new Error('contentDiv must be an HTML DIV element');
|
|
@@ -8102,14 +8471,22 @@ var Editor = /** @class */ (function () {
|
|
|
8102
8471
|
var plugins = [];
|
|
8103
8472
|
(0, roosterjs_editor_dom_1.getObjectKeys)(corePlugins).forEach(function (name) {
|
|
8104
8473
|
if (name == '_placeholder') {
|
|
8105
|
-
|
|
8474
|
+
if (options.plugins) {
|
|
8475
|
+
(0, roosterjs_editor_dom_1.arrayPush)(plugins, options.plugins);
|
|
8476
|
+
}
|
|
8106
8477
|
}
|
|
8107
8478
|
else {
|
|
8108
8479
|
plugins.push(corePlugins[name]);
|
|
8109
8480
|
}
|
|
8110
8481
|
});
|
|
8111
|
-
var zoomScale = options.zoomScale > 0 ? options.zoomScale : 1;
|
|
8112
|
-
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; })
|
|
8482
|
+
var zoomScale = ((_a = options.zoomScale) !== null && _a !== void 0 ? _a : -1) > 0 ? options.zoomScale : 1;
|
|
8483
|
+
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; }), getVisibleViewport: options.getVisibleViewport ||
|
|
8484
|
+
(function () {
|
|
8485
|
+
var scrollContainer = _this.getScrollContainer();
|
|
8486
|
+
return (0, roosterjs_editor_dom_1.getIntersectedRect)(scrollContainer == contentDiv
|
|
8487
|
+
? [scrollContainer]
|
|
8488
|
+
: [scrollContainer, contentDiv]);
|
|
8489
|
+
}), imageSelectionBorderColor: options.imageSelectionBorderColor });
|
|
8113
8490
|
// 3. Initialize plugins
|
|
8114
8491
|
this.core.plugins.forEach(function (plugin) { return plugin.initialize(_this); });
|
|
8115
8492
|
// 4. Ensure user will type in a container node, not the editor content DIV
|
|
@@ -8119,8 +8496,9 @@ var Editor = /** @class */ (function () {
|
|
|
8119
8496
|
* Dispose this editor, dispose all plugins and custom data
|
|
8120
8497
|
*/
|
|
8121
8498
|
Editor.prototype.dispose = function () {
|
|
8122
|
-
|
|
8123
|
-
|
|
8499
|
+
var core = this.getCore();
|
|
8500
|
+
for (var i = core.plugins.length - 1; i >= 0; i--) {
|
|
8501
|
+
core.plugins[i].dispose();
|
|
8124
8502
|
}
|
|
8125
8503
|
this.core = null;
|
|
8126
8504
|
};
|
|
@@ -8144,7 +8522,8 @@ var Editor = /** @class */ (function () {
|
|
|
8144
8522
|
* @returns true if node is inserted. Otherwise false
|
|
8145
8523
|
*/
|
|
8146
8524
|
Editor.prototype.insertNode = function (node, option) {
|
|
8147
|
-
|
|
8525
|
+
var core = this.getCore();
|
|
8526
|
+
return node ? core.api.insertNode(core, node, option !== null && option !== void 0 ? option : null) : false;
|
|
8148
8527
|
};
|
|
8149
8528
|
/**
|
|
8150
8529
|
* Delete a node from editor content
|
|
@@ -8153,7 +8532,7 @@ var Editor = /** @class */ (function () {
|
|
|
8153
8532
|
*/
|
|
8154
8533
|
Editor.prototype.deleteNode = function (node) {
|
|
8155
8534
|
// Only remove the node when it falls within editor
|
|
8156
|
-
if (node && this.contains(node)) {
|
|
8535
|
+
if (node && this.contains(node) && node.parentNode) {
|
|
8157
8536
|
node.parentNode.removeChild(node);
|
|
8158
8537
|
return true;
|
|
8159
8538
|
}
|
|
@@ -8167,9 +8546,10 @@ var Editor = /** @class */ (function () {
|
|
|
8167
8546
|
* @returns true if node is replaced. Otherwise false
|
|
8168
8547
|
*/
|
|
8169
8548
|
Editor.prototype.replaceNode = function (existingNode, toNode, transformColorForDarkMode) {
|
|
8549
|
+
var core = this.getCore();
|
|
8170
8550
|
// Only replace the node when it falls within editor
|
|
8171
8551
|
if (this.contains(existingNode) && toNode) {
|
|
8172
|
-
|
|
8552
|
+
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
8553
|
return true;
|
|
8174
8554
|
}
|
|
8175
8555
|
return false;
|
|
@@ -8180,25 +8560,25 @@ var Editor = /** @class */ (function () {
|
|
|
8180
8560
|
* @returns The BlockElement result
|
|
8181
8561
|
*/
|
|
8182
8562
|
Editor.prototype.getBlockElementAtNode = function (node) {
|
|
8183
|
-
return (0, roosterjs_editor_dom_1.getBlockElementAtNode)(this.
|
|
8563
|
+
return (0, roosterjs_editor_dom_1.getBlockElementAtNode)(this.getCore().contentDiv, node);
|
|
8184
8564
|
};
|
|
8185
8565
|
Editor.prototype.contains = function (arg) {
|
|
8186
|
-
return (0, roosterjs_editor_dom_1.contains)(this.
|
|
8566
|
+
return (0, roosterjs_editor_dom_1.contains)(this.getCore().contentDiv, arg);
|
|
8187
8567
|
};
|
|
8188
8568
|
Editor.prototype.queryElements = function (selector, scopeOrCallback, callback) {
|
|
8189
|
-
var _this = this;
|
|
8190
8569
|
if (scopeOrCallback === void 0) { scopeOrCallback = 0 /* Body */; }
|
|
8570
|
+
var core = this.getCore();
|
|
8191
8571
|
var result = [];
|
|
8192
8572
|
var scope = scopeOrCallback instanceof Function ? 0 /* Body */ : scopeOrCallback;
|
|
8193
8573
|
callback = scopeOrCallback instanceof Function ? scopeOrCallback : callback;
|
|
8194
8574
|
var selectionEx = scope == 0 /* Body */ ? null : this.getSelectionRangeEx();
|
|
8195
8575
|
if (selectionEx) {
|
|
8196
8576
|
selectionEx.ranges.forEach(function (range) {
|
|
8197
|
-
result.push.apply(result, (0, roosterjs_editor_dom_1.queryElements)(
|
|
8577
|
+
result.push.apply(result, (0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, range));
|
|
8198
8578
|
});
|
|
8199
8579
|
}
|
|
8200
8580
|
else {
|
|
8201
|
-
return (0, roosterjs_editor_dom_1.queryElements)(
|
|
8581
|
+
return (0, roosterjs_editor_dom_1.queryElements)(core.contentDiv, selector, callback, scope, undefined /* range */);
|
|
8202
8582
|
}
|
|
8203
8583
|
return result;
|
|
8204
8584
|
};
|
|
@@ -8214,7 +8594,7 @@ var Editor = /** @class */ (function () {
|
|
|
8214
8594
|
* otherwise just return start and end
|
|
8215
8595
|
*/
|
|
8216
8596
|
Editor.prototype.collapseNodes = function (start, end, canSplitParent) {
|
|
8217
|
-
return (0, roosterjs_editor_dom_1.collapseNodes)(this.
|
|
8597
|
+
return (0, roosterjs_editor_dom_1.collapseNodes)(this.getCore().contentDiv, start, end, canSplitParent);
|
|
8218
8598
|
};
|
|
8219
8599
|
//#endregion
|
|
8220
8600
|
//#region Content API
|
|
@@ -8224,7 +8604,7 @@ var Editor = /** @class */ (function () {
|
|
|
8224
8604
|
* @returns True if there's no visible content, otherwise false
|
|
8225
8605
|
*/
|
|
8226
8606
|
Editor.prototype.isEmpty = function (trim) {
|
|
8227
|
-
return (0, roosterjs_editor_dom_1.isNodeEmpty)(this.
|
|
8607
|
+
return (0, roosterjs_editor_dom_1.isNodeEmpty)(this.getCore().contentDiv, trim);
|
|
8228
8608
|
};
|
|
8229
8609
|
/**
|
|
8230
8610
|
* Get current editor content as HTML string
|
|
@@ -8233,7 +8613,8 @@ var Editor = /** @class */ (function () {
|
|
|
8233
8613
|
*/
|
|
8234
8614
|
Editor.prototype.getContent = function (mode) {
|
|
8235
8615
|
if (mode === void 0) { mode = 0 /* CleanHTML */; }
|
|
8236
|
-
|
|
8616
|
+
var core = this.getCore();
|
|
8617
|
+
return core.api.getContent(core, mode);
|
|
8237
8618
|
};
|
|
8238
8619
|
/**
|
|
8239
8620
|
* Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
|
|
@@ -8242,7 +8623,8 @@ var Editor = /** @class */ (function () {
|
|
|
8242
8623
|
*/
|
|
8243
8624
|
Editor.prototype.setContent = function (content, triggerContentChangedEvent) {
|
|
8244
8625
|
if (triggerContentChangedEvent === void 0) { triggerContentChangedEvent = true; }
|
|
8245
|
-
this.
|
|
8626
|
+
var core = this.getCore();
|
|
8627
|
+
core.api.setContent(core, content, triggerContentChangedEvent);
|
|
8246
8628
|
};
|
|
8247
8629
|
/**
|
|
8248
8630
|
* Insert HTML content into editor
|
|
@@ -8257,7 +8639,7 @@ var Editor = /** @class */ (function () {
|
|
|
8257
8639
|
var _a;
|
|
8258
8640
|
if (content) {
|
|
8259
8641
|
var doc = this.getDocument();
|
|
8260
|
-
var body = (_a = new DOMParser().parseFromString(this.
|
|
8642
|
+
var body = (_a = new DOMParser().parseFromString(this.getCore().trustedHTMLHandler(content), 'text/html')) === null || _a === void 0 ? void 0 : _a.body;
|
|
8261
8643
|
var allNodes = (body === null || body === void 0 ? void 0 : body.childNodes) ? (0, roosterjs_editor_dom_1.toArray)(body.childNodes) : [];
|
|
8262
8644
|
// If it is to insert on new line, and there are more than one node in the collection, wrap all nodes with
|
|
8263
8645
|
// a parent DIV before calling insertNode on each top level sub node. Otherwise, every sub node may get wrapped
|
|
@@ -8275,7 +8657,10 @@ var Editor = /** @class */ (function () {
|
|
|
8275
8657
|
*/
|
|
8276
8658
|
Editor.prototype.deleteSelectedContent = function () {
|
|
8277
8659
|
var range = this.getSelectionRange();
|
|
8278
|
-
|
|
8660
|
+
if (range && !range.collapsed) {
|
|
8661
|
+
return (0, roosterjs_editor_dom_1.deleteSelectedContent)(this.getCore().contentDiv, range);
|
|
8662
|
+
}
|
|
8663
|
+
return null;
|
|
8279
8664
|
};
|
|
8280
8665
|
/**
|
|
8281
8666
|
* Paste into editor using a clipboardData object
|
|
@@ -8286,6 +8671,9 @@ var Editor = /** @class */ (function () {
|
|
|
8286
8671
|
*/
|
|
8287
8672
|
Editor.prototype.paste = function (clipboardData, pasteAsText, applyCurrentFormat) {
|
|
8288
8673
|
var _this = this;
|
|
8674
|
+
if (pasteAsText === void 0) { pasteAsText = false; }
|
|
8675
|
+
if (applyCurrentFormat === void 0) { applyCurrentFormat = false; }
|
|
8676
|
+
var core = this.getCore();
|
|
8289
8677
|
if (!clipboardData) {
|
|
8290
8678
|
return;
|
|
8291
8679
|
}
|
|
@@ -8298,11 +8686,13 @@ var Editor = /** @class */ (function () {
|
|
|
8298
8686
|
}
|
|
8299
8687
|
var range = this.getSelectionRange();
|
|
8300
8688
|
var pos = range && roosterjs_editor_dom_1.Position.getStart(range);
|
|
8301
|
-
var fragment =
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8689
|
+
var fragment = core.api.createPasteFragment(core, clipboardData, pos, pasteAsText, applyCurrentFormat);
|
|
8690
|
+
if (fragment) {
|
|
8691
|
+
this.addUndoSnapshot(function () {
|
|
8692
|
+
_this.insertNode(fragment);
|
|
8693
|
+
return clipboardData;
|
|
8694
|
+
}, "Paste" /* Paste */);
|
|
8695
|
+
}
|
|
8306
8696
|
};
|
|
8307
8697
|
//#endregion
|
|
8308
8698
|
//#region Focus and Selection
|
|
@@ -8315,7 +8705,8 @@ var Editor = /** @class */ (function () {
|
|
|
8315
8705
|
*/
|
|
8316
8706
|
Editor.prototype.getSelectionRange = function (tryGetFromCache) {
|
|
8317
8707
|
if (tryGetFromCache === void 0) { tryGetFromCache = true; }
|
|
8318
|
-
|
|
8708
|
+
var core = this.getCore();
|
|
8709
|
+
return core.api.getSelectionRange(core, tryGetFromCache);
|
|
8319
8710
|
};
|
|
8320
8711
|
/**
|
|
8321
8712
|
* Get current selection range from Editor.
|
|
@@ -8325,7 +8716,8 @@ var Editor = /** @class */ (function () {
|
|
|
8325
8716
|
* @returns current selection range, or null if editor never got focus before
|
|
8326
8717
|
*/
|
|
8327
8718
|
Editor.prototype.getSelectionRangeEx = function () {
|
|
8328
|
-
|
|
8719
|
+
var core = this.getCore();
|
|
8720
|
+
return core.api.getSelectionRangeEx(core);
|
|
8329
8721
|
};
|
|
8330
8722
|
/**
|
|
8331
8723
|
* Get current selection in a serializable format
|
|
@@ -8334,40 +8726,53 @@ var Editor = /** @class */ (function () {
|
|
|
8334
8726
|
*/
|
|
8335
8727
|
Editor.prototype.getSelectionPath = function () {
|
|
8336
8728
|
var range = this.getSelectionRange();
|
|
8337
|
-
return range && (0, roosterjs_editor_dom_1.getSelectionPath)(this.
|
|
8729
|
+
return range && (0, roosterjs_editor_dom_1.getSelectionPath)(this.getCore().contentDiv, range);
|
|
8338
8730
|
};
|
|
8339
8731
|
/**
|
|
8340
8732
|
* Check if focus is in editor now
|
|
8341
8733
|
* @returns true if focus is in editor, otherwise false
|
|
8342
8734
|
*/
|
|
8343
8735
|
Editor.prototype.hasFocus = function () {
|
|
8344
|
-
|
|
8736
|
+
var core = this.getCore();
|
|
8737
|
+
return core.api.hasFocus(core);
|
|
8345
8738
|
};
|
|
8346
8739
|
/**
|
|
8347
8740
|
* Focus to this editor, the selection was restored to where it was before, no unexpected scroll.
|
|
8348
8741
|
*/
|
|
8349
8742
|
Editor.prototype.focus = function () {
|
|
8350
|
-
this.
|
|
8743
|
+
var core = this.getCore();
|
|
8744
|
+
core.api.focus(core);
|
|
8351
8745
|
};
|
|
8352
8746
|
Editor.prototype.select = function (arg1, arg2, arg3, arg4) {
|
|
8353
|
-
var
|
|
8354
|
-
if (
|
|
8355
|
-
var selection =
|
|
8356
|
-
|
|
8747
|
+
var core = this.getCore();
|
|
8748
|
+
if (arg1 && 'rows' in arg1) {
|
|
8749
|
+
var selection = core.api.selectTable(core, arg1, arg2);
|
|
8750
|
+
core.domEvent.tableSelectionRange = selection;
|
|
8751
|
+
return !!selection;
|
|
8752
|
+
}
|
|
8753
|
+
else {
|
|
8754
|
+
core.api.selectTable(core, null);
|
|
8755
|
+
core.domEvent.tableSelectionRange = null;
|
|
8756
|
+
}
|
|
8757
|
+
if (this.isFeatureEnabled("ImageSelection" /* ImageSelection */) &&
|
|
8758
|
+
(0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'HTMLImageElement') &&
|
|
8759
|
+
!arg2) {
|
|
8760
|
+
var selection = core.api.selectImage(core, arg1);
|
|
8761
|
+
core.domEvent.imageSelectionRange = selection;
|
|
8357
8762
|
return !!selection;
|
|
8358
8763
|
}
|
|
8359
8764
|
else {
|
|
8360
|
-
|
|
8361
|
-
|
|
8765
|
+
core.api.selectImage(core, null);
|
|
8766
|
+
core.domEvent.imageSelectionRange = null;
|
|
8362
8767
|
}
|
|
8363
8768
|
var range = !arg1
|
|
8364
8769
|
? null
|
|
8365
8770
|
: (0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'Range')
|
|
8366
8771
|
? arg1
|
|
8367
|
-
:
|
|
8368
|
-
? (0, roosterjs_editor_dom_1.createRange)(
|
|
8772
|
+
: 'start' in arg1 && Array.isArray(arg1.end)
|
|
8773
|
+
? (0, roosterjs_editor_dom_1.createRange)(core.contentDiv, arg1.start, arg1.end)
|
|
8369
8774
|
: (0, roosterjs_editor_dom_1.createRange)(arg1, arg2, arg3, arg4);
|
|
8370
|
-
return this.contains(range) &&
|
|
8775
|
+
return !!range && this.contains(range) && core.api.selectRange(core, range);
|
|
8371
8776
|
};
|
|
8372
8777
|
/**
|
|
8373
8778
|
* Get current focused position. Return null if editor doesn't have focus at this time.
|
|
@@ -8375,7 +8780,7 @@ var Editor = /** @class */ (function () {
|
|
|
8375
8780
|
Editor.prototype.getFocusedPosition = function () {
|
|
8376
8781
|
var _a;
|
|
8377
8782
|
var sel = (_a = this.getDocument().defaultView) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
8378
|
-
if (
|
|
8783
|
+
if ((sel === null || sel === void 0 ? void 0 : sel.focusNode) && this.contains(sel.focusNode)) {
|
|
8379
8784
|
return new roosterjs_editor_dom_1.Position(sel.focusNode, sel.focusOffset);
|
|
8380
8785
|
}
|
|
8381
8786
|
var range = this.getSelectionRange();
|
|
@@ -8398,14 +8803,16 @@ var Editor = /** @class */ (function () {
|
|
|
8398
8803
|
*/
|
|
8399
8804
|
Editor.prototype.getElementAtCursor = function (selector, startFrom, event) {
|
|
8400
8805
|
var _this = this;
|
|
8401
|
-
|
|
8402
|
-
|
|
8806
|
+
var _a;
|
|
8807
|
+
event = startFrom ? undefined : event; // Only use cache when startFrom is not specified, for different start position can have different result
|
|
8808
|
+
return ((_a = (0, roosterjs_editor_dom_1.cacheGetEventData)(event !== null && event !== void 0 ? event : null, 'GET_ELEMENT_AT_CURSOR_' + selector, function () {
|
|
8403
8809
|
if (!startFrom) {
|
|
8404
8810
|
var position = _this.getFocusedPosition();
|
|
8405
|
-
startFrom = position
|
|
8811
|
+
startFrom = position === null || position === void 0 ? void 0 : position.node;
|
|
8406
8812
|
}
|
|
8407
|
-
return (startFrom &&
|
|
8408
|
-
|
|
8813
|
+
return (startFrom &&
|
|
8814
|
+
(0, roosterjs_editor_dom_1.findClosestElementAncestor)(startFrom, _this.getCore().contentDiv, selector));
|
|
8815
|
+
})) !== null && _a !== void 0 ? _a : null);
|
|
8409
8816
|
};
|
|
8410
8817
|
/**
|
|
8411
8818
|
* Check if this position is at beginning of the editor.
|
|
@@ -8414,18 +8821,18 @@ var Editor = /** @class */ (function () {
|
|
|
8414
8821
|
* @returns True if position is at beginning of the editor, otherwise false
|
|
8415
8822
|
*/
|
|
8416
8823
|
Editor.prototype.isPositionAtBeginning = function (position) {
|
|
8417
|
-
return (0, roosterjs_editor_dom_1.isPositionAtBeginningOf)(position, this.
|
|
8824
|
+
return (0, roosterjs_editor_dom_1.isPositionAtBeginningOf)(position, this.getCore().contentDiv);
|
|
8418
8825
|
};
|
|
8419
8826
|
/**
|
|
8420
8827
|
* Get impacted regions from selection
|
|
8421
8828
|
*/
|
|
8422
8829
|
Editor.prototype.getSelectedRegions = function (type) {
|
|
8423
|
-
var _this = this;
|
|
8424
8830
|
if (type === void 0) { type = 0 /* Table */; }
|
|
8425
8831
|
var selection = this.getSelectionRangeEx();
|
|
8426
8832
|
var result = [];
|
|
8833
|
+
var contentDiv = this.getCore().contentDiv;
|
|
8427
8834
|
selection.ranges.forEach(function (range) {
|
|
8428
|
-
result.push.apply(result, (range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(
|
|
8835
|
+
result.push.apply(result, (range ? (0, roosterjs_editor_dom_1.getRegionsFromRange)(contentDiv, range, type) : []));
|
|
8429
8836
|
});
|
|
8430
8837
|
return result.filter(function (value, index, self) {
|
|
8431
8838
|
return self.indexOf(value) === index;
|
|
@@ -8436,7 +8843,8 @@ var Editor = /** @class */ (function () {
|
|
|
8436
8843
|
Editor.prototype.addDomEventHandler = function (nameOrMap, handler) {
|
|
8437
8844
|
var _a;
|
|
8438
8845
|
var eventsToMap = typeof nameOrMap == 'string' ? (_a = {}, _a[nameOrMap] = handler, _a) : nameOrMap;
|
|
8439
|
-
|
|
8846
|
+
var core = this.getCore();
|
|
8847
|
+
return core.api.attachDomEvent(core, eventsToMap);
|
|
8440
8848
|
};
|
|
8441
8849
|
/**
|
|
8442
8850
|
* Trigger an event to be dispatched to all plugins
|
|
@@ -8448,8 +8856,10 @@ var Editor = /** @class */ (function () {
|
|
|
8448
8856
|
* the result of this function provides a chance to read the modified result
|
|
8449
8857
|
*/
|
|
8450
8858
|
Editor.prototype.triggerPluginEvent = function (eventType, data, broadcast) {
|
|
8859
|
+
if (broadcast === void 0) { broadcast = false; }
|
|
8860
|
+
var core = this.getCore();
|
|
8451
8861
|
var event = __assign({ eventType: eventType }, data);
|
|
8452
|
-
|
|
8862
|
+
core.api.triggerEvent(core, event, broadcast);
|
|
8453
8863
|
return event;
|
|
8454
8864
|
};
|
|
8455
8865
|
/**
|
|
@@ -8471,14 +8881,16 @@ var Editor = /** @class */ (function () {
|
|
|
8471
8881
|
*/
|
|
8472
8882
|
Editor.prototype.undo = function () {
|
|
8473
8883
|
this.focus();
|
|
8474
|
-
this.
|
|
8884
|
+
var core = this.getCore();
|
|
8885
|
+
core.api.restoreUndoSnapshot(core, -1 /*step*/);
|
|
8475
8886
|
};
|
|
8476
8887
|
/**
|
|
8477
8888
|
* Redo next edit operation
|
|
8478
8889
|
*/
|
|
8479
8890
|
Editor.prototype.redo = function () {
|
|
8480
8891
|
this.focus();
|
|
8481
|
-
this.
|
|
8892
|
+
var core = this.getCore();
|
|
8893
|
+
core.api.restoreUndoSnapshot(core, 1 /*step*/);
|
|
8482
8894
|
};
|
|
8483
8895
|
/**
|
|
8484
8896
|
* Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger
|
|
@@ -8491,13 +8903,14 @@ var Editor = /** @class */ (function () {
|
|
|
8491
8903
|
* @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
|
|
8492
8904
|
*/
|
|
8493
8905
|
Editor.prototype.addUndoSnapshot = function (callback, changeSource, canUndoByBackspace, additionalData) {
|
|
8494
|
-
this.
|
|
8906
|
+
var core = this.getCore();
|
|
8907
|
+
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
8908
|
};
|
|
8496
8909
|
/**
|
|
8497
8910
|
* Whether there is an available undo/redo snapshot
|
|
8498
8911
|
*/
|
|
8499
8912
|
Editor.prototype.getUndoState = function () {
|
|
8500
|
-
var _a = this.
|
|
8913
|
+
var _a = this.getCore().undo, hasNewContent = _a.hasNewContent, snapshotsService = _a.snapshotsService;
|
|
8501
8914
|
return {
|
|
8502
8915
|
canUndo: hasNewContent || snapshotsService.canMove(-1 /*previousSnapshot*/),
|
|
8503
8916
|
canRedo: snapshotsService.canMove(1 /*nextSnapshot*/),
|
|
@@ -8510,13 +8923,13 @@ var Editor = /** @class */ (function () {
|
|
|
8510
8923
|
* @returns The HTML document which contains this editor
|
|
8511
8924
|
*/
|
|
8512
8925
|
Editor.prototype.getDocument = function () {
|
|
8513
|
-
return this.
|
|
8926
|
+
return this.getCore().contentDiv.ownerDocument;
|
|
8514
8927
|
};
|
|
8515
8928
|
/**
|
|
8516
8929
|
* Get the scroll container of the editor
|
|
8517
8930
|
*/
|
|
8518
8931
|
Editor.prototype.getScrollContainer = function () {
|
|
8519
|
-
return this.
|
|
8932
|
+
return this.getCore().domEvent.scrollContainer;
|
|
8520
8933
|
};
|
|
8521
8934
|
/**
|
|
8522
8935
|
* Get custom data related to this editor
|
|
@@ -8527,7 +8940,8 @@ var Editor = /** @class */ (function () {
|
|
|
8527
8940
|
* dispose editor.
|
|
8528
8941
|
*/
|
|
8529
8942
|
Editor.prototype.getCustomData = function (key, getter, disposer) {
|
|
8530
|
-
|
|
8943
|
+
var core = this.getCore();
|
|
8944
|
+
return (core.lifecycle.customData[key] = core.lifecycle.customData[key] || {
|
|
8531
8945
|
value: getter ? getter() : undefined,
|
|
8532
8946
|
disposer: disposer,
|
|
8533
8947
|
}).value;
|
|
@@ -8537,48 +8951,57 @@ var Editor = /** @class */ (function () {
|
|
|
8537
8951
|
* @returns True if editor is in IME input sequence, otherwise false
|
|
8538
8952
|
*/
|
|
8539
8953
|
Editor.prototype.isInIME = function () {
|
|
8540
|
-
return this.
|
|
8954
|
+
return this.getCore().domEvent.isInIME;
|
|
8541
8955
|
};
|
|
8542
8956
|
/**
|
|
8543
8957
|
* Get default format of this editor
|
|
8544
8958
|
* @returns Default format object of this editor
|
|
8545
8959
|
*/
|
|
8546
8960
|
Editor.prototype.getDefaultFormat = function () {
|
|
8547
|
-
return this.
|
|
8961
|
+
return this.getCore().lifecycle.defaultFormat;
|
|
8548
8962
|
};
|
|
8549
8963
|
/**
|
|
8550
8964
|
* Get a content traverser for the whole editor
|
|
8551
8965
|
* @param startNode The node to start from. If not passed, it will start from the beginning of the body
|
|
8552
8966
|
*/
|
|
8553
8967
|
Editor.prototype.getBodyTraverser = function (startNode) {
|
|
8554
|
-
return roosterjs_editor_dom_1.ContentTraverser.createBodyTraverser(this.
|
|
8968
|
+
return roosterjs_editor_dom_1.ContentTraverser.createBodyTraverser(this.getCore().contentDiv, startNode);
|
|
8555
8969
|
};
|
|
8556
8970
|
/**
|
|
8557
8971
|
* Get a content traverser for current selection
|
|
8972
|
+
* @returns A content traverser, or null if editor never got focus before
|
|
8558
8973
|
*/
|
|
8559
8974
|
Editor.prototype.getSelectionTraverser = function (range) {
|
|
8560
|
-
|
|
8561
|
-
|
|
8975
|
+
var _a;
|
|
8976
|
+
range = (_a = range !== null && range !== void 0 ? range : this.getSelectionRange()) !== null && _a !== void 0 ? _a : undefined;
|
|
8977
|
+
return range
|
|
8978
|
+
? roosterjs_editor_dom_1.ContentTraverser.createSelectionTraverser(this.getCore().contentDiv, range)
|
|
8979
|
+
: null;
|
|
8562
8980
|
};
|
|
8563
8981
|
/**
|
|
8564
8982
|
* Get a content traverser for current block element start from specified position
|
|
8565
8983
|
* @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart
|
|
8984
|
+
* @returns A content traverser, or null if editor never got focus before
|
|
8566
8985
|
*/
|
|
8567
8986
|
Editor.prototype.getBlockTraverser = function (startFrom) {
|
|
8568
8987
|
if (startFrom === void 0) { startFrom = 3 /* SelectionStart */; }
|
|
8569
8988
|
var range = this.getSelectionRange();
|
|
8570
|
-
return
|
|
8989
|
+
return range
|
|
8990
|
+
? roosterjs_editor_dom_1.ContentTraverser.createBlockTraverser(this.getCore().contentDiv, range, startFrom)
|
|
8991
|
+
: null;
|
|
8571
8992
|
};
|
|
8572
8993
|
/**
|
|
8573
8994
|
* Get a text traverser of current selection
|
|
8574
8995
|
* @param event Optional, if specified, editor will try to get cached result from the event object first.
|
|
8575
8996
|
* If it is not cached before, query from DOM and cache the result into the event object
|
|
8997
|
+
* @returns A content traverser, or null if editor never got focus before
|
|
8576
8998
|
*/
|
|
8577
8999
|
Editor.prototype.getContentSearcherOfCursor = function (event) {
|
|
8578
9000
|
var _this = this;
|
|
8579
|
-
return (0, roosterjs_editor_dom_1.cacheGetEventData)(event, 'ContentSearcher', function () {
|
|
9001
|
+
return (0, roosterjs_editor_dom_1.cacheGetEventData)(event !== null && event !== void 0 ? event : null, 'ContentSearcher', function () {
|
|
8580
9002
|
var range = _this.getSelectionRange();
|
|
8581
|
-
return (range &&
|
|
9003
|
+
return (range &&
|
|
9004
|
+
new roosterjs_editor_dom_1.PositionContentSearcher(_this.getCore().contentDiv, roosterjs_editor_dom_1.Position.getStart(range)));
|
|
8582
9005
|
});
|
|
8583
9006
|
};
|
|
8584
9007
|
/**
|
|
@@ -8588,7 +9011,7 @@ var Editor = /** @class */ (function () {
|
|
|
8588
9011
|
*/
|
|
8589
9012
|
Editor.prototype.runAsync = function (callback) {
|
|
8590
9013
|
var _this = this;
|
|
8591
|
-
var win = this.
|
|
9014
|
+
var win = this.getCore().contentDiv.ownerDocument.defaultView || window;
|
|
8592
9015
|
var handle = win.requestAnimationFrame(function () {
|
|
8593
9016
|
if (!_this.isDisposed() && callback) {
|
|
8594
9017
|
callback(_this);
|
|
@@ -8605,20 +9028,22 @@ var Editor = /** @class */ (function () {
|
|
|
8605
9028
|
*/
|
|
8606
9029
|
Editor.prototype.setEditorDomAttribute = function (name, value) {
|
|
8607
9030
|
if (value === null) {
|
|
8608
|
-
this.
|
|
9031
|
+
this.getCore().contentDiv.removeAttribute(name);
|
|
8609
9032
|
}
|
|
8610
9033
|
else {
|
|
8611
|
-
this.
|
|
9034
|
+
this.getCore().contentDiv.setAttribute(name, value);
|
|
8612
9035
|
}
|
|
8613
9036
|
};
|
|
8614
9037
|
/**
|
|
8615
|
-
*
|
|
9038
|
+
* Get DOM attribute of editor content DIV, null if there is no such attribute.
|
|
8616
9039
|
* @param name Name of the attribute
|
|
8617
9040
|
*/
|
|
8618
9041
|
Editor.prototype.getEditorDomAttribute = function (name) {
|
|
8619
|
-
return this.
|
|
9042
|
+
return this.getCore().contentDiv.getAttribute(name);
|
|
8620
9043
|
};
|
|
8621
9044
|
/**
|
|
9045
|
+
* @deprecated Use getVisibleViewport() instead.
|
|
9046
|
+
*
|
|
8622
9047
|
* Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.
|
|
8623
9048
|
* @param element The element to calculate from. If the given element is not in editor, return value will be null
|
|
8624
9049
|
* @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value
|
|
@@ -8627,7 +9052,7 @@ var Editor = /** @class */ (function () {
|
|
|
8627
9052
|
*/
|
|
8628
9053
|
Editor.prototype.getRelativeDistanceToEditor = function (element, addScroll) {
|
|
8629
9054
|
if (this.contains(element)) {
|
|
8630
|
-
var contentDiv = this.
|
|
9055
|
+
var contentDiv = this.getCore().contentDiv;
|
|
8631
9056
|
var editorRect = contentDiv.getBoundingClientRect();
|
|
8632
9057
|
var elementRect = element.getBoundingClientRect();
|
|
8633
9058
|
if (editorRect && elementRect) {
|
|
@@ -8647,22 +9072,24 @@ var Editor = /** @class */ (function () {
|
|
|
8647
9072
|
* @param feature The feature to add
|
|
8648
9073
|
*/
|
|
8649
9074
|
Editor.prototype.addContentEditFeature = function (feature) {
|
|
8650
|
-
var
|
|
9075
|
+
var core = this.getCore();
|
|
8651
9076
|
feature === null || feature === void 0 ? void 0 : feature.keys.forEach(function (key) {
|
|
8652
|
-
var array =
|
|
9077
|
+
var array = core.edit.features[key] || [];
|
|
8653
9078
|
array.push(feature);
|
|
8654
|
-
|
|
9079
|
+
core.edit.features[key] = array;
|
|
8655
9080
|
});
|
|
8656
9081
|
};
|
|
8657
9082
|
/**
|
|
8658
9083
|
* Get style based format state from current selection, including font name/size and colors
|
|
8659
9084
|
*/
|
|
8660
9085
|
Editor.prototype.getStyleBasedFormatState = function (node) {
|
|
9086
|
+
var _a;
|
|
8661
9087
|
if (!node) {
|
|
8662
9088
|
var range = this.getSelectionRange();
|
|
8663
|
-
node = range && roosterjs_editor_dom_1.Position.getStart(range).normalize().node;
|
|
9089
|
+
node = (_a = (range && roosterjs_editor_dom_1.Position.getStart(range).normalize().node)) !== null && _a !== void 0 ? _a : undefined;
|
|
8664
9090
|
}
|
|
8665
|
-
|
|
9091
|
+
var core = this.getCore();
|
|
9092
|
+
return core.api.getStyleBasedFormatState(core, node !== null && node !== void 0 ? node : null);
|
|
8666
9093
|
};
|
|
8667
9094
|
/**
|
|
8668
9095
|
* Get the pendable format such as underline and bold
|
|
@@ -8670,7 +9097,9 @@ var Editor = /** @class */ (function () {
|
|
|
8670
9097
|
* @returns The pending format state
|
|
8671
9098
|
*/
|
|
8672
9099
|
Editor.prototype.getPendableFormatState = function (forceGetStateFromDOM) {
|
|
8673
|
-
|
|
9100
|
+
if (forceGetStateFromDOM === void 0) { forceGetStateFromDOM = false; }
|
|
9101
|
+
var core = this.getCore();
|
|
9102
|
+
return core.api.getPendableFormatState(core, forceGetStateFromDOM);
|
|
8674
9103
|
};
|
|
8675
9104
|
/**
|
|
8676
9105
|
* Ensure user will type into a container element rather than into the editor content DIV directly
|
|
@@ -8678,7 +9107,8 @@ var Editor = /** @class */ (function () {
|
|
|
8678
9107
|
* @param keyboardEvent Optional keyboard event object
|
|
8679
9108
|
*/
|
|
8680
9109
|
Editor.prototype.ensureTypeInContainer = function (position, keyboardEvent) {
|
|
8681
|
-
this.
|
|
9110
|
+
var core = this.getCore();
|
|
9111
|
+
core.api.ensureTypeInContainer(core, position, keyboardEvent);
|
|
8682
9112
|
};
|
|
8683
9113
|
//#endregion
|
|
8684
9114
|
//#region Dark mode APIs
|
|
@@ -8690,7 +9120,8 @@ var Editor = /** @class */ (function () {
|
|
|
8690
9120
|
if (this.isDarkMode() == !!nextDarkMode) {
|
|
8691
9121
|
return;
|
|
8692
9122
|
}
|
|
8693
|
-
|
|
9123
|
+
var core = this.getCore();
|
|
9124
|
+
core.api.transformColor(core, core.contentDiv, false /*includeSelf*/, null /*callback*/, nextDarkMode
|
|
8694
9125
|
? 0 /* LightToDark */
|
|
8695
9126
|
: 1 /* DarkToLight */, true /*forceTransform*/);
|
|
8696
9127
|
this.triggerContentChangedEvent(nextDarkMode ? "SwitchToDarkMode" /* SwitchToDarkMode */ : "SwitchToLightMode" /* SwitchToLightMode */);
|
|
@@ -8700,14 +9131,15 @@ var Editor = /** @class */ (function () {
|
|
|
8700
9131
|
* @returns True if the editor is in dark mode, otherwise false
|
|
8701
9132
|
*/
|
|
8702
9133
|
Editor.prototype.isDarkMode = function () {
|
|
8703
|
-
return this.
|
|
9134
|
+
return this.getCore().lifecycle.isDarkMode;
|
|
8704
9135
|
};
|
|
8705
9136
|
/**
|
|
8706
9137
|
* Transform the given node and all its child nodes to dark mode color if editor is in dark mode
|
|
8707
9138
|
* @param node The node to transform
|
|
8708
9139
|
*/
|
|
8709
9140
|
Editor.prototype.transformToDarkColor = function (node) {
|
|
8710
|
-
this.
|
|
9141
|
+
var core = this.getCore();
|
|
9142
|
+
core.api.transformColor(core, node, true /*includeSelf*/, null /*callback*/, 0 /* LightToDark */);
|
|
8711
9143
|
};
|
|
8712
9144
|
/**
|
|
8713
9145
|
* Make the editor in "Shadow Edit" mode.
|
|
@@ -8718,26 +9150,28 @@ var Editor = /** @class */ (function () {
|
|
|
8718
9150
|
* use this function to do more shadow edit operation.
|
|
8719
9151
|
*/
|
|
8720
9152
|
Editor.prototype.startShadowEdit = function () {
|
|
8721
|
-
this.
|
|
9153
|
+
var core = this.getCore();
|
|
9154
|
+
core.api.switchShadowEdit(core, true /*isOn*/);
|
|
8722
9155
|
};
|
|
8723
9156
|
/**
|
|
8724
9157
|
* Leave "Shadow Edit" mode, all changes made during shadow edit will be discarded
|
|
8725
9158
|
*/
|
|
8726
9159
|
Editor.prototype.stopShadowEdit = function () {
|
|
8727
|
-
this.
|
|
9160
|
+
var core = this.getCore();
|
|
9161
|
+
core.api.switchShadowEdit(core, false /*isOn*/);
|
|
8728
9162
|
};
|
|
8729
9163
|
/**
|
|
8730
9164
|
* Check if editor is in Shadow Edit mode
|
|
8731
9165
|
*/
|
|
8732
9166
|
Editor.prototype.isInShadowEdit = function () {
|
|
8733
|
-
return !!this.
|
|
9167
|
+
return !!this.getCore().lifecycle.shadowEditFragment;
|
|
8734
9168
|
};
|
|
8735
9169
|
/**
|
|
8736
9170
|
* Check if the given experimental feature is enabled
|
|
8737
9171
|
* @param feature The feature to check
|
|
8738
9172
|
*/
|
|
8739
9173
|
Editor.prototype.isFeatureEnabled = function (feature) {
|
|
8740
|
-
return this.
|
|
9174
|
+
return this.getCore().lifecycle.experimentalFeatures.indexOf(feature) >= 0;
|
|
8741
9175
|
};
|
|
8742
9176
|
/**
|
|
8743
9177
|
* Get a function to convert HTML string to trusted HTML string.
|
|
@@ -8746,13 +9180,13 @@ var Editor = /** @class */ (function () {
|
|
|
8746
9180
|
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
8747
9181
|
*/
|
|
8748
9182
|
Editor.prototype.getTrustedHTMLHandler = function () {
|
|
8749
|
-
return this.
|
|
9183
|
+
return this.getCore().trustedHTMLHandler;
|
|
8750
9184
|
};
|
|
8751
9185
|
/**
|
|
8752
9186
|
* @deprecated Use getZoomScale() instead
|
|
8753
9187
|
*/
|
|
8754
9188
|
Editor.prototype.getSizeTransformer = function () {
|
|
8755
|
-
return this.
|
|
9189
|
+
return this.getCore().sizeTransformer;
|
|
8756
9190
|
};
|
|
8757
9191
|
/**
|
|
8758
9192
|
* Get current zoom scale, default value is 1
|
|
@@ -8761,7 +9195,7 @@ var Editor = /** @class */ (function () {
|
|
|
8761
9195
|
* @returns current zoom scale number
|
|
8762
9196
|
*/
|
|
8763
9197
|
Editor.prototype.getZoomScale = function () {
|
|
8764
|
-
return this.
|
|
9198
|
+
return this.getCore().zoomScale;
|
|
8765
9199
|
};
|
|
8766
9200
|
/**
|
|
8767
9201
|
* Set current zoom scale, default value is 1
|
|
@@ -8770,9 +9204,10 @@ var Editor = /** @class */ (function () {
|
|
|
8770
9204
|
* @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.
|
|
8771
9205
|
*/
|
|
8772
9206
|
Editor.prototype.setZoomScale = function (scale) {
|
|
9207
|
+
var core = this.getCore();
|
|
8773
9208
|
if (scale > 0 && scale <= 10) {
|
|
8774
|
-
var oldValue =
|
|
8775
|
-
|
|
9209
|
+
var oldValue = core.zoomScale;
|
|
9210
|
+
core.zoomScale = scale;
|
|
8776
9211
|
if (oldValue != scale) {
|
|
8777
9212
|
this.triggerPluginEvent(21 /* ZoomChanged */, {
|
|
8778
9213
|
oldZoomScale: oldValue,
|
|
@@ -8781,6 +9216,22 @@ var Editor = /** @class */ (function () {
|
|
|
8781
9216
|
}
|
|
8782
9217
|
}
|
|
8783
9218
|
};
|
|
9219
|
+
/**
|
|
9220
|
+
* Retrieves the rect of the visible viewport of the editor.
|
|
9221
|
+
*/
|
|
9222
|
+
Editor.prototype.getVisibleViewport = function () {
|
|
9223
|
+
return this.getCore().getVisibleViewport();
|
|
9224
|
+
};
|
|
9225
|
+
/**
|
|
9226
|
+
* @returns the current EditorCore object
|
|
9227
|
+
* @throws a standard Error if there's no core object
|
|
9228
|
+
*/
|
|
9229
|
+
Editor.prototype.getCore = function () {
|
|
9230
|
+
if (!this.core) {
|
|
9231
|
+
throw new Error('Editor is already disposed');
|
|
9232
|
+
}
|
|
9233
|
+
return this.core;
|
|
9234
|
+
};
|
|
8784
9235
|
return Editor;
|
|
8785
9236
|
}());
|
|
8786
9237
|
exports.default = Editor;
|
|
@@ -11547,9 +11998,9 @@ exports.default = getPredefinedCssForElement;
|
|
|
11547
11998
|
"use strict";
|
|
11548
11999
|
|
|
11549
12000
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11550
|
-
exports.
|
|
11551
|
-
exports.
|
|
11552
|
-
exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = void 0;
|
|
12001
|
+
exports.getIntersectedRect = exports.moveChildNodes = exports.KnownCreateElementData = exports.createElement = exports.matchesSelector = exports.setColor = exports.getInnerHTML = exports.readFile = exports.safeInstanceOf = exports.normalizeRect = exports.splitTextNode = exports.getLastLeafNode = exports.getFirstLeafNode = exports.getPreviousLeafSibling = exports.getNextLeafSibling = exports.wrap = exports.unwrap = exports.splitBalancedNodeRange = exports.splitParentNode = exports.queryElements = exports.matchLink = exports.isVoidHtmlElement = exports.isNodeEmpty = exports.isBlockElement = exports.getTagOfNode = exports.PendableFormatCommandMap = exports.getPendableFormatState = exports.getComputedStyle = exports.getComputedStyles = exports.fromHtml = exports.findClosestElementAncestor = exports.contains = exports.collapseNodes = exports.changeElementTag = exports.applyFormat = exports.getBrowserInfo = exports.Browser = exports.extractClipboardItemsForIE = exports.extractClipboardItems = exports.extractClipboardEvent = exports.applyTextStyle = exports.PartialInlineElement = exports.NodeInlineElement = exports.LinkInlineElement = exports.ImageInlineElement = exports.getInlineElementAtNode = exports.PositionContentSearcher = exports.ContentTraverser = exports.getFirstLastBlockElement = exports.getBlockElementAtNode = void 0;
|
|
12002
|
+
exports.getTextContent = exports.deleteSelectedContent = exports.adjustInsertPosition = exports.setStyles = exports.getStyles = exports.isCtrlOrMetaPressed = exports.isCharacterValue = exports.isModifierKey = exports.clearEventDataCache = exports.cacheGetEventData = exports.getEntitySelector = exports.getEntityFromElement = exports.commitEntity = exports.chainSanitizerCallback = exports.createDefaultHtmlSanitizerOptions = exports.getInheritableStyles = exports.HtmlSanitizer = exports.canUndoAutoComplete = exports.createSnapshots = exports.moveCurrentSnapsnot = exports.moveCurrentSnapshot = exports.clearProceedingSnapshotsV2 = exports.clearProceedingSnapshots = exports.canMoveCurrentSnapshot = exports.addSnapshotV2 = exports.addSnapshot = exports.addRangeToSelection = exports.setHtmlWithMetadata = exports.setHtmlWithSelectionPath = exports.getHtmlWithSelectionPath = exports.getSelectionPath = exports.isPositionAtBeginningOf = exports.getPositionRect = exports.createRange = exports.Position = exports.mergeBlocksInRegion = exports.getSelectionRangeInRegion = exports.isNodeInRegion = exports.collapseNodesInRegion = exports.getSelectedBlockElementsInRegion = exports.getRegionsFromRange = exports.saveTableCellMetadata = exports.getTableFormatInfo = exports.setListItemStyle = exports.VListChain = exports.createVListFromRegion = exports.VListItem = exports.VList = exports.isWholeTableSelected = exports.VTable = void 0;
|
|
12003
|
+
exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = exports.createNumberDefinition = exports.validate = void 0;
|
|
11553
12004
|
var getBlockElementAtNode_1 = __webpack_require__(/*! ./blockElements/getBlockElementAtNode */ "./packages/roosterjs-editor-dom/lib/blockElements/getBlockElementAtNode.ts");
|
|
11554
12005
|
Object.defineProperty(exports, "getBlockElementAtNode", { enumerable: true, get: function () { return getBlockElementAtNode_1.default; } });
|
|
11555
12006
|
var getFirstLastBlockElement_1 = __webpack_require__(/*! ./blockElements/getFirstLastBlockElement */ "./packages/roosterjs-editor-dom/lib/blockElements/getFirstLastBlockElement.ts");
|
|
@@ -11641,6 +12092,8 @@ Object.defineProperty(exports, "createElement", { enumerable: true, get: functio
|
|
|
11641
12092
|
Object.defineProperty(exports, "KnownCreateElementData", { enumerable: true, get: function () { return createElement_1.KnownCreateElementData; } });
|
|
11642
12093
|
var moveChildNodes_1 = __webpack_require__(/*! ./utils/moveChildNodes */ "./packages/roosterjs-editor-dom/lib/utils/moveChildNodes.ts");
|
|
11643
12094
|
Object.defineProperty(exports, "moveChildNodes", { enumerable: true, get: function () { return moveChildNodes_1.default; } });
|
|
12095
|
+
var getIntersectedRect_1 = __webpack_require__(/*! ./utils/getIntersectedRect */ "./packages/roosterjs-editor-dom/lib/utils/getIntersectedRect.ts");
|
|
12096
|
+
Object.defineProperty(exports, "getIntersectedRect", { enumerable: true, get: function () { return getIntersectedRect_1.default; } });
|
|
11644
12097
|
var VTable_1 = __webpack_require__(/*! ./table/VTable */ "./packages/roosterjs-editor-dom/lib/table/VTable.ts");
|
|
11645
12098
|
Object.defineProperty(exports, "VTable", { enumerable: true, get: function () { return VTable_1.default; } });
|
|
11646
12099
|
var isWholeTableSelected_1 = __webpack_require__(/*! ./table/isWholeTableSelected */ "./packages/roosterjs-editor-dom/lib/table/isWholeTableSelected.ts");
|
|
@@ -11657,6 +12110,8 @@ var setListItemStyle_1 = __webpack_require__(/*! ./list/setListItemStyle */ "./p
|
|
|
11657
12110
|
Object.defineProperty(exports, "setListItemStyle", { enumerable: true, get: function () { return setListItemStyle_1.default; } });
|
|
11658
12111
|
var tableFormatInfo_1 = __webpack_require__(/*! ./table/tableFormatInfo */ "./packages/roosterjs-editor-dom/lib/table/tableFormatInfo.ts");
|
|
11659
12112
|
Object.defineProperty(exports, "getTableFormatInfo", { enumerable: true, get: function () { return tableFormatInfo_1.getTableFormatInfo; } });
|
|
12113
|
+
var tableCellInfo_1 = __webpack_require__(/*! ./table/tableCellInfo */ "./packages/roosterjs-editor-dom/lib/table/tableCellInfo.ts");
|
|
12114
|
+
Object.defineProperty(exports, "saveTableCellMetadata", { enumerable: true, get: function () { return tableCellInfo_1.saveTableCellMetadata; } });
|
|
11660
12115
|
var getRegionsFromRange_1 = __webpack_require__(/*! ./region/getRegionsFromRange */ "./packages/roosterjs-editor-dom/lib/region/getRegionsFromRange.ts");
|
|
11661
12116
|
Object.defineProperty(exports, "getRegionsFromRange", { enumerable: true, get: function () { return getRegionsFromRange_1.default; } });
|
|
11662
12117
|
var getSelectedBlockElementsInRegion_1 = __webpack_require__(/*! ./region/getSelectedBlockElementsInRegion */ "./packages/roosterjs-editor-dom/lib/region/getSelectedBlockElementsInRegion.ts");
|
|
@@ -12627,8 +13082,10 @@ var VList = /** @class */ (function () {
|
|
|
12627
13082
|
/**
|
|
12628
13083
|
* Write the result back into DOM tree
|
|
12629
13084
|
* After that, this VList becomes unavailable because we set this.rootList to null
|
|
13085
|
+
*
|
|
13086
|
+
* @param shouldReuseAllAncestorListElements Optional - defaults to false.
|
|
12630
13087
|
*/
|
|
12631
|
-
VList.prototype.writeBack = function () {
|
|
13088
|
+
VList.prototype.writeBack = function (shouldReuseAllAncestorListElements) {
|
|
12632
13089
|
var _this = this;
|
|
12633
13090
|
if (!this.rootList) {
|
|
12634
13091
|
throw new Error('rootList must not be null');
|
|
@@ -12646,7 +13103,7 @@ var VList = /** @class */ (function () {
|
|
|
12646
13103
|
listStack.splice(1, listStack.length - 1);
|
|
12647
13104
|
start = newListStart;
|
|
12648
13105
|
}
|
|
12649
|
-
item.writeBack(listStack, _this.rootList);
|
|
13106
|
+
item.writeBack(listStack, _this.rootList, shouldReuseAllAncestorListElements);
|
|
12650
13107
|
var topList = listStack[1];
|
|
12651
13108
|
if ((0, safeInstanceOf_1.default)(topList, 'HTMLOListElement')) {
|
|
12652
13109
|
if (lastList != topList) {
|
|
@@ -13026,7 +13483,7 @@ var VListChain = /** @class */ (function () {
|
|
|
13026
13483
|
* After change the lists, commit the change to all lists in this chain to update the list number,
|
|
13027
13484
|
* and clear the temporary dataset values added to list node
|
|
13028
13485
|
*/
|
|
13029
|
-
VListChain.prototype.commit = function () {
|
|
13486
|
+
VListChain.prototype.commit = function (shouldReuseAllAncestorListElements) {
|
|
13030
13487
|
var lists = this.getLists();
|
|
13031
13488
|
var lastNumber = 0;
|
|
13032
13489
|
for (var i = 0; i < lists.length; i++) {
|
|
@@ -13036,7 +13493,7 @@ var VListChain = /** @class */ (function () {
|
|
|
13036
13493
|
lastNumber = vlist.getLastItemNumber() || 0;
|
|
13037
13494
|
delete list.dataset[CHAIN_DATASET_NAME];
|
|
13038
13495
|
delete list.dataset[AFTER_CURSOR_DATASET_NAME];
|
|
13039
|
-
vlist.writeBack();
|
|
13496
|
+
vlist.writeBack(shouldReuseAllAncestorListElements);
|
|
13040
13497
|
}
|
|
13041
13498
|
};
|
|
13042
13499
|
/**
|
|
@@ -13122,7 +13579,7 @@ var NEGATIVE_MARGIN = '-.25in';
|
|
|
13122
13579
|
*/
|
|
13123
13580
|
exports.ListStyleDefinitionMetadata = (0, definitionCreators_1.createObjectDefinition)({
|
|
13124
13581
|
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 */,
|
|
13582
|
+
unorderedStyleType: (0, definitionCreators_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 9 /* Max */),
|
|
13126
13583
|
}, true /** isOptional */, true /** allowNull */);
|
|
13127
13584
|
/**
|
|
13128
13585
|
* !!! Never directly create instance of this class. It should be created within VList class !!!
|
|
@@ -13310,19 +13767,41 @@ var VListItem = /** @class */ (function () {
|
|
|
13310
13767
|
* Write the change result back into DOM
|
|
13311
13768
|
* @param listStack current stack of list elements
|
|
13312
13769
|
* @param originalRoot Original list root element. It will be reused when write back if possible
|
|
13770
|
+
* @param shouldReuseAllAncestorListElements Optional - defaults to false. If true, only make
|
|
13771
|
+
* sure the direct parent of this list matches the list types when writing back.
|
|
13313
13772
|
*/
|
|
13314
|
-
VListItem.prototype.writeBack = function (listStack, originalRoot) {
|
|
13773
|
+
VListItem.prototype.writeBack = function (listStack, originalRoot, shouldReuseAllAncestorListElements) {
|
|
13315
13774
|
var _a;
|
|
13775
|
+
if (shouldReuseAllAncestorListElements === void 0) { shouldReuseAllAncestorListElements = false; }
|
|
13316
13776
|
var nextLevel = 1;
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
if
|
|
13324
|
-
|
|
13325
|
-
|
|
13777
|
+
if (shouldReuseAllAncestorListElements) {
|
|
13778
|
+
// Remove any un-needed lists from the stack.
|
|
13779
|
+
if (listStack.length > this.listTypes.length) {
|
|
13780
|
+
listStack.splice(this.listTypes.length);
|
|
13781
|
+
}
|
|
13782
|
+
// 1. If the listStack is the same length as the listTypes for this item, check
|
|
13783
|
+
// if the last item needs to change, and remove it if needed. We can always re-use
|
|
13784
|
+
// the other lists even if the type doesn't match - since the display is the same
|
|
13785
|
+
// as long as the list immediately surrounding the item is correct.
|
|
13786
|
+
var listStackEndIndex = listStack.length - 1;
|
|
13787
|
+
if (listStackEndIndex === this.listTypes.length - 1 && // they are the same length
|
|
13788
|
+
(0, getListTypeFromNode_1.default)(listStack[listStackEndIndex]) !==
|
|
13789
|
+
this.listTypes[listStackEndIndex]) {
|
|
13790
|
+
listStack.splice(listStackEndIndex);
|
|
13791
|
+
}
|
|
13792
|
+
nextLevel = listStack.length;
|
|
13793
|
+
}
|
|
13794
|
+
else {
|
|
13795
|
+
// 1. Determine list elements that we can reuse
|
|
13796
|
+
// e.g.:
|
|
13797
|
+
// passed in listStack: Fragment > OL > UL > OL
|
|
13798
|
+
// local listTypes: null > OL > UL > UL > OL
|
|
13799
|
+
// then Fragment > OL > UL can be reused
|
|
13800
|
+
for (; nextLevel < listStack.length; nextLevel++) {
|
|
13801
|
+
if ((0, getListTypeFromNode_1.default)(listStack[nextLevel]) !== this.listTypes[nextLevel]) {
|
|
13802
|
+
listStack.splice(nextLevel);
|
|
13803
|
+
break;
|
|
13804
|
+
}
|
|
13326
13805
|
}
|
|
13327
13806
|
}
|
|
13328
13807
|
// 2. Add new list elements
|
|
@@ -13339,7 +13818,8 @@ var VListItem = /** @class */ (function () {
|
|
|
13339
13818
|
//apply the styles of the current parent list to the new list
|
|
13340
13819
|
if (this.getDeepChildIndex(originalRoot) == stackLength) {
|
|
13341
13820
|
var listStyleType = (_a = this.node.parentElement) === null || _a === void 0 ? void 0 : _a.style.listStyleType;
|
|
13342
|
-
if (listStyleType
|
|
13821
|
+
if (listStyleType &&
|
|
13822
|
+
(0, getTagOfNode_1.default)(this.node.parentElement) === (0, getTagOfNode_1.default)(newList)) {
|
|
13343
13823
|
newList.style.listStyleType = listStyleType;
|
|
13344
13824
|
}
|
|
13345
13825
|
}
|
|
@@ -13349,10 +13829,8 @@ var VListItem = /** @class */ (function () {
|
|
|
13349
13829
|
this.node.style.setProperty('display', this.dummy ? 'block' : null);
|
|
13350
13830
|
// 4. Inherit styles of the child element to the li, so we are able to apply the styles to the ::marker
|
|
13351
13831
|
if (this.listTypes.length > 1) {
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
(0, setListItemStyle_1.default)(this.node, stylesToInherit);
|
|
13355
|
-
}
|
|
13832
|
+
var stylesToInherit = ['font-size', 'font-family', 'color'];
|
|
13833
|
+
(0, setListItemStyle_1.default)(this.node, stylesToInherit);
|
|
13356
13834
|
}
|
|
13357
13835
|
// 5. If this is not a list item now, need to unwrap the LI node and do proper handling
|
|
13358
13836
|
if (this.listTypes.length <= 1) {
|
|
@@ -13782,6 +14260,7 @@ var bulletListStyle = (_a = {},
|
|
|
13782
14260
|
_a[3 /* Square */] = 'square',
|
|
13783
14261
|
_a[2 /* Dash */] = '- ',
|
|
13784
14262
|
_a[5 /* LongArrow */] = '→ ',
|
|
14263
|
+
_a[8 /* DoubleLongArrow */] = '→ ',
|
|
13785
14264
|
_a[4 /* ShortArrow */] = '➢ ',
|
|
13786
14265
|
_a[6 /* UnfilledArrow */] = '➪ ',
|
|
13787
14266
|
_a[7 /* Hyphen */] = '— ',
|
|
@@ -13812,7 +14291,7 @@ var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roos
|
|
|
13812
14291
|
* @param styles The styles that should be applied to the element.
|
|
13813
14292
|
*/
|
|
13814
14293
|
function setListItemStyle(element, styles) {
|
|
13815
|
-
var elementsStyles = getInlineChildElementsStyle(element);
|
|
14294
|
+
var elementsStyles = getInlineChildElementsStyle(element, styles);
|
|
13816
14295
|
var stylesToApply = (0, getStyles_1.default)(element);
|
|
13817
14296
|
styles.forEach(function (styleName) {
|
|
13818
14297
|
var styleValues = elementsStyles.map(function (style) {
|
|
@@ -13827,21 +14306,41 @@ function setListItemStyle(element, styles) {
|
|
|
13827
14306
|
(0, setStyles_1.default)(element, stylesToApply);
|
|
13828
14307
|
}
|
|
13829
14308
|
exports.default = setListItemStyle;
|
|
13830
|
-
function getInlineChildElementsStyle(element) {
|
|
14309
|
+
function getInlineChildElementsStyle(element, styles) {
|
|
14310
|
+
var _a;
|
|
13831
14311
|
var result = [];
|
|
13832
14312
|
var contentTraverser = ContentTraverser_1.default.createBodyTraverser(element);
|
|
13833
14313
|
var currentInlineElement = null;
|
|
13834
|
-
|
|
14314
|
+
var _loop_1 = function () {
|
|
13835
14315
|
currentInlineElement = contentTraverser.currentInlineElement;
|
|
13836
14316
|
var currentNode = (currentInlineElement === null || currentInlineElement === void 0 ? void 0 : currentInlineElement.getContainerNode()) || null;
|
|
14317
|
+
var currentStyle = {};
|
|
13837
14318
|
currentNode = currentNode ? (0, findClosestElementAncestor_1.default)(currentNode) : null;
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
14319
|
+
// we should consider of when it is the single childnode of element, the parentNode's style should add
|
|
14320
|
+
// such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
|
|
14321
|
+
while (currentNode &&
|
|
14322
|
+
currentNode !== element &&
|
|
14323
|
+
(0, safeInstanceOf_1.default)(currentNode, 'HTMLElement')) {
|
|
14324
|
+
styles.forEach(function (styleName) {
|
|
14325
|
+
var styleValue = currentNode.style.getPropertyValue(styleName);
|
|
14326
|
+
if (styleValue && !currentStyle[styleName]) {
|
|
14327
|
+
currentStyle[styleName] = styleValue;
|
|
14328
|
+
}
|
|
14329
|
+
});
|
|
14330
|
+
if (((_a = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _a === void 0 ? void 0 : _a.childNodes.length) === 1) {
|
|
14331
|
+
currentNode = currentNode.parentNode;
|
|
14332
|
+
}
|
|
14333
|
+
else {
|
|
14334
|
+
currentNode = null;
|
|
13842
14335
|
}
|
|
13843
14336
|
}
|
|
14337
|
+
if (currentStyle) {
|
|
14338
|
+
result.push(currentStyle);
|
|
14339
|
+
}
|
|
13844
14340
|
contentTraverser.getNextInlineElement();
|
|
14341
|
+
};
|
|
14342
|
+
while (contentTraverser.currentInlineElement != currentInlineElement) {
|
|
14343
|
+
_loop_1();
|
|
13845
14344
|
}
|
|
13846
14345
|
return result;
|
|
13847
14346
|
}
|
|
@@ -14186,6 +14685,10 @@ function validate(input, def) {
|
|
|
14186
14685
|
if ((def.isOptional && typeof input === 'undefined') || (def.allowNull && input === null)) {
|
|
14187
14686
|
result = true;
|
|
14188
14687
|
}
|
|
14688
|
+
else if ((!def.isOptional && typeof input === 'undefined') ||
|
|
14689
|
+
(!def.allowNull && input === null)) {
|
|
14690
|
+
return false;
|
|
14691
|
+
}
|
|
14189
14692
|
else {
|
|
14190
14693
|
switch (def.type) {
|
|
14191
14694
|
case 2 /* String */:
|
|
@@ -14813,7 +15316,7 @@ function getEndOffset(node) {
|
|
|
14813
15316
|
if (node.nodeType == 3 /* Text */) {
|
|
14814
15317
|
return ((_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
14815
15318
|
}
|
|
14816
|
-
else if (node.nodeType == 1 /* Element */) {
|
|
15319
|
+
else if (node.nodeType == 1 /* Element */ || node.nodeType == 11 /* DocumentFragment */) {
|
|
14817
15320
|
return node.childNodes.length;
|
|
14818
15321
|
}
|
|
14819
15322
|
else {
|
|
@@ -15318,6 +15821,10 @@ function addSnapshot(snapshots, snapshot, isAutoCompleteSnapshot, getLength, com
|
|
|
15318
15821
|
snapshots.autoCompleteIndex = snapshots.currentIndex;
|
|
15319
15822
|
}
|
|
15320
15823
|
}
|
|
15824
|
+
else if (currentSnapshot && compare(snapshot, currentSnapshot)) {
|
|
15825
|
+
// replace the currentSnapshot, to update other data such as metadata
|
|
15826
|
+
snapshots.snapshots.splice(snapshots.currentIndex, 1, snapshot);
|
|
15827
|
+
}
|
|
15321
15828
|
}
|
|
15322
15829
|
exports.default = addSnapshot;
|
|
15323
15830
|
/**
|
|
@@ -15588,12 +16095,13 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15588
16095
|
};
|
|
15589
16096
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15590
16097
|
var applyTableFormat_1 = __webpack_require__(/*! ./applyTableFormat */ "./packages/roosterjs-editor-dom/lib/table/applyTableFormat.ts");
|
|
16098
|
+
var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
|
|
15591
16099
|
var moveChildNodes_1 = __webpack_require__(/*! ../utils/moveChildNodes */ "./packages/roosterjs-editor-dom/lib/utils/moveChildNodes.ts");
|
|
15592
16100
|
var normalizeRect_1 = __webpack_require__(/*! ../utils/normalizeRect */ "./packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts");
|
|
15593
16101
|
var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
|
|
15594
16102
|
var toArray_1 = __webpack_require__(/*! ../jsUtils/toArray */ "./packages/roosterjs-editor-dom/lib/jsUtils/toArray.ts");
|
|
15595
16103
|
var tableFormatInfo_1 = __webpack_require__(/*! ./tableFormatInfo */ "./packages/roosterjs-editor-dom/lib/table/tableFormatInfo.ts");
|
|
15596
|
-
var
|
|
16104
|
+
var metadata_1 = __webpack_require__(/*! ../metadata/metadata */ "./packages/roosterjs-editor-dom/lib/metadata/metadata.ts");
|
|
15597
16105
|
var DEFAULT_FORMAT = {
|
|
15598
16106
|
topBorderColor: '#ABABAB',
|
|
15599
16107
|
bottomBorderColor: '#ABABAB',
|
|
@@ -15624,15 +16132,12 @@ var VTable = /** @class */ (function () {
|
|
|
15624
16132
|
* Virtual cells
|
|
15625
16133
|
*/
|
|
15626
16134
|
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
16135
|
/**
|
|
15632
16136
|
* Current format of the table
|
|
15633
16137
|
*/
|
|
15634
16138
|
this.formatInfo = null;
|
|
15635
16139
|
this.trs = [];
|
|
16140
|
+
this.tableSelection = null;
|
|
15636
16141
|
this.table = (0, safeInstanceOf_1.default)(node, 'HTMLTableElement') ? node : getTableFromTd(node);
|
|
15637
16142
|
if (this.table) {
|
|
15638
16143
|
var currentTd_1 = (0, safeInstanceOf_1.default)(node, 'HTMLTableElement') ? null : node;
|
|
@@ -15672,6 +16177,24 @@ var VTable = /** @class */ (function () {
|
|
|
15672
16177
|
}
|
|
15673
16178
|
}
|
|
15674
16179
|
}
|
|
16180
|
+
Object.defineProperty(VTable.prototype, "selection", {
|
|
16181
|
+
/**
|
|
16182
|
+
* Selected range of cells with the coordinates of the first and last cell selected.
|
|
16183
|
+
*/
|
|
16184
|
+
get: function () {
|
|
16185
|
+
return this.tableSelection || null;
|
|
16186
|
+
},
|
|
16187
|
+
set: function (value) {
|
|
16188
|
+
if (value) {
|
|
16189
|
+
var firstCell = value.firstCell;
|
|
16190
|
+
this.row = firstCell === null || firstCell === void 0 ? void 0 : firstCell.y;
|
|
16191
|
+
this.col = firstCell === null || firstCell === void 0 ? void 0 : firstCell.x;
|
|
16192
|
+
}
|
|
16193
|
+
this.tableSelection = value;
|
|
16194
|
+
},
|
|
16195
|
+
enumerable: false,
|
|
16196
|
+
configurable: true
|
|
16197
|
+
});
|
|
15675
16198
|
/**
|
|
15676
16199
|
* Write the virtual table back to DOM tree to represent the change of VTable
|
|
15677
16200
|
* @param skipApplyFormat Do not reapply table format when write back.
|
|
@@ -15689,6 +16212,7 @@ var VTable = /** @class */ (function () {
|
|
|
15689
16212
|
row.forEach(function (cell, c) {
|
|
15690
16213
|
if (cell.td) {
|
|
15691
16214
|
_this.recalculateSpans(r, c);
|
|
16215
|
+
_this.recalculateCellHeight(cell.td);
|
|
15692
16216
|
tr.appendChild(cell.td);
|
|
15693
16217
|
}
|
|
15694
16218
|
});
|
|
@@ -15703,6 +16227,14 @@ var VTable = /** @class */ (function () {
|
|
|
15703
16227
|
(_a = this.table.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.table);
|
|
15704
16228
|
}
|
|
15705
16229
|
};
|
|
16230
|
+
VTable.prototype.recalculateCellHeight = function (td) {
|
|
16231
|
+
if (this.isEmptyCell(td) && td.rowSpan > 1) {
|
|
16232
|
+
for (var i = 1; i < td.rowSpan; i++) {
|
|
16233
|
+
var br = document.createElement('br');
|
|
16234
|
+
td.appendChild(br);
|
|
16235
|
+
}
|
|
16236
|
+
}
|
|
16237
|
+
};
|
|
15706
16238
|
/**
|
|
15707
16239
|
* Apply the given table format to this virtual table
|
|
15708
16240
|
* @param format Table format to apply
|
|
@@ -15723,8 +16255,8 @@ var VTable = /** @class */ (function () {
|
|
|
15723
16255
|
VTable.prototype.deleteCellShadeDataset = function (cells) {
|
|
15724
16256
|
cells === null || cells === void 0 ? void 0 : cells.forEach(function (row) {
|
|
15725
16257
|
row.forEach(function (cell) {
|
|
15726
|
-
if (cell.td
|
|
15727
|
-
|
|
16258
|
+
if (cell.td) {
|
|
16259
|
+
(0, metadata_1.removeMetadata)(cell.td);
|
|
15728
16260
|
}
|
|
15729
16261
|
});
|
|
15730
16262
|
});
|
|
@@ -15983,7 +16515,7 @@ var VTable = /** @class */ (function () {
|
|
|
15983
16515
|
? ((_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
16516
|
: ((_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
16517
|
if (cell.td && nextCell.td && checkSpans) {
|
|
15986
|
-
|
|
16518
|
+
this.mergeCellContents(cell.td, nextCell.td);
|
|
15987
16519
|
nextCell.td = null;
|
|
15988
16520
|
if (horizontally) {
|
|
15989
16521
|
nextCell.spanLeft = true;
|
|
@@ -15993,6 +16525,19 @@ var VTable = /** @class */ (function () {
|
|
|
15993
16525
|
}
|
|
15994
16526
|
}
|
|
15995
16527
|
};
|
|
16528
|
+
VTable.prototype.isEmptyCell = function (td) {
|
|
16529
|
+
return td.childElementCount === 1 && (0, getTagOfNode_1.default)(td.firstChild) === 'BR';
|
|
16530
|
+
};
|
|
16531
|
+
VTable.prototype.mergeCellContents = function (cellTd, nextCellTd) {
|
|
16532
|
+
if (this.isEmptyCell(nextCellTd)) {
|
|
16533
|
+
(0, moveChildNodes_1.default)(cellTd, nextCellTd, false /*keepExistingChildren*/);
|
|
16534
|
+
}
|
|
16535
|
+
else {
|
|
16536
|
+
var br = document.createElement('br');
|
|
16537
|
+
cellTd.appendChild(br);
|
|
16538
|
+
(0, moveChildNodes_1.default)(cellTd, nextCellTd, true /*keepExistingChildren*/);
|
|
16539
|
+
}
|
|
16540
|
+
};
|
|
15996
16541
|
/**
|
|
15997
16542
|
* Loop each cell of current column and invoke a callback function
|
|
15998
16543
|
* @param callback The callback function to invoke
|
|
@@ -16255,10 +16800,10 @@ function cloneNode(node) {
|
|
|
16255
16800
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16256
16801
|
var changeElementTag_1 = __webpack_require__(/*! ../utils/changeElementTag */ "./packages/roosterjs-editor-dom/lib/utils/changeElementTag.ts");
|
|
16257
16802
|
var setColor_1 = __webpack_require__(/*! ../utils/setColor */ "./packages/roosterjs-editor-dom/lib/utils/setColor.ts");
|
|
16803
|
+
var tableCellInfo_1 = __webpack_require__(/*! ./tableCellInfo */ "./packages/roosterjs-editor-dom/lib/table/tableCellInfo.ts");
|
|
16258
16804
|
var TRANSPARENT = 'transparent';
|
|
16259
16805
|
var TABLE_CELL_TAG_NAME = 'TD';
|
|
16260
16806
|
var TABLE_HEADER_TAG_NAME = 'TH';
|
|
16261
|
-
var CELL_SHADE = 'cellShade';
|
|
16262
16807
|
/**
|
|
16263
16808
|
* @internal
|
|
16264
16809
|
* Apply the given table format to this virtual table
|
|
@@ -16281,11 +16826,11 @@ exports.default = applyTableFormat;
|
|
|
16281
16826
|
* @returns
|
|
16282
16827
|
*/
|
|
16283
16828
|
function hasCellShade(cell) {
|
|
16829
|
+
var _a;
|
|
16284
16830
|
if (!cell.td) {
|
|
16285
16831
|
return false;
|
|
16286
16832
|
}
|
|
16287
|
-
|
|
16288
|
-
return colorShade ? true : false;
|
|
16833
|
+
return !!((_a = (0, tableCellInfo_1.getTableCellMetadata)(cell.td)) === null || _a === void 0 ? void 0 : _a.bgColorOverride);
|
|
16289
16834
|
}
|
|
16290
16835
|
/**
|
|
16291
16836
|
* Set color to the table
|
|
@@ -16563,6 +17108,47 @@ function isWholeTableSelected(vTable, selection) {
|
|
|
16563
17108
|
exports.default = isWholeTableSelected;
|
|
16564
17109
|
|
|
16565
17110
|
|
|
17111
|
+
/***/ }),
|
|
17112
|
+
|
|
17113
|
+
/***/ "./packages/roosterjs-editor-dom/lib/table/tableCellInfo.ts":
|
|
17114
|
+
/*!******************************************************************!*\
|
|
17115
|
+
!*** ./packages/roosterjs-editor-dom/lib/table/tableCellInfo.ts ***!
|
|
17116
|
+
\******************************************************************/
|
|
17117
|
+
/*! no static exports found */
|
|
17118
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
17119
|
+
|
|
17120
|
+
"use strict";
|
|
17121
|
+
|
|
17122
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17123
|
+
exports.saveTableCellMetadata = exports.getTableCellMetadata = void 0;
|
|
17124
|
+
var definitionCreators_1 = __webpack_require__(/*! ../metadata/definitionCreators */ "./packages/roosterjs-editor-dom/lib/metadata/definitionCreators.ts");
|
|
17125
|
+
var metadata_1 = __webpack_require__(/*! ../metadata/metadata */ "./packages/roosterjs-editor-dom/lib/metadata/metadata.ts");
|
|
17126
|
+
var BooleanDefinition = (0, definitionCreators_1.createBooleanDefinition)(false /** isOptional */, undefined /** value */, true /** allowNull */);
|
|
17127
|
+
var TableCellFormatMetadata = (0, definitionCreators_1.createObjectDefinition)({
|
|
17128
|
+
bgColorOverride: BooleanDefinition,
|
|
17129
|
+
}, false /* isOptional */, true /** allowNull */);
|
|
17130
|
+
/**
|
|
17131
|
+
* @internal
|
|
17132
|
+
* Get the format info of a table cell
|
|
17133
|
+
* @param cell The table cell to use
|
|
17134
|
+
*/
|
|
17135
|
+
function getTableCellMetadata(cell) {
|
|
17136
|
+
return (0, metadata_1.getMetadata)(cell, TableCellFormatMetadata);
|
|
17137
|
+
}
|
|
17138
|
+
exports.getTableCellMetadata = getTableCellMetadata;
|
|
17139
|
+
/**
|
|
17140
|
+
* Add metadata to a cell
|
|
17141
|
+
* @param cell The table cell to add the metadata
|
|
17142
|
+
* @param format The format of the table
|
|
17143
|
+
*/
|
|
17144
|
+
function saveTableCellMetadata(cell, format) {
|
|
17145
|
+
if (cell && format) {
|
|
17146
|
+
(0, metadata_1.setMetadata)(cell, format, TableCellFormatMetadata);
|
|
17147
|
+
}
|
|
17148
|
+
}
|
|
17149
|
+
exports.saveTableCellMetadata = saveTableCellMetadata;
|
|
17150
|
+
|
|
17151
|
+
|
|
16566
17152
|
/***/ }),
|
|
16567
17153
|
|
|
16568
17154
|
/***/ "./packages/roosterjs-editor-dom/lib/table/tableFormatInfo.ts":
|
|
@@ -17214,6 +17800,61 @@ function getInnerHTML(node) {
|
|
|
17214
17800
|
exports.default = getInnerHTML;
|
|
17215
17801
|
|
|
17216
17802
|
|
|
17803
|
+
/***/ }),
|
|
17804
|
+
|
|
17805
|
+
/***/ "./packages/roosterjs-editor-dom/lib/utils/getIntersectedRect.ts":
|
|
17806
|
+
/*!***********************************************************************!*\
|
|
17807
|
+
!*** ./packages/roosterjs-editor-dom/lib/utils/getIntersectedRect.ts ***!
|
|
17808
|
+
\***********************************************************************/
|
|
17809
|
+
/*! no static exports found */
|
|
17810
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
17811
|
+
|
|
17812
|
+
"use strict";
|
|
17813
|
+
|
|
17814
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17815
|
+
var normalizeRect_1 = __webpack_require__(/*! ./normalizeRect */ "./packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts");
|
|
17816
|
+
/**
|
|
17817
|
+
* Get the intersected Rect of elements provided
|
|
17818
|
+
*
|
|
17819
|
+
* @example
|
|
17820
|
+
* The result of the following Elements Rects would be:
|
|
17821
|
+
{
|
|
17822
|
+
top: Element2.top,
|
|
17823
|
+
bottom: Element1.bottom,
|
|
17824
|
+
left: Element2.left,
|
|
17825
|
+
right: Element2.right
|
|
17826
|
+
}
|
|
17827
|
+
+-------------------------+
|
|
17828
|
+
| Element 1 |
|
|
17829
|
+
| +-----------------+ |
|
|
17830
|
+
| | Element2 | |
|
|
17831
|
+
| | | |
|
|
17832
|
+
| | | |
|
|
17833
|
+
+-------------------------+
|
|
17834
|
+
| |
|
|
17835
|
+
+-----------------+
|
|
17836
|
+
|
|
17837
|
+
* @param elements Elements to use.
|
|
17838
|
+
* @param additionalRects additional rects to use
|
|
17839
|
+
* @returns If the Rect is valid return the rect, if not, return null.
|
|
17840
|
+
*/
|
|
17841
|
+
function getIntersectedRect(elements, additionalRects) {
|
|
17842
|
+
if (additionalRects === void 0) { additionalRects = []; }
|
|
17843
|
+
var rects = elements
|
|
17844
|
+
.map(function (element) { return (0, normalizeRect_1.default)(element.getBoundingClientRect()); })
|
|
17845
|
+
.filter(function (element) { return !!element; })
|
|
17846
|
+
.concat(additionalRects);
|
|
17847
|
+
var result = {
|
|
17848
|
+
top: Math.max.apply(Math, rects.map(function (r) { return r.top; })),
|
|
17849
|
+
bottom: Math.min.apply(Math, rects.map(function (r) { return r.bottom; })),
|
|
17850
|
+
left: Math.max.apply(Math, rects.map(function (r) { return r.left; })),
|
|
17851
|
+
right: Math.min.apply(Math, rects.map(function (r) { return r.right; })),
|
|
17852
|
+
};
|
|
17853
|
+
return result.top < result.bottom && result.left < result.right ? result : null;
|
|
17854
|
+
}
|
|
17855
|
+
exports.default = getIntersectedRect;
|
|
17856
|
+
|
|
17857
|
+
|
|
17217
17858
|
/***/ }),
|
|
17218
17859
|
|
|
17219
17860
|
/***/ "./packages/roosterjs-editor-dom/lib/utils/getLeafNode.ts":
|
|
@@ -18500,6 +19141,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18500
19141
|
__exportStar(__webpack_require__(/*! ./plugins/ImageResize/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageResize/index.ts"), exports);
|
|
18501
19142
|
|
|
18502
19143
|
|
|
19144
|
+
/***/ }),
|
|
19145
|
+
|
|
19146
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts":
|
|
19147
|
+
/*!*****************************************************************!*\
|
|
19148
|
+
!*** ./packages/roosterjs-editor-plugins/lib/ImageSelection.ts ***!
|
|
19149
|
+
\*****************************************************************/
|
|
19150
|
+
/*! no static exports found */
|
|
19151
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
19152
|
+
|
|
19153
|
+
"use strict";
|
|
19154
|
+
|
|
19155
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19156
|
+
if (k2 === undefined) k2 = k;
|
|
19157
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
19158
|
+
}) : (function(o, m, k, k2) {
|
|
19159
|
+
if (k2 === undefined) k2 = k;
|
|
19160
|
+
o[k2] = m[k];
|
|
19161
|
+
}));
|
|
19162
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19163
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19164
|
+
};
|
|
19165
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19166
|
+
__exportStar(__webpack_require__(/*! ./plugins/ImageSelection/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts"), exports);
|
|
19167
|
+
|
|
19168
|
+
|
|
18503
19169
|
/***/ }),
|
|
18504
19170
|
|
|
18505
19171
|
/***/ "./packages/roosterjs-editor-plugins/lib/Paste.ts":
|
|
@@ -18660,6 +19326,7 @@ __exportStar(__webpack_require__(/*! ./TableResize */ "./packages/roosterjs-edit
|
|
|
18660
19326
|
__exportStar(__webpack_require__(/*! ./Watermark */ "./packages/roosterjs-editor-plugins/lib/Watermark.ts"), exports);
|
|
18661
19327
|
__exportStar(__webpack_require__(/*! ./TableCellSelection */ "./packages/roosterjs-editor-plugins/lib/TableCellSelection.ts"), exports);
|
|
18662
19328
|
__exportStar(__webpack_require__(/*! ./AutoFormat */ "./packages/roosterjs-editor-plugins/lib/AutoFormat.ts"), exports);
|
|
19329
|
+
__exportStar(__webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts"), exports);
|
|
18663
19330
|
|
|
18664
19331
|
|
|
18665
19332
|
/***/ }),
|
|
@@ -18770,6 +19437,13 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
18770
19437
|
this.trigger.removeEventListener(this.dndMouse.MOUSEDOWN, this.onMouseDown);
|
|
18771
19438
|
this.removeDocumentEvents();
|
|
18772
19439
|
};
|
|
19440
|
+
Object.defineProperty(DragAndDropHelper.prototype, "mouseType", {
|
|
19441
|
+
get: function () {
|
|
19442
|
+
return this.dndMouse == MOUSE_EVENT_INFO_MOBILE ? 'touch' : 'mouse';
|
|
19443
|
+
},
|
|
19444
|
+
enumerable: false,
|
|
19445
|
+
configurable: true
|
|
19446
|
+
});
|
|
18773
19447
|
DragAndDropHelper.prototype.addDocumentEvents = function () {
|
|
18774
19448
|
var doc = this.trigger.ownerDocument;
|
|
18775
19449
|
doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, true /*useCapture*/);
|
|
@@ -19336,7 +20010,7 @@ var MergeInNewLine = {
|
|
|
19336
20010
|
(0, roosterjs_editor_api_1.blockFormat)(editor, function (region, start, end) {
|
|
19337
20011
|
var vList = (0, roosterjs_editor_dom_1.createVListFromRegion)(region, false /*includeSiblingList*/, li);
|
|
19338
20012
|
vList.setIndentation(start, end, 1 /* Decrease */, true /*softOutdent*/);
|
|
19339
|
-
vList.writeBack();
|
|
20013
|
+
vList.writeBack(editor.isFeatureEnabled("ReuseAllAncestorListElements" /* ReuseAllAncestorListElements */));
|
|
19340
20014
|
event.rawEvent.preventDefault();
|
|
19341
20015
|
});
|
|
19342
20016
|
}
|
|
@@ -19376,7 +20050,7 @@ var MaintainListChainWhenDelete = {
|
|
|
19376
20050
|
},
|
|
19377
20051
|
handleEvent: function (event, editor) {
|
|
19378
20052
|
var chains = getListChains(editor);
|
|
19379
|
-
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.
|
|
20053
|
+
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.commitListChains)(editor, chains); });
|
|
19380
20054
|
},
|
|
19381
20055
|
};
|
|
19382
20056
|
/**
|
|
@@ -19412,7 +20086,8 @@ function isAListPattern(textBeforeCursor) {
|
|
|
19412
20086
|
var AutoBullet = {
|
|
19413
20087
|
keys: [32 /* SPACE */],
|
|
19414
20088
|
shouldHandleEvent: function (event, editor) {
|
|
19415
|
-
if (!cacheGetListElement(event, editor)
|
|
20089
|
+
if (!cacheGetListElement(event, editor) &&
|
|
20090
|
+
!editor.isFeatureEnabled("AutoFormatList" /* AutoFormatList */)) {
|
|
19416
20091
|
var searcher = editor.getContentSearcherOfCursor(event);
|
|
19417
20092
|
var textBeforeCursor = searcher.getSubStringBefore(4);
|
|
19418
20093
|
// Auto list is triggered if:
|
|
@@ -19500,23 +20175,13 @@ var AutoNumberingList = {
|
|
|
19500
20175
|
event.rawEvent.preventDefault();
|
|
19501
20176
|
editor.addUndoSnapshot(function () {
|
|
19502
20177
|
var _a;
|
|
19503
|
-
var regions;
|
|
19504
20178
|
var searcher = editor.getContentSearcherOfCursor();
|
|
19505
20179
|
var textBeforeCursor = searcher.getSubStringBefore(5);
|
|
19506
20180
|
var textRange = searcher.getRangeFromText(textBeforeCursor, true /*exactMatch*/);
|
|
19507
|
-
if (
|
|
19508
|
-
// no op if the range can't be found
|
|
19509
|
-
}
|
|
19510
|
-
else if ((regions = editor.getSelectedRegions()) && regions.length == 1) {
|
|
19511
|
-
var num = parseInt(textBeforeCursor);
|
|
19512
|
-
var listStyle = (0, getAutoNumberingListStyle_1.default)(textBeforeCursor, num);
|
|
19513
|
-
prepareAutoBullet(editor, textRange);
|
|
19514
|
-
(0, roosterjs_editor_api_1.toggleNumbering)(editor, num, listStyle, 'autoToggleList' /** apiNameOverride */);
|
|
19515
|
-
}
|
|
19516
|
-
else {
|
|
20181
|
+
if (textRange) {
|
|
19517
20182
|
var listStyle = (0, getAutoNumberingListStyle_1.default)(textBeforeCursor);
|
|
19518
20183
|
prepareAutoBullet(editor, textRange);
|
|
19519
|
-
(0, roosterjs_editor_api_1.toggleNumbering)(editor, undefined
|
|
20184
|
+
(0, roosterjs_editor_api_1.toggleNumbering)(editor, undefined /** startNumber */, listStyle, 'autoToggleList' /** apiNameOverride */);
|
|
19520
20185
|
}
|
|
19521
20186
|
(_a = searcher.getRangeFromText(textBeforeCursor, true /*exactMatch*/)) === null || _a === void 0 ? void 0 : _a.deleteContents();
|
|
19522
20187
|
}, null /*changeSource*/, true /*canUndoByBackspace*/);
|
|
@@ -19536,7 +20201,7 @@ var MaintainListChain = {
|
|
|
19536
20201
|
},
|
|
19537
20202
|
handleEvent: function (event, editor) {
|
|
19538
20203
|
var chains = getListChains(editor);
|
|
19539
|
-
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.
|
|
20204
|
+
editor.runAsync(function (editor) { return (0, roosterjs_editor_api_1.commitListChains)(editor, chains); });
|
|
19540
20205
|
},
|
|
19541
20206
|
};
|
|
19542
20207
|
function getListChains(editor) {
|
|
@@ -19588,7 +20253,14 @@ function shouldTriggerList(event, editor, getListStyle) {
|
|
|
19588
20253
|
var searcher = editor.getContentSearcherOfCursor(event);
|
|
19589
20254
|
var textBeforeCursor = searcher.getSubStringBefore(4);
|
|
19590
20255
|
var itHasSpace = /\s/g.test(textBeforeCursor);
|
|
19591
|
-
|
|
20256
|
+
var element = editor.getElementAtCursor();
|
|
20257
|
+
var previousNode = editor.getBodyTraverser(element).getPreviousBlockElement();
|
|
20258
|
+
var isLi = previousNode
|
|
20259
|
+
? (0, roosterjs_editor_dom_1.getTagOfNode)(previousNode === null || previousNode === void 0 ? void 0 : previousNode.collapseToSingleElement()) === 'LI'
|
|
20260
|
+
: false;
|
|
20261
|
+
return (!itHasSpace &&
|
|
20262
|
+
!searcher.getNearestNonTextInlineElement() &&
|
|
20263
|
+
getListStyle(textBeforeCursor, !isLi));
|
|
19592
20264
|
}
|
|
19593
20265
|
/**
|
|
19594
20266
|
* @internal
|
|
@@ -19642,7 +20314,7 @@ function cacheGetRangeForMarkdownOperation(event, editor, triggerCharacter) {
|
|
|
19642
20314
|
var searcher = editor.getContentSearcherOfCursor(event);
|
|
19643
20315
|
var startPosition;
|
|
19644
20316
|
var endPosition;
|
|
19645
|
-
searcher.forEachTextInlineElement(function (textInlineElement) {
|
|
20317
|
+
searcher === null || searcher === void 0 ? void 0 : searcher.forEachTextInlineElement(function (textInlineElement) {
|
|
19646
20318
|
if (endPosition && startPosition) {
|
|
19647
20319
|
return true;
|
|
19648
20320
|
}
|
|
@@ -19686,7 +20358,8 @@ function handleMarkdownEvent(event, editor, triggerCharacter, elementTag) {
|
|
|
19686
20358
|
var textContentRange = range.cloneRange();
|
|
19687
20359
|
textContentRange.setStart(textContentRange.startContainer, textContentRange.startOffset + 1);
|
|
19688
20360
|
// set the removal range to include the typed last character.
|
|
19689
|
-
range.
|
|
20361
|
+
var lastIndex = range.endContainer.length;
|
|
20362
|
+
range.setEnd(range.endContainer, lastIndex);
|
|
19690
20363
|
// extract content and put it into a new element.
|
|
19691
20364
|
var elementToWrap = editor.getDocument().createElement(elementTag);
|
|
19692
20365
|
elementToWrap.appendChild(textContentRange.extractContents());
|
|
@@ -19704,19 +20377,19 @@ function handleMarkdownEvent(event, editor, triggerCharacter, elementTag) {
|
|
|
19704
20377
|
/**
|
|
19705
20378
|
* Markdown bold feature. Make bold text with markdown shortcuts.
|
|
19706
20379
|
*/
|
|
19707
|
-
var MarkdownBold = generateBasicMarkdownFeature(56 /* EIGHT_ASTERISK */, '*', 'b', true);
|
|
20380
|
+
var MarkdownBold = generateBasicMarkdownFeature(56 /* EIGHT_ASTERISK */, '*', 'b', true /* useShiftKey */);
|
|
19708
20381
|
/**
|
|
19709
20382
|
* Markdown italics feature. Make italic text with markdown shortcuts.
|
|
19710
20383
|
*/
|
|
19711
|
-
var MarkdownItalic = generateBasicMarkdownFeature(189 /* DASH_UNDERSCORE */, '_', 'i', true);
|
|
20384
|
+
var MarkdownItalic = generateBasicMarkdownFeature(189 /* DASH_UNDERSCORE */, '_', 'i', true /* useShiftKey */);
|
|
19712
20385
|
/**
|
|
19713
20386
|
* Markdown strikethrough feature. MAke strikethrough text with markdown shortcuts.
|
|
19714
20387
|
*/
|
|
19715
|
-
var MarkdownStrikethrough = generateBasicMarkdownFeature(192 /* GRAVE_TILDE */, '~', 's', true);
|
|
20388
|
+
var MarkdownStrikethrough = generateBasicMarkdownFeature(192 /* GRAVE_TILDE */, '~', 's', true /* useShiftKey */);
|
|
19716
20389
|
/**
|
|
19717
20390
|
* Markdown inline code feature. Marks specific text as inline code with markdown shortcuts.
|
|
19718
20391
|
*/
|
|
19719
|
-
var MarkdownInlineCode = generateBasicMarkdownFeature(192 /* GRAVE_TILDE */, '`', 'code', false);
|
|
20392
|
+
var MarkdownInlineCode = generateBasicMarkdownFeature(192 /* GRAVE_TILDE */, '`', 'code', false /* useShiftKey */);
|
|
19720
20393
|
/**
|
|
19721
20394
|
* @internal
|
|
19722
20395
|
*/
|
|
@@ -20397,7 +21070,7 @@ var bulletListType = {
|
|
|
20397
21070
|
'-': 2 /* Dash */,
|
|
20398
21071
|
'--': 3 /* Square */,
|
|
20399
21072
|
'->': 5 /* LongArrow */,
|
|
20400
|
-
'-->':
|
|
21073
|
+
'-->': 8 /* DoubleLongArrow */,
|
|
20401
21074
|
'=>': 6 /* UnfilledArrow */,
|
|
20402
21075
|
'>': 4 /* ShortArrow */,
|
|
20403
21076
|
'—': 7 /* Hyphen */,
|
|
@@ -20436,13 +21109,7 @@ var characters = {
|
|
|
20436
21109
|
'-': 2 /* Dash */,
|
|
20437
21110
|
')': 3 /* Parenthesis */,
|
|
20438
21111
|
};
|
|
20439
|
-
var numberingTriggers =
|
|
20440
|
-
'1': 1 /* Decimal */,
|
|
20441
|
-
i: 4 /* LowerRoman */,
|
|
20442
|
-
I: 5 /* UpperRoman */,
|
|
20443
|
-
a: 2 /* LowerAlpha */,
|
|
20444
|
-
A: 3 /* UpperAlpha */,
|
|
20445
|
-
};
|
|
21112
|
+
var numberingTriggers = ['1', 'a', 'A', 'I', 'i'];
|
|
20446
21113
|
var identifyNumberingType = function (text) {
|
|
20447
21114
|
if (!isNaN(parseInt(text))) {
|
|
20448
21115
|
return 1 /* Decimal */;
|
|
@@ -20501,16 +21168,14 @@ var DecimalsTypes = (_f = {},
|
|
|
20501
21168
|
_f[3 /* Parenthesis */] = 3 /* DecimalParenthesis */,
|
|
20502
21169
|
_f[4 /* DoubleParenthesis */] = 4 /* DecimalDoubleParenthesis */,
|
|
20503
21170
|
_f);
|
|
20504
|
-
var identifyNumberingListType = function (numbering, isDoubleParenthesis
|
|
21171
|
+
var identifyNumberingListType = function (numbering, isDoubleParenthesis) {
|
|
20505
21172
|
var separatorCharacter = isDoubleParenthesis
|
|
20506
21173
|
? 4 /* DoubleParenthesis */
|
|
20507
21174
|
: characters[numbering[1]];
|
|
20508
21175
|
// if separator is not valid, no need to check if the number is valid.
|
|
20509
21176
|
if (separatorCharacter) {
|
|
20510
|
-
var number = numbering.length
|
|
20511
|
-
var numberingType =
|
|
20512
|
-
? identifyNumberingType(number)
|
|
20513
|
-
: numberingTriggers[number];
|
|
21177
|
+
var number = numbering[numbering.length - 2];
|
|
21178
|
+
var numberingType = identifyNumberingType(number);
|
|
20514
21179
|
return numberingType ? numberingListTypes[numberingType](separatorCharacter) : null;
|
|
20515
21180
|
}
|
|
20516
21181
|
return null;
|
|
@@ -20518,16 +21183,22 @@ var identifyNumberingListType = function (numbering, isDoubleParenthesis, startN
|
|
|
20518
21183
|
/**
|
|
20519
21184
|
* @internal
|
|
20520
21185
|
* @param textBeforeCursor The trigger character
|
|
20521
|
-
* @param
|
|
21186
|
+
* @param isTheFirstItem (Optional) Is the start number of a list.
|
|
20522
21187
|
* @returns The style of a numbering list triggered by a string
|
|
20523
21188
|
*/
|
|
20524
|
-
function getAutoNumberingListStyle(textBeforeCursor,
|
|
21189
|
+
function getAutoNumberingListStyle(textBeforeCursor, isTheFirstItem) {
|
|
20525
21190
|
var trigger = textBeforeCursor.trim();
|
|
21191
|
+
//Only the staring items ['1', 'a', 'A', 'I', 'i'] must trigger a new list. All the other triggers is used to keep the list chain.
|
|
21192
|
+
//The index is always the character before the last character
|
|
21193
|
+
var listIndex = trigger[trigger.length - 2];
|
|
21194
|
+
if (isTheFirstItem && numberingTriggers.indexOf(listIndex) < 0) {
|
|
21195
|
+
return null;
|
|
21196
|
+
}
|
|
20526
21197
|
// the marker must be a combination of 2 or 3 characters, so if the length is less than 2, no need to check
|
|
20527
21198
|
// If the marker length is 3, the marker style is double parenthesis such as (1), (A).
|
|
20528
21199
|
var isDoubleParenthesis = trigger.length === 3 && trigger[0] === '(' && trigger[2] === ')';
|
|
20529
21200
|
var numberingType = trigger.length === 2 || isDoubleParenthesis
|
|
20530
|
-
? identifyNumberingListType(trigger, isDoubleParenthesis
|
|
21201
|
+
? identifyNumberingListType(trigger, isDoubleParenthesis)
|
|
20531
21202
|
: null;
|
|
20532
21203
|
return numberingType;
|
|
20533
21204
|
}
|
|
@@ -20873,7 +21544,7 @@ var CutPasteListChain = /** @class */ (function () {
|
|
|
20873
21544
|
break;
|
|
20874
21545
|
case 7 /* ContentChanged */:
|
|
20875
21546
|
if (((_a = this.chains) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.expectedChangeSource == event.source) {
|
|
20876
|
-
(0, roosterjs_editor_api_1.
|
|
21547
|
+
(0, roosterjs_editor_api_1.commitListChains)(this.editor, this.chains);
|
|
20877
21548
|
this.chains = null;
|
|
20878
21549
|
this.expectedChangeSource = null;
|
|
20879
21550
|
}
|
|
@@ -22697,42 +23368,126 @@ Object.defineProperty(exports, "ImageResize", { enumerable: true, get: function
|
|
|
22697
23368
|
|
|
22698
23369
|
/***/ }),
|
|
22699
23370
|
|
|
22700
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/
|
|
22701
|
-
|
|
22702
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/
|
|
22703
|
-
|
|
23371
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts":
|
|
23372
|
+
/*!****************************************************************************************!*\
|
|
23373
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts ***!
|
|
23374
|
+
\****************************************************************************************/
|
|
22704
23375
|
/*! no static exports found */
|
|
22705
23376
|
/***/ (function(module, exports, __webpack_require__) {
|
|
22706
23377
|
|
|
22707
23378
|
"use strict";
|
|
22708
23379
|
|
|
22709
23380
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22710
|
-
var convertPasteContentForSingleImage_1 = __webpack_require__(/*! ./imageConverter/convertPasteContentForSingleImage */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/imageConverter/convertPasteContentForSingleImage.ts");
|
|
22711
|
-
var convertPastedContentForLI_1 = __webpack_require__(/*! ./commonConverter/convertPastedContentForLI */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/commonConverter/convertPastedContentForLI.ts");
|
|
22712
|
-
var convertPastedContentFromExcel_1 = __webpack_require__(/*! ./excelConverter/convertPastedContentFromExcel */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/excelConverter/convertPastedContentFromExcel.ts");
|
|
22713
|
-
var convertPastedContentFromPowerPoint_1 = __webpack_require__(/*! ./pptConverter/convertPastedContentFromPowerPoint */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/pptConverter/convertPastedContentFromPowerPoint.ts");
|
|
22714
|
-
var convertPastedContentFromWord_1 = __webpack_require__(/*! ./wordConverter/convertPastedContentFromWord */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/wordConverter/convertPastedContentFromWord.ts");
|
|
22715
|
-
var handleLineMerge_1 = __webpack_require__(/*! ./lineMerge/handleLineMerge */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/lineMerge/handleLineMerge.ts");
|
|
22716
|
-
var sanitizeHtmlColorsFromPastedContent_1 = __webpack_require__(/*! ./sanitizeHtmlColorsFromPastedContent/sanitizeHtmlColorsFromPastedContent */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sanitizeHtmlColorsFromPastedContent/sanitizeHtmlColorsFromPastedContent.ts");
|
|
22717
23381
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
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';
|
|
22729
23382
|
/**
|
|
22730
|
-
*
|
|
22731
|
-
* 1. Content copied from Word
|
|
22732
|
-
* 2. Content copied from Excel
|
|
22733
|
-
* 3. Content copied from Word Online or OneNote Online
|
|
23383
|
+
* Detect image selection and help highlight the image
|
|
22734
23384
|
*/
|
|
22735
|
-
var
|
|
23385
|
+
var ImageSelection = /** @class */ (function () {
|
|
23386
|
+
function ImageSelection() {
|
|
23387
|
+
this.editor = null;
|
|
23388
|
+
this.imageId = null;
|
|
23389
|
+
}
|
|
23390
|
+
/**
|
|
23391
|
+
* Get a friendly name of this plugin
|
|
23392
|
+
*/
|
|
23393
|
+
ImageSelection.prototype.getName = function () {
|
|
23394
|
+
return 'ImageSelection';
|
|
23395
|
+
};
|
|
23396
|
+
/**
|
|
23397
|
+
* Initialize this plugin. This should only be called from Editor
|
|
23398
|
+
* @param editor Editor instance
|
|
23399
|
+
*/
|
|
23400
|
+
ImageSelection.prototype.initialize = function (editor) {
|
|
23401
|
+
this.editor = editor;
|
|
23402
|
+
};
|
|
23403
|
+
/**
|
|
23404
|
+
* Dispose this plugin
|
|
23405
|
+
*/
|
|
23406
|
+
ImageSelection.prototype.dispose = function () {
|
|
23407
|
+
this.editor.select(null);
|
|
23408
|
+
this.editor = null;
|
|
23409
|
+
this.imageId = null;
|
|
23410
|
+
};
|
|
23411
|
+
ImageSelection.prototype.onPluginEvent = function (event) {
|
|
23412
|
+
if (this.editor) {
|
|
23413
|
+
switch (event.eventType) {
|
|
23414
|
+
case 17 /* EnteredShadowEdit */:
|
|
23415
|
+
var selection = this.editor.getSelectionRangeEx();
|
|
23416
|
+
if (selection.type == 2 /* ImageSelection */) {
|
|
23417
|
+
this.editor.select(selection.image);
|
|
23418
|
+
}
|
|
23419
|
+
break;
|
|
23420
|
+
case 18 /* LeavingShadowEdit */:
|
|
23421
|
+
if (this.imageId) {
|
|
23422
|
+
var images = this.editor.queryElements('#' + this.imageId);
|
|
23423
|
+
if (images.length == 1) {
|
|
23424
|
+
var image = images[0];
|
|
23425
|
+
this.editor.select(image);
|
|
23426
|
+
}
|
|
23427
|
+
this.imageId = null;
|
|
23428
|
+
}
|
|
23429
|
+
break;
|
|
23430
|
+
case 5 /* MouseDown */:
|
|
23431
|
+
var target = event.rawEvent.target;
|
|
23432
|
+
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
|
|
23433
|
+
this.editor.select(target);
|
|
23434
|
+
this.imageId = target.id;
|
|
23435
|
+
}
|
|
23436
|
+
break;
|
|
23437
|
+
}
|
|
23438
|
+
}
|
|
23439
|
+
};
|
|
23440
|
+
return ImageSelection;
|
|
23441
|
+
}());
|
|
23442
|
+
exports.default = ImageSelection;
|
|
23443
|
+
|
|
23444
|
+
|
|
23445
|
+
/***/ }),
|
|
23446
|
+
|
|
23447
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts":
|
|
23448
|
+
/*!*******************************************************************************!*\
|
|
23449
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts ***!
|
|
23450
|
+
\*******************************************************************************/
|
|
23451
|
+
/*! no static exports found */
|
|
23452
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23453
|
+
|
|
23454
|
+
"use strict";
|
|
23455
|
+
|
|
23456
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23457
|
+
exports.ImageSelection = void 0;
|
|
23458
|
+
var ImageSelection_1 = __webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts");
|
|
23459
|
+
Object.defineProperty(exports, "ImageSelection", { enumerable: true, get: function () { return ImageSelection_1.default; } });
|
|
23460
|
+
|
|
23461
|
+
|
|
23462
|
+
/***/ }),
|
|
23463
|
+
|
|
23464
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/Paste.ts":
|
|
23465
|
+
/*!**********************************************************************!*\
|
|
23466
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/Paste.ts ***!
|
|
23467
|
+
\**********************************************************************/
|
|
23468
|
+
/*! no static exports found */
|
|
23469
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23470
|
+
|
|
23471
|
+
"use strict";
|
|
23472
|
+
|
|
23473
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23474
|
+
var convertPasteContentForSingleImage_1 = __webpack_require__(/*! ./imageConverter/convertPasteContentForSingleImage */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/imageConverter/convertPasteContentForSingleImage.ts");
|
|
23475
|
+
var convertPastedContentForLI_1 = __webpack_require__(/*! ./commonConverter/convertPastedContentForLI */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/commonConverter/convertPastedContentForLI.ts");
|
|
23476
|
+
var convertPastedContentFromExcel_1 = __webpack_require__(/*! ./excelConverter/convertPastedContentFromExcel */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/excelConverter/convertPastedContentFromExcel.ts");
|
|
23477
|
+
var convertPastedContentFromOfficeOnline_1 = __webpack_require__(/*! ./officeOnlineConverter/convertPastedContentFromOfficeOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromOfficeOnline.ts");
|
|
23478
|
+
var convertPastedContentFromPowerPoint_1 = __webpack_require__(/*! ./pptConverter/convertPastedContentFromPowerPoint */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/pptConverter/convertPastedContentFromPowerPoint.ts");
|
|
23479
|
+
var convertPastedContentFromWord_1 = __webpack_require__(/*! ./wordConverter/convertPastedContentFromWord */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/wordConverter/convertPastedContentFromWord.ts");
|
|
23480
|
+
var getPasteSource_1 = __webpack_require__(/*! ./sourceValidations/getPasteSource */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/getPasteSource.ts");
|
|
23481
|
+
var handleLineMerge_1 = __webpack_require__(/*! ./lineMerge/handleLineMerge */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/lineMerge/handleLineMerge.ts");
|
|
23482
|
+
var sanitizeHtmlColorsFromPastedContent_1 = __webpack_require__(/*! ./sanitizeHtmlColorsFromPastedContent/sanitizeHtmlColorsFromPastedContent */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sanitizeHtmlColorsFromPastedContent/sanitizeHtmlColorsFromPastedContent.ts");
|
|
23483
|
+
var constants_1 = __webpack_require__(/*! ./sourceValidations/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
23484
|
+
/**
|
|
23485
|
+
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
23486
|
+
* 1. Content copied from Word
|
|
23487
|
+
* 2. Content copied from Excel
|
|
23488
|
+
* 3. Content copied from Word Online or OneNote Online
|
|
23489
|
+
*/
|
|
23490
|
+
var Paste = /** @class */ (function () {
|
|
22736
23491
|
/**
|
|
22737
23492
|
* Construct a new instance of Paste class
|
|
22738
23493
|
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
@@ -22765,48 +23520,34 @@ var Paste = /** @class */ (function () {
|
|
|
22765
23520
|
* @param event PluginEvent object
|
|
22766
23521
|
*/
|
|
22767
23522
|
Paste.prototype.onPluginEvent = function (event) {
|
|
22768
|
-
var _a;
|
|
22769
23523
|
if (event.eventType == 10 /* BeforePaste */) {
|
|
22770
|
-
var
|
|
23524
|
+
var fragment = event.fragment, sanitizingOption = event.sanitizingOption;
|
|
22771
23525
|
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);
|
|
23526
|
+
switch ((0, getPasteSource_1.default)(event, this.editor)) {
|
|
23527
|
+
case 0 /* WordDesktop */:
|
|
23528
|
+
// Handle HTML copied from Word
|
|
23529
|
+
(0, convertPastedContentFromWord_1.default)(event);
|
|
23530
|
+
break;
|
|
23531
|
+
case 1 /* ExcelDesktop */:
|
|
23532
|
+
// Handle HTML copied from Excel
|
|
23533
|
+
(0, convertPastedContentFromExcel_1.default)(event, trustedHTMLHandler);
|
|
23534
|
+
break;
|
|
23535
|
+
case 2 /* PowerPointDesktop */:
|
|
23536
|
+
(0, convertPastedContentFromPowerPoint_1.default)(event, trustedHTMLHandler);
|
|
23537
|
+
break;
|
|
23538
|
+
case 4 /* WacComponents */:
|
|
23539
|
+
(0, convertPastedContentFromOfficeOnline_1.default)(fragment);
|
|
23540
|
+
break;
|
|
23541
|
+
case 3 /* GoogleSheets */:
|
|
23542
|
+
sanitizingOption.additionalTagReplacements[constants_1.GOOGLE_SHEET_NODE_NAME] = '*';
|
|
23543
|
+
break;
|
|
23544
|
+
case 6 /* SingleImage */:
|
|
23545
|
+
(0, convertPasteContentForSingleImage_1.default)(event, trustedHTMLHandler);
|
|
23546
|
+
break;
|
|
23547
|
+
case 5 /* Default */:
|
|
23548
|
+
(0, convertPastedContentForLI_1.default)(fragment);
|
|
23549
|
+
(0, handleLineMerge_1.default)(fragment);
|
|
23550
|
+
break;
|
|
22810
23551
|
}
|
|
22811
23552
|
(0, sanitizeHtmlColorsFromPastedContent_1.default)(sanitizingOption);
|
|
22812
23553
|
// Replace unknown tags with SPAN
|
|
@@ -22816,10 +23557,6 @@ var Paste = /** @class */ (function () {
|
|
|
22816
23557
|
return Paste;
|
|
22817
23558
|
}());
|
|
22818
23559
|
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
23560
|
|
|
22824
23561
|
|
|
22825
23562
|
/***/ }),
|
|
@@ -23098,6 +23835,41 @@ function createListItemBlock(listItem) {
|
|
|
23098
23835
|
exports.createListItemBlock = createListItemBlock;
|
|
23099
23836
|
|
|
23100
23837
|
|
|
23838
|
+
/***/ }),
|
|
23839
|
+
|
|
23840
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromOfficeOnline.ts":
|
|
23841
|
+
/*!***************************************************************************************************************************!*\
|
|
23842
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromOfficeOnline.ts ***!
|
|
23843
|
+
\***************************************************************************************************************************/
|
|
23844
|
+
/*! no static exports found */
|
|
23845
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
23846
|
+
|
|
23847
|
+
"use strict";
|
|
23848
|
+
|
|
23849
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23850
|
+
var constants_1 = __webpack_require__(/*! ../sourceValidations/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
23851
|
+
var convertPastedContentFromWordOnline_1 = __webpack_require__(/*! ./convertPastedContentFromWordOnline */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts");
|
|
23852
|
+
/**
|
|
23853
|
+
* @internal
|
|
23854
|
+
* Convert pasted content from Office Online
|
|
23855
|
+
* Once it is known that the document is from WAC
|
|
23856
|
+
* We need to remove the display property and margin from all the list item
|
|
23857
|
+
* @param event The BeforePaste event
|
|
23858
|
+
*/
|
|
23859
|
+
function convertPastedContentFromOfficeOnline(fragment) {
|
|
23860
|
+
fragment.querySelectorAll(constants_1.WAC_IDENTIFY_SELECTOR).forEach(function (el) {
|
|
23861
|
+
el.style.display = null;
|
|
23862
|
+
el.style.margin = null;
|
|
23863
|
+
});
|
|
23864
|
+
// call conversion function if the pasted content is from word online and
|
|
23865
|
+
// has list element in the pasted content.
|
|
23866
|
+
if ((0, convertPastedContentFromWordOnline_1.isWordOnlineWithList)(fragment)) {
|
|
23867
|
+
(0, convertPastedContentFromWordOnline_1.default)(fragment);
|
|
23868
|
+
}
|
|
23869
|
+
}
|
|
23870
|
+
exports.default = convertPastedContentFromOfficeOnline;
|
|
23871
|
+
|
|
23872
|
+
|
|
23101
23873
|
/***/ }),
|
|
23102
23874
|
|
|
23103
23875
|
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/officeOnlineConverter/convertPastedContentFromWordOnline.ts":
|
|
@@ -23521,6 +24293,255 @@ function sanitizeHtmlColorsFromPastedContent(sanitizingOption) {
|
|
|
23521
24293
|
exports.default = sanitizeHtmlColorsFromPastedContent;
|
|
23522
24294
|
|
|
23523
24295
|
|
|
24296
|
+
/***/ }),
|
|
24297
|
+
|
|
24298
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts":
|
|
24299
|
+
/*!********************************************************************************************!*\
|
|
24300
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts ***!
|
|
24301
|
+
\********************************************************************************************/
|
|
24302
|
+
/*! no static exports found */
|
|
24303
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24304
|
+
|
|
24305
|
+
"use strict";
|
|
24306
|
+
|
|
24307
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24308
|
+
exports.WAC_IDENTIFY_SELECTOR = exports.PROG_ID_NAME = exports.GOOGLE_SHEET_NODE_NAME = void 0;
|
|
24309
|
+
/**
|
|
24310
|
+
* @internal
|
|
24311
|
+
* Node attribute used to identify if the content is from Google Sheets.
|
|
24312
|
+
*/
|
|
24313
|
+
exports.GOOGLE_SHEET_NODE_NAME = 'google-sheets-html-origin';
|
|
24314
|
+
/**
|
|
24315
|
+
* @internal
|
|
24316
|
+
* Name of the HTMLMeta Property that provides the Office App Source of the pasted content
|
|
24317
|
+
*/
|
|
24318
|
+
exports.PROG_ID_NAME = 'ProgId';
|
|
24319
|
+
/**
|
|
24320
|
+
* @internal
|
|
24321
|
+
* Selector used to identify Wac Elements
|
|
24322
|
+
*/
|
|
24323
|
+
exports.WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer';
|
|
24324
|
+
|
|
24325
|
+
|
|
24326
|
+
/***/ }),
|
|
24327
|
+
|
|
24328
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/documentContainWacElements.ts":
|
|
24329
|
+
/*!*************************************************************************************************************!*\
|
|
24330
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/documentContainWacElements.ts ***!
|
|
24331
|
+
\*************************************************************************************************************/
|
|
24332
|
+
/*! no static exports found */
|
|
24333
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24334
|
+
|
|
24335
|
+
"use strict";
|
|
24336
|
+
|
|
24337
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24338
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
24339
|
+
/**
|
|
24340
|
+
* @internal
|
|
24341
|
+
* Check whether the fragment provided contain Wac Elements
|
|
24342
|
+
* @param props Properties related to the PasteEvent
|
|
24343
|
+
* @returns
|
|
24344
|
+
*/
|
|
24345
|
+
var documentContainWacElements = function (props) {
|
|
24346
|
+
var fragment = props.fragment;
|
|
24347
|
+
return !!fragment.querySelector(constants_1.WAC_IDENTIFY_SELECTOR);
|
|
24348
|
+
};
|
|
24349
|
+
exports.default = documentContainWacElements;
|
|
24350
|
+
|
|
24351
|
+
|
|
24352
|
+
/***/ }),
|
|
24353
|
+
|
|
24354
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/getPasteSource.ts":
|
|
24355
|
+
/*!*************************************************************************************************!*\
|
|
24356
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/getPasteSource.ts ***!
|
|
24357
|
+
\*************************************************************************************************/
|
|
24358
|
+
/*! no static exports found */
|
|
24359
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24360
|
+
|
|
24361
|
+
"use strict";
|
|
24362
|
+
|
|
24363
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24364
|
+
var documentContainWacElements_1 = __webpack_require__(/*! ./documentContainWacElements */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/documentContainWacElements.ts");
|
|
24365
|
+
var isExcelDesktopDocument_1 = __webpack_require__(/*! ./isExcelDesktopDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isExcelDesktopDocument.ts");
|
|
24366
|
+
var isGoogleSheetDocument_1 = __webpack_require__(/*! ./isGoogleSheetDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isGoogleSheetDocument.ts");
|
|
24367
|
+
var isPowerPointDesktopDocument_1 = __webpack_require__(/*! ./isPowerPointDesktopDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isPowerPointDesktopDocument.ts");
|
|
24368
|
+
var isWordDesktopDocument_1 = __webpack_require__(/*! ./isWordDesktopDocument */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isWordDesktopDocument.ts");
|
|
24369
|
+
var shouldConvertToSingleImage_1 = __webpack_require__(/*! ./shouldConvertToSingleImage */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/shouldConvertToSingleImage.ts");
|
|
24370
|
+
var getSourceFunctions = new Map([
|
|
24371
|
+
[0 /* WordDesktop */, isWordDesktopDocument_1.default],
|
|
24372
|
+
[1 /* ExcelDesktop */, isExcelDesktopDocument_1.default],
|
|
24373
|
+
[2 /* PowerPointDesktop */, isPowerPointDesktopDocument_1.default],
|
|
24374
|
+
[4 /* WacComponents */, documentContainWacElements_1.default],
|
|
24375
|
+
[3 /* GoogleSheets */, isGoogleSheetDocument_1.default],
|
|
24376
|
+
[6 /* SingleImage */, shouldConvertToSingleImage_1.default],
|
|
24377
|
+
]);
|
|
24378
|
+
/**
|
|
24379
|
+
* @internal
|
|
24380
|
+
* This function tries to get the source of the Pasted content
|
|
24381
|
+
* @param event the before paste event
|
|
24382
|
+
* @param editor editor instance
|
|
24383
|
+
* @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}
|
|
24384
|
+
*/
|
|
24385
|
+
function getPasteSource(event, editor) {
|
|
24386
|
+
var htmlAttributes = event.htmlAttributes, clipboardData = event.clipboardData, fragment = event.fragment;
|
|
24387
|
+
var result = null;
|
|
24388
|
+
var param = {
|
|
24389
|
+
htmlAttributes: htmlAttributes,
|
|
24390
|
+
fragment: fragment,
|
|
24391
|
+
editor: editor,
|
|
24392
|
+
clipboardData: clipboardData,
|
|
24393
|
+
};
|
|
24394
|
+
getSourceFunctions.forEach(function (func, key) {
|
|
24395
|
+
if (!result && func(param)) {
|
|
24396
|
+
result = key;
|
|
24397
|
+
}
|
|
24398
|
+
});
|
|
24399
|
+
return result !== null && result !== void 0 ? result : 5 /* Default */;
|
|
24400
|
+
}
|
|
24401
|
+
exports.default = getPasteSource;
|
|
24402
|
+
|
|
24403
|
+
|
|
24404
|
+
/***/ }),
|
|
24405
|
+
|
|
24406
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isExcelDesktopDocument.ts":
|
|
24407
|
+
/*!*********************************************************************************************************!*\
|
|
24408
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isExcelDesktopDocument.ts ***!
|
|
24409
|
+
\*********************************************************************************************************/
|
|
24410
|
+
/*! no static exports found */
|
|
24411
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24412
|
+
|
|
24413
|
+
"use strict";
|
|
24414
|
+
|
|
24415
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24416
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
24417
|
+
var EXCEL_ATTRIBUTE_NAME = 'xmlns:x';
|
|
24418
|
+
var EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';
|
|
24419
|
+
var EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';
|
|
24420
|
+
/**
|
|
24421
|
+
* @internal
|
|
24422
|
+
* Checks whether the Array provided contains strings that identify Excel Desktop documents
|
|
24423
|
+
* @param props Properties related to the PasteEvent
|
|
24424
|
+
* @returns
|
|
24425
|
+
*/
|
|
24426
|
+
var isExcelDesktopDocument = function (props) {
|
|
24427
|
+
var htmlAttributes = props.htmlAttributes;
|
|
24428
|
+
return (htmlAttributes[EXCEL_ATTRIBUTE_NAME] == EXCEL_ATTRIBUTE_VALUE ||
|
|
24429
|
+
htmlAttributes[constants_1.PROG_ID_NAME] == EXCEL_ONLINE_ATTRIBUTE_VALUE);
|
|
24430
|
+
};
|
|
24431
|
+
exports.default = isExcelDesktopDocument;
|
|
24432
|
+
|
|
24433
|
+
|
|
24434
|
+
/***/ }),
|
|
24435
|
+
|
|
24436
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isGoogleSheetDocument.ts":
|
|
24437
|
+
/*!********************************************************************************************************!*\
|
|
24438
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isGoogleSheetDocument.ts ***!
|
|
24439
|
+
\********************************************************************************************************/
|
|
24440
|
+
/*! no static exports found */
|
|
24441
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24442
|
+
|
|
24443
|
+
"use strict";
|
|
24444
|
+
|
|
24445
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24446
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
24447
|
+
/**
|
|
24448
|
+
* @internal
|
|
24449
|
+
* Checks whether the fragment provided contain elements from Google sheets
|
|
24450
|
+
* @param props Properties related to the PasteEvent
|
|
24451
|
+
* @returns
|
|
24452
|
+
*/
|
|
24453
|
+
var isGoogleSheetDocument = function (props) {
|
|
24454
|
+
var fragment = props.fragment;
|
|
24455
|
+
return !!fragment.querySelector(constants_1.GOOGLE_SHEET_NODE_NAME);
|
|
24456
|
+
};
|
|
24457
|
+
exports.default = isGoogleSheetDocument;
|
|
24458
|
+
|
|
24459
|
+
|
|
24460
|
+
/***/ }),
|
|
24461
|
+
|
|
24462
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isPowerPointDesktopDocument.ts":
|
|
24463
|
+
/*!**************************************************************************************************************!*\
|
|
24464
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isPowerPointDesktopDocument.ts ***!
|
|
24465
|
+
\**************************************************************************************************************/
|
|
24466
|
+
/*! no static exports found */
|
|
24467
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24468
|
+
|
|
24469
|
+
"use strict";
|
|
24470
|
+
|
|
24471
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24472
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
24473
|
+
var POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';
|
|
24474
|
+
/**
|
|
24475
|
+
* @internal
|
|
24476
|
+
* Checks whether the Array provided contains strings that identify Power Point Desktop documents
|
|
24477
|
+
* @param props Properties related to the PasteEvent
|
|
24478
|
+
* @returns
|
|
24479
|
+
*/
|
|
24480
|
+
var isPowerPointDesktopDocument = function (props) {
|
|
24481
|
+
return props.htmlAttributes[constants_1.PROG_ID_NAME] == POWERPOINT_ATTRIBUTE_VALUE;
|
|
24482
|
+
};
|
|
24483
|
+
exports.default = isPowerPointDesktopDocument;
|
|
24484
|
+
|
|
24485
|
+
|
|
24486
|
+
/***/ }),
|
|
24487
|
+
|
|
24488
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isWordDesktopDocument.ts":
|
|
24489
|
+
/*!********************************************************************************************************!*\
|
|
24490
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/isWordDesktopDocument.ts ***!
|
|
24491
|
+
\********************************************************************************************************/
|
|
24492
|
+
/*! no static exports found */
|
|
24493
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24494
|
+
|
|
24495
|
+
"use strict";
|
|
24496
|
+
|
|
24497
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24498
|
+
var constants_1 = __webpack_require__(/*! ./constants */ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/constants.ts");
|
|
24499
|
+
var WORD_ATTRIBUTE_NAME = 'xmlns:w';
|
|
24500
|
+
var WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';
|
|
24501
|
+
var WORD_PROG_ID = 'Word.Document';
|
|
24502
|
+
/**
|
|
24503
|
+
* @internal
|
|
24504
|
+
* Checks whether the Array provided contains strings that identify Word Desktop documents
|
|
24505
|
+
* @param props Properties related to the PasteEvent
|
|
24506
|
+
* @returns
|
|
24507
|
+
*/
|
|
24508
|
+
var isWordDesktopDocument = function (props) {
|
|
24509
|
+
var htmlAttributes = props.htmlAttributes;
|
|
24510
|
+
return (htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||
|
|
24511
|
+
htmlAttributes[constants_1.PROG_ID_NAME] == WORD_PROG_ID);
|
|
24512
|
+
};
|
|
24513
|
+
exports.default = isWordDesktopDocument;
|
|
24514
|
+
|
|
24515
|
+
|
|
24516
|
+
/***/ }),
|
|
24517
|
+
|
|
24518
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/shouldConvertToSingleImage.ts":
|
|
24519
|
+
/*!*************************************************************************************************************!*\
|
|
24520
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/Paste/sourceValidations/shouldConvertToSingleImage.ts ***!
|
|
24521
|
+
\*************************************************************************************************************/
|
|
24522
|
+
/*! no static exports found */
|
|
24523
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
24524
|
+
|
|
24525
|
+
"use strict";
|
|
24526
|
+
|
|
24527
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24528
|
+
/**
|
|
24529
|
+
* @internal
|
|
24530
|
+
* Checks whether the fragment only contains a single image to paste
|
|
24531
|
+
* and the editor have the ConvertSingleImageBody Experimental feature
|
|
24532
|
+
* @param props Properties related to the PasteEvent
|
|
24533
|
+
* @returns
|
|
24534
|
+
*/
|
|
24535
|
+
var shouldConvertToSingleImage = function (props) {
|
|
24536
|
+
var _a;
|
|
24537
|
+
var editor = props.editor, clipboardData = props.clipboardData;
|
|
24538
|
+
return (editor.isFeatureEnabled("ConvertSingleImageBody" /* ConvertSingleImageBody */) &&
|
|
24539
|
+
((_a = clipboardData.htmlFirstLevelChildTags) === null || _a === void 0 ? void 0 : _a.length) == 1 &&
|
|
24540
|
+
clipboardData.htmlFirstLevelChildTags[0] == 'IMG');
|
|
24541
|
+
};
|
|
24542
|
+
exports.default = shouldConvertToSingleImage;
|
|
24543
|
+
|
|
24544
|
+
|
|
23524
24545
|
/***/ }),
|
|
23525
24546
|
|
|
23526
24547
|
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/wordConverter/LevelLists.ts":
|
|
@@ -24807,9 +25828,8 @@ Object.defineProperty(exports, "PickerPlugin", { enumerable: true, get: function
|
|
|
24807
25828
|
|
|
24808
25829
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24809
25830
|
var normalizeTableSelection_1 = __webpack_require__(/*! ./utils/normalizeTableSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/utils/normalizeTableSelection.ts");
|
|
24810
|
-
var
|
|
25831
|
+
var DeleteTableContents_1 = __webpack_require__(/*! ./features/DeleteTableContents */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/features/DeleteTableContents.ts");
|
|
24811
25832
|
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
25833
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
24814
25834
|
var TABLE_CELL_SELECTOR = 'td,th';
|
|
24815
25835
|
var LEFT_CLICK = 1;
|
|
@@ -24879,30 +25899,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
24879
25899
|
_this.removeMouseUpEventListener();
|
|
24880
25900
|
}
|
|
24881
25901
|
};
|
|
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
25902
|
this.lastTarget = null;
|
|
24907
25903
|
this.firstTarget = null;
|
|
24908
25904
|
this.tableSelection = false;
|
|
@@ -24924,7 +25920,7 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
24924
25920
|
*/
|
|
24925
25921
|
TableCellSelection.prototype.initialize = function (editor) {
|
|
24926
25922
|
this.editor = editor;
|
|
24927
|
-
this.editor.addContentEditFeature(
|
|
25923
|
+
this.editor.addContentEditFeature(DeleteTableContents_1.DeleteTableContents);
|
|
24928
25924
|
};
|
|
24929
25925
|
/**
|
|
24930
25926
|
* Dispose this plugin
|
|
@@ -24959,9 +25955,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
24959
25955
|
}
|
|
24960
25956
|
}
|
|
24961
25957
|
break;
|
|
24962
|
-
case 9 /* BeforeCutCopy */:
|
|
24963
|
-
this.handleBeforeCutCopy(event);
|
|
24964
|
-
break;
|
|
24965
25958
|
case 5 /* MouseDown */:
|
|
24966
25959
|
if (!this.startedSelection) {
|
|
24967
25960
|
this.handleMouseDownEvent(event);
|
|
@@ -25018,33 +26011,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
25018
26011
|
this.restoreSelection();
|
|
25019
26012
|
}
|
|
25020
26013
|
};
|
|
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
26014
|
//#region Key events
|
|
25049
26015
|
/**
|
|
25050
26016
|
* Handles the on key event.
|
|
@@ -25399,12 +26365,6 @@ var TableCellSelection = /** @class */ (function () {
|
|
|
25399
26365
|
return TableCellSelection;
|
|
25400
26366
|
}());
|
|
25401
26367
|
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
26368
|
function updateSelection(editor, start, offset, end, endOffset) {
|
|
25409
26369
|
var selection = editor.getDocument().defaultView.getSelection();
|
|
25410
26370
|
end = end || start;
|
|
@@ -25427,52 +26387,64 @@ function getTableAtCursor(editor, node) {
|
|
|
25427
26387
|
|
|
25428
26388
|
/***/ }),
|
|
25429
26389
|
|
|
25430
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25431
|
-
|
|
25432
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25433
|
-
|
|
26390
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/features/DeleteTableContents.ts":
|
|
26391
|
+
/*!**********************************************************************************************************!*\
|
|
26392
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/features/DeleteTableContents.ts ***!
|
|
26393
|
+
\**********************************************************************************************************/
|
|
25434
26394
|
/*! no static exports found */
|
|
25435
26395
|
/***/ (function(module, exports, __webpack_require__) {
|
|
25436
26396
|
|
|
25437
26397
|
"use strict";
|
|
25438
26398
|
|
|
25439
26399
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25440
|
-
exports.
|
|
25441
|
-
var
|
|
25442
|
-
|
|
26400
|
+
exports.DeleteTableContents = void 0;
|
|
26401
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
26402
|
+
/**
|
|
26403
|
+
* @internal
|
|
26404
|
+
* Feature that when Backspace is pressed and there is Table Selection, delete the contents inside of the selection
|
|
26405
|
+
*/
|
|
26406
|
+
exports.DeleteTableContents = {
|
|
26407
|
+
keys: [46 /* DELETE */, 8 /* BACKSPACE */],
|
|
26408
|
+
shouldHandleEvent: function (_, editor) {
|
|
26409
|
+
var selection = editor.getSelectionRangeEx();
|
|
26410
|
+
return selection.type == 1 /* TableSelection */;
|
|
26411
|
+
},
|
|
26412
|
+
handleEvent: function (_, editor) {
|
|
26413
|
+
var selection = editor.getSelectionRangeEx();
|
|
26414
|
+
if (selection.type == 1 /* TableSelection */) {
|
|
26415
|
+
editor.addUndoSnapshot(function () {
|
|
26416
|
+
editor.getSelectedRegions().forEach(function (region) {
|
|
26417
|
+
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(region.rootNode, 'HTMLTableCellElement')) {
|
|
26418
|
+
deleteNodeContents(region.rootNode, editor);
|
|
26419
|
+
}
|
|
26420
|
+
});
|
|
26421
|
+
});
|
|
26422
|
+
}
|
|
26423
|
+
},
|
|
26424
|
+
};
|
|
26425
|
+
function deleteNodeContents(element, editor) {
|
|
26426
|
+
var range = new Range();
|
|
26427
|
+
range.selectNodeContents(element);
|
|
26428
|
+
range.deleteContents();
|
|
26429
|
+
element.appendChild(editor.getDocument().createElement('br'));
|
|
26430
|
+
}
|
|
25443
26431
|
|
|
25444
26432
|
|
|
25445
26433
|
/***/ }),
|
|
25446
26434
|
|
|
25447
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25448
|
-
|
|
25449
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/
|
|
25450
|
-
|
|
26435
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/index.ts":
|
|
26436
|
+
/*!***********************************************************************************!*\
|
|
26437
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/index.ts ***!
|
|
26438
|
+
\***********************************************************************************/
|
|
25451
26439
|
/*! no static exports found */
|
|
25452
26440
|
/***/ (function(module, exports, __webpack_require__) {
|
|
25453
26441
|
|
|
25454
26442
|
"use strict";
|
|
25455
26443
|
|
|
25456
26444
|
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;
|
|
26445
|
+
exports.TableCellSelection = void 0;
|
|
26446
|
+
var TableCellSelection_1 = __webpack_require__(/*! ./TableCellSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/TableCellSelection/TableCellSelection.ts");
|
|
26447
|
+
Object.defineProperty(exports, "TableCellSelection", { enumerable: true, get: function () { return TableCellSelection_1.default; } });
|
|
25476
26448
|
|
|
25477
26449
|
|
|
25478
26450
|
/***/ }),
|
|
@@ -25568,46 +26540,6 @@ function normalizeTableSelection(vTable) {
|
|
|
25568
26540
|
exports.default = normalizeTableSelection;
|
|
25569
26541
|
|
|
25570
26542
|
|
|
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
26543
|
/***/ }),
|
|
25612
26544
|
|
|
25613
26545
|
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/TableResize/TableResize.ts":
|
|
@@ -25956,12 +26888,18 @@ var INSERTER_HOVER_OFFSET = 5;
|
|
|
25956
26888
|
* When set a different current table or change current TD, we need to update these areas
|
|
25957
26889
|
*/
|
|
25958
26890
|
var TableEditor = /** @class */ (function () {
|
|
25959
|
-
function TableEditor(editor, table, onChanged, onShowHelperElement,
|
|
26891
|
+
function TableEditor(editor, table, onChanged, onShowHelperElement, contentDiv) {
|
|
25960
26892
|
var _this = this;
|
|
25961
26893
|
this.editor = editor;
|
|
25962
26894
|
this.table = table;
|
|
25963
26895
|
this.onChanged = onChanged;
|
|
25964
26896
|
this.onShowHelperElement = onShowHelperElement;
|
|
26897
|
+
// 1, 2 - Insert a column or a row
|
|
26898
|
+
this.horizontalInserter = null;
|
|
26899
|
+
this.verticalInserter = null;
|
|
26900
|
+
// 3, 4 - Resize a column or a row from a cell
|
|
26901
|
+
this.horizontalResizer = null;
|
|
26902
|
+
this.verticalResizer = null;
|
|
25965
26903
|
this.onFinishEditing = function () {
|
|
25966
26904
|
_this.editor.focus();
|
|
25967
26905
|
_this.editor.select(_this.start, _this.end);
|
|
@@ -25984,6 +26922,10 @@ var TableEditor = /** @class */ (function () {
|
|
|
25984
26922
|
_this.disposeTableResizer();
|
|
25985
26923
|
_this.onFinishEditing();
|
|
25986
26924
|
};
|
|
26925
|
+
/**
|
|
26926
|
+
* Public only for testing purposes
|
|
26927
|
+
* @param table the table to select
|
|
26928
|
+
*/
|
|
25987
26929
|
this.onSelect = function (table) {
|
|
25988
26930
|
_this.editor.focus();
|
|
25989
26931
|
if (table) {
|
|
@@ -26011,8 +26953,9 @@ var TableEditor = /** @class */ (function () {
|
|
|
26011
26953
|
}
|
|
26012
26954
|
};
|
|
26013
26955
|
this.isRTL = (0, roosterjs_editor_dom_1.getComputedStyle)(table, 'direction') == 'rtl';
|
|
26014
|
-
|
|
26015
|
-
this.
|
|
26956
|
+
var zoomScale = editor.getZoomScale();
|
|
26957
|
+
this.tableResizer = (0, TableResizer_1.default)(table, zoomScale, this.isRTL, this.onStartTableResize, this.onFinishEditing, this.onShowHelperElement);
|
|
26958
|
+
this.tableSelector = (0, TableSelector_1.default)(table, zoomScale, editor, this.onSelect, this.onShowHelperElement, contentDiv);
|
|
26016
26959
|
this.isCurrentlyEditing = false;
|
|
26017
26960
|
}
|
|
26018
26961
|
TableEditor.prototype.dispose = function () {
|
|
@@ -26031,14 +26974,18 @@ var TableEditor = /** @class */ (function () {
|
|
|
26031
26974
|
var j = 0;
|
|
26032
26975
|
for (; j < tr.cells.length; j++) {
|
|
26033
26976
|
var td = tr.cells[j];
|
|
26977
|
+
var tableRect = (0, roosterjs_editor_dom_1.normalizeRect)(this.table.getBoundingClientRect());
|
|
26034
26978
|
var tdRect = (0, roosterjs_editor_dom_1.normalizeRect)(td.getBoundingClientRect());
|
|
26035
|
-
if (!tdRect) {
|
|
26979
|
+
if (!tdRect || !tableRect) {
|
|
26036
26980
|
continue;
|
|
26037
26981
|
}
|
|
26038
26982
|
var lessThanBottom = y <= tdRect.bottom;
|
|
26039
26983
|
var lessThanRight = this.isRTL ? x >= tdRect.right : x <= tdRect.right;
|
|
26040
26984
|
if (lessThanRight && lessThanBottom) {
|
|
26041
|
-
|
|
26985
|
+
var isOnLeftOrRight = this.isRTL
|
|
26986
|
+
? tdRect.right <= tableRect.right && tdRect.right >= tableRect.right - 1
|
|
26987
|
+
: tdRect.left >= tableRect.left && tdRect.left <= tableRect.left + 1;
|
|
26988
|
+
if (i === 0 && y <= tdRect.top + INSERTER_HOVER_OFFSET) {
|
|
26042
26989
|
var center = (tdRect.left + tdRect.right) / 2;
|
|
26043
26990
|
var isOnRightHalf = this.isRTL ? x < center : x > center;
|
|
26044
26991
|
this.setInserterTd(isOnRightHalf ? td : tr.cells[j - 1], false /*isHorizontal*/);
|
|
@@ -26046,10 +26993,20 @@ var TableEditor = /** @class */ (function () {
|
|
|
26046
26993
|
else if (j == 0 &&
|
|
26047
26994
|
(this.isRTL
|
|
26048
26995
|
? x >= tdRect.right - INSERTER_HOVER_OFFSET
|
|
26049
|
-
: x <= tdRect.left + INSERTER_HOVER_OFFSET)
|
|
26050
|
-
|
|
26051
|
-
|
|
26052
|
-
|
|
26996
|
+
: x <= tdRect.left + INSERTER_HOVER_OFFSET) &&
|
|
26997
|
+
isOnLeftOrRight) {
|
|
26998
|
+
var tdAbove = (_a = this.table.rows[i - 1]) === null || _a === void 0 ? void 0 : _a.cells[0];
|
|
26999
|
+
var tdAboveRect = tdAbove
|
|
27000
|
+
? (0, roosterjs_editor_dom_1.normalizeRect)(tdAbove.getBoundingClientRect())
|
|
27001
|
+
: null;
|
|
27002
|
+
var isTdNotAboveMerged = !tdAboveRect
|
|
27003
|
+
? null
|
|
27004
|
+
: this.isRTL
|
|
27005
|
+
? tdAboveRect.right === tdRect.right
|
|
27006
|
+
: tdAboveRect.left === tdRect.left;
|
|
27007
|
+
this.setInserterTd(y < (tdRect.top + tdRect.bottom) / 2 && isTdNotAboveMerged
|
|
27008
|
+
? tdAbove
|
|
27009
|
+
: td, true /*isHorizontal*/);
|
|
26053
27010
|
}
|
|
26054
27011
|
else {
|
|
26055
27012
|
this.setInserterTd(null);
|
|
@@ -26083,7 +27040,7 @@ var TableEditor = /** @class */ (function () {
|
|
|
26083
27040
|
this.disposeTableInserter();
|
|
26084
27041
|
}
|
|
26085
27042
|
if (!this.horizontalInserter && !this.verticalInserter && td) {
|
|
26086
|
-
var newInserter = (0, TableInserter_1.default)(this.editor, td, this.isRTL, isHorizontal, this.onInserted, this.onShowHelperElement);
|
|
27043
|
+
var newInserter = (0, TableInserter_1.default)(this.editor, td, this.isRTL, !!isHorizontal, this.onInserted, this.onShowHelperElement);
|
|
26087
27044
|
if (isHorizontal) {
|
|
26088
27045
|
this.horizontalInserter = newInserter;
|
|
26089
27046
|
}
|
|
@@ -26133,21 +27090,6 @@ var TableEditor = /** @class */ (function () {
|
|
|
26133
27090
|
}
|
|
26134
27091
|
this.editor.addUndoSnapshot();
|
|
26135
27092
|
};
|
|
26136
|
-
TableEditor.prototype.getShouldShowTableSelectorHandler = function (scrollContainer, eventTarget) {
|
|
26137
|
-
if (eventTarget && (0, roosterjs_editor_dom_1.safeInstanceOf)(eventTarget, 'HTMLElement') && scrollContainer) {
|
|
26138
|
-
var scrollContainerRect_1 = (0, roosterjs_editor_dom_1.normalizeRect)(scrollContainer.getBoundingClientRect());
|
|
26139
|
-
var containerRect_1 = (0, roosterjs_editor_dom_1.normalizeRect)(eventTarget.getBoundingClientRect());
|
|
26140
|
-
if (scrollContainerRect_1 && containerRect_1) {
|
|
26141
|
-
var scrollContainerVisibleTop_1 = scrollContainer.scrollTop - scrollContainerRect_1.top;
|
|
26142
|
-
return function (rect) {
|
|
26143
|
-
return containerRect_1.top <= rect.top &&
|
|
26144
|
-
scrollContainerVisibleTop_1 <= rect.top &&
|
|
26145
|
-
scrollContainerRect_1.top <= rect.top;
|
|
26146
|
-
};
|
|
26147
|
-
}
|
|
26148
|
-
}
|
|
26149
|
-
return function () { return true; };
|
|
26150
|
-
};
|
|
26151
27093
|
return TableEditor;
|
|
26152
27094
|
}());
|
|
26153
27095
|
exports.default = TableEditor;
|
|
@@ -26171,10 +27113,12 @@ exports.disposeTableEditFeature = void 0;
|
|
|
26171
27113
|
*/
|
|
26172
27114
|
function disposeTableEditFeature(resizer) {
|
|
26173
27115
|
var _a, _b, _c;
|
|
26174
|
-
|
|
26175
|
-
|
|
26176
|
-
|
|
26177
|
-
|
|
27116
|
+
if (resizer) {
|
|
27117
|
+
(_b = (_a = resizer.div) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(resizer.div);
|
|
27118
|
+
resizer.div = null;
|
|
27119
|
+
(_c = resizer.featureHandler) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
27120
|
+
resizer.featureHandler = null;
|
|
27121
|
+
}
|
|
26178
27122
|
}
|
|
26179
27123
|
exports.disposeTableEditFeature = disposeTableEditFeature;
|
|
26180
27124
|
|
|
@@ -26217,7 +27161,7 @@ function createTableInserter(editor, td, isRTL, isHorizontal, onInsert, onShowHe
|
|
|
26217
27161
|
div.firstChild.style.width = tableRect.right - tableRect.left + "px";
|
|
26218
27162
|
}
|
|
26219
27163
|
else {
|
|
26220
|
-
div.style.left = (isRTL ? tdRect.left : tdRect.right - 8) + "px";
|
|
27164
|
+
div.style.left = (isRTL ? tdRect.left - 8 : tdRect.right - 8) + "px";
|
|
26221
27165
|
div.style.top = tdRect.top - (INSERTER_SIDE_LENGTH - 1 + 2 * INSERTER_BORDER_SIZE) + "px";
|
|
26222
27166
|
div.firstChild.style.height = tableRect.bottom - tableRect.top + "px";
|
|
26223
27167
|
}
|
|
@@ -26225,6 +27169,7 @@ function createTableInserter(editor, td, isRTL, isHorizontal, onInsert, onShowHe
|
|
|
26225
27169
|
var handler = new TableInsertHandler(div, td, isHorizontal, editor, onInsert);
|
|
26226
27170
|
return { div: div, featureHandler: handler, node: td };
|
|
26227
27171
|
}
|
|
27172
|
+
return null;
|
|
26228
27173
|
}
|
|
26229
27174
|
exports.default = createTableInserter;
|
|
26230
27175
|
var TableInsertHandler = /** @class */ (function () {
|
|
@@ -26407,10 +27352,10 @@ var TABLE_SELECTOR_ID = '_Table_Selector';
|
|
|
26407
27352
|
/**
|
|
26408
27353
|
* @internal
|
|
26409
27354
|
*/
|
|
26410
|
-
function createTableSelector(table, zoomScale, onFinishDragging, onShowHelperElement,
|
|
27355
|
+
function createTableSelector(table, zoomScale, editor, onFinishDragging, onShowHelperElement, contentDiv) {
|
|
26411
27356
|
var rect = (0, roosterjs_editor_dom_1.normalizeRect)(table.getBoundingClientRect());
|
|
26412
|
-
if (
|
|
26413
|
-
return
|
|
27357
|
+
if (!isTableTopVisible(editor, rect, contentDiv)) {
|
|
27358
|
+
return null;
|
|
26414
27359
|
}
|
|
26415
27360
|
var document = table.ownerDocument;
|
|
26416
27361
|
var createElementData = {
|
|
@@ -26448,6 +27393,14 @@ function setSelectorDivPosition(context, trigger) {
|
|
|
26448
27393
|
trigger.style.left = rect.left - TABLE_SELECTOR_LENGTH - 2 + "px";
|
|
26449
27394
|
}
|
|
26450
27395
|
}
|
|
27396
|
+
function isTableTopVisible(editor, rect, contentDiv) {
|
|
27397
|
+
var visibleViewport = editor.getVisibleViewport();
|
|
27398
|
+
if (contentDiv && (0, roosterjs_editor_dom_1.safeInstanceOf)(contentDiv, 'HTMLElement') && visibleViewport && rect) {
|
|
27399
|
+
var containerRect = (0, roosterjs_editor_dom_1.normalizeRect)(contentDiv.getBoundingClientRect());
|
|
27400
|
+
return containerRect.top <= rect.top && visibleViewport.top <= rect.top;
|
|
27401
|
+
}
|
|
27402
|
+
return true;
|
|
27403
|
+
}
|
|
26451
27404
|
|
|
26452
27405
|
|
|
26453
27406
|
/***/ }),
|
|
@@ -26490,10 +27443,11 @@ var Watermark = /** @class */ (function () {
|
|
|
26490
27443
|
* Create an instance of Watermark plugin
|
|
26491
27444
|
* @param watermark The watermark string
|
|
26492
27445
|
*/
|
|
26493
|
-
function Watermark(watermark, format) {
|
|
27446
|
+
function Watermark(watermark, format, customClass) {
|
|
26494
27447
|
var _this = this;
|
|
26495
27448
|
this.watermark = watermark;
|
|
26496
27449
|
this.format = format;
|
|
27450
|
+
this.customClass = customClass;
|
|
26497
27451
|
this.showHideWatermark = function () {
|
|
26498
27452
|
var hasFocus = _this.editor.hasFocus();
|
|
26499
27453
|
var watermarks = _this.editor.queryElements((0, roosterjs_editor_dom_1.getEntitySelector)(ENTITY_TYPE));
|
|
@@ -26503,7 +27457,10 @@ var Watermark = /** @class */ (function () {
|
|
|
26503
27457
|
_this.editor.focus();
|
|
26504
27458
|
}
|
|
26505
27459
|
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 */);
|
|
27460
|
+
var newEntity = (0, roosterjs_editor_api_1.insertEntity)(_this.editor, ENTITY_TYPE, _this.editor.getDocument().createTextNode(_this.watermark), false /*isBlock*/, false /*isReadonly*/, 0 /* Begin */);
|
|
27461
|
+
if (_this.customClass) {
|
|
27462
|
+
newEntity.wrapper.classList.add(_this.customClass);
|
|
27463
|
+
}
|
|
26507
27464
|
}
|
|
26508
27465
|
};
|
|
26509
27466
|
this.removeWatermark = function (wrapper) {
|
|
@@ -26705,7 +27662,7 @@ var CompatibleBulletListType;
|
|
|
26705
27662
|
*/
|
|
26706
27663
|
CompatibleBulletListType[CompatibleBulletListType["ShortArrow"] = 4] = "ShortArrow";
|
|
26707
27664
|
/**
|
|
26708
|
-
* Bullet triggered by ->
|
|
27665
|
+
* Bullet triggered by ->
|
|
26709
27666
|
*/
|
|
26710
27667
|
CompatibleBulletListType[CompatibleBulletListType["LongArrow"] = 5] = "LongArrow";
|
|
26711
27668
|
/**
|
|
@@ -26716,10 +27673,18 @@ var CompatibleBulletListType;
|
|
|
26716
27673
|
* Bullet triggered by —
|
|
26717
27674
|
*/
|
|
26718
27675
|
CompatibleBulletListType[CompatibleBulletListType["Hyphen"] = 7] = "Hyphen";
|
|
27676
|
+
/**
|
|
27677
|
+
* Bullet triggered by -->
|
|
27678
|
+
*/
|
|
27679
|
+
CompatibleBulletListType[CompatibleBulletListType["DoubleLongArrow"] = 8] = "DoubleLongArrow";
|
|
27680
|
+
/**
|
|
27681
|
+
* Bullet type circle
|
|
27682
|
+
*/
|
|
27683
|
+
CompatibleBulletListType[CompatibleBulletListType["Circle"] = 9] = "Circle";
|
|
26719
27684
|
/**
|
|
26720
27685
|
* Maximum value of the enum
|
|
26721
27686
|
*/
|
|
26722
|
-
CompatibleBulletListType[CompatibleBulletListType["Max"] =
|
|
27687
|
+
CompatibleBulletListType[CompatibleBulletListType["Max"] = 9] = "Max";
|
|
26723
27688
|
})(CompatibleBulletListType = exports.CompatibleBulletListType || (exports.CompatibleBulletListType = {}));
|
|
26724
27689
|
|
|
26725
27690
|
|
|
@@ -27538,7 +28503,7 @@ var CompatibleExperimentalFeatures;
|
|
|
27538
28503
|
*/
|
|
27539
28504
|
CompatibleExperimentalFeatures["ImageRotate"] = "ImageRotate";
|
|
27540
28505
|
/**
|
|
27541
|
-
*
|
|
28506
|
+
* @deprecated This feature is always enabled
|
|
27542
28507
|
*/
|
|
27543
28508
|
CompatibleExperimentalFeatures["ImageCrop"] = "ImageCrop";
|
|
27544
28509
|
/**
|
|
@@ -27586,6 +28551,17 @@ var CompatibleExperimentalFeatures;
|
|
|
27586
28551
|
* e.g. We will move list items with "display: block" into previous list item and change tag to be DIV
|
|
27587
28552
|
*/
|
|
27588
28553
|
CompatibleExperimentalFeatures["NormalizeList"] = "NormalizeList";
|
|
28554
|
+
/**
|
|
28555
|
+
* When a html image is selected, the selected image data will be stored by editor core.
|
|
28556
|
+
*/
|
|
28557
|
+
CompatibleExperimentalFeatures["ImageSelection"] = "ImageSelection";
|
|
28558
|
+
/**
|
|
28559
|
+
* With this feature enabled, when writing back a list item we will re-use all
|
|
28560
|
+
* ancestor list elements, even if they don't match the types currently in the
|
|
28561
|
+
* listTypes array for that item. The only list that we will ensure is correct
|
|
28562
|
+
* is the one closest to the item.
|
|
28563
|
+
*/
|
|
28564
|
+
CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
|
|
27589
28565
|
})(CompatibleExperimentalFeatures = exports.CompatibleExperimentalFeatures || (exports.CompatibleExperimentalFeatures = {}));
|
|
27590
28566
|
|
|
27591
28567
|
|
|
@@ -28319,6 +29295,10 @@ var CompatibleSelectionRangeTypes;
|
|
|
28319
29295
|
* Selection made inside of a single table.
|
|
28320
29296
|
*/
|
|
28321
29297
|
CompatibleSelectionRangeTypes[CompatibleSelectionRangeTypes["TableSelection"] = 1] = "TableSelection";
|
|
29298
|
+
/**
|
|
29299
|
+
* Selection made in a image.
|
|
29300
|
+
*/
|
|
29301
|
+
CompatibleSelectionRangeTypes[CompatibleSelectionRangeTypes["ImageSelection"] = 2] = "ImageSelection";
|
|
28322
29302
|
})(CompatibleSelectionRangeTypes = exports.CompatibleSelectionRangeTypes || (exports.CompatibleSelectionRangeTypes = {}));
|
|
28323
29303
|
|
|
28324
29304
|
|