roosterjs 8.35.2 → 8.37.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 +99 -37
- package/dist/rooster-amd.js +623 -373
- 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 +99 -37
- package/dist/rooster.js +623 -373
- package/dist/rooster.js.map +1 -1
- package/package.json +8 -8
- package/tsconfig.child.tsbuildinfo +1 -1
package/dist/rooster-amd.js
CHANGED
|
@@ -2154,12 +2154,14 @@ Object.defineProperty(exports, "getDarkColor", { enumerable: true, get: function
|
|
|
2154
2154
|
|
|
2155
2155
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2156
2156
|
var Color = __webpack_require__(/*! color */ "./node_modules/color/index.js");
|
|
2157
|
-
var
|
|
2157
|
+
var DefaultBaseLValue = 21.247; // L-value of #333333
|
|
2158
2158
|
/**
|
|
2159
2159
|
* Get dark mode color for a given color
|
|
2160
2160
|
* @param color The color to calculate from
|
|
2161
|
+
* @param baseLValue The Light value for base dark color in LAB format. @default the Light value for #333333
|
|
2161
2162
|
*/
|
|
2162
|
-
function getDarkColor(color) {
|
|
2163
|
+
function getDarkColor(color, baseLValue) {
|
|
2164
|
+
if (baseLValue === void 0) { baseLValue = DefaultBaseLValue; }
|
|
2163
2165
|
try {
|
|
2164
2166
|
var computedColor = Color(color || undefined);
|
|
2165
2167
|
var colorLab = computedColor.lab().array();
|
|
@@ -3083,8 +3085,7 @@ function setAlignment(editor, alignment) {
|
|
|
3083
3085
|
var selection = editor.getSelectionRangeEx();
|
|
3084
3086
|
var isATable = selection && selection.type === 1 /* TableSelection */;
|
|
3085
3087
|
var elementAtCursor = editor.getElementAtCursor();
|
|
3086
|
-
if (
|
|
3087
|
-
isATable &&
|
|
3088
|
+
if (isATable &&
|
|
3088
3089
|
(0, roosterjs_editor_dom_1.isWholeTableSelected)(new roosterjs_editor_dom_1.VTable(selection.table), selection.coordinates)) {
|
|
3089
3090
|
alignTable(selection, alignment);
|
|
3090
3091
|
}
|
|
@@ -4195,7 +4196,9 @@ function applyInlineStyle(editor, callback, apiName) {
|
|
|
4195
4196
|
else if (editor.isFeatureEnabled("PendingStyleBasedFormat" /* PendingStyleBasedFormat */)) {
|
|
4196
4197
|
editor.triggerPluginEvent(13 /* PendingFormatStateChanged */, {
|
|
4197
4198
|
formatState: {},
|
|
4198
|
-
|
|
4199
|
+
// Here we use callback instead of safeCallback because we know it's contentEditable.
|
|
4200
|
+
// In addition, for elements that are not added to the DOM tree, isContentEditable always returns false on Safari.
|
|
4201
|
+
formatCallback: callback,
|
|
4199
4202
|
});
|
|
4200
4203
|
editor.triggerContentChangedEvent("Format" /* Format */);
|
|
4201
4204
|
}
|
|
@@ -5096,7 +5099,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
|
|
|
5096
5099
|
* When typing goes directly under content div, many things can go wrong
|
|
5097
5100
|
* We fix it by wrapping it with a div and reposition cursor within the div
|
|
5098
5101
|
*/
|
|
5099
|
-
var ensureTypeInContainer = function (core, position, keyboardEvent) {
|
|
5102
|
+
var ensureTypeInContainer = function (core, position, keyboardEvent, applyFormatToSpan) {
|
|
5100
5103
|
var table = (0, roosterjs_editor_dom_1.findClosestElementAncestor)(position.node, core.contentDiv, 'table');
|
|
5101
5104
|
var td;
|
|
5102
5105
|
if (table && (td = table.querySelector('td,th'))) {
|
|
@@ -5117,20 +5120,28 @@ var ensureTypeInContainer = function (core, position, keyboardEvent) {
|
|
|
5117
5120
|
var shouldSetNodeStyles = (0, roosterjs_editor_dom_1.isNodeEmpty)(formatNode) ||
|
|
5118
5121
|
(keyboardEvent && wasNodeJustCreatedByKeyboardEvent(keyboardEvent, formatNode));
|
|
5119
5122
|
formatNode = formatNode && shouldSetNodeStyles ? formatNode : null;
|
|
5123
|
+
if (formatNode && core.lifecycle.defaultFormat && applyFormatToSpan) {
|
|
5124
|
+
var firstChild = formatNode.firstChild;
|
|
5125
|
+
formatNode = (0, roosterjs_editor_dom_1.safeInstanceOf)(firstChild, 'HTMLSpanElement')
|
|
5126
|
+
? firstChild
|
|
5127
|
+
: (0, roosterjs_editor_dom_1.wrap)((0, roosterjs_editor_dom_1.toArray)(formatNode.childNodes), 'span');
|
|
5128
|
+
position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
|
|
5129
|
+
}
|
|
5120
5130
|
}
|
|
5121
5131
|
else {
|
|
5122
5132
|
// Only reason we don't get the selection block is that we have an empty content div
|
|
5123
5133
|
// which can happen when users removes everything (i.e. select all and DEL, or backspace from very end to begin)
|
|
5124
5134
|
// The fix is to add a DIV wrapping, apply default format and move cursor over
|
|
5125
|
-
|
|
5126
|
-
core.api.insertNode(core,
|
|
5135
|
+
var newNode = (0, roosterjs_editor_dom_1.createElement)(1 /* EmptyLine */, core.contentDiv.ownerDocument);
|
|
5136
|
+
core.api.insertNode(core, newNode, {
|
|
5127
5137
|
position: 1 /* End */,
|
|
5128
5138
|
updateCursor: false,
|
|
5129
5139
|
replaceSelection: false,
|
|
5130
5140
|
insertOnNewLine: false,
|
|
5131
5141
|
});
|
|
5142
|
+
formatNode = newNode.firstChild;
|
|
5132
5143
|
// element points to a wrapping node we added "<div><br></div>". We should move the selection left to <br>
|
|
5133
|
-
position = new roosterjs_editor_dom_1.Position(formatNode
|
|
5144
|
+
position = new roosterjs_editor_dom_1.Position(formatNode, 0 /* Begin */);
|
|
5134
5145
|
}
|
|
5135
5146
|
if (formatNode && core.lifecycle.defaultFormat) {
|
|
5136
5147
|
(0, roosterjs_editor_dom_1.applyFormat)(formatNode, core.lifecycle.defaultFormat, core.lifecycle.isDarkMode);
|
|
@@ -5849,7 +5860,6 @@ exports.restoreUndoSnapshot = restoreUndoSnapshot;
|
|
|
5849
5860
|
|
|
5850
5861
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5851
5862
|
exports.selectImage = void 0;
|
|
5852
|
-
var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
|
|
5853
5863
|
var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
|
|
5854
5864
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
5855
5865
|
var IMAGE_ID = 'imageSelected';
|
|
@@ -5884,7 +5894,7 @@ exports.selectImage = selectImage;
|
|
|
5884
5894
|
var select = function (core, image) {
|
|
5885
5895
|
(0, roosterjs_editor_dom_1.removeImportantStyleRule)(image, ['border', 'margin']);
|
|
5886
5896
|
var borderCSS = buildBorderCSS(core, image.id);
|
|
5887
|
-
(0,
|
|
5897
|
+
(0, roosterjs_editor_dom_1.setGlobalCssStyles)(core.contentDiv.ownerDocument, borderCSS, STYLE_ID + core.contentDiv.id);
|
|
5888
5898
|
};
|
|
5889
5899
|
var buildBorderCSS = function (core, imageId) {
|
|
5890
5900
|
var divId = core.contentDiv.id;
|
|
@@ -5893,10 +5903,7 @@ var buildBorderCSS = function (core, imageId) {
|
|
|
5893
5903
|
};
|
|
5894
5904
|
var unselect = function (core) {
|
|
5895
5905
|
var doc = core.contentDiv.ownerDocument;
|
|
5896
|
-
|
|
5897
|
-
if (styleTag) {
|
|
5898
|
-
doc.head.removeChild(styleTag);
|
|
5899
|
-
}
|
|
5906
|
+
(0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, STYLE_ID + core.contentDiv.id);
|
|
5900
5907
|
};
|
|
5901
5908
|
|
|
5902
5909
|
|
|
@@ -5978,7 +5985,6 @@ function restorePendingFormatState(core) {
|
|
|
5978
5985
|
|
|
5979
5986
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5980
5987
|
exports.selectTable = void 0;
|
|
5981
|
-
var addSelectionStyle_1 = __webpack_require__(/*! ./utils/addSelectionStyle */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts");
|
|
5982
5988
|
var addUniqueId_1 = __webpack_require__(/*! ./utils/addUniqueId */ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts");
|
|
5983
5989
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
5984
5990
|
var TABLE_ID = 'tableSelected';
|
|
@@ -6079,19 +6085,13 @@ function buildCss(table, coordinates, contentDivSelector) {
|
|
|
6079
6085
|
function select(core, table, coordinates) {
|
|
6080
6086
|
var contentDivSelector = '#' + core.contentDiv.id;
|
|
6081
6087
|
var _a = buildCss(table, coordinates, contentDivSelector), css = _a.css, ranges = _a.ranges;
|
|
6082
|
-
(0,
|
|
6088
|
+
(0, roosterjs_editor_dom_1.setGlobalCssStyles)(core.contentDiv.ownerDocument, css, STYLE_ID + core.contentDiv.id);
|
|
6083
6089
|
return ranges;
|
|
6084
6090
|
}
|
|
6085
|
-
function
|
|
6086
|
-
var
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
if ((_a = styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
|
|
6090
|
-
while (styleElement.sheet.cssRules.length > 0) {
|
|
6091
|
-
styleElement.sheet.deleteRule(0);
|
|
6092
|
-
}
|
|
6093
|
-
}
|
|
6094
|
-
}
|
|
6091
|
+
var unselect = function (core) {
|
|
6092
|
+
var doc = core.contentDiv.ownerDocument;
|
|
6093
|
+
(0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, STYLE_ID + core.contentDiv.id);
|
|
6094
|
+
};
|
|
6095
6095
|
function generateCssFromCell(contentDivSelector, tableId, middleElSelector, rowIndex, cellTag, index) {
|
|
6096
6096
|
return (contentDivSelector +
|
|
6097
6097
|
' #' +
|
|
@@ -6228,7 +6228,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
|
|
|
6228
6228
|
*/
|
|
6229
6229
|
var switchShadowEdit = function (core, isOn) {
|
|
6230
6230
|
var lifecycle = core.lifecycle, contentDiv = core.contentDiv;
|
|
6231
|
-
var shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath, shadowEditImageSelectionPath = lifecycle.shadowEditImageSelectionPath;
|
|
6231
|
+
var shadowEditEntities = lifecycle.shadowEditEntities, shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath, shadowEditImageSelectionPath = lifecycle.shadowEditImageSelectionPath;
|
|
6232
6232
|
var wasInShadowEdit = !!shadowEditFragment;
|
|
6233
6233
|
var getShadowEditSelectionPath = function (selectionType, shadowEditSelection) {
|
|
6234
6234
|
return (((shadowEditSelection === null || shadowEditSelection === void 0 ? void 0 : shadowEditSelection.type) == selectionType &&
|
|
@@ -6243,10 +6243,9 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
6243
6243
|
var range = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
|
|
6244
6244
|
shadowEditSelectionPath = range && (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range);
|
|
6245
6245
|
shadowEditTableSelectionPath = getShadowEditSelectionPath(1 /* TableSelection */, selection);
|
|
6246
|
-
shadowEditFragment = core.contentDiv.ownerDocument.createDocumentFragment();
|
|
6247
6246
|
shadowEditImageSelectionPath = getShadowEditSelectionPath(2 /* ImageSelection */, selection);
|
|
6248
|
-
|
|
6249
|
-
shadowEditFragment.
|
|
6247
|
+
shadowEditEntities = {};
|
|
6248
|
+
shadowEditFragment = (0, roosterjs_editor_dom_1.moveContentWithEntityPlaceholders)(contentDiv, shadowEditEntities);
|
|
6250
6249
|
core.api.triggerEvent(core, {
|
|
6251
6250
|
eventType: 17 /* EnteredShadowEdit */,
|
|
6252
6251
|
fragment: shadowEditFragment,
|
|
@@ -6256,22 +6255,22 @@ var switchShadowEdit = function (core, isOn) {
|
|
|
6256
6255
|
lifecycle.shadowEditSelectionPath = shadowEditSelectionPath;
|
|
6257
6256
|
lifecycle.shadowEditTableSelectionPath = shadowEditTableSelectionPath;
|
|
6258
6257
|
lifecycle.shadowEditImageSelectionPath = shadowEditImageSelectionPath;
|
|
6258
|
+
lifecycle.shadowEditEntities = shadowEditEntities;
|
|
6259
6259
|
}
|
|
6260
|
-
(0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
|
|
6261
6260
|
if (lifecycle.shadowEditFragment) {
|
|
6262
|
-
|
|
6261
|
+
(0, roosterjs_editor_dom_1.restoreContentWithEntityPlaceholder)(lifecycle.shadowEditFragment, contentDiv, lifecycle.shadowEditEntities, true /*insertClonedNode*/);
|
|
6263
6262
|
}
|
|
6264
6263
|
}
|
|
6265
6264
|
else {
|
|
6266
6265
|
lifecycle.shadowEditFragment = null;
|
|
6267
6266
|
lifecycle.shadowEditSelectionPath = null;
|
|
6267
|
+
lifecycle.shadowEditEntities = null;
|
|
6268
6268
|
if (wasInShadowEdit) {
|
|
6269
6269
|
core.api.triggerEvent(core, {
|
|
6270
6270
|
eventType: 18 /* LeavingShadowEdit */,
|
|
6271
6271
|
}, false /*broadcast*/);
|
|
6272
|
-
(0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
|
|
6273
6272
|
if (shadowEditFragment) {
|
|
6274
|
-
|
|
6273
|
+
(0, roosterjs_editor_dom_1.restoreContentWithEntityPlaceholder)(shadowEditFragment, contentDiv, shadowEditEntities);
|
|
6275
6274
|
}
|
|
6276
6275
|
core.api.focus(core);
|
|
6277
6276
|
if (shadowEditSelectionPath) {
|
|
@@ -6486,39 +6485,6 @@ function handledExclusively(event, plugin) {
|
|
|
6486
6485
|
}
|
|
6487
6486
|
|
|
6488
6487
|
|
|
6489
|
-
/***/ }),
|
|
6490
|
-
|
|
6491
|
-
/***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts":
|
|
6492
|
-
/*!*******************************************************************************!*\
|
|
6493
|
-
!*** ./packages/roosterjs-editor-core/lib/coreApi/utils/addSelectionStyle.ts ***!
|
|
6494
|
-
\*******************************************************************************/
|
|
6495
|
-
/*! no static exports found */
|
|
6496
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
6497
|
-
|
|
6498
|
-
"use strict";
|
|
6499
|
-
|
|
6500
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6501
|
-
/**
|
|
6502
|
-
* Add style to selected elements
|
|
6503
|
-
* @param core The Editor core object
|
|
6504
|
-
* @param cssRule The css rule that must added to the selection
|
|
6505
|
-
* @param styleId the ID of the style tag
|
|
6506
|
-
*/
|
|
6507
|
-
function addSelectionStyle(core, cssRule, styleId) {
|
|
6508
|
-
var _a;
|
|
6509
|
-
var styleTagId = styleId + core.contentDiv.id;
|
|
6510
|
-
var doc = core.contentDiv.ownerDocument;
|
|
6511
|
-
var styleTag = doc.getElementById(styleTagId);
|
|
6512
|
-
if (!styleTag) {
|
|
6513
|
-
styleTag = doc.createElement('style');
|
|
6514
|
-
styleTag.id = styleTagId;
|
|
6515
|
-
doc.head.appendChild(styleTag);
|
|
6516
|
-
}
|
|
6517
|
-
(_a = styleTag.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssRule);
|
|
6518
|
-
}
|
|
6519
|
-
exports.default = addSelectionStyle;
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
6488
|
/***/ }),
|
|
6523
6489
|
|
|
6524
6490
|
/***/ "./packages/roosterjs-editor-core/lib/coreApi/utils/addUniqueId.ts":
|
|
@@ -6671,6 +6637,9 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6671
6637
|
var image = tempDiv_1.querySelector('#' + selection_1.image.id);
|
|
6672
6638
|
if (image) {
|
|
6673
6639
|
newRange = (0, roosterjs_editor_dom_1.createRange)(image);
|
|
6640
|
+
if (isCut) {
|
|
6641
|
+
this.deleteImage(this.editor, selection_1.image.id);
|
|
6642
|
+
}
|
|
6674
6643
|
}
|
|
6675
6644
|
}
|
|
6676
6645
|
else {
|
|
@@ -6780,6 +6749,11 @@ var CopyPastePlugin = /** @class */ (function () {
|
|
|
6780
6749
|
table.style.removeProperty('height');
|
|
6781
6750
|
}
|
|
6782
6751
|
};
|
|
6752
|
+
CopyPastePlugin.prototype.deleteImage = function (editor, imageId) {
|
|
6753
|
+
editor.queryElements('#' + imageId, function (node) {
|
|
6754
|
+
editor.deleteNode(node);
|
|
6755
|
+
});
|
|
6756
|
+
};
|
|
6783
6757
|
return CopyPastePlugin;
|
|
6784
6758
|
}());
|
|
6785
6759
|
exports.default = CopyPastePlugin;
|
|
@@ -7479,6 +7453,95 @@ var workaroundSelectionIssueForIE = roosterjs_editor_dom_1.Browser.isIE
|
|
|
7479
7453
|
: function () { };
|
|
7480
7454
|
|
|
7481
7455
|
|
|
7456
|
+
/***/ }),
|
|
7457
|
+
|
|
7458
|
+
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts":
|
|
7459
|
+
/*!**************************************************************************!*\
|
|
7460
|
+
!*** ./packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts ***!
|
|
7461
|
+
\**************************************************************************/
|
|
7462
|
+
/*! no static exports found */
|
|
7463
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
7464
|
+
|
|
7465
|
+
"use strict";
|
|
7466
|
+
|
|
7467
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7468
|
+
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
7469
|
+
var Escape = 'Escape';
|
|
7470
|
+
var mouseRightButton = 2;
|
|
7471
|
+
var mouseLeftButton = 0;
|
|
7472
|
+
/**
|
|
7473
|
+
* Detect image selection and help highlight the image
|
|
7474
|
+
*/
|
|
7475
|
+
var ImageSelection = /** @class */ (function () {
|
|
7476
|
+
function ImageSelection() {
|
|
7477
|
+
this.editor = null;
|
|
7478
|
+
}
|
|
7479
|
+
/**
|
|
7480
|
+
* Get a friendly name of this plugin
|
|
7481
|
+
*/
|
|
7482
|
+
ImageSelection.prototype.getName = function () {
|
|
7483
|
+
return 'ImageSelection';
|
|
7484
|
+
};
|
|
7485
|
+
/**
|
|
7486
|
+
* Initialize this plugin. This should only be called from Editor
|
|
7487
|
+
* @param editor Editor instance
|
|
7488
|
+
*/
|
|
7489
|
+
ImageSelection.prototype.initialize = function (editor) {
|
|
7490
|
+
this.editor = editor;
|
|
7491
|
+
};
|
|
7492
|
+
/**
|
|
7493
|
+
* Dispose this plugin
|
|
7494
|
+
*/
|
|
7495
|
+
ImageSelection.prototype.dispose = function () {
|
|
7496
|
+
var _a;
|
|
7497
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.select(null);
|
|
7498
|
+
this.editor = null;
|
|
7499
|
+
};
|
|
7500
|
+
ImageSelection.prototype.onPluginEvent = function (event) {
|
|
7501
|
+
var _a;
|
|
7502
|
+
if (this.editor) {
|
|
7503
|
+
switch (event.eventType) {
|
|
7504
|
+
case 17 /* EnteredShadowEdit */:
|
|
7505
|
+
case 18 /* LeavingShadowEdit */:
|
|
7506
|
+
var selection = this.editor.getSelectionRangeEx();
|
|
7507
|
+
if (selection.type == 2 /* ImageSelection */) {
|
|
7508
|
+
this.editor.select(selection.image);
|
|
7509
|
+
}
|
|
7510
|
+
break;
|
|
7511
|
+
case 6 /* MouseUp */:
|
|
7512
|
+
var target = event.rawEvent.target;
|
|
7513
|
+
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
|
|
7514
|
+
if (event.rawEvent.button === mouseRightButton) {
|
|
7515
|
+
var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
|
|
7516
|
+
this.editor.select(imageRange);
|
|
7517
|
+
}
|
|
7518
|
+
else if (event.rawEvent.button === mouseLeftButton) {
|
|
7519
|
+
this.editor.select(target);
|
|
7520
|
+
}
|
|
7521
|
+
}
|
|
7522
|
+
break;
|
|
7523
|
+
case 2 /* KeyUp */:
|
|
7524
|
+
var key = event.rawEvent.key;
|
|
7525
|
+
var keyDownSelection = this.editor.getSelectionRangeEx();
|
|
7526
|
+
if (keyDownSelection.type === 2 /* ImageSelection */) {
|
|
7527
|
+
if (key === Escape) {
|
|
7528
|
+
this.editor.select(keyDownSelection.image, -2 /* Before */);
|
|
7529
|
+
(_a = this.editor.getSelectionRange()) === null || _a === void 0 ? void 0 : _a.collapse();
|
|
7530
|
+
event.rawEvent.stopPropagation();
|
|
7531
|
+
}
|
|
7532
|
+
else {
|
|
7533
|
+
this.editor.select(keyDownSelection.ranges[0]);
|
|
7534
|
+
}
|
|
7535
|
+
}
|
|
7536
|
+
break;
|
|
7537
|
+
}
|
|
7538
|
+
}
|
|
7539
|
+
};
|
|
7540
|
+
return ImageSelection;
|
|
7541
|
+
}());
|
|
7542
|
+
exports.default = ImageSelection;
|
|
7543
|
+
|
|
7544
|
+
|
|
7482
7545
|
/***/ }),
|
|
7483
7546
|
|
|
7484
7547
|
/***/ "./packages/roosterjs-editor-core/lib/corePlugins/LifecyclePlugin.ts":
|
|
@@ -7569,6 +7632,7 @@ var LifecyclePlugin = /** @class */ (function () {
|
|
|
7569
7632
|
onExternalContentTransform: (_c = options.onExternalContentTransform) !== null && _c !== void 0 ? _c : null,
|
|
7570
7633
|
experimentalFeatures: options.experimentalFeatures || [],
|
|
7571
7634
|
shadowEditFragment: null,
|
|
7635
|
+
shadowEditEntities: null,
|
|
7572
7636
|
shadowEditSelectionPath: null,
|
|
7573
7637
|
shadowEditTableSelectionPath: null,
|
|
7574
7638
|
shadowEditImageSelectionPath: null,
|
|
@@ -8421,6 +8485,7 @@ var CopyPastePlugin_1 = __webpack_require__(/*! ./CopyPastePlugin */ "./packages
|
|
|
8421
8485
|
var DOMEventPlugin_1 = __webpack_require__(/*! ./DOMEventPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/DOMEventPlugin.ts");
|
|
8422
8486
|
var EditPlugin_1 = __webpack_require__(/*! ./EditPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/EditPlugin.ts");
|
|
8423
8487
|
var EntityPlugin_1 = __webpack_require__(/*! ./EntityPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/EntityPlugin.ts");
|
|
8488
|
+
var ImageSelection_1 = __webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts");
|
|
8424
8489
|
var LifecyclePlugin_1 = __webpack_require__(/*! ./LifecyclePlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/LifecyclePlugin.ts");
|
|
8425
8490
|
var MouseUpPlugin_1 = __webpack_require__(/*! ./MouseUpPlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/MouseUpPlugin.ts");
|
|
8426
8491
|
var NormalizeTablePlugin_1 = __webpack_require__(/*! ./NormalizeTablePlugin */ "./packages/roosterjs-editor-core/lib/corePlugins/NormalizeTablePlugin.ts");
|
|
@@ -8448,6 +8513,7 @@ function createCorePlugins(contentDiv, options) {
|
|
|
8448
8513
|
mouseUp: map.mouseUp || new MouseUpPlugin_1.default(),
|
|
8449
8514
|
copyPaste: map.copyPaste || new CopyPastePlugin_1.default(options),
|
|
8450
8515
|
entity: map.entity || new EntityPlugin_1.default(),
|
|
8516
|
+
imageSelection: map.imageSelection || new ImageSelection_1.default(),
|
|
8451
8517
|
normalizeTable: map.normalizeTable || new NormalizeTablePlugin_1.default(),
|
|
8452
8518
|
lifecycle: map.lifecycle || new LifecyclePlugin_1.default(options, contentDiv),
|
|
8453
8519
|
};
|
|
@@ -8893,9 +8959,7 @@ var Editor = /** @class */ (function () {
|
|
|
8893
8959
|
coordinates: arg2,
|
|
8894
8960
|
};
|
|
8895
8961
|
}
|
|
8896
|
-
else if (
|
|
8897
|
-
(0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'HTMLImageElement') &&
|
|
8898
|
-
typeof arg2 == 'undefined') {
|
|
8962
|
+
else if ((0, roosterjs_editor_dom_1.safeInstanceOf)(arg1, 'HTMLImageElement') && typeof arg2 == 'undefined') {
|
|
8899
8963
|
rangeEx = {
|
|
8900
8964
|
type: 2 /* ImageSelection */,
|
|
8901
8965
|
ranges: [],
|
|
@@ -11210,6 +11274,143 @@ function commitEntity(wrapper, type, isReadonly, id) {
|
|
|
11210
11274
|
exports.default = commitEntity;
|
|
11211
11275
|
|
|
11212
11276
|
|
|
11277
|
+
/***/ }),
|
|
11278
|
+
|
|
11279
|
+
/***/ "./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts":
|
|
11280
|
+
/*!****************************************************************************!*\
|
|
11281
|
+
!*** ./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts ***!
|
|
11282
|
+
\****************************************************************************/
|
|
11283
|
+
/*! no static exports found */
|
|
11284
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
11285
|
+
|
|
11286
|
+
"use strict";
|
|
11287
|
+
|
|
11288
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11289
|
+
exports.restoreContentWithEntityPlaceholder = exports.moveContentWithEntityPlaceholders = exports.createEntityPlaceholder = void 0;
|
|
11290
|
+
var getEntityFromElement_1 = __webpack_require__(/*! ./getEntityFromElement */ "./packages/roosterjs-editor-dom/lib/entity/getEntityFromElement.ts");
|
|
11291
|
+
var getEntitySelector_1 = __webpack_require__(/*! ./getEntitySelector */ "./packages/roosterjs-editor-dom/lib/entity/getEntitySelector.ts");
|
|
11292
|
+
var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
|
|
11293
|
+
var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
|
|
11294
|
+
var EntityPlaceHolderTagName = 'ENTITY-PLACEHOLDER';
|
|
11295
|
+
/**
|
|
11296
|
+
* Create a placeholder comment node for entity
|
|
11297
|
+
* @param entity The entity to create placeholder from
|
|
11298
|
+
* @returns A placeholder comment node as
|
|
11299
|
+
*/
|
|
11300
|
+
function createEntityPlaceholder(entity) {
|
|
11301
|
+
var placeholder = entity.wrapper.ownerDocument.createElement(EntityPlaceHolderTagName);
|
|
11302
|
+
placeholder.id = entity.id;
|
|
11303
|
+
return placeholder;
|
|
11304
|
+
}
|
|
11305
|
+
exports.createEntityPlaceholder = createEntityPlaceholder;
|
|
11306
|
+
/**
|
|
11307
|
+
* Move content from a container into a new Document fragment, and try keep entities to be reusable by creating placeholder
|
|
11308
|
+
* for them in the document fragment.
|
|
11309
|
+
* If an entity is directly under root container, the whole entity can be reused and no need to move it at all.
|
|
11310
|
+
* If an entity is not directly under root container, it is still reusable, but it may need some movement.
|
|
11311
|
+
* In any case, entities will be replaced with a placeholder in the target document fragment.
|
|
11312
|
+
* We will use an entity map (the "entities" parameter) to save the map from entity id to its wrapper element.
|
|
11313
|
+
* @param root The root element
|
|
11314
|
+
* @param entities A map from entity id to entity wrapper element
|
|
11315
|
+
* @returns A new document fragment contains all the content and entity placeholders
|
|
11316
|
+
*/
|
|
11317
|
+
function moveContentWithEntityPlaceholders(root, entities) {
|
|
11318
|
+
var entitySelector = (0, getEntitySelector_1.default)();
|
|
11319
|
+
var fragment = root.ownerDocument.createDocumentFragment();
|
|
11320
|
+
var next = null;
|
|
11321
|
+
var _loop_1 = function (child) {
|
|
11322
|
+
var entity;
|
|
11323
|
+
var nodeToAppend = child;
|
|
11324
|
+
next = child.nextSibling;
|
|
11325
|
+
if ((0, safeInstanceOf_1.default)(child, 'HTMLElement')) {
|
|
11326
|
+
if ((entity = (0, getEntityFromElement_1.default)(child))) {
|
|
11327
|
+
nodeToAppend = getPlaceholder(entity, entities);
|
|
11328
|
+
}
|
|
11329
|
+
else {
|
|
11330
|
+
child.querySelectorAll(entitySelector).forEach(function (wrapper) {
|
|
11331
|
+
var _a;
|
|
11332
|
+
if ((entity = (0, getEntityFromElement_1.default)(wrapper))) {
|
|
11333
|
+
var placeholder = getPlaceholder(entity, entities);
|
|
11334
|
+
(_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(placeholder, wrapper);
|
|
11335
|
+
}
|
|
11336
|
+
});
|
|
11337
|
+
}
|
|
11338
|
+
}
|
|
11339
|
+
fragment.appendChild(nodeToAppend);
|
|
11340
|
+
};
|
|
11341
|
+
for (var child = root.firstChild; child; child = next) {
|
|
11342
|
+
_loop_1(child);
|
|
11343
|
+
}
|
|
11344
|
+
fragment.normalize();
|
|
11345
|
+
return fragment;
|
|
11346
|
+
}
|
|
11347
|
+
exports.moveContentWithEntityPlaceholders = moveContentWithEntityPlaceholders;
|
|
11348
|
+
/**
|
|
11349
|
+
* Restore HTML content from a document fragment that may contain entity placeholders.
|
|
11350
|
+
* @param source Source document fragment that contains HTML content and entity placeholders
|
|
11351
|
+
* @param target Target container, usually to be editor root container
|
|
11352
|
+
* @param entities A map from entity id to entity wrapper, used for reusing existing DOM structure for entity
|
|
11353
|
+
* @param insertClonedNode When pass true, merge with a cloned copy of the nodes from source fragment rather than the nodes themselves @default false
|
|
11354
|
+
*/
|
|
11355
|
+
function restoreContentWithEntityPlaceholder(source, target, entities, insertClonedNode) {
|
|
11356
|
+
var anchor = target.firstChild;
|
|
11357
|
+
entities = entities || {};
|
|
11358
|
+
var _loop_2 = function (current) {
|
|
11359
|
+
var wrapper = null;
|
|
11360
|
+
var next = current.nextSibling;
|
|
11361
|
+
var id = tryGetIdFromEntityPlaceholder(current);
|
|
11362
|
+
if (id && (wrapper = entities[current.id])) {
|
|
11363
|
+
anchor = removeUntil(anchor, wrapper);
|
|
11364
|
+
if (anchor) {
|
|
11365
|
+
anchor = anchor.nextSibling;
|
|
11366
|
+
}
|
|
11367
|
+
else {
|
|
11368
|
+
target.appendChild(wrapper);
|
|
11369
|
+
}
|
|
11370
|
+
}
|
|
11371
|
+
else {
|
|
11372
|
+
var nodeToInsert = insertClonedNode ? current.cloneNode(true /*deep*/) : current;
|
|
11373
|
+
target.insertBefore(nodeToInsert, anchor);
|
|
11374
|
+
if ((0, safeInstanceOf_1.default)(nodeToInsert, 'HTMLElement')) {
|
|
11375
|
+
nodeToInsert.querySelectorAll(EntityPlaceHolderTagName).forEach(function (placeholder) {
|
|
11376
|
+
var _a;
|
|
11377
|
+
wrapper = entities[placeholder.id];
|
|
11378
|
+
if (wrapper) {
|
|
11379
|
+
(_a = placeholder.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(wrapper, placeholder);
|
|
11380
|
+
}
|
|
11381
|
+
});
|
|
11382
|
+
}
|
|
11383
|
+
}
|
|
11384
|
+
current = next;
|
|
11385
|
+
out_current_1 = current;
|
|
11386
|
+
};
|
|
11387
|
+
var out_current_1;
|
|
11388
|
+
for (var current = source.firstChild; current;) {
|
|
11389
|
+
_loop_2(current);
|
|
11390
|
+
current = out_current_1;
|
|
11391
|
+
}
|
|
11392
|
+
removeUntil(anchor);
|
|
11393
|
+
}
|
|
11394
|
+
exports.restoreContentWithEntityPlaceholder = restoreContentWithEntityPlaceholder;
|
|
11395
|
+
function removeUntil(anchor, nodeToStop) {
|
|
11396
|
+
var _a;
|
|
11397
|
+
while (anchor && (!nodeToStop || anchor != nodeToStop)) {
|
|
11398
|
+
var nodeToRemove = anchor;
|
|
11399
|
+
anchor = anchor.nextSibling;
|
|
11400
|
+
(_a = nodeToRemove.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(nodeToRemove);
|
|
11401
|
+
}
|
|
11402
|
+
return anchor;
|
|
11403
|
+
}
|
|
11404
|
+
function tryGetIdFromEntityPlaceholder(node) {
|
|
11405
|
+
return (0, getTagOfNode_1.default)(node) == EntityPlaceHolderTagName ? node.id : null;
|
|
11406
|
+
}
|
|
11407
|
+
function getPlaceholder(entity, entities) {
|
|
11408
|
+
var placeholder = createEntityPlaceholder(entity);
|
|
11409
|
+
entities[entity.id] = entity.wrapper;
|
|
11410
|
+
return placeholder;
|
|
11411
|
+
}
|
|
11412
|
+
|
|
11413
|
+
|
|
11213
11414
|
/***/ }),
|
|
11214
11415
|
|
|
11215
11416
|
/***/ "./packages/roosterjs-editor-dom/lib/entity/getEntityFromElement.ts":
|
|
@@ -12261,8 +12462,8 @@ exports.isCssVariable = isCssVariable;
|
|
|
12261
12462
|
|
|
12262
12463
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12263
12464
|
exports.getIntersectedRect = exports.moveChildNodes = exports.KnownCreateElementData = exports.createElement = exports.matchesSelector = exports.setColor = exports.getInnerHTML = exports.readFile = exports.safeInstanceOf = exports.normalizeRect = exports.splitTextNode = exports.getLastLeafNode = exports.getFirstLeafNode = exports.getPreviousLeafSibling = exports.getNextLeafSibling = exports.wrap = exports.unwrap = exports.splitBalancedNodeRange = exports.splitParentNode = exports.queryElements = exports.matchLink = exports.isVoidHtmlElement = exports.isNodeEmpty = exports.isBlockElement = exports.getTagOfNode = exports.PendableFormatCommandMap = exports.getPendableFormatState = exports.getComputedStyle = exports.getComputedStyles = exports.fromHtml = exports.findClosestElementAncestor = exports.contains = exports.collapseNodes = exports.changeElementTag = exports.applyFormat = exports.getBrowserInfo = exports.Browser = exports.extractClipboardItemsForIE = exports.extractClipboardItems = exports.extractClipboardEvent = exports.applyTextStyle = exports.PartialInlineElement = exports.NodeInlineElement = exports.LinkInlineElement = exports.ImageInlineElement = exports.getInlineElementAtNode = exports.PositionContentSearcher = exports.ContentTraverser = exports.getFirstLastBlockElement = exports.getBlockElementAtNode = void 0;
|
|
12264
|
-
exports.
|
|
12265
|
-
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 = void 0;
|
|
12465
|
+
exports.getStyles = exports.isCtrlOrMetaPressed = exports.isCharacterValue = exports.isModifierKey = exports.clearEventDataCache = 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.isNodeAfter = void 0;
|
|
12466
|
+
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;
|
|
12266
12467
|
var getBlockElementAtNode_1 = __webpack_require__(/*! ./blockElements/getBlockElementAtNode */ "./packages/roosterjs-editor-dom/lib/blockElements/getBlockElementAtNode.ts");
|
|
12267
12468
|
Object.defineProperty(exports, "getBlockElementAtNode", { enumerable: true, get: function () { return getBlockElementAtNode_1.default; } });
|
|
12268
12469
|
var getFirstLastBlockElement_1 = __webpack_require__(/*! ./blockElements/getFirstLastBlockElement */ "./packages/roosterjs-editor-dom/lib/blockElements/getFirstLastBlockElement.ts");
|
|
@@ -12434,6 +12635,10 @@ var getEntityFromElement_1 = __webpack_require__(/*! ./entity/getEntityFromEleme
|
|
|
12434
12635
|
Object.defineProperty(exports, "getEntityFromElement", { enumerable: true, get: function () { return getEntityFromElement_1.default; } });
|
|
12435
12636
|
var getEntitySelector_1 = __webpack_require__(/*! ./entity/getEntitySelector */ "./packages/roosterjs-editor-dom/lib/entity/getEntitySelector.ts");
|
|
12436
12637
|
Object.defineProperty(exports, "getEntitySelector", { enumerable: true, get: function () { return getEntitySelector_1.default; } });
|
|
12638
|
+
var entityPlaceholderUtils_1 = __webpack_require__(/*! ./entity/entityPlaceholderUtils */ "./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts");
|
|
12639
|
+
Object.defineProperty(exports, "createEntityPlaceholder", { enumerable: true, get: function () { return entityPlaceholderUtils_1.createEntityPlaceholder; } });
|
|
12640
|
+
Object.defineProperty(exports, "moveContentWithEntityPlaceholders", { enumerable: true, get: function () { return entityPlaceholderUtils_1.moveContentWithEntityPlaceholders; } });
|
|
12641
|
+
Object.defineProperty(exports, "restoreContentWithEntityPlaceholder", { enumerable: true, get: function () { return entityPlaceholderUtils_1.restoreContentWithEntityPlaceholder; } });
|
|
12437
12642
|
var cacheGetEventData_1 = __webpack_require__(/*! ./event/cacheGetEventData */ "./packages/roosterjs-editor-dom/lib/event/cacheGetEventData.ts");
|
|
12438
12643
|
Object.defineProperty(exports, "cacheGetEventData", { enumerable: true, get: function () { return cacheGetEventData_1.default; } });
|
|
12439
12644
|
var clearEventDataCache_1 = __webpack_require__(/*! ./event/clearEventDataCache */ "./packages/roosterjs-editor-dom/lib/event/clearEventDataCache.ts");
|
|
@@ -12450,6 +12655,10 @@ var setStyles_1 = __webpack_require__(/*! ./style/setStyles */ "./packages/roost
|
|
|
12450
12655
|
Object.defineProperty(exports, "setStyles", { enumerable: true, get: function () { return setStyles_1.default; } });
|
|
12451
12656
|
var removeImportantStyleRule_1 = __webpack_require__(/*! ./style/removeImportantStyleRule */ "./packages/roosterjs-editor-dom/lib/style/removeImportantStyleRule.ts");
|
|
12452
12657
|
Object.defineProperty(exports, "removeImportantStyleRule", { enumerable: true, get: function () { return removeImportantStyleRule_1.default; } });
|
|
12658
|
+
var setGlobalCssStyles_1 = __webpack_require__(/*! ./style/setGlobalCssStyles */ "./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts");
|
|
12659
|
+
Object.defineProperty(exports, "setGlobalCssStyles", { enumerable: true, get: function () { return setGlobalCssStyles_1.default; } });
|
|
12660
|
+
var removeGlobalCssStyle_1 = __webpack_require__(/*! ./style/removeGlobalCssStyle */ "./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts");
|
|
12661
|
+
Object.defineProperty(exports, "removeGlobalCssStyle", { enumerable: true, get: function () { return removeGlobalCssStyle_1.default; } });
|
|
12453
12662
|
var adjustInsertPosition_1 = __webpack_require__(/*! ./edit/adjustInsertPosition */ "./packages/roosterjs-editor-dom/lib/edit/adjustInsertPosition.ts");
|
|
12454
12663
|
Object.defineProperty(exports, "adjustInsertPosition", { enumerable: true, get: function () { return adjustInsertPosition_1.default; } });
|
|
12455
12664
|
var deleteSelectedContent_1 = __webpack_require__(/*! ./edit/deleteSelectedContent */ "./packages/roosterjs-editor-dom/lib/edit/deleteSelectedContent.ts");
|
|
@@ -13810,6 +14019,17 @@ function createListChainName() {
|
|
|
13810
14019
|
|
|
13811
14020
|
"use strict";
|
|
13812
14021
|
|
|
14022
|
+
var __assign = (this && this.__assign) || function () {
|
|
14023
|
+
__assign = Object.assign || function(t) {
|
|
14024
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
14025
|
+
s = arguments[i];
|
|
14026
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
14027
|
+
t[p] = s[p];
|
|
14028
|
+
}
|
|
14029
|
+
return t;
|
|
14030
|
+
};
|
|
14031
|
+
return __assign.apply(this, arguments);
|
|
14032
|
+
};
|
|
13813
14033
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13814
14034
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
13815
14035
|
if (ar || !(i in from)) {
|
|
@@ -13823,6 +14043,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13823
14043
|
exports.ListStyleDefinitionMetadata = void 0;
|
|
13824
14044
|
var contains_1 = __webpack_require__(/*! ../utils/contains */ "./packages/roosterjs-editor-dom/lib/utils/contains.ts");
|
|
13825
14045
|
var getListTypeFromNode_1 = __webpack_require__(/*! ./getListTypeFromNode */ "./packages/roosterjs-editor-dom/lib/list/getListTypeFromNode.ts");
|
|
14046
|
+
var getStyles_1 = __webpack_require__(/*! ../style/getStyles */ "./packages/roosterjs-editor-dom/lib/style/getStyles.ts");
|
|
13826
14047
|
var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
|
|
13827
14048
|
var isBlockElement_1 = __webpack_require__(/*! ../utils/isBlockElement */ "./packages/roosterjs-editor-dom/lib/utils/isBlockElement.ts");
|
|
13828
14049
|
var moveChildNodes_1 = __webpack_require__(/*! ../utils/moveChildNodes */ "./packages/roosterjs-editor-dom/lib/utils/moveChildNodes.ts");
|
|
@@ -13830,6 +14051,7 @@ var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./pac
|
|
|
13830
14051
|
var setBulletListMarkers_1 = __webpack_require__(/*! ./setBulletListMarkers */ "./packages/roosterjs-editor-dom/lib/list/setBulletListMarkers.ts");
|
|
13831
14052
|
var setListItemStyle_1 = __webpack_require__(/*! ./setListItemStyle */ "./packages/roosterjs-editor-dom/lib/list/setListItemStyle.ts");
|
|
13832
14053
|
var setNumberingListMarkers_1 = __webpack_require__(/*! ./setNumberingListMarkers */ "./packages/roosterjs-editor-dom/lib/list/setNumberingListMarkers.ts");
|
|
14054
|
+
var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts");
|
|
13833
14055
|
var toArray_1 = __webpack_require__(/*! ../jsUtils/toArray */ "./packages/roosterjs-editor-dom/lib/jsUtils/toArray.ts");
|
|
13834
14056
|
var unwrap_1 = __webpack_require__(/*! ../utils/unwrap */ "./packages/roosterjs-editor-dom/lib/utils/unwrap.ts");
|
|
13835
14057
|
var wrap_1 = __webpack_require__(/*! ../utils/wrap */ "./packages/roosterjs-editor-dom/lib/utils/wrap.ts");
|
|
@@ -13839,6 +14061,8 @@ var orderListStyles = [null, 'lower-alpha', 'lower-roman'];
|
|
|
13839
14061
|
var unorderedListStyles = ['disc', 'circle', 'square'];
|
|
13840
14062
|
var MARGIN_BASE = '0in 0in 0in 0.5in';
|
|
13841
14063
|
var NEGATIVE_MARGIN = '-.25in';
|
|
14064
|
+
var stylesToInherit = ['font-size', 'font-family', 'color'];
|
|
14065
|
+
var attrsToInherit = ['data-ogsc', 'data-ogsb', 'data-ogac', 'data-ogab'];
|
|
13842
14066
|
/**
|
|
13843
14067
|
* @internal
|
|
13844
14068
|
* The definition for the number of BulletListType or NumberingListType
|
|
@@ -14037,6 +14261,7 @@ var VListItem = /** @class */ (function () {
|
|
|
14037
14261
|
* sure the direct parent of this list matches the list types when writing back.
|
|
14038
14262
|
*/
|
|
14039
14263
|
VListItem.prototype.writeBack = function (listStack, originalRoot, shouldReuseAllAncestorListElements) {
|
|
14264
|
+
var _this = this;
|
|
14040
14265
|
var _a;
|
|
14041
14266
|
if (shouldReuseAllAncestorListElements === void 0) { shouldReuseAllAncestorListElements = false; }
|
|
14042
14267
|
var nextLevel = 1;
|
|
@@ -14095,12 +14320,43 @@ var VListItem = /** @class */ (function () {
|
|
|
14095
14320
|
this.node.style.setProperty('display', this.dummy ? 'block' : null);
|
|
14096
14321
|
// 4. Inherit styles of the child element to the li, so we are able to apply the styles to the ::marker
|
|
14097
14322
|
if (this.listTypes.length > 1) {
|
|
14098
|
-
|
|
14099
|
-
(0, setListItemStyle_1.default)(this.node,
|
|
14323
|
+
(0, setListItemStyle_1.default)(this.node, stylesToInherit, true /*isCssStyle*/);
|
|
14324
|
+
(0, setListItemStyle_1.default)(this.node, attrsToInherit, false /*isCssStyle*/);
|
|
14100
14325
|
}
|
|
14101
14326
|
// 5. If this is not a list item now, need to unwrap the LI node and do proper handling
|
|
14102
14327
|
if (this.listTypes.length <= 1) {
|
|
14103
|
-
|
|
14328
|
+
// If original <LI> node has styles for font and color, we need to apply it to new parent
|
|
14329
|
+
var isLi = (0, getTagOfNode_1.default)(this.node) == 'LI';
|
|
14330
|
+
var stylesToApply = isLi
|
|
14331
|
+
? {
|
|
14332
|
+
'font-family': this.node.style.fontFamily,
|
|
14333
|
+
'font-size': this.node.style.fontSize,
|
|
14334
|
+
color: this.node.style.color,
|
|
14335
|
+
}
|
|
14336
|
+
: undefined;
|
|
14337
|
+
var childNodes = isLi ? getChildrenAndUnwrap(this.node) : [this.node];
|
|
14338
|
+
if (stylesToApply) {
|
|
14339
|
+
var _loop_1 = function (i) {
|
|
14340
|
+
if ((0, safeInstanceOf_1.default)(childNodes[i], 'Text')) {
|
|
14341
|
+
childNodes[i] = (0, wrap_1.default)(childNodes[i], 'span');
|
|
14342
|
+
}
|
|
14343
|
+
var node = childNodes[i];
|
|
14344
|
+
if ((0, safeInstanceOf_1.default)(node, 'HTMLElement')) {
|
|
14345
|
+
var styles = __assign(__assign({}, stylesToApply), (0, getStyles_1.default)(node));
|
|
14346
|
+
(0, setStyles_1.default)(node, styles);
|
|
14347
|
+
attrsToInherit.forEach(function (attr) {
|
|
14348
|
+
var attrValue = _this.node.getAttribute(attr);
|
|
14349
|
+
if (attrValue) {
|
|
14350
|
+
node.setAttribute(attr, attrValue);
|
|
14351
|
+
}
|
|
14352
|
+
});
|
|
14353
|
+
}
|
|
14354
|
+
};
|
|
14355
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
14356
|
+
_loop_1(i);
|
|
14357
|
+
}
|
|
14358
|
+
}
|
|
14359
|
+
wrapIfNotBlockNode(childNodes, true /*checkFirst*/, true /*checkLast*/);
|
|
14104
14360
|
}
|
|
14105
14361
|
};
|
|
14106
14362
|
/**
|
|
@@ -14547,18 +14803,17 @@ var bulletListStyle = (_a = {},
|
|
|
14547
14803
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14548
14804
|
var ContentTraverser_1 = __webpack_require__(/*! ../contentTraverser/ContentTraverser */ "./packages/roosterjs-editor-dom/lib/contentTraverser/ContentTraverser.ts");
|
|
14549
14805
|
var findClosestElementAncestor_1 = __webpack_require__(/*! ../utils/findClosestElementAncestor */ "./packages/roosterjs-editor-dom/lib/utils/findClosestElementAncestor.ts");
|
|
14550
|
-
var getStyles_1 = __webpack_require__(/*! ../style/getStyles */ "./packages/roosterjs-editor-dom/lib/style/getStyles.ts");
|
|
14551
14806
|
var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
|
|
14552
|
-
var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts");
|
|
14553
14807
|
/**
|
|
14554
14808
|
* Set the Style of a List Item provided, with the styles that the inline child elements have
|
|
14555
14809
|
* If the child inline elements have different styles, it will not modify the styles of the list item
|
|
14556
14810
|
* @param element the LI Element to set the styles
|
|
14557
14811
|
* @param styles The styles that should be applied to the element.
|
|
14812
|
+
* @param isCssStyle True means the given styles are CSS style names, false means they are HTML attributes @default true
|
|
14558
14813
|
*/
|
|
14559
|
-
function setListItemStyle(element, styles) {
|
|
14560
|
-
|
|
14561
|
-
var
|
|
14814
|
+
function setListItemStyle(element, styles, isCssStyle) {
|
|
14815
|
+
if (isCssStyle === void 0) { isCssStyle = true; }
|
|
14816
|
+
var elementsStyles = getInlineChildElementsStyle(element, styles, isCssStyle);
|
|
14562
14817
|
styles.forEach(function (styleName) {
|
|
14563
14818
|
var styleValues = elementsStyles.map(function (style) {
|
|
14564
14819
|
return style[styleName] !== undefined ? style[styleName] : '';
|
|
@@ -14566,39 +14821,53 @@ function setListItemStyle(element, styles) {
|
|
|
14566
14821
|
if (styleValues &&
|
|
14567
14822
|
(styleValues.length == 1 || new Set(styleValues).size == 1) &&
|
|
14568
14823
|
styleValues[0]) {
|
|
14569
|
-
|
|
14824
|
+
if (isCssStyle) {
|
|
14825
|
+
element.style.setProperty(styleName, styleValues[0]);
|
|
14826
|
+
}
|
|
14827
|
+
else {
|
|
14828
|
+
element.setAttribute(styleName, styleValues[0]);
|
|
14829
|
+
}
|
|
14570
14830
|
}
|
|
14571
14831
|
});
|
|
14572
|
-
(0, setStyles_1.default)(element, stylesToApply);
|
|
14573
14832
|
}
|
|
14574
14833
|
exports.default = setListItemStyle;
|
|
14575
|
-
function getInlineChildElementsStyle(element, styles) {
|
|
14576
|
-
var _a;
|
|
14834
|
+
function getInlineChildElementsStyle(element, styles, isCssStyle) {
|
|
14835
|
+
var _a, _b;
|
|
14577
14836
|
var result = [];
|
|
14578
14837
|
var contentTraverser = ContentTraverser_1.default.createBodyTraverser(element);
|
|
14579
14838
|
var currentInlineElement = null;
|
|
14580
14839
|
var _loop_1 = function () {
|
|
14581
14840
|
currentInlineElement = contentTraverser.currentInlineElement;
|
|
14582
14841
|
var currentNode = (currentInlineElement === null || currentInlineElement === void 0 ? void 0 : currentInlineElement.getContainerNode()) || null;
|
|
14583
|
-
var currentStyle =
|
|
14842
|
+
var currentStyle = null;
|
|
14584
14843
|
currentNode = currentNode ? (0, findClosestElementAncestor_1.default)(currentNode) : null;
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
while (currentNode &&
|
|
14588
|
-
currentNode !== element &&
|
|
14589
|
-
(0, safeInstanceOf_1.default)(currentNode, 'HTMLElement')) {
|
|
14844
|
+
var _loop_2 = function () {
|
|
14845
|
+
var element_1 = currentNode;
|
|
14590
14846
|
styles.forEach(function (styleName) {
|
|
14591
|
-
var styleValue =
|
|
14847
|
+
var styleValue = isCssStyle
|
|
14848
|
+
? element_1.style.getPropertyValue(styleName)
|
|
14849
|
+
: element_1.getAttribute(styleName);
|
|
14850
|
+
if (!currentStyle) {
|
|
14851
|
+
currentStyle = {};
|
|
14852
|
+
}
|
|
14592
14853
|
if (styleValue && !currentStyle[styleName]) {
|
|
14593
14854
|
currentStyle[styleName] = styleValue;
|
|
14594
14855
|
}
|
|
14595
14856
|
});
|
|
14596
|
-
if (((
|
|
14857
|
+
if (((_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.childNodes.length) === 1) {
|
|
14597
14858
|
currentNode = currentNode.parentNode;
|
|
14598
14859
|
}
|
|
14599
14860
|
else {
|
|
14600
14861
|
currentNode = null;
|
|
14601
14862
|
}
|
|
14863
|
+
};
|
|
14864
|
+
// we should consider of when it is the single child node of element, the parentNode's style should add
|
|
14865
|
+
// such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
|
|
14866
|
+
while (currentNode &&
|
|
14867
|
+
currentNode !== element &&
|
|
14868
|
+
(0, safeInstanceOf_1.default)(currentNode, 'HTMLElement') &&
|
|
14869
|
+
(result.length == 0 || (((_a = currentNode.textContent) === null || _a === void 0 ? void 0 : _a.trim().length) || 0) > 0)) {
|
|
14870
|
+
_loop_2();
|
|
14602
14871
|
}
|
|
14603
14872
|
if (currentStyle) {
|
|
14604
14873
|
result.push(currentStyle);
|
|
@@ -16303,6 +16572,33 @@ function getStyles(element) {
|
|
|
16303
16572
|
exports.default = getStyles;
|
|
16304
16573
|
|
|
16305
16574
|
|
|
16575
|
+
/***/ }),
|
|
16576
|
+
|
|
16577
|
+
/***/ "./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts":
|
|
16578
|
+
/*!*************************************************************************!*\
|
|
16579
|
+
!*** ./packages/roosterjs-editor-dom/lib/style/removeGlobalCssStyle.ts ***!
|
|
16580
|
+
\*************************************************************************/
|
|
16581
|
+
/*! no static exports found */
|
|
16582
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
16583
|
+
|
|
16584
|
+
"use strict";
|
|
16585
|
+
|
|
16586
|
+
/**
|
|
16587
|
+
* Remove a css rule style from a style sheet
|
|
16588
|
+
* @param doc The document object
|
|
16589
|
+
* @param styleId the ID of the style tag
|
|
16590
|
+
*/
|
|
16591
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16592
|
+
function removeGlobalCssStyle(doc, styleId) {
|
|
16593
|
+
var _a;
|
|
16594
|
+
var styleTag = doc.getElementById(styleId);
|
|
16595
|
+
if (styleTag) {
|
|
16596
|
+
(_a = styleTag.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(styleTag);
|
|
16597
|
+
}
|
|
16598
|
+
}
|
|
16599
|
+
exports.default = removeGlobalCssStyle;
|
|
16600
|
+
|
|
16601
|
+
|
|
16306
16602
|
/***/ }),
|
|
16307
16603
|
|
|
16308
16604
|
/***/ "./packages/roosterjs-editor-dom/lib/style/removeImportantStyleRule.ts":
|
|
@@ -16340,6 +16636,38 @@ function removeImportantStyleRule(element, styleProperties) {
|
|
|
16340
16636
|
exports.default = removeImportantStyleRule;
|
|
16341
16637
|
|
|
16342
16638
|
|
|
16639
|
+
/***/ }),
|
|
16640
|
+
|
|
16641
|
+
/***/ "./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts":
|
|
16642
|
+
/*!***********************************************************************!*\
|
|
16643
|
+
!*** ./packages/roosterjs-editor-dom/lib/style/setGlobalCssStyles.ts ***!
|
|
16644
|
+
\***********************************************************************/
|
|
16645
|
+
/*! no static exports found */
|
|
16646
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
16647
|
+
|
|
16648
|
+
"use strict";
|
|
16649
|
+
|
|
16650
|
+
/**
|
|
16651
|
+
* Add global css styles
|
|
16652
|
+
* @param doc The document object
|
|
16653
|
+
* @param cssRule The css rule that must added to the selection
|
|
16654
|
+
* @param editorId Te id of the editor
|
|
16655
|
+
* @param styleId the ID of the style tag
|
|
16656
|
+
*/
|
|
16657
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16658
|
+
function setGlobalCssStyles(doc, cssRule, styleId) {
|
|
16659
|
+
var _a;
|
|
16660
|
+
var styleTag = doc.getElementById(styleId);
|
|
16661
|
+
if (!styleTag) {
|
|
16662
|
+
styleTag = doc.createElement('style');
|
|
16663
|
+
styleTag.id = styleId;
|
|
16664
|
+
doc.head.appendChild(styleTag);
|
|
16665
|
+
}
|
|
16666
|
+
(_a = styleTag.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssRule);
|
|
16667
|
+
}
|
|
16668
|
+
exports.default = setGlobalCssStyles;
|
|
16669
|
+
|
|
16670
|
+
|
|
16343
16671
|
/***/ }),
|
|
16344
16672
|
|
|
16345
16673
|
/***/ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts":
|
|
@@ -17907,7 +18235,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17907
18235
|
exports.KnownCreateElementData = void 0;
|
|
17908
18236
|
var getObjectKeys_1 = __webpack_require__(/*! ../jsUtils/getObjectKeys */ "./packages/roosterjs-editor-dom/lib/jsUtils/getObjectKeys.ts");
|
|
17909
18237
|
var safeInstanceOf_1 = __webpack_require__(/*! ./safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
|
|
17910
|
-
var Browser_1 = __webpack_require__(/*! ./Browser */ "./packages/roosterjs-editor-dom/lib/utils/Browser.ts");
|
|
17911
18238
|
/**
|
|
17912
18239
|
* All known CreateElementData used by roosterjs to create elements
|
|
17913
18240
|
*/
|
|
@@ -17915,9 +18242,10 @@ exports.KnownCreateElementData = (_a = {},
|
|
|
17915
18242
|
_a[0 /* None */] = { tag: '' },
|
|
17916
18243
|
// Edge can sometimes lose current format when Enter to new line.
|
|
17917
18244
|
// So here we add an extra SPAN for Edge to workaround this bug
|
|
17918
|
-
_a[1 /* EmptyLine */] =
|
|
17919
|
-
|
|
17920
|
-
: { tag: '
|
|
18245
|
+
_a[1 /* EmptyLine */] = {
|
|
18246
|
+
tag: 'div',
|
|
18247
|
+
children: [{ tag: 'span', children: [{ tag: 'br' }] }],
|
|
18248
|
+
},
|
|
17921
18249
|
_a[2 /* BlockquoteWrapper */] = {
|
|
17922
18250
|
tag: 'blockquote',
|
|
17923
18251
|
style: 'margin-top:0;margin-bottom:0',
|
|
@@ -17935,8 +18263,14 @@ exports.KnownCreateElementData = (_a = {},
|
|
|
17935
18263
|
style: 'position: fixed; width: 0; height: 0',
|
|
17936
18264
|
},
|
|
17937
18265
|
_a[6 /* ImageEditWrapper */] = {
|
|
17938
|
-
tag: '
|
|
17939
|
-
style: 'width:100%;
|
|
18266
|
+
tag: 'span',
|
|
18267
|
+
style: 'max-width:100%;position:fixed',
|
|
18268
|
+
children: [
|
|
18269
|
+
{
|
|
18270
|
+
tag: 'div',
|
|
18271
|
+
style: 'width:100%;height:100%;position:relative;overflow:hidden',
|
|
18272
|
+
},
|
|
18273
|
+
],
|
|
17940
18274
|
},
|
|
17941
18275
|
_a[7 /* TableHorizontalResizer */] = {
|
|
17942
18276
|
tag: 'div',
|
|
@@ -19513,31 +19847,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19513
19847
|
__exportStar(__webpack_require__(/*! ./plugins/ImageResize/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageResize/index.ts"), exports);
|
|
19514
19848
|
|
|
19515
19849
|
|
|
19516
|
-
/***/ }),
|
|
19517
|
-
|
|
19518
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts":
|
|
19519
|
-
/*!*****************************************************************!*\
|
|
19520
|
-
!*** ./packages/roosterjs-editor-plugins/lib/ImageSelection.ts ***!
|
|
19521
|
-
\*****************************************************************/
|
|
19522
|
-
/*! no static exports found */
|
|
19523
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
19524
|
-
|
|
19525
|
-
"use strict";
|
|
19526
|
-
|
|
19527
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19528
|
-
if (k2 === undefined) k2 = k;
|
|
19529
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
19530
|
-
}) : (function(o, m, k, k2) {
|
|
19531
|
-
if (k2 === undefined) k2 = k;
|
|
19532
|
-
o[k2] = m[k];
|
|
19533
|
-
}));
|
|
19534
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19535
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19536
|
-
};
|
|
19537
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19538
|
-
__exportStar(__webpack_require__(/*! ./plugins/ImageSelection/index */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts"), exports);
|
|
19539
|
-
|
|
19540
|
-
|
|
19541
19850
|
/***/ }),
|
|
19542
19851
|
|
|
19543
19852
|
/***/ "./packages/roosterjs-editor-plugins/lib/Paste.ts":
|
|
@@ -19698,7 +20007,6 @@ __exportStar(__webpack_require__(/*! ./TableResize */ "./packages/roosterjs-edit
|
|
|
19698
20007
|
__exportStar(__webpack_require__(/*! ./Watermark */ "./packages/roosterjs-editor-plugins/lib/Watermark.ts"), exports);
|
|
19699
20008
|
__exportStar(__webpack_require__(/*! ./TableCellSelection */ "./packages/roosterjs-editor-plugins/lib/TableCellSelection.ts"), exports);
|
|
19700
20009
|
__exportStar(__webpack_require__(/*! ./AutoFormat */ "./packages/roosterjs-editor-plugins/lib/AutoFormat.ts"), exports);
|
|
19701
|
-
__exportStar(__webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/ImageSelection.ts"), exports);
|
|
19702
20010
|
|
|
19703
20011
|
|
|
19704
20012
|
/***/ }),
|
|
@@ -20359,6 +20667,8 @@ var getAutoBulletListStyle_1 = __webpack_require__(/*! ../utils/getAutoBulletLis
|
|
|
20359
20667
|
var getAutoNumberingListStyle_1 = __webpack_require__(/*! ../utils/getAutoNumberingListStyle */ "./packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/utils/getAutoNumberingListStyle.ts");
|
|
20360
20668
|
var roosterjs_editor_api_1 = __webpack_require__(/*! roosterjs-editor-api */ "./packages/roosterjs-editor-api/lib/index.ts");
|
|
20361
20669
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
20670
|
+
var PREVIOUS_BLOCK_CACHE_KEY = 'previousBlock';
|
|
20671
|
+
var NEXT_BLOCK_CACHE_KEY = 'nextBlock';
|
|
20362
20672
|
var ListStyleDefinitionMetadata = (0, roosterjs_editor_dom_1.createObjectDefinition)({
|
|
20363
20673
|
orderedStyleType: (0, roosterjs_editor_dom_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 20 /* Max */),
|
|
20364
20674
|
unorderedStyleType: (0, roosterjs_editor_dom_1.createNumberDefinition)(true /** isOptional */, undefined /** value **/, 1 /* Min */, 9 /* Max */),
|
|
@@ -20588,10 +20898,10 @@ var AutoNumberingList = {
|
|
|
20588
20898
|
},
|
|
20589
20899
|
};
|
|
20590
20900
|
var getPreviousListItem = function (editor, textRange) {
|
|
20591
|
-
var
|
|
20592
|
-
var previousNode = (_a = editor
|
|
20901
|
+
var blockElement = editor
|
|
20593
20902
|
.getBodyTraverser(textRange === null || textRange === void 0 ? void 0 : textRange.startContainer)
|
|
20594
|
-
.getPreviousBlockElement()
|
|
20903
|
+
.getPreviousBlockElement();
|
|
20904
|
+
var previousNode = blockElement === null || blockElement === void 0 ? void 0 : blockElement.getEndNode();
|
|
20595
20905
|
return (0, roosterjs_editor_dom_1.getTagOfNode)(previousNode) === 'LI' ? previousNode : undefined;
|
|
20596
20906
|
};
|
|
20597
20907
|
var getPreviousListType = function (editor, textRange, listType) {
|
|
@@ -20693,6 +21003,57 @@ function shouldTriggerList(event, editor, getListStyle, listType) {
|
|
|
20693
21003
|
listStyle &&
|
|
20694
21004
|
shouldTriggerNewListStyle);
|
|
20695
21005
|
}
|
|
21006
|
+
/**
|
|
21007
|
+
* MergeListOnBackspaceAfterList edit feature, provides the ability to merge list on backspace on block after a list.
|
|
21008
|
+
*/
|
|
21009
|
+
var MergeListOnBackspaceAfterList = {
|
|
21010
|
+
keys: [8 /* BACKSPACE */],
|
|
21011
|
+
shouldHandleEvent: function (event, editor) {
|
|
21012
|
+
var _a, _b;
|
|
21013
|
+
var target = editor.getElementAtCursor();
|
|
21014
|
+
if (target) {
|
|
21015
|
+
var cursorBlock = (_a = editor.getBlockElementAtNode(target)) === null || _a === void 0 ? void 0 : _a.getStartNode();
|
|
21016
|
+
var previousBlock_1 = (_b = cursorBlock === null || cursorBlock === void 0 ? void 0 : cursorBlock.previousElementSibling) !== null && _b !== void 0 ? _b : null;
|
|
21017
|
+
if (isList(previousBlock_1)) {
|
|
21018
|
+
var range = editor.getSelectionRange();
|
|
21019
|
+
var searcher = editor.getContentSearcherOfCursor(event);
|
|
21020
|
+
var textBeforeCursor = searcher === null || searcher === void 0 ? void 0 : searcher.getSubStringBefore(4);
|
|
21021
|
+
var nearestInline = searcher === null || searcher === void 0 ? void 0 : searcher.getNearestNonTextInlineElement();
|
|
21022
|
+
if (range && range.collapsed && textBeforeCursor === '' && !nearestInline) {
|
|
21023
|
+
var tempBlock = cursorBlock === null || cursorBlock === void 0 ? void 0 : cursorBlock.nextElementSibling;
|
|
21024
|
+
var nextBlock_1 = isList(tempBlock) ? tempBlock : tempBlock === null || tempBlock === void 0 ? void 0 : tempBlock.firstChild;
|
|
21025
|
+
if (isList(nextBlock_1) &&
|
|
21026
|
+
(0, roosterjs_editor_dom_1.getTagOfNode)(previousBlock_1) == (0, roosterjs_editor_dom_1.getTagOfNode)(nextBlock_1)) {
|
|
21027
|
+
var element = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, PREVIOUS_BLOCK_CACHE_KEY, function () { return previousBlock_1; });
|
|
21028
|
+
var nextElement = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, NEXT_BLOCK_CACHE_KEY, function () { return nextBlock_1; });
|
|
21029
|
+
return !!element && !!nextElement;
|
|
21030
|
+
}
|
|
21031
|
+
}
|
|
21032
|
+
}
|
|
21033
|
+
}
|
|
21034
|
+
return false;
|
|
21035
|
+
},
|
|
21036
|
+
handleEvent: function (event, editor) {
|
|
21037
|
+
editor.runAsync(function (editor) {
|
|
21038
|
+
var previousList = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, PREVIOUS_BLOCK_CACHE_KEY, function () { return null; });
|
|
21039
|
+
var targetBlock = (0, roosterjs_editor_dom_1.cacheGetEventData)(event, NEXT_BLOCK_CACHE_KEY, function () { return null; });
|
|
21040
|
+
var rangeBeforeWriteBack = editor.getSelectionRange();
|
|
21041
|
+
if (previousList && targetBlock && rangeBeforeWriteBack) {
|
|
21042
|
+
var fvList = new roosterjs_editor_dom_1.VList(previousList);
|
|
21043
|
+
fvList.mergeVList(new roosterjs_editor_dom_1.VList(targetBlock));
|
|
21044
|
+
var span = editor.getDocument().createElement('span');
|
|
21045
|
+
span.id = 'restoreRange';
|
|
21046
|
+
rangeBeforeWriteBack.insertNode(span);
|
|
21047
|
+
fvList.writeBack();
|
|
21048
|
+
span = editor.queryElements('#restoreRange')[0];
|
|
21049
|
+
if (span.parentElement) {
|
|
21050
|
+
editor.select(new roosterjs_editor_dom_1.Position(span, -3 /* After */));
|
|
21051
|
+
span.parentElement.removeChild(span);
|
|
21052
|
+
}
|
|
21053
|
+
}
|
|
21054
|
+
});
|
|
21055
|
+
},
|
|
21056
|
+
};
|
|
20696
21057
|
/**
|
|
20697
21058
|
* @internal
|
|
20698
21059
|
*/
|
|
@@ -20707,7 +21068,12 @@ exports.ListFeatures = {
|
|
|
20707
21068
|
maintainListChainWhenDelete: MaintainListChainWhenDelete,
|
|
20708
21069
|
autoNumberingList: AutoNumberingList,
|
|
20709
21070
|
autoBulletList: AutoBulletList,
|
|
21071
|
+
mergeListOnBackspaceAfterList: MergeListOnBackspaceAfterList,
|
|
20710
21072
|
};
|
|
21073
|
+
function isList(element) {
|
|
21074
|
+
return (!!element &&
|
|
21075
|
+
((0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLOListElement') || (0, roosterjs_editor_dom_1.safeInstanceOf)(element, 'HTMLUListElement')));
|
|
21076
|
+
}
|
|
20711
21077
|
|
|
20712
21078
|
|
|
20713
21079
|
/***/ }),
|
|
@@ -21655,10 +22021,24 @@ function getAutoNumberingListStyle(textBeforeCursor, previousListChain, previous
|
|
|
21655
22021
|
}
|
|
21656
22022
|
}
|
|
21657
22023
|
var isDoubleParenthesis = trigger[0] === '(' && trigger[trigger.length - 1] === ')';
|
|
21658
|
-
var numberingType =
|
|
22024
|
+
var numberingType = isValidNumbering(trigger, isDoubleParenthesis)
|
|
22025
|
+
? identifyNumberingListType(trigger, isDoubleParenthesis, previousListStyle)
|
|
22026
|
+
: null;
|
|
21659
22027
|
return numberingType;
|
|
21660
22028
|
}
|
|
21661
22029
|
exports.default = getAutoNumberingListStyle;
|
|
22030
|
+
/**
|
|
22031
|
+
* Check if index has only numbers or only letters to avoid sequence of character such 1:1. trigger a list.
|
|
22032
|
+
* @param textBeforeCursor
|
|
22033
|
+
* @param isDoubleParenthesis
|
|
22034
|
+
* @returns
|
|
22035
|
+
*/
|
|
22036
|
+
function isValidNumbering(textBeforeCursor, isDoubleParenthesis) {
|
|
22037
|
+
var index = isDoubleParenthesis
|
|
22038
|
+
? textBeforeCursor.slice(1, -1)
|
|
22039
|
+
: textBeforeCursor.slice(0, -1);
|
|
22040
|
+
return Number(index) || /^[A-Za-z\s]*$/.test(index);
|
|
22041
|
+
}
|
|
21662
22042
|
|
|
21663
22043
|
|
|
21664
22044
|
/***/ }),
|
|
@@ -22312,12 +22692,8 @@ var getGeneratedImageSize_1 = __webpack_require__(/*! ./editInfoUtils/getGenerat
|
|
|
22312
22692
|
var Cropper_1 = __webpack_require__(/*! ./imageEditors/Cropper */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Cropper.ts");
|
|
22313
22693
|
var editInfo_1 = __webpack_require__(/*! ./editInfoUtils/editInfo */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/editInfo.ts");
|
|
22314
22694
|
var Rotator_1 = __webpack_require__(/*! ./imageEditors/Rotator */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Rotator.ts");
|
|
22315
|
-
var roosterjs_editor_api_1 = __webpack_require__(/*! roosterjs-editor-api */ "./packages/roosterjs-editor-api/lib/index.ts");
|
|
22316
22695
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
22317
22696
|
var Resizer_1 = __webpack_require__(/*! ./imageEditors/Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
|
|
22318
|
-
var SHIFT_KEYCODE = 16;
|
|
22319
|
-
var CTRL_KEYCODE = 17;
|
|
22320
|
-
var ALT_KEYCODE = 18;
|
|
22321
22697
|
var DIRECTIONS = 8;
|
|
22322
22698
|
var DirectionRad = (Math.PI * 2) / DIRECTIONS;
|
|
22323
22699
|
var DirectionOrder = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
|
|
@@ -22346,10 +22722,6 @@ var ImageEditHTMLMap = (_a = {},
|
|
|
22346
22722
|
_a[4 /* Rotate */] = Rotator_1.getRotateHTML,
|
|
22347
22723
|
_a[8 /* Crop */] = Cropper_1.getCropHTML,
|
|
22348
22724
|
_a);
|
|
22349
|
-
/**
|
|
22350
|
-
* Image edit entity name
|
|
22351
|
-
*/
|
|
22352
|
-
var IMAGE_EDIT_WRAPPER_ENTITY_TYPE = 'IMAGE_EDIT_WRAPPER';
|
|
22353
22725
|
/**
|
|
22354
22726
|
* Default background colors for rotate handle
|
|
22355
22727
|
*/
|
|
@@ -22377,35 +22749,31 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22377
22749
|
* quit editing mode when editor lose focus
|
|
22378
22750
|
*/
|
|
22379
22751
|
this.onBlur = function () {
|
|
22380
|
-
_this.setEditingImage(null);
|
|
22752
|
+
_this.setEditingImage(null, true);
|
|
22381
22753
|
};
|
|
22382
22754
|
/**
|
|
22383
22755
|
* Remove the temp wrapper of the image
|
|
22384
|
-
* @param wrapper The wrapper object to remove. If not specified, remove all existing wrappers.
|
|
22385
22756
|
*/
|
|
22386
|
-
this.removeWrapper = function (
|
|
22387
|
-
var
|
|
22388
|
-
var
|
|
22389
|
-
if (
|
|
22390
|
-
|
|
22391
|
-
|
|
22392
|
-
img.style.textAlign = null;
|
|
22393
|
-
parent.insertBefore(img, wrapper);
|
|
22394
|
-
parent.removeChild(wrapper);
|
|
22757
|
+
this.removeWrapper = function () {
|
|
22758
|
+
var _a, _b;
|
|
22759
|
+
var doc = _this.editor.getDocument();
|
|
22760
|
+
if (_this.zoomWrapper && ((_a = doc.body) === null || _a === void 0 ? void 0 : _a.contains(_this.zoomWrapper))) {
|
|
22761
|
+
(_b = doc.body) === null || _b === void 0 ? void 0 : _b.removeChild(_this.zoomWrapper);
|
|
22762
|
+
_this.toggleImageVisibility(_this.image, true /** showImage */);
|
|
22395
22763
|
}
|
|
22764
|
+
_this.wrapper = null;
|
|
22765
|
+
_this.zoomWrapper = null;
|
|
22396
22766
|
};
|
|
22397
22767
|
/**
|
|
22398
22768
|
* Update image edit elements to reflect current editing result
|
|
22399
22769
|
* @param context
|
|
22400
22770
|
*/
|
|
22401
22771
|
this.updateWrapper = function (context) {
|
|
22402
|
-
var wrapper = _this.
|
|
22772
|
+
var wrapper = _this.wrapper;
|
|
22403
22773
|
if (wrapper) {
|
|
22404
22774
|
// Prepare: get related editing elements
|
|
22405
22775
|
var cropContainers = getEditElements(wrapper, "r_cropC" /* CropContainer */);
|
|
22406
22776
|
var cropOverlays = getEditElements(wrapper, "r_cropO" /* CropOverlay */);
|
|
22407
|
-
var rotateCenter = getEditElements(wrapper, "r_rotateC" /* RotateCenter */)[0];
|
|
22408
|
-
var rotateHandle = getEditElements(wrapper, "r_rotateH" /* RotateHandle */)[0];
|
|
22409
22777
|
var resizeHandles = getEditElements(wrapper, "r_resizeH" /* ResizeHandle */);
|
|
22410
22778
|
var cropHandles = getEditElements(wrapper, "r_cropH" /* CropHandle */);
|
|
22411
22779
|
// Cropping and resizing will show different UI, so check if it is cropping here first
|
|
@@ -22424,12 +22792,14 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22424
22792
|
wrapper.style.height = getPx(visibleHeight);
|
|
22425
22793
|
wrapper.style.margin = marginVertical + "px " + marginHorizontal + "px";
|
|
22426
22794
|
wrapper.style.transform = "rotate(" + angleRad + "rad)";
|
|
22795
|
+
_this.zoomWrapper.style.width = getPx(visibleWidth);
|
|
22796
|
+
_this.zoomWrapper.style.height = getPx(visibleHeight);
|
|
22427
22797
|
// Update the text-alignment to avoid the image to overflow if the parent element have align center or right
|
|
22428
22798
|
// or if the direction is Right To Left
|
|
22429
22799
|
wrapper.style.textAlign = isRtl(wrapper.parentNode) ? 'right' : 'left';
|
|
22430
22800
|
// Update size of the image
|
|
22431
|
-
_this.
|
|
22432
|
-
_this.
|
|
22801
|
+
_this.clonedImage.style.width = getPx(originalWidth);
|
|
22802
|
+
_this.clonedImage.style.height = getPx(originalHeight);
|
|
22433
22803
|
if (isCropping) {
|
|
22434
22804
|
// For crop, we also need to set position of the overlays
|
|
22435
22805
|
setSize(cropContainers[0], cropLeftPx, cropTopPx, cropRightPx, cropBottomPx, undefined, undefined);
|
|
@@ -22441,7 +22811,7 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22441
22811
|
}
|
|
22442
22812
|
else {
|
|
22443
22813
|
// For rotate/resize, set the margin of the image so that cropped part won't be visible
|
|
22444
|
-
_this.
|
|
22814
|
+
_this.clonedImage.style.margin = -cropTopPx + "px 0 0 " + -cropLeftPx + "px";
|
|
22445
22815
|
// Double check resize
|
|
22446
22816
|
if ((context === null || context === void 0 ? void 0 : context.elementClass) == "r_resizeH" /* ResizeHandle */) {
|
|
22447
22817
|
var clientWidth = wrapper.clientWidth;
|
|
@@ -22450,7 +22820,6 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22450
22820
|
(0, Resizer_1.doubleCheckResize)(_this.editInfo, _this.options.preserveRatio, clientWidth, clientHeight);
|
|
22451
22821
|
_this.updateWrapper();
|
|
22452
22822
|
}
|
|
22453
|
-
(0, Rotator_1.updateRotateHandlePosition)(_this.editInfo, _this.editor.getRelativeDistanceToEditor(wrapper, true /*addScroll*/), marginVertical, rotateCenter, rotateHandle);
|
|
22454
22823
|
updateHandleCursor(resizeHandles, angleRad);
|
|
22455
22824
|
}
|
|
22456
22825
|
}
|
|
@@ -22487,56 +22856,26 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22487
22856
|
};
|
|
22488
22857
|
/**
|
|
22489
22858
|
* Handle events triggered from editor
|
|
22490
|
-
* @param
|
|
22859
|
+
* @param e PluginEvent object
|
|
22491
22860
|
*/
|
|
22492
22861
|
ImageEdit.prototype.onPluginEvent = function (e) {
|
|
22493
22862
|
switch (e.eventType) {
|
|
22863
|
+
case 22 /* SelectionChanged */:
|
|
22864
|
+
if (e.selectionRangeEx &&
|
|
22865
|
+
e.selectionRangeEx.type === 2 /* ImageSelection */) {
|
|
22866
|
+
this.setEditingImage(e.selectionRangeEx.image, 7 /* ResizeAndRotate */);
|
|
22867
|
+
}
|
|
22868
|
+
break;
|
|
22494
22869
|
case 5 /* MouseDown */:
|
|
22495
22870
|
this.setEditingImage(null);
|
|
22496
22871
|
break;
|
|
22497
|
-
case 6 /* MouseUp */:
|
|
22498
|
-
var target = e.rawEvent.target;
|
|
22499
|
-
if (e.isClicking &&
|
|
22500
|
-
e.rawEvent.button == 0 &&
|
|
22501
|
-
(0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement') &&
|
|
22502
|
-
target.isContentEditable &&
|
|
22503
|
-
(0, roosterjs_editor_dom_1.matchesSelector)(target, this.options.imageSelector)) {
|
|
22504
|
-
this.setEditingImage(target, 7 /* ResizeAndRotate */);
|
|
22505
|
-
}
|
|
22506
|
-
break;
|
|
22507
22872
|
case 0 /* KeyDown */:
|
|
22508
|
-
|
|
22509
|
-
if (key == 46 /* DELETE */ || key == 8 /* BACKSPACE */) {
|
|
22510
|
-
// Set current editing image to null and select the image if any, and do not prevent default of the event
|
|
22511
|
-
// so that browser will delete the selected image for us
|
|
22512
|
-
this.setEditingImage(null, true /*selectImage*/);
|
|
22513
|
-
}
|
|
22514
|
-
else if (key == 27 /* ESCAPE */ && this.image) {
|
|
22515
|
-
// Press ESC should cancel current editing operation, resume back to original edit info
|
|
22516
|
-
this.editInfo = (0, editInfo_1.getEditInfoFromImage)(this.image);
|
|
22517
|
-
this.setEditingImage(null);
|
|
22518
|
-
e.rawEvent.preventDefault();
|
|
22519
|
-
}
|
|
22520
|
-
else if (key != SHIFT_KEYCODE && key != CTRL_KEYCODE && key != ALT_KEYCODE) {
|
|
22521
|
-
// For other key, just unselect current image and select it. If this is an input key, the image will be replaced
|
|
22522
|
-
this.setEditingImage(null, true /*selectImage*/);
|
|
22523
|
-
}
|
|
22873
|
+
this.setEditingImage(null);
|
|
22524
22874
|
break;
|
|
22525
22875
|
case 7 /* ContentChanged */:
|
|
22526
|
-
if (e.source
|
|
22527
|
-
e.data.type != IMAGE_EDIT_WRAPPER_ENTITY_TYPE) {
|
|
22876
|
+
if (e.source !== "Format" /* Format */) {
|
|
22528
22877
|
// After contentChanged event, the current image wrapper may not be valid any more, remove all of them if any
|
|
22529
|
-
this.
|
|
22530
|
-
}
|
|
22531
|
-
break;
|
|
22532
|
-
case 15 /* EntityOperation */:
|
|
22533
|
-
if (e.entity.type == IMAGE_EDIT_WRAPPER_ENTITY_TYPE) {
|
|
22534
|
-
if (e.operation == 8 /* ReplaceTemporaryContent */) {
|
|
22535
|
-
this.removeWrapper(e.entity.wrapper);
|
|
22536
|
-
}
|
|
22537
|
-
else if (e.operation == 1 /* Click */) {
|
|
22538
|
-
e.rawEvent.preventDefault();
|
|
22539
|
-
}
|
|
22878
|
+
this.removeWrapper();
|
|
22540
22879
|
}
|
|
22541
22880
|
break;
|
|
22542
22881
|
case 8 /* ExtractContentWithDom */:
|
|
@@ -22545,10 +22884,13 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22545
22884
|
(0, editInfo_1.deleteEditInfo)(img);
|
|
22546
22885
|
});
|
|
22547
22886
|
break;
|
|
22887
|
+
case 14 /* Scroll */:
|
|
22888
|
+
this.setEditingImage(null);
|
|
22889
|
+
break;
|
|
22548
22890
|
}
|
|
22549
22891
|
};
|
|
22550
22892
|
/**
|
|
22551
|
-
* Check if the given image edit operation is allowed by this
|
|
22893
|
+
* Check if the given image edit operation is allowed by this plugin
|
|
22552
22894
|
* @param operation The image edit operation to check
|
|
22553
22895
|
* @returns True means it is allowed, otherwise false
|
|
22554
22896
|
*/
|
|
@@ -22559,16 +22901,13 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22559
22901
|
var _this = this;
|
|
22560
22902
|
var operation = typeof operationOrSelect === 'number' ? operationOrSelect : 0 /* None */;
|
|
22561
22903
|
var selectImage = typeof operationOrSelect === 'number' ? false : !!operationOrSelect;
|
|
22562
|
-
if (this.image) {
|
|
22904
|
+
if (!image && this.image) {
|
|
22563
22905
|
// When there is image in editing, clean up any cached objects and elements
|
|
22564
22906
|
this.clearDndHelpers();
|
|
22565
22907
|
// Apply the changes, and add undo snapshot if necessary
|
|
22566
|
-
(0, applyChange_1.default)(this.editor, this.image, this.editInfo, this.lastSrc, this.wasResized);
|
|
22908
|
+
(0, applyChange_1.default)(this.editor, this.image, this.editInfo, this.lastSrc, this.wasResized, this.clonedImage);
|
|
22567
22909
|
// Remove editing wrapper
|
|
22568
|
-
|
|
22569
|
-
if (wrapper) {
|
|
22570
|
-
this.removeWrapper(wrapper);
|
|
22571
|
-
}
|
|
22910
|
+
this.removeWrapper();
|
|
22572
22911
|
this.editor.addUndoSnapshot(function () { return _this.image; }, "ImageResize" /* ImageResize */);
|
|
22573
22912
|
if (selectImage) {
|
|
22574
22913
|
this.editor.select(this.image);
|
|
@@ -22576,6 +22915,7 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22576
22915
|
this.image = null;
|
|
22577
22916
|
this.editInfo = null;
|
|
22578
22917
|
this.lastSrc = null;
|
|
22918
|
+
this.clonedImage = null;
|
|
22579
22919
|
}
|
|
22580
22920
|
if (!this.image && (image === null || image === void 0 ? void 0 : image.isContentEditable)) {
|
|
22581
22921
|
// If there is new image to edit, enter editing mode for this image
|
|
@@ -22589,12 +22929,12 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22589
22929
|
((0, canRegenerateImage_1.default)(image) ? operation : 3 /* Resize */) &
|
|
22590
22930
|
this.allowedOperations;
|
|
22591
22931
|
// Create and update editing wrapper and elements
|
|
22592
|
-
|
|
22932
|
+
this.createWrapper(operation);
|
|
22593
22933
|
this.updateWrapper();
|
|
22594
22934
|
// Init drag and drop
|
|
22595
22935
|
this.dndHelpers = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], this.createDndHelpers("r_resizeH" /* ResizeHandle */, Resizer_1.Resizer), true), this.createDndHelpers("r_rotateH" /* RotateHandle */, Rotator_1.Rotator), true), this.createDndHelpers("r_cropH" /* CropHandle */, Cropper_1.Cropper), true), this.createDndHelpers("r_cropC" /* CropContainer */, Cropper_1.Cropper), true);
|
|
22596
|
-
|
|
22597
|
-
this.
|
|
22936
|
+
this.editor.select(this.image);
|
|
22937
|
+
this.toggleImageVisibility(this.image, false /** showImage */);
|
|
22598
22938
|
}
|
|
22599
22939
|
};
|
|
22600
22940
|
/**
|
|
@@ -22602,25 +22942,22 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22602
22942
|
*/
|
|
22603
22943
|
ImageEdit.prototype.createWrapper = function (operation) {
|
|
22604
22944
|
var _this = this;
|
|
22605
|
-
//
|
|
22606
|
-
|
|
22607
|
-
wrapper
|
|
22608
|
-
wrapper.
|
|
22945
|
+
//Clone the image and insert the clone in a entity
|
|
22946
|
+
this.clonedImage = this.image.cloneNode(true);
|
|
22947
|
+
this.wrapper = (0, roosterjs_editor_dom_1.createElement)(6 /* ImageEditWrapper */, this.image.ownerDocument);
|
|
22948
|
+
this.wrapper.firstChild.appendChild(this.clonedImage);
|
|
22609
22949
|
// keep the same vertical align
|
|
22610
|
-
var originalVerticalAlign = this.image
|
|
22611
|
-
.getComputedStyle(this.image)
|
|
22612
|
-
.getPropertyValue('vertical-align');
|
|
22950
|
+
var originalVerticalAlign = this.getStylePropertyValue(this.image, 'vertical-align');
|
|
22613
22951
|
if (originalVerticalAlign) {
|
|
22614
|
-
wrapper.style.verticalAlign = originalVerticalAlign;
|
|
22952
|
+
this.wrapper.style.verticalAlign = originalVerticalAlign;
|
|
22615
22953
|
}
|
|
22616
|
-
wrapper.style.display = roosterjs_editor_dom_1.Browser.isSafari ? 'inline-block' : 'inline-flex';
|
|
22954
|
+
this.wrapper.style.display = roosterjs_editor_dom_1.Browser.isSafari ? 'inline-block' : 'inline-flex';
|
|
22617
22955
|
// Cache current src so that we can compare it after edit see if src is changed
|
|
22618
22956
|
this.lastSrc = this.image.getAttribute('src');
|
|
22619
22957
|
// Set image src to original src to help show editing UI, also it will be used when regenerate image dataURL after editing
|
|
22620
|
-
this.
|
|
22621
|
-
this.
|
|
22622
|
-
this.
|
|
22623
|
-
var isExperimentalHandlesEnabled = this.editor.isFeatureEnabled("AdaptiveHandlesResizer" /* AdaptiveHandlesResizer */);
|
|
22958
|
+
this.clonedImage.src = this.editInfo.src;
|
|
22959
|
+
this.clonedImage.style.position = 'absolute';
|
|
22960
|
+
this.clonedImage.style.maxWidth = null;
|
|
22624
22961
|
// Get HTML for all edit elements (resize handle, rotate handle, crop handle and overlay, ...) and create HTML element
|
|
22625
22962
|
var options = {
|
|
22626
22963
|
borderColor: getColorString(this.options.borderColor, this.editor.isDarkMode()),
|
|
@@ -22628,8 +22965,7 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22628
22965
|
rotateHandleBackColor: this.editor.isDarkMode()
|
|
22629
22966
|
? DARK_MODE_BGCOLOR
|
|
22630
22967
|
: LIGHT_MODE_BGCOLOR,
|
|
22631
|
-
isSmallImage: isASmallImage(this.editInfo
|
|
22632
|
-
handlesExperimentalFeatures: isExperimentalHandlesEnabled,
|
|
22968
|
+
isSmallImage: isASmallImage(this.editInfo),
|
|
22633
22969
|
};
|
|
22634
22970
|
var htmlData = [(0, Resizer_1.getResizeBordersHTML)(options)];
|
|
22635
22971
|
(0, roosterjs_editor_dom_1.getObjectKeys)(ImageEditHTMLMap).forEach(function (thisOperation) {
|
|
@@ -22640,20 +22976,47 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22640
22976
|
htmlData.forEach(function (data) {
|
|
22641
22977
|
var element = (0, roosterjs_editor_dom_1.createElement)(data, _this.image.ownerDocument);
|
|
22642
22978
|
if (element) {
|
|
22643
|
-
wrapper.appendChild(element);
|
|
22979
|
+
_this.wrapper.appendChild(element);
|
|
22644
22980
|
}
|
|
22645
22981
|
});
|
|
22646
|
-
|
|
22982
|
+
this.insertImageWrapper(this.image, this.wrapper, this.editor.getZoomScale());
|
|
22647
22983
|
};
|
|
22648
|
-
|
|
22649
|
-
|
|
22650
|
-
|
|
22651
|
-
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
|
|
22656
|
-
|
|
22984
|
+
ImageEdit.prototype.toggleImageVisibility = function (image, showImage) {
|
|
22985
|
+
var editorId = this.editor.getEditorDomAttribute('id');
|
|
22986
|
+
var doc = this.editor.getDocument();
|
|
22987
|
+
var editingId = 'editingId' + editorId;
|
|
22988
|
+
if (showImage) {
|
|
22989
|
+
(0, roosterjs_editor_dom_1.removeGlobalCssStyle)(doc, editingId);
|
|
22990
|
+
}
|
|
22991
|
+
else {
|
|
22992
|
+
var cssRule = "#" + editorId + " #" + image.id + " {visibility: hidden}";
|
|
22993
|
+
(0, roosterjs_editor_dom_1.setGlobalCssStyles)(doc, cssRule, editingId);
|
|
22994
|
+
}
|
|
22995
|
+
};
|
|
22996
|
+
ImageEdit.prototype.createZoomWrapper = function (wrapper, scale) {
|
|
22997
|
+
var zoomWrapper = this.editor.getDocument().createElement('div');
|
|
22998
|
+
zoomWrapper.style.transform = "scale(" + (scale || 1) + ")";
|
|
22999
|
+
zoomWrapper.style.transformOrigin = 'top left';
|
|
23000
|
+
zoomWrapper.style.position = 'fixed';
|
|
23001
|
+
zoomWrapper.appendChild(wrapper);
|
|
23002
|
+
return zoomWrapper;
|
|
23003
|
+
};
|
|
23004
|
+
ImageEdit.prototype.copyImageSize = function (image, element) {
|
|
23005
|
+
var _a = image.getBoundingClientRect(), top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom;
|
|
23006
|
+
element.style.top = top + "px";
|
|
23007
|
+
element.style.bottom = bottom + "px";
|
|
23008
|
+
element.style.right = right + "px";
|
|
23009
|
+
element.style.left = left + "px";
|
|
23010
|
+
return element;
|
|
23011
|
+
};
|
|
23012
|
+
ImageEdit.prototype.insertImageWrapper = function (image, wrapper, scale) {
|
|
23013
|
+
this.zoomWrapper = this.copyImageSize(image, this.createZoomWrapper(wrapper, scale));
|
|
23014
|
+
this.editor.getDocument().body.appendChild(this.zoomWrapper);
|
|
23015
|
+
};
|
|
23016
|
+
ImageEdit.prototype.getStylePropertyValue = function (element, property) {
|
|
23017
|
+
return element.ownerDocument.defaultView
|
|
23018
|
+
.getComputedStyle(this.image)
|
|
23019
|
+
.getPropertyValue(property);
|
|
22657
23020
|
};
|
|
22658
23021
|
/**
|
|
22659
23022
|
* Create drag and drop helpers
|
|
@@ -22668,7 +23031,7 @@ var ImageEdit = /** @class */ (function () {
|
|
|
22668
23031
|
options: this.options,
|
|
22669
23032
|
elementClass: elementClass,
|
|
22670
23033
|
};
|
|
22671
|
-
var wrapper = this.
|
|
23034
|
+
var wrapper = this.wrapper;
|
|
22672
23035
|
return wrapper
|
|
22673
23036
|
? getEditElements(wrapper, elementClass).map(function (element) {
|
|
22674
23037
|
return new DragAndDropHelper_1.default(element, __assign(__assign({}, commonContext), { x: element.dataset.x, y: element.dataset.y }), _this.updateWrapper, dragAndDrop, _this.editor.getZoomScale());
|
|
@@ -22749,9 +23112,9 @@ function isFixedNumberValue(value) {
|
|
|
22749
23112
|
var numberValue = typeof value === 'string' ? parseInt(value) : value;
|
|
22750
23113
|
return !isNaN(numberValue);
|
|
22751
23114
|
}
|
|
22752
|
-
function isASmallImage(editInfo
|
|
23115
|
+
function isASmallImage(editInfo) {
|
|
22753
23116
|
var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx;
|
|
22754
|
-
return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE
|
|
23117
|
+
return widthPx && heightPx && widthPx * widthPx < MAX_SMALL_SIZE_IMAGE;
|
|
22755
23118
|
}
|
|
22756
23119
|
function getColorString(color, isDarkMode) {
|
|
22757
23120
|
if (typeof color === 'string') {
|
|
@@ -22938,10 +23301,11 @@ var editInfo_1 = __webpack_require__(/*! ./editInfo */ "./packages/roosterjs-edi
|
|
|
22938
23301
|
* @param image The image to apply the change
|
|
22939
23302
|
* @param editInfo Edit info that contains the changed information of the image
|
|
22940
23303
|
* @param previousSrc Last src value of the image before the change was made
|
|
23304
|
+
* @param editingImage (optional) Image in editing state
|
|
22941
23305
|
*/
|
|
22942
|
-
function applyChange(editor, image, editInfo, previousSrc, wasResized) {
|
|
23306
|
+
function applyChange(editor, image, editInfo, previousSrc, wasResized, editingImage) {
|
|
22943
23307
|
var newSrc = '';
|
|
22944
|
-
var initEditInfo = (0, editInfo_1.getEditInfoFromImage)(image);
|
|
23308
|
+
var initEditInfo = (0, editInfo_1.getEditInfoFromImage)(editingImage !== null && editingImage !== void 0 ? editingImage : image);
|
|
22945
23309
|
var state = (0, checkEditInfoState_1.default)(editInfo, initEditInfo);
|
|
22946
23310
|
switch (state) {
|
|
22947
23311
|
case 1 /* ResizeOnly */:
|
|
@@ -22955,7 +23319,7 @@ function applyChange(editor, image, editInfo, previousSrc, wasResized) {
|
|
|
22955
23319
|
break;
|
|
22956
23320
|
case 3 /* FullyChanged */:
|
|
22957
23321
|
// For other cases (cropped, rotated, ...) we need to create a new image to reflect the change
|
|
22958
|
-
newSrc = (0, generateDataURL_1.default)(image, editInfo);
|
|
23322
|
+
newSrc = (0, generateDataURL_1.default)(editingImage !== null && editingImage !== void 0 ? editingImage : image, editInfo);
|
|
22959
23323
|
break;
|
|
22960
23324
|
}
|
|
22961
23325
|
var srcChanged = newSrc != previousSrc;
|
|
@@ -23507,14 +23871,12 @@ exports.doubleCheckResize = doubleCheckResize;
|
|
|
23507
23871
|
* Get HTML for resize handles at the corners
|
|
23508
23872
|
*/
|
|
23509
23873
|
function getCornerResizeHTML(_a, onShowResizeHandle) {
|
|
23510
|
-
var resizeBorderColor = _a.borderColor
|
|
23874
|
+
var resizeBorderColor = _a.borderColor;
|
|
23511
23875
|
var result = [];
|
|
23512
23876
|
Xs.forEach(function (x) {
|
|
23513
23877
|
return Ys.forEach(function (y) {
|
|
23514
23878
|
var elementData = (x == '') == (y == '')
|
|
23515
|
-
? getResizeHandleHTML(x, y, resizeBorderColor,
|
|
23516
|
-
? 1 /* CircularHandlesCorner */
|
|
23517
|
-
: 0 /* SquareHandles */)
|
|
23879
|
+
? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
|
|
23518
23880
|
: null;
|
|
23519
23881
|
if (onShowResizeHandle) {
|
|
23520
23882
|
onShowResizeHandle(elementData, x, y);
|
|
@@ -23530,7 +23892,7 @@ exports.getCornerResizeHTML = getCornerResizeHTML;
|
|
|
23530
23892
|
* Get HTML for resize handles on the sides
|
|
23531
23893
|
*/
|
|
23532
23894
|
function getSideResizeHTML(_a, onShowResizeHandle) {
|
|
23533
|
-
var resizeBorderColor = _a.borderColor, isSmallImage = _a.isSmallImage
|
|
23895
|
+
var resizeBorderColor = _a.borderColor, isSmallImage = _a.isSmallImage;
|
|
23534
23896
|
if (isSmallImage) {
|
|
23535
23897
|
return null;
|
|
23536
23898
|
}
|
|
@@ -23538,9 +23900,7 @@ function getSideResizeHTML(_a, onShowResizeHandle) {
|
|
|
23538
23900
|
Xs.forEach(function (x) {
|
|
23539
23901
|
return Ys.forEach(function (y) {
|
|
23540
23902
|
var elementData = (x == '') != (y == '')
|
|
23541
|
-
? getResizeHandleHTML(x, y, resizeBorderColor,
|
|
23542
|
-
? 1 /* CircularHandlesCorner */
|
|
23543
|
-
: 0 /* SquareHandles */)
|
|
23903
|
+
? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
|
|
23544
23904
|
: null;
|
|
23545
23905
|
if (onShowResizeHandle) {
|
|
23546
23906
|
onShowResizeHandle(elementData, x, y);
|
|
@@ -23617,7 +23977,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
23617
23977
|
return __assign.apply(this, arguments);
|
|
23618
23978
|
};
|
|
23619
23979
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23620
|
-
exports.getRotateHTML = exports.
|
|
23980
|
+
exports.getRotateHTML = exports.Rotator = void 0;
|
|
23621
23981
|
var ROTATE_SIZE = 32;
|
|
23622
23982
|
var ROTATE_GAP = 15;
|
|
23623
23983
|
var DEG_PER_RAD = 180 / Math.PI;
|
|
@@ -23652,26 +24012,6 @@ exports.Rotator = {
|
|
|
23652
24012
|
}
|
|
23653
24013
|
},
|
|
23654
24014
|
};
|
|
23655
|
-
/**
|
|
23656
|
-
* @internal
|
|
23657
|
-
* Move rotate handle. When image is very close to the border of editor, rotate handle may not be visible.
|
|
23658
|
-
* Fix it by reduce the distance from image to rotate handle
|
|
23659
|
-
*/
|
|
23660
|
-
function updateRotateHandlePosition(editInfo, distance, marginVertical, rotateCenter, rotateHandle) {
|
|
23661
|
-
if (rotateCenter && rotateHandle && distance) {
|
|
23662
|
-
var angleRad = editInfo.angleRad, heightPx = editInfo.heightPx;
|
|
23663
|
-
var cosAngle = Math.cos(angleRad);
|
|
23664
|
-
var adjustedDistance = cosAngle <= 0
|
|
23665
|
-
? Number.MAX_SAFE_INTEGER
|
|
23666
|
-
: (distance[1] + heightPx / 2 + marginVertical) / cosAngle - heightPx / 2;
|
|
23667
|
-
var rotateGap = Math.max(Math.min(ROTATE_GAP, adjustedDistance), 0);
|
|
23668
|
-
var rotateTop = Math.max(Math.min(ROTATE_SIZE, adjustedDistance - rotateGap), 0);
|
|
23669
|
-
rotateCenter.style.top = -rotateGap + 'px';
|
|
23670
|
-
rotateCenter.style.height = rotateGap + 'px';
|
|
23671
|
-
rotateHandle.style.top = -rotateTop + 'px';
|
|
23672
|
-
}
|
|
23673
|
-
}
|
|
23674
|
-
exports.updateRotateHandlePosition = updateRotateHandlePosition;
|
|
23675
24015
|
/**
|
|
23676
24016
|
* @internal
|
|
23677
24017
|
* Get HTML for rotate elements, including the rotate handle with icon, and a line between the handle and the image
|
|
@@ -23683,12 +24023,12 @@ function getRotateHTML(_a) {
|
|
|
23683
24023
|
{
|
|
23684
24024
|
tag: 'div',
|
|
23685
24025
|
className: "r_rotateC" /* RotateCenter */,
|
|
23686
|
-
style: "position:absolute;left:50%;width:1px;background-color:" + borderColor,
|
|
24026
|
+
style: "position:absolute;left:50%;width:1px;background-color:" + borderColor + ";top:" + -ROTATE_GAP + "px;height:" + ROTATE_GAP + "px;",
|
|
23687
24027
|
children: [
|
|
23688
24028
|
{
|
|
23689
24029
|
tag: 'div',
|
|
23690
24030
|
className: "r_rotateH" /* RotateHandle */,
|
|
23691
|
-
style: "position:absolute;background-color:" + rotateHandleBackColor + ";border:solid 1px " + borderColor + ";border-radius:50%;width:" + ROTATE_SIZE + "px;height:" + ROTATE_SIZE + "px;left:-" + handleLeft + "px;cursor:move",
|
|
24031
|
+
style: "position:absolute;background-color:" + rotateHandleBackColor + ";border:solid 1px " + borderColor + ";border-radius:50%;width:" + ROTATE_SIZE + "px;height:" + ROTATE_SIZE + "px;left:-" + handleLeft + "px;cursor:move;top:" + -ROTATE_SIZE + "px;",
|
|
23692
24032
|
children: [getRotateIconHTML(borderColor)],
|
|
23693
24033
|
},
|
|
23694
24034
|
],
|
|
@@ -23842,111 +24182,6 @@ var ImageResize_1 = __webpack_require__(/*! ./ImageResize */ "./packages/rooster
|
|
|
23842
24182
|
Object.defineProperty(exports, "ImageResize", { enumerable: true, get: function () { return ImageResize_1.default; } });
|
|
23843
24183
|
|
|
23844
24184
|
|
|
23845
|
-
/***/ }),
|
|
23846
|
-
|
|
23847
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts":
|
|
23848
|
-
/*!****************************************************************************************!*\
|
|
23849
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts ***!
|
|
23850
|
-
\****************************************************************************************/
|
|
23851
|
-
/*! no static exports found */
|
|
23852
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
23853
|
-
|
|
23854
|
-
"use strict";
|
|
23855
|
-
|
|
23856
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23857
|
-
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
23858
|
-
var Escape = 'Escape';
|
|
23859
|
-
var mouseRightButton = 2;
|
|
23860
|
-
var mouseLeftButton = 0;
|
|
23861
|
-
/**
|
|
23862
|
-
* Requires @see ExperimentalFeatures.ImageSelection to be enabled.
|
|
23863
|
-
* Detect image selection and help highlight the image
|
|
23864
|
-
*/
|
|
23865
|
-
var ImageSelection = /** @class */ (function () {
|
|
23866
|
-
function ImageSelection() {
|
|
23867
|
-
this.editor = null;
|
|
23868
|
-
}
|
|
23869
|
-
/**
|
|
23870
|
-
* Get a friendly name of this plugin
|
|
23871
|
-
*/
|
|
23872
|
-
ImageSelection.prototype.getName = function () {
|
|
23873
|
-
return 'ImageSelection';
|
|
23874
|
-
};
|
|
23875
|
-
/**
|
|
23876
|
-
* Initialize this plugin. This should only be called from Editor
|
|
23877
|
-
* @param editor Editor instance
|
|
23878
|
-
*/
|
|
23879
|
-
ImageSelection.prototype.initialize = function (editor) {
|
|
23880
|
-
this.editor = editor;
|
|
23881
|
-
};
|
|
23882
|
-
/**
|
|
23883
|
-
* Dispose this plugin
|
|
23884
|
-
*/
|
|
23885
|
-
ImageSelection.prototype.dispose = function () {
|
|
23886
|
-
this.editor.select(null);
|
|
23887
|
-
this.editor = null;
|
|
23888
|
-
};
|
|
23889
|
-
ImageSelection.prototype.onPluginEvent = function (event) {
|
|
23890
|
-
if (this.editor && this.editor.isFeatureEnabled("ImageSelection" /* ImageSelection */)) {
|
|
23891
|
-
switch (event.eventType) {
|
|
23892
|
-
case 17 /* EnteredShadowEdit */:
|
|
23893
|
-
case 18 /* LeavingShadowEdit */:
|
|
23894
|
-
var selection = this.editor.getSelectionRangeEx();
|
|
23895
|
-
if (selection.type == 2 /* ImageSelection */) {
|
|
23896
|
-
this.editor.select(selection.image);
|
|
23897
|
-
}
|
|
23898
|
-
break;
|
|
23899
|
-
case 5 /* MouseDown */:
|
|
23900
|
-
var target = event.rawEvent.target;
|
|
23901
|
-
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement')) {
|
|
23902
|
-
if (event.rawEvent.button === mouseRightButton) {
|
|
23903
|
-
var imageRange = (0, roosterjs_editor_dom_1.createRange)(target);
|
|
23904
|
-
this.editor.select(imageRange);
|
|
23905
|
-
}
|
|
23906
|
-
else if (event.rawEvent.button === mouseLeftButton) {
|
|
23907
|
-
this.editor.select(target);
|
|
23908
|
-
}
|
|
23909
|
-
}
|
|
23910
|
-
break;
|
|
23911
|
-
case 0 /* KeyDown */:
|
|
23912
|
-
var key = event.rawEvent.key;
|
|
23913
|
-
var keyDownSelection = this.editor.getSelectionRangeEx();
|
|
23914
|
-
if (keyDownSelection.type === 2 /* ImageSelection */) {
|
|
23915
|
-
if (key === Escape) {
|
|
23916
|
-
this.editor.select(keyDownSelection.image, -2 /* Before */);
|
|
23917
|
-
this.editor.getSelectionRange().collapse();
|
|
23918
|
-
event.rawEvent.stopPropagation();
|
|
23919
|
-
}
|
|
23920
|
-
else {
|
|
23921
|
-
this.editor.select(keyDownSelection.ranges[0]);
|
|
23922
|
-
}
|
|
23923
|
-
}
|
|
23924
|
-
break;
|
|
23925
|
-
}
|
|
23926
|
-
}
|
|
23927
|
-
};
|
|
23928
|
-
return ImageSelection;
|
|
23929
|
-
}());
|
|
23930
|
-
exports.default = ImageSelection;
|
|
23931
|
-
|
|
23932
|
-
|
|
23933
|
-
/***/ }),
|
|
23934
|
-
|
|
23935
|
-
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts":
|
|
23936
|
-
/*!*******************************************************************************!*\
|
|
23937
|
-
!*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/index.ts ***!
|
|
23938
|
-
\*******************************************************************************/
|
|
23939
|
-
/*! no static exports found */
|
|
23940
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
23941
|
-
|
|
23942
|
-
"use strict";
|
|
23943
|
-
|
|
23944
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23945
|
-
exports.ImageSelection = void 0;
|
|
23946
|
-
var ImageSelection_1 = __webpack_require__(/*! ./ImageSelection */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageSelection/ImageSelection.ts");
|
|
23947
|
-
Object.defineProperty(exports, "ImageSelection", { enumerable: true, get: function () { return ImageSelection_1.default; } });
|
|
23948
|
-
|
|
23949
|
-
|
|
23950
24185
|
/***/ }),
|
|
23951
24186
|
|
|
23952
24187
|
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/Paste/Paste.ts":
|
|
@@ -25920,6 +26155,13 @@ var PickerPlugin = /** @class */ (function () {
|
|
|
25920
26155
|
*/
|
|
25921
26156
|
PickerPlugin.prototype.dispose = function () {
|
|
25922
26157
|
this.editor = null;
|
|
26158
|
+
this.isSuggesting = null;
|
|
26159
|
+
this.blockSuggestions = null;
|
|
26160
|
+
this.eventHandledOnKeyDown = null;
|
|
26161
|
+
this.lastKnownRange = null;
|
|
26162
|
+
this.isPendingInputEventHandling = null;
|
|
26163
|
+
this.currentInputLength = null;
|
|
26164
|
+
this.newInputLength = null;
|
|
25923
26165
|
this.dataProvider.onDispose();
|
|
25924
26166
|
};
|
|
25925
26167
|
/**
|
|
@@ -29019,6 +29261,7 @@ var CompatibleExperimentalFeatures;
|
|
|
29019
29261
|
*/
|
|
29020
29262
|
CompatibleExperimentalFeatures["ConvertSingleImageBody"] = "ConvertSingleImageBody";
|
|
29021
29263
|
/**
|
|
29264
|
+
* @deprecated This feature is always enabled
|
|
29022
29265
|
* Align table elements to left, center and right using setAlignment API
|
|
29023
29266
|
*/
|
|
29024
29267
|
CompatibleExperimentalFeatures["TableAlignment"] = "TableAlignment";
|
|
@@ -29027,6 +29270,7 @@ var CompatibleExperimentalFeatures;
|
|
|
29027
29270
|
*/
|
|
29028
29271
|
CompatibleExperimentalFeatures["TabKeyTextFeatures"] = "TabKeyTextFeatures";
|
|
29029
29272
|
/**
|
|
29273
|
+
* @deprecated this feature is always enabled
|
|
29030
29274
|
* Provide a circular resize handles that adaptive the number od handles to the size of the image
|
|
29031
29275
|
*/
|
|
29032
29276
|
CompatibleExperimentalFeatures["AdaptiveHandlesResizer"] = "AdaptiveHandlesResizer";
|
|
@@ -29055,6 +29299,7 @@ var CompatibleExperimentalFeatures;
|
|
|
29055
29299
|
*/
|
|
29056
29300
|
CompatibleExperimentalFeatures["NormalizeList"] = "NormalizeList";
|
|
29057
29301
|
/**
|
|
29302
|
+
* @deprecated this feature is always enabled
|
|
29058
29303
|
* When a html image is selected, the selected image data will be stored by editor core.
|
|
29059
29304
|
*/
|
|
29060
29305
|
CompatibleExperimentalFeatures["ImageSelection"] = "ImageSelection";
|
|
@@ -29065,6 +29310,11 @@ var CompatibleExperimentalFeatures;
|
|
|
29065
29310
|
* is the one closest to the item.
|
|
29066
29311
|
*/
|
|
29067
29312
|
CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
|
|
29313
|
+
/**
|
|
29314
|
+
* When apply default format when initialize or user type, apply the format on a SPAN element rather than
|
|
29315
|
+
* the block element (In most case, the DIV element) so keep the block element clean.
|
|
29316
|
+
*/
|
|
29317
|
+
CompatibleExperimentalFeatures["DefaultFormatInSpan"] = "DefaultFormatInSpan";
|
|
29068
29318
|
})(CompatibleExperimentalFeatures = exports.CompatibleExperimentalFeatures || (exports.CompatibleExperimentalFeatures = {}));
|
|
29069
29319
|
|
|
29070
29320
|
|