roosterjs 8.52.0 → 8.53.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 +26 -18
- package/dist/rooster-amd.js +212 -124
- 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 +26 -18
- package/dist/rooster.js +212 -124
- package/dist/rooster.js.map +1 -1
- package/package.json +7 -7
package/dist/rooster-amd.js
CHANGED
|
@@ -7474,6 +7474,7 @@ var ImageSelection = /** @class */ (function () {
|
|
|
7474
7474
|
case 6 /* MouseUp */:
|
|
7475
7475
|
var target = event.rawEvent.target;
|
|
7476
7476
|
if ((0, roosterjs_editor_dom_1.safeInstanceOf)(target, 'HTMLImageElement') &&
|
|
7477
|
+
target.isContentEditable &&
|
|
7477
7478
|
event.rawEvent.button === mouseLeftButton) {
|
|
7478
7479
|
this.editor.select(target);
|
|
7479
7480
|
}
|
|
@@ -24055,6 +24056,7 @@ var getGeneratedImageSize_1 = __webpack_require__(/*! ./editInfoUtils/getGenerat
|
|
|
24055
24056
|
var Cropper_1 = __webpack_require__(/*! ./imageEditors/Cropper */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Cropper.ts");
|
|
24056
24057
|
var editInfo_1 = __webpack_require__(/*! ./editInfoUtils/editInfo */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/editInfo.ts");
|
|
24057
24058
|
var Rotator_1 = __webpack_require__(/*! ./imageEditors/Rotator */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Rotator.ts");
|
|
24059
|
+
var constants_1 = __webpack_require__(/*! ./constants/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/constants/constants.ts");
|
|
24058
24060
|
var tryToConvertGifToPng_1 = __webpack_require__(/*! ./editInfoUtils/tryToConvertGifToPng */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/tryToConvertGifToPng.ts");
|
|
24059
24061
|
var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./packages/roosterjs-editor-dom/lib/index.ts");
|
|
24060
24062
|
var Resizer_1 = __webpack_require__(/*! ./imageEditors/Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
|
|
@@ -24093,10 +24095,6 @@ var ImageEditHTMLMap = (_a = {},
|
|
|
24093
24095
|
*/
|
|
24094
24096
|
var LIGHT_MODE_BGCOLOR = 'white';
|
|
24095
24097
|
var DARK_MODE_BGCOLOR = '#333';
|
|
24096
|
-
/**
|
|
24097
|
-
* The biggest area of image with 4 handles
|
|
24098
|
-
*/
|
|
24099
|
-
var MAX_SMALL_SIZE_IMAGE = 10000;
|
|
24100
24098
|
/**
|
|
24101
24099
|
* ImageEdit plugin provides the ability to edit an inline image in editor, including image resizing, rotation and cropping
|
|
24102
24100
|
*/
|
|
@@ -24221,9 +24219,11 @@ var ImageEdit = /** @class */ (function () {
|
|
|
24221
24219
|
_this.updateWrapper();
|
|
24222
24220
|
}
|
|
24223
24221
|
var viewport = (_b = _this.editor) === null || _b === void 0 ? void 0 : _b.getVisibleViewport();
|
|
24222
|
+
var isSmall = isASmallImage(targetWidth, targetHeight);
|
|
24224
24223
|
if (rotateHandle && rotateCenter && viewport) {
|
|
24225
|
-
(0, Rotator_1.
|
|
24224
|
+
(0, Rotator_1.updateRotateHandleState)(viewport, rotateCenter, rotateHandle, isSmall);
|
|
24226
24225
|
}
|
|
24226
|
+
updateSideHandlesVisibility(resizeHandles, isSmall);
|
|
24227
24227
|
updateHandleCursor(resizeHandles, angleRad);
|
|
24228
24228
|
}
|
|
24229
24229
|
}
|
|
@@ -24452,7 +24452,7 @@ var ImageEdit = /** @class */ (function () {
|
|
|
24452
24452
|
rotateHandleBackColor: this.editor.isDarkMode()
|
|
24453
24453
|
? DARK_MODE_BGCOLOR
|
|
24454
24454
|
: LIGHT_MODE_BGCOLOR,
|
|
24455
|
-
isSmallImage: isASmallImage(this.editInfo),
|
|
24455
|
+
isSmallImage: isASmallImage(this.editInfo.widthPx, this.editInfo.heightPx),
|
|
24456
24456
|
};
|
|
24457
24457
|
var htmlData_1 = [(0, Resizer_1.getResizeBordersHTML)(options_1)];
|
|
24458
24458
|
(0, roosterjs_editor_dom_1.getObjectKeys)(ImageEditHTMLMap).forEach(function (thisOperation) {
|
|
@@ -24564,12 +24564,20 @@ function rotateHandles(angleRad, y, x) {
|
|
|
24564
24564
|
* @param angleRad The angle that the image was rotated.
|
|
24565
24565
|
*/
|
|
24566
24566
|
function updateHandleCursor(handles, angleRad) {
|
|
24567
|
-
handles.
|
|
24568
|
-
var
|
|
24569
|
-
var x = handle.dataset.x;
|
|
24567
|
+
handles.forEach(function (handle) {
|
|
24568
|
+
var _a = handle.dataset, y = _a.y, x = _a.x;
|
|
24570
24569
|
handle.style.cursor = rotateHandles(angleRad, y, x) + "-resize";
|
|
24571
24570
|
});
|
|
24572
24571
|
}
|
|
24572
|
+
function updateSideHandlesVisibility(handles, isSmall) {
|
|
24573
|
+
handles.forEach(function (handle) {
|
|
24574
|
+
var _a = handle.dataset, y = _a.y, x = _a.x;
|
|
24575
|
+
var coordinate = (y !== null && y !== void 0 ? y : '') + (x !== null && x !== void 0 ? x : '');
|
|
24576
|
+
var directions = ['n', 's', 'e', 'w'];
|
|
24577
|
+
var isSideHandle = directions.indexOf(coordinate) > -1;
|
|
24578
|
+
handle.style.display = isSideHandle && isSmall ? 'none' : '';
|
|
24579
|
+
});
|
|
24580
|
+
}
|
|
24573
24581
|
/**
|
|
24574
24582
|
* Check if the current image was resized by the user
|
|
24575
24583
|
* @param image the current image
|
|
@@ -24593,9 +24601,10 @@ function isFixedNumberValue(value) {
|
|
|
24593
24601
|
var numberValue = typeof value === 'string' ? parseInt(value) : value;
|
|
24594
24602
|
return !isNaN(numberValue);
|
|
24595
24603
|
}
|
|
24596
|
-
function isASmallImage(
|
|
24597
|
-
|
|
24598
|
-
|
|
24604
|
+
function isASmallImage(widthPx, heightPx) {
|
|
24605
|
+
return widthPx && heightPx && (widthPx < constants_1.MIN_HEIGHT_WIDTH || heightPx < constants_1.MIN_HEIGHT_WIDTH)
|
|
24606
|
+
? true
|
|
24607
|
+
: false;
|
|
24599
24608
|
}
|
|
24600
24609
|
function getColorString(color, isDarkMode) {
|
|
24601
24610
|
if (typeof color === 'string') {
|
|
@@ -24765,6 +24774,40 @@ function loadImage(img, src, callback) {
|
|
|
24765
24774
|
}
|
|
24766
24775
|
|
|
24767
24776
|
|
|
24777
|
+
/***/ }),
|
|
24778
|
+
|
|
24779
|
+
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/constants/constants.ts":
|
|
24780
|
+
/*!****************************************************************************************!*\
|
|
24781
|
+
!*** ./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/constants/constants.ts ***!
|
|
24782
|
+
\****************************************************************************************/
|
|
24783
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
24784
|
+
|
|
24785
|
+
"use strict";
|
|
24786
|
+
|
|
24787
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24788
|
+
exports.MIN_HEIGHT_WIDTH = exports.Ys = exports.Xs = exports.CROP_HANDLE_WIDTH = exports.CROP_HANDLE_SIZE = exports.ROTATE_HANDLE_TOP = exports.ROTATE_WIDTH = exports.ROTATION = exports.ROTATE_ICON_MARGIN = exports.DEFAULT_ROTATE_HANDLE_HEIGHT = exports.DEG_PER_RAD = exports.ROTATE_GAP = exports.ROTATE_SIZE = exports.RESIZE_HANDLE_MARGIN = exports.RESIZE_HANDLE_SIZE = void 0;
|
|
24789
|
+
exports.RESIZE_HANDLE_SIZE = 10;
|
|
24790
|
+
exports.RESIZE_HANDLE_MARGIN = 6;
|
|
24791
|
+
exports.ROTATE_SIZE = 32;
|
|
24792
|
+
exports.ROTATE_GAP = 15;
|
|
24793
|
+
exports.DEG_PER_RAD = 180 / Math.PI;
|
|
24794
|
+
exports.DEFAULT_ROTATE_HANDLE_HEIGHT = exports.ROTATE_SIZE / 2 + exports.ROTATE_GAP;
|
|
24795
|
+
exports.ROTATE_ICON_MARGIN = 8;
|
|
24796
|
+
exports.ROTATION = {
|
|
24797
|
+
sw: 0,
|
|
24798
|
+
nw: 90,
|
|
24799
|
+
ne: 180,
|
|
24800
|
+
se: 270,
|
|
24801
|
+
};
|
|
24802
|
+
exports.ROTATE_WIDTH = 1;
|
|
24803
|
+
exports.ROTATE_HANDLE_TOP = exports.ROTATE_GAP + exports.RESIZE_HANDLE_MARGIN;
|
|
24804
|
+
exports.CROP_HANDLE_SIZE = 22;
|
|
24805
|
+
exports.CROP_HANDLE_WIDTH = 7;
|
|
24806
|
+
exports.Xs = ['w', '', 'e'];
|
|
24807
|
+
exports.Ys = ['s', '', 'n'];
|
|
24808
|
+
exports.MIN_HEIGHT_WIDTH = 3 * exports.RESIZE_HANDLE_SIZE + 2 * exports.RESIZE_HANDLE_MARGIN;
|
|
24809
|
+
|
|
24810
|
+
|
|
24768
24811
|
/***/ }),
|
|
24769
24812
|
|
|
24770
24813
|
/***/ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/applyChange.ts":
|
|
@@ -25190,17 +25233,8 @@ exports.tryToConvertGifToPng = tryToConvertGifToPng;
|
|
|
25190
25233
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25191
25234
|
exports.getCropHTML = exports.Cropper = void 0;
|
|
25192
25235
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
25236
|
+
var constants_1 = __webpack_require__(/*! ../constants/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/constants/constants.ts");
|
|
25193
25237
|
var Resizer_1 = __webpack_require__(/*! ./Resizer */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/imageEditors/Resizer.ts");
|
|
25194
|
-
var CROP_HANDLE_SIZE = 22;
|
|
25195
|
-
var CROP_HANDLE_WIDTH = 7;
|
|
25196
|
-
var Xs = ['w', 'e'];
|
|
25197
|
-
var Ys = ['s', 'n'];
|
|
25198
|
-
var ROTATION = {
|
|
25199
|
-
sw: 0,
|
|
25200
|
-
nw: 90,
|
|
25201
|
-
ne: 180,
|
|
25202
|
-
se: 270,
|
|
25203
|
-
};
|
|
25204
25238
|
/**
|
|
25205
25239
|
* @internal
|
|
25206
25240
|
* Crop handle for DragAndDropHelper
|
|
@@ -25272,7 +25306,7 @@ function getCropHTML() {
|
|
|
25272
25306
|
children: [],
|
|
25273
25307
|
};
|
|
25274
25308
|
if (containerHTML) {
|
|
25275
|
-
Xs.forEach(function (x) { return Ys.forEach(function (y) { var _a; return (_a = containerHTML.children) === null || _a === void 0 ? void 0 : _a.push(getCropHTMLInternal(x, y)); }); });
|
|
25309
|
+
constants_1.Xs.forEach(function (x) { return constants_1.Ys.forEach(function (y) { var _a; return (_a = containerHTML.children) === null || _a === void 0 ? void 0 : _a.push(getCropHTMLInternal(x, y)); }); });
|
|
25276
25310
|
}
|
|
25277
25311
|
return [containerHTML, overlayHTML, overlayHTML, overlayHTML, overlayHTML];
|
|
25278
25312
|
}
|
|
@@ -25280,11 +25314,11 @@ exports.getCropHTML = getCropHTML;
|
|
|
25280
25314
|
function getCropHTMLInternal(x, y) {
|
|
25281
25315
|
var leftOrRight = x == 'w' ? 'left' : 'right';
|
|
25282
25316
|
var topOrBottom = y == 'n' ? 'top' : 'bottom';
|
|
25283
|
-
var rotation = ROTATION[y + x];
|
|
25317
|
+
var rotation = constants_1.ROTATION[y + x];
|
|
25284
25318
|
return {
|
|
25285
25319
|
tag: 'div',
|
|
25286
25320
|
className: "r_cropH" /* CropHandle */,
|
|
25287
|
-
style: "position:absolute;pointer-events:auto;cursor:" + y + x + "-resize;" + leftOrRight + ":0;" + topOrBottom + ":0;width:" + CROP_HANDLE_SIZE + "px;height:" + CROP_HANDLE_SIZE + "px;transform:rotate(" + rotation + "deg)",
|
|
25321
|
+
style: "position:absolute;pointer-events:auto;cursor:" + y + x + "-resize;" + leftOrRight + ":0;" + topOrBottom + ":0;width:" + constants_1.CROP_HANDLE_SIZE + "px;height:" + constants_1.CROP_HANDLE_SIZE + "px;transform:rotate(" + rotation + "deg)",
|
|
25288
25322
|
dataset: { x: x, y: y },
|
|
25289
25323
|
children: getCropHandleHTML(),
|
|
25290
25324
|
};
|
|
@@ -25300,8 +25334,8 @@ function getCropHandleHTML() {
|
|
|
25300
25334
|
}
|
|
25301
25335
|
function getCropHandleHTMLInternal(layer, dir) {
|
|
25302
25336
|
var position = dir == 0
|
|
25303
|
-
? "right:" + layer + "px;height:" + (CROP_HANDLE_WIDTH - layer * 2) + "px;"
|
|
25304
|
-
: "top:" + layer + "px;width:" + (CROP_HANDLE_WIDTH - layer * 2) + "px;";
|
|
25337
|
+
? "right:" + layer + "px;height:" + (constants_1.CROP_HANDLE_WIDTH - layer * 2) + "px;"
|
|
25338
|
+
: "top:" + layer + "px;width:" + (constants_1.CROP_HANDLE_WIDTH - layer * 2) + "px;";
|
|
25305
25339
|
var bgColor = layer == 0 ? 'white' : 'black';
|
|
25306
25340
|
return {
|
|
25307
25341
|
tag: 'div',
|
|
@@ -25323,15 +25357,12 @@ function getCropHandleHTMLInternal(layer, dir) {
|
|
|
25323
25357
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25324
25358
|
exports.getResizeBordersHTML = exports.getSideResizeHTML = exports.getCornerResizeHTML = exports.doubleCheckResize = exports.rotateCoordinate = exports.Resizer = void 0;
|
|
25325
25359
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
25360
|
+
var constants_1 = __webpack_require__(/*! ../constants/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/constants/constants.ts");
|
|
25326
25361
|
var HandleTypes;
|
|
25327
25362
|
(function (HandleTypes) {
|
|
25328
25363
|
HandleTypes[HandleTypes["SquareHandles"] = 0] = "SquareHandles";
|
|
25329
25364
|
HandleTypes[HandleTypes["CircularHandlesCorner"] = 1] = "CircularHandlesCorner";
|
|
25330
25365
|
})(HandleTypes || (HandleTypes = {}));
|
|
25331
|
-
var RESIZE_HANDLE_SIZE = 10;
|
|
25332
|
-
var RESIZE_HANDLE_MARGIN = 3;
|
|
25333
|
-
var Xs = ['w', '', 'e'];
|
|
25334
|
-
var Ys = ['s', '', 'n'];
|
|
25335
25366
|
/**
|
|
25336
25367
|
* @internal
|
|
25337
25368
|
* The resize drag and drop handler
|
|
@@ -25435,8 +25466,8 @@ exports.doubleCheckResize = doubleCheckResize;
|
|
|
25435
25466
|
function getCornerResizeHTML(_a, onShowResizeHandle) {
|
|
25436
25467
|
var resizeBorderColor = _a.borderColor;
|
|
25437
25468
|
var result = [];
|
|
25438
|
-
Xs.forEach(function (x) {
|
|
25439
|
-
return Ys.forEach(function (y) {
|
|
25469
|
+
constants_1.Xs.forEach(function (x) {
|
|
25470
|
+
return constants_1.Ys.forEach(function (y) {
|
|
25440
25471
|
var elementData = (x == '') == (y == '')
|
|
25441
25472
|
? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
|
|
25442
25473
|
: null;
|
|
@@ -25456,13 +25487,10 @@ exports.getCornerResizeHTML = getCornerResizeHTML;
|
|
|
25456
25487
|
* Get HTML for resize handles on the sides
|
|
25457
25488
|
*/
|
|
25458
25489
|
function getSideResizeHTML(_a, onShowResizeHandle) {
|
|
25459
|
-
var resizeBorderColor = _a.borderColor
|
|
25460
|
-
if (isSmallImage) {
|
|
25461
|
-
return null;
|
|
25462
|
-
}
|
|
25490
|
+
var resizeBorderColor = _a.borderColor;
|
|
25463
25491
|
var result = [];
|
|
25464
|
-
Xs.forEach(function (x) {
|
|
25465
|
-
return Ys.forEach(function (y) {
|
|
25492
|
+
constants_1.Xs.forEach(function (x) {
|
|
25493
|
+
return constants_1.Ys.forEach(function (y) {
|
|
25466
25494
|
var elementData = (x == '') != (y == '')
|
|
25467
25495
|
? getResizeHandleHTML(x, y, resizeBorderColor, 1 /* CircularHandlesCorner */)
|
|
25468
25496
|
: null;
|
|
@@ -25512,10 +25540,10 @@ function getResizeHandleHTML(x, y, borderColor, handleTypes) {
|
|
|
25512
25540
|
}
|
|
25513
25541
|
var setHandleStyle = {
|
|
25514
25542
|
0: function (direction, leftOrRight, topOrBottom, borderColor) {
|
|
25515
|
-
return "position:relative;width:" + RESIZE_HANDLE_SIZE + "px;height:" + RESIZE_HANDLE_SIZE + "px;background-color: " + borderColor + ";cursor:" + direction + "-resize;" + topOrBottom + ":-" + RESIZE_HANDLE_MARGIN + "px;" + leftOrRight + ":-" + RESIZE_HANDLE_MARGIN + "px;";
|
|
25543
|
+
return "position:relative;width:" + constants_1.RESIZE_HANDLE_SIZE + "px;height:" + constants_1.RESIZE_HANDLE_SIZE + "px;background-color: " + borderColor + ";cursor:" + direction + "-resize;" + topOrBottom + ":-" + constants_1.RESIZE_HANDLE_MARGIN + "px;" + leftOrRight + ":-" + constants_1.RESIZE_HANDLE_MARGIN + "px;";
|
|
25516
25544
|
},
|
|
25517
25545
|
1: function (direction, leftOrRight, topOrBottom) {
|
|
25518
|
-
return "position:relative;width:" + RESIZE_HANDLE_SIZE + "px;height:" + RESIZE_HANDLE_SIZE + "px;background-color: #FFFFFF;cursor:" + direction + "-resize;" + topOrBottom + ":-" + RESIZE_HANDLE_MARGIN + "px;" + leftOrRight + ":-" + RESIZE_HANDLE_MARGIN + "px;border-radius:100%;border: 2px solid #bfbfbf;box-shadow: 0px 0.36316px 1.36185px rgba(100, 100, 100, 0.25);";
|
|
25546
|
+
return "position:relative;width:" + constants_1.RESIZE_HANDLE_SIZE + "px;height:" + constants_1.RESIZE_HANDLE_SIZE + "px;background-color: #FFFFFF;cursor:" + direction + "-resize;" + topOrBottom + ":-" + constants_1.RESIZE_HANDLE_MARGIN + "px;" + leftOrRight + ":-" + constants_1.RESIZE_HANDLE_MARGIN + "px;border-radius:100%;border: 2px solid #bfbfbf;box-shadow: 0px 0.36316px 1.36185px rgba(100, 100, 100, 0.25);";
|
|
25519
25547
|
},
|
|
25520
25548
|
};
|
|
25521
25549
|
|
|
@@ -25531,13 +25559,9 @@ var setHandleStyle = {
|
|
|
25531
25559
|
"use strict";
|
|
25532
25560
|
|
|
25533
25561
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25534
|
-
exports.getRotateHTML = exports.
|
|
25562
|
+
exports.getRotateHTML = exports.updateRotateHandleState = exports.Rotator = void 0;
|
|
25535
25563
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs");
|
|
25536
|
-
var
|
|
25537
|
-
var ROTATE_GAP = 15;
|
|
25538
|
-
var DEG_PER_RAD = 180 / Math.PI;
|
|
25539
|
-
var DEFAULT_ROTATE_HANDLE_HEIGHT = ROTATE_SIZE / 2 + ROTATE_GAP;
|
|
25540
|
-
var ROTATE_ICON_MARGIN = 8;
|
|
25564
|
+
var constants_1 = __webpack_require__(/*! ../constants/constants */ "./packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/constants/constants.ts");
|
|
25541
25565
|
/**
|
|
25542
25566
|
* @internal
|
|
25543
25567
|
* The rotate drag and drop handler
|
|
@@ -25549,14 +25573,14 @@ exports.Rotator = {
|
|
|
25549
25573
|
},
|
|
25550
25574
|
onDragging: function (_a, e, base, deltaX, deltaY) {
|
|
25551
25575
|
var editInfo = _a.editInfo, options = _a.options;
|
|
25552
|
-
var distance = editInfo.heightPx / 2 + DEFAULT_ROTATE_HANDLE_HEIGHT;
|
|
25576
|
+
var distance = editInfo.heightPx / 2 + constants_1.DEFAULT_ROTATE_HANDLE_HEIGHT;
|
|
25553
25577
|
var newX = distance * Math.sin(base.angleRad) + deltaX;
|
|
25554
25578
|
var newY = distance * Math.cos(base.angleRad) - deltaY;
|
|
25555
25579
|
var angleInRad = Math.atan2(newX, newY);
|
|
25556
25580
|
if (!e.altKey && options && options.minRotateDeg !== undefined) {
|
|
25557
|
-
var angleInDeg = angleInRad * DEG_PER_RAD;
|
|
25581
|
+
var angleInDeg = angleInRad * constants_1.DEG_PER_RAD;
|
|
25558
25582
|
var adjustedAngleInDeg = Math.round(angleInDeg / options.minRotateDeg) * options.minRotateDeg;
|
|
25559
|
-
angleInRad = adjustedAngleInDeg / DEG_PER_RAD;
|
|
25583
|
+
angleInRad = adjustedAngleInDeg / constants_1.DEG_PER_RAD;
|
|
25560
25584
|
}
|
|
25561
25585
|
if (editInfo.angleRad != angleInRad) {
|
|
25562
25586
|
editInfo.angleRad = angleInRad;
|
|
@@ -25572,51 +25596,60 @@ exports.Rotator = {
|
|
|
25572
25596
|
* Move rotate handle. When image is very close to the border of editor, rotate handle may not be visible.
|
|
25573
25597
|
* Fix it by reduce the distance from image to rotate handle
|
|
25574
25598
|
*/
|
|
25575
|
-
function
|
|
25576
|
-
|
|
25577
|
-
|
|
25578
|
-
|
|
25579
|
-
|
|
25580
|
-
|
|
25581
|
-
|
|
25582
|
-
|
|
25583
|
-
|
|
25584
|
-
|
|
25585
|
-
|
|
25586
|
-
|
|
25587
|
-
|
|
25588
|
-
|
|
25589
|
-
|
|
25590
|
-
adjustedDistance =
|
|
25591
|
-
|
|
25592
|
-
|
|
25593
|
-
|
|
25599
|
+
function updateRotateHandleState(editorRect, rotateCenter, rotateHandle, isSmallImage) {
|
|
25600
|
+
if (isSmallImage) {
|
|
25601
|
+
rotateCenter.style.display = 'none';
|
|
25602
|
+
rotateHandle.style.display = 'none';
|
|
25603
|
+
return;
|
|
25604
|
+
}
|
|
25605
|
+
else {
|
|
25606
|
+
rotateCenter.style.display = '';
|
|
25607
|
+
rotateHandle.style.display = '';
|
|
25608
|
+
var rotateHandleRect = rotateHandle.getBoundingClientRect();
|
|
25609
|
+
if (rotateHandleRect) {
|
|
25610
|
+
var top_1 = rotateHandleRect.top - editorRect.top;
|
|
25611
|
+
var left = rotateHandleRect.left - editorRect.left;
|
|
25612
|
+
var right = rotateHandleRect.right - editorRect.right;
|
|
25613
|
+
var bottom = rotateHandleRect.bottom - editorRect.bottom;
|
|
25614
|
+
var adjustedDistance = Number.MAX_SAFE_INTEGER;
|
|
25615
|
+
if (top_1 <= 0) {
|
|
25616
|
+
adjustedDistance = top_1;
|
|
25617
|
+
}
|
|
25618
|
+
else if (left <= 0) {
|
|
25619
|
+
adjustedDistance = left;
|
|
25620
|
+
}
|
|
25621
|
+
else if (right >= 0) {
|
|
25622
|
+
adjustedDistance = right;
|
|
25623
|
+
}
|
|
25624
|
+
else if (bottom >= 0) {
|
|
25625
|
+
adjustedDistance = bottom;
|
|
25626
|
+
}
|
|
25627
|
+
var rotateGap = Math.max(Math.min(constants_1.ROTATE_GAP, adjustedDistance), 0);
|
|
25628
|
+
var rotateTop = Math.max(Math.min(constants_1.ROTATE_SIZE, adjustedDistance - rotateGap), 0);
|
|
25629
|
+
rotateCenter.style.top = -rotateGap - constants_1.RESIZE_HANDLE_MARGIN + 'px';
|
|
25630
|
+
rotateCenter.style.height = rotateGap + 'px';
|
|
25631
|
+
rotateHandle.style.top = -rotateTop + 'px';
|
|
25594
25632
|
}
|
|
25595
|
-
var rotateGap = Math.max(Math.min(ROTATE_GAP, adjustedDistance), 0);
|
|
25596
|
-
var rotateTop = Math.max(Math.min(ROTATE_SIZE, adjustedDistance - rotateGap), 0);
|
|
25597
|
-
rotateCenter.style.top = -rotateGap + 'px';
|
|
25598
|
-
rotateCenter.style.height = rotateGap + 'px';
|
|
25599
|
-
rotateHandle.style.top = -rotateTop + 'px';
|
|
25600
25633
|
}
|
|
25601
25634
|
}
|
|
25602
|
-
exports.
|
|
25635
|
+
exports.updateRotateHandleState = updateRotateHandleState;
|
|
25603
25636
|
/**
|
|
25604
25637
|
* @internal
|
|
25605
25638
|
* Get HTML for rotate elements, including the rotate handle with icon, and a line between the handle and the image
|
|
25606
25639
|
*/
|
|
25607
25640
|
function getRotateHTML(_a) {
|
|
25608
25641
|
var borderColor = _a.borderColor, rotateHandleBackColor = _a.rotateHandleBackColor;
|
|
25609
|
-
var handleLeft = ROTATE_SIZE / 2;
|
|
25642
|
+
var handleLeft = constants_1.ROTATE_SIZE / 2;
|
|
25610
25643
|
return [
|
|
25611
25644
|
{
|
|
25612
25645
|
tag: 'div',
|
|
25613
25646
|
className: "r_rotateC" /* RotateCenter */,
|
|
25614
|
-
style: "position:absolute;left:50%;width:1px;background-color:" + borderColor + ";top:" + -
|
|
25647
|
+
style: "position:absolute;left:50%;width:1px;background-color:" + borderColor + ";top:" + -constants_1.ROTATE_HANDLE_TOP + "px;height:" + constants_1.ROTATE_GAP + "px;margin-left:" + -constants_1.ROTATE_WIDTH + "px;",
|
|
25615
25648
|
children: [
|
|
25616
25649
|
{
|
|
25617
25650
|
tag: 'div',
|
|
25618
25651
|
className: "r_rotateH" /* RotateHandle */,
|
|
25619
|
-
style: "position:absolute;background-color:" + rotateHandleBackColor + ";border:solid 1px " + borderColor + ";border-radius:50%;width:" + ROTATE_SIZE + "px;height:" + ROTATE_SIZE + "px;left:-" + handleLeft + "px;cursor:move;top:" + -ROTATE_SIZE + "px;",
|
|
25652
|
+
style: "position:absolute;background-color:" + rotateHandleBackColor + ";border:solid 1px " + borderColor + ";border-radius:50%;width:" + constants_1.ROTATE_SIZE + "px;height:" + constants_1.ROTATE_SIZE + "px;left:-" + (handleLeft + constants_1.ROTATE_WIDTH) + "px;cursor:move;top:" + -constants_1.ROTATE_SIZE + "px;",
|
|
25620
25653
|
children: [getRotateIconHTML(borderColor)],
|
|
25621
25654
|
},
|
|
25622
25655
|
],
|
|
@@ -25629,7 +25662,7 @@ function getRotateIconHTML(borderColor) {
|
|
|
25629
25662
|
return {
|
|
25630
25663
|
tag: 'svg',
|
|
25631
25664
|
namespace: 'http://www.w3.org/2000/svg',
|
|
25632
|
-
style: "width:16px;height:16px;margin: " + ROTATE_ICON_MARGIN + "px " + ROTATE_ICON_MARGIN + "px",
|
|
25665
|
+
style: "width:16px;height:16px;margin: " + constants_1.ROTATE_ICON_MARGIN + "px " + constants_1.ROTATE_ICON_MARGIN + "px",
|
|
25633
25666
|
children: [
|
|
25634
25667
|
{
|
|
25635
25668
|
tag: 'path',
|
|
@@ -28505,7 +28538,11 @@ var RIGHT_CLICK = 3;
|
|
|
28505
28538
|
*/
|
|
28506
28539
|
function handleMouseDownEvent(event, state, editor) {
|
|
28507
28540
|
var _a;
|
|
28508
|
-
var _b = event.rawEvent, which = _b.which, shiftKey = _b.shiftKey;
|
|
28541
|
+
var _b = event.rawEvent, which = _b.which, shiftKey = _b.shiftKey, target = _b.target;
|
|
28542
|
+
var table = editor.getElementAtCursor('table', target, event);
|
|
28543
|
+
if (table && !table.isContentEditable) {
|
|
28544
|
+
return;
|
|
28545
|
+
}
|
|
28509
28546
|
var td = editor.getElementAtCursor(constants_1.TABLE_CELL_SELECTOR);
|
|
28510
28547
|
if (which == RIGHT_CLICK && state.tableSelection && state.vTable && td) {
|
|
28511
28548
|
//If the user is right clicking To open context menu
|
|
@@ -29151,10 +29188,14 @@ var TableResize = /** @class */ (function () {
|
|
|
29151
29188
|
* @param onShowHelperElement An optional callback to allow customize helper element of table resizing.
|
|
29152
29189
|
* To customize the helper element, add this callback and change the attributes of elementData then it
|
|
29153
29190
|
* will be picked up by TableResize code
|
|
29191
|
+
* @param anchorContainerSelector An optional selector string to specify the container to host the plugin.
|
|
29192
|
+
* The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
|
|
29193
|
+
* If not specified, the plugin will be inserted in document.body
|
|
29154
29194
|
*/
|
|
29155
|
-
function TableResize(onShowHelperElement) {
|
|
29195
|
+
function TableResize(onShowHelperElement, anchorContainerSelector) {
|
|
29156
29196
|
var _this = this;
|
|
29157
29197
|
this.onShowHelperElement = onShowHelperElement;
|
|
29198
|
+
this.anchorContainerSelector = anchorContainerSelector;
|
|
29158
29199
|
this.editor = null;
|
|
29159
29200
|
this.onMouseMoveDisposer = null;
|
|
29160
29201
|
this.tableRectMap = null;
|
|
@@ -29248,7 +29289,10 @@ var TableResize = /** @class */ (function () {
|
|
|
29248
29289
|
this.disposeTableEditor();
|
|
29249
29290
|
}
|
|
29250
29291
|
if (!this.tableEditor && table && this.editor && table.rows.length > 0) {
|
|
29251
|
-
|
|
29292
|
+
var container = this.anchorContainerSelector
|
|
29293
|
+
? this.editor.getDocument().querySelector(this.anchorContainerSelector)
|
|
29294
|
+
: undefined;
|
|
29295
|
+
this.tableEditor = new TableEditor_1.default(this.editor, table, this.invalidateTableRects, this.onShowHelperElement, (0, roosterjs_editor_dom_1.safeInstanceOf)(container, 'HTMLElement') ? container : undefined, e === null || e === void 0 ? void 0 : e.currentTarget);
|
|
29252
29296
|
}
|
|
29253
29297
|
};
|
|
29254
29298
|
TableResize.prototype.disposeTableEditor = function () {
|
|
@@ -29299,7 +29343,7 @@ var MIN_CELL_WIDTH = 30;
|
|
|
29299
29343
|
/**
|
|
29300
29344
|
* @internal
|
|
29301
29345
|
*/
|
|
29302
|
-
function createCellResizer(td, zoomScale, isRTL, isHorizontal, onStart, onEnd, onShowHelperElement) {
|
|
29346
|
+
function createCellResizer(td, zoomScale, isRTL, isHorizontal, onStart, onEnd, onShowHelperElement, anchorContainer) {
|
|
29303
29347
|
var document = td.ownerDocument;
|
|
29304
29348
|
var createElementData = {
|
|
29305
29349
|
tag: 'div',
|
|
@@ -29307,7 +29351,7 @@ function createCellResizer(td, zoomScale, isRTL, isHorizontal, onStart, onEnd, o
|
|
|
29307
29351
|
};
|
|
29308
29352
|
onShowHelperElement === null || onShowHelperElement === void 0 ? void 0 : onShowHelperElement(createElementData, 'CellResizer');
|
|
29309
29353
|
var div = (0, roosterjs_editor_dom_1.createElement)(createElementData, document);
|
|
29310
|
-
document.body.appendChild(div);
|
|
29354
|
+
(anchorContainer || document.body).appendChild(div);
|
|
29311
29355
|
var context = { td: td, isRTL: isRTL, zoomScale: zoomScale, onStart: onStart };
|
|
29312
29356
|
var setPosition = isHorizontal ? setHorizontalPosition : setVerticalPosition;
|
|
29313
29357
|
setPosition(context, div);
|
|
@@ -29506,12 +29550,13 @@ var TOP_OR_SIDE;
|
|
|
29506
29550
|
* When set a different current table or change current TD, we need to update these areas
|
|
29507
29551
|
*/
|
|
29508
29552
|
var TableEditor = /** @class */ (function () {
|
|
29509
|
-
function TableEditor(editor, table, onChanged, onShowHelperElement, contentDiv) {
|
|
29553
|
+
function TableEditor(editor, table, onChanged, onShowHelperElement, anchorContainer, contentDiv) {
|
|
29510
29554
|
var _this = this;
|
|
29511
29555
|
this.editor = editor;
|
|
29512
29556
|
this.table = table;
|
|
29513
29557
|
this.onChanged = onChanged;
|
|
29514
29558
|
this.onShowHelperElement = onShowHelperElement;
|
|
29559
|
+
this.anchorContainer = anchorContainer;
|
|
29515
29560
|
this.contentDiv = contentDiv;
|
|
29516
29561
|
// 1, 2 - Insert a column or a row
|
|
29517
29562
|
this.horizontalInserter = null;
|
|
@@ -29624,7 +29669,7 @@ var TableEditor = /** @class */ (function () {
|
|
|
29624
29669
|
if (!firstCellRect) {
|
|
29625
29670
|
return;
|
|
29626
29671
|
}
|
|
29627
|
-
//Determine if cursor is on top or side
|
|
29672
|
+
// Determine if cursor is on top or side
|
|
29628
29673
|
var topOrSide = y <= firstCellRect.top + INSERTER_HOVER_OFFSET
|
|
29629
29674
|
? 0 /* top */
|
|
29630
29675
|
: this.isRTL
|
|
@@ -29634,25 +29679,28 @@ var TableEditor = /** @class */ (function () {
|
|
|
29634
29679
|
: x <= firstCellRect.left + INSERTER_HOVER_OFFSET
|
|
29635
29680
|
? 1 /* side */
|
|
29636
29681
|
: undefined;
|
|
29682
|
+
var topOrSideBinary = topOrSide ? 1 : 0;
|
|
29683
|
+
// Get whole table rect
|
|
29684
|
+
var tableRect = (0, roosterjs_editor_dom_1.normalizeRect)(this.table.getBoundingClientRect());
|
|
29637
29685
|
// i is row index, j is column index
|
|
29638
29686
|
for (var i = 0; i < this.table.rows.length; i++) {
|
|
29639
29687
|
var tr = this.table.rows[i];
|
|
29640
29688
|
var j = 0;
|
|
29641
29689
|
for (; j < tr.cells.length; j++) {
|
|
29642
29690
|
var td = tr.cells[j];
|
|
29643
|
-
var tableRect = (0, roosterjs_editor_dom_1.normalizeRect)(this.table.getBoundingClientRect());
|
|
29644
29691
|
var tdRect = (0, roosterjs_editor_dom_1.normalizeRect)(td.getBoundingClientRect());
|
|
29645
29692
|
if (!tdRect || !tableRect) {
|
|
29646
29693
|
continue;
|
|
29647
29694
|
}
|
|
29648
29695
|
// Determine the cell the cursor is in range of
|
|
29696
|
+
// Offset is only used for first row and column
|
|
29649
29697
|
var lessThanBottom = y <= tdRect.bottom;
|
|
29650
29698
|
var lessThanRight = this.isRTL
|
|
29651
|
-
? x <= tdRect.right + INSERTER_HOVER_OFFSET
|
|
29699
|
+
? x <= tdRect.right + INSERTER_HOVER_OFFSET * topOrSideBinary
|
|
29652
29700
|
: x <= tdRect.right;
|
|
29653
29701
|
var moreThanLeft = this.isRTL
|
|
29654
29702
|
? x >= tdRect.left
|
|
29655
|
-
: x >= tdRect.left - INSERTER_HOVER_OFFSET;
|
|
29703
|
+
: x >= tdRect.left - INSERTER_HOVER_OFFSET * topOrSideBinary;
|
|
29656
29704
|
if (lessThanBottom && lessThanRight && moreThanLeft) {
|
|
29657
29705
|
var isOnLeftOrRight = this.isRTL
|
|
29658
29706
|
? tdRect.right <= tableRect.right && tdRect.right >= tableRect.right - 1
|
|
@@ -29680,6 +29728,7 @@ var TableEditor = /** @class */ (function () {
|
|
|
29680
29728
|
this.setInserterTd(null);
|
|
29681
29729
|
}
|
|
29682
29730
|
this.setResizingTd(td);
|
|
29731
|
+
//Cell found
|
|
29683
29732
|
break;
|
|
29684
29733
|
}
|
|
29685
29734
|
}
|
|
@@ -29687,14 +29736,15 @@ var TableEditor = /** @class */ (function () {
|
|
|
29687
29736
|
break;
|
|
29688
29737
|
}
|
|
29689
29738
|
}
|
|
29739
|
+
// Create Selector and Resizer
|
|
29690
29740
|
this.setEditorFeatures();
|
|
29691
29741
|
};
|
|
29692
29742
|
TableEditor.prototype.setEditorFeatures = function () {
|
|
29693
29743
|
if (!this.tableSelector) {
|
|
29694
|
-
this.tableSelector = (0, TableSelector_1.default)(this.table, this.editor
|
|
29744
|
+
this.tableSelector = (0, TableSelector_1.default)(this.table, this.editor, this.onSelect, this.getOnMouseOut, this.onShowHelperElement, this.contentDiv, this.anchorContainer);
|
|
29695
29745
|
}
|
|
29696
29746
|
if (!this.tableResizer) {
|
|
29697
|
-
this.tableResizer = (0, TableResizer_1.default)(this.table, this.editor.
|
|
29747
|
+
this.tableResizer = (0, TableResizer_1.default)(this.table, this.editor, this.onStartTableResize, this.onFinishEditing, this.onShowHelperElement, this.contentDiv, this.anchorContainer);
|
|
29698
29748
|
}
|
|
29699
29749
|
};
|
|
29700
29750
|
TableEditor.prototype.setResizingTd = function (td) {
|
|
@@ -29703,8 +29753,8 @@ var TableEditor = /** @class */ (function () {
|
|
|
29703
29753
|
}
|
|
29704
29754
|
if (!this.horizontalResizer && td) {
|
|
29705
29755
|
var zoomScale = this.editor.getZoomScale();
|
|
29706
|
-
this.horizontalResizer = (0, CellResizer_1.default)(td, zoomScale, this.isRTL, true /*isHorizontal*/, this.onStartCellResize, this.onFinishEditing, this.onShowHelperElement);
|
|
29707
|
-
this.verticalResizer = (0, CellResizer_1.default)(td, zoomScale, this.isRTL, false /*isHorizontal*/, this.onStartCellResize, this.onFinishEditing, this.onShowHelperElement);
|
|
29756
|
+
this.horizontalResizer = (0, CellResizer_1.default)(td, zoomScale, this.isRTL, true /*isHorizontal*/, this.onStartCellResize, this.onFinishEditing, this.onShowHelperElement, this.anchorContainer);
|
|
29757
|
+
this.verticalResizer = (0, CellResizer_1.default)(td, zoomScale, this.isRTL, false /*isHorizontal*/, this.onStartCellResize, this.onFinishEditing, this.onShowHelperElement, this.anchorContainer);
|
|
29708
29758
|
}
|
|
29709
29759
|
};
|
|
29710
29760
|
/**
|
|
@@ -29717,7 +29767,7 @@ var TableEditor = /** @class */ (function () {
|
|
|
29717
29767
|
this.disposeTableInserter();
|
|
29718
29768
|
}
|
|
29719
29769
|
if (!this.horizontalInserter && !this.verticalInserter && td) {
|
|
29720
|
-
var newInserter = (0, TableInserter_1.default)(this.editor, td, this.isRTL, !!isHorizontal, this.onInserted, this.getOnMouseOut, this.onShowHelperElement);
|
|
29770
|
+
var newInserter = (0, TableInserter_1.default)(this.editor, td, this.isRTL, !!isHorizontal, this.onInserted, this.getOnMouseOut, this.onShowHelperElement, this.anchorContainer);
|
|
29721
29771
|
if (isHorizontal) {
|
|
29722
29772
|
this.horizontalInserter = newInserter;
|
|
29723
29773
|
}
|
|
@@ -29818,7 +29868,7 @@ var INSERTER_BORDER_SIZE = 1;
|
|
|
29818
29868
|
/**
|
|
29819
29869
|
* @internal
|
|
29820
29870
|
*/
|
|
29821
|
-
function createTableInserter(editor, td, isRTL, isHorizontal, onInsert, getOnMouseOut, onShowHelperElement) {
|
|
29871
|
+
function createTableInserter(editor, td, isRTL, isHorizontal, onInsert, getOnMouseOut, onShowHelperElement, anchorContainer) {
|
|
29822
29872
|
var table = editor.getElementAtCursor('table', td);
|
|
29823
29873
|
var tdRect = (0, roosterjs_editor_dom_1.normalizeRect)(td.getBoundingClientRect());
|
|
29824
29874
|
var viewPort = editor.getVisibleViewport();
|
|
@@ -29843,7 +29893,7 @@ function createTableInserter(editor, td, isRTL, isHorizontal, onInsert, getOnMou
|
|
|
29843
29893
|
div.style.top = tableRect.top - (INSERTER_SIDE_LENGTH - 1 + 2 * INSERTER_BORDER_SIZE) + "px";
|
|
29844
29894
|
div.firstChild.style.height = tableRect.bottom - tableRect.top + "px";
|
|
29845
29895
|
}
|
|
29846
|
-
document_1.body.appendChild(div);
|
|
29896
|
+
(anchorContainer || document_1.body).appendChild(div);
|
|
29847
29897
|
var handler = new TableInsertHandler(div, td, isHorizontal, editor, onInsert, getOnMouseOut);
|
|
29848
29898
|
return { div: div, featureHandler: handler, node: td };
|
|
29849
29899
|
}
|
|
@@ -29922,8 +29972,14 @@ var MIN_CELL_HEIGHT = 20;
|
|
|
29922
29972
|
/**
|
|
29923
29973
|
* @internal
|
|
29924
29974
|
*/
|
|
29925
|
-
function createTableResizer(table,
|
|
29975
|
+
function createTableResizer(table, editor, onStart, onEnd, onShowHelperElement, contentDiv, anchorContainer) {
|
|
29976
|
+
var rect = (0, roosterjs_editor_dom_1.normalizeRect)(table.getBoundingClientRect());
|
|
29977
|
+
if (!isTableBottomVisible(editor, rect, contentDiv)) {
|
|
29978
|
+
return null;
|
|
29979
|
+
}
|
|
29926
29980
|
var document = table.ownerDocument;
|
|
29981
|
+
var isRTL = (0, roosterjs_editor_dom_1.getComputedStyle)(table, 'direction') == 'rtl';
|
|
29982
|
+
var zoomScale = editor.getZoomScale();
|
|
29927
29983
|
var createElementData = {
|
|
29928
29984
|
tag: 'div',
|
|
29929
29985
|
style: "position: fixed; cursor: " + (isRTL ? 'ne' : 'nw') + "-resize; user-select: none; border: 1px solid #808080",
|
|
@@ -29932,15 +29988,20 @@ function createTableResizer(table, zoomScale, isRTL, onStart, onDragEnd, onShowH
|
|
|
29932
29988
|
var div = (0, roosterjs_editor_dom_1.createElement)(createElementData, document);
|
|
29933
29989
|
div.style.width = TABLE_RESIZER_LENGTH + "px";
|
|
29934
29990
|
div.style.height = TABLE_RESIZER_LENGTH + "px";
|
|
29935
|
-
document.body.appendChild(div);
|
|
29991
|
+
(anchorContainer || document.body).appendChild(div);
|
|
29936
29992
|
var context = {
|
|
29937
29993
|
isRTL: isRTL,
|
|
29938
29994
|
table: table,
|
|
29939
29995
|
zoomScale: zoomScale,
|
|
29940
29996
|
onStart: onStart,
|
|
29997
|
+
onEnd: onEnd,
|
|
29998
|
+
div: div,
|
|
29999
|
+
editor: editor,
|
|
30000
|
+
contentDiv: contentDiv,
|
|
29941
30001
|
};
|
|
29942
|
-
|
|
29943
|
-
var featureHandler = new DragAndDropHelper_1.default(div, context,
|
|
30002
|
+
setDivPosition(context, div);
|
|
30003
|
+
var featureHandler = new DragAndDropHelper_1.default(div, context, hideResizer, // Resizer is hidden while dragging only
|
|
30004
|
+
{
|
|
29944
30005
|
onDragStart: onDragStart,
|
|
29945
30006
|
onDragging: onDragging,
|
|
29946
30007
|
onDragEnd: onDragEnd,
|
|
@@ -30003,7 +30064,15 @@ function onDragging(context, event, initValue, deltaX, deltaY) {
|
|
|
30003
30064
|
return false;
|
|
30004
30065
|
}
|
|
30005
30066
|
}
|
|
30006
|
-
function
|
|
30067
|
+
function onDragEnd(context, event, initValue) {
|
|
30068
|
+
if (isTableBottomVisible(context.editor, (0, roosterjs_editor_dom_1.normalizeRect)(context.table.getBoundingClientRect()), context.contentDiv)) {
|
|
30069
|
+
context.div.style.visibility = 'visible';
|
|
30070
|
+
setDivPosition(context, context.div);
|
|
30071
|
+
}
|
|
30072
|
+
context.onEnd();
|
|
30073
|
+
return false;
|
|
30074
|
+
}
|
|
30075
|
+
function setDivPosition(context, trigger) {
|
|
30007
30076
|
var table = context.table, isRTL = context.isRTL;
|
|
30008
30077
|
var rect = (0, roosterjs_editor_dom_1.normalizeRect)(table.getBoundingClientRect());
|
|
30009
30078
|
if (rect) {
|
|
@@ -30013,6 +30082,19 @@ function setResizeDivPosition(context, trigger) {
|
|
|
30013
30082
|
: rect.right + "px";
|
|
30014
30083
|
}
|
|
30015
30084
|
}
|
|
30085
|
+
function hideResizer(context, trigger) {
|
|
30086
|
+
trigger.style.visibility = 'hidden';
|
|
30087
|
+
}
|
|
30088
|
+
function isTableBottomVisible(editor, rect, contentDiv) {
|
|
30089
|
+
var visibleViewport = editor.getVisibleViewport();
|
|
30090
|
+
if (contentDiv && (0, roosterjs_editor_dom_1.safeInstanceOf)(contentDiv, 'HTMLElement') && visibleViewport && rect) {
|
|
30091
|
+
var containerRect = (0, roosterjs_editor_dom_1.normalizeRect)(contentDiv.getBoundingClientRect());
|
|
30092
|
+
return (!!containerRect &&
|
|
30093
|
+
containerRect.bottom >= rect.bottom &&
|
|
30094
|
+
visibleViewport.bottom >= rect.bottom);
|
|
30095
|
+
}
|
|
30096
|
+
return true;
|
|
30097
|
+
}
|
|
30016
30098
|
|
|
30017
30099
|
|
|
30018
30100
|
/***/ }),
|
|
@@ -30034,11 +30116,12 @@ var TABLE_SELECTOR_ID = '_Table_Selector';
|
|
|
30034
30116
|
/**
|
|
30035
30117
|
* @internal
|
|
30036
30118
|
*/
|
|
30037
|
-
function createTableSelector(table,
|
|
30119
|
+
function createTableSelector(table, editor, onFinishDragging, getOnMouseOut, onShowHelperElement, contentDiv, anchorContainer) {
|
|
30038
30120
|
var rect = (0, roosterjs_editor_dom_1.normalizeRect)(table.getBoundingClientRect());
|
|
30039
30121
|
if (!isTableTopVisible(editor, rect, contentDiv)) {
|
|
30040
30122
|
return null;
|
|
30041
30123
|
}
|
|
30124
|
+
var zoomScale = editor.getZoomScale();
|
|
30042
30125
|
var document = table.ownerDocument;
|
|
30043
30126
|
var createElementData = {
|
|
30044
30127
|
tag: 'div',
|
|
@@ -30049,28 +30132,29 @@ function createTableSelector(table, zoomScale, editor, onFinishDragging, getOnMo
|
|
|
30049
30132
|
div.id = TABLE_SELECTOR_ID;
|
|
30050
30133
|
div.style.width = TABLE_SELECTOR_LENGTH + "px";
|
|
30051
30134
|
div.style.height = TABLE_SELECTOR_LENGTH + "px";
|
|
30052
|
-
document.body.appendChild(div);
|
|
30135
|
+
(anchorContainer || document.body).appendChild(div);
|
|
30053
30136
|
var context = {
|
|
30054
30137
|
table: table,
|
|
30055
30138
|
zoomScale: zoomScale,
|
|
30056
30139
|
rect: rect,
|
|
30140
|
+
isRTL: (0, roosterjs_editor_dom_1.getComputedStyle)(table, 'direction') == 'rtl',
|
|
30057
30141
|
};
|
|
30058
|
-
|
|
30142
|
+
setDivPosition(context, div);
|
|
30059
30143
|
var onDragEnd = function (context, event) {
|
|
30060
30144
|
if (event.target == div) {
|
|
30061
30145
|
onFinishDragging(context.table);
|
|
30062
30146
|
}
|
|
30063
30147
|
return false;
|
|
30064
30148
|
};
|
|
30065
|
-
var featureHandler = new TableSelectorFeature(div, context,
|
|
30149
|
+
var featureHandler = new TableSelectorFeature(div, context, setDivPosition, {
|
|
30066
30150
|
onDragEnd: onDragEnd,
|
|
30067
|
-
}, zoomScale, getOnMouseOut);
|
|
30151
|
+
}, context.zoomScale, getOnMouseOut);
|
|
30068
30152
|
return { div: div, featureHandler: featureHandler, node: table };
|
|
30069
30153
|
}
|
|
30070
30154
|
exports["default"] = createTableSelector;
|
|
30071
30155
|
var TableSelectorFeature = /** @class */ (function (_super) {
|
|
30072
30156
|
(0, tslib_1.__extends)(TableSelectorFeature, _super);
|
|
30073
|
-
function TableSelectorFeature(div, context, onSubmit, handler, zoomScale, getOnMouseOut, forceMobile) {
|
|
30157
|
+
function TableSelectorFeature(div, context, onSubmit, handler, zoomScale, getOnMouseOut, forceMobile, container) {
|
|
30074
30158
|
var _this = _super.call(this, div, context, onSubmit, handler, zoomScale, forceMobile) || this;
|
|
30075
30159
|
_this.div = div;
|
|
30076
30160
|
_this.onMouseOut = getOnMouseOut(div);
|
|
@@ -30086,7 +30170,7 @@ var TableSelectorFeature = /** @class */ (function (_super) {
|
|
|
30086
30170
|
};
|
|
30087
30171
|
return TableSelectorFeature;
|
|
30088
30172
|
}(DragAndDropHelper_1.default));
|
|
30089
|
-
function
|
|
30173
|
+
function setDivPosition(context, trigger) {
|
|
30090
30174
|
var rect = context.rect;
|
|
30091
30175
|
if (rect) {
|
|
30092
30176
|
trigger.style.top = rect.top - TABLE_SELECTOR_LENGTH + "px";
|
|
@@ -31286,6 +31370,16 @@ var CompatibleExperimentalFeatures;
|
|
|
31286
31370
|
* @deprecated
|
|
31287
31371
|
*/
|
|
31288
31372
|
CompatibleExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
|
|
31373
|
+
/**
|
|
31374
|
+
* @deprecated This feature is always enabled
|
|
31375
|
+
* Reuse existing DOM structure if possible when convert Content Model back to DOM tree
|
|
31376
|
+
*/
|
|
31377
|
+
CompatibleExperimentalFeatures["ReusableContentModel"] = "ReusableContentModel";
|
|
31378
|
+
/**
|
|
31379
|
+
* @deprecated This feature is always enabled
|
|
31380
|
+
* Handle keyboard editing event with Content Model
|
|
31381
|
+
*/
|
|
31382
|
+
CompatibleExperimentalFeatures["EditWithContentModel"] = "EditWithContentModel";
|
|
31289
31383
|
//#endregion
|
|
31290
31384
|
/**
|
|
31291
31385
|
* Provide additional Tab Key Features. Requires Text Features Content Editable Features
|
|
@@ -31302,14 +31396,6 @@ var CompatibleExperimentalFeatures;
|
|
|
31302
31396
|
* is the one closest to the item.
|
|
31303
31397
|
*/
|
|
31304
31398
|
CompatibleExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
|
|
31305
|
-
/**
|
|
31306
|
-
* Reuse existing DOM structure if possible when convert Content Model back to DOM tree
|
|
31307
|
-
*/
|
|
31308
|
-
CompatibleExperimentalFeatures["ReusableContentModel"] = "ReusableContentModel";
|
|
31309
|
-
/**
|
|
31310
|
-
* Handle keyboard editing event with Content Model
|
|
31311
|
-
*/
|
|
31312
|
-
CompatibleExperimentalFeatures["EditWithContentModel"] = "EditWithContentModel";
|
|
31313
31399
|
/**
|
|
31314
31400
|
* Delete table with Backspace key with the whole was selected with table selector
|
|
31315
31401
|
*/
|
|
@@ -33453,6 +33539,16 @@ var ExperimentalFeatures;
|
|
|
33453
33539
|
* @deprecated
|
|
33454
33540
|
*/
|
|
33455
33541
|
ExperimentalFeatures["DefaultFormatOnContainer"] = "DefaultFormatOnContainer";
|
|
33542
|
+
/**
|
|
33543
|
+
* @deprecated This feature is always enabled
|
|
33544
|
+
* Reuse existing DOM structure if possible when convert Content Model back to DOM tree
|
|
33545
|
+
*/
|
|
33546
|
+
ExperimentalFeatures["ReusableContentModel"] = "ReusableContentModel";
|
|
33547
|
+
/**
|
|
33548
|
+
* @deprecated This feature is always enabled
|
|
33549
|
+
* Handle keyboard editing event with Content Model
|
|
33550
|
+
*/
|
|
33551
|
+
ExperimentalFeatures["EditWithContentModel"] = "EditWithContentModel";
|
|
33456
33552
|
//#endregion
|
|
33457
33553
|
/**
|
|
33458
33554
|
* Provide additional Tab Key Features. Requires Text Features Content Editable Features
|
|
@@ -33469,14 +33565,6 @@ var ExperimentalFeatures;
|
|
|
33469
33565
|
* is the one closest to the item.
|
|
33470
33566
|
*/
|
|
33471
33567
|
ExperimentalFeatures["ReuseAllAncestorListElements"] = "ReuseAllAncestorListElements";
|
|
33472
|
-
/**
|
|
33473
|
-
* Reuse existing DOM structure if possible when convert Content Model back to DOM tree
|
|
33474
|
-
*/
|
|
33475
|
-
ExperimentalFeatures["ReusableContentModel"] = "ReusableContentModel";
|
|
33476
|
-
/**
|
|
33477
|
-
* Handle keyboard editing event with Content Model
|
|
33478
|
-
*/
|
|
33479
|
-
ExperimentalFeatures["EditWithContentModel"] = "EditWithContentModel";
|
|
33480
33568
|
/**
|
|
33481
33569
|
* Delete table with Backspace key with the whole was selected with table selector
|
|
33482
33570
|
*/
|