roosterjs 8.42.0 → 8.44.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 +156 -31
- package/dist/rooster-amd.js +1010 -206
- 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 +156 -31
- package/dist/rooster.js +1010 -206
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
- package/tsconfig.child.tsbuildinfo +1 -1
package/dist/rooster.js
CHANGED
|
@@ -2844,6 +2844,7 @@ function getElementBasedFormatState(editor, event) {
|
|
|
2844
2844
|
canUnlink: !!editor.queryElements('a[href]', 1 /* OnSelection */)[0],
|
|
2845
2845
|
canAddImageAltText: !!editor.queryElements('img', 1 /* OnSelection */)[0],
|
|
2846
2846
|
isBlockQuote: !!editor.queryElements('blockquote', 1 /* OnSelection */)[0],
|
|
2847
|
+
isCodeInline: !!editor.queryElements('code', 1 /* OnSelection */)[0],
|
|
2847
2848
|
isCodeBlock: !!editor.queryElements('pre>code', 1 /* OnSelection */)[0],
|
|
2848
2849
|
isInTable: !!table,
|
|
2849
2850
|
tableFormat: tableFormat,
|
|
@@ -2972,6 +2973,14 @@ function insertEntity(editor, type, contentNode, isBlock, isReadonly, position,
|
|
|
2972
2973
|
wrapper.parentNode.insertBefore(br, wrapper.nextSibling);
|
|
2973
2974
|
}
|
|
2974
2975
|
var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)(wrapper);
|
|
2976
|
+
if (!isBlock &&
|
|
2977
|
+
isReadonly &&
|
|
2978
|
+
editor.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */)) {
|
|
2979
|
+
(0, roosterjs_editor_dom_1.addDelimiters)(entity.wrapper);
|
|
2980
|
+
if (entity.wrapper.nextElementSibling) {
|
|
2981
|
+
editor.select(new roosterjs_editor_dom_1.Position(entity.wrapper.nextElementSibling, -3 /* After */));
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2975
2984
|
editor.triggerContentChangedEvent("InsertEntity" /* InsertEntity */, entity);
|
|
2976
2985
|
return entity;
|
|
2977
2986
|
}
|
|
@@ -4377,9 +4386,11 @@ function blockFormat(editor, callback, beforeRunCallback, apiName) {
|
|
|
4377
4386
|
(0, formatUndoSnapshot_1.default)(editor, function (start, end) {
|
|
4378
4387
|
if (!beforeRunCallback || beforeRunCallback()) {
|
|
4379
4388
|
var regions = editor.getSelectedRegions();
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4389
|
+
if (regions.length > 0) {
|
|
4390
|
+
var chains_1 = roosterjs_editor_dom_1.VListChain.createListChains(regions, start === null || start === void 0 ? void 0 : start.node);
|
|
4391
|
+
regions.forEach(function (region) { return callback(region, start, end, chains_1); });
|
|
4392
|
+
(0, commitListChains_1.default)(editor, chains_1);
|
|
4393
|
+
}
|
|
4383
4394
|
}
|
|
4384
4395
|
if (selection.type == 0 /* Normal */) {
|
|
4385
4396
|
editor.select(start, end);
|
|
@@ -4792,6 +4803,7 @@ var addUndoSnapshot = function (core, callback, changeSource, canUndoByBackspace
|
|
|
4792
4803
|
};
|
|
4793
4804
|
exports.addUndoSnapshot = addUndoSnapshot;
|
|
4794
4805
|
function addUndoSnapshotInternal(core, canUndoByBackspace) {
|
|
4806
|
+
var _a;
|
|
4795
4807
|
if (!core.lifecycle.shadowEditFragment) {
|
|
4796
4808
|
var rangeEx = core.api.getSelectionRangeEx(core);
|
|
4797
4809
|
var isDarkMode = core.lifecycle.isDarkMode;
|
|
@@ -4799,6 +4811,7 @@ function addUndoSnapshotInternal(core, canUndoByBackspace) {
|
|
|
4799
4811
|
core.undo.snapshotsService.addSnapshot({
|
|
4800
4812
|
html: core.contentDiv.innerHTML,
|
|
4801
4813
|
metadata: metadata,
|
|
4814
|
+
knownColors: ((_a = core.darkColorHandler) === null || _a === void 0 ? void 0 : _a.getKnownColorsCopy()) || [],
|
|
4802
4815
|
}, canUndoByBackspace);
|
|
4803
4816
|
core.undo.hasNewContent = false;
|
|
4804
4817
|
}
|
|
@@ -5312,7 +5325,7 @@ var getContent = function (core, mode) {
|
|
|
5312
5325
|
: null;
|
|
5313
5326
|
var range = path && (0, roosterjs_editor_dom_1.createRange)(clonedRoot, path.start, path.end);
|
|
5314
5327
|
if (core.lifecycle.isDarkMode || core.darkColorHandler) {
|
|
5315
|
-
core.api.transformColor(core, clonedRoot, false /*includeSelf*/, null /*callback*/, 1 /* DarkToLight */, !!core.darkColorHandler);
|
|
5328
|
+
core.api.transformColor(core, clonedRoot, false /*includeSelf*/, null /*callback*/, 1 /* DarkToLight */, !!core.darkColorHandler, core.lifecycle.isDarkMode);
|
|
5316
5329
|
}
|
|
5317
5330
|
if (triggerExtractContentEvent) {
|
|
5318
5331
|
core.api.triggerEvent(core, {
|
|
@@ -5634,6 +5647,8 @@ var getStyleBasedFormatState = function (core, node) {
|
|
|
5634
5647
|
'line-height',
|
|
5635
5648
|
'margin-top',
|
|
5636
5649
|
'margin-bottom',
|
|
5650
|
+
'text-align',
|
|
5651
|
+
'direction',
|
|
5637
5652
|
])
|
|
5638
5653
|
: [];
|
|
5639
5654
|
var contentDiv = core.contentDiv, darkColorHandler = core.darkColorHandler, isDarkMode = core.lifecycle.isDarkMode;
|
|
@@ -5677,6 +5692,8 @@ var getStyleBasedFormatState = function (core, node) {
|
|
|
5677
5692
|
lineHeight: styles[4],
|
|
5678
5693
|
marginTop: styles[5],
|
|
5679
5694
|
marginBottom: styles[6],
|
|
5695
|
+
textAlign: styles[7],
|
|
5696
|
+
direction: styles[8],
|
|
5680
5697
|
};
|
|
5681
5698
|
}
|
|
5682
5699
|
else {
|
|
@@ -5710,6 +5727,8 @@ var getStyleBasedFormatState = function (core, node) {
|
|
|
5710
5727
|
}
|
|
5711
5728
|
: undefined,
|
|
5712
5729
|
lineHeight: styles[4],
|
|
5730
|
+
textAlign: styles[7],
|
|
5731
|
+
direction: styles[8],
|
|
5713
5732
|
};
|
|
5714
5733
|
}
|
|
5715
5734
|
};
|
|
@@ -5951,6 +5970,13 @@ var restoreUndoSnapshot = function (core, step) {
|
|
|
5951
5970
|
try {
|
|
5952
5971
|
core.undo.isRestoring = true;
|
|
5953
5972
|
core.api.setContent(core, snapshot.html, true /*triggerContentChangedEvent*/, (_a = snapshot.metadata) !== null && _a !== void 0 ? _a : undefined);
|
|
5973
|
+
var darkColorHandler_1 = core.darkColorHandler;
|
|
5974
|
+
var isDarkModel_1 = core.lifecycle.isDarkMode;
|
|
5975
|
+
if (darkColorHandler_1) {
|
|
5976
|
+
snapshot.knownColors.forEach(function (color) {
|
|
5977
|
+
darkColorHandler_1.registerColor(color.lightModeColor, isDarkModel_1, color.darkModeColor);
|
|
5978
|
+
});
|
|
5979
|
+
}
|
|
5954
5980
|
}
|
|
5955
5981
|
finally {
|
|
5956
5982
|
core.undo.isRestoring = false;
|
|
@@ -6284,7 +6310,7 @@ var setContent = function (core, content, triggerContentChangedEvent, metadata)
|
|
|
6284
6310
|
}
|
|
6285
6311
|
var isDarkMode = core.lifecycle.isDarkMode;
|
|
6286
6312
|
if ((!metadata && isDarkMode) || (metadata && !!metadata.isDarkMode != !!isDarkMode)) {
|
|
6287
|
-
core.api.transformColor(core, core.contentDiv, false /*includeSelf*/, null /*callback*/, isDarkMode ? 0 /* LightToDark */ : 1 /* DarkToLight */, true /*forceTransform
|
|
6313
|
+
core.api.transformColor(core, core.contentDiv, false /*includeSelf*/, null /*callback*/, isDarkMode ? 0 /* LightToDark */ : 1 /* DarkToLight */, true /*forceTransform*/, metadata === null || metadata === void 0 ? void 0 : metadata.isDarkMode);
|
|
6288
6314
|
contentChanged = true;
|
|
6289
6315
|
}
|
|
6290
6316
|
if (triggerContentChangedEvent && contentChanged) {
|
|
@@ -6452,14 +6478,14 @@ var ColorAttributeName = [
|
|
|
6452
6478
|
* @param forceTransform By default this function will only work when editor core is in dark mode.
|
|
6453
6479
|
* Pass true to this value to force do color transformation even editor core is in light mode
|
|
6454
6480
|
*/
|
|
6455
|
-
var transformColor = function (core, rootNode, includeSelf, callback, direction, forceTransform) {
|
|
6481
|
+
var transformColor = function (core, rootNode, includeSelf, callback, direction, forceTransform, fromDarkMode) {
|
|
6456
6482
|
var darkColorHandler = core.darkColorHandler;
|
|
6457
6483
|
var elements = rootNode && (forceTransform || core.lifecycle.isDarkMode)
|
|
6458
6484
|
? getAll(rootNode, includeSelf)
|
|
6459
6485
|
: [];
|
|
6460
6486
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
6461
6487
|
if (darkColorHandler) {
|
|
6462
|
-
transformV2(elements, darkColorHandler, direction == 0 /* LightToDark */);
|
|
6488
|
+
transformV2(elements, darkColorHandler, !!fromDarkMode, direction == 0 /* LightToDark */);
|
|
6463
6489
|
}
|
|
6464
6490
|
else {
|
|
6465
6491
|
if (direction == 1 /* DarkToLight */) {
|
|
@@ -6474,11 +6500,13 @@ var transformColor = function (core, rootNode, includeSelf, callback, direction,
|
|
|
6474
6500
|
}
|
|
6475
6501
|
};
|
|
6476
6502
|
exports.transformColor = transformColor;
|
|
6477
|
-
function transformV2(elements, darkColorHandler, toDark) {
|
|
6503
|
+
function transformV2(elements, darkColorHandler, fromDark, toDark) {
|
|
6478
6504
|
elements.forEach(function (element) {
|
|
6479
6505
|
ColorAttributeName.forEach(function (names, i) {
|
|
6480
6506
|
var color = darkColorHandler.parseColorValue(element.style.getPropertyValue(names[0 /* CssColor */]) ||
|
|
6481
|
-
element.getAttribute(names[1 /* HtmlColor */])).lightModeColor;
|
|
6507
|
+
element.getAttribute(names[1 /* HtmlColor */]), fromDark).lightModeColor;
|
|
6508
|
+
element.style.setProperty(names[0 /* CssColor */], null);
|
|
6509
|
+
element.removeAttribute(names[1 /* HtmlColor */]);
|
|
6482
6510
|
if (color && color != 'inherit') {
|
|
6483
6511
|
(0, roosterjs_editor_dom_1.setColor)(element, color, i != 0, toDark, false /*shouldAdaptFontColor*/, darkColorHandler);
|
|
6484
6512
|
}
|
|
@@ -7225,6 +7253,7 @@ exports.default = EditPlugin;
|
|
|
7225
7253
|
"use strict";
|
|
7226
7254
|
|
|
7227
7255
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7256
|
+
var inlineEntityOnPluginEvent_1 = __webpack_require__(/*! ./utils/inlineEntityOnPluginEvent */ "./packages/roosterjs-editor-core/lib/corePlugins/utils/inlineEntityOnPluginEvent.ts");
|
|
7228
7257
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
7229
7258
|
var ENTITY_ID_REGEX = /_(\d{1,8})$/;
|
|
7230
7259
|
var ENTITY_CSS_REGEX = '^' + "_Entity" /* ENTITY_INFO_NAME */ + '$';
|
|
@@ -7311,6 +7340,7 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
7311
7340
|
* @param event PluginEvent object
|
|
7312
7341
|
*/
|
|
7313
7342
|
EntityPlugin.prototype.onPluginEvent = function (event) {
|
|
7343
|
+
var _a;
|
|
7314
7344
|
switch (event.eventType) {
|
|
7315
7345
|
case 6 /* MouseUp */:
|
|
7316
7346
|
this.handleMouseUpEvent(event);
|
|
@@ -7345,6 +7375,9 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
7345
7375
|
this.handleEntityOperationEvent(event);
|
|
7346
7376
|
break;
|
|
7347
7377
|
}
|
|
7378
|
+
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */)) {
|
|
7379
|
+
(0, inlineEntityOnPluginEvent_1.inlineEntityOnPluginEvent)(event, this.editor);
|
|
7380
|
+
}
|
|
7348
7381
|
};
|
|
7349
7382
|
EntityPlugin.prototype.handleContextMenuEvent = function (event) {
|
|
7350
7383
|
var _a;
|
|
@@ -7394,6 +7427,8 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
7394
7427
|
};
|
|
7395
7428
|
EntityPlugin.prototype.handleContentChangedEvent = function (event) {
|
|
7396
7429
|
var _this = this;
|
|
7430
|
+
var _a;
|
|
7431
|
+
var shouldNormalizeDelimiters = false;
|
|
7397
7432
|
// 1. find removed entities
|
|
7398
7433
|
for (var i = this.state.knownEntityElements.length - 1; i >= 0; i--) {
|
|
7399
7434
|
var element = this.state.knownEntityElements[i];
|
|
@@ -7402,6 +7437,11 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
7402
7437
|
if (element.shadowRoot) {
|
|
7403
7438
|
this.triggerEvent(element, 10 /* RemoveShadowRoot */);
|
|
7404
7439
|
}
|
|
7440
|
+
if (!shouldNormalizeDelimiters &&
|
|
7441
|
+
!element.isContentEditable &&
|
|
7442
|
+
!(0, roosterjs_editor_dom_1.isBlockElement)(element)) {
|
|
7443
|
+
shouldNormalizeDelimiters = true;
|
|
7444
|
+
}
|
|
7405
7445
|
}
|
|
7406
7446
|
}
|
|
7407
7447
|
// 2. collect all new entities
|
|
@@ -7425,6 +7465,10 @@ var EntityPlugin = /** @class */ (function () {
|
|
|
7425
7465
|
_this.triggerEvent(_this.state.shadowEntityCache[id], 6 /* Overwrite */);
|
|
7426
7466
|
delete _this.state.shadowEntityCache[id];
|
|
7427
7467
|
});
|
|
7468
|
+
if (shouldNormalizeDelimiters &&
|
|
7469
|
+
((_a = this.editor) === null || _a === void 0 ? void 0 : _a.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */))) {
|
|
7470
|
+
(0, inlineEntityOnPluginEvent_1.normalizeDelimitersInEditor)(this.editor);
|
|
7471
|
+
}
|
|
7428
7472
|
};
|
|
7429
7473
|
EntityPlugin.prototype.handleEntityOperationEvent = function (event) {
|
|
7430
7474
|
var _this = this;
|
|
@@ -7601,6 +7645,7 @@ var workaroundSelectionIssueForIE = roosterjs_editor_dom_1.Browser.isIE
|
|
|
7601
7645
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7602
7646
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
7603
7647
|
var Escape = 'Escape';
|
|
7648
|
+
var Delete = 'Delete';
|
|
7604
7649
|
var mouseRightButton = 2;
|
|
7605
7650
|
var mouseLeftButton = 0;
|
|
7606
7651
|
/**
|
|
@@ -7672,6 +7717,10 @@ var ImageSelection = /** @class */ (function () {
|
|
|
7672
7717
|
(_a = this.editor.getSelectionRange()) === null || _a === void 0 ? void 0 : _a.collapse();
|
|
7673
7718
|
event.rawEvent.stopPropagation();
|
|
7674
7719
|
}
|
|
7720
|
+
else if (key === Delete) {
|
|
7721
|
+
this.editor.deleteNode(keyDownSelection.image);
|
|
7722
|
+
event.rawEvent.preventDefault();
|
|
7723
|
+
}
|
|
7675
7724
|
else {
|
|
7676
7725
|
this.editor.select(keyDownSelection.ranges[0]);
|
|
7677
7726
|
}
|
|
@@ -8623,7 +8672,7 @@ function createUndoSnapshotServiceBridge(service) {
|
|
|
8623
8672
|
? {
|
|
8624
8673
|
canMove: function (delta) { return service.canMove(delta); },
|
|
8625
8674
|
move: function (delta) {
|
|
8626
|
-
return (html = service.move(delta)) ? { html: html, metadata: null } : null;
|
|
8675
|
+
return (html = service.move(delta)) ? { html: html, metadata: null, knownColors: [] } : null;
|
|
8627
8676
|
},
|
|
8628
8677
|
addSnapshot: function (snapshot, isAutoCompleteSnapshot) {
|
|
8629
8678
|
return service.addSnapshot(snapshot.html +
|
|
@@ -8741,6 +8790,222 @@ var forEachSelectedCell = function (vTable, callback) {
|
|
|
8741
8790
|
exports.forEachSelectedCell = forEachSelectedCell;
|
|
8742
8791
|
|
|
8743
8792
|
|
|
8793
|
+
/***/ }),
|
|
8794
|
+
|
|
8795
|
+
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/utils/inlineEntityOnPluginEvent.ts":
|
|
8796
|
+
/*!*******************************************************************************************!*\
|
|
8797
|
+
!*** ./packages/roosterjs-editor-core/lib/corePlugins/utils/inlineEntityOnPluginEvent.ts ***!
|
|
8798
|
+
\*******************************************************************************************/
|
|
8799
|
+
/*! no static exports found */
|
|
8800
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
8801
|
+
|
|
8802
|
+
"use strict";
|
|
8803
|
+
|
|
8804
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8805
|
+
exports.normalizeDelimitersInEditor = exports.inlineEntityOnPluginEvent = void 0;
|
|
8806
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
8807
|
+
var DELIMITER_SELECTOR = '.' + "entityDelimiterAfter" /* DELIMITER_AFTER */ + ',.' + "entityDelimiterBefore" /* DELIMITER_BEFORE */;
|
|
8808
|
+
var ZERO_WIDTH_SPACE = '\u200B';
|
|
8809
|
+
var INLINE_ENTITY_SELECTOR = 'span' + (0, roosterjs_editor_dom_1.getEntitySelector)();
|
|
8810
|
+
var NBSP = '\u00A0';
|
|
8811
|
+
function inlineEntityOnPluginEvent(event, editor) {
|
|
8812
|
+
switch (event.eventType) {
|
|
8813
|
+
case 7 /* ContentChanged */:
|
|
8814
|
+
if (event.source === "SetContent" /* SetContent */) {
|
|
8815
|
+
normalizeDelimitersInEditor(editor);
|
|
8816
|
+
}
|
|
8817
|
+
break;
|
|
8818
|
+
case 11 /* EditorReady */:
|
|
8819
|
+
normalizeDelimitersInEditor(editor);
|
|
8820
|
+
break;
|
|
8821
|
+
case 10 /* BeforePaste */:
|
|
8822
|
+
addDelimitersIfNeeded(event.fragment.querySelectorAll(INLINE_ENTITY_SELECTOR));
|
|
8823
|
+
break;
|
|
8824
|
+
case 8 /* ExtractContentWithDom */:
|
|
8825
|
+
case 9 /* BeforeCutCopy */:
|
|
8826
|
+
event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(removeNode);
|
|
8827
|
+
break;
|
|
8828
|
+
case 0 /* KeyDown */:
|
|
8829
|
+
handleKeyDownEvent(editor, event);
|
|
8830
|
+
break;
|
|
8831
|
+
}
|
|
8832
|
+
}
|
|
8833
|
+
exports.inlineEntityOnPluginEvent = inlineEntityOnPluginEvent;
|
|
8834
|
+
function preventTypeInDelimiter(delimiter) {
|
|
8835
|
+
var _a, _b, _c, _d;
|
|
8836
|
+
delimiter.normalize();
|
|
8837
|
+
var textNode = delimiter.firstChild;
|
|
8838
|
+
var index = (_b = (_a = textNode.nodeValue) === null || _a === void 0 ? void 0 : _a.indexOf(ZERO_WIDTH_SPACE)) !== null && _b !== void 0 ? _b : -1;
|
|
8839
|
+
if (index >= 0) {
|
|
8840
|
+
(0, roosterjs_editor_dom_1.splitTextNode)(textNode, index == 0 ? 1 : index, false /* returnFirstPart */);
|
|
8841
|
+
var nodeToMove_1;
|
|
8842
|
+
delimiter.childNodes.forEach(function (node) {
|
|
8843
|
+
if (node.nodeValue !== ZERO_WIDTH_SPACE) {
|
|
8844
|
+
nodeToMove_1 = node;
|
|
8845
|
+
}
|
|
8846
|
+
});
|
|
8847
|
+
if (nodeToMove_1) {
|
|
8848
|
+
(_c = delimiter.parentElement) === null || _c === void 0 ? void 0 : _c.insertBefore(nodeToMove_1, delimiter.className == "entityDelimiterBefore" /* DELIMITER_BEFORE */
|
|
8849
|
+
? delimiter
|
|
8850
|
+
: delimiter.nextSibling);
|
|
8851
|
+
var selection = (_d = nodeToMove_1.ownerDocument) === null || _d === void 0 ? void 0 : _d.getSelection();
|
|
8852
|
+
if (selection) {
|
|
8853
|
+
selection.setPosition(nodeToMove_1, new roosterjs_editor_dom_1.Position(nodeToMove_1, -1 /* End */).offset);
|
|
8854
|
+
}
|
|
8855
|
+
}
|
|
8856
|
+
}
|
|
8857
|
+
}
|
|
8858
|
+
/**
|
|
8859
|
+
* @internal
|
|
8860
|
+
*/
|
|
8861
|
+
function normalizeDelimitersInEditor(editor) {
|
|
8862
|
+
removeInvalidDelimiters(editor.queryElements(DELIMITER_SELECTOR));
|
|
8863
|
+
addDelimitersIfNeeded(editor.queryElements(INLINE_ENTITY_SELECTOR));
|
|
8864
|
+
}
|
|
8865
|
+
exports.normalizeDelimitersInEditor = normalizeDelimitersInEditor;
|
|
8866
|
+
function addDelimitersIfNeeded(nodes) {
|
|
8867
|
+
nodes.forEach(function (node) {
|
|
8868
|
+
if (tryGetEntityFromNode(node)) {
|
|
8869
|
+
(0, roosterjs_editor_dom_1.addDelimiters)(node);
|
|
8870
|
+
}
|
|
8871
|
+
});
|
|
8872
|
+
}
|
|
8873
|
+
function tryGetEntityFromNode(node) {
|
|
8874
|
+
return !!(node &&
|
|
8875
|
+
(0, roosterjs_editor_dom_1.safeInstanceOf)(node, 'HTMLElement') &&
|
|
8876
|
+
isReadOnly((0, roosterjs_editor_dom_1.getEntityFromElement)(node)));
|
|
8877
|
+
}
|
|
8878
|
+
function removeNode(el) {
|
|
8879
|
+
var _a;
|
|
8880
|
+
(_a = el === null || el === void 0 ? void 0 : el.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(el);
|
|
8881
|
+
}
|
|
8882
|
+
function isReadOnly(entity) {
|
|
8883
|
+
return ((entity === null || entity === void 0 ? void 0 : entity.isReadonly) &&
|
|
8884
|
+
!(0, roosterjs_editor_dom_1.isBlockElement)(entity.wrapper) &&
|
|
8885
|
+
(0, roosterjs_editor_dom_1.safeInstanceOf)(entity.wrapper, 'HTMLElement'));
|
|
8886
|
+
}
|
|
8887
|
+
function removeInvalidDelimiters(nodes) {
|
|
8888
|
+
nodes.forEach(function (node) {
|
|
8889
|
+
if ((0, roosterjs_editor_dom_1.getDelimiterFromElement)(node)) {
|
|
8890
|
+
var sibling = node.classList.contains("entityDelimiterBefore" /* DELIMITER_BEFORE */)
|
|
8891
|
+
? node.nextElementSibling
|
|
8892
|
+
: node.previousElementSibling;
|
|
8893
|
+
if (!((0, roosterjs_editor_dom_1.safeInstanceOf)(sibling, 'HTMLElement') && (0, roosterjs_editor_dom_1.getEntityFromElement)(sibling))) {
|
|
8894
|
+
removeNode(node);
|
|
8895
|
+
}
|
|
8896
|
+
}
|
|
8897
|
+
else {
|
|
8898
|
+
removeDelimiterAttr(node);
|
|
8899
|
+
}
|
|
8900
|
+
});
|
|
8901
|
+
}
|
|
8902
|
+
function removeDelimiterAttr(node) {
|
|
8903
|
+
if (!node) {
|
|
8904
|
+
return;
|
|
8905
|
+
}
|
|
8906
|
+
var isAfter = node.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
8907
|
+
var entitySibling = isAfter ? node.previousElementSibling : node.nextElementSibling;
|
|
8908
|
+
if (entitySibling && tryGetEntityFromNode(entitySibling)) {
|
|
8909
|
+
return;
|
|
8910
|
+
}
|
|
8911
|
+
node.classList.remove("entityDelimiterAfter" /* DELIMITER_AFTER */, "entityDelimiterBefore" /* DELIMITER_BEFORE */);
|
|
8912
|
+
node.normalize();
|
|
8913
|
+
node.childNodes.forEach(function (cn) {
|
|
8914
|
+
var _a, _b, _c;
|
|
8915
|
+
var index = (_b = (_a = cn.textContent) === null || _a === void 0 ? void 0 : _a.indexOf(ZERO_WIDTH_SPACE)) !== null && _b !== void 0 ? _b : -1;
|
|
8916
|
+
if (index >= 0) {
|
|
8917
|
+
(_c = (0, roosterjs_editor_dom_1.createRange)(cn, index, cn, index + 1)) === null || _c === void 0 ? void 0 : _c.deleteContents();
|
|
8918
|
+
}
|
|
8919
|
+
});
|
|
8920
|
+
}
|
|
8921
|
+
function handleCollapsedEnter(editor, delimiter) {
|
|
8922
|
+
var isAfter = delimiter.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
8923
|
+
var sibling = isAfter ? delimiter.nextSibling : delimiter.previousSibling;
|
|
8924
|
+
var positionToUse;
|
|
8925
|
+
var element;
|
|
8926
|
+
if (sibling) {
|
|
8927
|
+
positionToUse = new roosterjs_editor_dom_1.Position(sibling, isAfter ? 0 /* Begin */ : -1 /* End */);
|
|
8928
|
+
}
|
|
8929
|
+
else {
|
|
8930
|
+
element = delimiter.insertAdjacentElement(isAfter ? 'afterend' : 'beforebegin', (0, roosterjs_editor_dom_1.createElement)({
|
|
8931
|
+
tag: 'span',
|
|
8932
|
+
children: [NBSP],
|
|
8933
|
+
}, editor.getDocument()));
|
|
8934
|
+
if (!element) {
|
|
8935
|
+
return;
|
|
8936
|
+
}
|
|
8937
|
+
positionToUse = new roosterjs_editor_dom_1.Position(element, 0 /* Begin */);
|
|
8938
|
+
}
|
|
8939
|
+
if (positionToUse) {
|
|
8940
|
+
editor.select(positionToUse);
|
|
8941
|
+
editor.runAsync(function (aEditor) {
|
|
8942
|
+
var elAfter = aEditor.getElementAtCursor();
|
|
8943
|
+
removeDelimiterAttr(elAfter);
|
|
8944
|
+
removeNode(element);
|
|
8945
|
+
});
|
|
8946
|
+
}
|
|
8947
|
+
}
|
|
8948
|
+
var getPosition = function (container) {
|
|
8949
|
+
if (container && (0, roosterjs_editor_dom_1.getDelimiterFromElement)(container)) {
|
|
8950
|
+
var isAfter = container.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
8951
|
+
return new roosterjs_editor_dom_1.Position(container, isAfter ? -3 /* After */ : -2 /* Before */);
|
|
8952
|
+
}
|
|
8953
|
+
return undefined;
|
|
8954
|
+
};
|
|
8955
|
+
function handleSelectionNotCollapsed(editor, range, event) {
|
|
8956
|
+
var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset;
|
|
8957
|
+
var startElement = editor.getElementAtCursor(DELIMITER_SELECTOR, startContainer);
|
|
8958
|
+
var endElement = editor.getElementAtCursor(DELIMITER_SELECTOR, endContainer);
|
|
8959
|
+
var startUpdate = getPosition(startElement);
|
|
8960
|
+
var endUpdate = getPosition(endElement);
|
|
8961
|
+
if (startUpdate || endUpdate) {
|
|
8962
|
+
editor.select(startUpdate !== null && startUpdate !== void 0 ? startUpdate : new roosterjs_editor_dom_1.Position(startContainer, startOffset), endUpdate !== null && endUpdate !== void 0 ? endUpdate : new roosterjs_editor_dom_1.Position(endContainer, endOffset));
|
|
8963
|
+
}
|
|
8964
|
+
editor.runAsync(function (aEditor) {
|
|
8965
|
+
var delimiter = aEditor.getElementAtCursor(DELIMITER_SELECTOR);
|
|
8966
|
+
if (delimiter) {
|
|
8967
|
+
preventTypeInDelimiter(delimiter);
|
|
8968
|
+
if (event.which === 13 /* ENTER */) {
|
|
8969
|
+
removeDelimiterAttr(delimiter);
|
|
8970
|
+
}
|
|
8971
|
+
}
|
|
8972
|
+
});
|
|
8973
|
+
}
|
|
8974
|
+
function handleKeyDownEvent(editor, event) {
|
|
8975
|
+
var _a, _b;
|
|
8976
|
+
var range = editor.getSelectionRangeEx();
|
|
8977
|
+
var rawEvent = event.rawEvent;
|
|
8978
|
+
if (range.type != 0 /* Normal */) {
|
|
8979
|
+
return;
|
|
8980
|
+
}
|
|
8981
|
+
if (range.areAllCollapsed && ((0, roosterjs_editor_dom_1.isCharacterValue)(rawEvent) || rawEvent.which === 13 /* ENTER */)) {
|
|
8982
|
+
var position = (_a = editor.getFocusedPosition()) === null || _a === void 0 ? void 0 : _a.normalize();
|
|
8983
|
+
if (!position) {
|
|
8984
|
+
return;
|
|
8985
|
+
}
|
|
8986
|
+
var element = position.element, node = position.node;
|
|
8987
|
+
var refNode = element == node ? element.childNodes.item(position.offset) : element;
|
|
8988
|
+
var delimiter_1 = editor.getElementAtCursor(DELIMITER_SELECTOR, refNode);
|
|
8989
|
+
if (!delimiter_1) {
|
|
8990
|
+
return;
|
|
8991
|
+
}
|
|
8992
|
+
if (rawEvent.which === 13 /* ENTER */) {
|
|
8993
|
+
handleCollapsedEnter(editor, delimiter_1);
|
|
8994
|
+
}
|
|
8995
|
+
else if (((_b = delimiter_1.firstChild) === null || _b === void 0 ? void 0 : _b.nodeType) == 3 /* Text */) {
|
|
8996
|
+
editor.runAsync(function () { return preventTypeInDelimiter(delimiter_1); });
|
|
8997
|
+
}
|
|
8998
|
+
}
|
|
8999
|
+
else if (!range.areAllCollapsed && !rawEvent.shiftKey && rawEvent.which != 16 /* SHIFT */) {
|
|
9000
|
+
var currentRange = range.ranges[0];
|
|
9001
|
+
if (!currentRange) {
|
|
9002
|
+
return;
|
|
9003
|
+
}
|
|
9004
|
+
handleSelectionNotCollapsed(editor, currentRange, rawEvent);
|
|
9005
|
+
}
|
|
9006
|
+
}
|
|
9007
|
+
|
|
9008
|
+
|
|
8744
9009
|
/***/ }),
|
|
8745
9010
|
|
|
8746
9011
|
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/utils/removeCellsOutsideSelection.ts":
|
|
@@ -8812,6 +9077,13 @@ var DarkColorHandlerImpl = /** @class */ (function () {
|
|
|
8812
9077
|
this.getDarkColor = getDarkColor;
|
|
8813
9078
|
this.knownColors = {};
|
|
8814
9079
|
}
|
|
9080
|
+
/**
|
|
9081
|
+
* Get a copy of known colors
|
|
9082
|
+
* @returns
|
|
9083
|
+
*/
|
|
9084
|
+
DarkColorHandlerImpl.prototype.getKnownColorsCopy = function () {
|
|
9085
|
+
return Object.values(this.knownColors);
|
|
9086
|
+
};
|
|
8815
9087
|
/**
|
|
8816
9088
|
* Given a light mode color value and an optional dark mode color value, register this color
|
|
8817
9089
|
* so that editor can handle it, then return the CSS color value for current color mode.
|
|
@@ -8853,11 +9125,13 @@ var DarkColorHandlerImpl = /** @class */ (function () {
|
|
|
8853
9125
|
* Parse an existing color value, if it is in variable-based color format, extract color key,
|
|
8854
9126
|
* light color and query related dark color if any
|
|
8855
9127
|
* @param color The color string to parse
|
|
9128
|
+
* @param isInDarkMode Whether current content is in dark mode. When set to true, if the color value is not in dark var format,
|
|
9129
|
+
* we will treat is as a dark mode color and try to find a matched dark mode color.
|
|
8856
9130
|
*/
|
|
8857
|
-
DarkColorHandlerImpl.prototype.parseColorValue = function (color) {
|
|
9131
|
+
DarkColorHandlerImpl.prototype.parseColorValue = function (color, isInDarkMode) {
|
|
8858
9132
|
var _a;
|
|
8859
9133
|
var key;
|
|
8860
|
-
var lightModeColor =
|
|
9134
|
+
var lightModeColor = '';
|
|
8861
9135
|
var darkModeColor;
|
|
8862
9136
|
if (color) {
|
|
8863
9137
|
var match = color.startsWith(VARIABLE_PREFIX) ? VARIABLE_REGEX.exec(color) : null;
|
|
@@ -8871,9 +9145,42 @@ var DarkColorHandlerImpl = /** @class */ (function () {
|
|
|
8871
9145
|
lightModeColor = '';
|
|
8872
9146
|
}
|
|
8873
9147
|
}
|
|
9148
|
+
else if (isInDarkMode) {
|
|
9149
|
+
// If editor is in dark mode but the color is not in dark color format, it is possible the color was inserted from external code
|
|
9150
|
+
// without any light color info. So we first try to see if there is a known dark color can match this color, and use its related
|
|
9151
|
+
// light color as light mode color. Otherwise we need to drop this color to avoid show "white on white" content.
|
|
9152
|
+
lightModeColor = this.findLightColorFromDarkColor(color) || '';
|
|
9153
|
+
if (lightModeColor) {
|
|
9154
|
+
darkModeColor = color;
|
|
9155
|
+
}
|
|
9156
|
+
}
|
|
9157
|
+
else {
|
|
9158
|
+
lightModeColor = color;
|
|
9159
|
+
}
|
|
8874
9160
|
}
|
|
8875
9161
|
return { key: key, lightModeColor: lightModeColor, darkModeColor: darkModeColor };
|
|
8876
9162
|
};
|
|
9163
|
+
/**
|
|
9164
|
+
* Find related light mode color from dark mode color.
|
|
9165
|
+
* @param darkColor The existing dark color
|
|
9166
|
+
*/
|
|
9167
|
+
DarkColorHandlerImpl.prototype.findLightColorFromDarkColor = function (darkColor) {
|
|
9168
|
+
var _this = this;
|
|
9169
|
+
var rgbSearch = (0, roosterjs_editor_dom_1.parseColor)(darkColor);
|
|
9170
|
+
if (rgbSearch) {
|
|
9171
|
+
var key = (0, roosterjs_editor_dom_1.getObjectKeys)(this.knownColors).find(function (key) {
|
|
9172
|
+
var rgbCurrent = (0, roosterjs_editor_dom_1.parseColor)(_this.knownColors[key].darkModeColor);
|
|
9173
|
+
return (rgbCurrent &&
|
|
9174
|
+
rgbCurrent[0] == rgbSearch[0] &&
|
|
9175
|
+
rgbCurrent[1] == rgbSearch[1] &&
|
|
9176
|
+
rgbCurrent[2] == rgbSearch[2]);
|
|
9177
|
+
});
|
|
9178
|
+
if (key) {
|
|
9179
|
+
return this.knownColors[key].lightModeColor;
|
|
9180
|
+
}
|
|
9181
|
+
}
|
|
9182
|
+
return null;
|
|
9183
|
+
};
|
|
8877
9184
|
return DarkColorHandlerImpl;
|
|
8878
9185
|
}());
|
|
8879
9186
|
exports.default = DarkColorHandlerImpl;
|
|
@@ -9650,13 +9957,14 @@ var Editor = /** @class */ (function () {
|
|
|
9650
9957
|
* @param nextDarkMode The next status of dark mode. True if the editor should be in dark mode, false if not.
|
|
9651
9958
|
*/
|
|
9652
9959
|
Editor.prototype.setDarkModeState = function (nextDarkMode) {
|
|
9653
|
-
|
|
9960
|
+
var isDarkMode = this.isDarkMode();
|
|
9961
|
+
if (isDarkMode == !!nextDarkMode) {
|
|
9654
9962
|
return;
|
|
9655
9963
|
}
|
|
9656
9964
|
var core = this.getCore();
|
|
9657
9965
|
core.api.transformColor(core, core.contentDiv, false /*includeSelf*/, null /*callback*/, nextDarkMode
|
|
9658
9966
|
? 0 /* LightToDark */
|
|
9659
|
-
: 1 /* DarkToLight */, true /*forceTransform
|
|
9967
|
+
: 1 /* DarkToLight */, true /*forceTransform*/, isDarkMode);
|
|
9660
9968
|
this.triggerContentChangedEvent(nextDarkMode ? "SwitchToDarkMode" /* SwitchToDarkMode */ : "SwitchToLightMode" /* SwitchToLightMode */);
|
|
9661
9969
|
};
|
|
9662
9970
|
/**
|
|
@@ -11130,6 +11438,110 @@ var SelectionScoper = /** @class */ (function () {
|
|
|
11130
11438
|
exports.default = SelectionScoper;
|
|
11131
11439
|
|
|
11132
11440
|
|
|
11441
|
+
/***/ }),
|
|
11442
|
+
|
|
11443
|
+
/***/ "./packages/roosterjs-editor-dom/lib/delimiter/addDelimiters.ts":
|
|
11444
|
+
/*!**********************************************************************!*\
|
|
11445
|
+
!*** ./packages/roosterjs-editor-dom/lib/delimiter/addDelimiters.ts ***!
|
|
11446
|
+
\**********************************************************************/
|
|
11447
|
+
/*! no static exports found */
|
|
11448
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
11449
|
+
|
|
11450
|
+
"use strict";
|
|
11451
|
+
|
|
11452
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11453
|
+
exports.addDelimiterBefore = exports.addDelimiterAfter = void 0;
|
|
11454
|
+
var createElement_1 = __webpack_require__(/*! ../utils/createElement */ "./packages/roosterjs-editor-dom/lib/utils/createElement.ts");
|
|
11455
|
+
var getDelimiterFromElement_1 = __webpack_require__(/*! ./getDelimiterFromElement */ "./packages/roosterjs-editor-dom/lib/delimiter/getDelimiterFromElement.ts");
|
|
11456
|
+
var ZERO_WIDTH_SPACE = '\u200B';
|
|
11457
|
+
/**
|
|
11458
|
+
* Adds delimiters to the element provided. If the delimiters already exists, will not be added
|
|
11459
|
+
* @param node the node to add the delimiters
|
|
11460
|
+
*/
|
|
11461
|
+
function addDelimiters(node) {
|
|
11462
|
+
var _a = getDelimiters(node), delimiterAfter = _a[0], delimiterBefore = _a[1];
|
|
11463
|
+
if (!delimiterAfter) {
|
|
11464
|
+
delimiterAfter = addDelimiterAfter(node);
|
|
11465
|
+
}
|
|
11466
|
+
if (!delimiterBefore) {
|
|
11467
|
+
delimiterBefore = addDelimiterBefore(node);
|
|
11468
|
+
}
|
|
11469
|
+
return [delimiterAfter, delimiterBefore];
|
|
11470
|
+
}
|
|
11471
|
+
exports.default = addDelimiters;
|
|
11472
|
+
/**
|
|
11473
|
+
* Adds delimiter after the element provided.
|
|
11474
|
+
* @param element element to use
|
|
11475
|
+
*/
|
|
11476
|
+
function addDelimiterAfter(element) {
|
|
11477
|
+
return insertDelimiter(element, "entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
11478
|
+
}
|
|
11479
|
+
exports.addDelimiterAfter = addDelimiterAfter;
|
|
11480
|
+
/**
|
|
11481
|
+
* Adds delimiter before the element provided.
|
|
11482
|
+
* @param element element to use
|
|
11483
|
+
*/
|
|
11484
|
+
function addDelimiterBefore(element) {
|
|
11485
|
+
return insertDelimiter(element, "entityDelimiterBefore" /* DELIMITER_BEFORE */);
|
|
11486
|
+
}
|
|
11487
|
+
exports.addDelimiterBefore = addDelimiterBefore;
|
|
11488
|
+
function getDelimiters(entityWrapper) {
|
|
11489
|
+
var result = [];
|
|
11490
|
+
var nextElementSibling = entityWrapper.nextElementSibling, previousElementSibling = entityWrapper.previousElementSibling;
|
|
11491
|
+
result.push(isDelimiter(nextElementSibling, "entityDelimiterAfter" /* DELIMITER_AFTER */), isDelimiter(previousElementSibling, "entityDelimiterBefore" /* DELIMITER_BEFORE */));
|
|
11492
|
+
return result;
|
|
11493
|
+
}
|
|
11494
|
+
function isDelimiter(el, className) {
|
|
11495
|
+
return el && (0, getDelimiterFromElement_1.default)(el) && el.classList.contains(className) ? el : undefined;
|
|
11496
|
+
}
|
|
11497
|
+
function insertDelimiter(element, delimiterClass) {
|
|
11498
|
+
var span = (0, createElement_1.default)({
|
|
11499
|
+
tag: 'span',
|
|
11500
|
+
className: delimiterClass,
|
|
11501
|
+
children: [ZERO_WIDTH_SPACE],
|
|
11502
|
+
}, element.ownerDocument);
|
|
11503
|
+
if (span) {
|
|
11504
|
+
var insertPosition = delimiterClass == "entityDelimiterAfter" /* DELIMITER_AFTER */ ? 'afterend' : 'beforebegin';
|
|
11505
|
+
element.insertAdjacentElement(insertPosition, span);
|
|
11506
|
+
}
|
|
11507
|
+
return element;
|
|
11508
|
+
}
|
|
11509
|
+
|
|
11510
|
+
|
|
11511
|
+
/***/ }),
|
|
11512
|
+
|
|
11513
|
+
/***/ "./packages/roosterjs-editor-dom/lib/delimiter/getDelimiterFromElement.ts":
|
|
11514
|
+
/*!********************************************************************************!*\
|
|
11515
|
+
!*** ./packages/roosterjs-editor-dom/lib/delimiter/getDelimiterFromElement.ts ***!
|
|
11516
|
+
\********************************************************************************/
|
|
11517
|
+
/*! no static exports found */
|
|
11518
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
11519
|
+
|
|
11520
|
+
"use strict";
|
|
11521
|
+
|
|
11522
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11523
|
+
var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
|
|
11524
|
+
var ZERO_WIDTH_SPACE = '\u200B';
|
|
11525
|
+
/**
|
|
11526
|
+
* Retrieves Delimiter information from a provided element.
|
|
11527
|
+
* @param element element to try to retrieve a delimiter
|
|
11528
|
+
* @returns delimiter info if it is a Delimiter, else null
|
|
11529
|
+
*/
|
|
11530
|
+
function getDelimiterFromElement(element) {
|
|
11531
|
+
if (!element) {
|
|
11532
|
+
return null;
|
|
11533
|
+
}
|
|
11534
|
+
if ((0, safeInstanceOf_1.default)(element, 'HTMLSpanElement') &&
|
|
11535
|
+
(element.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */) ||
|
|
11536
|
+
element.classList.contains("entityDelimiterBefore" /* DELIMITER_BEFORE */)) &&
|
|
11537
|
+
element.textContent === ZERO_WIDTH_SPACE) {
|
|
11538
|
+
return element;
|
|
11539
|
+
}
|
|
11540
|
+
return null;
|
|
11541
|
+
}
|
|
11542
|
+
exports.default = getDelimiterFromElement;
|
|
11543
|
+
|
|
11544
|
+
|
|
11133
11545
|
/***/ }),
|
|
11134
11546
|
|
|
11135
11547
|
/***/ "./packages/roosterjs-editor-dom/lib/edit/adjustInsertPosition.ts":
|
|
@@ -12512,7 +12924,6 @@ var DEFAULT_STYLE_VALUES = {
|
|
|
12512
12924
|
'outline-style': 'none',
|
|
12513
12925
|
'outline-width': '0px',
|
|
12514
12926
|
overflow: 'visible',
|
|
12515
|
-
'text-decoration': 'none',
|
|
12516
12927
|
'-webkit-text-stroke-width': '0px',
|
|
12517
12928
|
'word-wrap': 'break-word',
|
|
12518
12929
|
'margin-left': '0px',
|
|
@@ -12741,9 +13152,9 @@ exports.isCssVariable = isCssVariable;
|
|
|
12741
13152
|
"use strict";
|
|
12742
13153
|
|
|
12743
13154
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12744
|
-
exports.
|
|
12745
|
-
exports.
|
|
12746
|
-
exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = exports.createNumberDefinition = exports.validate = exports.getTextContent = exports.deleteSelectedContent = exports.adjustInsertPosition = exports.removeGlobalCssStyle = exports.setGlobalCssStyles = exports.removeImportantStyleRule = exports.setStyles = void 0;
|
|
13155
|
+
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.getDelimiterFromElement = exports.addDelimiterBefore = exports.addDelimiterAfter = exports.addDelimiters = exports.PositionContentSearcher = exports.ContentTraverser = exports.getFirstLastBlockElement = exports.getBlockElementAtNode = void 0;
|
|
13156
|
+
exports.cacheGetEventData = exports.restoreContentWithEntityPlaceholder = exports.moveContentWithEntityPlaceholders = exports.createEntityPlaceholder = 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 = exports.parseColor = exports.isNodeAfter = exports.getIntersectedRect = exports.moveChildNodes = exports.KnownCreateElementData = exports.createElement = void 0;
|
|
13157
|
+
exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = exports.createNumberDefinition = exports.validate = exports.getTextContent = exports.deleteSelectedContent = exports.adjustInsertPosition = exports.removeGlobalCssStyle = exports.setGlobalCssStyles = exports.removeImportantStyleRule = exports.setStyles = exports.getStyles = exports.isCtrlOrMetaPressed = exports.isCharacterValue = exports.isModifierKey = exports.clearEventDataCache = void 0;
|
|
12747
13158
|
var getBlockElementAtNode_1 = __webpack_require__(/*! ./blockElements/getBlockElementAtNode */ "./packages/roosterjs-editor-dom/lib/blockElements/getBlockElementAtNode.ts");
|
|
12748
13159
|
Object.defineProperty(exports, "getBlockElementAtNode", { enumerable: true, get: function () { return getBlockElementAtNode_1.default; } });
|
|
12749
13160
|
var getFirstLastBlockElement_1 = __webpack_require__(/*! ./blockElements/getFirstLastBlockElement */ "./packages/roosterjs-editor-dom/lib/blockElements/getFirstLastBlockElement.ts");
|
|
@@ -12752,6 +13163,12 @@ var ContentTraverser_1 = __webpack_require__(/*! ./contentTraverser/ContentTrave
|
|
|
12752
13163
|
Object.defineProperty(exports, "ContentTraverser", { enumerable: true, get: function () { return ContentTraverser_1.default; } });
|
|
12753
13164
|
var PositionContentSearcher_1 = __webpack_require__(/*! ./contentTraverser/PositionContentSearcher */ "./packages/roosterjs-editor-dom/lib/contentTraverser/PositionContentSearcher.ts");
|
|
12754
13165
|
Object.defineProperty(exports, "PositionContentSearcher", { enumerable: true, get: function () { return PositionContentSearcher_1.default; } });
|
|
13166
|
+
var addDelimiters_1 = __webpack_require__(/*! ./delimiter/addDelimiters */ "./packages/roosterjs-editor-dom/lib/delimiter/addDelimiters.ts");
|
|
13167
|
+
Object.defineProperty(exports, "addDelimiters", { enumerable: true, get: function () { return addDelimiters_1.default; } });
|
|
13168
|
+
Object.defineProperty(exports, "addDelimiterAfter", { enumerable: true, get: function () { return addDelimiters_1.addDelimiterAfter; } });
|
|
13169
|
+
Object.defineProperty(exports, "addDelimiterBefore", { enumerable: true, get: function () { return addDelimiters_1.addDelimiterBefore; } });
|
|
13170
|
+
var getDelimiterFromElement_1 = __webpack_require__(/*! ./delimiter/getDelimiterFromElement */ "./packages/roosterjs-editor-dom/lib/delimiter/getDelimiterFromElement.ts");
|
|
13171
|
+
Object.defineProperty(exports, "getDelimiterFromElement", { enumerable: true, get: function () { return getDelimiterFromElement_1.default; } });
|
|
12755
13172
|
var getInlineElementAtNode_1 = __webpack_require__(/*! ./inlineElements/getInlineElementAtNode */ "./packages/roosterjs-editor-dom/lib/inlineElements/getInlineElementAtNode.ts");
|
|
12756
13173
|
Object.defineProperty(exports, "getInlineElementAtNode", { enumerable: true, get: function () { return getInlineElementAtNode_1.default; } });
|
|
12757
13174
|
var ImageInlineElement_1 = __webpack_require__(/*! ./inlineElements/ImageInlineElement */ "./packages/roosterjs-editor-dom/lib/inlineElements/ImageInlineElement.ts");
|
|
@@ -12839,6 +13256,8 @@ var getIntersectedRect_1 = __webpack_require__(/*! ./utils/getIntersectedRect */
|
|
|
12839
13256
|
Object.defineProperty(exports, "getIntersectedRect", { enumerable: true, get: function () { return getIntersectedRect_1.default; } });
|
|
12840
13257
|
var isNodeAfter_1 = __webpack_require__(/*! ./utils/isNodeAfter */ "./packages/roosterjs-editor-dom/lib/utils/isNodeAfter.ts");
|
|
12841
13258
|
Object.defineProperty(exports, "isNodeAfter", { enumerable: true, get: function () { return isNodeAfter_1.default; } });
|
|
13259
|
+
var parseColor_1 = __webpack_require__(/*! ./utils/parseColor */ "./packages/roosterjs-editor-dom/lib/utils/parseColor.ts");
|
|
13260
|
+
Object.defineProperty(exports, "parseColor", { enumerable: true, get: function () { return parseColor_1.default; } });
|
|
12842
13261
|
var VTable_1 = __webpack_require__(/*! ./table/VTable */ "./packages/roosterjs-editor-dom/lib/table/VTable.ts");
|
|
12843
13262
|
Object.defineProperty(exports, "VTable", { enumerable: true, get: function () { return VTable_1.default; } });
|
|
12844
13263
|
var isWholeTableSelected_1 = __webpack_require__(/*! ./table/isWholeTableSelected */ "./packages/roosterjs-editor-dom/lib/table/isWholeTableSelected.ts");
|
|
@@ -19417,6 +19836,51 @@ function normalizeRect(clientRect) {
|
|
|
19417
19836
|
exports.default = normalizeRect;
|
|
19418
19837
|
|
|
19419
19838
|
|
|
19839
|
+
/***/ }),
|
|
19840
|
+
|
|
19841
|
+
/***/ "./packages/roosterjs-editor-dom/lib/utils/parseColor.ts":
|
|
19842
|
+
/*!***************************************************************!*\
|
|
19843
|
+
!*** ./packages/roosterjs-editor-dom/lib/utils/parseColor.ts ***!
|
|
19844
|
+
\***************************************************************/
|
|
19845
|
+
/*! no static exports found */
|
|
19846
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
19847
|
+
|
|
19848
|
+
"use strict";
|
|
19849
|
+
|
|
19850
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19851
|
+
var HEX3_REGEX = /^#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])$/;
|
|
19852
|
+
var HEX6_REGEX = /^#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/;
|
|
19853
|
+
var RGB_REGEX = /^rgb\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*\)$/;
|
|
19854
|
+
var RGBA_REGEX = /^rgba\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*\)$/;
|
|
19855
|
+
/**
|
|
19856
|
+
* Parse color string to r/g/b value.
|
|
19857
|
+
* If the given color is not in a recognized format, return null
|
|
19858
|
+
*/
|
|
19859
|
+
function parseColor(color) {
|
|
19860
|
+
color = (color || '').trim();
|
|
19861
|
+
var match;
|
|
19862
|
+
if ((match = color.match(HEX3_REGEX))) {
|
|
19863
|
+
return [
|
|
19864
|
+
parseInt(match[1] + match[1], 16),
|
|
19865
|
+
parseInt(match[2] + match[2], 16),
|
|
19866
|
+
parseInt(match[3] + match[3], 16),
|
|
19867
|
+
];
|
|
19868
|
+
}
|
|
19869
|
+
else if ((match = color.match(HEX6_REGEX))) {
|
|
19870
|
+
return [parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16)];
|
|
19871
|
+
}
|
|
19872
|
+
else if ((match = color.match(RGB_REGEX) || color.match(RGBA_REGEX))) {
|
|
19873
|
+
return [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])];
|
|
19874
|
+
}
|
|
19875
|
+
else {
|
|
19876
|
+
// CSS color names such as red, green is not included for now.
|
|
19877
|
+
// If need, we can add those colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
|
|
19878
|
+
return null;
|
|
19879
|
+
}
|
|
19880
|
+
}
|
|
19881
|
+
exports.default = parseColor;
|
|
19882
|
+
|
|
19883
|
+
|
|
19420
19884
|
/***/ }),
|
|
19421
19885
|
|
|
19422
19886
|
/***/ "./packages/roosterjs-editor-dom/lib/utils/queryElements.ts":
|
|
@@ -19586,6 +20050,7 @@ exports.default = safeInstanceOf;
|
|
|
19586
20050
|
"use strict";
|
|
19587
20051
|
|
|
19588
20052
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20053
|
+
var parseColor_1 = __webpack_require__(/*! ./parseColor */ "./packages/roosterjs-editor-dom/lib/utils/parseColor.ts");
|
|
19589
20054
|
var WHITE = '#ffffff';
|
|
19590
20055
|
var GRAY = '#333333';
|
|
19591
20056
|
var BLACK = '#000000';
|
|
@@ -19680,40 +20145,19 @@ function isADarkOrBrightColor(color) {
|
|
|
19680
20145
|
* @returns
|
|
19681
20146
|
*/
|
|
19682
20147
|
function calculateLightness(color) {
|
|
19683
|
-
var
|
|
19684
|
-
var r;
|
|
19685
|
-
var g;
|
|
19686
|
-
var b;
|
|
19687
|
-
if (color.substring(0, 1) == '#') {
|
|
19688
|
-
_a = getColorsFromHEX(color), r = _a[0], g = _a[1], b = _a[2];
|
|
19689
|
-
}
|
|
19690
|
-
else {
|
|
19691
|
-
_b = getColorsFromRGB(color), r = _b[0], g = _b[1], b = _b[2];
|
|
19692
|
-
}
|
|
20148
|
+
var colorValues = (0, parseColor_1.default)(color);
|
|
19693
20149
|
// Use the values of r,g,b to calculate the lightness in the HSl representation
|
|
19694
20150
|
//First calculate the fraction of the light in each color, since in css the value of r,g,b is in the interval of [0,255], we have
|
|
19695
|
-
|
|
19696
|
-
|
|
19697
|
-
|
|
19698
|
-
|
|
19699
|
-
|
|
19700
|
-
|
|
19701
|
-
|
|
19702
|
-
|
|
19703
|
-
|
|
20151
|
+
if (colorValues) {
|
|
20152
|
+
var red = colorValues[0] / 255;
|
|
20153
|
+
var green = colorValues[1] / 255;
|
|
20154
|
+
var blue = colorValues[2] / 255;
|
|
20155
|
+
//Then the lightness in the HSL representation is the average between maximum fraction of r,g,b and the minimum fraction
|
|
20156
|
+
return (Math.max(red, green, blue) + Math.min(red, green, blue)) * 50;
|
|
20157
|
+
}
|
|
20158
|
+
else {
|
|
20159
|
+
return 255;
|
|
19704
20160
|
}
|
|
19705
|
-
var colors = color.replace('#', '');
|
|
19706
|
-
var r = parseInt(colors.substr(0, 2), 16);
|
|
19707
|
-
var g = parseInt(colors.substr(2, 2), 16);
|
|
19708
|
-
var b = parseInt(colors.substr(4, 2), 16);
|
|
19709
|
-
return [r, g, b];
|
|
19710
|
-
}
|
|
19711
|
-
function getColorsFromRGB(color) {
|
|
19712
|
-
var colors = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
|
|
19713
|
-
var r = parseInt(colors[1]);
|
|
19714
|
-
var g = parseInt(colors[2]);
|
|
19715
|
-
var b = parseInt(colors[3]);
|
|
19716
|
-
return [r, g, b];
|
|
19717
20161
|
}
|
|
19718
20162
|
|
|
19719
20163
|
|
|
@@ -20403,6 +20847,9 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
20403
20847
|
this.onSubmit = onSubmit;
|
|
20404
20848
|
this.handler = handler;
|
|
20405
20849
|
this.zoomScale = zoomScale;
|
|
20850
|
+
this.initX = 0;
|
|
20851
|
+
this.initY = 0;
|
|
20852
|
+
this.initValue = undefined;
|
|
20406
20853
|
this.onMouseDown = function (e) {
|
|
20407
20854
|
var _a;
|
|
20408
20855
|
var _b, _c;
|
|
@@ -20418,7 +20865,8 @@ var DragAndDropHelper = /** @class */ (function () {
|
|
|
20418
20865
|
var _d = _this.dndMouse.getPageXY(e), pageX = _d[0], pageY = _d[1];
|
|
20419
20866
|
var deltaX = (pageX - _this.initX) / _this.zoomScale;
|
|
20420
20867
|
var deltaY = (pageY - _this.initY) / _this.zoomScale;
|
|
20421
|
-
if (
|
|
20868
|
+
if (_this.initValue &&
|
|
20869
|
+
((_b = (_a = _this.handler).onDragging) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, e, _this.initValue, deltaX, deltaY))) {
|
|
20422
20870
|
(_c = _this.onSubmit) === null || _c === void 0 ? void 0 : _c.call(_this, _this.context, _this.trigger);
|
|
20423
20871
|
}
|
|
20424
20872
|
};
|
|
@@ -20520,7 +20968,7 @@ var AutoFormat = /** @class */ (function () {
|
|
|
20520
20968
|
event.eventType === 6 /* MouseUp */) {
|
|
20521
20969
|
this.lastKeyTyped = '';
|
|
20522
20970
|
}
|
|
20523
|
-
if (event.eventType ===
|
|
20971
|
+
if (event.eventType === 1 /* KeyPress */) {
|
|
20524
20972
|
var keyTyped = event.rawEvent.key;
|
|
20525
20973
|
if (keyTyped && keyTyped.length > 1) {
|
|
20526
20974
|
this.lastKeyTyped = '';
|
|
@@ -20861,11 +21309,14 @@ function cacheGetReadonlyEntityElement(event, editor, operation) {
|
|
|
20861
21309
|
return entityElement && !entityElement.isContentEditable ? entityElement : null;
|
|
20862
21310
|
});
|
|
20863
21311
|
if (element && operation !== undefined) {
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20867
|
-
|
|
20868
|
-
|
|
21312
|
+
var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)(element);
|
|
21313
|
+
if (entity) {
|
|
21314
|
+
editor.triggerPluginEvent(15 /* EntityOperation */, {
|
|
21315
|
+
operation: operation,
|
|
21316
|
+
rawEvent: event.rawEvent,
|
|
21317
|
+
entity: entity,
|
|
21318
|
+
});
|
|
21319
|
+
}
|
|
20869
21320
|
}
|
|
20870
21321
|
return element;
|
|
20871
21322
|
}
|
|
@@ -20881,20 +21332,23 @@ var EnterBeforeReadonlyEntityFeature = {
|
|
|
20881
21332
|
return cacheGetNeighborEntityElement(event, editor, true /*isNext*/, false /*collapseOnly*/);
|
|
20882
21333
|
},
|
|
20883
21334
|
handleEvent: function (event, editor) {
|
|
20884
|
-
var _a;
|
|
21335
|
+
var _a, _b, _c;
|
|
20885
21336
|
event.rawEvent.preventDefault();
|
|
20886
21337
|
var range = editor.getSelectionRange();
|
|
21338
|
+
if (!range) {
|
|
21339
|
+
return;
|
|
21340
|
+
}
|
|
20887
21341
|
var node = roosterjs_editor_dom_1.Position.getEnd(range).normalize().node;
|
|
20888
21342
|
var br = editor.getDocument().createElement('BR');
|
|
20889
|
-
node.parentNode.insertBefore(br, node.nextSibling);
|
|
21343
|
+
(_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(br, node.nextSibling);
|
|
20890
21344
|
var block = editor.getBlockElementAtNode(node);
|
|
20891
21345
|
var newContainer;
|
|
20892
21346
|
if (block) {
|
|
20893
21347
|
newContainer = block.collapseToSingleElement();
|
|
20894
|
-
(
|
|
21348
|
+
(_b = br.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(br);
|
|
20895
21349
|
}
|
|
20896
|
-
editor.getSelectionRange().deleteContents();
|
|
20897
|
-
if (newContainer.nextSibling) {
|
|
21350
|
+
(_c = editor.getSelectionRange()) === null || _c === void 0 ? void 0 : _c.deleteContents();
|
|
21351
|
+
if (newContainer === null || newContainer === void 0 ? void 0 : newContainer.nextSibling) {
|
|
20898
21352
|
editor.select(newContainer.nextSibling, 0 /* Begin */);
|
|
20899
21353
|
}
|
|
20900
21354
|
},
|
|
@@ -20947,7 +21401,7 @@ function cacheGetNeighborEntityElement(event, editor, isNext, collapseOnly, oper
|
|
|
20947
21401
|
var node = sibling && sibling.getContainerNode();
|
|
20948
21402
|
if (!collapseOnly) {
|
|
20949
21403
|
var block = editor.getBlockElementAtNode(pos.node);
|
|
20950
|
-
if (!block || !block.contains(node)) {
|
|
21404
|
+
if (!block || (node && !block.contains(node))) {
|
|
20951
21405
|
node = null;
|
|
20952
21406
|
}
|
|
20953
21407
|
}
|
|
@@ -20956,14 +21410,205 @@ function cacheGetNeighborEntityElement(event, editor, isNext, collapseOnly, oper
|
|
|
20956
21410
|
return entityNode;
|
|
20957
21411
|
});
|
|
20958
21412
|
if (element && operation !== undefined) {
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
20962
|
-
|
|
20963
|
-
});
|
|
21413
|
+
var entity = (0, roosterjs_editor_dom_1.getEntityFromElement)(element);
|
|
21414
|
+
if (entity) {
|
|
21415
|
+
triggerOperation(entity, editor, operation, event);
|
|
21416
|
+
}
|
|
20964
21417
|
}
|
|
20965
21418
|
return element;
|
|
20966
21419
|
}
|
|
21420
|
+
/**
|
|
21421
|
+
* @requires ExperimentalFeatures.InlineEntityReadOnlyDelimiters to be enabled
|
|
21422
|
+
* Content edit feature to move the cursor from Delimiters around Entities when using Right or Left Arrow Keys
|
|
21423
|
+
*/
|
|
21424
|
+
var MoveBetweenDelimitersFeature = {
|
|
21425
|
+
keys: [39 /* RIGHT */, 37 /* LEFT */],
|
|
21426
|
+
shouldHandleEvent: function (event, editor) {
|
|
21427
|
+
if (!editor.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */)) {
|
|
21428
|
+
return false;
|
|
21429
|
+
}
|
|
21430
|
+
var element = editor.getElementAtCursor();
|
|
21431
|
+
if (!element) {
|
|
21432
|
+
return false;
|
|
21433
|
+
}
|
|
21434
|
+
var isRTL = (0, roosterjs_editor_dom_1.getComputedStyle)(element, 'direction') === 'rtl';
|
|
21435
|
+
var shouldCheckBefore = isRTL == (event.rawEvent.which === 37 /* LEFT */);
|
|
21436
|
+
return getIsDelimiterAtCursor(event, editor, shouldCheckBefore);
|
|
21437
|
+
},
|
|
21438
|
+
handleEvent: function (event, editor) {
|
|
21439
|
+
var checkBefore = cacheGetCheckBefore(event);
|
|
21440
|
+
var delimiter = cacheDelimiter(event, checkBefore);
|
|
21441
|
+
if (!delimiter) {
|
|
21442
|
+
return;
|
|
21443
|
+
}
|
|
21444
|
+
var _a = getRelatedElements(delimiter, checkBefore), delimiterPair = _a.delimiterPair, entity = _a.entity;
|
|
21445
|
+
if (delimiterPair && entity && (0, roosterjs_editor_dom_1.matchesSelector)(entity, (0, roosterjs_editor_dom_1.getEntitySelector)())) {
|
|
21446
|
+
event.rawEvent.preventDefault();
|
|
21447
|
+
editor.runAsync(function () {
|
|
21448
|
+
var positionType = checkBefore
|
|
21449
|
+
? event.rawEvent.shiftKey
|
|
21450
|
+
? -3 /* After */
|
|
21451
|
+
: -1 /* End */
|
|
21452
|
+
: -2 /* Before */;
|
|
21453
|
+
var position = new roosterjs_editor_dom_1.Position(delimiterPair, positionType);
|
|
21454
|
+
if (event.rawEvent.shiftKey) {
|
|
21455
|
+
var selection = delimiterPair.ownerDocument.getSelection();
|
|
21456
|
+
selection === null || selection === void 0 ? void 0 : selection.extend(position.node, position.offset);
|
|
21457
|
+
}
|
|
21458
|
+
else {
|
|
21459
|
+
editor.select(position);
|
|
21460
|
+
}
|
|
21461
|
+
});
|
|
21462
|
+
}
|
|
21463
|
+
},
|
|
21464
|
+
};
|
|
21465
|
+
/**
|
|
21466
|
+
* @requires ExperimentalFeatures.InlineEntityReadOnlyDelimiters to be enabled
|
|
21467
|
+
* Content edit Feature to trigger a Delete Entity Operation when one of the Delimiter is about to be removed with DELETE or Backspace
|
|
21468
|
+
*/
|
|
21469
|
+
var RemoveEntityBetweenDelimitersFeature = {
|
|
21470
|
+
keys: [8 /* BACKSPACE */, 46 /* DELETE */],
|
|
21471
|
+
shouldHandleEvent: function (event, editor) {
|
|
21472
|
+
if (!editor.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */)) {
|
|
21473
|
+
return false;
|
|
21474
|
+
}
|
|
21475
|
+
var range = editor.getSelectionRange();
|
|
21476
|
+
if (!(range === null || range === void 0 ? void 0 : range.collapsed)) {
|
|
21477
|
+
return false;
|
|
21478
|
+
}
|
|
21479
|
+
var checkBefore = event.rawEvent.which === 46 /* DELETE */;
|
|
21480
|
+
var isDelimiter = getIsDelimiterAtCursor(event, editor, checkBefore);
|
|
21481
|
+
if (isDelimiter) {
|
|
21482
|
+
var delimiter = cacheDelimiter(event, checkBefore);
|
|
21483
|
+
var entityElement = checkBefore
|
|
21484
|
+
? delimiter === null || delimiter === void 0 ? void 0 : delimiter.nextElementSibling
|
|
21485
|
+
: delimiter === null || delimiter === void 0 ? void 0 : delimiter.previousElementSibling;
|
|
21486
|
+
return !!cacheEntityBetweenDelimiter(event, editor, checkBefore, entityElement);
|
|
21487
|
+
}
|
|
21488
|
+
return false;
|
|
21489
|
+
},
|
|
21490
|
+
handleEvent: function (event, editor) {
|
|
21491
|
+
var checkBefore = event.rawEvent.which === 46 /* DELETE */;
|
|
21492
|
+
cacheEntityBetweenDelimiter(event, editor, checkBefore, null, checkBefore ? 4 /* RemoveFromStart */ : 5 /* RemoveFromEnd */);
|
|
21493
|
+
},
|
|
21494
|
+
};
|
|
21495
|
+
function getIsDelimiterAtCursor(event, editor, checkBefore) {
|
|
21496
|
+
var _a;
|
|
21497
|
+
var position = (_a = editor.getFocusedPosition()) === null || _a === void 0 ? void 0 : _a.normalize();
|
|
21498
|
+
cacheGetCheckBefore(event, checkBefore);
|
|
21499
|
+
if (!position) {
|
|
21500
|
+
return false;
|
|
21501
|
+
}
|
|
21502
|
+
var focusedElement = position.node.nodeType == 3 /* Text */
|
|
21503
|
+
? position.node
|
|
21504
|
+
: position.node == position.element
|
|
21505
|
+
? position.element.childNodes.item(position.offset)
|
|
21506
|
+
: position.element;
|
|
21507
|
+
var searcher = editor.getContentSearcherOfCursor(event);
|
|
21508
|
+
var data = checkBefore
|
|
21509
|
+
? {
|
|
21510
|
+
class: "entityDelimiterBefore" /* DELIMITER_BEFORE */,
|
|
21511
|
+
pairClass: "entityDelimiterAfter" /* DELIMITER_AFTER */,
|
|
21512
|
+
getDelimiterPair: function (element) { var _a; return (_a = element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.nextElementSibling; },
|
|
21513
|
+
getNextSibling: function () {
|
|
21514
|
+
var _a;
|
|
21515
|
+
return (_a = searcher === null || searcher === void 0 ? void 0 : searcher.getInlineElementAfter()) === null || _a === void 0 ? void 0 : _a.getContainerNode();
|
|
21516
|
+
},
|
|
21517
|
+
isAtEndOrBeginning: position.isAtEnd,
|
|
21518
|
+
}
|
|
21519
|
+
: {
|
|
21520
|
+
class: "entityDelimiterAfter" /* DELIMITER_AFTER */,
|
|
21521
|
+
pairClass: "entityDelimiterBefore" /* DELIMITER_BEFORE */,
|
|
21522
|
+
getDelimiterPair: function (element) { var _a; return (_a = element.previousElementSibling) === null || _a === void 0 ? void 0 : _a.previousElementSibling; },
|
|
21523
|
+
getNextSibling: function () {
|
|
21524
|
+
var _a;
|
|
21525
|
+
return (_a = searcher === null || searcher === void 0 ? void 0 : searcher.getInlineElementBefore()) === null || _a === void 0 ? void 0 : _a.getContainerNode();
|
|
21526
|
+
},
|
|
21527
|
+
isAtEndOrBeginning: position.offset == 0,
|
|
21528
|
+
};
|
|
21529
|
+
var sibling = data.getNextSibling();
|
|
21530
|
+
if (data.isAtEndOrBeginning && sibling) {
|
|
21531
|
+
var elAtCursor = editor.getElementAtCursor('.' + data.class, sibling);
|
|
21532
|
+
if (elAtCursor && !!shouldHandle(elAtCursor)) {
|
|
21533
|
+
return true;
|
|
21534
|
+
}
|
|
21535
|
+
}
|
|
21536
|
+
var entityAtCursor = editor.getElementAtCursor('.' + data.class, focusedElement);
|
|
21537
|
+
return !!shouldHandle(entityAtCursor);
|
|
21538
|
+
function shouldHandle(element) {
|
|
21539
|
+
var _a;
|
|
21540
|
+
return (element &&
|
|
21541
|
+
(((_a = data.getDelimiterPair(element)) === null || _a === void 0 ? void 0 : _a.className) || '').indexOf(data.pairClass) > -1 &&
|
|
21542
|
+
cacheDelimiter(event, checkBefore, element));
|
|
21543
|
+
}
|
|
21544
|
+
}
|
|
21545
|
+
function cacheDelimiter(event, checkBefore, delimiter) {
|
|
21546
|
+
return (0, roosterjs_editor_dom_1.cacheGetEventData)(event, 'delimiter_cache_key_' + checkBefore, function () { return delimiter; });
|
|
21547
|
+
}
|
|
21548
|
+
function cacheEntityBetweenDelimiter(event, editor, checkBefore, entity, operation) {
|
|
21549
|
+
var element = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, 'entity_delimiter_cache_key_' + checkBefore, function () { return entity && editor.getElementAtCursor((0, roosterjs_editor_dom_1.getEntitySelector)(), entity); });
|
|
21550
|
+
if (element && operation !== undefined) {
|
|
21551
|
+
var entity_1 = (0, roosterjs_editor_dom_1.getEntityFromElement)(element);
|
|
21552
|
+
if (entity_1) {
|
|
21553
|
+
triggerOperation(entity_1, editor, operation, event);
|
|
21554
|
+
}
|
|
21555
|
+
}
|
|
21556
|
+
return element;
|
|
21557
|
+
}
|
|
21558
|
+
function triggerOperation(entity, editor, operation, event) {
|
|
21559
|
+
var _a = entity.wrapper, nextElementSibling = _a.nextElementSibling, previousElementSibling = _a.previousElementSibling;
|
|
21560
|
+
editor.triggerPluginEvent(15 /* EntityOperation */, {
|
|
21561
|
+
operation: operation,
|
|
21562
|
+
rawEvent: event.rawEvent,
|
|
21563
|
+
entity: entity,
|
|
21564
|
+
});
|
|
21565
|
+
if (entity.isReadonly &&
|
|
21566
|
+
!(0, roosterjs_editor_dom_1.isBlockElement)(entity.wrapper) &&
|
|
21567
|
+
editor.isFeatureEnabled("InlineEntityReadOnlyDelimiters" /* InlineEntityReadOnlyDelimiters */)) {
|
|
21568
|
+
if (event.rawEvent.defaultPrevented) {
|
|
21569
|
+
editor.runAsync(function () {
|
|
21570
|
+
if (!editor.contains(entity.wrapper)) {
|
|
21571
|
+
removeDelimiters(nextElementSibling, previousElementSibling);
|
|
21572
|
+
}
|
|
21573
|
+
else {
|
|
21574
|
+
var delimiterAfter = (0, roosterjs_editor_dom_1.addDelimiters)(entity.wrapper)[0];
|
|
21575
|
+
if (delimiterAfter) {
|
|
21576
|
+
editor.select(delimiterAfter, -3 /* After */);
|
|
21577
|
+
}
|
|
21578
|
+
}
|
|
21579
|
+
});
|
|
21580
|
+
}
|
|
21581
|
+
else if ((0, roosterjs_editor_dom_1.getDelimiterFromElement)(nextElementSibling) &&
|
|
21582
|
+
(0, roosterjs_editor_dom_1.getDelimiterFromElement)(previousElementSibling)) {
|
|
21583
|
+
editor.select((0, roosterjs_editor_dom_1.createRange)(previousElementSibling, nextElementSibling));
|
|
21584
|
+
}
|
|
21585
|
+
}
|
|
21586
|
+
}
|
|
21587
|
+
function removeDelimiters(nextElementSibling, previousElementSibling) {
|
|
21588
|
+
[nextElementSibling, previousElementSibling].forEach(function (sibling) {
|
|
21589
|
+
var _a;
|
|
21590
|
+
if ((0, roosterjs_editor_dom_1.getDelimiterFromElement)(sibling)) {
|
|
21591
|
+
(_a = sibling === null || sibling === void 0 ? void 0 : sibling.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(sibling);
|
|
21592
|
+
}
|
|
21593
|
+
});
|
|
21594
|
+
}
|
|
21595
|
+
function cacheGetCheckBefore(event, checkBefore) {
|
|
21596
|
+
return !!(0, roosterjs_editor_dom_1.cacheGetEventData)(event, 'Check_Before', function () { return checkBefore; });
|
|
21597
|
+
}
|
|
21598
|
+
function getRelatedElements(delimiter, checkBefore) {
|
|
21599
|
+
var _a, _b;
|
|
21600
|
+
var entity;
|
|
21601
|
+
var delimiterPair;
|
|
21602
|
+
if (checkBefore) {
|
|
21603
|
+
entity = delimiter.nextElementSibling;
|
|
21604
|
+
delimiterPair = (_a = entity === null || entity === void 0 ? void 0 : entity.nextElementSibling) !== null && _a !== void 0 ? _a : null;
|
|
21605
|
+
}
|
|
21606
|
+
else {
|
|
21607
|
+
entity = delimiter.previousElementSibling;
|
|
21608
|
+
delimiterPair = (_b = entity === null || entity === void 0 ? void 0 : entity.previousElementSibling) !== null && _b !== void 0 ? _b : null;
|
|
21609
|
+
}
|
|
21610
|
+
return { entity: entity, delimiterPair: delimiterPair };
|
|
21611
|
+
}
|
|
20967
21612
|
/**
|
|
20968
21613
|
* @internal
|
|
20969
21614
|
*/
|
|
@@ -20973,6 +21618,8 @@ exports.EntityFeatures = {
|
|
|
20973
21618
|
enterBeforeReadonlyEntity: EnterBeforeReadonlyEntityFeature,
|
|
20974
21619
|
backspaceAfterEntity: BackspaceAfterEntityFeature,
|
|
20975
21620
|
deleteBeforeEntity: DeleteBeforeEntityFeature,
|
|
21621
|
+
moveBetweenDelimitersFeature: MoveBetweenDelimitersFeature,
|
|
21622
|
+
removeEntityBetweenDelimiters: RemoveEntityBetweenDelimitersFeature,
|
|
20976
21623
|
};
|
|
20977
21624
|
|
|
20978
21625
|
|
|
@@ -21050,9 +21697,11 @@ var MergeInNewLine = {
|
|
|
21050
21697
|
if (li.previousSibling) {
|
|
21051
21698
|
(0, roosterjs_editor_api_1.blockFormat)(editor, function (region, start, end) {
|
|
21052
21699
|
var vList = (0, roosterjs_editor_dom_1.createVListFromRegion)(region, false /*includeSiblingList*/, li);
|
|
21053
|
-
vList
|
|
21054
|
-
|
|
21055
|
-
|
|
21700
|
+
if (vList) {
|
|
21701
|
+
vList.setIndentation(start, end, 1 /* Decrease */, true /*softOutdent*/);
|
|
21702
|
+
vList.writeBack(editor.isFeatureEnabled("ReuseAllAncestorListElements" /* ReuseAllAncestorListElements */));
|
|
21703
|
+
event.rawEvent.preventDefault();
|
|
21704
|
+
}
|
|
21056
21705
|
});
|
|
21057
21706
|
}
|
|
21058
21707
|
else {
|
|
@@ -21860,7 +22509,8 @@ var TabInTable = {
|
|
|
21860
22509
|
}
|
|
21861
22510
|
var cell = vtable.getCell(row, col);
|
|
21862
22511
|
if (cell.td) {
|
|
21863
|
-
|
|
22512
|
+
var newPos = new roosterjs_editor_dom_1.Position(cell.td, 0 /* Begin */).normalize();
|
|
22513
|
+
editor.select(newPos);
|
|
21864
22514
|
break;
|
|
21865
22515
|
}
|
|
21866
22516
|
}
|
|
@@ -21937,7 +22587,7 @@ var UpDownInTable = {
|
|
|
21937
22587
|
selection_1 === null || selection_1 === void 0 ? void 0 : selection_1.setBaseAndExtent(anchorNode_1, anchorOffset_1, newPos.node, newPos.offset);
|
|
21938
22588
|
}
|
|
21939
22589
|
else {
|
|
21940
|
-
editor.select(newPos);
|
|
22590
|
+
editor.select(newPos.normalize());
|
|
21941
22591
|
}
|
|
21942
22592
|
}
|
|
21943
22593
|
});
|
|
@@ -21945,6 +22595,23 @@ var UpDownInTable = {
|
|
|
21945
22595
|
},
|
|
21946
22596
|
defaultDisabled: !roosterjs_editor_dom_1.Browser.isChrome && !roosterjs_editor_dom_1.Browser.isSafari,
|
|
21947
22597
|
};
|
|
22598
|
+
/**
|
|
22599
|
+
* Requires @see ExperimentalFeatures.DeleteTableWithBackspace
|
|
22600
|
+
* Delete a table selected with the table selector pressing Backspace key
|
|
22601
|
+
*/
|
|
22602
|
+
var DeleteTableWithBackspace = {
|
|
22603
|
+
keys: [8 /* BACKSPACE */],
|
|
22604
|
+
shouldHandleEvent: function (event, editor) {
|
|
22605
|
+
return editor.isFeatureEnabled("DeleteTableWithBackspace" /* DeleteTableWithBackspace */) &&
|
|
22606
|
+
cacheIsWholeTableSelected(event, editor);
|
|
22607
|
+
},
|
|
22608
|
+
handleEvent: function (event, editor) {
|
|
22609
|
+
var td = cacheGetTableCell(event, editor);
|
|
22610
|
+
var vtable = new roosterjs_editor_dom_1.VTable(td);
|
|
22611
|
+
vtable.edit(4 /* DeleteTable */);
|
|
22612
|
+
vtable.writeBack();
|
|
22613
|
+
},
|
|
22614
|
+
};
|
|
21948
22615
|
function cacheGetTableCell(event, editor) {
|
|
21949
22616
|
return (0, roosterjs_editor_dom_1.cacheGetEventData)(event, 'TABLE_CELL_FOR_TABLE_FEATURES', function () {
|
|
21950
22617
|
var pos = editor.getFocusedPosition();
|
|
@@ -21973,6 +22640,7 @@ exports.TableFeatures = {
|
|
|
21973
22640
|
tabInTable: TabInTable,
|
|
21974
22641
|
upDownInTable: UpDownInTable,
|
|
21975
22642
|
indentTableOnTab: IndentTableOnTab,
|
|
22643
|
+
deleteTableWithBackspace: DeleteTableWithBackspace,
|
|
21976
22644
|
};
|
|
21977
22645
|
|
|
21978
22646
|
|
|
@@ -23088,7 +23756,7 @@ var DefaultOptions = {
|
|
|
23088
23756
|
preserveRatio: false,
|
|
23089
23757
|
minRotateDeg: 5,
|
|
23090
23758
|
imageSelector: 'img',
|
|
23091
|
-
rotateIconHTML:
|
|
23759
|
+
rotateIconHTML: '',
|
|
23092
23760
|
disableCrop: false,
|
|
23093
23761
|
disableRotate: false,
|
|
23094
23762
|
disableSideResize: false,
|
|
@@ -23127,6 +23795,34 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23127
23795
|
function ImageEdit(options, onShowResizeHandle) {
|
|
23128
23796
|
var _this = this;
|
|
23129
23797
|
this.onShowResizeHandle = onShowResizeHandle;
|
|
23798
|
+
this.editor = null;
|
|
23799
|
+
this.disposer = null;
|
|
23800
|
+
// Current editing image
|
|
23801
|
+
this.image = null;
|
|
23802
|
+
// Image cloned from the current editing image
|
|
23803
|
+
this.clonedImage = null;
|
|
23804
|
+
// The image wrapper
|
|
23805
|
+
this.wrapper = null;
|
|
23806
|
+
// Current edit info of the image. All changes user made will be stored in this object.
|
|
23807
|
+
// We use this object to update the editing UI, and finally we will use this object to generate
|
|
23808
|
+
// the new image if necessary
|
|
23809
|
+
this.editInfo = null;
|
|
23810
|
+
// Src of the image before current editing
|
|
23811
|
+
this.lastSrc = null;
|
|
23812
|
+
// Drag and drop helper objects
|
|
23813
|
+
this.dndHelpers = [];
|
|
23814
|
+
/**
|
|
23815
|
+
* Identify if the image was resized by the user.
|
|
23816
|
+
*/
|
|
23817
|
+
this.wasResized = false;
|
|
23818
|
+
/**
|
|
23819
|
+
* The span element that wraps the image and opens shadow dom
|
|
23820
|
+
*/
|
|
23821
|
+
this.shadowSpan = null;
|
|
23822
|
+
/**
|
|
23823
|
+
* The span element that wraps the image and opens shadow dom
|
|
23824
|
+
*/
|
|
23825
|
+
this.isCropping = false;
|
|
23130
23826
|
/**
|
|
23131
23827
|
* quit editing mode when editor lose focus
|
|
23132
23828
|
*/
|
|
@@ -23137,7 +23833,11 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23137
23833
|
* Remove the temp wrapper of the image
|
|
23138
23834
|
*/
|
|
23139
23835
|
this.removeWrapper = function () {
|
|
23140
|
-
if (_this.editor
|
|
23836
|
+
if (_this.editor &&
|
|
23837
|
+
_this.image &&
|
|
23838
|
+
_this.image.parentNode &&
|
|
23839
|
+
_this.editor.contains(_this.image) &&
|
|
23840
|
+
_this.wrapper) {
|
|
23141
23841
|
(0, roosterjs_editor_dom_1.unwrap)(_this.image.parentNode);
|
|
23142
23842
|
}
|
|
23143
23843
|
_this.wrapper = null;
|
|
@@ -23148,8 +23848,14 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23148
23848
|
* @param context
|
|
23149
23849
|
*/
|
|
23150
23850
|
this.updateWrapper = function (context) {
|
|
23851
|
+
var _a, _b;
|
|
23151
23852
|
var wrapper = _this.wrapper;
|
|
23152
|
-
if (wrapper
|
|
23853
|
+
if (wrapper &&
|
|
23854
|
+
_this.editInfo &&
|
|
23855
|
+
_this.image &&
|
|
23856
|
+
_this.clonedImage &&
|
|
23857
|
+
_this.options &&
|
|
23858
|
+
((_a = _this.shadowSpan) === null || _a === void 0 ? void 0 : _a.parentElement)) {
|
|
23153
23859
|
// Prepare: get related editing elements
|
|
23154
23860
|
var cropContainers = getEditElements(wrapper, "r_cropC" /* CropContainer */);
|
|
23155
23861
|
var cropOverlays = getEditElements(wrapper, "r_cropO" /* CropOverlay */);
|
|
@@ -23159,9 +23865,9 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23159
23865
|
var cropHandles = getEditElements(wrapper, "r_cropH" /* CropHandle */);
|
|
23160
23866
|
// Cropping and resizing will show different UI, so check if it is cropping here first
|
|
23161
23867
|
_this.isCropping = cropContainers.length == 1 && cropOverlays.length == 4;
|
|
23162
|
-
var
|
|
23868
|
+
var _c = _this.editInfo, angleRad = _c.angleRad, bottomPercent = _c.bottomPercent, leftPercent = _c.leftPercent, rightPercent = _c.rightPercent, topPercent = _c.topPercent;
|
|
23163
23869
|
// Width/height of the image
|
|
23164
|
-
var
|
|
23870
|
+
var _d = (0, getGeneratedImageSize_1.default)(_this.editInfo, _this.isCropping), targetWidth = _d.targetWidth, targetHeight = _d.targetHeight, originalWidth = _d.originalWidth, originalHeight = _d.originalHeight, visibleWidth = _d.visibleWidth, visibleHeight = _d.visibleHeight;
|
|
23165
23871
|
var marginHorizontal = (targetWidth - visibleWidth) / 2;
|
|
23166
23872
|
var marginVertical = (targetHeight - visibleHeight) / 2;
|
|
23167
23873
|
var cropLeftPx = originalWidth * leftPercent;
|
|
@@ -23195,12 +23901,12 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23195
23901
|
var clientWidth = wrapper.clientWidth;
|
|
23196
23902
|
var clientHeight = wrapper.clientHeight;
|
|
23197
23903
|
_this.wasResized = true;
|
|
23198
|
-
(0, Resizer_1.doubleCheckResize)(_this.editInfo, _this.options.preserveRatio, clientWidth, clientHeight);
|
|
23904
|
+
(0, Resizer_1.doubleCheckResize)(_this.editInfo, _this.options.preserveRatio || false, clientWidth, clientHeight);
|
|
23199
23905
|
_this.updateWrapper();
|
|
23200
23906
|
}
|
|
23201
|
-
var viewport = _this.editor.getVisibleViewport();
|
|
23907
|
+
var viewport = (_b = _this.editor) === null || _b === void 0 ? void 0 : _b.getVisibleViewport();
|
|
23202
23908
|
if (rotateHandle && rotateCenter && viewport) {
|
|
23203
|
-
(0, Rotator_1.updateRotateHandlePosition)(_this.editInfo,
|
|
23909
|
+
(0, Rotator_1.updateRotateHandlePosition)(_this.editInfo, viewport, marginVertical, rotateCenter, rotateHandle);
|
|
23204
23910
|
}
|
|
23205
23911
|
updateHandleCursor(resizeHandles, angleRad);
|
|
23206
23912
|
}
|
|
@@ -23239,8 +23945,9 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23239
23945
|
* Dispose this plugin
|
|
23240
23946
|
*/
|
|
23241
23947
|
ImageEdit.prototype.dispose = function () {
|
|
23948
|
+
var _a;
|
|
23242
23949
|
this.clearDndHelpers();
|
|
23243
|
-
this.disposer();
|
|
23950
|
+
(_a = this.disposer) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
23244
23951
|
this.disposer = null;
|
|
23245
23952
|
this.editor = null;
|
|
23246
23953
|
};
|
|
@@ -23249,10 +23956,13 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23249
23956
|
* @param e PluginEvent object
|
|
23250
23957
|
*/
|
|
23251
23958
|
ImageEdit.prototype.onPluginEvent = function (e) {
|
|
23959
|
+
var _a;
|
|
23252
23960
|
switch (e.eventType) {
|
|
23253
23961
|
case 22 /* SelectionChanged */:
|
|
23254
23962
|
if (e.selectionRangeEx &&
|
|
23255
|
-
e.selectionRangeEx.type === 2 /* ImageSelection */
|
|
23963
|
+
e.selectionRangeEx.type === 2 /* ImageSelection */ &&
|
|
23964
|
+
this.options &&
|
|
23965
|
+
this.options.onSelectState !== undefined) {
|
|
23256
23966
|
this.setEditingImage(e.selectionRangeEx.image, this.options.onSelectState);
|
|
23257
23967
|
}
|
|
23258
23968
|
break;
|
|
@@ -23275,9 +23985,11 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23275
23985
|
break;
|
|
23276
23986
|
case 8 /* ExtractContentWithDom */:
|
|
23277
23987
|
// When extract content, remove all image info since they may not be valid when load the content again
|
|
23278
|
-
|
|
23279
|
-
(0,
|
|
23280
|
-
|
|
23988
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.imageSelector) {
|
|
23989
|
+
(0, roosterjs_editor_dom_1.toArray)(e.clonedRoot.querySelectorAll(this.options.imageSelector)).forEach(function (img) {
|
|
23990
|
+
(0, editInfo_1.deleteEditInfo)(img);
|
|
23991
|
+
});
|
|
23992
|
+
}
|
|
23281
23993
|
break;
|
|
23282
23994
|
case 12 /* BeforeDispose */:
|
|
23283
23995
|
this.removeWrapper();
|
|
@@ -23296,7 +24008,12 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23296
24008
|
var _this = this;
|
|
23297
24009
|
var operation = typeof operationOrSelect === 'number' ? operationOrSelect : 0 /* None */;
|
|
23298
24010
|
var selectImage = typeof operationOrSelect === 'number' ? false : !!operationOrSelect;
|
|
23299
|
-
if (!image &&
|
|
24011
|
+
if (!image &&
|
|
24012
|
+
this.image &&
|
|
24013
|
+
this.editor &&
|
|
24014
|
+
this.editInfo &&
|
|
24015
|
+
this.lastSrc &&
|
|
24016
|
+
this.clonedImage) {
|
|
23300
24017
|
// When there is image in editing, clean up any cached objects and elements
|
|
23301
24018
|
this.clearDndHelpers();
|
|
23302
24019
|
// Apply the changes, and add undo snapshot if necessary
|
|
@@ -23313,7 +24030,7 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23313
24030
|
this.clonedImage = null;
|
|
23314
24031
|
this.isCropping = false;
|
|
23315
24032
|
}
|
|
23316
|
-
if (!this.image && (image === null || image === void 0 ? void 0 : image.isContentEditable)) {
|
|
24033
|
+
if (!this.image && (image === null || image === void 0 ? void 0 : image.isContentEditable) && this.editor) {
|
|
23317
24034
|
// If there is new image to edit, enter editing mode for this image
|
|
23318
24035
|
this.editor.addUndoSnapshot();
|
|
23319
24036
|
this.image = image;
|
|
@@ -23337,47 +24054,55 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23337
24054
|
*/
|
|
23338
24055
|
ImageEdit.prototype.createWrapper = function (operation) {
|
|
23339
24056
|
var _this = this;
|
|
23340
|
-
|
|
23341
|
-
this.
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
:
|
|
23358
|
-
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
23367
|
-
|
|
23368
|
-
|
|
23369
|
-
|
|
23370
|
-
}
|
|
23371
|
-
|
|
23372
|
-
|
|
24057
|
+
var _a, _b;
|
|
24058
|
+
if (this.image && this.editor && this.options && this.editInfo) {
|
|
24059
|
+
//Clone the image and insert the clone in a entity
|
|
24060
|
+
this.clonedImage = this.image.cloneNode(true);
|
|
24061
|
+
this.clonedImage.removeAttribute('id');
|
|
24062
|
+
this.wrapper = (0, roosterjs_editor_dom_1.createElement)(6 /* ImageEditWrapper */, this.image.ownerDocument);
|
|
24063
|
+
(_b = (_a = this.wrapper) === null || _a === void 0 ? void 0 : _a.firstChild) === null || _b === void 0 ? void 0 : _b.appendChild(this.clonedImage);
|
|
24064
|
+
this.wrapper.style.display = roosterjs_editor_dom_1.Browser.isSafari ? 'inline-block' : 'inline-flex';
|
|
24065
|
+
// Cache current src so that we can compare it after edit see if src is changed
|
|
24066
|
+
this.lastSrc = this.image.getAttribute('src');
|
|
24067
|
+
// Set image src to original src to help show editing UI, also it will be used when regenerate image dataURL after editing
|
|
24068
|
+
if (this.clonedImage) {
|
|
24069
|
+
this.clonedImage.src = this.editInfo.src;
|
|
24070
|
+
this.clonedImage.style.position = 'absolute';
|
|
24071
|
+
}
|
|
24072
|
+
// Get HTML for all edit elements (resize handle, rotate handle, crop handle and overlay, ...) and create HTML element
|
|
24073
|
+
var options_1 = {
|
|
24074
|
+
borderColor: getColorString(this.options.borderColor, this.editor.isDarkMode()),
|
|
24075
|
+
rotateIconHTML: this.options.rotateIconHTML,
|
|
24076
|
+
rotateHandleBackColor: this.editor.isDarkMode()
|
|
24077
|
+
? DARK_MODE_BGCOLOR
|
|
24078
|
+
: LIGHT_MODE_BGCOLOR,
|
|
24079
|
+
isSmallImage: isASmallImage(this.editInfo),
|
|
24080
|
+
};
|
|
24081
|
+
var htmlData_1 = [(0, Resizer_1.getResizeBordersHTML)(options_1)];
|
|
24082
|
+
(0, roosterjs_editor_dom_1.getObjectKeys)(ImageEditHTMLMap).forEach(function (thisOperation) {
|
|
24083
|
+
var element = ImageEditHTMLMap[thisOperation](options_1, _this.onShowResizeHandle);
|
|
24084
|
+
if ((operation & thisOperation) == thisOperation && element) {
|
|
24085
|
+
(0, roosterjs_editor_dom_1.arrayPush)(htmlData_1, element);
|
|
24086
|
+
}
|
|
24087
|
+
});
|
|
24088
|
+
htmlData_1.forEach(function (data) {
|
|
24089
|
+
var element = (0, roosterjs_editor_dom_1.createElement)(data, _this.image.ownerDocument);
|
|
24090
|
+
if (element && _this.wrapper) {
|
|
24091
|
+
_this.wrapper.appendChild(element);
|
|
24092
|
+
}
|
|
24093
|
+
});
|
|
24094
|
+
this.insertImageWrapper(this.wrapper);
|
|
24095
|
+
}
|
|
23373
24096
|
};
|
|
23374
24097
|
ImageEdit.prototype.insertImageWrapper = function (wrapper) {
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
|
|
24098
|
+
if (this.image) {
|
|
24099
|
+
this.shadowSpan = (0, roosterjs_editor_dom_1.wrap)(this.image, 'span');
|
|
24100
|
+
var shadowRoot = this.shadowSpan.attachShadow({
|
|
24101
|
+
mode: 'open',
|
|
24102
|
+
});
|
|
24103
|
+
this.shadowSpan.style.verticalAlign = 'bottom';
|
|
24104
|
+
shadowRoot.appendChild(wrapper);
|
|
24105
|
+
}
|
|
23381
24106
|
};
|
|
23382
24107
|
/**
|
|
23383
24108
|
* Create drag and drop helpers
|
|
@@ -23387,15 +24112,16 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23387
24112
|
*/
|
|
23388
24113
|
ImageEdit.prototype.createDndHelpers = function (elementClass, dragAndDrop) {
|
|
23389
24114
|
var _this = this;
|
|
23390
|
-
var commonContext = {
|
|
23391
|
-
editInfo: this.editInfo,
|
|
23392
|
-
options: this.options,
|
|
23393
|
-
elementClass: elementClass,
|
|
23394
|
-
};
|
|
23395
24115
|
var wrapper = this.wrapper;
|
|
23396
|
-
return wrapper
|
|
24116
|
+
return wrapper && this.editInfo
|
|
23397
24117
|
? getEditElements(wrapper, elementClass).map(function (element) {
|
|
23398
|
-
return new DragAndDropHelper_1.default(element,
|
|
24118
|
+
return new DragAndDropHelper_1.default(element, {
|
|
24119
|
+
editInfo: _this.editInfo,
|
|
24120
|
+
options: _this.options,
|
|
24121
|
+
elementClass: elementClass,
|
|
24122
|
+
x: element.dataset.x,
|
|
24123
|
+
y: element.dataset.y,
|
|
24124
|
+
}, _this.updateWrapper, dragAndDrop, _this.editor ? _this.editor.getZoomScale() : 1);
|
|
23399
24125
|
})
|
|
23400
24126
|
: [];
|
|
23401
24127
|
};
|
|
@@ -23405,18 +24131,18 @@ var ImageEdit = /** @class */ (function () {
|
|
|
23405
24131
|
ImageEdit.prototype.clearDndHelpers = function () {
|
|
23406
24132
|
var _a;
|
|
23407
24133
|
(_a = this.dndHelpers) === null || _a === void 0 ? void 0 : _a.forEach(function (helper) { return helper.dispose(); });
|
|
23408
|
-
this.dndHelpers =
|
|
24134
|
+
this.dndHelpers = [];
|
|
23409
24135
|
};
|
|
23410
24136
|
return ImageEdit;
|
|
23411
24137
|
}());
|
|
23412
24138
|
exports.default = ImageEdit;
|
|
23413
24139
|
function setSize(element, left, top, right, bottom, width, height) {
|
|
23414
|
-
element.style.left = getPx(left);
|
|
23415
|
-
element.style.top = getPx(top);
|
|
23416
|
-
element.style.right = getPx(right);
|
|
23417
|
-
element.style.bottom = getPx(bottom);
|
|
23418
|
-
element.style.width = getPx(width);
|
|
23419
|
-
element.style.height = getPx(height);
|
|
24140
|
+
element.style.left = left !== undefined ? getPx(left) : element.style.left;
|
|
24141
|
+
element.style.top = top !== undefined ? getPx(top) : element.style.top;
|
|
24142
|
+
element.style.right = right !== undefined ? getPx(right) : element.style.right;
|
|
24143
|
+
element.style.bottom = bottom !== undefined ? getPx(bottom) : element.style.bottom;
|
|
24144
|
+
element.style.width = width !== undefined ? getPx(width) : element.style.width;
|
|
24145
|
+
element.style.height = height !== undefined ? getPx(height) : element.style.height;
|
|
23420
24146
|
}
|
|
23421
24147
|
function setWrapperSizeDimensions(wrapper, image, width, height) {
|
|
23422
24148
|
var hasBorder = image.style.borderStyle;
|
|
@@ -23430,7 +24156,7 @@ function setWrapperSizeDimensions(wrapper, image, width, height) {
|
|
|
23430
24156
|
wrapper.style.height = getPx(height);
|
|
23431
24157
|
}
|
|
23432
24158
|
function getPx(value) {
|
|
23433
|
-
return value
|
|
24159
|
+
return value + 'px';
|
|
23434
24160
|
}
|
|
23435
24161
|
function getEditElements(wrapper, elementClass) {
|
|
23436
24162
|
return (0, roosterjs_editor_dom_1.toArray)(wrapper.querySelectorAll('.' + elementClass));
|
|
@@ -23444,12 +24170,12 @@ function handleRadIndexCalculator(angleRad) {
|
|
|
23444
24170
|
var idx = Math.round(angleRad / DirectionRad) % DIRECTIONS;
|
|
23445
24171
|
return idx < 0 ? idx + DIRECTIONS : idx;
|
|
23446
24172
|
}
|
|
23447
|
-
function rotateHandles(
|
|
24173
|
+
function rotateHandles(y, x, angleRad) {
|
|
23448
24174
|
var radIndex = handleRadIndexCalculator(angleRad);
|
|
23449
|
-
var originalDirection =
|
|
24175
|
+
var originalDirection = y + x;
|
|
23450
24176
|
var originalIndex = DirectionOrder.indexOf(originalDirection);
|
|
23451
24177
|
var rotatedIndex = originalIndex >= 0 && originalIndex + radIndex;
|
|
23452
|
-
return DirectionOrder[rotatedIndex % DIRECTIONS];
|
|
24178
|
+
return rotatedIndex ? DirectionOrder[rotatedIndex % DIRECTIONS] : '';
|
|
23453
24179
|
}
|
|
23454
24180
|
/**
|
|
23455
24181
|
* Rotate the resizer and cropper handles according to the image position.
|
|
@@ -23458,7 +24184,11 @@ function rotateHandles(element, angleRad) {
|
|
|
23458
24184
|
*/
|
|
23459
24185
|
function updateHandleCursor(handles, angleRad) {
|
|
23460
24186
|
handles.map(function (handle) {
|
|
23461
|
-
|
|
24187
|
+
var y = handle.dataset.y;
|
|
24188
|
+
var x = handle.dataset.x;
|
|
24189
|
+
if (y && x) {
|
|
24190
|
+
handle.style.cursor = rotateHandles(y, x, angleRad) + "-resize";
|
|
24191
|
+
}
|
|
23462
24192
|
});
|
|
23463
24193
|
}
|
|
23464
24194
|
/**
|
|
@@ -23486,7 +24216,7 @@ function isFixedNumberValue(value) {
|
|
|
23486
24216
|
}
|
|
23487
24217
|
function isASmallImage(editInfo) {
|
|
23488
24218
|
var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx;
|
|
23489
|
-
return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE;
|
|
24219
|
+
return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE ? true : false;
|
|
23490
24220
|
}
|
|
23491
24221
|
function getColorString(color, isDarkMode) {
|
|
23492
24222
|
if (typeof color === 'string') {
|
|
@@ -23523,9 +24253,12 @@ function canRegenerateImage(img) {
|
|
|
23523
24253
|
canvas.width = 10;
|
|
23524
24254
|
canvas.height = 10;
|
|
23525
24255
|
var context = canvas.getContext('2d');
|
|
23526
|
-
context
|
|
23527
|
-
|
|
23528
|
-
|
|
24256
|
+
if (context) {
|
|
24257
|
+
context.drawImage(img, 0, 0);
|
|
24258
|
+
context.getImageData(0, 0, 1, 1);
|
|
24259
|
+
return true;
|
|
24260
|
+
}
|
|
24261
|
+
return false;
|
|
23529
24262
|
}
|
|
23530
24263
|
catch (_a) {
|
|
23531
24264
|
return false;
|
|
@@ -23555,9 +24288,12 @@ var editInfo_1 = __webpack_require__(/*! ../editInfoUtils/editInfo */ "./package
|
|
|
23555
24288
|
*/
|
|
23556
24289
|
function isResizedTo(image, percentage) {
|
|
23557
24290
|
var editInfo = (0, editInfo_1.getEditInfoFromImage)(image);
|
|
23558
|
-
|
|
23559
|
-
|
|
23560
|
-
Math.round(
|
|
24291
|
+
if (editInfo) {
|
|
24292
|
+
var _a = (0, getTargetSizeByPercentage_1.default)(editInfo, percentage), width = _a.width, height = _a.height;
|
|
24293
|
+
return (Math.round(width) == Math.round(editInfo.widthPx) &&
|
|
24294
|
+
Math.round(height) == Math.round(editInfo.heightPx));
|
|
24295
|
+
}
|
|
24296
|
+
return false;
|
|
23561
24297
|
}
|
|
23562
24298
|
exports.default = isResizedTo;
|
|
23563
24299
|
|
|
@@ -23622,13 +24358,13 @@ function resizeByPercentage(editor, image, percentage, minWidth, minHeight) {
|
|
|
23622
24358
|
var editInfo = (0, editInfo_1.getEditInfoFromImage)(image);
|
|
23623
24359
|
if (!(0, isResizedTo_1.default)(image, percentage)) {
|
|
23624
24360
|
loadImage(image, image.src, function () {
|
|
23625
|
-
if (!editor.isDisposed() && editor.contains(image)) {
|
|
24361
|
+
if (!editor.isDisposed() && editor.contains(image) && editInfo) {
|
|
23626
24362
|
var lastSrc_1 = image.getAttribute('src');
|
|
23627
24363
|
var _a = (0, getTargetSizeByPercentage_1.default)(editInfo, percentage), width = _a.width, height = _a.height;
|
|
23628
24364
|
editInfo.widthPx = Math.max(width, minWidth);
|
|
23629
24365
|
editInfo.heightPx = Math.max(height, minHeight);
|
|
23630
24366
|
editor.addUndoSnapshot(function () {
|
|
23631
|
-
(0, applyChange_1.default)(editor, image, editInfo, lastSrc_1, true /*wasResized*/);
|
|
24367
|
+
(0, applyChange_1.default)(editor, image, editInfo, lastSrc_1 || '', true /*wasResized*/);
|
|
23632
24368
|
}, "ImageResize" /* ImageResize */);
|
|
23633
24369
|
}
|
|
23634
24370
|
});
|
|
@@ -23844,7 +24580,9 @@ exports.deleteEditInfo = deleteEditInfo;
|
|
|
23844
24580
|
*/
|
|
23845
24581
|
function getEditInfoFromImage(image) {
|
|
23846
24582
|
var obj = (0, roosterjs_editor_dom_1.getMetadata)(image);
|
|
23847
|
-
return (0, checkEditInfoState_1.default)(obj) == 0 /* Invalid */
|
|
24583
|
+
return !obj || (0, checkEditInfoState_1.default)(obj) == 0 /* Invalid */
|
|
24584
|
+
? getInitialEditInfo(image)
|
|
24585
|
+
: obj;
|
|
23848
24586
|
}
|
|
23849
24587
|
exports.getEditInfoFromImage = getEditInfoFromImage;
|
|
23850
24588
|
function getInitialEditInfo(image) {
|
|
@@ -23896,9 +24634,11 @@ function generateDataURL(image, editInfo) {
|
|
|
23896
24634
|
canvas.width = targetWidth;
|
|
23897
24635
|
canvas.height = targetHeight;
|
|
23898
24636
|
var context = canvas.getContext('2d');
|
|
23899
|
-
context
|
|
23900
|
-
|
|
23901
|
-
|
|
24637
|
+
if (context) {
|
|
24638
|
+
context.translate(targetWidth / 2, targetHeight / 2);
|
|
24639
|
+
context.rotate(angle);
|
|
24640
|
+
context.drawImage(image, naturalWidth * left, naturalHeight * top, imageWidth, imageHeight, -width / 2, -height / 2, width, height);
|
|
24641
|
+
}
|
|
23902
24642
|
return canvas.toDataURL('image/png', 1.0);
|
|
23903
24643
|
}
|
|
23904
24644
|
exports.default = generateDataURL;
|
|
@@ -24031,7 +24771,10 @@ exports.Cropper = {
|
|
|
24031
24771
|
var minWidth = options.minWidth, minHeight = options.minHeight;
|
|
24032
24772
|
var widthPercent = 1 - leftPercent - rightPercent;
|
|
24033
24773
|
var heightPercent = 1 - topPercent - bottomPercent;
|
|
24034
|
-
if (widthPercent > 0 &&
|
|
24774
|
+
if (widthPercent > 0 &&
|
|
24775
|
+
heightPercent > 0 &&
|
|
24776
|
+
minWidth !== undefined &&
|
|
24777
|
+
minHeight !== undefined) {
|
|
24035
24778
|
var fullWidth = widthPx / widthPercent;
|
|
24036
24779
|
var fullHeight = heightPx / heightPercent;
|
|
24037
24780
|
var newLeft = x != 'e'
|
|
@@ -24081,7 +24824,9 @@ function getCropHTML() {
|
|
|
24081
24824
|
className: "r_cropC" /* CropContainer */,
|
|
24082
24825
|
children: [],
|
|
24083
24826
|
};
|
|
24084
|
-
|
|
24827
|
+
if (containerHTML) {
|
|
24828
|
+
Xs.forEach(function (x) { return Ys.forEach(function (y) { var _a; return (_a = containerHTML.children) === null || _a === void 0 ? void 0 : _a.push(getCropHTMLInternal(x, y)); }); });
|
|
24829
|
+
}
|
|
24085
24830
|
return [containerHTML, overlayHTML, overlayHTML, overlayHTML, overlayHTML];
|
|
24086
24831
|
}
|
|
24087
24832
|
exports.getCropHTML = getCropHTML;
|
|
@@ -24160,36 +24905,41 @@ exports.Resizer = {
|
|
|
24160
24905
|
var x = _a.x, y = _a.y, editInfo = _a.editInfo, options = _a.options;
|
|
24161
24906
|
var ratio = base.widthPx > 0 && base.heightPx > 0 ? (base.widthPx * 1.0) / base.heightPx : 0;
|
|
24162
24907
|
_b = rotateCoordinate(deltaX, deltaY, editInfo.angleRad), deltaX = _b[0], deltaY = _b[1];
|
|
24163
|
-
|
|
24164
|
-
|
|
24165
|
-
|
|
24166
|
-
|
|
24167
|
-
|
|
24168
|
-
|
|
24169
|
-
|
|
24170
|
-
|
|
24171
|
-
|
|
24172
|
-
|
|
24173
|
-
if (ratio >
|
|
24174
|
-
|
|
24175
|
-
|
|
24176
|
-
if (newWidth < options.minWidth) {
|
|
24177
|
-
newWidth = options.minWidth;
|
|
24178
|
-
newHeight = newWidth / ratio;
|
|
24179
|
-
}
|
|
24180
|
-
}
|
|
24181
|
-
else {
|
|
24182
|
-
// first sure newWidth is right,calculate newHeight
|
|
24183
|
-
newHeight = newWidth / ratio;
|
|
24184
|
-
if (newHeight < options.minHeight) {
|
|
24185
|
-
newHeight = options.minHeight;
|
|
24908
|
+
if (options.minWidth !== undefined && options.minHeight !== undefined) {
|
|
24909
|
+
var horizontalOnly = x == '';
|
|
24910
|
+
var verticalOnly = y == '';
|
|
24911
|
+
var shouldPreserveRatio = !(horizontalOnly || verticalOnly) && (options.preserveRatio || e.shiftKey);
|
|
24912
|
+
var newWidth = horizontalOnly
|
|
24913
|
+
? base.widthPx
|
|
24914
|
+
: Math.max(base.widthPx + deltaX * (x == 'w' ? -1 : 1), options.minWidth);
|
|
24915
|
+
var newHeight = verticalOnly
|
|
24916
|
+
? base.heightPx
|
|
24917
|
+
: Math.max(base.heightPx + deltaY * (y == 'n' ? -1 : 1), options.minHeight);
|
|
24918
|
+
if (shouldPreserveRatio && ratio > 0) {
|
|
24919
|
+
if (ratio > 1) {
|
|
24920
|
+
// first sure newHeight is right,calculate newWidth
|
|
24186
24921
|
newWidth = newHeight * ratio;
|
|
24922
|
+
if (newWidth < options.minWidth) {
|
|
24923
|
+
newWidth = options.minWidth;
|
|
24924
|
+
newHeight = newWidth / ratio;
|
|
24925
|
+
}
|
|
24926
|
+
}
|
|
24927
|
+
else {
|
|
24928
|
+
// first sure newWidth is right,calculate newHeight
|
|
24929
|
+
newHeight = newWidth / ratio;
|
|
24930
|
+
if (newHeight < options.minHeight) {
|
|
24931
|
+
newHeight = options.minHeight;
|
|
24932
|
+
newWidth = newHeight * ratio;
|
|
24933
|
+
}
|
|
24187
24934
|
}
|
|
24188
24935
|
}
|
|
24936
|
+
editInfo.widthPx = newWidth;
|
|
24937
|
+
editInfo.heightPx = newHeight;
|
|
24938
|
+
return true;
|
|
24939
|
+
}
|
|
24940
|
+
else {
|
|
24941
|
+
return false;
|
|
24189
24942
|
}
|
|
24190
|
-
editInfo.widthPx = newWidth;
|
|
24191
|
-
editInfo.heightPx = newHeight;
|
|
24192
|
-
return true;
|
|
24193
24943
|
},
|
|
24194
24944
|
};
|
|
24195
24945
|
/**
|
|
@@ -24249,10 +24999,12 @@ function getCornerResizeHTML(_a, onShowResizeHandle) {
|
|
|
24249
24999
|
var elementData = (x == '') == (y == '')
|
|
24250
25000
|
? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
|
|
24251
25001
|
: null;
|
|
24252
|
-
if (onShowResizeHandle) {
|
|
25002
|
+
if (onShowResizeHandle && elementData) {
|
|
24253
25003
|
onShowResizeHandle(elementData, x, y);
|
|
24254
25004
|
}
|
|
24255
|
-
|
|
25005
|
+
if (elementData) {
|
|
25006
|
+
result.push(elementData);
|
|
25007
|
+
}
|
|
24256
25008
|
});
|
|
24257
25009
|
});
|
|
24258
25010
|
return result;
|
|
@@ -24273,10 +25025,12 @@ function getSideResizeHTML(_a, onShowResizeHandle) {
|
|
|
24273
25025
|
var elementData = (x == '') != (y == '')
|
|
24274
25026
|
? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
|
|
24275
25027
|
: null;
|
|
24276
|
-
if (onShowResizeHandle) {
|
|
25028
|
+
if (onShowResizeHandle && elementData) {
|
|
24277
25029
|
onShowResizeHandle(elementData, x, y);
|
|
24278
25030
|
}
|
|
24279
|
-
|
|
25031
|
+
if (elementData) {
|
|
25032
|
+
result.push(elementData);
|
|
25033
|
+
}
|
|
24280
25034
|
});
|
|
24281
25035
|
});
|
|
24282
25036
|
return result;
|
|
@@ -24369,7 +25123,7 @@ exports.Rotator = {
|
|
|
24369
25123
|
var newX = distance * Math.sin(base.angleRad) + deltaX;
|
|
24370
25124
|
var newY = distance * Math.cos(base.angleRad) - deltaY;
|
|
24371
25125
|
var angleInRad = Math.atan2(newX, newY);
|
|
24372
|
-
if (!e.altKey) {
|
|
25126
|
+
if (!e.altKey && options && options.minRotateDeg !== undefined) {
|
|
24373
25127
|
var angleInDeg = angleInRad * DEG_PER_RAD;
|
|
24374
25128
|
var adjustedAngleInDeg = Math.round(angleInDeg / options.minRotateDeg) * options.minRotateDeg;
|
|
24375
25129
|
angleInRad = adjustedAngleInDeg / DEG_PER_RAD;
|
|
@@ -24391,7 +25145,7 @@ exports.Rotator = {
|
|
|
24391
25145
|
function updateRotateHandlePosition(editInfo, editorRect, marginVertical, rotateCenter, rotateHandle) {
|
|
24392
25146
|
var rotateHandleRect = rotateHandle.getBoundingClientRect();
|
|
24393
25147
|
if (rotateHandleRect) {
|
|
24394
|
-
var top_1 = rotateHandleRect.top -
|
|
25148
|
+
var top_1 = rotateHandleRect.top - editorRect.top;
|
|
24395
25149
|
var angleRad = editInfo.angleRad, heightPx = editInfo.heightPx;
|
|
24396
25150
|
var cosAngle = Math.cos(angleRad);
|
|
24397
25151
|
var adjustedDistance = cosAngle <= 0
|
|
@@ -25430,6 +26184,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25430
26184
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
25431
26185
|
var HTTP = 'http:';
|
|
25432
26186
|
var HTTPS = 'https:';
|
|
26187
|
+
var NOTES = 'notes:';
|
|
25433
26188
|
/**
|
|
25434
26189
|
* @internal
|
|
25435
26190
|
* Clear local paths and remove link
|
|
@@ -25447,7 +26202,10 @@ function validateLink(link, htmlElement) {
|
|
|
25447
26202
|
catch (_a) {
|
|
25448
26203
|
url = undefined;
|
|
25449
26204
|
}
|
|
25450
|
-
if (url &&
|
|
26205
|
+
if (url &&
|
|
26206
|
+
(url.protocol === HTTP ||
|
|
26207
|
+
url.protocol === HTTPS ||
|
|
26208
|
+
url.protocol === NOTES) /* whitelist Notes protocol */) {
|
|
25451
26209
|
return link;
|
|
25452
26210
|
}
|
|
25453
26211
|
htmlElement.removeAttribute('href');
|
|
@@ -29227,6 +29985,35 @@ var CompatibleDefinitionType;
|
|
|
29227
29985
|
})(CompatibleDefinitionType = exports.CompatibleDefinitionType || (exports.CompatibleDefinitionType = {}));
|
|
29228
29986
|
|
|
29229
29987
|
|
|
29988
|
+
/***/ }),
|
|
29989
|
+
|
|
29990
|
+
/***/ "./packages/roosterjs-editor-types/lib/compatibleEnum/DelimiterClasses.ts":
|
|
29991
|
+
/*!********************************************************************************!*\
|
|
29992
|
+
!*** ./packages/roosterjs-editor-types/lib/compatibleEnum/DelimiterClasses.ts ***!
|
|
29993
|
+
\********************************************************************************/
|
|
29994
|
+
/*! no static exports found */
|
|
29995
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
29996
|
+
|
|
29997
|
+
"use strict";
|
|
29998
|
+
|
|
29999
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30000
|
+
exports.CompatibleDelimiterClasses = void 0;
|
|
30001
|
+
/**
|
|
30002
|
+
* Class names for Delimiter
|
|
30003
|
+
*/
|
|
30004
|
+
var CompatibleDelimiterClasses;
|
|
30005
|
+
(function (CompatibleDelimiterClasses) {
|
|
30006
|
+
/**
|
|
30007
|
+
* Class name to specify this delimiter is before an entity
|
|
30008
|
+
*/
|
|
30009
|
+
CompatibleDelimiterClasses["DELIMITER_BEFORE"] = "entityDelimiterBefore";
|
|
30010
|
+
/**
|
|
30011
|
+
* Class name to specify this delimiter is after an entity
|
|
30012
|
+
*/
|
|
30013
|
+
CompatibleDelimiterClasses["DELIMITER_AFTER"] = "entityDelimiterAfter";
|
|
30014
|
+
})(CompatibleDelimiterClasses = exports.CompatibleDelimiterClasses || (exports.CompatibleDelimiterClasses = {}));
|
|
30015
|
+
|
|
30016
|
+
|
|
29230
30017
|
/***/ }),
|
|
29231
30018
|
|
|
29232
30019
|
/***/ "./packages/roosterjs-editor-types/lib/compatibleEnum/Direction.ts":
|
|
@@ -29666,6 +30453,8 @@ exports.CompatibleExperimentalFeatures = void 0;
|
|
|
29666
30453
|
*/
|
|
29667
30454
|
var CompatibleExperimentalFeatures;
|
|
29668
30455
|
(function (CompatibleExperimentalFeatures) {
|
|
30456
|
+
// #region Graduated and deprecated features.
|
|
30457
|
+
// These features will be removed in next major release
|
|
29669
30458
|
/**
|
|
29670
30459
|
* @deprecated This feature is always enabled
|
|
29671
30460
|
*/
|
|
@@ -29717,23 +30506,11 @@ var CompatibleExperimentalFeatures;
|
|
|
29717
30506
|
* Align table elements to left, center and right using setAlignment API
|
|
29718
30507
|
*/
|
|
29719
30508
|
CompatibleExperimentalFeatures["TableAlignment"] = "TableAlignment";
|
|
29720
|
-
/**
|
|
29721
|
-
* Provide additional Tab Key Features. Requires Text Features Content Editable Features
|
|
29722
|
-
*/
|
|
29723
|
-
CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
|
|
29724
30509
|
/**
|
|
29725
30510
|
* @deprecated this feature is always enabled
|
|
29726
30511
|
* Provide a circular resize handles that adaptive the number od handles to the size of the image
|
|
29727
30512
|
*/
|
|
29728
30513
|
CompatibleExperimentalFeatures["AdaptiveHandlesResizer"] = "AdaptiveHandlesResizer";
|
|
29729
|
-
/**
|
|
29730
|
-
* Align list elements elements to left, center and right using setAlignment API
|
|
29731
|
-
*/
|
|
29732
|
-
CompatibleExperimentalFeatures["ListItemAlignment"] = "ListItemAlignment";
|
|
29733
|
-
/**
|
|
29734
|
-
* Trigger formatting by a especial characters. Ex: (A), 1. i).
|
|
29735
|
-
*/
|
|
29736
|
-
CompatibleExperimentalFeatures["AutoFormatList"] = "AutoFormatList";
|
|
29737
30514
|
/**
|
|
29738
30515
|
* @deprecated this feature is always disabled
|
|
29739
30516
|
* Automatically transform -- into hyphen, if typed between two words.
|
|
@@ -29757,6 +30534,19 @@ var CompatibleExperimentalFeatures;
|
|
|
29757
30534
|
* When a html image is selected, the selected image data will be stored by editor core.
|
|
29758
30535
|
*/
|
|
29759
30536
|
CompatibleExperimentalFeatures["ImageSelection"] = "ImageSelection";
|
|
30537
|
+
//#endregion
|
|
30538
|
+
/**
|
|
30539
|
+
* Provide additional Tab Key Features. Requires Text Features Content Editable Features
|
|
30540
|
+
*/
|
|
30541
|
+
CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
|
|
30542
|
+
/**
|
|
30543
|
+
* Align list elements elements to left, center and right using setAlignment API
|
|
30544
|
+
*/
|
|
30545
|
+
CompatibleExperimentalFeatures["ListItemAlignment"] = "ListItemAlignment";
|
|
30546
|
+
/**
|
|
30547
|
+
* Trigger formatting by a especial characters. Ex: (A), 1. i).
|
|
30548
|
+
*/
|
|
30549
|
+
CompatibleExperimentalFeatures["AutoFormatList"] = "AutoFormatList";
|
|
29760
30550
|
/**
|
|
29761
30551
|
* With this feature enabled, when writing back a list item we will re-use all
|
|
29762
30552
|
* ancestor list elements, even if they don't match the types currently in the
|
|
@@ -29775,6 +30565,18 @@ var CompatibleExperimentalFeatures;
|
|
|
29775
30565
|
* if you need them work for dark mode
|
|
29776
30566
|
*/
|
|
29777
30567
|
CompatibleExperimentalFeatures["VariableBasedDarkColor"] = "VariableBasedDarkColor";
|
|
30568
|
+
/**
|
|
30569
|
+
* Reuse existing DOM structure if possible when convert Content Model back to DOM tree
|
|
30570
|
+
*/
|
|
30571
|
+
CompatibleExperimentalFeatures["ReusableContentModel"] = "ReusableContentModel";
|
|
30572
|
+
/**
|
|
30573
|
+
* Delete table with Backspace key with the whole was selected with table selector
|
|
30574
|
+
*/
|
|
30575
|
+
CompatibleExperimentalFeatures["DeleteTableWithBackspace"] = "DeleteTableWithBackspace";
|
|
30576
|
+
/**
|
|
30577
|
+
* Add entities around a Read Only Inline entity to prevent cursor to be hidden when cursor is next of it.
|
|
30578
|
+
*/
|
|
30579
|
+
CompatibleExperimentalFeatures["InlineEntityReadOnlyDelimiters"] = "InlineEntityReadOnlyDelimiters";
|
|
29778
30580
|
})(CompatibleExperimentalFeatures = exports.CompatibleExperimentalFeatures || (exports.CompatibleExperimentalFeatures = {}));
|
|
29779
30581
|
|
|
29780
30582
|
|
|
@@ -30740,7 +31542,7 @@ var CompatibleTableOperation;
|
|
|
30740
31542
|
"use strict";
|
|
30741
31543
|
|
|
30742
31544
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30743
|
-
exports.CompatibleTableOperation = exports.CompatibleTableBorderFormat = exports.CompatibleSelectionRangeTypes = exports.CompatibleRegionType = exports.CompatibleQueryScope = exports.CompatiblePositionType = exports.CompatiblePluginEventType = exports.CompatibleNumberingListType = exports.CompatibleNodeType = exports.CompatibleListType = exports.CompatibleKnownCreateElementDataIndex = exports.CompatibleKeys = exports.CompatibleIndentation = exports.CompatibleImageEditOperation = exports.CompatibleGetContentMode = exports.CompatibleFontSizeChange = exports.CompatibleExperimentalFeatures = exports.CompatibleEntityOperation = exports.CompatibleEntityClasses = exports.CompatibleDocumentPosition = exports.CompatibleDocumentCommand = exports.CompatibleDirection = exports.CompatibleDefinitionType = exports.CompatibleDarkModeDatasetNames = exports.CompatibleContentType = exports.CompatibleContentTypePrefix = exports.CompatibleContentPosition = exports.CompatibleColorTransformDirection = exports.CompatibleClearFormatMode = exports.CompatibleChangeSource = exports.CompatibleCapitalization = exports.CompatibleBulletListType = exports.CompatibleAlignment = void 0;
|
|
31545
|
+
exports.CompatibleTableOperation = exports.CompatibleTableBorderFormat = exports.CompatibleSelectionRangeTypes = exports.CompatibleRegionType = exports.CompatibleQueryScope = exports.CompatiblePositionType = exports.CompatiblePluginEventType = exports.CompatibleNumberingListType = exports.CompatibleNodeType = exports.CompatibleListType = exports.CompatibleKnownCreateElementDataIndex = exports.CompatibleKeys = exports.CompatibleIndentation = exports.CompatibleImageEditOperation = exports.CompatibleGetContentMode = exports.CompatibleFontSizeChange = exports.CompatibleExperimentalFeatures = exports.CompatibleEntityOperation = exports.CompatibleEntityClasses = exports.CompatibleDocumentPosition = exports.CompatibleDocumentCommand = exports.CompatibleDirection = exports.CompatibleDelimiterClasses = exports.CompatibleDefinitionType = exports.CompatibleDarkModeDatasetNames = exports.CompatibleContentType = exports.CompatibleContentTypePrefix = exports.CompatibleContentPosition = exports.CompatibleColorTransformDirection = exports.CompatibleClearFormatMode = exports.CompatibleChangeSource = exports.CompatibleCapitalization = exports.CompatibleBulletListType = exports.CompatibleAlignment = void 0;
|
|
30744
31546
|
var Alignment_1 = __webpack_require__(/*! ./Alignment */ "./packages/roosterjs-editor-types/lib/compatibleEnum/Alignment.ts");
|
|
30745
31547
|
Object.defineProperty(exports, "CompatibleAlignment", { enumerable: true, get: function () { return Alignment_1.CompatibleAlignment; } });
|
|
30746
31548
|
var BulletListType_1 = __webpack_require__(/*! ./BulletListType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/BulletListType.ts");
|
|
@@ -30762,6 +31564,8 @@ var DarkModeDatasetNames_1 = __webpack_require__(/*! ./DarkModeDatasetNames */ "
|
|
|
30762
31564
|
Object.defineProperty(exports, "CompatibleDarkModeDatasetNames", { enumerable: true, get: function () { return DarkModeDatasetNames_1.CompatibleDarkModeDatasetNames; } });
|
|
30763
31565
|
var DefinitionType_1 = __webpack_require__(/*! ./DefinitionType */ "./packages/roosterjs-editor-types/lib/compatibleEnum/DefinitionType.ts");
|
|
30764
31566
|
Object.defineProperty(exports, "CompatibleDefinitionType", { enumerable: true, get: function () { return DefinitionType_1.CompatibleDefinitionType; } });
|
|
31567
|
+
var DelimiterClasses_1 = __webpack_require__(/*! ./DelimiterClasses */ "./packages/roosterjs-editor-types/lib/compatibleEnum/DelimiterClasses.ts");
|
|
31568
|
+
Object.defineProperty(exports, "CompatibleDelimiterClasses", { enumerable: true, get: function () { return DelimiterClasses_1.CompatibleDelimiterClasses; } });
|
|
30765
31569
|
var Direction_1 = __webpack_require__(/*! ./Direction */ "./packages/roosterjs-editor-types/lib/compatibleEnum/Direction.ts");
|
|
30766
31570
|
Object.defineProperty(exports, "CompatibleDirection", { enumerable: true, get: function () { return Direction_1.CompatibleDirection; } });
|
|
30767
31571
|
var DocumentCommand_1 = __webpack_require__(/*! ./DocumentCommand */ "./packages/roosterjs-editor-types/lib/compatibleEnum/DocumentCommand.ts");
|