@leafer/worker 1.6.6 → 1.7.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/worker.js +495 -350
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +491 -346
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +22 -22
package/dist/worker.module.js
CHANGED
|
@@ -43,7 +43,7 @@ const IncrementId = {
|
|
|
43
43
|
};
|
|
44
44
|
const I$2 = IncrementId;
|
|
45
45
|
|
|
46
|
-
const { round: round$6, pow: pow$2, PI: PI$
|
|
46
|
+
const { round: round$6, pow: pow$2, PI: PI$4 } = Math;
|
|
47
47
|
const MathHelper = {
|
|
48
48
|
within(value, min, max) {
|
|
49
49
|
if (typeof min === 'object')
|
|
@@ -139,9 +139,9 @@ const MathHelper = {
|
|
|
139
139
|
function randInt(num) {
|
|
140
140
|
return Math.round(Math.random() * num);
|
|
141
141
|
}
|
|
142
|
-
const OneRadian = PI$
|
|
143
|
-
const PI2 = PI$
|
|
144
|
-
const PI_2 = PI$
|
|
142
|
+
const OneRadian = PI$4 / 180;
|
|
143
|
+
const PI2 = PI$4 * 2;
|
|
144
|
+
const PI_2 = PI$4 / 2;
|
|
145
145
|
function getPointData() { return { x: 0, y: 0 }; }
|
|
146
146
|
function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
|
|
147
147
|
function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
@@ -436,7 +436,7 @@ const MatrixHelper = {
|
|
|
436
436
|
const M$a = MatrixHelper;
|
|
437
437
|
|
|
438
438
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
439
|
-
const { sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5
|
|
439
|
+
const { sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5 } = Math;
|
|
440
440
|
const PointHelper = {
|
|
441
441
|
defaultPoint: getPointData(),
|
|
442
442
|
tempPoint: {},
|
|
@@ -549,10 +549,11 @@ const PointHelper = {
|
|
|
549
549
|
getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
|
|
550
550
|
if (toOriginX === undefined)
|
|
551
551
|
toOriginX = originX, toOriginY = originY;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
|
|
552
|
+
const a = fromX - originX;
|
|
553
|
+
const b = fromY - originY;
|
|
554
|
+
const c = toX - toOriginX;
|
|
555
|
+
const d = toY - toOriginY;
|
|
556
|
+
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
556
557
|
},
|
|
557
558
|
getAtan2(t, to) {
|
|
558
559
|
return atan2$2(to.y - t.y, to.x - t.x);
|
|
@@ -3339,7 +3340,7 @@ const { getCenterX, getCenterY } = PointHelper;
|
|
|
3339
3340
|
const { arcTo } = PathCommandDataHelper;
|
|
3340
3341
|
const PathCorner = {
|
|
3341
3342
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3342
|
-
let command, commandLen;
|
|
3343
|
+
let command, lastCommand, commandLen;
|
|
3343
3344
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3344
3345
|
const len = data.length;
|
|
3345
3346
|
const smooth = [];
|
|
@@ -3377,8 +3378,10 @@ const PathCorner = {
|
|
|
3377
3378
|
lastY = y;
|
|
3378
3379
|
break;
|
|
3379
3380
|
case Z$3:
|
|
3380
|
-
|
|
3381
|
-
|
|
3381
|
+
if (lastCommand !== Z$3) {
|
|
3382
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3383
|
+
smooth.push(Z$3);
|
|
3384
|
+
}
|
|
3382
3385
|
i += 1;
|
|
3383
3386
|
break;
|
|
3384
3387
|
default:
|
|
@@ -3387,6 +3390,7 @@ const PathCorner = {
|
|
|
3387
3390
|
smooth.push(data[i + j]);
|
|
3388
3391
|
i += commandLen;
|
|
3389
3392
|
}
|
|
3393
|
+
lastCommand = command;
|
|
3390
3394
|
}
|
|
3391
3395
|
if (command !== Z$3) {
|
|
3392
3396
|
smooth[1] = startX;
|
|
@@ -3883,12 +3887,12 @@ class LeaferImage {
|
|
|
3883
3887
|
try {
|
|
3884
3888
|
if (transform && pattern.setTransform) {
|
|
3885
3889
|
pattern.setTransform(transform);
|
|
3886
|
-
transform =
|
|
3890
|
+
transform = undefined;
|
|
3887
3891
|
}
|
|
3888
3892
|
}
|
|
3889
3893
|
catch (_a) { }
|
|
3890
3894
|
if (paint)
|
|
3891
|
-
paint
|
|
3895
|
+
DataHelper.stintSet(paint, 'transform', transform);
|
|
3892
3896
|
return pattern;
|
|
3893
3897
|
}
|
|
3894
3898
|
destroy() {
|
|
@@ -3993,10 +3997,14 @@ function pathInputType(defaultValue) {
|
|
|
3993
3997
|
}));
|
|
3994
3998
|
}
|
|
3995
3999
|
const pathType = boundsType;
|
|
3996
|
-
function affectStrokeBoundsType(defaultValue) {
|
|
4000
|
+
function affectStrokeBoundsType(defaultValue, useStroke) {
|
|
3997
4001
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3998
4002
|
set(value) {
|
|
3999
|
-
this.__setAttr(key, value)
|
|
4003
|
+
if (this.__setAttr(key, value)) {
|
|
4004
|
+
doStrokeType(this);
|
|
4005
|
+
if (useStroke)
|
|
4006
|
+
this.__.__useStroke = true;
|
|
4007
|
+
}
|
|
4000
4008
|
}
|
|
4001
4009
|
}));
|
|
4002
4010
|
}
|
|
@@ -5422,6 +5430,8 @@ const LeafBounds = {
|
|
|
5422
5430
|
|
|
5423
5431
|
const LeafRender = {
|
|
5424
5432
|
__render(canvas, options) {
|
|
5433
|
+
if (options.shape)
|
|
5434
|
+
return this.__renderShape(canvas, options);
|
|
5425
5435
|
if (this.__worldOpacity) {
|
|
5426
5436
|
const data = this.__;
|
|
5427
5437
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5431,12 +5441,10 @@ const LeafRender = {
|
|
|
5431
5441
|
return this.__renderEraser(canvas, options);
|
|
5432
5442
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5433
5443
|
this.__draw(tempCanvas, options, canvas);
|
|
5434
|
-
if (this.__worldFlipped)
|
|
5444
|
+
if (this.__worldFlipped)
|
|
5435
5445
|
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5436
|
-
|
|
5437
|
-
else {
|
|
5446
|
+
else
|
|
5438
5447
|
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5439
|
-
}
|
|
5440
5448
|
tempCanvas.recycle(this.__nowWorld);
|
|
5441
5449
|
}
|
|
5442
5450
|
else {
|
|
@@ -5446,6 +5454,12 @@ const LeafRender = {
|
|
|
5446
5454
|
Debug.drawBounds(this, canvas, options);
|
|
5447
5455
|
}
|
|
5448
5456
|
},
|
|
5457
|
+
__renderShape(canvas, options) {
|
|
5458
|
+
if (this.__worldOpacity) {
|
|
5459
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5460
|
+
this.__drawShape(canvas, options);
|
|
5461
|
+
}
|
|
5462
|
+
},
|
|
5449
5463
|
__clip(canvas, options) {
|
|
5450
5464
|
if (this.__worldOpacity) {
|
|
5451
5465
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5865,7 +5879,8 @@ let Leaf = class Leaf {
|
|
|
5865
5879
|
__drawFast(_canvas, _options) { }
|
|
5866
5880
|
__draw(_canvas, _options, _originCanvas) { }
|
|
5867
5881
|
__clip(_canvas, _options) { }
|
|
5868
|
-
__renderShape(_canvas, _options
|
|
5882
|
+
__renderShape(_canvas, _options) { }
|
|
5883
|
+
__drawShape(_canvas, _options) { }
|
|
5869
5884
|
__updateWorldOpacity() { }
|
|
5870
5885
|
__updateChange() { }
|
|
5871
5886
|
__drawPath(_canvas) { }
|
|
@@ -6233,7 +6248,7 @@ class LeafLevelList {
|
|
|
6233
6248
|
}
|
|
6234
6249
|
}
|
|
6235
6250
|
|
|
6236
|
-
const version = "1.
|
|
6251
|
+
const version = "1.7.0";
|
|
6237
6252
|
|
|
6238
6253
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6239
6254
|
get allowBackgroundColor() { return true; }
|
|
@@ -7150,13 +7165,9 @@ class UIData extends LeafData {
|
|
|
7150
7165
|
else
|
|
7151
7166
|
return strokeWidth;
|
|
7152
7167
|
}
|
|
7153
|
-
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7154
|
-
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
7155
7168
|
get __hasMultiPaint() {
|
|
7156
7169
|
const t = this;
|
|
7157
|
-
|
|
7158
|
-
return true;
|
|
7159
|
-
return t.fill && this.__hasStroke;
|
|
7170
|
+
return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
|
|
7160
7171
|
}
|
|
7161
7172
|
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7162
7173
|
get __hasSurface() { const t = this; return (t.fill || t.stroke); }
|
|
@@ -7447,15 +7458,18 @@ const { stintSet: stintSet$1 } = DataHelper;
|
|
|
7447
7458
|
const UIRender = {
|
|
7448
7459
|
__updateChange() {
|
|
7449
7460
|
const data = this.__;
|
|
7461
|
+
if (data.__useStroke) {
|
|
7462
|
+
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
7463
|
+
stintSet$1(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
|
|
7464
|
+
stintSet$1(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7465
|
+
}
|
|
7450
7466
|
if (data.__useEffect) {
|
|
7451
7467
|
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7452
7468
|
stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
|
|
7453
7469
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7454
7470
|
}
|
|
7455
|
-
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7456
|
-
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7457
7471
|
data.__checkSingle();
|
|
7458
|
-
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7472
|
+
stintSet$1(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
|
|
7459
7473
|
},
|
|
7460
7474
|
__drawFast(canvas, options) {
|
|
7461
7475
|
drawFast(this, canvas, options);
|
|
@@ -7513,18 +7527,15 @@ const UIRender = {
|
|
|
7513
7527
|
this.__drawFast(canvas, options);
|
|
7514
7528
|
}
|
|
7515
7529
|
},
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
this.
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
if (stroke && !ignoreStroke)
|
|
7526
|
-
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7527
|
-
}
|
|
7530
|
+
__drawShape(canvas, options) {
|
|
7531
|
+
this.__drawRenderPath(canvas);
|
|
7532
|
+
const data = this.__, { fill, stroke } = data;
|
|
7533
|
+
if (fill && !options.ignoreFill)
|
|
7534
|
+
data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7535
|
+
if (data.__isCanvas)
|
|
7536
|
+
this.__drawAfterFill(canvas, options);
|
|
7537
|
+
if (stroke && !options.ignoreStroke)
|
|
7538
|
+
data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7528
7539
|
},
|
|
7529
7540
|
__drawAfterFill(canvas, options) {
|
|
7530
7541
|
if (this.__.__clipAfterFill) {
|
|
@@ -7649,12 +7660,14 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7649
7660
|
}
|
|
7650
7661
|
}
|
|
7651
7662
|
__updateRenderPath() {
|
|
7652
|
-
|
|
7653
|
-
|
|
7663
|
+
const data = this.__;
|
|
7664
|
+
if (data.path) {
|
|
7654
7665
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
7655
7666
|
if (data.__useArrow)
|
|
7656
7667
|
PathArrow.addArrows(this, !data.cornerRadius);
|
|
7657
7668
|
}
|
|
7669
|
+
else
|
|
7670
|
+
data.__pathForRender && (data.__pathForRender = undefined);
|
|
7658
7671
|
}
|
|
7659
7672
|
__drawRenderPath(canvas) {
|
|
7660
7673
|
canvas.beginPath();
|
|
@@ -7865,13 +7878,13 @@ __decorate([
|
|
|
7865
7878
|
surfaceType()
|
|
7866
7879
|
], UI.prototype, "fill", void 0);
|
|
7867
7880
|
__decorate([
|
|
7868
|
-
strokeType()
|
|
7881
|
+
strokeType(undefined, true)
|
|
7869
7882
|
], UI.prototype, "stroke", void 0);
|
|
7870
7883
|
__decorate([
|
|
7871
7884
|
strokeType('inside')
|
|
7872
7885
|
], UI.prototype, "strokeAlign", void 0);
|
|
7873
7886
|
__decorate([
|
|
7874
|
-
strokeType(1)
|
|
7887
|
+
strokeType(1, true)
|
|
7875
7888
|
], UI.prototype, "strokeWidth", void 0);
|
|
7876
7889
|
__decorate([
|
|
7877
7890
|
strokeType(false)
|
|
@@ -8298,7 +8311,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8298
8311
|
list.push(item);
|
|
8299
8312
|
this.requestRender();
|
|
8300
8313
|
}
|
|
8301
|
-
zoom(_zoomType,
|
|
8314
|
+
zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
|
|
8302
8315
|
return Plugin.need('view');
|
|
8303
8316
|
}
|
|
8304
8317
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
@@ -8343,7 +8356,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8343
8356
|
Leafer_1.list.remove(this);
|
|
8344
8357
|
try {
|
|
8345
8358
|
this.stop();
|
|
8346
|
-
this.
|
|
8359
|
+
this.emitLeafer(LeaferEvent.END);
|
|
8347
8360
|
this.__removeListenEvents();
|
|
8348
8361
|
this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
|
|
8349
8362
|
this.__controllers.length = 0;
|
|
@@ -8471,7 +8484,7 @@ let Box = class Box extends Group {
|
|
|
8471
8484
|
}
|
|
8472
8485
|
__drawContent(canvas, options) {
|
|
8473
8486
|
this.__renderGroup(canvas, options);
|
|
8474
|
-
if (this.__.
|
|
8487
|
+
if (this.__.__useStroke) {
|
|
8475
8488
|
canvas.setWorld(this.__nowWorld);
|
|
8476
8489
|
this.__drawRenderPath(canvas);
|
|
8477
8490
|
}
|
|
@@ -8691,8 +8704,8 @@ let Polygon = class Polygon extends UI {
|
|
|
8691
8704
|
for (let i = 1; i < sides; i++) {
|
|
8692
8705
|
lineTo$1(path, rx + rx * sin$2((i * 2 * PI$2) / sides), ry - ry * cos$2((i * 2 * PI$2) / sides));
|
|
8693
8706
|
}
|
|
8707
|
+
closePath$1(path);
|
|
8694
8708
|
}
|
|
8695
|
-
closePath$1(path);
|
|
8696
8709
|
}
|
|
8697
8710
|
__updateRenderPath() { }
|
|
8698
8711
|
__updateBoxBounds() { }
|
|
@@ -8926,10 +8939,15 @@ let Text = class Text extends UI {
|
|
|
8926
8939
|
const box = this.__box;
|
|
8927
8940
|
if (box)
|
|
8928
8941
|
box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
8929
|
-
if (this.textEditing && !
|
|
8942
|
+
if (this.textEditing && !options.exporting)
|
|
8930
8943
|
return;
|
|
8931
8944
|
super.__draw(canvas, options, originCanvas);
|
|
8932
8945
|
}
|
|
8946
|
+
__drawShape(canvas, options) {
|
|
8947
|
+
if (options.shape)
|
|
8948
|
+
this.__box && this.__box.__drawShape(canvas, options);
|
|
8949
|
+
super.__drawShape(canvas, options);
|
|
8950
|
+
}
|
|
8933
8951
|
destroy() {
|
|
8934
8952
|
if (this.boxStyle)
|
|
8935
8953
|
this.boxStyle = null;
|
|
@@ -9751,6 +9769,7 @@ const config$1 = {
|
|
|
9751
9769
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9752
9770
|
},
|
|
9753
9771
|
pointer: {
|
|
9772
|
+
type: 'pointer',
|
|
9754
9773
|
snap: true,
|
|
9755
9774
|
hitRadius: 5,
|
|
9756
9775
|
tapTime: 120,
|
|
@@ -10294,7 +10313,7 @@ ui$5.__updateHitCanvas = function () {
|
|
|
10294
10313
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10295
10314
|
h.clear();
|
|
10296
10315
|
ImageManager.patternLocked = true;
|
|
10297
|
-
this.__renderShape(h, { matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y)
|
|
10316
|
+
this.__renderShape(h, { matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y), ignoreFill: !isHitPixelFill, ignoreStroke: !isHitPixelStroke });
|
|
10298
10317
|
ImageManager.patternLocked = false;
|
|
10299
10318
|
h.resetTransform();
|
|
10300
10319
|
data.__isHitPixel = true;
|
|
@@ -10698,7 +10717,7 @@ const PaintModule = {
|
|
|
10698
10717
|
};
|
|
10699
10718
|
|
|
10700
10719
|
let origin$1 = {};
|
|
10701
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
|
|
10720
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
|
|
10702
10721
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10703
10722
|
const transform = get$3();
|
|
10704
10723
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -10707,13 +10726,15 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
10707
10726
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
10708
10727
|
data.transform = transform;
|
|
10709
10728
|
}
|
|
10710
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10729
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
10711
10730
|
const transform = get$3();
|
|
10712
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
10713
|
-
if (scaleX)
|
|
10714
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
10715
10731
|
if (rotation)
|
|
10716
10732
|
rotate$2(transform, rotation);
|
|
10733
|
+
if (skew)
|
|
10734
|
+
skewHelper(transform, skew.x, skew.y);
|
|
10735
|
+
if (scaleX)
|
|
10736
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10737
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
10717
10738
|
data.transform = transform;
|
|
10718
10739
|
}
|
|
10719
10740
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -10750,11 +10771,13 @@ const tempBox = new Bounds();
|
|
|
10750
10771
|
const tempScaleData = {};
|
|
10751
10772
|
const tempImage = {};
|
|
10752
10773
|
function createData(leafPaint, image, paint, box) {
|
|
10753
|
-
const { changeful, sync } = paint;
|
|
10774
|
+
const { changeful, sync, editing } = paint;
|
|
10754
10775
|
if (changeful)
|
|
10755
10776
|
leafPaint.changeful = changeful;
|
|
10756
10777
|
if (sync)
|
|
10757
10778
|
leafPaint.sync = sync;
|
|
10779
|
+
if (editing)
|
|
10780
|
+
leafPaint.editing = editing;
|
|
10758
10781
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10759
10782
|
}
|
|
10760
10783
|
function getPatternData(paint, box, image) {
|
|
@@ -10763,7 +10786,7 @@ function getPatternData(paint, box, image) {
|
|
|
10763
10786
|
if (paint.mode === 'strench')
|
|
10764
10787
|
paint.mode = 'stretch';
|
|
10765
10788
|
let { width, height } = image;
|
|
10766
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
10789
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
10767
10790
|
const sameBox = box.width === width && box.height === height;
|
|
10768
10791
|
const data = { mode };
|
|
10769
10792
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -10797,8 +10820,8 @@ function getPatternData(paint, box, image) {
|
|
|
10797
10820
|
break;
|
|
10798
10821
|
case 'normal':
|
|
10799
10822
|
case 'clip':
|
|
10800
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
10801
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10823
|
+
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
10824
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
10802
10825
|
break;
|
|
10803
10826
|
case 'repeat':
|
|
10804
10827
|
if (!sameBox || scaleX || rotation)
|
|
@@ -10875,11 +10898,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
10875
10898
|
}
|
|
10876
10899
|
onLoadSuccess(ui, event);
|
|
10877
10900
|
}
|
|
10878
|
-
leafPaint.loadId =
|
|
10901
|
+
leafPaint.loadId = undefined;
|
|
10879
10902
|
}, (error) => {
|
|
10880
10903
|
ignoreRender(ui, false);
|
|
10881
10904
|
onLoadError(ui, event, error);
|
|
10882
|
-
leafPaint.loadId =
|
|
10905
|
+
leafPaint.loadId = undefined;
|
|
10883
10906
|
});
|
|
10884
10907
|
if (ui.placeholderColor) {
|
|
10885
10908
|
if (!ui.placeholderDelay)
|
|
@@ -10945,6 +10968,8 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
10945
10968
|
const { image, data } = paint;
|
|
10946
10969
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
10947
10970
|
if (sx) {
|
|
10971
|
+
sx = abs$4(sx);
|
|
10972
|
+
sy = abs$4(sy);
|
|
10948
10973
|
imageMatrix = get$1();
|
|
10949
10974
|
copy$4(imageMatrix, transform);
|
|
10950
10975
|
scale$2(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -11938,41 +11963,10 @@ class EditorEvent extends Event {
|
|
|
11938
11963
|
}
|
|
11939
11964
|
EditorEvent.BEFORE_SELECT = 'editor.before_select';
|
|
11940
11965
|
EditorEvent.SELECT = 'editor.select';
|
|
11966
|
+
EditorEvent.AFTER_SELECT = 'editor.after_select';
|
|
11941
11967
|
EditorEvent.BEFORE_HOVER = 'editor.before_hover';
|
|
11942
11968
|
EditorEvent.HOVER = 'editor.hover';
|
|
11943
11969
|
|
|
11944
|
-
class EditorMoveEvent extends EditorEvent {
|
|
11945
|
-
constructor(type, data) {
|
|
11946
|
-
super(type, data);
|
|
11947
|
-
}
|
|
11948
|
-
}
|
|
11949
|
-
EditorMoveEvent.BEFORE_MOVE = 'editor.before_move';
|
|
11950
|
-
EditorMoveEvent.MOVE = 'editor.move';
|
|
11951
|
-
|
|
11952
|
-
class EditorScaleEvent extends EditorEvent {
|
|
11953
|
-
constructor(type, data) {
|
|
11954
|
-
super(type, data);
|
|
11955
|
-
}
|
|
11956
|
-
}
|
|
11957
|
-
EditorScaleEvent.BEFORE_SCALE = 'editor.before_scale';
|
|
11958
|
-
EditorScaleEvent.SCALE = 'editor.scale';
|
|
11959
|
-
|
|
11960
|
-
class EditorRotateEvent extends EditorEvent {
|
|
11961
|
-
constructor(type, data) {
|
|
11962
|
-
super(type, data);
|
|
11963
|
-
}
|
|
11964
|
-
}
|
|
11965
|
-
EditorRotateEvent.BEFORE_ROTATE = 'editor.before_rotate';
|
|
11966
|
-
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
11967
|
-
|
|
11968
|
-
class EditorSkewEvent extends EditorEvent {
|
|
11969
|
-
constructor(type, data) {
|
|
11970
|
-
super(type, data);
|
|
11971
|
-
}
|
|
11972
|
-
}
|
|
11973
|
-
EditorSkewEvent.BEFORE_SKEW = 'editor.before_skew';
|
|
11974
|
-
EditorSkewEvent.SKEW = 'editor.skew';
|
|
11975
|
-
|
|
11976
11970
|
function targetAttr(fn) {
|
|
11977
11971
|
return (target, key) => {
|
|
11978
11972
|
const privateKey = '_' + key;
|
|
@@ -12383,16 +12377,16 @@ const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bo
|
|
|
12383
12377
|
const { toPoint } = AroundHelper;
|
|
12384
12378
|
const { within: within$2 } = MathHelper;
|
|
12385
12379
|
const EditDataHelper = {
|
|
12386
|
-
getScaleData(
|
|
12380
|
+
getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
|
|
12387
12381
|
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
12388
|
-
const { boxBounds, widthRange, heightRange, dragBounds, worldBoxBounds } =
|
|
12382
|
+
const { boxBounds, widthRange, heightRange, dragBounds, worldBoxBounds } = target;
|
|
12389
12383
|
const { width, height } = startBounds;
|
|
12390
12384
|
if (around) {
|
|
12391
12385
|
totalMove.x *= 2;
|
|
12392
12386
|
totalMove.y *= 2;
|
|
12393
12387
|
}
|
|
12394
|
-
const originChangedScaleX =
|
|
12395
|
-
const originChangedScaleY =
|
|
12388
|
+
const originChangedScaleX = target.scaleX / startBounds.scaleX;
|
|
12389
|
+
const originChangedScaleY = target.scaleY / startBounds.scaleY;
|
|
12396
12390
|
const signX = originChangedScaleX < 0 ? -1 : 1;
|
|
12397
12391
|
const signY = originChangedScaleY < 0 ? -1 : 1;
|
|
12398
12392
|
const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
|
|
@@ -12468,7 +12462,7 @@ const EditDataHelper = {
|
|
|
12468
12462
|
if (useScaleY)
|
|
12469
12463
|
scaleY /= changedScaleY;
|
|
12470
12464
|
if (!flipable) {
|
|
12471
|
-
const { worldTransform } =
|
|
12465
|
+
const { worldTransform } = target;
|
|
12472
12466
|
if (scaleX < 0)
|
|
12473
12467
|
scaleX = 1 / boxBounds.width / worldTransform.scaleX;
|
|
12474
12468
|
if (scaleY < 0)
|
|
@@ -12476,9 +12470,9 @@ const EditDataHelper = {
|
|
|
12476
12470
|
}
|
|
12477
12471
|
toPoint(around || align, boxBounds, origin, true);
|
|
12478
12472
|
if (dragBounds) {
|
|
12479
|
-
const allowBounds = dragBounds === 'parent' ?
|
|
12480
|
-
const localBounds = new Bounds(
|
|
12481
|
-
localBounds.scaleOf(
|
|
12473
|
+
const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds;
|
|
12474
|
+
const localBounds = new Bounds(target.__localBoxBounds);
|
|
12475
|
+
localBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
|
|
12482
12476
|
if (!BoundsHelper.includes(allowBounds, localBounds)) {
|
|
12483
12477
|
const realBounds = localBounds.getIntersect(allowBounds);
|
|
12484
12478
|
const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
|
|
@@ -12489,11 +12483,11 @@ const EditDataHelper = {
|
|
|
12489
12483
|
}
|
|
12490
12484
|
}
|
|
12491
12485
|
if (useScaleX && widthRange) {
|
|
12492
|
-
const nowWidth = boxBounds.width *
|
|
12486
|
+
const nowWidth = boxBounds.width * target.scaleX;
|
|
12493
12487
|
scaleX = within$2(nowWidth * scaleX, widthRange) / nowWidth;
|
|
12494
12488
|
}
|
|
12495
12489
|
if (useScaleY && heightRange) {
|
|
12496
|
-
const nowHeight = boxBounds.height *
|
|
12490
|
+
const nowHeight = boxBounds.height * target.scaleY;
|
|
12497
12491
|
scaleY = within$2(nowHeight * scaleY, heightRange) / nowHeight;
|
|
12498
12492
|
}
|
|
12499
12493
|
if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
@@ -12504,7 +12498,7 @@ const EditDataHelper = {
|
|
|
12504
12498
|
scaleY = scaleX = Math.min(scaleX, scaleY);
|
|
12505
12499
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
12506
12500
|
},
|
|
12507
|
-
getRotateData(
|
|
12501
|
+
getRotateData(target, direction, current, last, around) {
|
|
12508
12502
|
let align, origin = {};
|
|
12509
12503
|
switch (direction) {
|
|
12510
12504
|
case topLeft$1:
|
|
@@ -12522,8 +12516,8 @@ const EditDataHelper = {
|
|
|
12522
12516
|
default:
|
|
12523
12517
|
align = 'center';
|
|
12524
12518
|
}
|
|
12525
|
-
toPoint(around || align,
|
|
12526
|
-
return { origin, rotation: PointHelper.getRotation(last, origin, current) };
|
|
12519
|
+
toPoint(around || align, target.boxBounds, origin, true);
|
|
12520
|
+
return { origin, rotation: PointHelper.getRotation(last, target.getWorldPointByBox(origin), current) };
|
|
12527
12521
|
},
|
|
12528
12522
|
getSkewData(bounds, direction, move, around) {
|
|
12529
12523
|
let align, origin = {}, skewX = 0, skewY = 0;
|
|
@@ -12620,9 +12614,9 @@ const EditDataHelper = {
|
|
|
12620
12614
|
};
|
|
12621
12615
|
|
|
12622
12616
|
const cacheCursors = {};
|
|
12623
|
-
function updateCursor(
|
|
12624
|
-
const {
|
|
12625
|
-
if (!point || !editor.editing || !editBox.visible)
|
|
12617
|
+
function updateCursor(editBox, e) {
|
|
12618
|
+
const { enterPoint: point } = editBox;
|
|
12619
|
+
if (!point || !editBox.editor.editing || !editBox.visible)
|
|
12626
12620
|
return;
|
|
12627
12621
|
if (point.name === 'circle')
|
|
12628
12622
|
return;
|
|
@@ -12631,9 +12625,8 @@ function updateCursor(editor, e) {
|
|
|
12631
12625
|
point.cursor = 'pointer';
|
|
12632
12626
|
return;
|
|
12633
12627
|
}
|
|
12634
|
-
let { rotation } = editBox;
|
|
12635
|
-
const { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } =
|
|
12636
|
-
const { pointType } = point, { flippedX, flippedY } = editBox;
|
|
12628
|
+
let { rotation, flippedX, flippedY } = editBox;
|
|
12629
|
+
const { pointType } = point, { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editBox.mergeConfig;
|
|
12637
12630
|
let showResize = pointType.includes('resize');
|
|
12638
12631
|
if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
|
|
12639
12632
|
showResize = false;
|
|
@@ -12650,9 +12643,9 @@ function updateCursor(editor, e) {
|
|
|
12650
12643
|
cacheCursors[key] = point.cursor = { url: toDataURL(url, rotation), x, y };
|
|
12651
12644
|
}
|
|
12652
12645
|
}
|
|
12653
|
-
function updateMoveCursor(
|
|
12654
|
-
const { moveCursor, moveable } =
|
|
12655
|
-
|
|
12646
|
+
function updateMoveCursor(editBox) {
|
|
12647
|
+
const { moveCursor, moveable } = editBox.mergeConfig;
|
|
12648
|
+
editBox.rect.cursor = moveable ? moveCursor : undefined;
|
|
12656
12649
|
}
|
|
12657
12650
|
function toDataURL(svg, rotation) {
|
|
12658
12651
|
return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
|
|
@@ -12667,6 +12660,15 @@ class EditPoint extends Box {
|
|
|
12667
12660
|
|
|
12668
12661
|
const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
|
|
12669
12662
|
class EditBox extends Group {
|
|
12663
|
+
get mergeConfig() {
|
|
12664
|
+
const { config } = this, { mergeConfig } = this.editor;
|
|
12665
|
+
return this.mergedConfig = config ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
|
|
12666
|
+
}
|
|
12667
|
+
get target() { return this._target || this.editor.element; }
|
|
12668
|
+
set target(target) { this._target = target; }
|
|
12669
|
+
get single() { return !!this._target || this.editor.single; }
|
|
12670
|
+
get transformTool() { return this._transformTool || this.editor; }
|
|
12671
|
+
set transformTool(tool) { this._transformTool = tool; }
|
|
12670
12672
|
get flipped() { return this.flippedX || this.flippedY; }
|
|
12671
12673
|
get flippedX() { return this.scaleX < 0; }
|
|
12672
12674
|
get flippedY() { return this.scaleY < 0; }
|
|
@@ -12709,8 +12711,7 @@ class EditBox extends Group {
|
|
|
12709
12711
|
this.add(view);
|
|
12710
12712
|
}
|
|
12711
12713
|
load() {
|
|
12712
|
-
const {
|
|
12713
|
-
const { rect, circle, resizePoints } = this;
|
|
12714
|
+
const { target, mergeConfig, single, rect, circle, resizePoints } = this;
|
|
12714
12715
|
const { stroke, strokeWidth } = mergeConfig;
|
|
12715
12716
|
const pointsStyle = this.getPointsStyle();
|
|
12716
12717
|
const middlePointsStyle = this.getMiddlePointsStyle();
|
|
@@ -12723,18 +12724,26 @@ class EditBox extends Group {
|
|
|
12723
12724
|
}
|
|
12724
12725
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
12725
12726
|
rect.set(Object.assign({ stroke, strokeWidth, editConfig }, (mergeConfig.rect || {})));
|
|
12726
|
-
|
|
12727
|
-
rect.
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12727
|
+
const syncEventer = single && this.transformTool.editTool;
|
|
12728
|
+
rect.hittable = !syncEventer;
|
|
12729
|
+
rect.syncEventer = syncEventer && this.editor;
|
|
12730
|
+
if (syncEventer) {
|
|
12731
|
+
target.syncEventer = rect;
|
|
12732
|
+
this.app.interaction.bottomList = [{ target: rect, proxy: target }];
|
|
12731
12733
|
}
|
|
12734
|
+
updateMoveCursor(this);
|
|
12735
|
+
}
|
|
12736
|
+
update() {
|
|
12737
|
+
const { editor } = this;
|
|
12738
|
+
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = this.target.getLayoutBounds('box', editor, true);
|
|
12739
|
+
this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
12740
|
+
this.updateBounds({ x: 0, y: 0, width, height });
|
|
12732
12741
|
}
|
|
12733
|
-
|
|
12734
|
-
const {
|
|
12735
|
-
const { mergeConfig,
|
|
12742
|
+
updateBounds(bounds) {
|
|
12743
|
+
const { editMask } = this.editor;
|
|
12744
|
+
const { mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
|
|
12736
12745
|
const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
|
|
12737
|
-
this.visible = !
|
|
12746
|
+
this.visible = !this.target.locked;
|
|
12738
12747
|
editMask.visible = mask ? true : 0;
|
|
12739
12748
|
if (this.view.worldOpacity) {
|
|
12740
12749
|
const { width, height } = bounds;
|
|
@@ -12768,25 +12777,25 @@ class EditBox extends Group {
|
|
|
12768
12777
|
}
|
|
12769
12778
|
circle.visible = showPoints && rotateable && !!(mergeConfig.circle || mergeConfig.rotatePoint);
|
|
12770
12779
|
if (circle.visible)
|
|
12771
|
-
this.layoutCircle(
|
|
12780
|
+
this.layoutCircle();
|
|
12772
12781
|
if (rect.path)
|
|
12773
12782
|
rect.path = null;
|
|
12774
|
-
rect.set(Object.assign(Object.assign({}, bounds), { visible:
|
|
12783
|
+
rect.set(Object.assign(Object.assign({}, bounds), { visible: single ? editBox : true }));
|
|
12775
12784
|
buttons.visible = showPoints && buttons.children.length > 0 || 0;
|
|
12776
12785
|
if (buttons.visible)
|
|
12777
|
-
this.layoutButtons(
|
|
12786
|
+
this.layoutButtons();
|
|
12778
12787
|
}
|
|
12779
12788
|
else
|
|
12780
12789
|
rect.set(bounds);
|
|
12781
12790
|
}
|
|
12782
|
-
layoutCircle(
|
|
12783
|
-
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } =
|
|
12791
|
+
layoutCircle() {
|
|
12792
|
+
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } = this.mergedConfig;
|
|
12784
12793
|
const direction = fourDirection.indexOf(circleDirection || ((this.buttons.children.length && buttonsDirection === 'bottom') ? 'top' : 'bottom'));
|
|
12785
12794
|
this.setButtonPosition(this.circle, direction, circleMargin || buttonsMargin, !!middlePoint);
|
|
12786
12795
|
}
|
|
12787
|
-
layoutButtons(
|
|
12796
|
+
layoutButtons() {
|
|
12788
12797
|
const { buttons } = this;
|
|
12789
|
-
const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } =
|
|
12798
|
+
const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } = this.mergedConfig;
|
|
12790
12799
|
const { flippedX, flippedY } = this;
|
|
12791
12800
|
let index = fourDirection.indexOf(buttonsDirection);
|
|
12792
12801
|
if ((index % 2 && flippedX) || ((index + 1) % 2 && flippedY)) {
|
|
@@ -12819,16 +12828,16 @@ class EditBox extends Group {
|
|
|
12819
12828
|
this.visible = false;
|
|
12820
12829
|
}
|
|
12821
12830
|
getPointStyle(userStyle) {
|
|
12822
|
-
const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.
|
|
12831
|
+
const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.mergedConfig;
|
|
12823
12832
|
const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0, editConfig };
|
|
12824
12833
|
return userStyle ? Object.assign(defaultStyle, userStyle) : defaultStyle;
|
|
12825
12834
|
}
|
|
12826
12835
|
getPointsStyle() {
|
|
12827
|
-
const { point } = this.
|
|
12836
|
+
const { point } = this.mergedConfig;
|
|
12828
12837
|
return point instanceof Array ? point : [point];
|
|
12829
12838
|
}
|
|
12830
12839
|
getMiddlePointsStyle() {
|
|
12831
|
-
const { middlePoint } = this.
|
|
12840
|
+
const { middlePoint } = this.mergedConfig;
|
|
12832
12841
|
return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
|
|
12833
12842
|
}
|
|
12834
12843
|
onSelect(e) {
|
|
@@ -12841,16 +12850,16 @@ class EditBox extends Group {
|
|
|
12841
12850
|
onDragStart(e) {
|
|
12842
12851
|
this.dragging = true;
|
|
12843
12852
|
const point = this.dragPoint = e.current, { pointType } = point;
|
|
12844
|
-
const { editor, dragStartData } = this, {
|
|
12853
|
+
const { editor, dragStartData } = this, { target } = this;
|
|
12845
12854
|
if (point.name === 'rect') {
|
|
12846
12855
|
this.moving = true;
|
|
12847
|
-
editor.opacity =
|
|
12856
|
+
editor.opacity = this.mergeConfig.hideOnMove ? 0 : 1;
|
|
12848
12857
|
}
|
|
12849
12858
|
dragStartData.x = e.x;
|
|
12850
12859
|
dragStartData.y = e.y;
|
|
12851
|
-
dragStartData.point = { x:
|
|
12852
|
-
dragStartData.bounds = Object.assign({},
|
|
12853
|
-
dragStartData.rotation =
|
|
12860
|
+
dragStartData.point = { x: target.x, y: target.y };
|
|
12861
|
+
dragStartData.bounds = Object.assign({}, target.getLayoutBounds('box', 'local'));
|
|
12862
|
+
dragStartData.rotation = target.rotation;
|
|
12854
12863
|
if (pointType && pointType.includes('resize'))
|
|
12855
12864
|
ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
12856
12865
|
}
|
|
@@ -12865,22 +12874,31 @@ class EditBox extends Group {
|
|
|
12865
12874
|
ResizeEvent.resizingKeys = null;
|
|
12866
12875
|
}
|
|
12867
12876
|
onDrag(e) {
|
|
12868
|
-
const {
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12877
|
+
const { transformTool } = this, point = e.current;
|
|
12878
|
+
if (point.name === 'rect') {
|
|
12879
|
+
transformTool.onMove(e);
|
|
12880
|
+
updateMoveCursor(this);
|
|
12881
|
+
}
|
|
12882
|
+
else {
|
|
12883
|
+
const { pointType } = this.enterPoint = point;
|
|
12884
|
+
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !this.mergeConfig.resizeable) {
|
|
12885
|
+
transformTool.onRotate(e);
|
|
12886
|
+
if (pointType === 'resize-rotate')
|
|
12887
|
+
transformTool.onScale(e);
|
|
12888
|
+
}
|
|
12889
|
+
else if (pointType === 'resize')
|
|
12890
|
+
transformTool.onScale(e);
|
|
12891
|
+
if (pointType === 'skew')
|
|
12892
|
+
transformTool.onSkew(e);
|
|
12893
|
+
updateCursor(this, e);
|
|
12894
|
+
}
|
|
12895
|
+
}
|
|
12896
|
+
onKey(e) {
|
|
12897
|
+
updateCursor(this, e);
|
|
12880
12898
|
}
|
|
12881
12899
|
onArrow(e) {
|
|
12882
12900
|
const { editor } = this;
|
|
12883
|
-
if (editor.editing &&
|
|
12901
|
+
if (editor.editing && this.mergeConfig.keyEvent) {
|
|
12884
12902
|
let x = 0, y = 0;
|
|
12885
12903
|
const distance = e.shiftKey ? 10 : 1;
|
|
12886
12904
|
switch (e.code) {
|
|
@@ -12901,27 +12919,28 @@ class EditBox extends Group {
|
|
|
12901
12919
|
}
|
|
12902
12920
|
}
|
|
12903
12921
|
onDoubleTap(e) {
|
|
12904
|
-
|
|
12922
|
+
const { openInner, preventEditInner } = this.mergeConfig;
|
|
12923
|
+
if (openInner === 'double' && !preventEditInner)
|
|
12905
12924
|
this.openInner(e);
|
|
12906
12925
|
}
|
|
12907
12926
|
onLongPress(e) {
|
|
12908
|
-
|
|
12927
|
+
const { openInner, preventEditInner } = this.mergeConfig;
|
|
12928
|
+
if (openInner === 'long' && preventEditInner)
|
|
12909
12929
|
this.openInner(e);
|
|
12910
12930
|
}
|
|
12911
12931
|
openInner(e) {
|
|
12912
|
-
const { editor } = this;
|
|
12913
|
-
if (
|
|
12914
|
-
|
|
12915
|
-
if (element.locked)
|
|
12932
|
+
const { editor, target } = this;
|
|
12933
|
+
if (this.single) {
|
|
12934
|
+
if (target.locked)
|
|
12916
12935
|
return;
|
|
12917
|
-
if (
|
|
12918
|
-
if (
|
|
12919
|
-
const { children } =
|
|
12936
|
+
if (target.isBranch && !target.editInner) {
|
|
12937
|
+
if (target.textBox) {
|
|
12938
|
+
const { children } = target;
|
|
12920
12939
|
const find = children.find(item => item.editable && item instanceof Text) || children.find(item => item instanceof Text);
|
|
12921
12940
|
if (find)
|
|
12922
12941
|
return editor.openInnerEditor(find);
|
|
12923
12942
|
}
|
|
12924
|
-
editor.openGroup(
|
|
12943
|
+
editor.openGroup(target);
|
|
12925
12944
|
editor.target = editor.selector.findDeepOne(e);
|
|
12926
12945
|
}
|
|
12927
12946
|
else {
|
|
@@ -12930,7 +12949,6 @@ class EditBox extends Group {
|
|
|
12930
12949
|
}
|
|
12931
12950
|
}
|
|
12932
12951
|
listenPointEvents(point, type, direction) {
|
|
12933
|
-
const { editor } = this;
|
|
12934
12952
|
point.direction = direction;
|
|
12935
12953
|
point.pointType = type;
|
|
12936
12954
|
const events = [
|
|
@@ -12940,19 +12958,25 @@ class EditBox extends Group {
|
|
|
12940
12958
|
[PointerEvent.LEAVE, () => { this.enterPoint = null; }],
|
|
12941
12959
|
];
|
|
12942
12960
|
if (point.name !== 'circle')
|
|
12943
|
-
events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(
|
|
12961
|
+
events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(this, e); }]);
|
|
12944
12962
|
this.__eventIds.push(point.on_(events));
|
|
12945
12963
|
}
|
|
12946
12964
|
__listenEvents() {
|
|
12947
|
-
const { rect, editor } = this;
|
|
12948
|
-
|
|
12965
|
+
const { rect, editor, __eventIds: events } = this;
|
|
12966
|
+
events.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
|
|
12949
12967
|
[DragEvent.START, this.onDragStart, this],
|
|
12950
|
-
[DragEvent.DRAG,
|
|
12968
|
+
[DragEvent.DRAG, this.onDrag, this],
|
|
12951
12969
|
[DragEvent.END, this.onDragEnd, this],
|
|
12952
|
-
[PointerEvent.ENTER, () => updateMoveCursor(
|
|
12970
|
+
[PointerEvent.ENTER, () => updateMoveCursor(this)],
|
|
12953
12971
|
[PointerEvent.DOUBLE_TAP, this.onDoubleTap, this],
|
|
12954
12972
|
[PointerEvent.LONG_PRESS, this.onLongPress, this]
|
|
12955
12973
|
]));
|
|
12974
|
+
this.waitLeafer(() => {
|
|
12975
|
+
events.push(editor.app.on_([
|
|
12976
|
+
[[KeyEvent.HOLD, KeyEvent.UP], this.onKey, this],
|
|
12977
|
+
[KeyEvent.DOWN, this.onArrow, this]
|
|
12978
|
+
]));
|
|
12979
|
+
});
|
|
12956
12980
|
}
|
|
12957
12981
|
__removeListenEvents() {
|
|
12958
12982
|
this.off_(this.__eventIds);
|
|
@@ -12983,11 +13007,12 @@ class EditMask extends UI {
|
|
|
12983
13007
|
if (options.bounds && !options.bounds.hit(editor.editBox.rect.__world, options.matrix))
|
|
12984
13008
|
return;
|
|
12985
13009
|
canvas.saveBlendMode('destination-out');
|
|
13010
|
+
options = Object.assign(Object.assign({}, options), { shape: true });
|
|
12986
13011
|
editor.list.forEach(item => {
|
|
12987
|
-
item.
|
|
12988
|
-
const {
|
|
12989
|
-
if (
|
|
12990
|
-
|
|
13012
|
+
item.__render(canvas, options);
|
|
13013
|
+
const { parent } = item;
|
|
13014
|
+
if (parent && parent.textBox)
|
|
13015
|
+
parent.__renderShape(canvas, options);
|
|
12991
13016
|
});
|
|
12992
13017
|
canvas.restoreBlendMode();
|
|
12993
13018
|
}
|
|
@@ -13082,7 +13107,7 @@ const config = {
|
|
|
13082
13107
|
const bounds$1 = new Bounds();
|
|
13083
13108
|
function simulate(editor) {
|
|
13084
13109
|
const { simulateTarget, list } = editor;
|
|
13085
|
-
const { zoomLayer } = list[0].leafer
|
|
13110
|
+
const { zoomLayer } = list[0].leafer;
|
|
13086
13111
|
simulateTarget.safeChange(() => {
|
|
13087
13112
|
bounds$1.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page'));
|
|
13088
13113
|
if (bounds$1.width === 0)
|
|
@@ -13104,15 +13129,14 @@ function onTarget(editor, oldValue) {
|
|
|
13104
13129
|
else {
|
|
13105
13130
|
editor.simulateTarget.remove();
|
|
13106
13131
|
editor.leafList.reset();
|
|
13107
|
-
editor.closeInnerEditor();
|
|
13108
13132
|
}
|
|
13109
|
-
editor.
|
|
13133
|
+
editor.closeInnerEditor();
|
|
13134
|
+
const data = { editor, value: target, oldValue };
|
|
13135
|
+
editor.emitEvent(new EditorEvent(EditorEvent.SELECT, data));
|
|
13110
13136
|
editor.checkOpenedGroups();
|
|
13111
13137
|
if (editor.editing) {
|
|
13112
13138
|
editor.waitLeafer(() => {
|
|
13113
|
-
updateMoveCursor(editor);
|
|
13114
13139
|
editor.updateEditTool();
|
|
13115
|
-
editor.update();
|
|
13116
13140
|
editor.listenTargetEvents();
|
|
13117
13141
|
});
|
|
13118
13142
|
}
|
|
@@ -13120,6 +13144,7 @@ function onTarget(editor, oldValue) {
|
|
|
13120
13144
|
editor.updateEditTool();
|
|
13121
13145
|
editor.removeTargetEvents();
|
|
13122
13146
|
}
|
|
13147
|
+
editor.emitEvent(new EditorEvent(EditorEvent.AFTER_SELECT, data));
|
|
13123
13148
|
}
|
|
13124
13149
|
function onHover(editor, oldValue) {
|
|
13125
13150
|
editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
|
|
@@ -13291,93 +13316,45 @@ class SimulateElement extends Rect {
|
|
|
13291
13316
|
}
|
|
13292
13317
|
}
|
|
13293
13318
|
|
|
13294
|
-
class
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
get editing() { return !!this.list.length; }
|
|
13298
|
-
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13299
|
-
get multiple() { return this.list.length > 1; }
|
|
13300
|
-
get single() { return this.list.length === 1; }
|
|
13301
|
-
get dragging() { return this.editBox.dragging; }
|
|
13302
|
-
get moving() { return this.editBox.moving; }
|
|
13303
|
-
get dragPoint() { return this.editBox.dragPoint; }
|
|
13304
|
-
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13305
|
-
get buttons() { return this.editBox.buttons; }
|
|
13306
|
-
constructor(userConfig, data) {
|
|
13307
|
-
super(data);
|
|
13308
|
-
this.leafList = new LeafList();
|
|
13309
|
-
this.openedGroupList = new LeafList();
|
|
13310
|
-
this.simulateTarget = new SimulateElement(this);
|
|
13311
|
-
this.editBox = new EditBox(this);
|
|
13312
|
-
this.editToolList = {};
|
|
13313
|
-
this.selector = new EditSelect(this);
|
|
13314
|
-
this.editMask = new EditMask(this);
|
|
13315
|
-
this.targetEventIds = [];
|
|
13316
|
-
let mergedConfig = DataHelper.clone(config);
|
|
13317
|
-
if (userConfig)
|
|
13318
|
-
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
13319
|
-
this.mergedConfig = this.config = mergedConfig;
|
|
13320
|
-
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13321
|
-
if (!Plugin.has('resize'))
|
|
13322
|
-
this.config.editSize = 'scale';
|
|
13323
|
-
}
|
|
13324
|
-
select(target) {
|
|
13325
|
-
this.target = target;
|
|
13326
|
-
}
|
|
13327
|
-
cancel() {
|
|
13328
|
-
this.target = null;
|
|
13329
|
-
}
|
|
13330
|
-
hasItem(item) {
|
|
13331
|
-
return this.leafList.has(item);
|
|
13332
|
-
}
|
|
13333
|
-
addItem(item) {
|
|
13334
|
-
if (!this.hasItem(item) && !item.locked)
|
|
13335
|
-
this.leafList.add(item), this.target = this.leafList.list;
|
|
13336
|
-
}
|
|
13337
|
-
removeItem(item) {
|
|
13338
|
-
if (this.hasItem(item))
|
|
13339
|
-
this.leafList.remove(item), this.target = this.leafList.list;
|
|
13340
|
-
}
|
|
13341
|
-
shiftItem(item) {
|
|
13342
|
-
this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
|
|
13343
|
-
}
|
|
13344
|
-
update() {
|
|
13345
|
-
if (this.editing) {
|
|
13346
|
-
if (!this.element.parent)
|
|
13347
|
-
return this.cancel();
|
|
13348
|
-
if (this.innerEditing)
|
|
13349
|
-
this.innerEditor.update();
|
|
13350
|
-
this.editTool.update();
|
|
13351
|
-
this.selector.update();
|
|
13352
|
-
}
|
|
13319
|
+
class EditorMoveEvent extends EditorEvent {
|
|
13320
|
+
constructor(type, data) {
|
|
13321
|
+
super(type, data);
|
|
13353
13322
|
}
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13323
|
+
}
|
|
13324
|
+
EditorMoveEvent.BEFORE_MOVE = 'editor.before_move';
|
|
13325
|
+
EditorMoveEvent.MOVE = 'editor.move';
|
|
13326
|
+
|
|
13327
|
+
class EditorScaleEvent extends EditorEvent {
|
|
13328
|
+
constructor(type, data) {
|
|
13329
|
+
super(type, data);
|
|
13358
13330
|
}
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
if (this.editing) {
|
|
13367
|
-
const tag = this.single ? this.list[0].editOuter : 'EditTool';
|
|
13368
|
-
this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
|
|
13369
|
-
this.editBox.load();
|
|
13370
|
-
this.editTool.load();
|
|
13371
|
-
}
|
|
13331
|
+
}
|
|
13332
|
+
EditorScaleEvent.BEFORE_SCALE = 'editor.before_scale';
|
|
13333
|
+
EditorScaleEvent.SCALE = 'editor.scale';
|
|
13334
|
+
|
|
13335
|
+
class EditorRotateEvent extends EditorEvent {
|
|
13336
|
+
constructor(type, data) {
|
|
13337
|
+
super(type, data);
|
|
13372
13338
|
}
|
|
13373
|
-
|
|
13374
|
-
|
|
13339
|
+
}
|
|
13340
|
+
EditorRotateEvent.BEFORE_ROTATE = 'editor.before_rotate';
|
|
13341
|
+
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
13342
|
+
|
|
13343
|
+
class EditorSkewEvent extends EditorEvent {
|
|
13344
|
+
constructor(type, data) {
|
|
13345
|
+
super(type, data);
|
|
13375
13346
|
}
|
|
13347
|
+
}
|
|
13348
|
+
EditorSkewEvent.BEFORE_SKEW = 'editor.before_skew';
|
|
13349
|
+
EditorSkewEvent.SKEW = 'editor.skew';
|
|
13350
|
+
|
|
13351
|
+
class TransformTool {
|
|
13376
13352
|
onMove(e) {
|
|
13353
|
+
const { target, mergeConfig, dragStartData } = this.editBox;
|
|
13377
13354
|
if (e instanceof MoveEvent) {
|
|
13378
13355
|
if (e.moveType !== 'drag') {
|
|
13379
|
-
const { moveable, resizeable } =
|
|
13380
|
-
const move = e.getLocalMove(
|
|
13356
|
+
const { moveable, resizeable } = mergeConfig;
|
|
13357
|
+
const move = e.getLocalMove(target);
|
|
13381
13358
|
if (moveable === 'move')
|
|
13382
13359
|
e.stop(), this.move(move.x, move.y);
|
|
13383
13360
|
else if (resizeable === 'zoom')
|
|
@@ -13392,22 +13369,22 @@ class Editor extends Group {
|
|
|
13392
13369
|
else
|
|
13393
13370
|
total.x = 0;
|
|
13394
13371
|
}
|
|
13395
|
-
this.move(DragEvent.getValidMove(
|
|
13372
|
+
this.move(DragEvent.getValidMove(target, dragStartData.point, total));
|
|
13396
13373
|
}
|
|
13397
13374
|
}
|
|
13398
13375
|
onScale(e) {
|
|
13399
|
-
const {
|
|
13400
|
-
let { around, lockRatio, resizeable, flipable, editSize } =
|
|
13376
|
+
const { target, mergeConfig, single, dragStartData } = this.editBox;
|
|
13377
|
+
let { around, lockRatio, resizeable, flipable, editSize } = mergeConfig;
|
|
13401
13378
|
if (e instanceof ZoomEvent) {
|
|
13402
13379
|
if (resizeable === 'zoom')
|
|
13403
|
-
e.stop(), this.scaleOf(
|
|
13380
|
+
e.stop(), this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
|
|
13404
13381
|
}
|
|
13405
13382
|
else {
|
|
13406
13383
|
const { direction } = e.current;
|
|
13407
|
-
if (e.shiftKey ||
|
|
13384
|
+
if (e.shiftKey || target.lockRatio)
|
|
13408
13385
|
lockRatio = true;
|
|
13409
|
-
const data = EditDataHelper.getScaleData(
|
|
13410
|
-
if (this.editTool.onScaleWithDrag) {
|
|
13386
|
+
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, e.getInnerTotal(target), lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === 'scale');
|
|
13387
|
+
if (this.editTool && this.editTool.onScaleWithDrag) {
|
|
13411
13388
|
data.drag = e;
|
|
13412
13389
|
this.scaleWithDrag(data);
|
|
13413
13390
|
}
|
|
@@ -13417,38 +13394,38 @@ class Editor extends Group {
|
|
|
13417
13394
|
}
|
|
13418
13395
|
}
|
|
13419
13396
|
onRotate(e) {
|
|
13420
|
-
const {
|
|
13397
|
+
const { target, mergeConfig, dragStartData } = this.editBox;
|
|
13398
|
+
const { skewable, rotateable, around, rotateGap } = mergeConfig;
|
|
13421
13399
|
const { direction, name } = e.current;
|
|
13422
13400
|
if (skewable && name === 'resize-line')
|
|
13423
13401
|
return this.onSkew(e);
|
|
13424
|
-
const { element } = this, { dragStartData } = this.editBox;
|
|
13425
13402
|
let origin, rotation;
|
|
13426
13403
|
if (e instanceof RotateEvent) {
|
|
13427
13404
|
if (rotateable === 'rotate')
|
|
13428
|
-
e.stop(), rotation = e.rotation, origin =
|
|
13405
|
+
e.stop(), rotation = e.rotation, origin = target.getBoxPoint(e);
|
|
13429
13406
|
else
|
|
13430
13407
|
return;
|
|
13431
|
-
if (
|
|
13408
|
+
if (target.scaleX * target.scaleY < 0)
|
|
13432
13409
|
rotation = -rotation;
|
|
13433
13410
|
}
|
|
13434
13411
|
else {
|
|
13435
|
-
const data = EditDataHelper.getRotateData(
|
|
13412
|
+
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (target.around || target.origin || around || 'center'));
|
|
13436
13413
|
rotation = data.rotation;
|
|
13437
13414
|
origin = data.origin;
|
|
13438
13415
|
}
|
|
13439
|
-
if (
|
|
13416
|
+
if (target.scaleX * target.scaleY < 0)
|
|
13440
13417
|
rotation = -rotation;
|
|
13441
13418
|
if (e instanceof DragEvent)
|
|
13442
|
-
rotation = dragStartData.rotation + rotation -
|
|
13443
|
-
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap,
|
|
13419
|
+
rotation = dragStartData.rotation + rotation - target.rotation;
|
|
13420
|
+
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
|
|
13444
13421
|
if (!rotation)
|
|
13445
13422
|
return;
|
|
13446
13423
|
this.rotateOf(origin, rotation);
|
|
13447
13424
|
}
|
|
13448
13425
|
onSkew(e) {
|
|
13449
|
-
const {
|
|
13450
|
-
const { around } =
|
|
13451
|
-
const { origin, skewX, skewY } = EditDataHelper.getSkewData(
|
|
13426
|
+
const { target, mergeConfig } = this.editBox;
|
|
13427
|
+
const { around } = mergeConfig;
|
|
13428
|
+
const { origin, skewX, skewY } = EditDataHelper.getSkewData(target.boxBounds, e.current.direction, e.getInnerMove(target), EditDataHelper.getAround(around, e.altKey));
|
|
13452
13429
|
if (!skewX && !skewY)
|
|
13453
13430
|
return;
|
|
13454
13431
|
this.skewOf(origin, skewX, skewY);
|
|
@@ -13458,7 +13435,8 @@ class Editor extends Group {
|
|
|
13458
13435
|
return;
|
|
13459
13436
|
if (typeof x === 'object')
|
|
13460
13437
|
y = x.y, x = x.x;
|
|
13461
|
-
const {
|
|
13438
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13439
|
+
const { beforeMove } = mergeConfig;
|
|
13462
13440
|
if (beforeMove) {
|
|
13463
13441
|
const check = beforeMove({ target, x, y });
|
|
13464
13442
|
if (typeof check === 'object')
|
|
@@ -13467,25 +13445,26 @@ class Editor extends Group {
|
|
|
13467
13445
|
return;
|
|
13468
13446
|
}
|
|
13469
13447
|
const world = target.getWorldPointByLocal({ x, y }, null, true);
|
|
13470
|
-
if (
|
|
13448
|
+
if (!single)
|
|
13471
13449
|
target.safeChange(() => target.move(x, y));
|
|
13472
|
-
const data = { target, editor
|
|
13450
|
+
const data = { target, editor, moveX: world.x, moveY: world.y };
|
|
13473
13451
|
this.emitEvent(new EditorMoveEvent(EditorMoveEvent.BEFORE_MOVE, data));
|
|
13474
13452
|
const event = new EditorMoveEvent(EditorMoveEvent.MOVE, data);
|
|
13475
|
-
this.
|
|
13453
|
+
this.doMove(event);
|
|
13476
13454
|
this.emitEvent(event);
|
|
13477
13455
|
}
|
|
13478
13456
|
scaleWithDrag(data) {
|
|
13479
13457
|
if (!this.checkTransform('resizeable'))
|
|
13480
13458
|
return;
|
|
13481
|
-
const {
|
|
13459
|
+
const { target, mergeConfig, editor } = this.editBox;
|
|
13460
|
+
const { beforeScale } = mergeConfig;
|
|
13482
13461
|
if (beforeScale) {
|
|
13483
13462
|
const { origin, scaleX, scaleY, drag } = data;
|
|
13484
13463
|
const check = beforeScale({ target, drag, origin, scaleX, scaleY });
|
|
13485
13464
|
if (check === false)
|
|
13486
13465
|
return;
|
|
13487
13466
|
}
|
|
13488
|
-
data = Object.assign(Object.assign({}, data), { target, editor
|
|
13467
|
+
data = Object.assign(Object.assign({}, data), { target, editor, worldOrigin: target.getWorldPoint(data.origin) });
|
|
13489
13468
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13490
13469
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13491
13470
|
this.editTool.onScaleWithDrag(event);
|
|
@@ -13494,7 +13473,8 @@ class Editor extends Group {
|
|
|
13494
13473
|
scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
|
|
13495
13474
|
if (!this.checkTransform('resizeable'))
|
|
13496
13475
|
return;
|
|
13497
|
-
const {
|
|
13476
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13477
|
+
const { beforeScale } = mergeConfig;
|
|
13498
13478
|
if (beforeScale) {
|
|
13499
13479
|
const check = beforeScale({ target, origin, scaleX, scaleY });
|
|
13500
13480
|
if (typeof check === 'object')
|
|
@@ -13503,29 +13483,30 @@ class Editor extends Group {
|
|
|
13503
13483
|
return;
|
|
13504
13484
|
}
|
|
13505
13485
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13506
|
-
const transform =
|
|
13507
|
-
const data = { target, editor
|
|
13486
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.scaleOf(origin, scaleX, scaleY)));
|
|
13487
|
+
const data = { target, editor, worldOrigin, scaleX, scaleY, transform };
|
|
13508
13488
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13509
13489
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13510
|
-
this.
|
|
13490
|
+
this.doScale(event);
|
|
13511
13491
|
this.emitEvent(event);
|
|
13512
13492
|
}
|
|
13513
13493
|
flip(axis) {
|
|
13514
13494
|
if (!this.checkTransform('resizeable'))
|
|
13515
13495
|
return;
|
|
13516
|
-
const {
|
|
13496
|
+
const { target, single, editor } = this.editBox;
|
|
13517
13497
|
const worldOrigin = this.getWorldOrigin('center');
|
|
13518
|
-
const transform =
|
|
13519
|
-
const data = { target
|
|
13498
|
+
const transform = !single ? this.getChangedTransform(() => target.safeChange(() => target.flip(axis))) : new Matrix(LeafHelper.getFlipTransform(target, axis));
|
|
13499
|
+
const data = { target, editor, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform };
|
|
13520
13500
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13521
13501
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13522
|
-
this.
|
|
13502
|
+
this.doScale(event);
|
|
13523
13503
|
this.emitEvent(event);
|
|
13524
13504
|
}
|
|
13525
13505
|
rotateOf(origin, rotation) {
|
|
13526
13506
|
if (!this.checkTransform('rotateable'))
|
|
13527
13507
|
return;
|
|
13528
|
-
const {
|
|
13508
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13509
|
+
const { beforeRotate } = mergeConfig;
|
|
13529
13510
|
if (beforeRotate) {
|
|
13530
13511
|
const check = beforeRotate({ target, origin, rotation });
|
|
13531
13512
|
if (typeof check === 'number')
|
|
@@ -13534,17 +13515,18 @@ class Editor extends Group {
|
|
|
13534
13515
|
return;
|
|
13535
13516
|
}
|
|
13536
13517
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13537
|
-
const transform =
|
|
13538
|
-
const data = { target, editor
|
|
13518
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.rotateOf(origin, rotation)));
|
|
13519
|
+
const data = { target, editor, worldOrigin, rotation, transform };
|
|
13539
13520
|
this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data));
|
|
13540
13521
|
const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data);
|
|
13541
|
-
this.
|
|
13522
|
+
this.doRotate(event);
|
|
13542
13523
|
this.emitEvent(event);
|
|
13543
13524
|
}
|
|
13544
13525
|
skewOf(origin, skewX, skewY = 0, _resize) {
|
|
13545
13526
|
if (!this.checkTransform('skewable'))
|
|
13546
13527
|
return;
|
|
13547
|
-
const {
|
|
13528
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13529
|
+
const { beforeSkew } = mergeConfig;
|
|
13548
13530
|
if (beforeSkew) {
|
|
13549
13531
|
const check = beforeSkew({ target, origin, skewX, skewY });
|
|
13550
13532
|
if (typeof check === 'object')
|
|
@@ -13553,25 +13535,142 @@ class Editor extends Group {
|
|
|
13553
13535
|
return;
|
|
13554
13536
|
}
|
|
13555
13537
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13556
|
-
const transform =
|
|
13557
|
-
const data = { target, editor
|
|
13538
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.skewOf(origin, skewX, skewY)));
|
|
13539
|
+
const data = { target, editor, worldOrigin, skewX, skewY, transform };
|
|
13558
13540
|
this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data));
|
|
13559
13541
|
const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data);
|
|
13560
|
-
this.
|
|
13542
|
+
this.doSkew(event);
|
|
13561
13543
|
this.emitEvent(event);
|
|
13562
13544
|
}
|
|
13563
|
-
|
|
13545
|
+
doMove(event) {
|
|
13546
|
+
this.editTool.onMove(event);
|
|
13547
|
+
}
|
|
13548
|
+
doScale(event) {
|
|
13549
|
+
this.editTool.onScale(event);
|
|
13550
|
+
}
|
|
13551
|
+
doRotate(event) {
|
|
13552
|
+
this.editTool.onRotate(event);
|
|
13553
|
+
}
|
|
13554
|
+
doSkew(event) {
|
|
13555
|
+
this.editTool.onSkew(event);
|
|
13556
|
+
}
|
|
13557
|
+
checkTransform(type) {
|
|
13558
|
+
const { target, mergeConfig } = this.editBox;
|
|
13559
|
+
return target && !target.locked && mergeConfig[type];
|
|
13560
|
+
}
|
|
13564
13561
|
getWorldOrigin(origin) {
|
|
13565
|
-
|
|
13562
|
+
const { target } = this.editBox;
|
|
13563
|
+
return target.getWorldPoint(LeafHelper.getInnerOrigin(target, origin));
|
|
13566
13564
|
}
|
|
13567
13565
|
getChangedTransform(func) {
|
|
13568
|
-
const {
|
|
13569
|
-
if (
|
|
13570
|
-
return
|
|
13571
|
-
const oldMatrix = new Matrix(
|
|
13566
|
+
const { target, single } = this.editBox;
|
|
13567
|
+
if (!single && !target.canChange)
|
|
13568
|
+
return target.changedTransform;
|
|
13569
|
+
const oldMatrix = new Matrix(target.worldTransform);
|
|
13572
13570
|
func();
|
|
13573
|
-
return new Matrix(
|
|
13571
|
+
return new Matrix(target.worldTransform).divide(oldMatrix);
|
|
13572
|
+
}
|
|
13573
|
+
emitEvent(event, capture) {
|
|
13574
|
+
this.editBox.editor.emitEvent(event, capture);
|
|
13575
|
+
}
|
|
13576
|
+
}
|
|
13577
|
+
|
|
13578
|
+
let Editor = class Editor extends Group {
|
|
13579
|
+
get list() { return this.leafList.list; }
|
|
13580
|
+
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
13581
|
+
get editing() { return !!this.list.length; }
|
|
13582
|
+
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13583
|
+
get multiple() { return this.list.length > 1; }
|
|
13584
|
+
get single() { return this.list.length === 1; }
|
|
13585
|
+
get dragging() { return this.editBox.dragging; }
|
|
13586
|
+
get moving() { return this.editBox.moving; }
|
|
13587
|
+
get dragPoint() { return this.editBox.dragPoint; }
|
|
13588
|
+
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13589
|
+
get buttons() { return this.editBox.buttons; }
|
|
13590
|
+
constructor(userConfig, data) {
|
|
13591
|
+
super(data);
|
|
13592
|
+
this.leafList = new LeafList();
|
|
13593
|
+
this.openedGroupList = new LeafList();
|
|
13594
|
+
this.simulateTarget = new SimulateElement(this);
|
|
13595
|
+
this.editBox = new EditBox(this);
|
|
13596
|
+
this.editToolList = {};
|
|
13597
|
+
this.selector = new EditSelect(this);
|
|
13598
|
+
this.editMask = new EditMask(this);
|
|
13599
|
+
this.targetEventIds = [];
|
|
13600
|
+
let mergedConfig = DataHelper.clone(config);
|
|
13601
|
+
if (userConfig)
|
|
13602
|
+
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
13603
|
+
this.mergedConfig = this.config = mergedConfig;
|
|
13604
|
+
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13605
|
+
if (!Plugin.has('resize'))
|
|
13606
|
+
this.config.editSize = 'scale';
|
|
13607
|
+
}
|
|
13608
|
+
select(target) {
|
|
13609
|
+
this.target = target;
|
|
13610
|
+
}
|
|
13611
|
+
cancel() {
|
|
13612
|
+
this.target = null;
|
|
13613
|
+
}
|
|
13614
|
+
hasItem(item) {
|
|
13615
|
+
return this.leafList.has(item);
|
|
13616
|
+
}
|
|
13617
|
+
addItem(item) {
|
|
13618
|
+
if (!this.hasItem(item) && !item.locked)
|
|
13619
|
+
this.leafList.add(item), this.target = this.leafList.list;
|
|
13620
|
+
}
|
|
13621
|
+
removeItem(item) {
|
|
13622
|
+
if (this.hasItem(item))
|
|
13623
|
+
this.leafList.remove(item), this.target = this.leafList.list;
|
|
13624
|
+
}
|
|
13625
|
+
shiftItem(item) {
|
|
13626
|
+
this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
|
|
13627
|
+
}
|
|
13628
|
+
update() {
|
|
13629
|
+
if (this.editing) {
|
|
13630
|
+
if (!this.element.parent)
|
|
13631
|
+
return this.cancel();
|
|
13632
|
+
if (this.innerEditing)
|
|
13633
|
+
this.innerEditor.update();
|
|
13634
|
+
this.editTool.update();
|
|
13635
|
+
this.selector.update();
|
|
13636
|
+
}
|
|
13637
|
+
}
|
|
13638
|
+
updateEditBox() {
|
|
13639
|
+
if (this.multiple)
|
|
13640
|
+
simulate(this);
|
|
13641
|
+
this.update();
|
|
13642
|
+
}
|
|
13643
|
+
updateEditTool() {
|
|
13644
|
+
let tool = this.editTool;
|
|
13645
|
+
if (tool) {
|
|
13646
|
+
this.editBox.unload();
|
|
13647
|
+
tool.unload();
|
|
13648
|
+
this.editTool = null;
|
|
13649
|
+
}
|
|
13650
|
+
if (this.editing) {
|
|
13651
|
+
const tag = this.element.editOuter || 'EditTool';
|
|
13652
|
+
tool = this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
|
|
13653
|
+
this.editBox.load();
|
|
13654
|
+
tool.load();
|
|
13655
|
+
this.update();
|
|
13656
|
+
}
|
|
13657
|
+
}
|
|
13658
|
+
getEditSize(_ui) {
|
|
13659
|
+
return this.mergeConfig.editSize;
|
|
13574
13660
|
}
|
|
13661
|
+
onMove(_e) { }
|
|
13662
|
+
onScale(_e) { }
|
|
13663
|
+
onRotate(_e) { }
|
|
13664
|
+
onSkew(_e) { }
|
|
13665
|
+
move(_x, _y = 0) { }
|
|
13666
|
+
scaleWithDrag(_data) { }
|
|
13667
|
+
scaleOf(_origin, scaleX, _scaleY = scaleX, _resize) { }
|
|
13668
|
+
flip(_axis) { }
|
|
13669
|
+
rotateOf(_origin, _rotation) { }
|
|
13670
|
+
skewOf(_origin, _skewX, _skewY = 0, _resize) { }
|
|
13671
|
+
checkTransform(_type) { return undefined; }
|
|
13672
|
+
getWorldOrigin(_origin) { return undefined; }
|
|
13673
|
+
getChangedTransform(_func) { return undefined; }
|
|
13575
13674
|
group(userGroup) {
|
|
13576
13675
|
if (this.multiple) {
|
|
13577
13676
|
this.emitGroupEvent(EditorGroupEvent.BEFORE_GROUP);
|
|
@@ -13689,12 +13788,9 @@ class Editor extends Group {
|
|
|
13689
13788
|
if (this.targetChanged)
|
|
13690
13789
|
this.update();
|
|
13691
13790
|
}
|
|
13692
|
-
onKey(e) {
|
|
13693
|
-
updateCursor(this, e);
|
|
13694
|
-
}
|
|
13695
13791
|
listenTargetEvents() {
|
|
13696
13792
|
if (!this.targetEventIds.length) {
|
|
13697
|
-
const { app, leafer,
|
|
13793
|
+
const { app, leafer, editMask } = this;
|
|
13698
13794
|
this.targetEventIds = [
|
|
13699
13795
|
leafer.on_(RenderEvent.START, this.onRenderStart, this),
|
|
13700
13796
|
app.on_([
|
|
@@ -13702,8 +13798,6 @@ class Editor extends Group {
|
|
|
13702
13798
|
[MoveEvent.BEFORE_MOVE, this.onMove, this, true],
|
|
13703
13799
|
[ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
|
|
13704
13800
|
[RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
|
|
13705
|
-
[[KeyEvent.HOLD, KeyEvent.UP], this.onKey, this],
|
|
13706
|
-
[KeyEvent.DOWN, editBox.onArrow, editBox]
|
|
13707
13801
|
])
|
|
13708
13802
|
];
|
|
13709
13803
|
if (editMask.visible)
|
|
@@ -13728,7 +13822,7 @@ class Editor extends Group {
|
|
|
13728
13822
|
super.destroy();
|
|
13729
13823
|
}
|
|
13730
13824
|
}
|
|
13731
|
-
}
|
|
13825
|
+
};
|
|
13732
13826
|
__decorate([
|
|
13733
13827
|
mergeConfigAttr()
|
|
13734
13828
|
], Editor.prototype, "mergeConfig", void 0);
|
|
@@ -13738,14 +13832,19 @@ __decorate([
|
|
|
13738
13832
|
__decorate([
|
|
13739
13833
|
targetAttr(onTarget)
|
|
13740
13834
|
], Editor.prototype, "target", void 0);
|
|
13835
|
+
Editor = __decorate([
|
|
13836
|
+
useModule(TransformTool, ['editBox', 'editTool', 'emitEvent'])
|
|
13837
|
+
], Editor);
|
|
13741
13838
|
|
|
13742
13839
|
class InnerEditor {
|
|
13743
13840
|
static registerInnerEditor() {
|
|
13744
13841
|
EditToolCreator.register(this);
|
|
13745
13842
|
}
|
|
13746
13843
|
get tag() { return 'InnerEditor'; }
|
|
13844
|
+
get mode() { return 'focus'; }
|
|
13747
13845
|
get editBox() { return this.editor.editBox; }
|
|
13748
13846
|
constructor(editor) {
|
|
13847
|
+
this.eventIds = [];
|
|
13749
13848
|
this.editor = editor;
|
|
13750
13849
|
this.create();
|
|
13751
13850
|
}
|
|
@@ -13758,7 +13857,7 @@ class InnerEditor {
|
|
|
13758
13857
|
load() {
|
|
13759
13858
|
const { editor } = this;
|
|
13760
13859
|
if (editor) {
|
|
13761
|
-
if (editor.app)
|
|
13860
|
+
if (editor.app && this.mode === 'focus')
|
|
13762
13861
|
editor.selector.hittable = editor.app.tree.hitChildren = false;
|
|
13763
13862
|
this.onLoad();
|
|
13764
13863
|
}
|
|
@@ -13769,7 +13868,7 @@ class InnerEditor {
|
|
|
13769
13868
|
unload() {
|
|
13770
13869
|
const { editor } = this;
|
|
13771
13870
|
if (editor) {
|
|
13772
|
-
if (editor.app)
|
|
13871
|
+
if (editor.app && this.mode === 'focus')
|
|
13773
13872
|
editor.selector.hittable = editor.app.tree.hitChildren = true;
|
|
13774
13873
|
this.onUnload();
|
|
13775
13874
|
}
|
|
@@ -13843,10 +13942,7 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
13843
13942
|
this.onLoad();
|
|
13844
13943
|
}
|
|
13845
13944
|
update() {
|
|
13846
|
-
|
|
13847
|
-
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = editor.element.getLayoutBounds('box', editor, true);
|
|
13848
|
-
editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
13849
|
-
editBox.update({ x: 0, y: 0, width, height });
|
|
13945
|
+
this.editBox.update();
|
|
13850
13946
|
this.onUpdate();
|
|
13851
13947
|
}
|
|
13852
13948
|
unload() {
|
|
@@ -14241,12 +14337,8 @@ function updateStyle$1(textDom, text, textScale) {
|
|
|
14241
14337
|
style.justifyContent = verticalAlignMap[text.verticalAlign];
|
|
14242
14338
|
style.lineHeight = (text.__.__lineHeight || 0) * textScale + 'px';
|
|
14243
14339
|
style.letterSpacing = (text.__.__letterSpacing || 0) * textScale + 'px';
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
}
|
|
14247
|
-
else if (textWrap === 'break') {
|
|
14248
|
-
style.wordBreak = 'break-all';
|
|
14249
|
-
}
|
|
14340
|
+
style.whiteSpace = (textWrap === 'none' || text.__.__autoWidth) ? 'nowrap' : 'normal';
|
|
14341
|
+
style.wordBreak = textWrap === 'break' ? 'break-all' : 'normal';
|
|
14250
14342
|
style.textIndent = (text.paraIndent || 0) * textScale + 'px';
|
|
14251
14343
|
style.padding = padding instanceof Array ? padding.map(item => item * textScale + 'px').join(' ') : (padding || 0) * textScale + 'px';
|
|
14252
14344
|
style.textOverflow = textOverflow === 'show' ? '' : (textOverflow === 'hide' ? 'clip' : textOverflow);
|
|
@@ -14319,10 +14411,12 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14319
14411
|
];
|
|
14320
14412
|
this.onFocus = this.onFocus.bind(this);
|
|
14321
14413
|
this.onInput = this.onInput.bind(this);
|
|
14414
|
+
this.onPaste = this.onPaste.bind(this);
|
|
14322
14415
|
this.onUpdate = this.onUpdate.bind(this);
|
|
14323
14416
|
this.onKeydown = this.onKeydown.bind(this);
|
|
14324
14417
|
div.addEventListener("focus", this.onFocus);
|
|
14325
14418
|
div.addEventListener("input", this.onInput);
|
|
14419
|
+
div.addEventListener("paste", this.onPaste);
|
|
14326
14420
|
window.addEventListener('keydown', this.onKeydown);
|
|
14327
14421
|
window.addEventListener('scroll', this.onUpdate);
|
|
14328
14422
|
const selection = window.getSelection();
|
|
@@ -14352,15 +14446,43 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14352
14446
|
if (e.key === 'Enter') {
|
|
14353
14447
|
e.preventDefault();
|
|
14354
14448
|
const br = document.createElement('br');
|
|
14449
|
+
const zwsp = document.createTextNode('\u200B');
|
|
14355
14450
|
const selection = window.getSelection();
|
|
14356
14451
|
const range = selection.getRangeAt(0);
|
|
14357
14452
|
range.deleteContents();
|
|
14453
|
+
range.insertNode(zwsp);
|
|
14358
14454
|
range.insertNode(br);
|
|
14359
14455
|
range.setStartAfter(br);
|
|
14360
14456
|
range.setEndAfter(br);
|
|
14361
14457
|
this.onInput();
|
|
14362
14458
|
}
|
|
14363
14459
|
}
|
|
14460
|
+
onPaste(event) {
|
|
14461
|
+
if (this.isHTMLText)
|
|
14462
|
+
return;
|
|
14463
|
+
event.preventDefault();
|
|
14464
|
+
const clipboardData = event.clipboardData;
|
|
14465
|
+
if (!clipboardData)
|
|
14466
|
+
return;
|
|
14467
|
+
let text = clipboardData.getData('text/plain').replace(/\r\n?/g, '\n');
|
|
14468
|
+
const selection = window.getSelection();
|
|
14469
|
+
if (!selection || !selection.rangeCount)
|
|
14470
|
+
return;
|
|
14471
|
+
const range = selection.getRangeAt(0);
|
|
14472
|
+
range.deleteContents();
|
|
14473
|
+
const lines = text.split('\n');
|
|
14474
|
+
const fragment = document.createDocumentFragment();
|
|
14475
|
+
lines.forEach((line, index) => {
|
|
14476
|
+
if (index > 0)
|
|
14477
|
+
fragment.appendChild(document.createElement('br'));
|
|
14478
|
+
fragment.appendChild(document.createTextNode(line));
|
|
14479
|
+
});
|
|
14480
|
+
range.insertNode(fragment);
|
|
14481
|
+
range.collapse(false);
|
|
14482
|
+
selection.removeAllRanges();
|
|
14483
|
+
selection.addRange(range);
|
|
14484
|
+
this.onInput();
|
|
14485
|
+
}
|
|
14364
14486
|
onUpdate() {
|
|
14365
14487
|
const { editTarget: text } = this;
|
|
14366
14488
|
let textScale = 1;
|
|
@@ -14372,30 +14494,32 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14372
14494
|
textScale *= 12 / text.fontSize;
|
|
14373
14495
|
}
|
|
14374
14496
|
this.textScale = textScale;
|
|
14375
|
-
let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14376
|
-
if (!this.inBody)
|
|
14377
|
-
x -= window.scrollX, y -= window.scrollY;
|
|
14378
14497
|
let { width, height } = text, offsetX = 0, offsetY = 0;
|
|
14379
14498
|
width *= textScale, height *= textScale;
|
|
14380
14499
|
const data = text.__;
|
|
14381
|
-
if (data.__autoWidth
|
|
14500
|
+
if (data.__autoWidth) {
|
|
14382
14501
|
width += 20;
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
|
|
14502
|
+
if (data.autoSizeAlign) {
|
|
14503
|
+
switch (data.textAlign) {
|
|
14504
|
+
case 'center':
|
|
14505
|
+
offsetX = -width / 2;
|
|
14506
|
+
break;
|
|
14507
|
+
case 'right': offsetX = -width;
|
|
14508
|
+
}
|
|
14388
14509
|
}
|
|
14389
14510
|
}
|
|
14390
|
-
if (data.__autoHeight
|
|
14511
|
+
if (data.__autoHeight) {
|
|
14391
14512
|
height += 20;
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14513
|
+
if (data.autoSizeAlign) {
|
|
14514
|
+
switch (data.verticalAlign) {
|
|
14515
|
+
case 'middle':
|
|
14516
|
+
offsetY = -height / 2;
|
|
14517
|
+
break;
|
|
14518
|
+
case 'bottom': offsetY = -height;
|
|
14519
|
+
}
|
|
14397
14520
|
}
|
|
14398
14521
|
}
|
|
14522
|
+
const { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14399
14523
|
const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale).translateInner(offsetX, offsetY);
|
|
14400
14524
|
const { style } = this.editDom;
|
|
14401
14525
|
style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
@@ -14417,6 +14541,7 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14417
14541
|
editor.off_(this.eventIds);
|
|
14418
14542
|
dom.removeEventListener("focus", this.onFocus);
|
|
14419
14543
|
dom.removeEventListener("input", this.onInput);
|
|
14544
|
+
dom.removeEventListener("paste", this.onPaste);
|
|
14420
14545
|
window.removeEventListener('keydown', this.onKeydown);
|
|
14421
14546
|
window.removeEventListener('scroll', this.onUpdate);
|
|
14422
14547
|
dom.remove();
|
|
@@ -14819,8 +14944,16 @@ function getFixBounds(bounds, scaleBounds) {
|
|
|
14819
14944
|
}
|
|
14820
14945
|
|
|
14821
14946
|
Plugin.add('view');
|
|
14822
|
-
Leafer.prototype.zoom = function (zoomType,
|
|
14947
|
+
Leafer.prototype.zoom = function (zoomType, optionsOrPadding, scroll, transition) {
|
|
14823
14948
|
this.killAnimate();
|
|
14949
|
+
let padding;
|
|
14950
|
+
if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {
|
|
14951
|
+
padding = optionsOrPadding.padding;
|
|
14952
|
+
scroll = optionsOrPadding.scroll;
|
|
14953
|
+
transition = optionsOrPadding.transition;
|
|
14954
|
+
}
|
|
14955
|
+
else
|
|
14956
|
+
padding = optionsOrPadding;
|
|
14824
14957
|
const { zoomLayer } = this;
|
|
14825
14958
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
|
|
14826
14959
|
const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
|
|
@@ -14867,7 +15000,7 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
|
|
|
14867
15000
|
}
|
|
14868
15001
|
const { width, height } = bounds;
|
|
14869
15002
|
let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y;
|
|
14870
|
-
if (
|
|
15003
|
+
if (scroll) {
|
|
14871
15004
|
moveX += Math.max((limitBounds.width - width) / 2, 0);
|
|
14872
15005
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
14873
15006
|
}
|
|
@@ -14880,6 +15013,10 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed, transition) {
|
|
|
14880
15013
|
data.scaleX *= changeScale;
|
|
14881
15014
|
data.scaleY *= changeScale;
|
|
14882
15015
|
}
|
|
15016
|
+
if (scroll === 'x')
|
|
15017
|
+
moveY = 0;
|
|
15018
|
+
else if (scroll === 'y')
|
|
15019
|
+
moveX = 0;
|
|
14883
15020
|
PointHelper.move(data, moveX, moveY);
|
|
14884
15021
|
bounds.move(moveX, moveY);
|
|
14885
15022
|
zoomLayer.set(data, transition);
|
|
@@ -15045,6 +15182,11 @@ let HTMLText = class HTMLText extends Image {
|
|
|
15045
15182
|
}
|
|
15046
15183
|
super.__updateBoxBounds();
|
|
15047
15184
|
}
|
|
15185
|
+
__draw(canvas, options, originCanvas) {
|
|
15186
|
+
if (this.textEditing && !options.exporting)
|
|
15187
|
+
return;
|
|
15188
|
+
super.__draw(canvas, options, originCanvas);
|
|
15189
|
+
}
|
|
15048
15190
|
};
|
|
15049
15191
|
__decorate([
|
|
15050
15192
|
dataProcessor(HTMLTextData)
|
|
@@ -15055,6 +15197,9 @@ __decorate([
|
|
|
15055
15197
|
__decorate([
|
|
15056
15198
|
dataType('TextEditor')
|
|
15057
15199
|
], HTMLText.prototype, "editInner", void 0);
|
|
15200
|
+
__decorate([
|
|
15201
|
+
surfaceType(false)
|
|
15202
|
+
], HTMLText.prototype, "textEditing", void 0);
|
|
15058
15203
|
HTMLText = __decorate([
|
|
15059
15204
|
registerUI()
|
|
15060
15205
|
], HTMLText);
|
|
@@ -17988,7 +18133,7 @@ const ExportModule = {
|
|
|
17988
18133
|
let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
17989
18134
|
if (clip)
|
|
17990
18135
|
x += clip.x, y += clip.y, width = clip.width, height = clip.height;
|
|
17991
|
-
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
18136
|
+
const renderOptions = { exporting: true, matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
17992
18137
|
let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
|
|
17993
18138
|
let sliceLeaf;
|
|
17994
18139
|
if (slice) {
|
|
@@ -18139,4 +18284,4 @@ Object.assign(Filter, {
|
|
|
18139
18284
|
}
|
|
18140
18285
|
});
|
|
18141
18286
|
|
|
18142
|
-
export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
18287
|
+
export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|