roosterjs 9.61.0 → 9.63.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 +101 -3
- package/dist/rooster-amd.js +733 -99
- 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 +101 -3
- package/dist/rooster.js +733 -99
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
package/dist/rooster.js
CHANGED
|
@@ -2550,8 +2550,8 @@ exports["default"] = getDarkColor;
|
|
|
2550
2550
|
"use strict";
|
|
2551
2551
|
|
|
2552
2552
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2553
|
-
exports.
|
|
2554
|
-
exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.getTextDirection = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = void 0;
|
|
2553
|
+
exports.formatTableWithContentModel = exports.createEditorContextForEntity = exports.clearSelectedCells = exports.insertTableColumn = exports.insertTableRow = exports.insertEntity = exports.toggleCode = exports.setParagraphMargin = exports.adjustImageSelection = exports.setImageAltText = exports.adjustLinkSelection = exports.removeLink = exports.insertLink = exports.clearFormat = exports.getFormatState = exports.changeImage = exports.setImageSize = exports.setImageBoxShadow = exports.setImageBorder = exports.setSpacing = exports.toggleBlockQuote = exports.setHeadingLevel = exports.setDirection = exports.setAlignment = exports.insertHorizontalLine = exports.setIndentation = exports.setListStartNumber = exports.setListStyle = exports.insertImage = exports.splitTextSegment = exports.changeCapitalization = exports.applySegmentFormat = exports.changeFontSize = exports.setTextColor = exports.setFontSize = exports.setFontName = exports.setBackgroundColor = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleUnderline = exports.toggleItalic = exports.toggleBold = exports.toggleNumbering = exports.toggleBullet = exports.applyTableBorderFormat = exports.editTable = exports.setTableCellShade = exports.formatTable = exports.insertTable = void 0;
|
|
2554
|
+
exports.adjustWordSelection = exports.queryContentModelBlocks = exports.getListAnnounceData = exports.getPromoteLink = exports.promoteLink = exports.matchLink = exports.getTextDirection = exports.insertHorizontalLineIntoModel = exports.setModelIndentation = exports.findListItemsInSameThread = exports.setModelListStartNumber = exports.setModelListStyle = exports.setListType = exports.formatInsertPointWithContentModel = exports.formatTextSegmentBeforeSelectionMarker = exports.formatSegmentWithContentModel = exports.formatParagraphWithContentModel = exports.formatImageWithContentModel = void 0;
|
|
2555
2555
|
var insertTable_1 = __webpack_require__(/*! ./publicApi/table/insertTable */ "./packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts");
|
|
2556
2556
|
Object.defineProperty(exports, "insertTable", ({ enumerable: true, get: function () { return insertTable_1.insertTable; } }));
|
|
2557
2557
|
var formatTable_1 = __webpack_require__(/*! ./publicApi/table/formatTable */ "./packages/roosterjs-content-model-api/lib/publicApi/table/formatTable.ts");
|
|
@@ -2602,6 +2602,8 @@ var setListStartNumber_1 = __webpack_require__(/*! ./publicApi/list/setListStart
|
|
|
2602
2602
|
Object.defineProperty(exports, "setListStartNumber", ({ enumerable: true, get: function () { return setListStartNumber_1.setListStartNumber; } }));
|
|
2603
2603
|
var setIndentation_1 = __webpack_require__(/*! ./publicApi/block/setIndentation */ "./packages/roosterjs-content-model-api/lib/publicApi/block/setIndentation.ts");
|
|
2604
2604
|
Object.defineProperty(exports, "setIndentation", ({ enumerable: true, get: function () { return setIndentation_1.setIndentation; } }));
|
|
2605
|
+
var insertHorizontalLine_1 = __webpack_require__(/*! ./publicApi/block/insertHorizontalLine */ "./packages/roosterjs-content-model-api/lib/publicApi/block/insertHorizontalLine.ts");
|
|
2606
|
+
Object.defineProperty(exports, "insertHorizontalLine", ({ enumerable: true, get: function () { return insertHorizontalLine_1.insertHorizontalLine; } }));
|
|
2605
2607
|
var setAlignment_1 = __webpack_require__(/*! ./publicApi/block/setAlignment */ "./packages/roosterjs-content-model-api/lib/publicApi/block/setAlignment.ts");
|
|
2606
2608
|
Object.defineProperty(exports, "setAlignment", ({ enumerable: true, get: function () { return setAlignment_1.setAlignment; } }));
|
|
2607
2609
|
var setDirection_1 = __webpack_require__(/*! ./publicApi/block/setDirection */ "./packages/roosterjs-content-model-api/lib/publicApi/block/setDirection.ts");
|
|
@@ -2616,6 +2618,8 @@ var setImageBorder_1 = __webpack_require__(/*! ./publicApi/image/setImageBorder
|
|
|
2616
2618
|
Object.defineProperty(exports, "setImageBorder", ({ enumerable: true, get: function () { return setImageBorder_1.setImageBorder; } }));
|
|
2617
2619
|
var setImageBoxShadow_1 = __webpack_require__(/*! ./publicApi/image/setImageBoxShadow */ "./packages/roosterjs-content-model-api/lib/publicApi/image/setImageBoxShadow.ts");
|
|
2618
2620
|
Object.defineProperty(exports, "setImageBoxShadow", ({ enumerable: true, get: function () { return setImageBoxShadow_1.setImageBoxShadow; } }));
|
|
2621
|
+
var setImageSize_1 = __webpack_require__(/*! ./publicApi/image/setImageSize */ "./packages/roosterjs-content-model-api/lib/publicApi/image/setImageSize.ts");
|
|
2622
|
+
Object.defineProperty(exports, "setImageSize", ({ enumerable: true, get: function () { return setImageSize_1.setImageSize; } }));
|
|
2619
2623
|
var changeImage_1 = __webpack_require__(/*! ./publicApi/image/changeImage */ "./packages/roosterjs-content-model-api/lib/publicApi/image/changeImage.ts");
|
|
2620
2624
|
Object.defineProperty(exports, "changeImage", ({ enumerable: true, get: function () { return changeImage_1.changeImage; } }));
|
|
2621
2625
|
var getFormatState_1 = __webpack_require__(/*! ./publicApi/format/getFormatState */ "./packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts");
|
|
@@ -2668,6 +2672,8 @@ var findListItemsInSameThread_1 = __webpack_require__(/*! ./modelApi/list/findLi
|
|
|
2668
2672
|
Object.defineProperty(exports, "findListItemsInSameThread", ({ enumerable: true, get: function () { return findListItemsInSameThread_1.findListItemsInSameThread; } }));
|
|
2669
2673
|
var setModelIndentation_1 = __webpack_require__(/*! ./modelApi/block/setModelIndentation */ "./packages/roosterjs-content-model-api/lib/modelApi/block/setModelIndentation.ts");
|
|
2670
2674
|
Object.defineProperty(exports, "setModelIndentation", ({ enumerable: true, get: function () { return setModelIndentation_1.setModelIndentation; } }));
|
|
2675
|
+
var insertHorizontalLineIntoModel_1 = __webpack_require__(/*! ./modelApi/block/insertHorizontalLineIntoModel */ "./packages/roosterjs-content-model-api/lib/modelApi/block/insertHorizontalLineIntoModel.ts");
|
|
2676
|
+
Object.defineProperty(exports, "insertHorizontalLineIntoModel", ({ enumerable: true, get: function () { return insertHorizontalLineIntoModel_1.insertHorizontalLineIntoModel; } }));
|
|
2671
2677
|
var setModelDirection_1 = __webpack_require__(/*! ./modelApi/block/setModelDirection */ "./packages/roosterjs-content-model-api/lib/modelApi/block/setModelDirection.ts");
|
|
2672
2678
|
Object.defineProperty(exports, "getTextDirection", ({ enumerable: true, get: function () { return setModelDirection_1.getTextDirection; } }));
|
|
2673
2679
|
var matchLink_1 = __webpack_require__(/*! ./modelApi/link/matchLink */ "./packages/roosterjs-content-model-api/lib/modelApi/link/matchLink.ts");
|
|
@@ -2683,6 +2689,39 @@ var adjustWordSelection_1 = __webpack_require__(/*! ./modelApi/selection/adjustW
|
|
|
2683
2689
|
Object.defineProperty(exports, "adjustWordSelection", ({ enumerable: true, get: function () { return adjustWordSelection_1.adjustWordSelection; } }));
|
|
2684
2690
|
|
|
2685
2691
|
|
|
2692
|
+
/***/ },
|
|
2693
|
+
|
|
2694
|
+
/***/ "./packages/roosterjs-content-model-api/lib/modelApi/block/insertHorizontalLineIntoModel.ts"
|
|
2695
|
+
/*!**************************************************************************************************!*\
|
|
2696
|
+
!*** ./packages/roosterjs-content-model-api/lib/modelApi/block/insertHorizontalLineIntoModel.ts ***!
|
|
2697
|
+
\**************************************************************************************************/
|
|
2698
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
2699
|
+
|
|
2700
|
+
"use strict";
|
|
2701
|
+
|
|
2702
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2703
|
+
exports.insertHorizontalLineIntoModel = void 0;
|
|
2704
|
+
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
2705
|
+
/**
|
|
2706
|
+
* Insert a horizontal line into the model at current selection
|
|
2707
|
+
*/
|
|
2708
|
+
function insertHorizontalLineIntoModel(model, context, format) {
|
|
2709
|
+
if (format === void 0) { format = {
|
|
2710
|
+
borderTop: '1px solid',
|
|
2711
|
+
borderRight: '1px solid',
|
|
2712
|
+
borderBottom: '1px solid',
|
|
2713
|
+
borderLeft: '1px solid',
|
|
2714
|
+
width: '98%',
|
|
2715
|
+
display: 'table',
|
|
2716
|
+
height: '1px',
|
|
2717
|
+
}; }
|
|
2718
|
+
var doc = (0, roosterjs_content_model_dom_1.createContentModelDocument)();
|
|
2719
|
+
(0, roosterjs_content_model_dom_1.addBlock)(doc, (0, roosterjs_content_model_dom_1.createDivider)('hr', format));
|
|
2720
|
+
return !!(0, roosterjs_content_model_dom_1.mergeModel)(model, doc, context);
|
|
2721
|
+
}
|
|
2722
|
+
exports.insertHorizontalLineIntoModel = insertHorizontalLineIntoModel;
|
|
2723
|
+
|
|
2724
|
+
|
|
2686
2725
|
/***/ },
|
|
2687
2726
|
|
|
2688
2727
|
/***/ "./packages/roosterjs-content-model-api/lib/modelApi/block/setModelAlignment.ts"
|
|
@@ -5740,6 +5779,33 @@ function insertTableContent(table, contentRows, colNumber, customCellFormat) {
|
|
|
5740
5779
|
exports.insertTableContent = insertTableContent;
|
|
5741
5780
|
|
|
5742
5781
|
|
|
5782
|
+
/***/ },
|
|
5783
|
+
|
|
5784
|
+
/***/ "./packages/roosterjs-content-model-api/lib/publicApi/block/insertHorizontalLine.ts"
|
|
5785
|
+
/*!******************************************************************************************!*\
|
|
5786
|
+
!*** ./packages/roosterjs-content-model-api/lib/publicApi/block/insertHorizontalLine.ts ***!
|
|
5787
|
+
\******************************************************************************************/
|
|
5788
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
5789
|
+
|
|
5790
|
+
"use strict";
|
|
5791
|
+
|
|
5792
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5793
|
+
exports.insertHorizontalLine = void 0;
|
|
5794
|
+
var insertHorizontalLineIntoModel_1 = __webpack_require__(/*! ../../modelApi/block/insertHorizontalLineIntoModel */ "./packages/roosterjs-content-model-api/lib/modelApi/block/insertHorizontalLineIntoModel.ts");
|
|
5795
|
+
/**
|
|
5796
|
+
* Insert a horizontal line into editor at current selection, replacing selected content
|
|
5797
|
+
* @param editor The editor instance
|
|
5798
|
+
* @param format Optional divider format. Defaults to a thin solid line with 98% width
|
|
5799
|
+
*/
|
|
5800
|
+
function insertHorizontalLine(editor, format) {
|
|
5801
|
+
editor.focus();
|
|
5802
|
+
editor.formatContentModel(function (model, context) { return (0, insertHorizontalLineIntoModel_1.insertHorizontalLineIntoModel)(model, context, format); }, {
|
|
5803
|
+
apiName: 'insertHorizontalLine',
|
|
5804
|
+
});
|
|
5805
|
+
}
|
|
5806
|
+
exports.insertHorizontalLine = insertHorizontalLine;
|
|
5807
|
+
|
|
5808
|
+
|
|
5743
5809
|
/***/ },
|
|
5744
5810
|
|
|
5745
5811
|
/***/ "./packages/roosterjs-content-model-api/lib/publicApi/block/setAlignment.ts"
|
|
@@ -6411,6 +6477,35 @@ function setImageBoxShadow(editor, boxShadow, margin) {
|
|
|
6411
6477
|
exports.setImageBoxShadow = setImageBoxShadow;
|
|
6412
6478
|
|
|
6413
6479
|
|
|
6480
|
+
/***/ },
|
|
6481
|
+
|
|
6482
|
+
/***/ "./packages/roosterjs-content-model-api/lib/publicApi/image/setImageSize.ts"
|
|
6483
|
+
/*!**********************************************************************************!*\
|
|
6484
|
+
!*** ./packages/roosterjs-content-model-api/lib/publicApi/image/setImageSize.ts ***!
|
|
6485
|
+
\**********************************************************************************/
|
|
6486
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
6487
|
+
|
|
6488
|
+
"use strict";
|
|
6489
|
+
|
|
6490
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6491
|
+
exports.setImageSize = void 0;
|
|
6492
|
+
var formatImageWithContentModel_1 = __webpack_require__(/*! ../utils/formatImageWithContentModel */ "./packages/roosterjs-content-model-api/lib/publicApi/utils/formatImageWithContentModel.ts");
|
|
6493
|
+
/**
|
|
6494
|
+
* Set the width and height of all selected images.
|
|
6495
|
+
* @param editor The editor instance
|
|
6496
|
+
* @param width The image width as a CSS value (e.g. "200px" or "50%"). An empty string clears the explicit width.
|
|
6497
|
+
* @param height The image height as a CSS value (e.g. "100px" or "auto"). An empty string clears the explicit height.
|
|
6498
|
+
*/
|
|
6499
|
+
function setImageSize(editor, width, height) {
|
|
6500
|
+
editor.focus();
|
|
6501
|
+
(0, formatImageWithContentModel_1.formatImageWithContentModel)(editor, 'setImageSize', function (image) {
|
|
6502
|
+
image.format.width = width;
|
|
6503
|
+
image.format.height = height;
|
|
6504
|
+
});
|
|
6505
|
+
}
|
|
6506
|
+
exports.setImageSize = setImageSize;
|
|
6507
|
+
|
|
6508
|
+
|
|
6414
6509
|
/***/ },
|
|
6415
6510
|
|
|
6416
6511
|
/***/ "./packages/roosterjs-content-model-api/lib/publicApi/link/adjustLinkSelection.ts"
|
|
@@ -11032,6 +11127,33 @@ function findTableCellElement(parsedTable, coordinate) {
|
|
|
11032
11127
|
exports.findTableCellElement = findTableCellElement;
|
|
11033
11128
|
|
|
11034
11129
|
|
|
11130
|
+
/***/ },
|
|
11131
|
+
|
|
11132
|
+
/***/ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts"
|
|
11133
|
+
/*!****************************************************************************************************!*\
|
|
11134
|
+
!*** ./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts ***!
|
|
11135
|
+
\****************************************************************************************************/
|
|
11136
|
+
(__unused_webpack_module, exports) {
|
|
11137
|
+
|
|
11138
|
+
"use strict";
|
|
11139
|
+
|
|
11140
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11141
|
+
exports.getTextSelectionStyle = exports.RANGE_SELECTION_CSS_KEY = void 0;
|
|
11142
|
+
/**
|
|
11143
|
+
* @internal
|
|
11144
|
+
*/
|
|
11145
|
+
exports.RANGE_SELECTION_CSS_KEY = '_RangeSelection';
|
|
11146
|
+
/**
|
|
11147
|
+
* @internal
|
|
11148
|
+
* Get the text selection style for the current color mode, or null to use browser defaults.
|
|
11149
|
+
*/
|
|
11150
|
+
function getTextSelectionStyle(state, isDarkMode) {
|
|
11151
|
+
var color = isDarkMode ? state.textSelectionColorDark : state.textSelectionColor;
|
|
11152
|
+
return color ? "background-color: " + color + " !important; color: currentColor !important;" : null;
|
|
11153
|
+
}
|
|
11154
|
+
exports.getTextSelectionStyle = getTextSelectionStyle;
|
|
11155
|
+
|
|
11156
|
+
|
|
11035
11157
|
/***/ },
|
|
11036
11158
|
|
|
11037
11159
|
/***/ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/setDOMSelection.ts"
|
|
@@ -11049,6 +11171,7 @@ var ensureUniqueId_1 = __webpack_require__(/*! ../setEditorStyle/ensureUniqueId
|
|
|
11049
11171
|
var findLastedCoInMergedCell_1 = __webpack_require__(/*! ./findLastedCoInMergedCell */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findLastedCoInMergedCell.ts");
|
|
11050
11172
|
var findTableCellElement_1 = __webpack_require__(/*! ./findTableCellElement */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findTableCellElement.ts");
|
|
11051
11173
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
11174
|
+
var getTextSelectionStyle_1 = __webpack_require__(/*! ./getTextSelectionStyle */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts");
|
|
11052
11175
|
var setTableCellsStyle_1 = __webpack_require__(/*! ./setTableCellsStyle */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/setTableCellsStyle.ts");
|
|
11053
11176
|
var toggleCaret_1 = __webpack_require__(/*! ./toggleCaret */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/toggleCaret.ts");
|
|
11054
11177
|
var DOM_SELECTION_CSS_KEY = '_DOMSelection';
|
|
@@ -11073,6 +11196,7 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
|
|
|
11073
11196
|
core.selection.skipReselectOnFocus = true;
|
|
11074
11197
|
core.api.setEditorStyle(core, DOM_SELECTION_CSS_KEY, null /*cssRule*/);
|
|
11075
11198
|
core.api.setEditorStyle(core, HIDE_SELECTION_CSS_KEY, null /*cssRule*/);
|
|
11199
|
+
core.api.setEditorStyle(core, getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, null /*cssRule*/);
|
|
11076
11200
|
(0, toggleCaret_1.toggleCaret)(core, false /* hide */);
|
|
11077
11201
|
try {
|
|
11078
11202
|
switch (selection === null || selection === void 0 ? void 0 : selection.type) {
|
|
@@ -11125,6 +11249,14 @@ var setDOMSelection = function (core, selection, skipSelectionChangedEvent) {
|
|
|
11125
11249
|
}
|
|
11126
11250
|
break;
|
|
11127
11251
|
case 'range':
|
|
11252
|
+
var textSelectionStyle = !selection.range.collapsed
|
|
11253
|
+
? (0, getTextSelectionStyle_1.getTextSelectionStyle)(core.selection, isDarkMode)
|
|
11254
|
+
: null;
|
|
11255
|
+
if (textSelectionStyle) {
|
|
11256
|
+
core.api.setEditorStyle(core, getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, textSelectionStyle, [
|
|
11257
|
+
SELECTION_SELECTOR,
|
|
11258
|
+
]);
|
|
11259
|
+
}
|
|
11128
11260
|
core.domHelper.setSelectionRange(selection.range, selection.isReverted);
|
|
11129
11261
|
core.selection.selection = core.domHelper.hasFocus() ? null : selection;
|
|
11130
11262
|
break;
|
|
@@ -14521,6 +14653,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
14521
14653
|
exports.createSelectionPlugin = exports.DEFAULT_TABLE_CELL_SELECTION_BACKGROUND_COLOR = exports.DEFAULT_SELECTION_BORDER_COLOR = void 0;
|
|
14522
14654
|
var findCoordinate_1 = __webpack_require__(/*! ./findCoordinate */ "./packages/roosterjs-content-model-core/lib/corePlugin/selection/findCoordinate.ts");
|
|
14523
14655
|
var findTableCellElement_1 = __webpack_require__(/*! ../../coreApi/setDOMSelection/findTableCellElement */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/findTableCellElement.ts");
|
|
14656
|
+
var getTextSelectionStyle_1 = __webpack_require__(/*! ../../coreApi/setDOMSelection/getTextSelectionStyle */ "./packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/getTextSelectionStyle.ts");
|
|
14524
14657
|
var isSingleImageInSelection_1 = __webpack_require__(/*! ./isSingleImageInSelection */ "./packages/roosterjs-content-model-core/lib/corePlugin/selection/isSingleImageInSelection.ts");
|
|
14525
14658
|
var normalizePos_1 = __webpack_require__(/*! ./normalizePos */ "./packages/roosterjs-content-model-core/lib/corePlugin/selection/normalizePos.ts");
|
|
14526
14659
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
@@ -14640,6 +14773,7 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14640
14773
|
this.onSelectionChange = function () {
|
|
14641
14774
|
var _a, _b;
|
|
14642
14775
|
if (((_a = _this.editor) === null || _a === void 0 ? void 0 : _a.hasFocus()) && !_this.editor.isInShadowEdit()) {
|
|
14776
|
+
_this.editor.setEditorStyle(getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, null /* cssRule */);
|
|
14643
14777
|
var newSelection = _this.editor.getDOMSelection();
|
|
14644
14778
|
var domHelper = _this.editor.getDOMHelper();
|
|
14645
14779
|
// If an image selection changed to a wider range due to a keyboard event, we should update the selection
|
|
@@ -14651,22 +14785,31 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14651
14785
|
var isReverted = sel
|
|
14652
14786
|
? sel.focusNode != range.endContainer || sel.focusOffset != range.endOffset
|
|
14653
14787
|
: false;
|
|
14654
|
-
|
|
14788
|
+
newSelection = {
|
|
14655
14789
|
type: 'range',
|
|
14656
14790
|
range: range,
|
|
14657
14791
|
isReverted: isReverted,
|
|
14658
|
-
}
|
|
14792
|
+
};
|
|
14793
|
+
_this.editor.setDOMSelection(newSelection);
|
|
14659
14794
|
}
|
|
14660
14795
|
else if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) !== 'image' && image) {
|
|
14661
|
-
|
|
14796
|
+
newSelection = {
|
|
14662
14797
|
type: 'image',
|
|
14663
14798
|
image: image,
|
|
14664
|
-
}
|
|
14799
|
+
};
|
|
14800
|
+
_this.editor.setDOMSelection(newSelection);
|
|
14665
14801
|
}
|
|
14666
14802
|
}
|
|
14667
|
-
// Safari has problem to handle onBlur event. When blur, we cannot get the original selection from editor.
|
|
14668
|
-
// So we always save a selection whenever editor has focus. Then after blur, we can still use this cached selection.
|
|
14669
14803
|
if ((newSelection === null || newSelection === void 0 ? void 0 : newSelection.type) == 'range') {
|
|
14804
|
+
if (!newSelection.range.collapsed) {
|
|
14805
|
+
var textSelectionStyle = (0, getTextSelectionStyle_1.getTextSelectionStyle)(_this.state, _this.editor.isDarkMode());
|
|
14806
|
+
if (textSelectionStyle) {
|
|
14807
|
+
_this.editor.setEditorStyle(getTextSelectionStyle_1.RANGE_SELECTION_CSS_KEY, textSelectionStyle, [
|
|
14808
|
+
'*::selection',
|
|
14809
|
+
]);
|
|
14810
|
+
}
|
|
14811
|
+
}
|
|
14812
|
+
// Safari cannot retrieve the original selection on blur, so cache it while focused.
|
|
14670
14813
|
if (_this.isSafari) {
|
|
14671
14814
|
_this.state.selection = newSelection;
|
|
14672
14815
|
}
|
|
@@ -14685,12 +14828,20 @@ var SelectionPlugin = /** @class */ (function () {
|
|
|
14685
14828
|
? undefined
|
|
14686
14829
|
: exports.DEFAULT_TABLE_CELL_SELECTION_BACKGROUND_COLOR,
|
|
14687
14830
|
};
|
|
14831
|
+
if (options.textSelectionColor) {
|
|
14832
|
+
this.state.textSelectionColor = options.textSelectionColor;
|
|
14833
|
+
}
|
|
14688
14834
|
}
|
|
14689
14835
|
SelectionPlugin.prototype.getName = function () {
|
|
14690
14836
|
return 'Selection';
|
|
14691
14837
|
};
|
|
14692
14838
|
SelectionPlugin.prototype.initialize = function (editor) {
|
|
14693
14839
|
this.editor = editor;
|
|
14840
|
+
if (!this.state.textSelectionColorDark && this.state.textSelectionColor) {
|
|
14841
|
+
this.state.textSelectionColorDark = editor
|
|
14842
|
+
.getColorManager()
|
|
14843
|
+
.getDarkColor(this.state.textSelectionColor, undefined, 'background');
|
|
14844
|
+
}
|
|
14694
14845
|
if (!this.state.imageSelectionBorderColorDark && this.state.imageSelectionBorderColor) {
|
|
14695
14846
|
this.state.imageSelectionBorderColorDark = editor
|
|
14696
14847
|
.getColorManager()
|
|
@@ -17488,6 +17639,7 @@ exports.EmptySegmentFormat = {
|
|
|
17488
17639
|
letterSpacing: '',
|
|
17489
17640
|
lineHeight: '',
|
|
17490
17641
|
strikethrough: false,
|
|
17642
|
+
superOrSubScriptFontSize: '',
|
|
17491
17643
|
superOrSubScriptSequence: '',
|
|
17492
17644
|
textColor: '',
|
|
17493
17645
|
underline: false,
|
|
@@ -18874,6 +19026,7 @@ exports.linkProcessor = linkProcessor;
|
|
|
18874
19026
|
|
|
18875
19027
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
18876
19028
|
exports.listItemProcessor = void 0;
|
|
19029
|
+
var applyWordLikeListStyles_1 = __webpack_require__(/*! ../../modelApi/list/applyWordLikeListStyles */ "./packages/roosterjs-content-model-dom/lib/modelApi/list/applyWordLikeListStyles.ts");
|
|
18877
19030
|
var createListItem_1 = __webpack_require__(/*! ../../modelApi/creators/createListItem */ "./packages/roosterjs-content-model-dom/lib/modelApi/creators/createListItem.ts");
|
|
18878
19031
|
var createListLevel_1 = __webpack_require__(/*! ../../modelApi/creators/createListLevel */ "./packages/roosterjs-content-model-dom/lib/modelApi/creators/createListLevel.ts");
|
|
18879
19032
|
var parseFormat_1 = __webpack_require__(/*! ../utils/parseFormat */ "./packages/roosterjs-content-model-dom/lib/domToModel/utils/parseFormat.ts");
|
|
@@ -18882,12 +19035,13 @@ var stackFormat_1 = __webpack_require__(/*! ../utils/stackFormat */ "./packages/
|
|
|
18882
19035
|
* @internal
|
|
18883
19036
|
*/
|
|
18884
19037
|
var listItemProcessor = function (group, element, context) {
|
|
18885
|
-
var _a;
|
|
19038
|
+
var _a, _b, _c;
|
|
18886
19039
|
var listFormat = context.listFormat;
|
|
19040
|
+
var wordLikeStyles = ((_b = (_a = context.experimentalFeatures) === null || _a === void 0 ? void 0 : _a.indexOf('WordLikeStyles')) !== null && _b !== void 0 ? _b : -1) >= 0;
|
|
18887
19041
|
var originalListParent = listFormat.listParent;
|
|
18888
19042
|
var shouldPopListLevel = false;
|
|
18889
19043
|
try {
|
|
18890
|
-
listFormat.listParent = (
|
|
19044
|
+
listFormat.listParent = (_c = listFormat.listParent) !== null && _c !== void 0 ? _c : group;
|
|
18891
19045
|
var listParent_1 = listFormat.listParent;
|
|
18892
19046
|
if (listFormat.levels.length == 0) {
|
|
18893
19047
|
listFormat.levels.push((0, createListLevel_1.createListLevel)(listFormat.potentialListType || 'UL', context.blockFormat));
|
|
@@ -18895,12 +19049,16 @@ var listItemProcessor = function (group, element, context) {
|
|
|
18895
19049
|
}
|
|
18896
19050
|
(0, stackFormat_1.stackFormat)(context, {
|
|
18897
19051
|
segment: 'shallowCloneForBlock',
|
|
19052
|
+
paragraph: wordLikeStyles ? 'shallowClone' : undefined,
|
|
18898
19053
|
}, function () {
|
|
18899
19054
|
(0, parseFormat_1.parseFormat)(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
|
|
18900
19055
|
var listItem = (0, createListItem_1.createListItem)(listFormat.levels, context.segmentFormat);
|
|
18901
19056
|
(0, parseFormat_1.parseFormat)(element, context.formatParsers.listItemElement, listItem.format, context);
|
|
18902
19057
|
listParent_1.blocks.push(listItem);
|
|
18903
19058
|
(0, parseFormat_1.parseFormat)(element, context.formatParsers.listItemThread, listItem.levels[listItem.levels.length - 1].format, context);
|
|
19059
|
+
if (wordLikeStyles && listItem.format.direction) {
|
|
19060
|
+
context.blockFormat.direction = listItem.format.direction;
|
|
19061
|
+
}
|
|
18904
19062
|
context.elementProcessors.child(listItem, element, context);
|
|
18905
19063
|
var firstChild = listItem.blocks[0];
|
|
18906
19064
|
if (listItem.blocks.length == 1 &&
|
|
@@ -18909,6 +19067,9 @@ var listItemProcessor = function (group, element, context) {
|
|
|
18909
19067
|
Object.assign(listItem.format, firstChild.format);
|
|
18910
19068
|
firstChild.format = {};
|
|
18911
19069
|
}
|
|
19070
|
+
if (wordLikeStyles) {
|
|
19071
|
+
(0, applyWordLikeListStyles_1.applyWordLikeListStyles)(listItem, context.blockFormat.direction);
|
|
19072
|
+
}
|
|
18912
19073
|
});
|
|
18913
19074
|
}
|
|
18914
19075
|
finally {
|
|
@@ -21895,11 +22056,12 @@ var LTR = {
|
|
|
21895
22056
|
exports.marginFormatHandler = {
|
|
21896
22057
|
parse: function (format, element, _, defaultStyle) {
|
|
21897
22058
|
MarginKeys.forEach(function (key) {
|
|
21898
|
-
var _a, _b;
|
|
22059
|
+
var _a, _b, _c;
|
|
21899
22060
|
var alternativeKey = DefaultMarginKey[(_a = format.direction) !== null && _a !== void 0 ? _a : 'ltr'][key];
|
|
21900
22061
|
var value = element.style[key] ||
|
|
22062
|
+
(alternativeKey ? (_b = element.style[alternativeKey]) === null || _b === void 0 ? void 0 : _b.toString() : '') ||
|
|
21901
22063
|
defaultStyle[key] ||
|
|
21902
|
-
(alternativeKey ? (
|
|
22064
|
+
(alternativeKey ? (_c = defaultStyle[alternativeKey]) === null || _c === void 0 ? void 0 : _c.toString() : '');
|
|
21903
22065
|
if (value) {
|
|
21904
22066
|
switch (key) {
|
|
21905
22067
|
case 'marginTop':
|
|
@@ -22609,8 +22771,13 @@ exports.verticalAlignFormatHandler = {
|
|
|
22609
22771
|
break;
|
|
22610
22772
|
}
|
|
22611
22773
|
},
|
|
22612
|
-
apply: function (format, element) {
|
|
22613
|
-
|
|
22774
|
+
apply: function (format, element, context) {
|
|
22775
|
+
var _a, _b, _c;
|
|
22776
|
+
if (element.tagName == 'IMG' &&
|
|
22777
|
+
((_b = (_a = context.experimentalFeatures) === null || _a === void 0 ? void 0 : _a.indexOf('WordLikeStyles')) !== null && _b !== void 0 ? _b : -1) >= 0) {
|
|
22778
|
+
element.style.verticalAlign = (_c = format.verticalAlign) !== null && _c !== void 0 ? _c : 'middle';
|
|
22779
|
+
}
|
|
22780
|
+
else if (format.verticalAlign) {
|
|
22614
22781
|
element.style.verticalAlign = format.verticalAlign;
|
|
22615
22782
|
}
|
|
22616
22783
|
},
|
|
@@ -23117,6 +23284,7 @@ exports.listStyleFormatHandler = {
|
|
|
23117
23284
|
|
|
23118
23285
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
23119
23286
|
exports.boldFormatHandler = void 0;
|
|
23287
|
+
var isBlockElement_1 = __webpack_require__(/*! ../../domToModel/utils/isBlockElement */ "./packages/roosterjs-content-model-dom/lib/domToModel/utils/isBlockElement.ts");
|
|
23120
23288
|
var shouldSetValue_1 = __webpack_require__(/*! ../utils/shouldSetValue */ "./packages/roosterjs-content-model-dom/lib/formatHandlers/utils/shouldSetValue.ts");
|
|
23121
23289
|
var moveChildNodes_1 = __webpack_require__(/*! ../../domUtils/moveChildNodes */ "./packages/roosterjs-content-model-dom/lib/domUtils/moveChildNodes.ts");
|
|
23122
23290
|
/**
|
|
@@ -23136,7 +23304,7 @@ exports.boldFormatHandler = {
|
|
|
23136
23304
|
var blockFontWeight = context.implicitFormat.fontWeight;
|
|
23137
23305
|
if ((blockFontWeight && blockFontWeight != format.fontWeight) ||
|
|
23138
23306
|
(!blockFontWeight && format.fontWeight && format.fontWeight != 'normal')) {
|
|
23139
|
-
if (format.fontWeight == 'bold') {
|
|
23307
|
+
if (format.fontWeight == 'bold' && !(0, isBlockElement_1.isBlockElement)(element)) {
|
|
23140
23308
|
(0, moveChildNodes_1.wrapAllChildNodes)(element, 'b');
|
|
23141
23309
|
}
|
|
23142
23310
|
else {
|
|
@@ -23530,12 +23698,17 @@ exports.superOrSubScriptFormatHandler = {
|
|
|
23530
23698
|
parse: function (format, element, context, defaultStyle) {
|
|
23531
23699
|
var verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;
|
|
23532
23700
|
var fontSize = element.style.fontSize || defaultStyle.fontSize;
|
|
23533
|
-
|
|
23701
|
+
var inheritFontSize = (element.tagName == 'SUP' || element.tagName == 'SUB') && fontSize == 'inherit';
|
|
23702
|
+
if (isSuperOrSubScript(fontSize, verticalAlign) ||
|
|
23703
|
+
(inheritFontSize && (verticalAlign == 'super' || verticalAlign == 'sub'))) {
|
|
23534
23704
|
format.superOrSubScriptSequence = (format.superOrSubScriptSequence || '')
|
|
23535
23705
|
.split(' ')
|
|
23536
23706
|
.concat(verticalAlign)
|
|
23537
23707
|
.join(' ')
|
|
23538
23708
|
.trim();
|
|
23709
|
+
if (inheritFontSize) {
|
|
23710
|
+
format.superOrSubScriptFontSize = 'inherit';
|
|
23711
|
+
}
|
|
23539
23712
|
}
|
|
23540
23713
|
},
|
|
23541
23714
|
apply: function (format, element) {
|
|
@@ -23546,7 +23719,10 @@ exports.superOrSubScriptFormatHandler = {
|
|
|
23546
23719
|
.forEach(function (value) {
|
|
23547
23720
|
var tagName = value == 'super' ? 'sup' : value == 'sub' ? 'sub' : null;
|
|
23548
23721
|
if (tagName) {
|
|
23549
|
-
(0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
|
|
23722
|
+
var wrapper = (0, moveChildNodes_1.wrapAllChildNodes)(element, tagName);
|
|
23723
|
+
if (format.superOrSubScriptFontSize) {
|
|
23724
|
+
wrapper.style.fontSize = format.superOrSubScriptFontSize;
|
|
23725
|
+
}
|
|
23550
23726
|
}
|
|
23551
23727
|
});
|
|
23552
23728
|
}
|
|
@@ -25482,9 +25658,9 @@ exports.normalizeSegmentFormat = normalizeSegmentFormat;
|
|
|
25482
25658
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25483
25659
|
exports.stripInvisibleUnicode = void 0;
|
|
25484
25660
|
// According to https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
|
|
25485
|
-
// there are some invisible unicode characters in the range of U+E0000 to U+
|
|
25661
|
+
// there are some invisible unicode characters in the range of U+E0000 to U+E007F, which are used for hiding text in HTML.
|
|
25486
25662
|
// We need to strip them out before processing the pasted content, otherwise they will be treated as normal text and cause unexpected behavior.
|
|
25487
|
-
var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{
|
|
25663
|
+
var INVISIBLE_UNICODE_REGEX = /[\u{E0000}-\u{E007F}]/gu;
|
|
25488
25664
|
/**
|
|
25489
25665
|
* @internal
|
|
25490
25666
|
* Strip invisible unicode characters from the given string
|
|
@@ -27465,21 +27641,22 @@ var KeysOfSegmentFormat = (0, getObjectKeys_1.getObjectKeys)(EmptySegmentFormat_
|
|
|
27465
27641
|
* @returns Insert point after merge, or null if there is no insert point
|
|
27466
27642
|
*/
|
|
27467
27643
|
function mergeModel(target, source, context, options) {
|
|
27468
|
-
var _a, _b;
|
|
27644
|
+
var _a, _b, _c;
|
|
27469
27645
|
var insertPosition = (_a = options === null || options === void 0 ? void 0 : options.insertPosition) !== null && _a !== void 0 ? _a : (0, deleteSelection_1.deleteSelection)(target, [], context).insertPoint;
|
|
27470
|
-
var
|
|
27646
|
+
var _d = options || {}, addParagraphAfterMergedContent = _d.addParagraphAfterMergedContent, mergeFormat = _d.mergeFormat, mergeParagraphAfterList = _d.mergeParagraphAfterList, mergeTable = _d.mergeTable;
|
|
27471
27647
|
if (mergeParagraphAfterList && insertPosition && ((_b = source.blocks[0]) === null || _b === void 0 ? void 0 : _b.blockType) == 'Paragraph') {
|
|
27472
27648
|
moveParagraphAfterListIntoList(insertPosition);
|
|
27473
27649
|
}
|
|
27474
27650
|
if (addParagraphAfterMergedContent && !mergeTable) {
|
|
27475
|
-
var
|
|
27651
|
+
var _e = insertPosition || {}, paragraph = _e.paragraph, marker = _e.marker;
|
|
27476
27652
|
var newPara = (0, createParagraph_1.createParagraph)(false /* isImplicit */, paragraph === null || paragraph === void 0 ? void 0 : paragraph.format, marker === null || marker === void 0 ? void 0 : marker.format);
|
|
27477
27653
|
(0, addBlock_1.addBlock)(source, newPara);
|
|
27478
27654
|
}
|
|
27479
27655
|
if (insertPosition) {
|
|
27480
27656
|
if (mergeFormat && mergeFormat != 'none') {
|
|
27481
|
-
var newFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (target.format || {})),
|
|
27482
|
-
|
|
27657
|
+
var newFormat = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, (target.format || {})), ((options === null || options === void 0 ? void 0 : options.preserveParagraphDecorator)
|
|
27658
|
+
? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (_c = insertPosition.paragraph.decorator) === null || _c === void 0 ? void 0 : _c.format), insertPosition.paragraph.segmentFormat) : undefined)), insertPosition.marker.format);
|
|
27659
|
+
applyDefaultFormat(source, newFormat, mergeFormat, options === null || options === void 0 ? void 0 : options.preserveParagraphDecorator);
|
|
27483
27660
|
}
|
|
27484
27661
|
for (var i = 0; i < source.blocks.length; i++) {
|
|
27485
27662
|
var block = source.blocks[i];
|
|
@@ -27757,7 +27934,7 @@ function insertBlock(markerPosition, block) {
|
|
|
27757
27934
|
(0, mutate_1.mutateBlock)(path[0]).blocks.splice(blockIndex, 0, block);
|
|
27758
27935
|
}
|
|
27759
27936
|
}
|
|
27760
|
-
function applyDefaultFormat(group, format, applyDefaultFormatOption) {
|
|
27937
|
+
function applyDefaultFormat(group, format, applyDefaultFormatOption, preserveParagraphDecorator) {
|
|
27761
27938
|
group.blocks.forEach(function (block) {
|
|
27762
27939
|
var _a;
|
|
27763
27940
|
mergeBlockFormat(applyDefaultFormatOption, block);
|
|
@@ -27766,28 +27943,32 @@ function applyDefaultFormat(group, format, applyDefaultFormatOption) {
|
|
|
27766
27943
|
if (block.blockGroupType == 'ListItem') {
|
|
27767
27944
|
(0, mutate_1.mutateBlock)(block).formatHolder.format = mergeSegmentFormat(applyDefaultFormatOption, format, block.formatHolder.format);
|
|
27768
27945
|
}
|
|
27769
|
-
applyDefaultFormat(block, format, applyDefaultFormatOption);
|
|
27946
|
+
applyDefaultFormat(block, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
27770
27947
|
break;
|
|
27771
27948
|
case 'Table':
|
|
27772
27949
|
block.rows.forEach(function (row) {
|
|
27773
27950
|
return row.cells.forEach(function (cell) {
|
|
27774
|
-
applyDefaultFormat(cell, format, applyDefaultFormatOption);
|
|
27951
|
+
applyDefaultFormat(cell, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
27775
27952
|
});
|
|
27776
27953
|
});
|
|
27777
27954
|
break;
|
|
27778
27955
|
case 'Paragraph':
|
|
27779
27956
|
var paragraphFormat_1 = ((_a = block.decorator) === null || _a === void 0 ? void 0 : _a.format) || {};
|
|
27780
27957
|
var paragraph = (0, mutate_1.mutateBlock)(block);
|
|
27958
|
+
var paragraphTargetFormat_1 = applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
|
|
27959
|
+
preserveParagraphDecorator
|
|
27960
|
+
? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, format), paragraphFormat_1) : format;
|
|
27781
27961
|
paragraph.segments.forEach(function (segment) {
|
|
27782
27962
|
if (segment.segmentType == 'General') {
|
|
27783
|
-
applyDefaultFormat(segment, format, applyDefaultFormatOption);
|
|
27963
|
+
applyDefaultFormat(segment, format, applyDefaultFormatOption, preserveParagraphDecorator);
|
|
27784
27964
|
}
|
|
27785
|
-
segment.format = mergeSegmentFormat(applyDefaultFormatOption,
|
|
27965
|
+
segment.format = mergeSegmentFormat(applyDefaultFormatOption, paragraphTargetFormat_1, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, paragraphFormat_1), segment.format));
|
|
27786
27966
|
if (segment.link) {
|
|
27787
27967
|
segment.link.format = mergeLinkFormat(applyDefaultFormatOption, format, segment.link.format);
|
|
27788
27968
|
}
|
|
27789
27969
|
});
|
|
27790
|
-
if (applyDefaultFormatOption === 'keepSourceEmphasisFormat'
|
|
27970
|
+
if (applyDefaultFormatOption === 'keepSourceEmphasisFormat' &&
|
|
27971
|
+
!preserveParagraphDecorator) {
|
|
27791
27972
|
delete paragraph.decorator;
|
|
27792
27973
|
}
|
|
27793
27974
|
break;
|
|
@@ -27837,7 +28018,7 @@ function mergeSegmentFormat(applyDefaultFormatOption, targetFormat, sourceFormat
|
|
|
27837
28018
|
}
|
|
27838
28019
|
function getSemanticFormat(segmentFormat) {
|
|
27839
28020
|
var result = {};
|
|
27840
|
-
var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline;
|
|
28021
|
+
var fontWeight = segmentFormat.fontWeight, italic = segmentFormat.italic, underline = segmentFormat.underline, strikethrough = segmentFormat.strikethrough;
|
|
27841
28022
|
if (fontWeight && fontWeight != 'normal') {
|
|
27842
28023
|
result.fontWeight = fontWeight;
|
|
27843
28024
|
}
|
|
@@ -27847,6 +28028,9 @@ function getSemanticFormat(segmentFormat) {
|
|
|
27847
28028
|
if (underline) {
|
|
27848
28029
|
result.underline = underline;
|
|
27849
28030
|
}
|
|
28031
|
+
if (strikethrough) {
|
|
28032
|
+
result.strikethrough = strikethrough;
|
|
28033
|
+
}
|
|
27850
28034
|
return result;
|
|
27851
28035
|
}
|
|
27852
28036
|
/**
|
|
@@ -28440,6 +28624,44 @@ function areSameColor(color1, color2) {
|
|
|
28440
28624
|
}
|
|
28441
28625
|
|
|
28442
28626
|
|
|
28627
|
+
/***/ },
|
|
28628
|
+
|
|
28629
|
+
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/list/applyWordLikeListStyles.ts"
|
|
28630
|
+
/*!*******************************************************************************************!*\
|
|
28631
|
+
!*** ./packages/roosterjs-content-model-dom/lib/modelApi/list/applyWordLikeListStyles.ts ***!
|
|
28632
|
+
\*******************************************************************************************/
|
|
28633
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
28634
|
+
|
|
28635
|
+
"use strict";
|
|
28636
|
+
|
|
28637
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
28638
|
+
exports.applyWordLikeListStyles = void 0;
|
|
28639
|
+
var mutate_1 = __webpack_require__(/*! ../common/mutate */ "./packages/roosterjs-content-model-dom/lib/modelApi/common/mutate.ts");
|
|
28640
|
+
var setParagraphNotImplicit_1 = __webpack_require__(/*! ../block/setParagraphNotImplicit */ "./packages/roosterjs-content-model-dom/lib/modelApi/block/setParagraphNotImplicit.ts");
|
|
28641
|
+
/**
|
|
28642
|
+
* @internal
|
|
28643
|
+
* Store default Word-like list spacing in the model and retain paragraph wrappers.
|
|
28644
|
+
*/
|
|
28645
|
+
function applyWordLikeListStyles(listItem, inheritedDirection) {
|
|
28646
|
+
var _a;
|
|
28647
|
+
listItem.format.marginBottom = (_a = listItem.format.marginBottom) !== null && _a !== void 0 ? _a : '2px';
|
|
28648
|
+
listItem.blocks.forEach(function (block) {
|
|
28649
|
+
var _a, _b, _c, _d;
|
|
28650
|
+
(0, setParagraphNotImplicit_1.setParagraphNotImplicit)(block);
|
|
28651
|
+
var direction = (_d = (_b = (_a = block.format.direction) !== null && _a !== void 0 ? _a : listItem.format.direction) !== null && _b !== void 0 ? _b : (_c = listItem.levels[listItem.levels.length - 1]) === null || _c === void 0 ? void 0 : _c.format.direction) !== null && _d !== void 0 ? _d : inheritedDirection;
|
|
28652
|
+
var marginKey = direction == 'rtl' ? 'marginRight' : 'marginLeft';
|
|
28653
|
+
if (block.format[marginKey] == undefined) {
|
|
28654
|
+
var format = (0, mutate_1.mutateBlock)(block).format;
|
|
28655
|
+
format[marginKey] = '8px';
|
|
28656
|
+
if (direction == 'rtl') {
|
|
28657
|
+
format.direction = direction;
|
|
28658
|
+
}
|
|
28659
|
+
}
|
|
28660
|
+
});
|
|
28661
|
+
}
|
|
28662
|
+
exports.applyWordLikeListStyles = applyWordLikeListStyles;
|
|
28663
|
+
|
|
28664
|
+
|
|
28443
28665
|
/***/ },
|
|
28444
28666
|
|
|
28445
28667
|
/***/ "./packages/roosterjs-content-model-dom/lib/modelApi/list/getAutoListStyleType.ts"
|
|
@@ -30585,6 +30807,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
30585
30807
|
exports.handleListItem = void 0;
|
|
30586
30808
|
var applyFormat_1 = __webpack_require__(/*! ../utils/applyFormat */ "./packages/roosterjs-content-model-dom/lib/modelToDom/utils/applyFormat.ts");
|
|
30587
30809
|
var applyMetadata_1 = __webpack_require__(/*! ../utils/applyMetadata */ "./packages/roosterjs-content-model-dom/lib/modelToDom/utils/applyMetadata.ts");
|
|
30810
|
+
var applyWordLikeListStyles_1 = __webpack_require__(/*! ../../modelApi/list/applyWordLikeListStyles */ "./packages/roosterjs-content-model-dom/lib/modelApi/list/applyWordLikeListStyles.ts");
|
|
30588
30811
|
var isGenericRoleElement_1 = __webpack_require__(/*! ../../domUtils/isGenericRoleElement */ "./packages/roosterjs-content-model-dom/lib/domUtils/isGenericRoleElement.ts");
|
|
30589
30812
|
var reuseCachedElement_1 = __webpack_require__(/*! ../../domUtils/reuseCachedElement */ "./packages/roosterjs-content-model-dom/lib/domUtils/reuseCachedElement.ts");
|
|
30590
30813
|
var setParagraphNotImplicit_1 = __webpack_require__(/*! ../../modelApi/block/setParagraphNotImplicit */ "./packages/roosterjs-content-model-dom/lib/modelApi/block/setParagraphNotImplicit.ts");
|
|
@@ -30596,10 +30819,11 @@ var PresentationRoleValue = 'presentation';
|
|
|
30596
30819
|
* @internal
|
|
30597
30820
|
*/
|
|
30598
30821
|
var handleListItem = function (doc, parent, listItem, context, refNode) {
|
|
30599
|
-
var _a, _b;
|
|
30822
|
+
var _a, _b, _c, _d;
|
|
30600
30823
|
refNode = context.modelHandlers.list(doc, parent, listItem, context, refNode);
|
|
30601
30824
|
var nodeStack = context.listFormat.nodeStack;
|
|
30602
|
-
var
|
|
30825
|
+
var wordLikeStyles = ((_b = (_a = context.experimentalFeatures) === null || _a === void 0 ? void 0 : _a.indexOf('WordLikeStyles')) !== null && _b !== void 0 ? _b : -1) >= 0;
|
|
30826
|
+
var leafLevel = (_c = nodeStack === null || nodeStack === void 0 ? void 0 : nodeStack[nodeStack.length - 1]) !== null && _c !== void 0 ? _c : {};
|
|
30603
30827
|
var itemRefNode = leafLevel.refNode || null;
|
|
30604
30828
|
var listParent = leafLevel.node || parent;
|
|
30605
30829
|
var level = listItem.levels[listItem.levels.length - 1];
|
|
@@ -30627,6 +30851,9 @@ var handleListItem = function (doc, parent, listItem, context, refNode) {
|
|
|
30627
30851
|
listItem.cachedElement = li;
|
|
30628
30852
|
}
|
|
30629
30853
|
if (level) {
|
|
30854
|
+
if (wordLikeStyles) {
|
|
30855
|
+
(0, applyWordLikeListStyles_1.applyWordLikeListStyles)(listItem, context.implicitFormat.direction);
|
|
30856
|
+
}
|
|
30630
30857
|
(0, applyFormat_1.applyFormat)(li, context.formatAppliers.segment, listItem.formatHolder.format, context);
|
|
30631
30858
|
(0, applyFormat_1.applyFormat)(li, context.formatAppliers.listItemThread, level.format, context);
|
|
30632
30859
|
// Need to apply metadata after applying listItem format since the list numbers value relies on the result of list thread handling
|
|
@@ -30656,7 +30883,7 @@ var handleListItem = function (doc, parent, listItem, context, refNode) {
|
|
|
30656
30883
|
}
|
|
30657
30884
|
}
|
|
30658
30885
|
if (isNewlyCreated) {
|
|
30659
|
-
(
|
|
30886
|
+
(_d = context.onNodeCreated) === null || _d === void 0 ? void 0 : _d.call(context, listItem, li);
|
|
30660
30887
|
}
|
|
30661
30888
|
return refNode;
|
|
30662
30889
|
};
|
|
@@ -31838,11 +32065,27 @@ exports.createTableFromMarkdown = void 0;
|
|
|
31838
32065
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
31839
32066
|
var createParagraphFromMarkdown_1 = __webpack_require__(/*! ./createParagraphFromMarkdown */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/creators/createParagraphFromMarkdown.ts");
|
|
31840
32067
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
32068
|
+
var DefaultMarkdownTable = {
|
|
32069
|
+
headerRowColor: null,
|
|
32070
|
+
topBorderColor: '#000',
|
|
32071
|
+
bottomBorderColor: '#000',
|
|
32072
|
+
verticalBorderColor: '#000',
|
|
32073
|
+
tableBorderFormat: roosterjs_content_model_dom_1.TableBorderFormat.Default,
|
|
32074
|
+
headerRowCustomStyles: {
|
|
32075
|
+
fontWeight: 'normal',
|
|
32076
|
+
italic: false,
|
|
32077
|
+
},
|
|
32078
|
+
firstColumnCustomStyles: {
|
|
32079
|
+
fontWeight: 'normal',
|
|
32080
|
+
italic: false,
|
|
32081
|
+
},
|
|
32082
|
+
};
|
|
31841
32083
|
/**
|
|
31842
32084
|
* @internal
|
|
31843
32085
|
*/
|
|
31844
32086
|
function createTableFromMarkdown(tableLines, options) {
|
|
31845
32087
|
var e_1, _a;
|
|
32088
|
+
var _b;
|
|
31846
32089
|
var tableDivider = tableLines[1].split('|').filter(function (content) { return content.trim() !== ''; });
|
|
31847
32090
|
tableLines.splice(1, 1);
|
|
31848
32091
|
var table = (0, roosterjs_content_model_dom_1.createTable)(0, options.direction
|
|
@@ -31861,9 +32104,7 @@ function createTableFromMarkdown(tableLines, options) {
|
|
|
31861
32104
|
}
|
|
31862
32105
|
finally { if (e_1) throw e_1.error; }
|
|
31863
32106
|
}
|
|
31864
|
-
(0, roosterjs_content_model_dom_1.applyTableFormat)(table,
|
|
31865
|
-
hasHeaderRow: true,
|
|
31866
|
-
});
|
|
32107
|
+
(0, roosterjs_content_model_dom_1.applyTableFormat)(table, (_b = options.tableStyles) !== null && _b !== void 0 ? _b : DefaultMarkdownTable);
|
|
31867
32108
|
return table;
|
|
31868
32109
|
}
|
|
31869
32110
|
exports.createTableFromMarkdown = createTableFromMarkdown;
|
|
@@ -32843,12 +33084,16 @@ exports.modelProcessor = modelProcessor;
|
|
|
32843
33084
|
|
|
32844
33085
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
32845
33086
|
exports.MarkdownPastePlugin = void 0;
|
|
33087
|
+
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
32846
33088
|
var convertMarkdownToContentModel_1 = __webpack_require__(/*! ../markdownToModel/convertMarkdownToContentModel */ "./packages/roosterjs-content-model-markdown/lib/markdownToModel/convertMarkdownToContentModel.ts");
|
|
32847
33089
|
var isPastedContentMarkdown_1 = __webpack_require__(/*! ../publicApi/isPastedContentMarkdown */ "./packages/roosterjs-content-model-markdown/lib/publicApi/isPastedContentMarkdown.ts");
|
|
32848
33090
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
32849
33091
|
var DefaultOptions = {
|
|
32850
33092
|
autoConversion: false,
|
|
32851
33093
|
undoConversion: false,
|
|
33094
|
+
markdownToModelOptions: {
|
|
33095
|
+
emptyLine: 'merge',
|
|
33096
|
+
},
|
|
32852
33097
|
};
|
|
32853
33098
|
/**
|
|
32854
33099
|
* Markdown paste plugin. Handles the BeforePaste event and, when the pasted content
|
|
@@ -32861,8 +33106,9 @@ var MarkdownPastePlugin = /** @class */ (function () {
|
|
|
32861
33106
|
* @param options Options to control the markdown paste behavior
|
|
32862
33107
|
*/
|
|
32863
33108
|
function MarkdownPastePlugin(options) {
|
|
33109
|
+
var _a, _b;
|
|
32864
33110
|
this.editor = null;
|
|
32865
|
-
this.options = options !== null &&
|
|
33111
|
+
this.options = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultOptions), options), { markdownToModelOptions: (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultOptions.markdownToModelOptions), options === null || options === void 0 ? void 0 : options.markdownToModelOptions), { emptyLine: (_b = (_a = options === null || options === void 0 ? void 0 : options.markdownToModelOptions) === null || _a === void 0 ? void 0 : _a.emptyLine) !== null && _b !== void 0 ? _b : 'merge' }) });
|
|
32866
33112
|
}
|
|
32867
33113
|
/**
|
|
32868
33114
|
* Get name of this plugin
|
|
@@ -32907,10 +33153,9 @@ var MarkdownPastePlugin = /** @class */ (function () {
|
|
|
32907
33153
|
(0, isPastedContentMarkdown_1.isPastedContentMarkdown)(this.editor, clipboardData) &&
|
|
32908
33154
|
clipboardData.modelBeforePaste) {
|
|
32909
33155
|
var modelBeforePaste_1 = (0, roosterjs_content_model_dom_1.cloneModelForPaste)(clipboardData.modelBeforePaste);
|
|
32910
|
-
(0, roosterjs_content_model_dom_1.mergeModel)(modelBeforePaste_1, (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(clipboardData.text, {
|
|
32911
|
-
|
|
32912
|
-
|
|
32913
|
-
mergeFormat: 'preferTarget',
|
|
33156
|
+
(0, roosterjs_content_model_dom_1.mergeModel)(modelBeforePaste_1, (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(clipboardData.text, this.options.markdownToModelOptions), undefined /*context*/, {
|
|
33157
|
+
mergeFormat: 'keepSourceEmphasisFormat',
|
|
33158
|
+
preserveParagraphDecorator: true,
|
|
32914
33159
|
});
|
|
32915
33160
|
if (this.options.undoConversion) {
|
|
32916
33161
|
this.editor.takeSnapshot();
|
|
@@ -32928,17 +33173,15 @@ var MarkdownPastePlugin = /** @class */ (function () {
|
|
|
32928
33173
|
else if (event.eventType === 'beforePaste' && !event.clipboardData.pasteNativeEvent) {
|
|
32929
33174
|
var shouldConvert = event.pasteType === 'asMarkdown';
|
|
32930
33175
|
if (shouldConvert && (0, isPastedContentMarkdown_1.isPastedContentMarkdown)(this.editor, event.clipboardData)) {
|
|
32931
|
-
convertPastedTextToMarkdown(this.editor, event.fragment, event.clipboardData.text);
|
|
33176
|
+
convertPastedTextToMarkdown(this.editor, event.fragment, event.clipboardData.text, this.options.markdownToModelOptions);
|
|
32932
33177
|
}
|
|
32933
33178
|
}
|
|
32934
33179
|
};
|
|
32935
33180
|
return MarkdownPastePlugin;
|
|
32936
33181
|
}());
|
|
32937
33182
|
exports.MarkdownPastePlugin = MarkdownPastePlugin;
|
|
32938
|
-
function convertPastedTextToMarkdown(editor, fragment, text) {
|
|
32939
|
-
var model = (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(text,
|
|
32940
|
-
emptyLine: 'merge',
|
|
32941
|
-
});
|
|
33183
|
+
function convertPastedTextToMarkdown(editor, fragment, text, markdownToModelOptions) {
|
|
33184
|
+
var model = (0, convertMarkdownToContentModel_1.convertMarkdownToContentModel)(text, markdownToModelOptions);
|
|
32942
33185
|
while (fragment.firstChild) {
|
|
32943
33186
|
fragment.removeChild(fragment.firstChild);
|
|
32944
33187
|
}
|
|
@@ -33621,9 +33864,10 @@ var createAnchor = function (doc, url, text) {
|
|
|
33621
33864
|
"use strict";
|
|
33622
33865
|
|
|
33623
33866
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
33624
|
-
exports.checkAndInsertHorizontalLine =
|
|
33867
|
+
exports.checkAndInsertHorizontalLine = void 0;
|
|
33625
33868
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
33626
33869
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
33870
|
+
var roosterjs_content_model_api_1 = __webpack_require__(/*! roosterjs-content-model-api */ "./packages/roosterjs-content-model-api/lib/index.ts");
|
|
33627
33871
|
var HorizontalLineTriggerCharacters = [
|
|
33628
33872
|
'-',
|
|
33629
33873
|
'=',
|
|
@@ -33662,28 +33906,14 @@ var HorizontalLineStyles = new Map([
|
|
|
33662
33906
|
(0, tslib_1.__assign)({ borderTop: '3pt double', borderRight: '3pt none', borderBottom: '3pt double', borderLeft: '3pt none' }, commonStyles),
|
|
33663
33907
|
],
|
|
33664
33908
|
]);
|
|
33665
|
-
/**
|
|
33666
|
-
* @internal exported only for unit test
|
|
33667
|
-
*
|
|
33668
|
-
* Create a horizontal line and insert it into the model
|
|
33669
|
-
*
|
|
33670
|
-
* @param model the model to insert horizontal line into
|
|
33671
|
-
* @param context the formatting context
|
|
33672
|
-
*/
|
|
33673
|
-
function insertHorizontalLineIntoModel(model, context, triggerChar) {
|
|
33674
|
-
var hr = (0, roosterjs_content_model_dom_1.createDivider)('hr', HorizontalLineStyles.get(triggerChar));
|
|
33675
|
-
var doc = (0, roosterjs_content_model_dom_1.createContentModelDocument)();
|
|
33676
|
-
(0, roosterjs_content_model_dom_1.addBlock)(doc, hr);
|
|
33677
|
-
(0, roosterjs_content_model_dom_1.mergeModel)(model, doc, context);
|
|
33678
|
-
}
|
|
33679
|
-
exports.insertHorizontalLineIntoModel = insertHorizontalLineIntoModel;
|
|
33680
33909
|
/**
|
|
33681
33910
|
* @internal
|
|
33682
33911
|
*
|
|
33683
33912
|
* Check if the current line should be formatted as horizontal line, and insert horizontal line if needed
|
|
33684
33913
|
*
|
|
33685
|
-
* @param
|
|
33686
|
-
* @param
|
|
33914
|
+
* @param model The model to check and insert horizontal line into
|
|
33915
|
+
* @param paragraph The paragraph to check for trigger characters
|
|
33916
|
+
* @param context The formatting context
|
|
33687
33917
|
* @returns True if horizontal line is inserted, otherwise false
|
|
33688
33918
|
*/
|
|
33689
33919
|
var checkAndInsertHorizontalLine = function (model, paragraph, context) {
|
|
@@ -33703,7 +33933,7 @@ var checkAndInsertHorizontalLine = function (model, paragraph, context) {
|
|
|
33703
33933
|
var shouldFormat = allText.split('').every(function (char) { return char === triggerCharacter; });
|
|
33704
33934
|
if (shouldFormat) {
|
|
33705
33935
|
paragraph.segments = paragraph.segments.filter(function (s) { return s.segmentType != 'Text'; });
|
|
33706
|
-
insertHorizontalLineIntoModel(model, context, triggerCharacter);
|
|
33936
|
+
(0, roosterjs_content_model_api_1.insertHorizontalLineIntoModel)(model, context, HorizontalLineStyles.get(triggerCharacter));
|
|
33707
33937
|
context.canUndoByBackspace = true;
|
|
33708
33938
|
}
|
|
33709
33939
|
return shouldFormat;
|
|
@@ -37591,6 +37821,211 @@ var HyperlinkPlugin = /** @class */ (function () {
|
|
|
37591
37821
|
exports.HyperlinkPlugin = HyperlinkPlugin;
|
|
37592
37822
|
|
|
37593
37823
|
|
|
37824
|
+
/***/ },
|
|
37825
|
+
|
|
37826
|
+
/***/ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/ImageCropKeyboardHelper.ts"
|
|
37827
|
+
/*!***************************************************************************************************!*\
|
|
37828
|
+
!*** ./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/ImageCropKeyboardHelper.ts ***!
|
|
37829
|
+
\***************************************************************************************************/
|
|
37830
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
37831
|
+
|
|
37832
|
+
"use strict";
|
|
37833
|
+
|
|
37834
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
37835
|
+
exports.ImageCropKeyboardHelper = void 0;
|
|
37836
|
+
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
37837
|
+
var cropperContext_1 = __webpack_require__(/*! ./cropperContext */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/cropperContext.ts");
|
|
37838
|
+
var ImageEditElementClass_1 = __webpack_require__(/*! ../types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
|
|
37839
|
+
var DefaultTopLeftLabel = 'Top left';
|
|
37840
|
+
var DefaultBottomRightLabel = 'Bottom right';
|
|
37841
|
+
var DefaultMoveCropLabel = 'Move Crop';
|
|
37842
|
+
var FocusTargetAttributes = [
|
|
37843
|
+
'tabindex',
|
|
37844
|
+
'contenteditable',
|
|
37845
|
+
'role',
|
|
37846
|
+
'aria-label',
|
|
37847
|
+
'aria-describedby',
|
|
37848
|
+
'part',
|
|
37849
|
+
];
|
|
37850
|
+
/**
|
|
37851
|
+
* @internal
|
|
37852
|
+
* Keyboard cropping shares the pointer handler's geometry and constraints.
|
|
37853
|
+
*/
|
|
37854
|
+
var ImageCropKeyboardHelper = /** @class */ (function () {
|
|
37855
|
+
function ImageCropKeyboardHelper(wrapper, imageId, editInfo, options, onCrop, onFinish) {
|
|
37856
|
+
var _this = this;
|
|
37857
|
+
this.wrapper = wrapper;
|
|
37858
|
+
this.editInfo = editInfo;
|
|
37859
|
+
this.options = options;
|
|
37860
|
+
this.onCrop = onCrop;
|
|
37861
|
+
this.onFinish = onFinish;
|
|
37862
|
+
this.cropFocusTargets = [];
|
|
37863
|
+
this.disposed = false;
|
|
37864
|
+
this.stopPropagation = function (event) {
|
|
37865
|
+
if (_this.contains(event.target)) {
|
|
37866
|
+
event.stopPropagation();
|
|
37867
|
+
}
|
|
37868
|
+
};
|
|
37869
|
+
this.onFocusOut = function (event) {
|
|
37870
|
+
if (!_this.disposed && _this.contains(event.target) && !_this.contains(event.relatedTarget)) {
|
|
37871
|
+
_this.onFinish(true, false);
|
|
37872
|
+
}
|
|
37873
|
+
};
|
|
37874
|
+
this.onKeyDown = function (event) {
|
|
37875
|
+
if (!_this.contains(event.target)) {
|
|
37876
|
+
return;
|
|
37877
|
+
}
|
|
37878
|
+
event.stopPropagation();
|
|
37879
|
+
if (event.key == 'Tab') {
|
|
37880
|
+
var index = _this.cropFocusTargets.findIndex(function (target) { return target === event.target; });
|
|
37881
|
+
var next = _this.cropFocusTargets[index + (event.shiftKey ? -1 : 1)];
|
|
37882
|
+
if (next) {
|
|
37883
|
+
event.preventDefault();
|
|
37884
|
+
next.focus();
|
|
37885
|
+
}
|
|
37886
|
+
}
|
|
37887
|
+
else if (event.key == 'Enter' || event.key == 'Escape') {
|
|
37888
|
+
event.preventDefault();
|
|
37889
|
+
_this.onFinish(event.key == 'Enter', true);
|
|
37890
|
+
}
|
|
37891
|
+
else if (event.key == 'ArrowLeft' ||
|
|
37892
|
+
event.key == 'ArrowRight' ||
|
|
37893
|
+
event.key == 'ArrowUp' ||
|
|
37894
|
+
event.key == 'ArrowDown') {
|
|
37895
|
+
event.preventDefault();
|
|
37896
|
+
if (!event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
37897
|
+
_this.crop(event);
|
|
37898
|
+
}
|
|
37899
|
+
}
|
|
37900
|
+
else if (event.key == ' ' || event.key == 'Delete' || event.key == 'Backspace') {
|
|
37901
|
+
event.preventDefault();
|
|
37902
|
+
}
|
|
37903
|
+
};
|
|
37904
|
+
var cropLabels = options.cropLabels;
|
|
37905
|
+
if (cropLabels === null || cropLabels === void 0 ? void 0 : cropLabels.instructions) {
|
|
37906
|
+
this.instructions = this.createInstructions(imageId, cropLabels.instructions);
|
|
37907
|
+
wrapper.appendChild(this.instructions);
|
|
37908
|
+
}
|
|
37909
|
+
['nw', 'se'].forEach(function (direction) {
|
|
37910
|
+
var _a;
|
|
37911
|
+
var handle = wrapper.querySelector("." + ImageEditElementClass_1.ImageEditElementClass.CropHandle + "[data-y=\"" + direction[0] + "\"][data-x=\"" + direction[1] + "\"]");
|
|
37912
|
+
if (handle) {
|
|
37913
|
+
_this.prepareTarget(handle, ((_a = cropLabels === null || cropLabels === void 0 ? void 0 : cropLabels.handleLabel) === null || _a === void 0 ? void 0 : _a.call(cropLabels, direction)) ||
|
|
37914
|
+
(direction == 'nw' ? DefaultTopLeftLabel : DefaultBottomRightLabel));
|
|
37915
|
+
}
|
|
37916
|
+
});
|
|
37917
|
+
this.cropMoveTarget = wrapper.querySelector("." + ImageEditElementClass_1.ImageEditElementClass.ImageBorder);
|
|
37918
|
+
if (this.cropMoveTarget) {
|
|
37919
|
+
wrapper.appendChild(this.cropMoveTarget);
|
|
37920
|
+
this.prepareTarget(this.cropMoveTarget, (cropLabels === null || cropLabels === void 0 ? void 0 : cropLabels.moveCropLabel) || DefaultMoveCropLabel);
|
|
37921
|
+
}
|
|
37922
|
+
// Make native tab entry start at the top-left corner as well.
|
|
37923
|
+
var first = this.cropFocusTargets[0];
|
|
37924
|
+
if (first === null || first === void 0 ? void 0 : first.parentElement) {
|
|
37925
|
+
first.parentElement.insertBefore(first, first.parentElement.firstChild);
|
|
37926
|
+
}
|
|
37927
|
+
wrapper.addEventListener('keydown', this.onKeyDown);
|
|
37928
|
+
wrapper.addEventListener('keyup', this.stopPropagation);
|
|
37929
|
+
wrapper.addEventListener('keypress', this.stopPropagation);
|
|
37930
|
+
wrapper.addEventListener('focusout', this.onFocusOut);
|
|
37931
|
+
}
|
|
37932
|
+
ImageCropKeyboardHelper.prototype.focus = function () {
|
|
37933
|
+
var _a;
|
|
37934
|
+
(_a = this.cropFocusTargets[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
37935
|
+
};
|
|
37936
|
+
ImageCropKeyboardHelper.prototype.contains = function (target) {
|
|
37937
|
+
return this.cropFocusTargets.some(function (element) { return element === target; });
|
|
37938
|
+
};
|
|
37939
|
+
ImageCropKeyboardHelper.prototype.dispose = function () {
|
|
37940
|
+
var e_1, _a, e_2, _b;
|
|
37941
|
+
var _c;
|
|
37942
|
+
this.disposed = true;
|
|
37943
|
+
this.wrapper.removeEventListener('keydown', this.onKeyDown);
|
|
37944
|
+
this.wrapper.removeEventListener('keyup', this.stopPropagation);
|
|
37945
|
+
this.wrapper.removeEventListener('keypress', this.stopPropagation);
|
|
37946
|
+
this.wrapper.removeEventListener('focusout', this.onFocusOut);
|
|
37947
|
+
try {
|
|
37948
|
+
for (var _d = (0, tslib_1.__values)(this.cropFocusTargets), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
37949
|
+
var target = _e.value;
|
|
37950
|
+
try {
|
|
37951
|
+
for (var FocusTargetAttributes_1 = (e_2 = void 0, (0, tslib_1.__values)(FocusTargetAttributes)), FocusTargetAttributes_1_1 = FocusTargetAttributes_1.next(); !FocusTargetAttributes_1_1.done; FocusTargetAttributes_1_1 = FocusTargetAttributes_1.next()) {
|
|
37952
|
+
var attribute = FocusTargetAttributes_1_1.value;
|
|
37953
|
+
target.removeAttribute(attribute);
|
|
37954
|
+
}
|
|
37955
|
+
}
|
|
37956
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
37957
|
+
finally {
|
|
37958
|
+
try {
|
|
37959
|
+
if (FocusTargetAttributes_1_1 && !FocusTargetAttributes_1_1.done && (_b = FocusTargetAttributes_1.return)) _b.call(FocusTargetAttributes_1);
|
|
37960
|
+
}
|
|
37961
|
+
finally { if (e_2) throw e_2.error; }
|
|
37962
|
+
}
|
|
37963
|
+
target.classList.remove(ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget);
|
|
37964
|
+
}
|
|
37965
|
+
}
|
|
37966
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37967
|
+
finally {
|
|
37968
|
+
try {
|
|
37969
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
37970
|
+
}
|
|
37971
|
+
finally { if (e_1) throw e_1.error; }
|
|
37972
|
+
}
|
|
37973
|
+
(_c = this.instructions) === null || _c === void 0 ? void 0 : _c.remove();
|
|
37974
|
+
};
|
|
37975
|
+
ImageCropKeyboardHelper.prototype.createInstructions = function (imageId, text) {
|
|
37976
|
+
var instructions = this.wrapper.ownerDocument.createElement('span');
|
|
37977
|
+
instructions.id = 'imageCropInstructions' + imageId;
|
|
37978
|
+
instructions.textContent = text;
|
|
37979
|
+
instructions.style.cssText =
|
|
37980
|
+
'position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;';
|
|
37981
|
+
return instructions;
|
|
37982
|
+
};
|
|
37983
|
+
ImageCropKeyboardHelper.prototype.prepareTarget = function (target, label) {
|
|
37984
|
+
target.tabIndex = 0;
|
|
37985
|
+
target.contentEditable = 'false';
|
|
37986
|
+
target.setAttribute('role', 'application');
|
|
37987
|
+
if (label) {
|
|
37988
|
+
target.setAttribute('aria-label', label);
|
|
37989
|
+
}
|
|
37990
|
+
if (this.instructions) {
|
|
37991
|
+
target.setAttribute('aria-describedby', this.instructions.id);
|
|
37992
|
+
}
|
|
37993
|
+
target.classList.add(ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget);
|
|
37994
|
+
target.setAttribute('part', ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget);
|
|
37995
|
+
this.cropFocusTargets.push(target);
|
|
37996
|
+
};
|
|
37997
|
+
ImageCropKeyboardHelper.prototype.crop = function (event) {
|
|
37998
|
+
var _a, _b;
|
|
37999
|
+
var target = this.cropFocusTargets.find(function (element) { return element === event.target; });
|
|
38000
|
+
var context = {
|
|
38001
|
+
editInfo: this.editInfo,
|
|
38002
|
+
options: this.options,
|
|
38003
|
+
elementClass: target === this.cropMoveTarget
|
|
38004
|
+
? ImageEditElementClass_1.ImageEditElementClass.CropContainer
|
|
38005
|
+
: ImageEditElementClass_1.ImageEditElementClass.CropHandle,
|
|
38006
|
+
x: (target === null || target === void 0 ? void 0 : target.dataset.x) == 'e' ? 'e' : (target === null || target === void 0 ? void 0 : target.dataset.x) == 'w' ? 'w' : '',
|
|
38007
|
+
y: (target === null || target === void 0 ? void 0 : target.dataset.y) == 'n' ? 'n' : (target === null || target === void 0 ? void 0 : target.dataset.y) == 's' ? 's' : '',
|
|
38008
|
+
};
|
|
38009
|
+
var dragEvent = {
|
|
38010
|
+
clientX: 0,
|
|
38011
|
+
clientY: 0,
|
|
38012
|
+
pageX: 0,
|
|
38013
|
+
pageY: 0,
|
|
38014
|
+
target: event.target,
|
|
38015
|
+
shiftKey: event.shiftKey,
|
|
38016
|
+
altKey: event.altKey,
|
|
38017
|
+
};
|
|
38018
|
+
var base = (_a = cropperContext_1.Cropper.onDragStart) === null || _a === void 0 ? void 0 : _a.call(cropperContext_1.Cropper, context, dragEvent);
|
|
38019
|
+
if (base &&
|
|
38020
|
+
((_b = cropperContext_1.Cropper.onDragging) === null || _b === void 0 ? void 0 : _b.call(cropperContext_1.Cropper, context, dragEvent, base, event.key == 'ArrowLeft' ? -1 : event.key == 'ArrowRight' ? 1 : 0, event.key == 'ArrowUp' ? -1 : event.key == 'ArrowDown' ? 1 : 0))) {
|
|
38021
|
+
this.onCrop();
|
|
38022
|
+
}
|
|
38023
|
+
};
|
|
38024
|
+
return ImageCropKeyboardHelper;
|
|
38025
|
+
}());
|
|
38026
|
+
exports.ImageCropKeyboardHelper = ImageCropKeyboardHelper;
|
|
38027
|
+
|
|
38028
|
+
|
|
37594
38029
|
/***/ },
|
|
37595
38030
|
|
|
37596
38031
|
/***/ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/createImageCropper.ts"
|
|
@@ -37695,6 +38130,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
37695
38130
|
exports.Cropper = void 0;
|
|
37696
38131
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
37697
38132
|
var imageEditUtils_1 = __webpack_require__(/*! ../utils/imageEditUtils */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/imageEditUtils.ts");
|
|
38133
|
+
var ImageEditElementClass_1 = __webpack_require__(/*! ../types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
|
|
37698
38134
|
/**
|
|
37699
38135
|
* @internal
|
|
37700
38136
|
* Crop handle for DragAndDropHelper
|
|
@@ -37707,7 +38143,7 @@ exports.Cropper = {
|
|
|
37707
38143
|
onDragging: function (_a, e, base, dx, dy) {
|
|
37708
38144
|
var _b;
|
|
37709
38145
|
var _c;
|
|
37710
|
-
var editInfo = _a.editInfo, x = _a.x, y = _a.y, options = _a.options;
|
|
38146
|
+
var editInfo = _a.editInfo, x = _a.x, y = _a.y, options = _a.options, elementClass = _a.elementClass;
|
|
37711
38147
|
_b = (0, tslib_1.__read)((0, imageEditUtils_1.rotateCoordinate)(dx, dy, (_c = editInfo.angleRad) !== null && _c !== void 0 ? _c : 0), 2), dx = _b[0], dy = _b[1];
|
|
37712
38148
|
var widthPx = editInfo.widthPx, heightPx = editInfo.heightPx, leftPercent = editInfo.leftPercent, rightPercent = editInfo.rightPercent, topPercent = editInfo.topPercent, bottomPercent = editInfo.bottomPercent;
|
|
37713
38149
|
if (leftPercent === undefined ||
|
|
@@ -37731,6 +38167,15 @@ exports.Cropper = {
|
|
|
37731
38167
|
minHeight !== undefined) {
|
|
37732
38168
|
var fullWidth = widthPx / widthPercent;
|
|
37733
38169
|
var fullHeight = heightPx / heightPercent;
|
|
38170
|
+
if (elementClass == ImageEditElementClass_1.ImageEditElementClass.CropContainer) {
|
|
38171
|
+
var deltaX = Math.max(-base.leftPercent, Math.min(dx / fullWidth, base.rightPercent));
|
|
38172
|
+
var deltaY = Math.max(-base.topPercent, Math.min(dy / fullHeight, base.bottomPercent));
|
|
38173
|
+
editInfo.leftPercent = base.leftPercent + deltaX;
|
|
38174
|
+
editInfo.rightPercent = base.rightPercent - deltaX;
|
|
38175
|
+
editInfo.topPercent = base.topPercent + deltaY;
|
|
38176
|
+
editInfo.bottomPercent = base.bottomPercent - deltaY;
|
|
38177
|
+
return true;
|
|
38178
|
+
}
|
|
37734
38179
|
var newLeft = x != 'e'
|
|
37735
38180
|
? crop(base.leftPercent, dx, fullWidth, rightPercent, minWidth)
|
|
37736
38181
|
: leftPercent;
|
|
@@ -37789,6 +38234,7 @@ var getHTMLImageOptions_1 = __webpack_require__(/*! ./utils/getHTMLImageOptions
|
|
|
37789
38234
|
var getSelectedImage_1 = __webpack_require__(/*! ./utils/getSelectedImage */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/getSelectedImage.ts");
|
|
37790
38235
|
var updateImageEditInfo_1 = __webpack_require__(/*! ./utils/updateImageEditInfo */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/updateImageEditInfo.ts");
|
|
37791
38236
|
var ImageEditElementClass_1 = __webpack_require__(/*! ./types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
|
|
38237
|
+
var ImageCropKeyboardHelper_1 = __webpack_require__(/*! ./Cropper/ImageCropKeyboardHelper */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/ImageCropKeyboardHelper.ts");
|
|
37792
38238
|
var normalizeImageSelection_1 = __webpack_require__(/*! ./utils/normalizeImageSelection */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/utils/normalizeImageSelection.ts");
|
|
37793
38239
|
var resizerContext_1 = __webpack_require__(/*! ./Resizer/resizerContext */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Resizer/resizerContext.ts");
|
|
37794
38240
|
var rotatorContext_1 = __webpack_require__(/*! ./Rotator/rotatorContext */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Rotator/rotatorContext.ts");
|
|
@@ -37809,6 +38255,7 @@ var MouseRightButton = 2;
|
|
|
37809
38255
|
var DRAG_ID = '_dragging';
|
|
37810
38256
|
var IMAGE_EDIT_CLASS = 'imageEdit';
|
|
37811
38257
|
var IMAGE_EDIT_CLASS_CARET = 'imageEditCaretColor';
|
|
38258
|
+
var IMAGE_EDIT_CLASS_CROP_KEYBOARD = 'imageEditCropKeyboard';
|
|
37812
38259
|
var IMAGE_EDIT_FORMAT_EVENT = 'ImageEditEvent';
|
|
37813
38260
|
/**
|
|
37814
38261
|
* ImageEdit plugin handles the following image editing features:
|
|
@@ -37816,6 +38263,10 @@ var IMAGE_EDIT_FORMAT_EVENT = 'ImageEditEvent';
|
|
|
37816
38263
|
* - Crop image
|
|
37817
38264
|
* - Rotate image
|
|
37818
38265
|
* - Flip image
|
|
38266
|
+
*
|
|
38267
|
+
* In crop mode, Tab focuses the top-left corner, bottom-right corner, then the
|
|
38268
|
+
* whole image. Arrow keys crop at corners or move the fixed-size crop viewport
|
|
38269
|
+
* by one pixel. Enter applies the crop; Escape cancels it.
|
|
37819
38270
|
*/
|
|
37820
38271
|
var ImageEditPlugin = /** @class */ (function () {
|
|
37821
38272
|
function ImageEditPlugin(options) {
|
|
@@ -37835,6 +38286,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37835
38286
|
this.croppers = [];
|
|
37836
38287
|
this.zoomScale = 1;
|
|
37837
38288
|
this.disposer = null;
|
|
38289
|
+
this.cropKeyboardHelper = null;
|
|
37838
38290
|
this.isEditing = false;
|
|
37839
38291
|
this.options = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, DefaultOptions), options);
|
|
37840
38292
|
}
|
|
@@ -37854,8 +38306,19 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37854
38306
|
var _this = this;
|
|
37855
38307
|
this.editor = editor;
|
|
37856
38308
|
this.disposer = editor.attachDomEvent({
|
|
38309
|
+
keydown: {
|
|
38310
|
+
capture: true,
|
|
38311
|
+
beforeDispatch: function (ev) {
|
|
38312
|
+
_this.focusCropHandle(ev);
|
|
38313
|
+
},
|
|
38314
|
+
},
|
|
37857
38315
|
blur: {
|
|
37858
|
-
beforeDispatch: function () {
|
|
38316
|
+
beforeDispatch: function (ev) {
|
|
38317
|
+
if (_this.cropKeyboardHelper &&
|
|
38318
|
+
(ev.relatedTarget === _this.shadowSpan ||
|
|
38319
|
+
_this.cropKeyboardHelper.contains(ev.relatedTarget))) {
|
|
38320
|
+
return;
|
|
38321
|
+
}
|
|
37859
38322
|
if (_this.isEditing && _this.editor && !_this.editor.isDisposed()) {
|
|
37860
38323
|
_this.applyFormatWithContentModel(_this.editor, _this.isCropMode, true /* shouldSelectImage */);
|
|
37861
38324
|
}
|
|
@@ -37990,6 +38453,11 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
37990
38453
|
};
|
|
37991
38454
|
ImageEditPlugin.prototype.keyDownHandler = function (editor, event) {
|
|
37992
38455
|
if (this.isEditing) {
|
|
38456
|
+
if (this.cropKeyboardHelper &&
|
|
38457
|
+
(this.cropKeyboardHelper.contains(event.rawEvent.composedPath()[0]) ||
|
|
38458
|
+
this.focusCropHandle(event.rawEvent))) {
|
|
38459
|
+
return;
|
|
38460
|
+
}
|
|
37993
38461
|
if (event.rawEvent.key === 'Escape' ||
|
|
37994
38462
|
event.rawEvent.key === 'Delete' ||
|
|
37995
38463
|
event.rawEvent.key === 'Backspace') {
|
|
@@ -38006,6 +38474,19 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
38006
38474
|
}
|
|
38007
38475
|
}
|
|
38008
38476
|
};
|
|
38477
|
+
ImageEditPlugin.prototype.focusCropHandle = function (event) {
|
|
38478
|
+
if (this.cropKeyboardHelper &&
|
|
38479
|
+
event.key == 'Tab' &&
|
|
38480
|
+
!event.shiftKey &&
|
|
38481
|
+
!this.cropKeyboardHelper.contains(event.composedPath()[0])) {
|
|
38482
|
+
// Enter crop controls before editing plugins can indent or rerender the image.
|
|
38483
|
+
event.preventDefault();
|
|
38484
|
+
event.stopPropagation();
|
|
38485
|
+
this.cropKeyboardHelper.focus();
|
|
38486
|
+
return true;
|
|
38487
|
+
}
|
|
38488
|
+
return false;
|
|
38489
|
+
};
|
|
38009
38490
|
ImageEditPlugin.prototype.setContentHandler = function () {
|
|
38010
38491
|
if (this.selectedImage) {
|
|
38011
38492
|
this.cleanInfo();
|
|
@@ -38246,7 +38727,7 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
38246
38727
|
if (this.imageEditInfo) {
|
|
38247
38728
|
this.startEditing(editor, image, ['crop']);
|
|
38248
38729
|
if (this.imageEditInfo && this.selectedImage && this.wrapper && this.clonedImage) {
|
|
38249
|
-
|
|
38730
|
+
var onCrop = function () {
|
|
38250
38731
|
if (_this.imageEditInfo &&
|
|
38251
38732
|
_this.selectedImage &&
|
|
38252
38733
|
_this.wrapper &&
|
|
@@ -38254,11 +38735,46 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
38254
38735
|
(0, updateWrapper_1.updateWrapper)(_this.imageEditInfo, _this.options, _this.selectedImage, _this.clonedImage, _this.wrapper, undefined /* resizers */, _this.croppers, isRTL);
|
|
38255
38736
|
_this.isCropMode = true;
|
|
38256
38737
|
}
|
|
38257
|
-
}
|
|
38738
|
+
};
|
|
38739
|
+
this.dndHelpers = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)((0, getDropAndDragHelpers_1.getDropAndDragHelpers)(this.wrapper, this.imageEditInfo, this.options, ImageEditElementClass_1.ImageEditElementClass.CropHandle, cropperContext_1.Cropper, onCrop, this.zoomScale, !!editor.getEnvironment().isMobileOrTablet, !!editor.getEnvironment().isTouchSupported)), false);
|
|
38258
38740
|
(0, updateWrapper_1.updateWrapper)(this.imageEditInfo, this.options, this.selectedImage, this.clonedImage, this.wrapper, undefined /* resizers */, this.croppers, isRTL);
|
|
38741
|
+
this.startCropWithKeyboard(editor, onCrop);
|
|
38259
38742
|
}
|
|
38260
38743
|
}
|
|
38261
38744
|
};
|
|
38745
|
+
ImageEditPlugin.prototype.startCropWithKeyboard = function (editor, onCrop) {
|
|
38746
|
+
var _this = this;
|
|
38747
|
+
var _a;
|
|
38748
|
+
if (this.wrapper && this.selectedImage && this.imageEditInfo) {
|
|
38749
|
+
(_a = this.cropKeyboardHelper) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
38750
|
+
this.cropKeyboardHelper = new ImageCropKeyboardHelper_1.ImageCropKeyboardHelper(this.wrapper, this.selectedImage.id, this.imageEditInfo, this.options, onCrop, function (apply, restoreFocus) { return _this.finishKeyboardCrop(editor, apply, restoreFocus); });
|
|
38751
|
+
editor.setEditorStyle(IMAGE_EDIT_CLASS_CROP_KEYBOARD, 'outline:2px solid Highlight;outline-offset:-2px;', ["span::part(" + ImageEditElementClass_1.ImageEditElementClass.CropKeyboardTarget + "):focus"]);
|
|
38752
|
+
}
|
|
38753
|
+
};
|
|
38754
|
+
ImageEditPlugin.prototype.finishKeyboardCrop = function (editor, apply, restoreFocus) {
|
|
38755
|
+
var _a;
|
|
38756
|
+
(_a = this.cropKeyboardHelper) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
38757
|
+
this.cropKeyboardHelper = null;
|
|
38758
|
+
editor.setEditorStyle(IMAGE_EDIT_CLASS_CROP_KEYBOARD, null);
|
|
38759
|
+
if (apply) {
|
|
38760
|
+
this.applyFormatWithContentModel(editor, true, true);
|
|
38761
|
+
}
|
|
38762
|
+
else {
|
|
38763
|
+
this.isEditing = false;
|
|
38764
|
+
var image = this.removeImageWrapper();
|
|
38765
|
+
if (image) {
|
|
38766
|
+
(0, roosterjs_content_model_dom_1.setImageState)(image, '');
|
|
38767
|
+
}
|
|
38768
|
+
this.cleanInfo();
|
|
38769
|
+
if (restoreFocus && image) {
|
|
38770
|
+
editor.focus();
|
|
38771
|
+
editor.setDOMSelection({ type: 'image', image: image });
|
|
38772
|
+
}
|
|
38773
|
+
}
|
|
38774
|
+
if (restoreFocus) {
|
|
38775
|
+
editor.focus();
|
|
38776
|
+
}
|
|
38777
|
+
};
|
|
38262
38778
|
ImageEditPlugin.prototype.cropImage = function () {
|
|
38263
38779
|
if (!this.editor) {
|
|
38264
38780
|
return;
|
|
@@ -38284,9 +38800,12 @@ var ImageEditPlugin = /** @class */ (function () {
|
|
|
38284
38800
|
* Exported for testing purpose only
|
|
38285
38801
|
*/
|
|
38286
38802
|
ImageEditPlugin.prototype.cleanInfo = function () {
|
|
38287
|
-
var _a, _b;
|
|
38288
|
-
(_a = this.
|
|
38289
|
-
|
|
38803
|
+
var _a, _b, _c, _d;
|
|
38804
|
+
(_a = this.cropKeyboardHelper) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
38805
|
+
this.cropKeyboardHelper = null;
|
|
38806
|
+
(_b = this.editor) === null || _b === void 0 ? void 0 : _b.setEditorStyle(IMAGE_EDIT_CLASS, null);
|
|
38807
|
+
(_c = this.editor) === null || _c === void 0 ? void 0 : _c.setEditorStyle(IMAGE_EDIT_CLASS_CARET, null);
|
|
38808
|
+
(_d = this.editor) === null || _d === void 0 ? void 0 : _d.setEditorStyle(IMAGE_EDIT_CLASS_CROP_KEYBOARD, null);
|
|
38290
38809
|
this.selectedImage = null;
|
|
38291
38810
|
this.shadowSpan = null;
|
|
38292
38811
|
this.wrapper = null;
|
|
@@ -38873,6 +39392,14 @@ exports.ImageEditElementClass = void 0;
|
|
|
38873
39392
|
*/
|
|
38874
39393
|
var ImageEditElementClass;
|
|
38875
39394
|
(function (ImageEditElementClass) {
|
|
39395
|
+
/**
|
|
39396
|
+
* CSS class name for the image border
|
|
39397
|
+
*/
|
|
39398
|
+
ImageEditElementClass["ImageBorder"] = "r_imageB";
|
|
39399
|
+
/**
|
|
39400
|
+
* CSS class and part name for keyboard crop focus targets
|
|
39401
|
+
*/
|
|
39402
|
+
ImageEditElementClass["CropKeyboardTarget"] = "r_cropK";
|
|
38876
39403
|
/**
|
|
38877
39404
|
* CSS class name for resize handle
|
|
38878
39405
|
*/
|
|
@@ -39112,6 +39639,7 @@ exports.createImageWrapper = void 0;
|
|
|
39112
39639
|
var createImageCropper_1 = __webpack_require__(/*! ../Cropper/createImageCropper */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Cropper/createImageCropper.ts");
|
|
39113
39640
|
var createImageResizer_1 = __webpack_require__(/*! ../Resizer/createImageResizer */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Resizer/createImageResizer.ts");
|
|
39114
39641
|
var createImageRotator_1 = __webpack_require__(/*! ../Rotator/createImageRotator */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/Rotator/createImageRotator.ts");
|
|
39642
|
+
var ImageEditElementClass_1 = __webpack_require__(/*! ../types/ImageEditElementClass */ "./packages/roosterjs-content-model-plugins/lib/imageEdit/types/ImageEditElementClass.ts");
|
|
39115
39643
|
var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
|
|
39116
39644
|
/**
|
|
39117
39645
|
* @internal
|
|
@@ -39188,6 +39716,7 @@ var createWrapper = function (editor, image, options, editInfo, resizers, rotato
|
|
|
39188
39716
|
var createBorder = function (editor, borderColor) {
|
|
39189
39717
|
var doc = editor.getDocument();
|
|
39190
39718
|
var resizeBorder = doc.createElement('div');
|
|
39719
|
+
resizeBorder.className = ImageEditElementClass_1.ImageEditElementClass.ImageBorder;
|
|
39191
39720
|
resizeBorder.setAttribute("style", "position:absolute;left:0;right:0;top:0;bottom:0;border:solid 2px " + borderColor + ";pointer-events:none;");
|
|
39192
39721
|
return resizeBorder;
|
|
39193
39722
|
};
|
|
@@ -39611,15 +40140,10 @@ exports.setFlipped = setFlipped;
|
|
|
39611
40140
|
/**
|
|
39612
40141
|
* @internal
|
|
39613
40142
|
*/
|
|
39614
|
-
function setWrapperSizeDimensions(wrapper, image, width, height
|
|
40143
|
+
function setWrapperSizeDimensions(wrapper, image, width, height) {
|
|
39615
40144
|
var hasBorder = image.style.borderStyle;
|
|
39616
40145
|
if (hasBorder) {
|
|
39617
40146
|
var borderWidth = image.style.borderWidth ? 2 * parseInt(image.style.borderWidth) : 2;
|
|
39618
|
-
if (isRotating) {
|
|
39619
|
-
wrapper.style.width = getPx(parseInt(image.style.width) + borderWidth);
|
|
39620
|
-
wrapper.style.height = getPx(parseInt(image.style.height) + borderWidth);
|
|
39621
|
-
return;
|
|
39622
|
-
}
|
|
39623
40147
|
wrapper.style.width = getPx(width + borderWidth);
|
|
39624
40148
|
wrapper.style.height = getPx(height + borderWidth);
|
|
39625
40149
|
return;
|
|
@@ -39871,7 +40395,7 @@ function updateWrapper(editInfo, options, image, clonedImage, wrapper, resizers,
|
|
|
39871
40395
|
wrapper.style.marginLeft = marginHorizontal + "px";
|
|
39872
40396
|
wrapper.style.marginRight = marginHorizontal + "px";
|
|
39873
40397
|
wrapper.style.transform = "rotate(" + angleRad + "rad)";
|
|
39874
|
-
(0, imageEditUtils_1.setWrapperSizeDimensions)(wrapper, image, visibleWidth, visibleHeight
|
|
40398
|
+
(0, imageEditUtils_1.setWrapperSizeDimensions)(wrapper, image, visibleWidth, visibleHeight);
|
|
39875
40399
|
wrapper.style.verticalAlign = 'text-bottom';
|
|
39876
40400
|
// Update the text-alignment to avoid the image to overflow if the parent element have align center or right
|
|
39877
40401
|
// or if the direction is Right To Left
|
|
@@ -40885,12 +41409,16 @@ var wacSubSuperParser = function (format, element) {
|
|
|
40885
41409
|
if (verticalAlign === 'sub') {
|
|
40886
41410
|
format.superOrSubScriptSequence = 'sub';
|
|
40887
41411
|
}
|
|
41412
|
+
if ((verticalAlign === 'super' || verticalAlign === 'sub') &&
|
|
41413
|
+
element.style.fontSize !== 'smaller') {
|
|
41414
|
+
format.superOrSubScriptFontSize = 'inherit';
|
|
41415
|
+
}
|
|
40888
41416
|
};
|
|
40889
41417
|
/**
|
|
40890
41418
|
* This processor does:
|
|
40891
41419
|
* 1) Remove the display and margin of the element.
|
|
40892
41420
|
* 2) When an element should be ignored but should handle the child elements call the default child processor.
|
|
40893
|
-
* 3) Removes
|
|
41421
|
+
* 3) Removes selected End of Paragraph markers unless they are the paragraph's only content.
|
|
40894
41422
|
* 4) Finally call the default processor.
|
|
40895
41423
|
* @returns
|
|
40896
41424
|
*/
|
|
@@ -40904,12 +41432,19 @@ var wacElementProcessor = function (group, element, context) {
|
|
|
40904
41432
|
context.elementProcessors.child(group, element, context);
|
|
40905
41433
|
return;
|
|
40906
41434
|
}
|
|
40907
|
-
if (constants_1.TEMP_ELEMENTS_CLASSES.some(function (className) { return element.classList.contains(className); })
|
|
40908
|
-
// This is needed to remove some temporary End of paragraph elements that WAC sometimes preserves
|
|
40909
|
-
(element.classList.contains(SELECTED_CLASS) && element.classList.contains(END_OF_PARAGRAPH))) {
|
|
41435
|
+
if (constants_1.TEMP_ELEMENTS_CLASSES.some(function (className) { return element.classList.contains(className); })) {
|
|
40910
41436
|
return;
|
|
40911
41437
|
}
|
|
40912
|
-
|
|
41438
|
+
if (element.classList.contains(SELECTED_CLASS) &&
|
|
41439
|
+
element.classList.contains(END_OF_PARAGRAPH)) {
|
|
41440
|
+
var lastBlock = group.blocks[group.blocks.length - 1];
|
|
41441
|
+
if ((lastBlock === null || lastBlock === void 0 ? void 0 : lastBlock.blockType) != 'Paragraph' || lastBlock.segments.length > 0) {
|
|
41442
|
+
return;
|
|
41443
|
+
}
|
|
41444
|
+
element.style.removeProperty('background-color');
|
|
41445
|
+
element.style.removeProperty('border-color');
|
|
41446
|
+
}
|
|
41447
|
+
if (shouldClearListContext(elementTag, element, context)) {
|
|
40913
41448
|
var listFormat = context.listFormat;
|
|
40914
41449
|
listFormat.levels = [];
|
|
40915
41450
|
listFormat.listParent = undefined;
|
|
@@ -40947,6 +41482,7 @@ var wacLiElementProcessor = function (group, element, context) {
|
|
|
40947
41482
|
if (lastblock.blockType == 'BlockGroup' && lastblock.blockGroupType == 'ListItem') {
|
|
40948
41483
|
var currentLevel = lastblock.levels[lastblock.levels.length - 1];
|
|
40949
41484
|
updateStartOverride(currentLevel, element, context);
|
|
41485
|
+
updateHeading(lastblock, element, context);
|
|
40950
41486
|
}
|
|
40951
41487
|
}
|
|
40952
41488
|
var newLevels = [];
|
|
@@ -40978,6 +41514,19 @@ var wacListLevelParser = function (format) {
|
|
|
40978
41514
|
format.marginLeft = undefined;
|
|
40979
41515
|
format.paddingLeft = BASE_PADDING_WAC_LISTS;
|
|
40980
41516
|
};
|
|
41517
|
+
var wacTableCellPaddingParser = function (format, element) {
|
|
41518
|
+
var keys = [
|
|
41519
|
+
'paddingTop',
|
|
41520
|
+
'paddingRight',
|
|
41521
|
+
'paddingBottom',
|
|
41522
|
+
'paddingLeft',
|
|
41523
|
+
];
|
|
41524
|
+
keys.forEach(function (key) {
|
|
41525
|
+
if (element.style[key]) {
|
|
41526
|
+
format[key] = element.style[key];
|
|
41527
|
+
}
|
|
41528
|
+
});
|
|
41529
|
+
};
|
|
40981
41530
|
/**
|
|
40982
41531
|
* This function returns whether we need to clear the list format.
|
|
40983
41532
|
* Word Online wraps lists inside divs to have this structure:
|
|
@@ -41021,6 +41570,7 @@ function processPastedContentWacComponents(ev) {
|
|
|
41021
41570
|
(0, addParser_1.addParser)(ev.domToModelOption, 'listLevel', wacListLevelParser);
|
|
41022
41571
|
(0, addParser_1.addParser)(ev.domToModelOption, 'container', wacContainerParser);
|
|
41023
41572
|
(0, addParser_1.addParser)(ev.domToModelOption, 'table', wacContainerParser);
|
|
41573
|
+
(0, addParser_1.addParser)(ev.domToModelOption, 'tableCell', wacTableCellPaddingParser);
|
|
41024
41574
|
(0, addParser_1.addParser)(ev.domToModelOption, 'segment', wacCommentParser);
|
|
41025
41575
|
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', wacElementProcessor);
|
|
41026
41576
|
(0, setProcessor_1.setProcessor)(ev.domToModelOption, 'li', wacLiElementProcessor);
|
|
@@ -41031,6 +41581,58 @@ var wacContainerParser = function (format, element) {
|
|
|
41031
41581
|
delete format.marginLeft;
|
|
41032
41582
|
}
|
|
41033
41583
|
};
|
|
41584
|
+
function updateHeading(listItem, element, context) {
|
|
41585
|
+
var _a;
|
|
41586
|
+
var paragraph = element.querySelector('p');
|
|
41587
|
+
var styleName = (_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.querySelector('[data-ccp-parastyle]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-ccp-parastyle');
|
|
41588
|
+
var list = element.closest('ol');
|
|
41589
|
+
if (!paragraph || !list || !/^heading [1-6]$/i.test(styleName || '')) {
|
|
41590
|
+
return;
|
|
41591
|
+
}
|
|
41592
|
+
var headingParagraph = listItem.blocks.find(function (block) { var _a; return block.blockType == 'Paragraph' && ((_a = block.decorator) === null || _a === void 0 ? void 0 : _a.tagName) == 'p'; });
|
|
41593
|
+
if ((headingParagraph === null || headingParagraph === void 0 ? void 0 : headingParagraph.blockType) == 'Paragraph') {
|
|
41594
|
+
// An inside marker and a block paragraph would occupy separate lines.
|
|
41595
|
+
Object.assign(listItem.format, headingParagraph.format);
|
|
41596
|
+
headingParagraph.isImplicit = true;
|
|
41597
|
+
headingParagraph.format = {};
|
|
41598
|
+
delete headingParagraph.decorator;
|
|
41599
|
+
}
|
|
41600
|
+
listItem.levels.forEach(function (level) {
|
|
41601
|
+
level.format.paddingLeft = '0px';
|
|
41602
|
+
level.format.paddingRight = '0px';
|
|
41603
|
+
level.format.marginTop = '0px';
|
|
41604
|
+
level.format.marginBottom = '0px';
|
|
41605
|
+
});
|
|
41606
|
+
listItem.format.marginLeft = '0px';
|
|
41607
|
+
listItem.format.marginRight = '0px';
|
|
41608
|
+
listItem.format.listStylePosition = 'inside';
|
|
41609
|
+
(0, roosterjs_content_model_dom_1.parseFormat)(paragraph, context.formatParsers.segmentOnBlock, listItem.formatHolder.format, context);
|
|
41610
|
+
var listId = element.getAttribute('data-listid');
|
|
41611
|
+
var template = element.getAttribute('data-leveltext');
|
|
41612
|
+
var _b = (0, tslib_1.__read)(extractWordListMetadata(list, element), 2), start = _b[0], level = _b[1];
|
|
41613
|
+
if (!listId ||
|
|
41614
|
+
!template ||
|
|
41615
|
+
!/^%[1-9](?:\.%[1-9])*[.)]?$/.test(template) ||
|
|
41616
|
+
!(level > 0 && level <= 9) ||
|
|
41617
|
+
!Number.isFinite(start)) {
|
|
41618
|
+
return;
|
|
41619
|
+
}
|
|
41620
|
+
var listFormat = context.listFormat;
|
|
41621
|
+
var headings = (listFormat.headingNumbers = listFormat.headingNumbers || new Map());
|
|
41622
|
+
var numbers = headings.get(listId) || [];
|
|
41623
|
+
numbers[level - 1] = start;
|
|
41624
|
+
numbers.length = level;
|
|
41625
|
+
headings.set(listId, numbers);
|
|
41626
|
+
var complete = true;
|
|
41627
|
+
var label = template.replace(/%([1-9])/g, function (_match, index) {
|
|
41628
|
+
var number = numbers[parseInt(index) - 1];
|
|
41629
|
+
complete = complete && number !== undefined;
|
|
41630
|
+
return number === undefined ? '' : number.toString();
|
|
41631
|
+
});
|
|
41632
|
+
if (complete) {
|
|
41633
|
+
listItem.format.listStyleType = '"' + label + ' "';
|
|
41634
|
+
}
|
|
41635
|
+
}
|
|
41034
41636
|
function updateStartOverride(currentLevel, element, ctx) {
|
|
41035
41637
|
if (!currentLevel || currentLevel.listType == 'UL') {
|
|
41036
41638
|
return;
|
|
@@ -41321,6 +41923,7 @@ function processWordList(styles, group, element, context, metadata) {
|
|
|
41321
41923
|
}
|
|
41322
41924
|
if (wordListStyle && group && typeof listFormat.wordLevel === 'number') {
|
|
41323
41925
|
var wordLevel_1 = listFormat.wordLevel, wordList = listFormat.wordList;
|
|
41926
|
+
var isHeading_1 = /^H[1-6]$/.test(element.tagName);
|
|
41324
41927
|
// Retrieve the Fake bullet on the element and also the list type
|
|
41325
41928
|
var listMetadata_1 = metadata.get(lNumber + ":" + level);
|
|
41326
41929
|
var listType_1 = ((_a = listMetadata_1 === null || listMetadata_1 === void 0 ? void 0 : listMetadata_1['mso-level-number-format']) === null || _a === void 0 ? void 0 : _a.toLowerCase()) != BULLET_METADATA
|
|
@@ -41333,26 +41936,52 @@ function processWordList(styles, group, element, context, metadata) {
|
|
|
41333
41936
|
var currentLevelFormat = listFormat.levels[listFormat.levels.length - 1]
|
|
41334
41937
|
.format;
|
|
41335
41938
|
currentLevelFormat.wordList = wordList;
|
|
41336
|
-
if (
|
|
41939
|
+
if (isHeading_1) {
|
|
41940
|
+
// Keep Word's heading spacing on the item, not on synthesized list wrappers.
|
|
41941
|
+
currentLevelFormat.paddingLeft = '0px';
|
|
41942
|
+
currentLevelFormat.paddingRight = '0px';
|
|
41943
|
+
currentLevelFormat.marginTop = '0px';
|
|
41944
|
+
currentLevelFormat.marginBottom = '0px';
|
|
41945
|
+
}
|
|
41946
|
+
else if (wordLevel_1 > 1) {
|
|
41337
41947
|
delete currentLevelFormat.paddingLeft;
|
|
41338
41948
|
delete currentLevelFormat.paddingRight;
|
|
41339
41949
|
}
|
|
41340
|
-
var
|
|
41341
|
-
var
|
|
41950
|
+
var bullet_1 = getBulletFromMetadata(listMetadata_1, listType_1);
|
|
41951
|
+
var bulletElement_1 = getBulletElement(element);
|
|
41952
|
+
var listFormatMetadata = bullet_1
|
|
41342
41953
|
? {
|
|
41343
|
-
unorderedStyleType: listType_1 == 'UL' ?
|
|
41344
|
-
orderedStyleType: listType_1 == 'OL' ?
|
|
41954
|
+
unorderedStyleType: listType_1 == 'UL' ? bullet_1 : undefined,
|
|
41955
|
+
orderedStyleType: listType_1 == 'OL' ? bullet_1 : undefined,
|
|
41345
41956
|
}
|
|
41346
41957
|
: undefined;
|
|
41347
|
-
|
|
41348
|
-
|
|
41349
|
-
|
|
41350
|
-
|
|
41351
|
-
|
|
41352
|
-
|
|
41353
|
-
|
|
41354
|
-
|
|
41355
|
-
|
|
41958
|
+
var originalSegmentFormat = context.segmentFormat;
|
|
41959
|
+
try {
|
|
41960
|
+
context.segmentFormat = (0, tslib_1.__assign)({}, originalSegmentFormat);
|
|
41961
|
+
(0, customListUtils_1.processAsListItem)(context, element, group, listFormatMetadata, bulletElement_1, function (listItem) {
|
|
41962
|
+
var _a;
|
|
41963
|
+
if (isHeading_1 && listType_1 == 'OL') {
|
|
41964
|
+
listItem.format.marginLeft = '0px';
|
|
41965
|
+
listItem.format.marginRight = '0px';
|
|
41966
|
+
listItem.format.listStylePosition = 'inside';
|
|
41967
|
+
// Preserve Word's rendered number when its outline template is unsupported.
|
|
41968
|
+
var number = (_a = bulletElement_1 === null || bulletElement_1 === void 0 ? void 0 : bulletElement_1.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
41969
|
+
if (bullet_1 === undefined && number && /^\d+(?:\.\d+)*[.)]?$/.test(number)) {
|
|
41970
|
+
listItem.format.listStyleType = '"' + number + ' "';
|
|
41971
|
+
}
|
|
41972
|
+
}
|
|
41973
|
+
else if (wordLevel_1 > 1 && !isHeading_1) {
|
|
41974
|
+
delete listItem.format.marginLeft;
|
|
41975
|
+
delete listItem.format.marginRight;
|
|
41976
|
+
}
|
|
41977
|
+
if (listType_1 == 'OL') {
|
|
41978
|
+
setStartNumber(listItem, context, listMetadata_1, element);
|
|
41979
|
+
}
|
|
41980
|
+
});
|
|
41981
|
+
}
|
|
41982
|
+
finally {
|
|
41983
|
+
context.segmentFormat = originalSegmentFormat;
|
|
41984
|
+
}
|
|
41356
41985
|
if (listFormat.levels.length > 0 &&
|
|
41357
41986
|
listFormat.wordKnownLevels.get(wordList) != listFormat.levels) {
|
|
41358
41987
|
listFormat.wordKnownLevels.set(wordList, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(listFormat.levels), false));
|
|
@@ -41473,8 +42102,13 @@ function wordListPaddingParser(format, element) {
|
|
|
41473
42102
|
* @returns
|
|
41474
42103
|
*/
|
|
41475
42104
|
function getBulletElement(element) {
|
|
42105
|
+
var _a;
|
|
41476
42106
|
var firstChild = element.firstElementChild;
|
|
41477
42107
|
var isBulletElement = false;
|
|
42108
|
+
if ((0, roosterjs_content_model_dom_1.isNodeOfType)(firstChild, 'ELEMENT_NODE') &&
|
|
42109
|
+
((_a = (0, getStyles_1.getStyles)(firstChild)[MSO_LIST]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === MSO_LIST_IGNORE) {
|
|
42110
|
+
return firstChild;
|
|
42111
|
+
}
|
|
41478
42112
|
if (firstChild) {
|
|
41479
42113
|
for (var i = 0; i < firstChild.childNodes.length; i++) {
|
|
41480
42114
|
var child = firstChild.childNodes[i];
|