@leafer-in/editor 1.4.0 → 1.4.2
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/editor.cjs +24 -7
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.esm.js +25 -8
- package/dist/editor.esm.js.map +1 -1
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +24 -7
- package/dist/editor.js.map +1 -1
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.cjs.map +1 -1
- package/dist/editor.min.js +1 -1
- package/dist/editor.min.js.map +1 -1
- package/package.json +5 -5
- package/src/Editor.ts +2 -1
- package/src/editor/simulate.ts +6 -1
- package/src/helper/EditDataHelper.ts +17 -5
package/dist/editor.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event, defineKey,
|
|
1
|
+
import { Event, defineKey, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, Box, Text, Matrix, Debug, LeafHelper, PropertyEvent, DataHelper, RenderEvent, getPointData, Plugin as Plugin$1, Creator, dataType } from '@leafer-ui/draw';
|
|
2
2
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, Plugin, RotateEvent, KeyEvent } from '@leafer-ui/core';
|
|
3
3
|
import '@leafer-in/resize';
|
|
4
4
|
|
|
@@ -160,7 +160,7 @@ class Stroker extends UI {
|
|
|
160
160
|
}
|
|
161
161
|
__decorate([
|
|
162
162
|
targetAttr(onTarget$1)
|
|
163
|
-
], Stroker.prototype, "target",
|
|
163
|
+
], Stroker.prototype, "target", void 0);
|
|
164
164
|
function onTarget$1(stroker) {
|
|
165
165
|
const value = stroker.target;
|
|
166
166
|
stroker.list = value ? (value instanceof Array ? value : [value]) : [];
|
|
@@ -439,7 +439,7 @@ const { within } = MathHelper;
|
|
|
439
439
|
const EditDataHelper = {
|
|
440
440
|
getScaleData(element, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
|
|
441
441
|
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
442
|
-
const { boxBounds, widthRange, heightRange } = element;
|
|
442
|
+
const { boxBounds, widthRange, heightRange, dragBounds } = element;
|
|
443
443
|
const { width, height } = startBounds;
|
|
444
444
|
if (around) {
|
|
445
445
|
totalMove.x *= 2;
|
|
@@ -527,6 +527,17 @@ const EditDataHelper = {
|
|
|
527
527
|
if (scaleY < 0)
|
|
528
528
|
scaleY = 1 / boxBounds.height / worldTransform.scaleY;
|
|
529
529
|
}
|
|
530
|
+
toPoint(around || align, boxBounds, origin, true);
|
|
531
|
+
if (dragBounds) {
|
|
532
|
+
const allowBounds = dragBounds === 'parent' ? element.parent.boxBounds : dragBounds;
|
|
533
|
+
const localBounds = new Bounds(element.__localBoxBounds);
|
|
534
|
+
localBounds.scaleOf(element.getLocalPointByInner(origin), scaleX, scaleY);
|
|
535
|
+
if (!BoundsHelper.includes(allowBounds, localBounds)) {
|
|
536
|
+
const realBounds = localBounds.getIntersect(allowBounds);
|
|
537
|
+
scaleX *= realBounds.width / localBounds.width;
|
|
538
|
+
scaleY *= realBounds.height / localBounds.height;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
530
541
|
if (widthRange) {
|
|
531
542
|
const nowWidth = boxBounds.width * element.scaleX;
|
|
532
543
|
scaleX = within(nowWidth * scaleX, widthRange) / nowWidth;
|
|
@@ -535,7 +546,6 @@ const EditDataHelper = {
|
|
|
535
546
|
const nowHeight = boxBounds.height * element.scaleY;
|
|
536
547
|
scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
|
|
537
548
|
}
|
|
538
|
-
toPoint(around || align, boxBounds, origin, true);
|
|
539
549
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
540
550
|
},
|
|
541
551
|
getRotateData(bounds, direction, current, last, around) {
|
|
@@ -1082,7 +1092,14 @@ const bounds = new Bounds();
|
|
|
1082
1092
|
function simulate(editor) {
|
|
1083
1093
|
const { simulateTarget, list } = editor;
|
|
1084
1094
|
const { zoomLayer } = list[0].leafer.zoomLayer;
|
|
1085
|
-
simulateTarget.safeChange(() =>
|
|
1095
|
+
simulateTarget.safeChange(() => {
|
|
1096
|
+
bounds.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page'));
|
|
1097
|
+
if (bounds.width === 0)
|
|
1098
|
+
bounds.width = 0.1;
|
|
1099
|
+
if (bounds.height === 0)
|
|
1100
|
+
bounds.height = 0.1;
|
|
1101
|
+
simulateTarget.reset(bounds.get());
|
|
1102
|
+
});
|
|
1086
1103
|
zoomLayer.add(simulateTarget);
|
|
1087
1104
|
}
|
|
1088
1105
|
|
|
@@ -1439,9 +1456,9 @@ class Editor extends Group {
|
|
|
1439
1456
|
this.skewOf(origin, skewX, skewY);
|
|
1440
1457
|
}
|
|
1441
1458
|
move(x, y = 0) {
|
|
1459
|
+
const { element } = this;
|
|
1442
1460
|
if (!this.checkTransform('moveable'))
|
|
1443
1461
|
return;
|
|
1444
|
-
const { element } = this;
|
|
1445
1462
|
const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
|
|
1446
1463
|
if (this.multiple)
|
|
1447
1464
|
element.safeChange(() => element.move(x, y));
|
|
@@ -1649,10 +1666,10 @@ class Editor extends Group {
|
|
|
1649
1666
|
}
|
|
1650
1667
|
__decorate([
|
|
1651
1668
|
targetAttr(onHover)
|
|
1652
|
-
], Editor.prototype, "hoverTarget",
|
|
1669
|
+
], Editor.prototype, "hoverTarget", void 0);
|
|
1653
1670
|
__decorate([
|
|
1654
1671
|
targetAttr(onTarget)
|
|
1655
|
-
], Editor.prototype, "target",
|
|
1672
|
+
], Editor.prototype, "target", void 0);
|
|
1656
1673
|
|
|
1657
1674
|
class InnerEditor {
|
|
1658
1675
|
static registerInnerEditor() {
|