@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.js
CHANGED
|
@@ -46,7 +46,7 @@ var LeaferUI = (function (exports) {
|
|
|
46
46
|
};
|
|
47
47
|
const I$2 = IncrementId;
|
|
48
48
|
|
|
49
|
-
const { round: round$6, pow: pow$2, PI: PI$
|
|
49
|
+
const { round: round$6, pow: pow$2, PI: PI$4 } = Math;
|
|
50
50
|
const MathHelper = {
|
|
51
51
|
within(value, min, max) {
|
|
52
52
|
if (typeof min === 'object')
|
|
@@ -142,9 +142,9 @@ var LeaferUI = (function (exports) {
|
|
|
142
142
|
function randInt(num) {
|
|
143
143
|
return Math.round(Math.random() * num);
|
|
144
144
|
}
|
|
145
|
-
const OneRadian = PI$
|
|
146
|
-
const PI2 = PI$
|
|
147
|
-
const PI_2 = PI$
|
|
145
|
+
const OneRadian = PI$4 / 180;
|
|
146
|
+
const PI2 = PI$4 * 2;
|
|
147
|
+
const PI_2 = PI$4 / 2;
|
|
148
148
|
function getPointData() { return { x: 0, y: 0 }; }
|
|
149
149
|
function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
|
|
150
150
|
function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
@@ -439,7 +439,7 @@ var LeaferUI = (function (exports) {
|
|
|
439
439
|
const M$a = MatrixHelper;
|
|
440
440
|
|
|
441
441
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
442
|
-
const { sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5
|
|
442
|
+
const { sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5 } = Math;
|
|
443
443
|
const PointHelper = {
|
|
444
444
|
defaultPoint: getPointData(),
|
|
445
445
|
tempPoint: {},
|
|
@@ -552,10 +552,11 @@ var LeaferUI = (function (exports) {
|
|
|
552
552
|
getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
|
|
553
553
|
if (toOriginX === undefined)
|
|
554
554
|
toOriginX = originX, toOriginY = originY;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
555
|
+
const a = fromX - originX;
|
|
556
|
+
const b = fromY - originY;
|
|
557
|
+
const c = toX - toOriginX;
|
|
558
|
+
const d = toY - toOriginY;
|
|
559
|
+
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
559
560
|
},
|
|
560
561
|
getAtan2(t, to) {
|
|
561
562
|
return atan2$2(to.y - t.y, to.x - t.x);
|
|
@@ -3342,7 +3343,7 @@ var LeaferUI = (function (exports) {
|
|
|
3342
3343
|
const { arcTo } = PathCommandDataHelper;
|
|
3343
3344
|
const PathCorner = {
|
|
3344
3345
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3345
|
-
let command, commandLen;
|
|
3346
|
+
let command, lastCommand, commandLen;
|
|
3346
3347
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3347
3348
|
const len = data.length;
|
|
3348
3349
|
const smooth = [];
|
|
@@ -3380,8 +3381,10 @@ var LeaferUI = (function (exports) {
|
|
|
3380
3381
|
lastY = y;
|
|
3381
3382
|
break;
|
|
3382
3383
|
case Z$3:
|
|
3383
|
-
|
|
3384
|
-
|
|
3384
|
+
if (lastCommand !== Z$3) {
|
|
3385
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3386
|
+
smooth.push(Z$3);
|
|
3387
|
+
}
|
|
3385
3388
|
i += 1;
|
|
3386
3389
|
break;
|
|
3387
3390
|
default:
|
|
@@ -3390,6 +3393,7 @@ var LeaferUI = (function (exports) {
|
|
|
3390
3393
|
smooth.push(data[i + j]);
|
|
3391
3394
|
i += commandLen;
|
|
3392
3395
|
}
|
|
3396
|
+
lastCommand = command;
|
|
3393
3397
|
}
|
|
3394
3398
|
if (command !== Z$3) {
|
|
3395
3399
|
smooth[1] = startX;
|
|
@@ -3886,12 +3890,12 @@ var LeaferUI = (function (exports) {
|
|
|
3886
3890
|
try {
|
|
3887
3891
|
if (transform && pattern.setTransform) {
|
|
3888
3892
|
pattern.setTransform(transform);
|
|
3889
|
-
transform =
|
|
3893
|
+
transform = undefined;
|
|
3890
3894
|
}
|
|
3891
3895
|
}
|
|
3892
3896
|
catch (_a) { }
|
|
3893
3897
|
if (paint)
|
|
3894
|
-
paint
|
|
3898
|
+
DataHelper.stintSet(paint, 'transform', transform);
|
|
3895
3899
|
return pattern;
|
|
3896
3900
|
}
|
|
3897
3901
|
destroy() {
|
|
@@ -3996,10 +4000,14 @@ var LeaferUI = (function (exports) {
|
|
|
3996
4000
|
}));
|
|
3997
4001
|
}
|
|
3998
4002
|
const pathType = boundsType;
|
|
3999
|
-
function affectStrokeBoundsType(defaultValue) {
|
|
4003
|
+
function affectStrokeBoundsType(defaultValue, useStroke) {
|
|
4000
4004
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
4001
4005
|
set(value) {
|
|
4002
|
-
this.__setAttr(key, value)
|
|
4006
|
+
if (this.__setAttr(key, value)) {
|
|
4007
|
+
doStrokeType(this);
|
|
4008
|
+
if (useStroke)
|
|
4009
|
+
this.__.__useStroke = true;
|
|
4010
|
+
}
|
|
4003
4011
|
}
|
|
4004
4012
|
}));
|
|
4005
4013
|
}
|
|
@@ -5425,6 +5433,8 @@ var LeaferUI = (function (exports) {
|
|
|
5425
5433
|
|
|
5426
5434
|
const LeafRender = {
|
|
5427
5435
|
__render(canvas, options) {
|
|
5436
|
+
if (options.shape)
|
|
5437
|
+
return this.__renderShape(canvas, options);
|
|
5428
5438
|
if (this.__worldOpacity) {
|
|
5429
5439
|
const data = this.__;
|
|
5430
5440
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5434,12 +5444,10 @@ var LeaferUI = (function (exports) {
|
|
|
5434
5444
|
return this.__renderEraser(canvas, options);
|
|
5435
5445
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5436
5446
|
this.__draw(tempCanvas, options, canvas);
|
|
5437
|
-
if (this.__worldFlipped)
|
|
5447
|
+
if (this.__worldFlipped)
|
|
5438
5448
|
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5439
|
-
|
|
5440
|
-
else {
|
|
5449
|
+
else
|
|
5441
5450
|
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5442
|
-
}
|
|
5443
5451
|
tempCanvas.recycle(this.__nowWorld);
|
|
5444
5452
|
}
|
|
5445
5453
|
else {
|
|
@@ -5449,6 +5457,12 @@ var LeaferUI = (function (exports) {
|
|
|
5449
5457
|
Debug.drawBounds(this, canvas, options);
|
|
5450
5458
|
}
|
|
5451
5459
|
},
|
|
5460
|
+
__renderShape(canvas, options) {
|
|
5461
|
+
if (this.__worldOpacity) {
|
|
5462
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5463
|
+
this.__drawShape(canvas, options);
|
|
5464
|
+
}
|
|
5465
|
+
},
|
|
5452
5466
|
__clip(canvas, options) {
|
|
5453
5467
|
if (this.__worldOpacity) {
|
|
5454
5468
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5868,7 +5882,8 @@ var LeaferUI = (function (exports) {
|
|
|
5868
5882
|
__drawFast(_canvas, _options) { }
|
|
5869
5883
|
__draw(_canvas, _options, _originCanvas) { }
|
|
5870
5884
|
__clip(_canvas, _options) { }
|
|
5871
|
-
__renderShape(_canvas, _options
|
|
5885
|
+
__renderShape(_canvas, _options) { }
|
|
5886
|
+
__drawShape(_canvas, _options) { }
|
|
5872
5887
|
__updateWorldOpacity() { }
|
|
5873
5888
|
__updateChange() { }
|
|
5874
5889
|
__drawPath(_canvas) { }
|
|
@@ -6236,7 +6251,7 @@ var LeaferUI = (function (exports) {
|
|
|
6236
6251
|
}
|
|
6237
6252
|
}
|
|
6238
6253
|
|
|
6239
|
-
const version = "1.
|
|
6254
|
+
const version = "1.7.0";
|
|
6240
6255
|
|
|
6241
6256
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6242
6257
|
get allowBackgroundColor() { return true; }
|
|
@@ -7153,13 +7168,9 @@ var LeaferUI = (function (exports) {
|
|
|
7153
7168
|
else
|
|
7154
7169
|
return strokeWidth;
|
|
7155
7170
|
}
|
|
7156
|
-
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7157
|
-
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
7158
7171
|
get __hasMultiPaint() {
|
|
7159
7172
|
const t = this;
|
|
7160
|
-
|
|
7161
|
-
return true;
|
|
7162
|
-
return t.fill && this.__hasStroke;
|
|
7173
|
+
return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
|
|
7163
7174
|
}
|
|
7164
7175
|
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7165
7176
|
get __hasSurface() { const t = this; return (t.fill || t.stroke); }
|
|
@@ -7450,15 +7461,18 @@ var LeaferUI = (function (exports) {
|
|
|
7450
7461
|
const UIRender = {
|
|
7451
7462
|
__updateChange() {
|
|
7452
7463
|
const data = this.__;
|
|
7464
|
+
if (data.__useStroke) {
|
|
7465
|
+
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
7466
|
+
stintSet$1(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
|
|
7467
|
+
stintSet$1(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7468
|
+
}
|
|
7453
7469
|
if (data.__useEffect) {
|
|
7454
7470
|
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7455
7471
|
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')));
|
|
7456
7472
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7457
7473
|
}
|
|
7458
|
-
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7459
|
-
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7460
7474
|
data.__checkSingle();
|
|
7461
|
-
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7475
|
+
stintSet$1(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
|
|
7462
7476
|
},
|
|
7463
7477
|
__drawFast(canvas, options) {
|
|
7464
7478
|
drawFast(this, canvas, options);
|
|
@@ -7516,18 +7530,15 @@ var LeaferUI = (function (exports) {
|
|
|
7516
7530
|
this.__drawFast(canvas, options);
|
|
7517
7531
|
}
|
|
7518
7532
|
},
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
this.
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
if (stroke && !ignoreStroke)
|
|
7529
|
-
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7530
|
-
}
|
|
7533
|
+
__drawShape(canvas, options) {
|
|
7534
|
+
this.__drawRenderPath(canvas);
|
|
7535
|
+
const data = this.__, { fill, stroke } = data;
|
|
7536
|
+
if (fill && !options.ignoreFill)
|
|
7537
|
+
data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7538
|
+
if (data.__isCanvas)
|
|
7539
|
+
this.__drawAfterFill(canvas, options);
|
|
7540
|
+
if (stroke && !options.ignoreStroke)
|
|
7541
|
+
data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7531
7542
|
},
|
|
7532
7543
|
__drawAfterFill(canvas, options) {
|
|
7533
7544
|
if (this.__.__clipAfterFill) {
|
|
@@ -7652,12 +7663,14 @@ var LeaferUI = (function (exports) {
|
|
|
7652
7663
|
}
|
|
7653
7664
|
}
|
|
7654
7665
|
__updateRenderPath() {
|
|
7655
|
-
|
|
7656
|
-
|
|
7666
|
+
const data = this.__;
|
|
7667
|
+
if (data.path) {
|
|
7657
7668
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
7658
7669
|
if (data.__useArrow)
|
|
7659
7670
|
PathArrow.addArrows(this, !data.cornerRadius);
|
|
7660
7671
|
}
|
|
7672
|
+
else
|
|
7673
|
+
data.__pathForRender && (data.__pathForRender = undefined);
|
|
7661
7674
|
}
|
|
7662
7675
|
__drawRenderPath(canvas) {
|
|
7663
7676
|
canvas.beginPath();
|
|
@@ -7868,13 +7881,13 @@ var LeaferUI = (function (exports) {
|
|
|
7868
7881
|
surfaceType()
|
|
7869
7882
|
], exports.UI.prototype, "fill", void 0);
|
|
7870
7883
|
__decorate([
|
|
7871
|
-
strokeType()
|
|
7884
|
+
strokeType(undefined, true)
|
|
7872
7885
|
], exports.UI.prototype, "stroke", void 0);
|
|
7873
7886
|
__decorate([
|
|
7874
7887
|
strokeType('inside')
|
|
7875
7888
|
], exports.UI.prototype, "strokeAlign", void 0);
|
|
7876
7889
|
__decorate([
|
|
7877
|
-
strokeType(1)
|
|
7890
|
+
strokeType(1, true)
|
|
7878
7891
|
], exports.UI.prototype, "strokeWidth", void 0);
|
|
7879
7892
|
__decorate([
|
|
7880
7893
|
strokeType(false)
|
|
@@ -8301,7 +8314,7 @@ var LeaferUI = (function (exports) {
|
|
|
8301
8314
|
list.push(item);
|
|
8302
8315
|
this.requestRender();
|
|
8303
8316
|
}
|
|
8304
|
-
zoom(_zoomType,
|
|
8317
|
+
zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
|
|
8305
8318
|
return Plugin.need('view');
|
|
8306
8319
|
}
|
|
8307
8320
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
@@ -8346,7 +8359,7 @@ var LeaferUI = (function (exports) {
|
|
|
8346
8359
|
Leafer_1.list.remove(this);
|
|
8347
8360
|
try {
|
|
8348
8361
|
this.stop();
|
|
8349
|
-
this.
|
|
8362
|
+
this.emitLeafer(LeaferEvent.END);
|
|
8350
8363
|
this.__removeListenEvents();
|
|
8351
8364
|
this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
|
|
8352
8365
|
this.__controllers.length = 0;
|
|
@@ -8474,7 +8487,7 @@ var LeaferUI = (function (exports) {
|
|
|
8474
8487
|
}
|
|
8475
8488
|
__drawContent(canvas, options) {
|
|
8476
8489
|
this.__renderGroup(canvas, options);
|
|
8477
|
-
if (this.__.
|
|
8490
|
+
if (this.__.__useStroke) {
|
|
8478
8491
|
canvas.setWorld(this.__nowWorld);
|
|
8479
8492
|
this.__drawRenderPath(canvas);
|
|
8480
8493
|
}
|
|
@@ -8694,8 +8707,8 @@ var LeaferUI = (function (exports) {
|
|
|
8694
8707
|
for (let i = 1; i < sides; i++) {
|
|
8695
8708
|
lineTo$1(path, rx + rx * sin$2((i * 2 * PI$2) / sides), ry - ry * cos$2((i * 2 * PI$2) / sides));
|
|
8696
8709
|
}
|
|
8710
|
+
closePath$1(path);
|
|
8697
8711
|
}
|
|
8698
|
-
closePath$1(path);
|
|
8699
8712
|
}
|
|
8700
8713
|
__updateRenderPath() { }
|
|
8701
8714
|
__updateBoxBounds() { }
|
|
@@ -8929,10 +8942,15 @@ var LeaferUI = (function (exports) {
|
|
|
8929
8942
|
const box = this.__box;
|
|
8930
8943
|
if (box)
|
|
8931
8944
|
box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
8932
|
-
if (this.textEditing && !
|
|
8945
|
+
if (this.textEditing && !options.exporting)
|
|
8933
8946
|
return;
|
|
8934
8947
|
super.__draw(canvas, options, originCanvas);
|
|
8935
8948
|
}
|
|
8949
|
+
__drawShape(canvas, options) {
|
|
8950
|
+
if (options.shape)
|
|
8951
|
+
this.__box && this.__box.__drawShape(canvas, options);
|
|
8952
|
+
super.__drawShape(canvas, options);
|
|
8953
|
+
}
|
|
8936
8954
|
destroy() {
|
|
8937
8955
|
if (this.boxStyle)
|
|
8938
8956
|
this.boxStyle = null;
|
|
@@ -9754,6 +9772,7 @@ var LeaferUI = (function (exports) {
|
|
|
9754
9772
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9755
9773
|
},
|
|
9756
9774
|
pointer: {
|
|
9775
|
+
type: 'pointer',
|
|
9757
9776
|
snap: true,
|
|
9758
9777
|
hitRadius: 5,
|
|
9759
9778
|
tapTime: 120,
|
|
@@ -10297,7 +10316,7 @@ var LeaferUI = (function (exports) {
|
|
|
10297
10316
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10298
10317
|
h.clear();
|
|
10299
10318
|
ImageManager.patternLocked = true;
|
|
10300
|
-
this.__renderShape(h, { matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y)
|
|
10319
|
+
this.__renderShape(h, { matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y), ignoreFill: !isHitPixelFill, ignoreStroke: !isHitPixelStroke });
|
|
10301
10320
|
ImageManager.patternLocked = false;
|
|
10302
10321
|
h.resetTransform();
|
|
10303
10322
|
data.__isHitPixel = true;
|
|
@@ -10701,7 +10720,7 @@ var LeaferUI = (function (exports) {
|
|
|
10701
10720
|
};
|
|
10702
10721
|
|
|
10703
10722
|
let origin$1 = {};
|
|
10704
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
|
|
10723
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
|
|
10705
10724
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10706
10725
|
const transform = get$3();
|
|
10707
10726
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -10710,13 +10729,15 @@ var LeaferUI = (function (exports) {
|
|
|
10710
10729
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
10711
10730
|
data.transform = transform;
|
|
10712
10731
|
}
|
|
10713
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10732
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
10714
10733
|
const transform = get$3();
|
|
10715
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
10716
|
-
if (scaleX)
|
|
10717
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
10718
10734
|
if (rotation)
|
|
10719
10735
|
rotate$2(transform, rotation);
|
|
10736
|
+
if (skew)
|
|
10737
|
+
skewHelper(transform, skew.x, skew.y);
|
|
10738
|
+
if (scaleX)
|
|
10739
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10740
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
10720
10741
|
data.transform = transform;
|
|
10721
10742
|
}
|
|
10722
10743
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -10753,11 +10774,13 @@ var LeaferUI = (function (exports) {
|
|
|
10753
10774
|
const tempScaleData = {};
|
|
10754
10775
|
const tempImage = {};
|
|
10755
10776
|
function createData(leafPaint, image, paint, box) {
|
|
10756
|
-
const { changeful, sync } = paint;
|
|
10777
|
+
const { changeful, sync, editing } = paint;
|
|
10757
10778
|
if (changeful)
|
|
10758
10779
|
leafPaint.changeful = changeful;
|
|
10759
10780
|
if (sync)
|
|
10760
10781
|
leafPaint.sync = sync;
|
|
10782
|
+
if (editing)
|
|
10783
|
+
leafPaint.editing = editing;
|
|
10761
10784
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10762
10785
|
}
|
|
10763
10786
|
function getPatternData(paint, box, image) {
|
|
@@ -10766,7 +10789,7 @@ var LeaferUI = (function (exports) {
|
|
|
10766
10789
|
if (paint.mode === 'strench')
|
|
10767
10790
|
paint.mode = 'stretch';
|
|
10768
10791
|
let { width, height } = image;
|
|
10769
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
10792
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
10770
10793
|
const sameBox = box.width === width && box.height === height;
|
|
10771
10794
|
const data = { mode };
|
|
10772
10795
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -10800,8 +10823,8 @@ var LeaferUI = (function (exports) {
|
|
|
10800
10823
|
break;
|
|
10801
10824
|
case 'normal':
|
|
10802
10825
|
case 'clip':
|
|
10803
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
10804
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10826
|
+
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
10827
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
10805
10828
|
break;
|
|
10806
10829
|
case 'repeat':
|
|
10807
10830
|
if (!sameBox || scaleX || rotation)
|
|
@@ -10878,11 +10901,11 @@ var LeaferUI = (function (exports) {
|
|
|
10878
10901
|
}
|
|
10879
10902
|
onLoadSuccess(ui, event);
|
|
10880
10903
|
}
|
|
10881
|
-
leafPaint.loadId =
|
|
10904
|
+
leafPaint.loadId = undefined;
|
|
10882
10905
|
}, (error) => {
|
|
10883
10906
|
ignoreRender(ui, false);
|
|
10884
10907
|
onLoadError(ui, event, error);
|
|
10885
|
-
leafPaint.loadId =
|
|
10908
|
+
leafPaint.loadId = undefined;
|
|
10886
10909
|
});
|
|
10887
10910
|
if (ui.placeholderColor) {
|
|
10888
10911
|
if (!ui.placeholderDelay)
|
|
@@ -10948,6 +10971,8 @@ var LeaferUI = (function (exports) {
|
|
|
10948
10971
|
const { image, data } = paint;
|
|
10949
10972
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
10950
10973
|
if (sx) {
|
|
10974
|
+
sx = abs$4(sx);
|
|
10975
|
+
sy = abs$4(sy);
|
|
10951
10976
|
imageMatrix = get$1();
|
|
10952
10977
|
copy$4(imageMatrix, transform);
|
|
10953
10978
|
scale$2(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -11941,41 +11966,10 @@ var LeaferUI = (function (exports) {
|
|
|
11941
11966
|
}
|
|
11942
11967
|
EditorEvent.BEFORE_SELECT = 'editor.before_select';
|
|
11943
11968
|
EditorEvent.SELECT = 'editor.select';
|
|
11969
|
+
EditorEvent.AFTER_SELECT = 'editor.after_select';
|
|
11944
11970
|
EditorEvent.BEFORE_HOVER = 'editor.before_hover';
|
|
11945
11971
|
EditorEvent.HOVER = 'editor.hover';
|
|
11946
11972
|
|
|
11947
|
-
class EditorMoveEvent extends EditorEvent {
|
|
11948
|
-
constructor(type, data) {
|
|
11949
|
-
super(type, data);
|
|
11950
|
-
}
|
|
11951
|
-
}
|
|
11952
|
-
EditorMoveEvent.BEFORE_MOVE = 'editor.before_move';
|
|
11953
|
-
EditorMoveEvent.MOVE = 'editor.move';
|
|
11954
|
-
|
|
11955
|
-
class EditorScaleEvent extends EditorEvent {
|
|
11956
|
-
constructor(type, data) {
|
|
11957
|
-
super(type, data);
|
|
11958
|
-
}
|
|
11959
|
-
}
|
|
11960
|
-
EditorScaleEvent.BEFORE_SCALE = 'editor.before_scale';
|
|
11961
|
-
EditorScaleEvent.SCALE = 'editor.scale';
|
|
11962
|
-
|
|
11963
|
-
class EditorRotateEvent extends EditorEvent {
|
|
11964
|
-
constructor(type, data) {
|
|
11965
|
-
super(type, data);
|
|
11966
|
-
}
|
|
11967
|
-
}
|
|
11968
|
-
EditorRotateEvent.BEFORE_ROTATE = 'editor.before_rotate';
|
|
11969
|
-
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
11970
|
-
|
|
11971
|
-
class EditorSkewEvent extends EditorEvent {
|
|
11972
|
-
constructor(type, data) {
|
|
11973
|
-
super(type, data);
|
|
11974
|
-
}
|
|
11975
|
-
}
|
|
11976
|
-
EditorSkewEvent.BEFORE_SKEW = 'editor.before_skew';
|
|
11977
|
-
EditorSkewEvent.SKEW = 'editor.skew';
|
|
11978
|
-
|
|
11979
11973
|
function targetAttr(fn) {
|
|
11980
11974
|
return (target, key) => {
|
|
11981
11975
|
const privateKey = '_' + key;
|
|
@@ -12386,16 +12380,16 @@ var LeaferUI = (function (exports) {
|
|
|
12386
12380
|
const { toPoint } = AroundHelper;
|
|
12387
12381
|
const { within: within$2 } = MathHelper;
|
|
12388
12382
|
const EditDataHelper = {
|
|
12389
|
-
getScaleData(
|
|
12383
|
+
getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
|
|
12390
12384
|
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
12391
|
-
const { boxBounds, widthRange, heightRange, dragBounds, worldBoxBounds } =
|
|
12385
|
+
const { boxBounds, widthRange, heightRange, dragBounds, worldBoxBounds } = target;
|
|
12392
12386
|
const { width, height } = startBounds;
|
|
12393
12387
|
if (around) {
|
|
12394
12388
|
totalMove.x *= 2;
|
|
12395
12389
|
totalMove.y *= 2;
|
|
12396
12390
|
}
|
|
12397
|
-
const originChangedScaleX =
|
|
12398
|
-
const originChangedScaleY =
|
|
12391
|
+
const originChangedScaleX = target.scaleX / startBounds.scaleX;
|
|
12392
|
+
const originChangedScaleY = target.scaleY / startBounds.scaleY;
|
|
12399
12393
|
const signX = originChangedScaleX < 0 ? -1 : 1;
|
|
12400
12394
|
const signY = originChangedScaleY < 0 ? -1 : 1;
|
|
12401
12395
|
const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
|
|
@@ -12471,7 +12465,7 @@ var LeaferUI = (function (exports) {
|
|
|
12471
12465
|
if (useScaleY)
|
|
12472
12466
|
scaleY /= changedScaleY;
|
|
12473
12467
|
if (!flipable) {
|
|
12474
|
-
const { worldTransform } =
|
|
12468
|
+
const { worldTransform } = target;
|
|
12475
12469
|
if (scaleX < 0)
|
|
12476
12470
|
scaleX = 1 / boxBounds.width / worldTransform.scaleX;
|
|
12477
12471
|
if (scaleY < 0)
|
|
@@ -12479,9 +12473,9 @@ var LeaferUI = (function (exports) {
|
|
|
12479
12473
|
}
|
|
12480
12474
|
toPoint(around || align, boxBounds, origin, true);
|
|
12481
12475
|
if (dragBounds) {
|
|
12482
|
-
const allowBounds = dragBounds === 'parent' ?
|
|
12483
|
-
const localBounds = new Bounds(
|
|
12484
|
-
localBounds.scaleOf(
|
|
12476
|
+
const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds;
|
|
12477
|
+
const localBounds = new Bounds(target.__localBoxBounds);
|
|
12478
|
+
localBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
|
|
12485
12479
|
if (!BoundsHelper.includes(allowBounds, localBounds)) {
|
|
12486
12480
|
const realBounds = localBounds.getIntersect(allowBounds);
|
|
12487
12481
|
const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
|
|
@@ -12492,11 +12486,11 @@ var LeaferUI = (function (exports) {
|
|
|
12492
12486
|
}
|
|
12493
12487
|
}
|
|
12494
12488
|
if (useScaleX && widthRange) {
|
|
12495
|
-
const nowWidth = boxBounds.width *
|
|
12489
|
+
const nowWidth = boxBounds.width * target.scaleX;
|
|
12496
12490
|
scaleX = within$2(nowWidth * scaleX, widthRange) / nowWidth;
|
|
12497
12491
|
}
|
|
12498
12492
|
if (useScaleY && heightRange) {
|
|
12499
|
-
const nowHeight = boxBounds.height *
|
|
12493
|
+
const nowHeight = boxBounds.height * target.scaleY;
|
|
12500
12494
|
scaleY = within$2(nowHeight * scaleY, heightRange) / nowHeight;
|
|
12501
12495
|
}
|
|
12502
12496
|
if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
@@ -12507,7 +12501,7 @@ var LeaferUI = (function (exports) {
|
|
|
12507
12501
|
scaleY = scaleX = Math.min(scaleX, scaleY);
|
|
12508
12502
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
12509
12503
|
},
|
|
12510
|
-
getRotateData(
|
|
12504
|
+
getRotateData(target, direction, current, last, around) {
|
|
12511
12505
|
let align, origin = {};
|
|
12512
12506
|
switch (direction) {
|
|
12513
12507
|
case topLeft$1:
|
|
@@ -12525,8 +12519,8 @@ var LeaferUI = (function (exports) {
|
|
|
12525
12519
|
default:
|
|
12526
12520
|
align = 'center';
|
|
12527
12521
|
}
|
|
12528
|
-
toPoint(around || align,
|
|
12529
|
-
return { origin, rotation: PointHelper.getRotation(last, origin, current) };
|
|
12522
|
+
toPoint(around || align, target.boxBounds, origin, true);
|
|
12523
|
+
return { origin, rotation: PointHelper.getRotation(last, target.getWorldPointByBox(origin), current) };
|
|
12530
12524
|
},
|
|
12531
12525
|
getSkewData(bounds, direction, move, around) {
|
|
12532
12526
|
let align, origin = {}, skewX = 0, skewY = 0;
|
|
@@ -12623,9 +12617,9 @@ var LeaferUI = (function (exports) {
|
|
|
12623
12617
|
};
|
|
12624
12618
|
|
|
12625
12619
|
const cacheCursors = {};
|
|
12626
|
-
function updateCursor(
|
|
12627
|
-
const {
|
|
12628
|
-
if (!point || !editor.editing || !editBox.visible)
|
|
12620
|
+
function updateCursor(editBox, e) {
|
|
12621
|
+
const { enterPoint: point } = editBox;
|
|
12622
|
+
if (!point || !editBox.editor.editing || !editBox.visible)
|
|
12629
12623
|
return;
|
|
12630
12624
|
if (point.name === 'circle')
|
|
12631
12625
|
return;
|
|
@@ -12634,9 +12628,8 @@ var LeaferUI = (function (exports) {
|
|
|
12634
12628
|
point.cursor = 'pointer';
|
|
12635
12629
|
return;
|
|
12636
12630
|
}
|
|
12637
|
-
let { rotation } = editBox;
|
|
12638
|
-
const { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } =
|
|
12639
|
-
const { pointType } = point, { flippedX, flippedY } = editBox;
|
|
12631
|
+
let { rotation, flippedX, flippedY } = editBox;
|
|
12632
|
+
const { pointType } = point, { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editBox.mergeConfig;
|
|
12640
12633
|
let showResize = pointType.includes('resize');
|
|
12641
12634
|
if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
|
|
12642
12635
|
showResize = false;
|
|
@@ -12653,9 +12646,9 @@ var LeaferUI = (function (exports) {
|
|
|
12653
12646
|
cacheCursors[key] = point.cursor = { url: toDataURL(url, rotation), x, y };
|
|
12654
12647
|
}
|
|
12655
12648
|
}
|
|
12656
|
-
function updateMoveCursor(
|
|
12657
|
-
const { moveCursor, moveable } =
|
|
12658
|
-
|
|
12649
|
+
function updateMoveCursor(editBox) {
|
|
12650
|
+
const { moveCursor, moveable } = editBox.mergeConfig;
|
|
12651
|
+
editBox.rect.cursor = moveable ? moveCursor : undefined;
|
|
12659
12652
|
}
|
|
12660
12653
|
function toDataURL(svg, rotation) {
|
|
12661
12654
|
return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
|
|
@@ -12670,6 +12663,15 @@ var LeaferUI = (function (exports) {
|
|
|
12670
12663
|
|
|
12671
12664
|
const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
|
|
12672
12665
|
class EditBox extends exports.Group {
|
|
12666
|
+
get mergeConfig() {
|
|
12667
|
+
const { config } = this, { mergeConfig } = this.editor;
|
|
12668
|
+
return this.mergedConfig = config ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
|
|
12669
|
+
}
|
|
12670
|
+
get target() { return this._target || this.editor.element; }
|
|
12671
|
+
set target(target) { this._target = target; }
|
|
12672
|
+
get single() { return !!this._target || this.editor.single; }
|
|
12673
|
+
get transformTool() { return this._transformTool || this.editor; }
|
|
12674
|
+
set transformTool(tool) { this._transformTool = tool; }
|
|
12673
12675
|
get flipped() { return this.flippedX || this.flippedY; }
|
|
12674
12676
|
get flippedX() { return this.scaleX < 0; }
|
|
12675
12677
|
get flippedY() { return this.scaleY < 0; }
|
|
@@ -12712,8 +12714,7 @@ var LeaferUI = (function (exports) {
|
|
|
12712
12714
|
this.add(view);
|
|
12713
12715
|
}
|
|
12714
12716
|
load() {
|
|
12715
|
-
const {
|
|
12716
|
-
const { rect, circle, resizePoints } = this;
|
|
12717
|
+
const { target, mergeConfig, single, rect, circle, resizePoints } = this;
|
|
12717
12718
|
const { stroke, strokeWidth } = mergeConfig;
|
|
12718
12719
|
const pointsStyle = this.getPointsStyle();
|
|
12719
12720
|
const middlePointsStyle = this.getMiddlePointsStyle();
|
|
@@ -12726,18 +12727,26 @@ var LeaferUI = (function (exports) {
|
|
|
12726
12727
|
}
|
|
12727
12728
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
12728
12729
|
rect.set(Object.assign({ stroke, strokeWidth, editConfig }, (mergeConfig.rect || {})));
|
|
12729
|
-
|
|
12730
|
-
rect.
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12730
|
+
const syncEventer = single && this.transformTool.editTool;
|
|
12731
|
+
rect.hittable = !syncEventer;
|
|
12732
|
+
rect.syncEventer = syncEventer && this.editor;
|
|
12733
|
+
if (syncEventer) {
|
|
12734
|
+
target.syncEventer = rect;
|
|
12735
|
+
this.app.interaction.bottomList = [{ target: rect, proxy: target }];
|
|
12734
12736
|
}
|
|
12737
|
+
updateMoveCursor(this);
|
|
12738
|
+
}
|
|
12739
|
+
update() {
|
|
12740
|
+
const { editor } = this;
|
|
12741
|
+
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = this.target.getLayoutBounds('box', editor, true);
|
|
12742
|
+
this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
12743
|
+
this.updateBounds({ x: 0, y: 0, width, height });
|
|
12735
12744
|
}
|
|
12736
|
-
|
|
12737
|
-
const {
|
|
12738
|
-
const { mergeConfig,
|
|
12745
|
+
updateBounds(bounds) {
|
|
12746
|
+
const { editMask } = this.editor;
|
|
12747
|
+
const { mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
|
|
12739
12748
|
const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
|
|
12740
|
-
this.visible = !
|
|
12749
|
+
this.visible = !this.target.locked;
|
|
12741
12750
|
editMask.visible = mask ? true : 0;
|
|
12742
12751
|
if (this.view.worldOpacity) {
|
|
12743
12752
|
const { width, height } = bounds;
|
|
@@ -12771,25 +12780,25 @@ var LeaferUI = (function (exports) {
|
|
|
12771
12780
|
}
|
|
12772
12781
|
circle.visible = showPoints && rotateable && !!(mergeConfig.circle || mergeConfig.rotatePoint);
|
|
12773
12782
|
if (circle.visible)
|
|
12774
|
-
this.layoutCircle(
|
|
12783
|
+
this.layoutCircle();
|
|
12775
12784
|
if (rect.path)
|
|
12776
12785
|
rect.path = null;
|
|
12777
|
-
rect.set(Object.assign(Object.assign({}, bounds), { visible:
|
|
12786
|
+
rect.set(Object.assign(Object.assign({}, bounds), { visible: single ? editBox : true }));
|
|
12778
12787
|
buttons.visible = showPoints && buttons.children.length > 0 || 0;
|
|
12779
12788
|
if (buttons.visible)
|
|
12780
|
-
this.layoutButtons(
|
|
12789
|
+
this.layoutButtons();
|
|
12781
12790
|
}
|
|
12782
12791
|
else
|
|
12783
12792
|
rect.set(bounds);
|
|
12784
12793
|
}
|
|
12785
|
-
layoutCircle(
|
|
12786
|
-
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } =
|
|
12794
|
+
layoutCircle() {
|
|
12795
|
+
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } = this.mergedConfig;
|
|
12787
12796
|
const direction = fourDirection.indexOf(circleDirection || ((this.buttons.children.length && buttonsDirection === 'bottom') ? 'top' : 'bottom'));
|
|
12788
12797
|
this.setButtonPosition(this.circle, direction, circleMargin || buttonsMargin, !!middlePoint);
|
|
12789
12798
|
}
|
|
12790
|
-
layoutButtons(
|
|
12799
|
+
layoutButtons() {
|
|
12791
12800
|
const { buttons } = this;
|
|
12792
|
-
const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } =
|
|
12801
|
+
const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } = this.mergedConfig;
|
|
12793
12802
|
const { flippedX, flippedY } = this;
|
|
12794
12803
|
let index = fourDirection.indexOf(buttonsDirection);
|
|
12795
12804
|
if ((index % 2 && flippedX) || ((index + 1) % 2 && flippedY)) {
|
|
@@ -12822,16 +12831,16 @@ var LeaferUI = (function (exports) {
|
|
|
12822
12831
|
this.visible = false;
|
|
12823
12832
|
}
|
|
12824
12833
|
getPointStyle(userStyle) {
|
|
12825
|
-
const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.
|
|
12834
|
+
const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.mergedConfig;
|
|
12826
12835
|
const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0, editConfig };
|
|
12827
12836
|
return userStyle ? Object.assign(defaultStyle, userStyle) : defaultStyle;
|
|
12828
12837
|
}
|
|
12829
12838
|
getPointsStyle() {
|
|
12830
|
-
const { point } = this.
|
|
12839
|
+
const { point } = this.mergedConfig;
|
|
12831
12840
|
return point instanceof Array ? point : [point];
|
|
12832
12841
|
}
|
|
12833
12842
|
getMiddlePointsStyle() {
|
|
12834
|
-
const { middlePoint } = this.
|
|
12843
|
+
const { middlePoint } = this.mergedConfig;
|
|
12835
12844
|
return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
|
|
12836
12845
|
}
|
|
12837
12846
|
onSelect(e) {
|
|
@@ -12844,16 +12853,16 @@ var LeaferUI = (function (exports) {
|
|
|
12844
12853
|
onDragStart(e) {
|
|
12845
12854
|
this.dragging = true;
|
|
12846
12855
|
const point = this.dragPoint = e.current, { pointType } = point;
|
|
12847
|
-
const { editor, dragStartData } = this, {
|
|
12856
|
+
const { editor, dragStartData } = this, { target } = this;
|
|
12848
12857
|
if (point.name === 'rect') {
|
|
12849
12858
|
this.moving = true;
|
|
12850
|
-
editor.opacity =
|
|
12859
|
+
editor.opacity = this.mergeConfig.hideOnMove ? 0 : 1;
|
|
12851
12860
|
}
|
|
12852
12861
|
dragStartData.x = e.x;
|
|
12853
12862
|
dragStartData.y = e.y;
|
|
12854
|
-
dragStartData.point = { x:
|
|
12855
|
-
dragStartData.bounds = Object.assign({},
|
|
12856
|
-
dragStartData.rotation =
|
|
12863
|
+
dragStartData.point = { x: target.x, y: target.y };
|
|
12864
|
+
dragStartData.bounds = Object.assign({}, target.getLayoutBounds('box', 'local'));
|
|
12865
|
+
dragStartData.rotation = target.rotation;
|
|
12857
12866
|
if (pointType && pointType.includes('resize'))
|
|
12858
12867
|
ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
12859
12868
|
}
|
|
@@ -12868,22 +12877,31 @@ var LeaferUI = (function (exports) {
|
|
|
12868
12877
|
ResizeEvent.resizingKeys = null;
|
|
12869
12878
|
}
|
|
12870
12879
|
onDrag(e) {
|
|
12871
|
-
const {
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12880
|
+
const { transformTool } = this, point = e.current;
|
|
12881
|
+
if (point.name === 'rect') {
|
|
12882
|
+
transformTool.onMove(e);
|
|
12883
|
+
updateMoveCursor(this);
|
|
12884
|
+
}
|
|
12885
|
+
else {
|
|
12886
|
+
const { pointType } = this.enterPoint = point;
|
|
12887
|
+
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !this.mergeConfig.resizeable) {
|
|
12888
|
+
transformTool.onRotate(e);
|
|
12889
|
+
if (pointType === 'resize-rotate')
|
|
12890
|
+
transformTool.onScale(e);
|
|
12891
|
+
}
|
|
12892
|
+
else if (pointType === 'resize')
|
|
12893
|
+
transformTool.onScale(e);
|
|
12894
|
+
if (pointType === 'skew')
|
|
12895
|
+
transformTool.onSkew(e);
|
|
12896
|
+
updateCursor(this, e);
|
|
12897
|
+
}
|
|
12898
|
+
}
|
|
12899
|
+
onKey(e) {
|
|
12900
|
+
updateCursor(this, e);
|
|
12883
12901
|
}
|
|
12884
12902
|
onArrow(e) {
|
|
12885
12903
|
const { editor } = this;
|
|
12886
|
-
if (editor.editing &&
|
|
12904
|
+
if (editor.editing && this.mergeConfig.keyEvent) {
|
|
12887
12905
|
let x = 0, y = 0;
|
|
12888
12906
|
const distance = e.shiftKey ? 10 : 1;
|
|
12889
12907
|
switch (e.code) {
|
|
@@ -12904,27 +12922,28 @@ var LeaferUI = (function (exports) {
|
|
|
12904
12922
|
}
|
|
12905
12923
|
}
|
|
12906
12924
|
onDoubleTap(e) {
|
|
12907
|
-
|
|
12925
|
+
const { openInner, preventEditInner } = this.mergeConfig;
|
|
12926
|
+
if (openInner === 'double' && !preventEditInner)
|
|
12908
12927
|
this.openInner(e);
|
|
12909
12928
|
}
|
|
12910
12929
|
onLongPress(e) {
|
|
12911
|
-
|
|
12930
|
+
const { openInner, preventEditInner } = this.mergeConfig;
|
|
12931
|
+
if (openInner === 'long' && preventEditInner)
|
|
12912
12932
|
this.openInner(e);
|
|
12913
12933
|
}
|
|
12914
12934
|
openInner(e) {
|
|
12915
|
-
const { editor } = this;
|
|
12916
|
-
if (
|
|
12917
|
-
|
|
12918
|
-
if (element.locked)
|
|
12935
|
+
const { editor, target } = this;
|
|
12936
|
+
if (this.single) {
|
|
12937
|
+
if (target.locked)
|
|
12919
12938
|
return;
|
|
12920
|
-
if (
|
|
12921
|
-
if (
|
|
12922
|
-
const { children } =
|
|
12939
|
+
if (target.isBranch && !target.editInner) {
|
|
12940
|
+
if (target.textBox) {
|
|
12941
|
+
const { children } = target;
|
|
12923
12942
|
const find = children.find(item => item.editable && item instanceof exports.Text) || children.find(item => item instanceof exports.Text);
|
|
12924
12943
|
if (find)
|
|
12925
12944
|
return editor.openInnerEditor(find);
|
|
12926
12945
|
}
|
|
12927
|
-
editor.openGroup(
|
|
12946
|
+
editor.openGroup(target);
|
|
12928
12947
|
editor.target = editor.selector.findDeepOne(e);
|
|
12929
12948
|
}
|
|
12930
12949
|
else {
|
|
@@ -12933,7 +12952,6 @@ var LeaferUI = (function (exports) {
|
|
|
12933
12952
|
}
|
|
12934
12953
|
}
|
|
12935
12954
|
listenPointEvents(point, type, direction) {
|
|
12936
|
-
const { editor } = this;
|
|
12937
12955
|
point.direction = direction;
|
|
12938
12956
|
point.pointType = type;
|
|
12939
12957
|
const events = [
|
|
@@ -12943,19 +12961,25 @@ var LeaferUI = (function (exports) {
|
|
|
12943
12961
|
[exports.PointerEvent.LEAVE, () => { this.enterPoint = null; }],
|
|
12944
12962
|
];
|
|
12945
12963
|
if (point.name !== 'circle')
|
|
12946
|
-
events.push([exports.PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(
|
|
12964
|
+
events.push([exports.PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(this, e); }]);
|
|
12947
12965
|
this.__eventIds.push(point.on_(events));
|
|
12948
12966
|
}
|
|
12949
12967
|
__listenEvents() {
|
|
12950
|
-
const { rect, editor } = this;
|
|
12951
|
-
|
|
12968
|
+
const { rect, editor, __eventIds: events } = this;
|
|
12969
|
+
events.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
|
|
12952
12970
|
[exports.DragEvent.START, this.onDragStart, this],
|
|
12953
|
-
[exports.DragEvent.DRAG,
|
|
12971
|
+
[exports.DragEvent.DRAG, this.onDrag, this],
|
|
12954
12972
|
[exports.DragEvent.END, this.onDragEnd, this],
|
|
12955
|
-
[exports.PointerEvent.ENTER, () => updateMoveCursor(
|
|
12973
|
+
[exports.PointerEvent.ENTER, () => updateMoveCursor(this)],
|
|
12956
12974
|
[exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this],
|
|
12957
12975
|
[exports.PointerEvent.LONG_PRESS, this.onLongPress, this]
|
|
12958
12976
|
]));
|
|
12977
|
+
this.waitLeafer(() => {
|
|
12978
|
+
events.push(editor.app.on_([
|
|
12979
|
+
[[exports.KeyEvent.HOLD, exports.KeyEvent.UP], this.onKey, this],
|
|
12980
|
+
[exports.KeyEvent.DOWN, this.onArrow, this]
|
|
12981
|
+
]));
|
|
12982
|
+
});
|
|
12959
12983
|
}
|
|
12960
12984
|
__removeListenEvents() {
|
|
12961
12985
|
this.off_(this.__eventIds);
|
|
@@ -12986,11 +13010,12 @@ var LeaferUI = (function (exports) {
|
|
|
12986
13010
|
if (options.bounds && !options.bounds.hit(editor.editBox.rect.__world, options.matrix))
|
|
12987
13011
|
return;
|
|
12988
13012
|
canvas.saveBlendMode('destination-out');
|
|
13013
|
+
options = Object.assign(Object.assign({}, options), { shape: true });
|
|
12989
13014
|
editor.list.forEach(item => {
|
|
12990
|
-
item.
|
|
12991
|
-
const {
|
|
12992
|
-
if (
|
|
12993
|
-
|
|
13015
|
+
item.__render(canvas, options);
|
|
13016
|
+
const { parent } = item;
|
|
13017
|
+
if (parent && parent.textBox)
|
|
13018
|
+
parent.__renderShape(canvas, options);
|
|
12994
13019
|
});
|
|
12995
13020
|
canvas.restoreBlendMode();
|
|
12996
13021
|
}
|
|
@@ -13085,7 +13110,7 @@ ${filterStyle$1}
|
|
|
13085
13110
|
const bounds$1 = new Bounds();
|
|
13086
13111
|
function simulate(editor) {
|
|
13087
13112
|
const { simulateTarget, list } = editor;
|
|
13088
|
-
const { zoomLayer } = list[0].leafer
|
|
13113
|
+
const { zoomLayer } = list[0].leafer;
|
|
13089
13114
|
simulateTarget.safeChange(() => {
|
|
13090
13115
|
bounds$1.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page'));
|
|
13091
13116
|
if (bounds$1.width === 0)
|
|
@@ -13107,15 +13132,14 @@ ${filterStyle$1}
|
|
|
13107
13132
|
else {
|
|
13108
13133
|
editor.simulateTarget.remove();
|
|
13109
13134
|
editor.leafList.reset();
|
|
13110
|
-
editor.closeInnerEditor();
|
|
13111
13135
|
}
|
|
13112
|
-
editor.
|
|
13136
|
+
editor.closeInnerEditor();
|
|
13137
|
+
const data = { editor, value: target, oldValue };
|
|
13138
|
+
editor.emitEvent(new EditorEvent(EditorEvent.SELECT, data));
|
|
13113
13139
|
editor.checkOpenedGroups();
|
|
13114
13140
|
if (editor.editing) {
|
|
13115
13141
|
editor.waitLeafer(() => {
|
|
13116
|
-
updateMoveCursor(editor);
|
|
13117
13142
|
editor.updateEditTool();
|
|
13118
|
-
editor.update();
|
|
13119
13143
|
editor.listenTargetEvents();
|
|
13120
13144
|
});
|
|
13121
13145
|
}
|
|
@@ -13123,6 +13147,7 @@ ${filterStyle$1}
|
|
|
13123
13147
|
editor.updateEditTool();
|
|
13124
13148
|
editor.removeTargetEvents();
|
|
13125
13149
|
}
|
|
13150
|
+
editor.emitEvent(new EditorEvent(EditorEvent.AFTER_SELECT, data));
|
|
13126
13151
|
}
|
|
13127
13152
|
function onHover(editor, oldValue) {
|
|
13128
13153
|
editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
|
|
@@ -13294,93 +13319,45 @@ ${filterStyle$1}
|
|
|
13294
13319
|
}
|
|
13295
13320
|
}
|
|
13296
13321
|
|
|
13297
|
-
class
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
get editing() { return !!this.list.length; }
|
|
13301
|
-
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13302
|
-
get multiple() { return this.list.length > 1; }
|
|
13303
|
-
get single() { return this.list.length === 1; }
|
|
13304
|
-
get dragging() { return this.editBox.dragging; }
|
|
13305
|
-
get moving() { return this.editBox.moving; }
|
|
13306
|
-
get dragPoint() { return this.editBox.dragPoint; }
|
|
13307
|
-
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13308
|
-
get buttons() { return this.editBox.buttons; }
|
|
13309
|
-
constructor(userConfig, data) {
|
|
13310
|
-
super(data);
|
|
13311
|
-
this.leafList = new LeafList();
|
|
13312
|
-
this.openedGroupList = new LeafList();
|
|
13313
|
-
this.simulateTarget = new SimulateElement(this);
|
|
13314
|
-
this.editBox = new EditBox(this);
|
|
13315
|
-
this.editToolList = {};
|
|
13316
|
-
this.selector = new EditSelect(this);
|
|
13317
|
-
this.editMask = new EditMask(this);
|
|
13318
|
-
this.targetEventIds = [];
|
|
13319
|
-
let mergedConfig = DataHelper.clone(config);
|
|
13320
|
-
if (userConfig)
|
|
13321
|
-
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
13322
|
-
this.mergedConfig = this.config = mergedConfig;
|
|
13323
|
-
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13324
|
-
if (!Plugin.has('resize'))
|
|
13325
|
-
this.config.editSize = 'scale';
|
|
13326
|
-
}
|
|
13327
|
-
select(target) {
|
|
13328
|
-
this.target = target;
|
|
13329
|
-
}
|
|
13330
|
-
cancel() {
|
|
13331
|
-
this.target = null;
|
|
13332
|
-
}
|
|
13333
|
-
hasItem(item) {
|
|
13334
|
-
return this.leafList.has(item);
|
|
13335
|
-
}
|
|
13336
|
-
addItem(item) {
|
|
13337
|
-
if (!this.hasItem(item) && !item.locked)
|
|
13338
|
-
this.leafList.add(item), this.target = this.leafList.list;
|
|
13339
|
-
}
|
|
13340
|
-
removeItem(item) {
|
|
13341
|
-
if (this.hasItem(item))
|
|
13342
|
-
this.leafList.remove(item), this.target = this.leafList.list;
|
|
13343
|
-
}
|
|
13344
|
-
shiftItem(item) {
|
|
13345
|
-
this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
|
|
13346
|
-
}
|
|
13347
|
-
update() {
|
|
13348
|
-
if (this.editing) {
|
|
13349
|
-
if (!this.element.parent)
|
|
13350
|
-
return this.cancel();
|
|
13351
|
-
if (this.innerEditing)
|
|
13352
|
-
this.innerEditor.update();
|
|
13353
|
-
this.editTool.update();
|
|
13354
|
-
this.selector.update();
|
|
13355
|
-
}
|
|
13322
|
+
class EditorMoveEvent extends EditorEvent {
|
|
13323
|
+
constructor(type, data) {
|
|
13324
|
+
super(type, data);
|
|
13356
13325
|
}
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13326
|
+
}
|
|
13327
|
+
EditorMoveEvent.BEFORE_MOVE = 'editor.before_move';
|
|
13328
|
+
EditorMoveEvent.MOVE = 'editor.move';
|
|
13329
|
+
|
|
13330
|
+
class EditorScaleEvent extends EditorEvent {
|
|
13331
|
+
constructor(type, data) {
|
|
13332
|
+
super(type, data);
|
|
13361
13333
|
}
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
if (this.editing) {
|
|
13370
|
-
const tag = this.single ? this.list[0].editOuter : 'EditTool';
|
|
13371
|
-
this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
|
|
13372
|
-
this.editBox.load();
|
|
13373
|
-
this.editTool.load();
|
|
13374
|
-
}
|
|
13334
|
+
}
|
|
13335
|
+
EditorScaleEvent.BEFORE_SCALE = 'editor.before_scale';
|
|
13336
|
+
EditorScaleEvent.SCALE = 'editor.scale';
|
|
13337
|
+
|
|
13338
|
+
class EditorRotateEvent extends EditorEvent {
|
|
13339
|
+
constructor(type, data) {
|
|
13340
|
+
super(type, data);
|
|
13375
13341
|
}
|
|
13376
|
-
|
|
13377
|
-
|
|
13342
|
+
}
|
|
13343
|
+
EditorRotateEvent.BEFORE_ROTATE = 'editor.before_rotate';
|
|
13344
|
+
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
13345
|
+
|
|
13346
|
+
class EditorSkewEvent extends EditorEvent {
|
|
13347
|
+
constructor(type, data) {
|
|
13348
|
+
super(type, data);
|
|
13378
13349
|
}
|
|
13350
|
+
}
|
|
13351
|
+
EditorSkewEvent.BEFORE_SKEW = 'editor.before_skew';
|
|
13352
|
+
EditorSkewEvent.SKEW = 'editor.skew';
|
|
13353
|
+
|
|
13354
|
+
class TransformTool {
|
|
13379
13355
|
onMove(e) {
|
|
13356
|
+
const { target, mergeConfig, dragStartData } = this.editBox;
|
|
13380
13357
|
if (e instanceof exports.MoveEvent) {
|
|
13381
13358
|
if (e.moveType !== 'drag') {
|
|
13382
|
-
const { moveable, resizeable } =
|
|
13383
|
-
const move = e.getLocalMove(
|
|
13359
|
+
const { moveable, resizeable } = mergeConfig;
|
|
13360
|
+
const move = e.getLocalMove(target);
|
|
13384
13361
|
if (moveable === 'move')
|
|
13385
13362
|
e.stop(), this.move(move.x, move.y);
|
|
13386
13363
|
else if (resizeable === 'zoom')
|
|
@@ -13395,22 +13372,22 @@ ${filterStyle$1}
|
|
|
13395
13372
|
else
|
|
13396
13373
|
total.x = 0;
|
|
13397
13374
|
}
|
|
13398
|
-
this.move(exports.DragEvent.getValidMove(
|
|
13375
|
+
this.move(exports.DragEvent.getValidMove(target, dragStartData.point, total));
|
|
13399
13376
|
}
|
|
13400
13377
|
}
|
|
13401
13378
|
onScale(e) {
|
|
13402
|
-
const {
|
|
13403
|
-
let { around, lockRatio, resizeable, flipable, editSize } =
|
|
13379
|
+
const { target, mergeConfig, single, dragStartData } = this.editBox;
|
|
13380
|
+
let { around, lockRatio, resizeable, flipable, editSize } = mergeConfig;
|
|
13404
13381
|
if (e instanceof exports.ZoomEvent) {
|
|
13405
13382
|
if (resizeable === 'zoom')
|
|
13406
|
-
e.stop(), this.scaleOf(
|
|
13383
|
+
e.stop(), this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
|
|
13407
13384
|
}
|
|
13408
13385
|
else {
|
|
13409
13386
|
const { direction } = e.current;
|
|
13410
|
-
if (e.shiftKey ||
|
|
13387
|
+
if (e.shiftKey || target.lockRatio)
|
|
13411
13388
|
lockRatio = true;
|
|
13412
|
-
const data = EditDataHelper.getScaleData(
|
|
13413
|
-
if (this.editTool.onScaleWithDrag) {
|
|
13389
|
+
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, e.getInnerTotal(target), lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === 'scale');
|
|
13390
|
+
if (this.editTool && this.editTool.onScaleWithDrag) {
|
|
13414
13391
|
data.drag = e;
|
|
13415
13392
|
this.scaleWithDrag(data);
|
|
13416
13393
|
}
|
|
@@ -13420,38 +13397,38 @@ ${filterStyle$1}
|
|
|
13420
13397
|
}
|
|
13421
13398
|
}
|
|
13422
13399
|
onRotate(e) {
|
|
13423
|
-
const {
|
|
13400
|
+
const { target, mergeConfig, dragStartData } = this.editBox;
|
|
13401
|
+
const { skewable, rotateable, around, rotateGap } = mergeConfig;
|
|
13424
13402
|
const { direction, name } = e.current;
|
|
13425
13403
|
if (skewable && name === 'resize-line')
|
|
13426
13404
|
return this.onSkew(e);
|
|
13427
|
-
const { element } = this, { dragStartData } = this.editBox;
|
|
13428
13405
|
let origin, rotation;
|
|
13429
13406
|
if (e instanceof exports.RotateEvent) {
|
|
13430
13407
|
if (rotateable === 'rotate')
|
|
13431
|
-
e.stop(), rotation = e.rotation, origin =
|
|
13408
|
+
e.stop(), rotation = e.rotation, origin = target.getBoxPoint(e);
|
|
13432
13409
|
else
|
|
13433
13410
|
return;
|
|
13434
|
-
if (
|
|
13411
|
+
if (target.scaleX * target.scaleY < 0)
|
|
13435
13412
|
rotation = -rotation;
|
|
13436
13413
|
}
|
|
13437
13414
|
else {
|
|
13438
|
-
const data = EditDataHelper.getRotateData(
|
|
13415
|
+
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (target.around || target.origin || around || 'center'));
|
|
13439
13416
|
rotation = data.rotation;
|
|
13440
13417
|
origin = data.origin;
|
|
13441
13418
|
}
|
|
13442
|
-
if (
|
|
13419
|
+
if (target.scaleX * target.scaleY < 0)
|
|
13443
13420
|
rotation = -rotation;
|
|
13444
13421
|
if (e instanceof exports.DragEvent)
|
|
13445
|
-
rotation = dragStartData.rotation + rotation -
|
|
13446
|
-
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap,
|
|
13422
|
+
rotation = dragStartData.rotation + rotation - target.rotation;
|
|
13423
|
+
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
|
|
13447
13424
|
if (!rotation)
|
|
13448
13425
|
return;
|
|
13449
13426
|
this.rotateOf(origin, rotation);
|
|
13450
13427
|
}
|
|
13451
13428
|
onSkew(e) {
|
|
13452
|
-
const {
|
|
13453
|
-
const { around } =
|
|
13454
|
-
const { origin, skewX, skewY } = EditDataHelper.getSkewData(
|
|
13429
|
+
const { target, mergeConfig } = this.editBox;
|
|
13430
|
+
const { around } = mergeConfig;
|
|
13431
|
+
const { origin, skewX, skewY } = EditDataHelper.getSkewData(target.boxBounds, e.current.direction, e.getInnerMove(target), EditDataHelper.getAround(around, e.altKey));
|
|
13455
13432
|
if (!skewX && !skewY)
|
|
13456
13433
|
return;
|
|
13457
13434
|
this.skewOf(origin, skewX, skewY);
|
|
@@ -13461,7 +13438,8 @@ ${filterStyle$1}
|
|
|
13461
13438
|
return;
|
|
13462
13439
|
if (typeof x === 'object')
|
|
13463
13440
|
y = x.y, x = x.x;
|
|
13464
|
-
const {
|
|
13441
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13442
|
+
const { beforeMove } = mergeConfig;
|
|
13465
13443
|
if (beforeMove) {
|
|
13466
13444
|
const check = beforeMove({ target, x, y });
|
|
13467
13445
|
if (typeof check === 'object')
|
|
@@ -13470,25 +13448,26 @@ ${filterStyle$1}
|
|
|
13470
13448
|
return;
|
|
13471
13449
|
}
|
|
13472
13450
|
const world = target.getWorldPointByLocal({ x, y }, null, true);
|
|
13473
|
-
if (
|
|
13451
|
+
if (!single)
|
|
13474
13452
|
target.safeChange(() => target.move(x, y));
|
|
13475
|
-
const data = { target, editor
|
|
13453
|
+
const data = { target, editor, moveX: world.x, moveY: world.y };
|
|
13476
13454
|
this.emitEvent(new EditorMoveEvent(EditorMoveEvent.BEFORE_MOVE, data));
|
|
13477
13455
|
const event = new EditorMoveEvent(EditorMoveEvent.MOVE, data);
|
|
13478
|
-
this.
|
|
13456
|
+
this.doMove(event);
|
|
13479
13457
|
this.emitEvent(event);
|
|
13480
13458
|
}
|
|
13481
13459
|
scaleWithDrag(data) {
|
|
13482
13460
|
if (!this.checkTransform('resizeable'))
|
|
13483
13461
|
return;
|
|
13484
|
-
const {
|
|
13462
|
+
const { target, mergeConfig, editor } = this.editBox;
|
|
13463
|
+
const { beforeScale } = mergeConfig;
|
|
13485
13464
|
if (beforeScale) {
|
|
13486
13465
|
const { origin, scaleX, scaleY, drag } = data;
|
|
13487
13466
|
const check = beforeScale({ target, drag, origin, scaleX, scaleY });
|
|
13488
13467
|
if (check === false)
|
|
13489
13468
|
return;
|
|
13490
13469
|
}
|
|
13491
|
-
data = Object.assign(Object.assign({}, data), { target, editor
|
|
13470
|
+
data = Object.assign(Object.assign({}, data), { target, editor, worldOrigin: target.getWorldPoint(data.origin) });
|
|
13492
13471
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13493
13472
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13494
13473
|
this.editTool.onScaleWithDrag(event);
|
|
@@ -13497,7 +13476,8 @@ ${filterStyle$1}
|
|
|
13497
13476
|
scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
|
|
13498
13477
|
if (!this.checkTransform('resizeable'))
|
|
13499
13478
|
return;
|
|
13500
|
-
const {
|
|
13479
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13480
|
+
const { beforeScale } = mergeConfig;
|
|
13501
13481
|
if (beforeScale) {
|
|
13502
13482
|
const check = beforeScale({ target, origin, scaleX, scaleY });
|
|
13503
13483
|
if (typeof check === 'object')
|
|
@@ -13506,29 +13486,30 @@ ${filterStyle$1}
|
|
|
13506
13486
|
return;
|
|
13507
13487
|
}
|
|
13508
13488
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13509
|
-
const transform =
|
|
13510
|
-
const data = { target, editor
|
|
13489
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.scaleOf(origin, scaleX, scaleY)));
|
|
13490
|
+
const data = { target, editor, worldOrigin, scaleX, scaleY, transform };
|
|
13511
13491
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13512
13492
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13513
|
-
this.
|
|
13493
|
+
this.doScale(event);
|
|
13514
13494
|
this.emitEvent(event);
|
|
13515
13495
|
}
|
|
13516
13496
|
flip(axis) {
|
|
13517
13497
|
if (!this.checkTransform('resizeable'))
|
|
13518
13498
|
return;
|
|
13519
|
-
const {
|
|
13499
|
+
const { target, single, editor } = this.editBox;
|
|
13520
13500
|
const worldOrigin = this.getWorldOrigin('center');
|
|
13521
|
-
const transform =
|
|
13522
|
-
const data = { target
|
|
13501
|
+
const transform = !single ? this.getChangedTransform(() => target.safeChange(() => target.flip(axis))) : new Matrix(LeafHelper.getFlipTransform(target, axis));
|
|
13502
|
+
const data = { target, editor, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform };
|
|
13523
13503
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13524
13504
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13525
|
-
this.
|
|
13505
|
+
this.doScale(event);
|
|
13526
13506
|
this.emitEvent(event);
|
|
13527
13507
|
}
|
|
13528
13508
|
rotateOf(origin, rotation) {
|
|
13529
13509
|
if (!this.checkTransform('rotateable'))
|
|
13530
13510
|
return;
|
|
13531
|
-
const {
|
|
13511
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13512
|
+
const { beforeRotate } = mergeConfig;
|
|
13532
13513
|
if (beforeRotate) {
|
|
13533
13514
|
const check = beforeRotate({ target, origin, rotation });
|
|
13534
13515
|
if (typeof check === 'number')
|
|
@@ -13537,17 +13518,18 @@ ${filterStyle$1}
|
|
|
13537
13518
|
return;
|
|
13538
13519
|
}
|
|
13539
13520
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13540
|
-
const transform =
|
|
13541
|
-
const data = { target, editor
|
|
13521
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.rotateOf(origin, rotation)));
|
|
13522
|
+
const data = { target, editor, worldOrigin, rotation, transform };
|
|
13542
13523
|
this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data));
|
|
13543
13524
|
const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data);
|
|
13544
|
-
this.
|
|
13525
|
+
this.doRotate(event);
|
|
13545
13526
|
this.emitEvent(event);
|
|
13546
13527
|
}
|
|
13547
13528
|
skewOf(origin, skewX, skewY = 0, _resize) {
|
|
13548
13529
|
if (!this.checkTransform('skewable'))
|
|
13549
13530
|
return;
|
|
13550
|
-
const {
|
|
13531
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13532
|
+
const { beforeSkew } = mergeConfig;
|
|
13551
13533
|
if (beforeSkew) {
|
|
13552
13534
|
const check = beforeSkew({ target, origin, skewX, skewY });
|
|
13553
13535
|
if (typeof check === 'object')
|
|
@@ -13556,25 +13538,142 @@ ${filterStyle$1}
|
|
|
13556
13538
|
return;
|
|
13557
13539
|
}
|
|
13558
13540
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13559
|
-
const transform =
|
|
13560
|
-
const data = { target, editor
|
|
13541
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.skewOf(origin, skewX, skewY)));
|
|
13542
|
+
const data = { target, editor, worldOrigin, skewX, skewY, transform };
|
|
13561
13543
|
this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data));
|
|
13562
13544
|
const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data);
|
|
13563
|
-
this.
|
|
13545
|
+
this.doSkew(event);
|
|
13564
13546
|
this.emitEvent(event);
|
|
13565
13547
|
}
|
|
13566
|
-
|
|
13548
|
+
doMove(event) {
|
|
13549
|
+
this.editTool.onMove(event);
|
|
13550
|
+
}
|
|
13551
|
+
doScale(event) {
|
|
13552
|
+
this.editTool.onScale(event);
|
|
13553
|
+
}
|
|
13554
|
+
doRotate(event) {
|
|
13555
|
+
this.editTool.onRotate(event);
|
|
13556
|
+
}
|
|
13557
|
+
doSkew(event) {
|
|
13558
|
+
this.editTool.onSkew(event);
|
|
13559
|
+
}
|
|
13560
|
+
checkTransform(type) {
|
|
13561
|
+
const { target, mergeConfig } = this.editBox;
|
|
13562
|
+
return target && !target.locked && mergeConfig[type];
|
|
13563
|
+
}
|
|
13567
13564
|
getWorldOrigin(origin) {
|
|
13568
|
-
|
|
13565
|
+
const { target } = this.editBox;
|
|
13566
|
+
return target.getWorldPoint(LeafHelper.getInnerOrigin(target, origin));
|
|
13569
13567
|
}
|
|
13570
13568
|
getChangedTransform(func) {
|
|
13571
|
-
const {
|
|
13572
|
-
if (
|
|
13573
|
-
return
|
|
13574
|
-
const oldMatrix = new Matrix(
|
|
13569
|
+
const { target, single } = this.editBox;
|
|
13570
|
+
if (!single && !target.canChange)
|
|
13571
|
+
return target.changedTransform;
|
|
13572
|
+
const oldMatrix = new Matrix(target.worldTransform);
|
|
13575
13573
|
func();
|
|
13576
|
-
return new Matrix(
|
|
13574
|
+
return new Matrix(target.worldTransform).divide(oldMatrix);
|
|
13575
|
+
}
|
|
13576
|
+
emitEvent(event, capture) {
|
|
13577
|
+
this.editBox.editor.emitEvent(event, capture);
|
|
13578
|
+
}
|
|
13579
|
+
}
|
|
13580
|
+
|
|
13581
|
+
exports.Editor = class Editor extends exports.Group {
|
|
13582
|
+
get list() { return this.leafList.list; }
|
|
13583
|
+
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
13584
|
+
get editing() { return !!this.list.length; }
|
|
13585
|
+
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13586
|
+
get multiple() { return this.list.length > 1; }
|
|
13587
|
+
get single() { return this.list.length === 1; }
|
|
13588
|
+
get dragging() { return this.editBox.dragging; }
|
|
13589
|
+
get moving() { return this.editBox.moving; }
|
|
13590
|
+
get dragPoint() { return this.editBox.dragPoint; }
|
|
13591
|
+
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13592
|
+
get buttons() { return this.editBox.buttons; }
|
|
13593
|
+
constructor(userConfig, data) {
|
|
13594
|
+
super(data);
|
|
13595
|
+
this.leafList = new LeafList();
|
|
13596
|
+
this.openedGroupList = new LeafList();
|
|
13597
|
+
this.simulateTarget = new SimulateElement(this);
|
|
13598
|
+
this.editBox = new EditBox(this);
|
|
13599
|
+
this.editToolList = {};
|
|
13600
|
+
this.selector = new EditSelect(this);
|
|
13601
|
+
this.editMask = new EditMask(this);
|
|
13602
|
+
this.targetEventIds = [];
|
|
13603
|
+
let mergedConfig = DataHelper.clone(config);
|
|
13604
|
+
if (userConfig)
|
|
13605
|
+
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
13606
|
+
this.mergedConfig = this.config = mergedConfig;
|
|
13607
|
+
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13608
|
+
if (!Plugin.has('resize'))
|
|
13609
|
+
this.config.editSize = 'scale';
|
|
13610
|
+
}
|
|
13611
|
+
select(target) {
|
|
13612
|
+
this.target = target;
|
|
13613
|
+
}
|
|
13614
|
+
cancel() {
|
|
13615
|
+
this.target = null;
|
|
13616
|
+
}
|
|
13617
|
+
hasItem(item) {
|
|
13618
|
+
return this.leafList.has(item);
|
|
13619
|
+
}
|
|
13620
|
+
addItem(item) {
|
|
13621
|
+
if (!this.hasItem(item) && !item.locked)
|
|
13622
|
+
this.leafList.add(item), this.target = this.leafList.list;
|
|
13623
|
+
}
|
|
13624
|
+
removeItem(item) {
|
|
13625
|
+
if (this.hasItem(item))
|
|
13626
|
+
this.leafList.remove(item), this.target = this.leafList.list;
|
|
13627
|
+
}
|
|
13628
|
+
shiftItem(item) {
|
|
13629
|
+
this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
|
|
13630
|
+
}
|
|
13631
|
+
update() {
|
|
13632
|
+
if (this.editing) {
|
|
13633
|
+
if (!this.element.parent)
|
|
13634
|
+
return this.cancel();
|
|
13635
|
+
if (this.innerEditing)
|
|
13636
|
+
this.innerEditor.update();
|
|
13637
|
+
this.editTool.update();
|
|
13638
|
+
this.selector.update();
|
|
13639
|
+
}
|
|
13640
|
+
}
|
|
13641
|
+
updateEditBox() {
|
|
13642
|
+
if (this.multiple)
|
|
13643
|
+
simulate(this);
|
|
13644
|
+
this.update();
|
|
13645
|
+
}
|
|
13646
|
+
updateEditTool() {
|
|
13647
|
+
let tool = this.editTool;
|
|
13648
|
+
if (tool) {
|
|
13649
|
+
this.editBox.unload();
|
|
13650
|
+
tool.unload();
|
|
13651
|
+
this.editTool = null;
|
|
13652
|
+
}
|
|
13653
|
+
if (this.editing) {
|
|
13654
|
+
const tag = this.element.editOuter || 'EditTool';
|
|
13655
|
+
tool = this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
|
|
13656
|
+
this.editBox.load();
|
|
13657
|
+
tool.load();
|
|
13658
|
+
this.update();
|
|
13659
|
+
}
|
|
13660
|
+
}
|
|
13661
|
+
getEditSize(_ui) {
|
|
13662
|
+
return this.mergeConfig.editSize;
|
|
13577
13663
|
}
|
|
13664
|
+
onMove(_e) { }
|
|
13665
|
+
onScale(_e) { }
|
|
13666
|
+
onRotate(_e) { }
|
|
13667
|
+
onSkew(_e) { }
|
|
13668
|
+
move(_x, _y = 0) { }
|
|
13669
|
+
scaleWithDrag(_data) { }
|
|
13670
|
+
scaleOf(_origin, scaleX, _scaleY = scaleX, _resize) { }
|
|
13671
|
+
flip(_axis) { }
|
|
13672
|
+
rotateOf(_origin, _rotation) { }
|
|
13673
|
+
skewOf(_origin, _skewX, _skewY = 0, _resize) { }
|
|
13674
|
+
checkTransform(_type) { return undefined; }
|
|
13675
|
+
getWorldOrigin(_origin) { return undefined; }
|
|
13676
|
+
getChangedTransform(_func) { return undefined; }
|
|
13578
13677
|
group(userGroup) {
|
|
13579
13678
|
if (this.multiple) {
|
|
13580
13679
|
this.emitGroupEvent(EditorGroupEvent.BEFORE_GROUP);
|
|
@@ -13692,12 +13791,9 @@ ${filterStyle$1}
|
|
|
13692
13791
|
if (this.targetChanged)
|
|
13693
13792
|
this.update();
|
|
13694
13793
|
}
|
|
13695
|
-
onKey(e) {
|
|
13696
|
-
updateCursor(this, e);
|
|
13697
|
-
}
|
|
13698
13794
|
listenTargetEvents() {
|
|
13699
13795
|
if (!this.targetEventIds.length) {
|
|
13700
|
-
const { app, leafer,
|
|
13796
|
+
const { app, leafer, editMask } = this;
|
|
13701
13797
|
this.targetEventIds = [
|
|
13702
13798
|
leafer.on_(RenderEvent.START, this.onRenderStart, this),
|
|
13703
13799
|
app.on_([
|
|
@@ -13705,8 +13801,6 @@ ${filterStyle$1}
|
|
|
13705
13801
|
[exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true],
|
|
13706
13802
|
[exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
|
|
13707
13803
|
[exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
|
|
13708
|
-
[[exports.KeyEvent.HOLD, exports.KeyEvent.UP], this.onKey, this],
|
|
13709
|
-
[exports.KeyEvent.DOWN, editBox.onArrow, editBox]
|
|
13710
13804
|
])
|
|
13711
13805
|
];
|
|
13712
13806
|
if (editMask.visible)
|
|
@@ -13731,24 +13825,29 @@ ${filterStyle$1}
|
|
|
13731
13825
|
super.destroy();
|
|
13732
13826
|
}
|
|
13733
13827
|
}
|
|
13734
|
-
}
|
|
13828
|
+
};
|
|
13735
13829
|
__decorate([
|
|
13736
13830
|
mergeConfigAttr()
|
|
13737
|
-
], Editor.prototype, "mergeConfig", void 0);
|
|
13831
|
+
], exports.Editor.prototype, "mergeConfig", void 0);
|
|
13738
13832
|
__decorate([
|
|
13739
13833
|
targetAttr(onHover)
|
|
13740
|
-
], Editor.prototype, "hoverTarget", void 0);
|
|
13834
|
+
], exports.Editor.prototype, "hoverTarget", void 0);
|
|
13741
13835
|
__decorate([
|
|
13742
13836
|
targetAttr(onTarget)
|
|
13743
|
-
], Editor.prototype, "target", void 0);
|
|
13837
|
+
], exports.Editor.prototype, "target", void 0);
|
|
13838
|
+
exports.Editor = __decorate([
|
|
13839
|
+
useModule(TransformTool, ['editBox', 'editTool', 'emitEvent'])
|
|
13840
|
+
], exports.Editor);
|
|
13744
13841
|
|
|
13745
13842
|
class InnerEditor {
|
|
13746
13843
|
static registerInnerEditor() {
|
|
13747
13844
|
EditToolCreator.register(this);
|
|
13748
13845
|
}
|
|
13749
13846
|
get tag() { return 'InnerEditor'; }
|
|
13847
|
+
get mode() { return 'focus'; }
|
|
13750
13848
|
get editBox() { return this.editor.editBox; }
|
|
13751
13849
|
constructor(editor) {
|
|
13850
|
+
this.eventIds = [];
|
|
13752
13851
|
this.editor = editor;
|
|
13753
13852
|
this.create();
|
|
13754
13853
|
}
|
|
@@ -13761,7 +13860,7 @@ ${filterStyle$1}
|
|
|
13761
13860
|
load() {
|
|
13762
13861
|
const { editor } = this;
|
|
13763
13862
|
if (editor) {
|
|
13764
|
-
if (editor.app)
|
|
13863
|
+
if (editor.app && this.mode === 'focus')
|
|
13765
13864
|
editor.selector.hittable = editor.app.tree.hitChildren = false;
|
|
13766
13865
|
this.onLoad();
|
|
13767
13866
|
}
|
|
@@ -13772,7 +13871,7 @@ ${filterStyle$1}
|
|
|
13772
13871
|
unload() {
|
|
13773
13872
|
const { editor } = this;
|
|
13774
13873
|
if (editor) {
|
|
13775
|
-
if (editor.app)
|
|
13874
|
+
if (editor.app && this.mode === 'focus')
|
|
13776
13875
|
editor.selector.hittable = editor.app.tree.hitChildren = true;
|
|
13777
13876
|
this.onUnload();
|
|
13778
13877
|
}
|
|
@@ -13846,10 +13945,7 @@ ${filterStyle$1}
|
|
|
13846
13945
|
this.onLoad();
|
|
13847
13946
|
}
|
|
13848
13947
|
update() {
|
|
13849
|
-
|
|
13850
|
-
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = editor.element.getLayoutBounds('box', editor, true);
|
|
13851
|
-
editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
13852
|
-
editBox.update({ x: 0, y: 0, width, height });
|
|
13948
|
+
this.editBox.update();
|
|
13853
13949
|
this.onUpdate();
|
|
13854
13950
|
}
|
|
13855
13951
|
unload() {
|
|
@@ -14186,7 +14282,7 @@ ${filterStyle$1}
|
|
|
14186
14282
|
|
|
14187
14283
|
Plugin.add('editor', 'resize');
|
|
14188
14284
|
Creator.editor = function (options, app) {
|
|
14189
|
-
const editor = new Editor(options);
|
|
14285
|
+
const editor = new exports.Editor(options);
|
|
14190
14286
|
if (app)
|
|
14191
14287
|
app.sky.add(app.editor = editor);
|
|
14192
14288
|
return editor;
|
|
@@ -14244,12 +14340,8 @@ ${filterStyle$1}
|
|
|
14244
14340
|
style.justifyContent = verticalAlignMap[text.verticalAlign];
|
|
14245
14341
|
style.lineHeight = (text.__.__lineHeight || 0) * textScale + 'px';
|
|
14246
14342
|
style.letterSpacing = (text.__.__letterSpacing || 0) * textScale + 'px';
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
}
|
|
14250
|
-
else if (textWrap === 'break') {
|
|
14251
|
-
style.wordBreak = 'break-all';
|
|
14252
|
-
}
|
|
14343
|
+
style.whiteSpace = (textWrap === 'none' || text.__.__autoWidth) ? 'nowrap' : 'normal';
|
|
14344
|
+
style.wordBreak = textWrap === 'break' ? 'break-all' : 'normal';
|
|
14253
14345
|
style.textIndent = (text.paraIndent || 0) * textScale + 'px';
|
|
14254
14346
|
style.padding = padding instanceof Array ? padding.map(item => item * textScale + 'px').join(' ') : (padding || 0) * textScale + 'px';
|
|
14255
14347
|
style.textOverflow = textOverflow === 'show' ? '' : (textOverflow === 'hide' ? 'clip' : textOverflow);
|
|
@@ -14322,10 +14414,12 @@ ${filterStyle$1}
|
|
|
14322
14414
|
];
|
|
14323
14415
|
this.onFocus = this.onFocus.bind(this);
|
|
14324
14416
|
this.onInput = this.onInput.bind(this);
|
|
14417
|
+
this.onPaste = this.onPaste.bind(this);
|
|
14325
14418
|
this.onUpdate = this.onUpdate.bind(this);
|
|
14326
14419
|
this.onKeydown = this.onKeydown.bind(this);
|
|
14327
14420
|
div.addEventListener("focus", this.onFocus);
|
|
14328
14421
|
div.addEventListener("input", this.onInput);
|
|
14422
|
+
div.addEventListener("paste", this.onPaste);
|
|
14329
14423
|
window.addEventListener('keydown', this.onKeydown);
|
|
14330
14424
|
window.addEventListener('scroll', this.onUpdate);
|
|
14331
14425
|
const selection = window.getSelection();
|
|
@@ -14355,15 +14449,43 @@ ${filterStyle$1}
|
|
|
14355
14449
|
if (e.key === 'Enter') {
|
|
14356
14450
|
e.preventDefault();
|
|
14357
14451
|
const br = document.createElement('br');
|
|
14452
|
+
const zwsp = document.createTextNode('\u200B');
|
|
14358
14453
|
const selection = window.getSelection();
|
|
14359
14454
|
const range = selection.getRangeAt(0);
|
|
14360
14455
|
range.deleteContents();
|
|
14456
|
+
range.insertNode(zwsp);
|
|
14361
14457
|
range.insertNode(br);
|
|
14362
14458
|
range.setStartAfter(br);
|
|
14363
14459
|
range.setEndAfter(br);
|
|
14364
14460
|
this.onInput();
|
|
14365
14461
|
}
|
|
14366
14462
|
}
|
|
14463
|
+
onPaste(event) {
|
|
14464
|
+
if (this.isHTMLText)
|
|
14465
|
+
return;
|
|
14466
|
+
event.preventDefault();
|
|
14467
|
+
const clipboardData = event.clipboardData;
|
|
14468
|
+
if (!clipboardData)
|
|
14469
|
+
return;
|
|
14470
|
+
let text = clipboardData.getData('text/plain').replace(/\r\n?/g, '\n');
|
|
14471
|
+
const selection = window.getSelection();
|
|
14472
|
+
if (!selection || !selection.rangeCount)
|
|
14473
|
+
return;
|
|
14474
|
+
const range = selection.getRangeAt(0);
|
|
14475
|
+
range.deleteContents();
|
|
14476
|
+
const lines = text.split('\n');
|
|
14477
|
+
const fragment = document.createDocumentFragment();
|
|
14478
|
+
lines.forEach((line, index) => {
|
|
14479
|
+
if (index > 0)
|
|
14480
|
+
fragment.appendChild(document.createElement('br'));
|
|
14481
|
+
fragment.appendChild(document.createTextNode(line));
|
|
14482
|
+
});
|
|
14483
|
+
range.insertNode(fragment);
|
|
14484
|
+
range.collapse(false);
|
|
14485
|
+
selection.removeAllRanges();
|
|
14486
|
+
selection.addRange(range);
|
|
14487
|
+
this.onInput();
|
|
14488
|
+
}
|
|
14367
14489
|
onUpdate() {
|
|
14368
14490
|
const { editTarget: text } = this;
|
|
14369
14491
|
let textScale = 1;
|
|
@@ -14375,30 +14497,32 @@ ${filterStyle$1}
|
|
|
14375
14497
|
textScale *= 12 / text.fontSize;
|
|
14376
14498
|
}
|
|
14377
14499
|
this.textScale = textScale;
|
|
14378
|
-
let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14379
|
-
if (!this.inBody)
|
|
14380
|
-
x -= window.scrollX, y -= window.scrollY;
|
|
14381
14500
|
let { width, height } = text, offsetX = 0, offsetY = 0;
|
|
14382
14501
|
width *= textScale, height *= textScale;
|
|
14383
14502
|
const data = text.__;
|
|
14384
|
-
if (data.__autoWidth
|
|
14503
|
+
if (data.__autoWidth) {
|
|
14385
14504
|
width += 20;
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14505
|
+
if (data.autoSizeAlign) {
|
|
14506
|
+
switch (data.textAlign) {
|
|
14507
|
+
case 'center':
|
|
14508
|
+
offsetX = -width / 2;
|
|
14509
|
+
break;
|
|
14510
|
+
case 'right': offsetX = -width;
|
|
14511
|
+
}
|
|
14391
14512
|
}
|
|
14392
14513
|
}
|
|
14393
|
-
if (data.__autoHeight
|
|
14514
|
+
if (data.__autoHeight) {
|
|
14394
14515
|
height += 20;
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14516
|
+
if (data.autoSizeAlign) {
|
|
14517
|
+
switch (data.verticalAlign) {
|
|
14518
|
+
case 'middle':
|
|
14519
|
+
offsetY = -height / 2;
|
|
14520
|
+
break;
|
|
14521
|
+
case 'bottom': offsetY = -height;
|
|
14522
|
+
}
|
|
14400
14523
|
}
|
|
14401
14524
|
}
|
|
14525
|
+
const { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14402
14526
|
const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale).translateInner(offsetX, offsetY);
|
|
14403
14527
|
const { style } = this.editDom;
|
|
14404
14528
|
style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
@@ -14420,6 +14544,7 @@ ${filterStyle$1}
|
|
|
14420
14544
|
editor.off_(this.eventIds);
|
|
14421
14545
|
dom.removeEventListener("focus", this.onFocus);
|
|
14422
14546
|
dom.removeEventListener("input", this.onInput);
|
|
14547
|
+
dom.removeEventListener("paste", this.onPaste);
|
|
14423
14548
|
window.removeEventListener('keydown', this.onKeydown);
|
|
14424
14549
|
window.removeEventListener('scroll', this.onUpdate);
|
|
14425
14550
|
dom.remove();
|
|
@@ -14822,8 +14947,16 @@ ${filterStyle$1}
|
|
|
14822
14947
|
}
|
|
14823
14948
|
|
|
14824
14949
|
Plugin.add('view');
|
|
14825
|
-
exports.Leafer.prototype.zoom = function (zoomType,
|
|
14950
|
+
exports.Leafer.prototype.zoom = function (zoomType, optionsOrPadding, scroll, transition) {
|
|
14826
14951
|
this.killAnimate();
|
|
14952
|
+
let padding;
|
|
14953
|
+
if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {
|
|
14954
|
+
padding = optionsOrPadding.padding;
|
|
14955
|
+
scroll = optionsOrPadding.scroll;
|
|
14956
|
+
transition = optionsOrPadding.transition;
|
|
14957
|
+
}
|
|
14958
|
+
else
|
|
14959
|
+
padding = optionsOrPadding;
|
|
14827
14960
|
const { zoomLayer } = this;
|
|
14828
14961
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
|
|
14829
14962
|
const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
|
|
@@ -14870,7 +15003,7 @@ ${filterStyle$1}
|
|
|
14870
15003
|
}
|
|
14871
15004
|
const { width, height } = bounds;
|
|
14872
15005
|
let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y;
|
|
14873
|
-
if (
|
|
15006
|
+
if (scroll) {
|
|
14874
15007
|
moveX += Math.max((limitBounds.width - width) / 2, 0);
|
|
14875
15008
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
14876
15009
|
}
|
|
@@ -14883,6 +15016,10 @@ ${filterStyle$1}
|
|
|
14883
15016
|
data.scaleX *= changeScale;
|
|
14884
15017
|
data.scaleY *= changeScale;
|
|
14885
15018
|
}
|
|
15019
|
+
if (scroll === 'x')
|
|
15020
|
+
moveY = 0;
|
|
15021
|
+
else if (scroll === 'y')
|
|
15022
|
+
moveX = 0;
|
|
14886
15023
|
PointHelper.move(data, moveX, moveY);
|
|
14887
15024
|
bounds.move(moveX, moveY);
|
|
14888
15025
|
zoomLayer.set(data, transition);
|
|
@@ -15048,6 +15185,11 @@ ${filterStyle$1}
|
|
|
15048
15185
|
}
|
|
15049
15186
|
super.__updateBoxBounds();
|
|
15050
15187
|
}
|
|
15188
|
+
__draw(canvas, options, originCanvas) {
|
|
15189
|
+
if (this.textEditing && !options.exporting)
|
|
15190
|
+
return;
|
|
15191
|
+
super.__draw(canvas, options, originCanvas);
|
|
15192
|
+
}
|
|
15051
15193
|
};
|
|
15052
15194
|
__decorate([
|
|
15053
15195
|
dataProcessor(HTMLTextData)
|
|
@@ -15058,6 +15200,9 @@ ${filterStyle$1}
|
|
|
15058
15200
|
__decorate([
|
|
15059
15201
|
dataType('TextEditor')
|
|
15060
15202
|
], exports.HTMLText.prototype, "editInner", void 0);
|
|
15203
|
+
__decorate([
|
|
15204
|
+
surfaceType(false)
|
|
15205
|
+
], exports.HTMLText.prototype, "textEditing", void 0);
|
|
15061
15206
|
exports.HTMLText = __decorate([
|
|
15062
15207
|
registerUI()
|
|
15063
15208
|
], exports.HTMLText);
|
|
@@ -17991,7 +18136,7 @@ ${filterStyle$1}
|
|
|
17991
18136
|
let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
17992
18137
|
if (clip)
|
|
17993
18138
|
x += clip.x, y += clip.y, width = clip.width, height = clip.height;
|
|
17994
|
-
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
18139
|
+
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) };
|
|
17995
18140
|
let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
|
|
17996
18141
|
let sliceLeaf;
|
|
17997
18142
|
if (slice) {
|
|
@@ -18170,7 +18315,6 @@ ${filterStyle$1}
|
|
|
18170
18315
|
exports.EditSelect = EditSelect;
|
|
18171
18316
|
exports.EditSelectHelper = EditSelectHelper;
|
|
18172
18317
|
exports.EditToolCreator = EditToolCreator;
|
|
18173
|
-
exports.Editor = Editor;
|
|
18174
18318
|
exports.EditorEvent = EditorEvent;
|
|
18175
18319
|
exports.EditorGroupEvent = EditorGroupEvent;
|
|
18176
18320
|
exports.EditorHelper = EditorHelper;
|
|
@@ -18281,6 +18425,7 @@ ${filterStyle$1}
|
|
|
18281
18425
|
exports.TaskProcessor = TaskProcessor;
|
|
18282
18426
|
exports.TextConvert = TextConvert;
|
|
18283
18427
|
exports.TextData = TextData;
|
|
18428
|
+
exports.TransformTool = TransformTool;
|
|
18284
18429
|
exports.Transformer = Transformer;
|
|
18285
18430
|
exports.Transition = Transition;
|
|
18286
18431
|
exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
|