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