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