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