@leafer-editor/worker 1.5.3 → 1.6.1
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 +476 -289
- package/dist/worker.js.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +476 -289
- package/dist/worker.module.js.map +1 -1
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +15 -15
package/dist/worker.module.js
CHANGED
|
@@ -45,7 +45,7 @@ const IncrementId = {
|
|
|
45
45
|
};
|
|
46
46
|
const I$2 = IncrementId;
|
|
47
47
|
|
|
48
|
-
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
48
|
+
const { round: round$3, pow: pow$1, PI: PI$4 } = Math;
|
|
49
49
|
const MathHelper = {
|
|
50
50
|
within(value, min, max) {
|
|
51
51
|
if (typeof min === 'object')
|
|
@@ -109,7 +109,7 @@ const MathHelper = {
|
|
|
109
109
|
},
|
|
110
110
|
float(num, maxLength) {
|
|
111
111
|
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
112
|
-
num = round(num * a) / a;
|
|
112
|
+
num = round$3(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
114
|
},
|
|
115
115
|
getScaleData(scale, size, originSize, scaleData) {
|
|
@@ -132,8 +132,15 @@ const MathHelper = {
|
|
|
132
132
|
scaleData.scaleX = scale.x;
|
|
133
133
|
scaleData.scaleY = scale.y;
|
|
134
134
|
}
|
|
135
|
+
},
|
|
136
|
+
randInt,
|
|
137
|
+
randColor(opacity) {
|
|
138
|
+
return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
|
|
135
139
|
}
|
|
136
140
|
};
|
|
141
|
+
function randInt(num) {
|
|
142
|
+
return Math.round(Math.random() * num);
|
|
143
|
+
}
|
|
137
144
|
const OneRadian = PI$4 / 180;
|
|
138
145
|
const PI2 = PI$4 * 2;
|
|
139
146
|
const PI_2 = PI$4 / 2;
|
|
@@ -431,7 +438,7 @@ const MatrixHelper = {
|
|
|
431
438
|
const M$9 = MatrixHelper;
|
|
432
439
|
|
|
433
440
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
434
|
-
const { sin: sin$4, cos: cos$4, abs: abs$6, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
441
|
+
const { sin: sin$4, cos: cos$4, abs: abs$6, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2, PI: PI$3 } = Math;
|
|
435
442
|
const PointHelper = {
|
|
436
443
|
defaultPoint: getPointData(),
|
|
437
444
|
tempPoint: {},
|
|
@@ -452,6 +459,10 @@ const PointHelper = {
|
|
|
452
459
|
t.x = x;
|
|
453
460
|
t.y = y;
|
|
454
461
|
},
|
|
462
|
+
round(t, halfPixel) {
|
|
463
|
+
t.x = halfPixel ? round$2(t.x - 0.5) + 0.5 : round$2(t.x);
|
|
464
|
+
t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
|
|
465
|
+
},
|
|
455
466
|
move(t, x, y) {
|
|
456
467
|
t.x += x;
|
|
457
468
|
t.y += y;
|
|
@@ -1317,6 +1328,7 @@ const StringNumberMap = {
|
|
|
1317
1328
|
'E': 1
|
|
1318
1329
|
};
|
|
1319
1330
|
|
|
1331
|
+
const { randColor } = MathHelper;
|
|
1320
1332
|
class Debug {
|
|
1321
1333
|
constructor(name) {
|
|
1322
1334
|
this.repeatMap = {};
|
|
@@ -1331,6 +1343,19 @@ class Debug {
|
|
|
1331
1343
|
static set exclude(name) {
|
|
1332
1344
|
this.excludeList = getNameList(name);
|
|
1333
1345
|
}
|
|
1346
|
+
static drawRepaint(canvas, bounds) {
|
|
1347
|
+
const color = randColor();
|
|
1348
|
+
canvas.fillWorld(bounds, color.replace('1)', '.1)'));
|
|
1349
|
+
canvas.strokeWorld(bounds, color);
|
|
1350
|
+
}
|
|
1351
|
+
static drawBounds(leaf, canvas, _options) {
|
|
1352
|
+
const showHit = Debug.showBounds === 'hit', w = leaf.__nowWorld, color = randColor();
|
|
1353
|
+
if (showHit)
|
|
1354
|
+
canvas.setWorld(w), leaf.__drawHitPath(canvas), canvas.fillStyle = color.replace('1)', '.2)'), canvas.fill();
|
|
1355
|
+
canvas.resetTransform();
|
|
1356
|
+
canvas.setStroke(color, 2);
|
|
1357
|
+
showHit ? canvas.stroke() : canvas.strokeWorld(w, color);
|
|
1358
|
+
}
|
|
1334
1359
|
log(...messages) {
|
|
1335
1360
|
if (D$6.enable) {
|
|
1336
1361
|
if (D$6.filterList.length && D$6.filterList.every(name => name !== this.name))
|
|
@@ -1417,7 +1442,7 @@ const Plugin = {
|
|
|
1417
1442
|
return rs;
|
|
1418
1443
|
},
|
|
1419
1444
|
need(name) {
|
|
1420
|
-
console.error('
|
|
1445
|
+
console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1421
1446
|
}
|
|
1422
1447
|
};
|
|
1423
1448
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
@@ -2017,7 +2042,7 @@ __decorate([
|
|
|
2017
2042
|
contextMethod()
|
|
2018
2043
|
], Canvas$1.prototype, "strokeText", null);
|
|
2019
2044
|
|
|
2020
|
-
const { copy: copy$c } = MatrixHelper;
|
|
2045
|
+
const { copy: copy$c, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
|
|
2021
2046
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
2022
2047
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
2023
2048
|
class LeaferCanvasBase extends Canvas$1 {
|
|
@@ -2026,6 +2051,8 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2026
2051
|
get pixelRatio() { return this.size.pixelRatio; }
|
|
2027
2052
|
get pixelWidth() { return this.width * this.pixelRatio; }
|
|
2028
2053
|
get pixelHeight() { return this.height * this.pixelRatio; }
|
|
2054
|
+
get pixelSnap() { return this.config.pixelSnap; }
|
|
2055
|
+
set pixelSnap(value) { this.config.pixelSnap = value; }
|
|
2029
2056
|
get allowBackgroundColor() { return this.view && this.parentView; }
|
|
2030
2057
|
constructor(config, manager) {
|
|
2031
2058
|
super();
|
|
@@ -2086,15 +2113,22 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2086
2113
|
stopAutoLayout() { }
|
|
2087
2114
|
setCursor(_cursor) { }
|
|
2088
2115
|
setWorld(matrix, parentMatrix) {
|
|
2089
|
-
const { pixelRatio } = this;
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2116
|
+
const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
|
|
2117
|
+
if (parentMatrix)
|
|
2118
|
+
multiplyParent$3(matrix, parentMatrix, w);
|
|
2119
|
+
w.a = matrix.a * pixelRatio;
|
|
2120
|
+
w.b = matrix.b * pixelRatio;
|
|
2121
|
+
w.c = matrix.c * pixelRatio;
|
|
2122
|
+
w.d = matrix.d * pixelRatio;
|
|
2123
|
+
w.e = matrix.e * pixelRatio;
|
|
2124
|
+
w.f = matrix.f * pixelRatio;
|
|
2125
|
+
if (pixelSnap) {
|
|
2126
|
+
if (matrix.half && (matrix.half * pixelRatio) % 2)
|
|
2127
|
+
w.e = round$1(w.e - 0.5) + 0.5, w.f = round$1(w.f - 0.5) + 0.5;
|
|
2128
|
+
else
|
|
2129
|
+
w.e = round$1(w.e), w.f = round$1(w.f);
|
|
2097
2130
|
}
|
|
2131
|
+
this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
|
|
2098
2132
|
}
|
|
2099
2133
|
useWorldTransform(worldTransform) {
|
|
2100
2134
|
if (worldTransform)
|
|
@@ -2237,12 +2271,13 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2237
2271
|
return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
|
|
2238
2272
|
}
|
|
2239
2273
|
getSameCanvas(useSameWorldTransform, useSameSmooth) {
|
|
2240
|
-
const canvas = this.manager ? this.manager.get(
|
|
2274
|
+
const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
|
|
2241
2275
|
canvas.save();
|
|
2242
2276
|
if (useSameWorldTransform)
|
|
2243
2277
|
copy$c(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
|
|
2244
2278
|
if (useSameSmooth)
|
|
2245
2279
|
canvas.smooth = this.smooth;
|
|
2280
|
+
canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
|
|
2246
2281
|
return canvas;
|
|
2247
2282
|
}
|
|
2248
2283
|
recycle(clearBounds) {
|
|
@@ -3669,7 +3704,7 @@ const Resource = {
|
|
|
3669
3704
|
const R = Resource;
|
|
3670
3705
|
|
|
3671
3706
|
const ImageManager = {
|
|
3672
|
-
maxRecycled:
|
|
3707
|
+
maxRecycled: 10,
|
|
3673
3708
|
recycledList: [],
|
|
3674
3709
|
patternTasker: new TaskProcessor(),
|
|
3675
3710
|
get(config) {
|
|
@@ -4022,9 +4057,8 @@ function hitType(defaultValue) {
|
|
|
4022
4057
|
set(value) {
|
|
4023
4058
|
if (this.__setAttr(key, value)) {
|
|
4024
4059
|
this.__layout.hitCanvasChanged = true;
|
|
4025
|
-
if (Debug.
|
|
4060
|
+
if (Debug.showBounds === 'hit')
|
|
4026
4061
|
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
4027
|
-
}
|
|
4028
4062
|
if (this.leafer)
|
|
4029
4063
|
this.leafer.updateCursor();
|
|
4030
4064
|
}
|
|
@@ -4185,7 +4219,7 @@ function registerUIEvent() {
|
|
|
4185
4219
|
}
|
|
4186
4220
|
|
|
4187
4221
|
const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4188
|
-
const matrix$3 = {};
|
|
4222
|
+
const matrix$3 = {}, { round } = Math;
|
|
4189
4223
|
const LeafHelper = {
|
|
4190
4224
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4191
4225
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
@@ -4259,6 +4293,8 @@ const LeafHelper = {
|
|
|
4259
4293
|
y = x.y, x = x.x;
|
|
4260
4294
|
x += t.x;
|
|
4261
4295
|
y += t.y;
|
|
4296
|
+
if (t.leafer && t.leafer.config.pointSnap)
|
|
4297
|
+
x = round(x), y = round(y);
|
|
4262
4298
|
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4263
4299
|
},
|
|
4264
4300
|
zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
|
|
@@ -4497,6 +4533,7 @@ class LeafLayout {
|
|
|
4497
4533
|
set contentBounds(bounds) { this._contentBounds = bounds; }
|
|
4498
4534
|
get strokeBounds() { return this._strokeBounds || this.boxBounds; }
|
|
4499
4535
|
get renderBounds() { return this._renderBounds || this.boxBounds; }
|
|
4536
|
+
set renderBounds(bounds) { this._renderBounds = bounds; }
|
|
4500
4537
|
get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
|
|
4501
4538
|
get localStrokeBounds() { return this._localStrokeBounds || this; }
|
|
4502
4539
|
get localRenderBounds() { return this._localRenderBounds || this; }
|
|
@@ -4515,11 +4552,13 @@ class LeafLayout {
|
|
|
4515
4552
|
get height() { return this.boxBounds.height; }
|
|
4516
4553
|
constructor(leaf) {
|
|
4517
4554
|
this.leaf = leaf;
|
|
4518
|
-
this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
4519
4555
|
if (this.leaf.__local)
|
|
4520
4556
|
this._localRenderBounds = this._localStrokeBounds = this.leaf.__local;
|
|
4521
|
-
|
|
4522
|
-
|
|
4557
|
+
if (leaf.__world) {
|
|
4558
|
+
this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
4559
|
+
this.boxChange();
|
|
4560
|
+
this.matrixChange();
|
|
4561
|
+
}
|
|
4523
4562
|
}
|
|
4524
4563
|
createLocal() {
|
|
4525
4564
|
const local = this.leaf.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -4851,6 +4890,9 @@ class ResizeEvent extends Event {
|
|
|
4851
4890
|
}
|
|
4852
4891
|
this.old = oldSize;
|
|
4853
4892
|
}
|
|
4893
|
+
static isResizing(leaf) {
|
|
4894
|
+
return this.resizingKeys && this.resizingKeys[leaf.innerId] !== undefined;
|
|
4895
|
+
}
|
|
4854
4896
|
}
|
|
4855
4897
|
ResizeEvent.RESIZE = 'resize';
|
|
4856
4898
|
|
|
@@ -4893,6 +4935,7 @@ class RenderEvent extends Event {
|
|
|
4893
4935
|
}
|
|
4894
4936
|
RenderEvent.REQUEST = 'render.request';
|
|
4895
4937
|
RenderEvent.CHILD_START = 'render.child_start';
|
|
4938
|
+
RenderEvent.CHILD_END = 'render.child_end';
|
|
4896
4939
|
RenderEvent.START = 'render.start';
|
|
4897
4940
|
RenderEvent.BEFORE = 'render.before';
|
|
4898
4941
|
RenderEvent.RENDER = 'render';
|
|
@@ -5272,24 +5315,27 @@ const LeafBounds = {
|
|
|
5272
5315
|
const LeafRender = {
|
|
5273
5316
|
__render(canvas, options) {
|
|
5274
5317
|
if (this.__worldOpacity) {
|
|
5318
|
+
const data = this.__;
|
|
5275
5319
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5276
|
-
canvas.opacity =
|
|
5320
|
+
canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
|
|
5277
5321
|
if (this.__.__single) {
|
|
5278
|
-
if (
|
|
5322
|
+
if (data.eraser === 'path')
|
|
5279
5323
|
return this.__renderEraser(canvas, options);
|
|
5280
5324
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5281
5325
|
this.__draw(tempCanvas, options, canvas);
|
|
5282
5326
|
if (this.__worldFlipped) {
|
|
5283
|
-
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null,
|
|
5327
|
+
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5284
5328
|
}
|
|
5285
5329
|
else {
|
|
5286
|
-
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds,
|
|
5330
|
+
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5287
5331
|
}
|
|
5288
5332
|
tempCanvas.recycle(this.__nowWorld);
|
|
5289
5333
|
}
|
|
5290
5334
|
else {
|
|
5291
5335
|
this.__draw(canvas, options);
|
|
5292
5336
|
}
|
|
5337
|
+
if (Debug.showBounds)
|
|
5338
|
+
Debug.drawBounds(this, canvas, options);
|
|
5293
5339
|
}
|
|
5294
5340
|
},
|
|
5295
5341
|
__clip(canvas, options) {
|
|
@@ -5319,14 +5365,19 @@ const BranchRender = {
|
|
|
5319
5365
|
__render(canvas, options) {
|
|
5320
5366
|
this.__nowWorld = this.__getNowWorld(options);
|
|
5321
5367
|
if (this.__worldOpacity) {
|
|
5322
|
-
|
|
5323
|
-
|
|
5368
|
+
const data = this.__;
|
|
5369
|
+
if (data.dim)
|
|
5370
|
+
options.dimOpacity = data.dim === true ? 0.2 : data.dim;
|
|
5371
|
+
else if (data.dimskip)
|
|
5372
|
+
options.dimOpacity && (options.dimOpacity = 0);
|
|
5373
|
+
if (data.__single) {
|
|
5374
|
+
if (data.eraser === 'path')
|
|
5324
5375
|
return this.__renderEraser(canvas, options);
|
|
5325
5376
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5326
5377
|
this.__renderBranch(tempCanvas, options);
|
|
5327
5378
|
const nowWorld = this.__nowWorld;
|
|
5328
|
-
canvas.opacity =
|
|
5329
|
-
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld,
|
|
5379
|
+
canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
|
|
5380
|
+
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
|
|
5330
5381
|
tempCanvas.recycle(nowWorld);
|
|
5331
5382
|
}
|
|
5332
5383
|
else {
|
|
@@ -5401,9 +5452,11 @@ let Leaf = class Leaf {
|
|
|
5401
5452
|
reset(data) {
|
|
5402
5453
|
if (this.leafer)
|
|
5403
5454
|
this.leafer.forceRender(this.__world);
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5455
|
+
if (data !== 0) {
|
|
5456
|
+
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 };
|
|
5457
|
+
if (data !== null)
|
|
5458
|
+
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
5459
|
+
}
|
|
5407
5460
|
this.__worldOpacity = 1;
|
|
5408
5461
|
this.__ = new this.__DataProcessor(this);
|
|
5409
5462
|
this.__layout = new this.__LayoutProcessor(this);
|
|
@@ -5539,9 +5592,10 @@ let Leaf = class Leaf {
|
|
|
5539
5592
|
if (options.matrix) {
|
|
5540
5593
|
if (!this.__cameraWorld)
|
|
5541
5594
|
this.__cameraWorld = {};
|
|
5542
|
-
const cameraWorld = this.__cameraWorld;
|
|
5543
|
-
multiplyParent(
|
|
5595
|
+
const cameraWorld = this.__cameraWorld, world = this.__world;
|
|
5596
|
+
multiplyParent(world, options.matrix, cameraWorld, undefined, world);
|
|
5544
5597
|
toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
5598
|
+
cameraWorld.half !== world.half && (cameraWorld.half = world.half);
|
|
5545
5599
|
return cameraWorld;
|
|
5546
5600
|
}
|
|
5547
5601
|
else {
|
|
@@ -5701,7 +5755,7 @@ let Leaf = class Leaf {
|
|
|
5701
5755
|
__updateHitCanvas() { }
|
|
5702
5756
|
__render(_canvas, _options) { }
|
|
5703
5757
|
__drawFast(_canvas, _options) { }
|
|
5704
|
-
__draw(_canvas, _options) { }
|
|
5758
|
+
__draw(_canvas, _options, _originCanvas) { }
|
|
5705
5759
|
__clip(_canvas, _options) { }
|
|
5706
5760
|
__renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
|
|
5707
5761
|
__updateWorldOpacity() { }
|
|
@@ -6071,7 +6125,7 @@ class LeafLevelList {
|
|
|
6071
6125
|
}
|
|
6072
6126
|
}
|
|
6073
6127
|
|
|
6074
|
-
const version = "1.
|
|
6128
|
+
const version = "1.6.1";
|
|
6075
6129
|
|
|
6076
6130
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6077
6131
|
get allowBackgroundColor() { return true; }
|
|
@@ -6311,7 +6365,6 @@ function updateChange(updateList) {
|
|
|
6311
6365
|
}
|
|
6312
6366
|
|
|
6313
6367
|
const { worldBounds: worldBounds$1 } = LeafBoundsHelper;
|
|
6314
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
6315
6368
|
class LayoutBlockData {
|
|
6316
6369
|
constructor(list) {
|
|
6317
6370
|
this.updatedBounds = new Bounds();
|
|
@@ -6325,13 +6378,7 @@ class LayoutBlockData {
|
|
|
6325
6378
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds$1);
|
|
6326
6379
|
}
|
|
6327
6380
|
setAfter() {
|
|
6328
|
-
|
|
6329
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
6330
|
-
this.afterBounds.set(bigBounds);
|
|
6331
|
-
}
|
|
6332
|
-
else {
|
|
6333
|
-
this.afterBounds.setListWithFn(list, worldBounds$1);
|
|
6334
|
-
}
|
|
6381
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds$1);
|
|
6335
6382
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
6336
6383
|
}
|
|
6337
6384
|
merge(data) {
|
|
@@ -6533,6 +6580,22 @@ class Renderer {
|
|
|
6533
6580
|
requestLayout() {
|
|
6534
6581
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6535
6582
|
}
|
|
6583
|
+
checkRender() {
|
|
6584
|
+
if (this.running) {
|
|
6585
|
+
const { target } = this;
|
|
6586
|
+
if (target.isApp) {
|
|
6587
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
6588
|
+
target.children.forEach(leafer => {
|
|
6589
|
+
leafer.renderer.FPS = this.FPS;
|
|
6590
|
+
leafer.renderer.checkRender();
|
|
6591
|
+
});
|
|
6592
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
6593
|
+
}
|
|
6594
|
+
if (this.changed && this.canvas.view)
|
|
6595
|
+
this.render();
|
|
6596
|
+
this.target.emit(RenderEvent.NEXT);
|
|
6597
|
+
}
|
|
6598
|
+
}
|
|
6536
6599
|
render(callback) {
|
|
6537
6600
|
if (!(this.running && this.canvas.view))
|
|
6538
6601
|
return this.update();
|
|
@@ -6541,8 +6604,6 @@ class Renderer {
|
|
|
6541
6604
|
this.totalBounds = new Bounds();
|
|
6542
6605
|
debug$6.log(target.innerName, '--->');
|
|
6543
6606
|
try {
|
|
6544
|
-
if (!target.isApp)
|
|
6545
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6546
6607
|
this.emitRender(RenderEvent.START);
|
|
6547
6608
|
this.renderOnce(callback);
|
|
6548
6609
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6610,20 +6671,12 @@ class Renderer {
|
|
|
6610
6671
|
}
|
|
6611
6672
|
clipRender(block) {
|
|
6612
6673
|
const t = Run.start('PartRender');
|
|
6613
|
-
const { canvas } = this;
|
|
6614
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
6615
|
-
const includes = block.includes(this.target.__world);
|
|
6616
|
-
const realBounds = new Bounds(bounds);
|
|
6674
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
6617
6675
|
canvas.save();
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
6623
|
-
canvas.clearWorld(bounds, true);
|
|
6624
|
-
canvas.clipWorld(bounds, true);
|
|
6625
|
-
}
|
|
6626
|
-
this.__render(bounds, includes, realBounds);
|
|
6676
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
6677
|
+
canvas.clearWorld(bounds, true);
|
|
6678
|
+
canvas.clipWorld(bounds, true);
|
|
6679
|
+
this.__render(bounds, realBounds);
|
|
6627
6680
|
canvas.restore();
|
|
6628
6681
|
Run.end(t);
|
|
6629
6682
|
}
|
|
@@ -6632,28 +6685,22 @@ class Renderer {
|
|
|
6632
6685
|
const { canvas } = this;
|
|
6633
6686
|
canvas.save();
|
|
6634
6687
|
canvas.clear();
|
|
6635
|
-
this.__render(canvas.bounds
|
|
6688
|
+
this.__render(canvas.bounds);
|
|
6636
6689
|
canvas.restore();
|
|
6637
6690
|
Run.end(t);
|
|
6638
6691
|
}
|
|
6639
|
-
__render(bounds,
|
|
6640
|
-
const
|
|
6692
|
+
__render(bounds, realBounds) {
|
|
6693
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
6641
6694
|
if (this.needFill)
|
|
6642
|
-
|
|
6695
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
6643
6696
|
if (Debug.showRepaint)
|
|
6644
|
-
|
|
6645
|
-
this.target.__render(
|
|
6697
|
+
Debug.drawRepaint(canvas, bounds);
|
|
6698
|
+
this.target.__render(canvas, options);
|
|
6646
6699
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
6647
6700
|
this.renderOptions = options;
|
|
6648
6701
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
if (Debug.showBoundsView)
|
|
6652
|
-
this.renderBoundsView(options);
|
|
6653
|
-
this.canvas.updateRender(realBounds);
|
|
6654
|
-
}
|
|
6655
|
-
renderHitView(_options) { }
|
|
6656
|
-
renderBoundsView(_options) { }
|
|
6702
|
+
canvas.updateRender(realBounds);
|
|
6703
|
+
}
|
|
6657
6704
|
addBlock(block) {
|
|
6658
6705
|
if (!this.updateBlocks)
|
|
6659
6706
|
this.updateBlocks = [];
|
|
@@ -6669,17 +6716,16 @@ class Renderer {
|
|
|
6669
6716
|
}
|
|
6670
6717
|
}
|
|
6671
6718
|
__requestRender() {
|
|
6672
|
-
|
|
6719
|
+
const target = this.target;
|
|
6720
|
+
if (this.requestTime || !target)
|
|
6673
6721
|
return;
|
|
6722
|
+
if (target.parentApp)
|
|
6723
|
+
return target.parentApp.requestRender(false);
|
|
6674
6724
|
const requestTime = this.requestTime = Date.now();
|
|
6675
6725
|
Platform.requestRender(() => {
|
|
6676
6726
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6677
6727
|
this.requestTime = 0;
|
|
6678
|
-
|
|
6679
|
-
if (this.changed && this.canvas.view)
|
|
6680
|
-
this.render();
|
|
6681
|
-
this.target.emit(RenderEvent.NEXT);
|
|
6682
|
-
}
|
|
6728
|
+
this.checkRender();
|
|
6683
6729
|
});
|
|
6684
6730
|
}
|
|
6685
6731
|
__onResize(e) {
|
|
@@ -6737,6 +6783,7 @@ class Renderer {
|
|
|
6737
6783
|
}
|
|
6738
6784
|
}
|
|
6739
6785
|
}
|
|
6786
|
+
Renderer.clipSpread = 10;
|
|
6740
6787
|
|
|
6741
6788
|
const { hitRadiusPoint } = BoundsHelper;
|
|
6742
6789
|
class Picker {
|
|
@@ -6982,6 +7029,7 @@ class UIData extends LeafData {
|
|
|
6982
7029
|
return strokeWidth;
|
|
6983
7030
|
}
|
|
6984
7031
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7032
|
+
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
6985
7033
|
get __hasMultiPaint() {
|
|
6986
7034
|
const t = this;
|
|
6987
7035
|
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
@@ -7026,14 +7074,14 @@ class UIData extends LeafData {
|
|
|
7026
7074
|
this.__removeInput('fill');
|
|
7027
7075
|
PaintImage.recycleImage('fill', this);
|
|
7028
7076
|
this.__isFills = false;
|
|
7029
|
-
|
|
7030
|
-
this.__pixelFill = false;
|
|
7077
|
+
this.__pixelFill && (this.__pixelFill = false);
|
|
7031
7078
|
}
|
|
7032
7079
|
this._fill = value;
|
|
7033
7080
|
}
|
|
7034
7081
|
else if (typeof value === 'object') {
|
|
7035
7082
|
this.__setInput('fill', value);
|
|
7036
|
-
|
|
7083
|
+
const layout = this.__leaf.__layout;
|
|
7084
|
+
layout.boxChanged || layout.boxChange();
|
|
7037
7085
|
this.__isFills = true;
|
|
7038
7086
|
this._fill || (this._fill = emptyPaint);
|
|
7039
7087
|
}
|
|
@@ -7044,14 +7092,14 @@ class UIData extends LeafData {
|
|
|
7044
7092
|
this.__removeInput('stroke');
|
|
7045
7093
|
PaintImage.recycleImage('stroke', this);
|
|
7046
7094
|
this.__isStrokes = false;
|
|
7047
|
-
|
|
7048
|
-
this.__pixelStroke = false;
|
|
7095
|
+
this.__pixelStroke && (this.__pixelStroke = false);
|
|
7049
7096
|
}
|
|
7050
7097
|
this._stroke = value;
|
|
7051
7098
|
}
|
|
7052
7099
|
else if (typeof value === 'object') {
|
|
7053
7100
|
this.__setInput('stroke', value);
|
|
7054
|
-
|
|
7101
|
+
const layout = this.__leaf.__layout;
|
|
7102
|
+
layout.boxChanged || layout.boxChange();
|
|
7055
7103
|
this.__isStrokes = true;
|
|
7056
7104
|
this._stroke || (this._stroke = emptyPaint);
|
|
7057
7105
|
}
|
|
@@ -7166,6 +7214,31 @@ class TextData extends UIData {
|
|
|
7166
7214
|
this._fontWeight = value;
|
|
7167
7215
|
}
|
|
7168
7216
|
}
|
|
7217
|
+
setBoxStyle(value) {
|
|
7218
|
+
let t = this.__leaf, box = t.__box;
|
|
7219
|
+
if (value) {
|
|
7220
|
+
const { boxStyle } = this;
|
|
7221
|
+
if (box)
|
|
7222
|
+
for (let key in boxStyle)
|
|
7223
|
+
box[key] = undefined;
|
|
7224
|
+
else
|
|
7225
|
+
box = t.__box = UICreator.get('Rect', 0);
|
|
7226
|
+
const layout = t.__layout, boxLayout = box.__layout;
|
|
7227
|
+
if (!boxStyle)
|
|
7228
|
+
box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
7229
|
+
box.set(value);
|
|
7230
|
+
if (boxLayout.strokeChanged)
|
|
7231
|
+
layout.strokeChange();
|
|
7232
|
+
if (boxLayout.renderChanged)
|
|
7233
|
+
layout.renderChange();
|
|
7234
|
+
box.__updateChange();
|
|
7235
|
+
}
|
|
7236
|
+
else if (box) {
|
|
7237
|
+
t.__box = box.parent = null;
|
|
7238
|
+
box.destroy();
|
|
7239
|
+
}
|
|
7240
|
+
this._boxStyle = value;
|
|
7241
|
+
}
|
|
7169
7242
|
}
|
|
7170
7243
|
|
|
7171
7244
|
class ImageData extends RectData {
|
|
@@ -7203,7 +7276,7 @@ class CanvasData extends RectData {
|
|
|
7203
7276
|
const UIBounds = {
|
|
7204
7277
|
__updateStrokeSpread() {
|
|
7205
7278
|
let width = 0, boxWidth = 0;
|
|
7206
|
-
const data = this.__, { strokeAlign, strokeWidth } = data;
|
|
7279
|
+
const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
|
|
7207
7280
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
7208
7281
|
boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
|
|
7209
7282
|
if (!data.__boxStroke) {
|
|
@@ -7214,6 +7287,10 @@ const UIBounds = {
|
|
|
7214
7287
|
}
|
|
7215
7288
|
if (data.__useArrow)
|
|
7216
7289
|
width += strokeWidth * 5;
|
|
7290
|
+
if (box) {
|
|
7291
|
+
width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
|
|
7292
|
+
boxWidth = box.__layout.strokeBoxSpread;
|
|
7293
|
+
}
|
|
7217
7294
|
this.__layout.strokeBoxSpread = boxWidth;
|
|
7218
7295
|
return width;
|
|
7219
7296
|
},
|
|
@@ -7232,25 +7309,26 @@ const UIBounds = {
|
|
|
7232
7309
|
if (backgroundBlur)
|
|
7233
7310
|
shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
7234
7311
|
this.__layout.renderShapeSpread = shapeWidth;
|
|
7235
|
-
|
|
7312
|
+
width += this.__layout.strokeSpread || 0;
|
|
7313
|
+
return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
|
|
7236
7314
|
}
|
|
7237
7315
|
};
|
|
7238
7316
|
|
|
7239
7317
|
const UIRender = {
|
|
7240
7318
|
__updateChange() {
|
|
7241
|
-
const data = this.__;
|
|
7319
|
+
const data = this.__, w = this.__world;
|
|
7242
7320
|
if (data.__useEffect) {
|
|
7243
7321
|
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
7244
7322
|
data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
|
|
7245
7323
|
}
|
|
7324
|
+
const half = data.__hasHalf;
|
|
7325
|
+
w.half !== half && (w.half = half);
|
|
7246
7326
|
data.__checkSingle();
|
|
7247
7327
|
const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
|
|
7248
|
-
if (complex)
|
|
7328
|
+
if (complex)
|
|
7249
7329
|
data.__complex = true;
|
|
7250
|
-
|
|
7251
|
-
else {
|
|
7330
|
+
else
|
|
7252
7331
|
data.__complex && (data.__complex = false);
|
|
7253
|
-
}
|
|
7254
7332
|
},
|
|
7255
7333
|
__drawFast(canvas, options) {
|
|
7256
7334
|
drawFast(this, canvas, options);
|
|
@@ -7337,10 +7415,11 @@ function drawFast(ui, canvas, options) {
|
|
|
7337
7415
|
|
|
7338
7416
|
const RectRender = {
|
|
7339
7417
|
__drawFast(canvas, options) {
|
|
7340
|
-
let {
|
|
7418
|
+
let { x, y, width, height } = this.__layout.boxBounds;
|
|
7419
|
+
const { fill, stroke, __drawAfterFill } = this.__;
|
|
7341
7420
|
if (fill) {
|
|
7342
7421
|
canvas.fillStyle = fill;
|
|
7343
|
-
canvas.fillRect(
|
|
7422
|
+
canvas.fillRect(x, y, width, height);
|
|
7344
7423
|
}
|
|
7345
7424
|
if (__drawAfterFill)
|
|
7346
7425
|
this.__drawAfterFill(canvas, options);
|
|
@@ -7359,14 +7438,14 @@ const RectRender = {
|
|
|
7359
7438
|
if (width < 0 || height < 0) {
|
|
7360
7439
|
canvas.save();
|
|
7361
7440
|
this.__clip(canvas, options);
|
|
7362
|
-
canvas.strokeRect(half, half, width, height);
|
|
7441
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7363
7442
|
canvas.restore();
|
|
7364
7443
|
}
|
|
7365
7444
|
else
|
|
7366
|
-
canvas.strokeRect(half, half, width, height);
|
|
7445
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7367
7446
|
break;
|
|
7368
7447
|
case 'outside':
|
|
7369
|
-
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
7448
|
+
canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
|
|
7370
7449
|
break;
|
|
7371
7450
|
}
|
|
7372
7451
|
}
|
|
@@ -7522,6 +7601,12 @@ __decorate([
|
|
|
7522
7601
|
__decorate([
|
|
7523
7602
|
surfaceType(false)
|
|
7524
7603
|
], UI.prototype, "locked", void 0);
|
|
7604
|
+
__decorate([
|
|
7605
|
+
surfaceType(false)
|
|
7606
|
+
], UI.prototype, "dim", void 0);
|
|
7607
|
+
__decorate([
|
|
7608
|
+
surfaceType(false)
|
|
7609
|
+
], UI.prototype, "dimskip", void 0);
|
|
7525
7610
|
__decorate([
|
|
7526
7611
|
sortType(0)
|
|
7527
7612
|
], UI.prototype, "zIndex", void 0);
|
|
@@ -7783,7 +7868,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7783
7868
|
start: true,
|
|
7784
7869
|
hittable: true,
|
|
7785
7870
|
smooth: true,
|
|
7786
|
-
lazySpeard: 100
|
|
7871
|
+
lazySpeard: 100,
|
|
7787
7872
|
};
|
|
7788
7873
|
this.leafs = 0;
|
|
7789
7874
|
this.__eventIds = [];
|
|
@@ -8207,13 +8292,13 @@ let Box = class Box extends Group {
|
|
|
8207
8292
|
super.__updateRenderBounds();
|
|
8208
8293
|
copy$6(childrenRenderBounds, renderBounds);
|
|
8209
8294
|
this.__updateRectRenderBounds();
|
|
8210
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8295
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
|
|
8211
8296
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8212
8297
|
add(renderBounds, childrenRenderBounds);
|
|
8213
8298
|
}
|
|
8214
8299
|
else
|
|
8215
8300
|
this.__updateRectRenderBounds();
|
|
8216
|
-
|
|
8301
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8217
8302
|
}
|
|
8218
8303
|
__updateRectRenderBounds() { }
|
|
8219
8304
|
__updateRectChange() { }
|
|
@@ -8621,33 +8706,13 @@ Canvas = __decorate([
|
|
|
8621
8706
|
registerUI()
|
|
8622
8707
|
], Canvas);
|
|
8623
8708
|
|
|
8624
|
-
const { copyAndSpread, includes,
|
|
8709
|
+
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
8625
8710
|
let Text = class Text extends UI {
|
|
8626
8711
|
get __tag() { return 'Text'; }
|
|
8627
|
-
get textDrawData() {
|
|
8628
|
-
this.__layout.update();
|
|
8629
|
-
return this.__.__textDrawData;
|
|
8630
|
-
}
|
|
8712
|
+
get textDrawData() { this.updateLayout(); return this.__.__textDrawData; }
|
|
8631
8713
|
constructor(data) {
|
|
8632
8714
|
super(data);
|
|
8633
8715
|
}
|
|
8634
|
-
__drawHitPath(canvas) {
|
|
8635
|
-
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8636
|
-
canvas.beginPath();
|
|
8637
|
-
if (this.__.__letterSpacing < 0) {
|
|
8638
|
-
this.__drawPathByData(canvas);
|
|
8639
|
-
}
|
|
8640
|
-
else {
|
|
8641
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8642
|
-
}
|
|
8643
|
-
}
|
|
8644
|
-
__drawPathByData(drawer, _data) {
|
|
8645
|
-
const { x, y, width, height } = this.__layout.boxBounds;
|
|
8646
|
-
drawer.rect(x, y, width, height);
|
|
8647
|
-
}
|
|
8648
|
-
__drawRenderPath(canvas) {
|
|
8649
|
-
canvas.font = this.__.__font;
|
|
8650
|
-
}
|
|
8651
8716
|
__updateTextDrawData() {
|
|
8652
8717
|
const data = this.__;
|
|
8653
8718
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
@@ -8664,15 +8729,16 @@ let Text = class Text extends UI {
|
|
|
8664
8729
|
const layout = this.__layout;
|
|
8665
8730
|
const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
|
|
8666
8731
|
this.__updateTextDrawData();
|
|
8667
|
-
const { bounds } = data.__textDrawData;
|
|
8732
|
+
const { bounds: contentBounds } = data.__textDrawData;
|
|
8668
8733
|
const b = layout.boxBounds;
|
|
8734
|
+
layout.contentBounds = contentBounds;
|
|
8669
8735
|
if (data.__lineHeight < fontSize)
|
|
8670
|
-
spread(
|
|
8736
|
+
spread(contentBounds, fontSize / 2);
|
|
8671
8737
|
if (autoWidth || autoHeight) {
|
|
8672
|
-
b.x = autoWidth ?
|
|
8673
|
-
b.y = autoHeight ?
|
|
8674
|
-
b.width = autoWidth ?
|
|
8675
|
-
b.height = autoHeight ?
|
|
8738
|
+
b.x = autoWidth ? contentBounds.x : 0;
|
|
8739
|
+
b.y = autoHeight ? contentBounds.y : 0;
|
|
8740
|
+
b.width = autoWidth ? contentBounds.width : data.width;
|
|
8741
|
+
b.height = autoHeight ? contentBounds.height : data.height;
|
|
8676
8742
|
if (padding) {
|
|
8677
8743
|
const [top, right, bottom, left] = data.__padding;
|
|
8678
8744
|
if (autoWidth)
|
|
@@ -8686,23 +8752,45 @@ let Text = class Text extends UI {
|
|
|
8686
8752
|
super.__updateBoxBounds();
|
|
8687
8753
|
if (italic)
|
|
8688
8754
|
b.width += fontSize * 0.16;
|
|
8689
|
-
const
|
|
8690
|
-
if (
|
|
8691
|
-
|
|
8692
|
-
layout.renderChanged = true;
|
|
8693
|
-
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8694
|
-
}
|
|
8755
|
+
const isOverflow = !includes(b, contentBounds) || undefined;
|
|
8756
|
+
if (isOverflow)
|
|
8757
|
+
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8695
8758
|
else
|
|
8696
|
-
data.__textBoxBounds =
|
|
8759
|
+
data.__textBoxBounds = b;
|
|
8760
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8761
|
+
}
|
|
8762
|
+
__onUpdateSize() {
|
|
8763
|
+
if (this.__box)
|
|
8764
|
+
this.__box.__onUpdateSize();
|
|
8765
|
+
super.__onUpdateSize();
|
|
8697
8766
|
}
|
|
8698
8767
|
__updateRenderSpread() {
|
|
8699
8768
|
let width = super.__updateRenderSpread();
|
|
8700
8769
|
if (!width)
|
|
8701
|
-
width = this.
|
|
8770
|
+
width = this.isOverflow ? 1 : 0;
|
|
8702
8771
|
return width;
|
|
8703
8772
|
}
|
|
8704
8773
|
__updateRenderBounds() {
|
|
8705
|
-
|
|
8774
|
+
const { renderBounds, renderSpread } = this.__layout;
|
|
8775
|
+
copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
8776
|
+
if (this.__box)
|
|
8777
|
+
this.__box.__layout.renderBounds = renderBounds;
|
|
8778
|
+
}
|
|
8779
|
+
__drawRenderPath(canvas) {
|
|
8780
|
+
canvas.font = this.__.__font;
|
|
8781
|
+
}
|
|
8782
|
+
__draw(canvas, options, originCanvas) {
|
|
8783
|
+
const box = this.__box;
|
|
8784
|
+
if (box)
|
|
8785
|
+
box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
8786
|
+
if (this.textEditing && !Export.running)
|
|
8787
|
+
return;
|
|
8788
|
+
super.__draw(canvas, options, originCanvas);
|
|
8789
|
+
}
|
|
8790
|
+
destroy() {
|
|
8791
|
+
if (this.boxStyle)
|
|
8792
|
+
this.boxStyle = null;
|
|
8793
|
+
super.destroy();
|
|
8706
8794
|
}
|
|
8707
8795
|
};
|
|
8708
8796
|
__decorate([
|
|
@@ -8714,6 +8802,9 @@ __decorate([
|
|
|
8714
8802
|
__decorate([
|
|
8715
8803
|
boundsType(0)
|
|
8716
8804
|
], Text.prototype, "height", void 0);
|
|
8805
|
+
__decorate([
|
|
8806
|
+
surfaceType()
|
|
8807
|
+
], Text.prototype, "boxStyle", void 0);
|
|
8717
8808
|
__decorate([
|
|
8718
8809
|
dataType(false)
|
|
8719
8810
|
], Text.prototype, "resizeFontSize", void 0);
|
|
@@ -8877,26 +8968,25 @@ let App = class App extends Leafer {
|
|
|
8877
8968
|
this.leafer = this;
|
|
8878
8969
|
this.watcher.disable();
|
|
8879
8970
|
this.layouter.disable();
|
|
8880
|
-
this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this));
|
|
8881
8971
|
}
|
|
8882
8972
|
start() {
|
|
8883
8973
|
super.start();
|
|
8884
|
-
this.
|
|
8974
|
+
this.forEach(leafer => leafer.start());
|
|
8885
8975
|
}
|
|
8886
8976
|
stop() {
|
|
8887
|
-
this.
|
|
8977
|
+
this.forEach(leafer => leafer.stop());
|
|
8888
8978
|
super.stop();
|
|
8889
8979
|
}
|
|
8890
8980
|
unlockLayout() {
|
|
8891
8981
|
super.unlockLayout();
|
|
8892
|
-
this.
|
|
8982
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
8893
8983
|
}
|
|
8894
8984
|
lockLayout() {
|
|
8895
8985
|
super.lockLayout();
|
|
8896
|
-
this.
|
|
8986
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
8897
8987
|
}
|
|
8898
8988
|
forceRender(bounds, sync) {
|
|
8899
|
-
this.
|
|
8989
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
8900
8990
|
}
|
|
8901
8991
|
addLeafer(merge) {
|
|
8902
8992
|
const leafer = new Leafer(merge);
|
|
@@ -8916,9 +9006,8 @@ let App = class App extends Leafer {
|
|
|
8916
9006
|
leafer.canvas.childIndex = index;
|
|
8917
9007
|
this.__listenChildEvents(leafer);
|
|
8918
9008
|
}
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
9009
|
+
forEach(fn) {
|
|
9010
|
+
this.children.forEach(fn);
|
|
8922
9011
|
}
|
|
8923
9012
|
__onCreated() {
|
|
8924
9013
|
this.created = this.children.every(child => child.created);
|
|
@@ -8941,18 +9030,18 @@ let App = class App extends Leafer {
|
|
|
8941
9030
|
const m = options.matrix;
|
|
8942
9031
|
if (m)
|
|
8943
9032
|
canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
8944
|
-
this.
|
|
9033
|
+
this.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
8945
9034
|
}
|
|
8946
9035
|
}
|
|
8947
9036
|
__onResize(event) {
|
|
8948
|
-
this.
|
|
9037
|
+
this.forEach(leafer => leafer.resize(event));
|
|
8949
9038
|
super.__onResize(event);
|
|
8950
9039
|
}
|
|
8951
9040
|
updateLayout() {
|
|
8952
|
-
this.
|
|
9041
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
8953
9042
|
}
|
|
8954
9043
|
__getChildConfig(userConfig) {
|
|
8955
|
-
|
|
9044
|
+
const config = Object.assign({}, this.config);
|
|
8956
9045
|
config.hittable = config.realCanvas = undefined;
|
|
8957
9046
|
if (userConfig)
|
|
8958
9047
|
DataHelper.assign(config, userConfig);
|
|
@@ -9511,6 +9600,7 @@ const config$1 = {
|
|
|
9511
9600
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9512
9601
|
},
|
|
9513
9602
|
pointer: {
|
|
9603
|
+
snap: true,
|
|
9514
9604
|
hitRadius: 5,
|
|
9515
9605
|
tapTime: 120,
|
|
9516
9606
|
longPressTime: 800,
|
|
@@ -9605,8 +9695,7 @@ class InteractionBase {
|
|
|
9605
9695
|
if (this.downData) {
|
|
9606
9696
|
const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
|
|
9607
9697
|
if (canDrag) {
|
|
9608
|
-
|
|
9609
|
-
this.pointerWaitCancel();
|
|
9698
|
+
this.pointerWaitCancel();
|
|
9610
9699
|
this.waitRightTap = false;
|
|
9611
9700
|
}
|
|
9612
9701
|
this.dragger.checkDrag(data, canDrag);
|
|
@@ -9866,7 +9955,10 @@ class InteractionBase {
|
|
|
9866
9955
|
}
|
|
9867
9956
|
getLocal(clientPoint, updateClient) {
|
|
9868
9957
|
const clientBounds = this.canvas.getClientBounds(updateClient);
|
|
9869
|
-
|
|
9958
|
+
const point = { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
|
|
9959
|
+
if (this.p.snap)
|
|
9960
|
+
PointHelper.round(point);
|
|
9961
|
+
return point;
|
|
9870
9962
|
}
|
|
9871
9963
|
emitTap(data) {
|
|
9872
9964
|
this.emit(PointerEvent.TAP, data);
|
|
@@ -9885,9 +9977,11 @@ class InteractionBase {
|
|
|
9885
9977
|
this.waitTap = true;
|
|
9886
9978
|
}
|
|
9887
9979
|
tapWaitCancel() {
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9980
|
+
if (this.waitTap) {
|
|
9981
|
+
clearTimeout(this.tapTimer);
|
|
9982
|
+
this.waitTap = false;
|
|
9983
|
+
this.tapCount = 0;
|
|
9984
|
+
}
|
|
9891
9985
|
}
|
|
9892
9986
|
longPressWait(data) {
|
|
9893
9987
|
clearTimeout(this.longPressTimer);
|
|
@@ -9907,8 +10001,10 @@ class InteractionBase {
|
|
|
9907
10001
|
return hasLong;
|
|
9908
10002
|
}
|
|
9909
10003
|
longPressWaitCancel() {
|
|
9910
|
-
|
|
9911
|
-
|
|
10004
|
+
if (this.longPressTimer) {
|
|
10005
|
+
clearTimeout(this.longPressTimer);
|
|
10006
|
+
this.longPressed = false;
|
|
10007
|
+
}
|
|
9912
10008
|
}
|
|
9913
10009
|
__onResize() {
|
|
9914
10010
|
const { dragOut } = this.m;
|
|
@@ -9998,25 +10094,26 @@ const { toInnerRadiusPointOf, copy: copy$5, setRadius } = PointHelper;
|
|
|
9998
10094
|
const inner = {};
|
|
9999
10095
|
const leaf$1 = Leaf.prototype;
|
|
10000
10096
|
leaf$1.__hitWorld = function (point) {
|
|
10001
|
-
|
|
10097
|
+
const data = this.__;
|
|
10098
|
+
if (!data.hitSelf)
|
|
10002
10099
|
return false;
|
|
10003
|
-
|
|
10100
|
+
const world = this.__world, layout = this.__layout;
|
|
10101
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
10102
|
+
if (data.hitRadius) {
|
|
10004
10103
|
copy$5(inner, point), point = inner;
|
|
10005
|
-
setRadius(point,
|
|
10104
|
+
setRadius(point, data.hitRadius);
|
|
10006
10105
|
}
|
|
10007
|
-
toInnerRadiusPointOf(point,
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
if (this.__.hitBox || isSmall) {
|
|
10011
|
-
if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
|
|
10106
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
10107
|
+
if (data.hitBox || isSmall) {
|
|
10108
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
10012
10109
|
return true;
|
|
10013
10110
|
if (isSmall)
|
|
10014
10111
|
return false;
|
|
10015
10112
|
}
|
|
10016
|
-
if (
|
|
10113
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
10017
10114
|
this.__updateHitCanvas();
|
|
10018
|
-
if (!
|
|
10019
|
-
|
|
10115
|
+
if (!layout.boundsChanged)
|
|
10116
|
+
layout.hitCanvasChanged = false;
|
|
10020
10117
|
}
|
|
10021
10118
|
return this.__hit(inner);
|
|
10022
10119
|
};
|
|
@@ -10029,7 +10126,9 @@ leaf$1.__drawHitPath = function (canvas) { if (canvas)
|
|
|
10029
10126
|
const matrix$2 = new Matrix();
|
|
10030
10127
|
const ui$2 = UI.prototype;
|
|
10031
10128
|
ui$2.__updateHitCanvas = function () {
|
|
10032
|
-
|
|
10129
|
+
if (this.__box)
|
|
10130
|
+
this.__box.__updateHitCanvas();
|
|
10131
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
10033
10132
|
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10034
10133
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
10035
10134
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
@@ -10056,6 +10155,8 @@ ui$2.__updateHitCanvas = function () {
|
|
|
10056
10155
|
h.setStrokeOptions(data);
|
|
10057
10156
|
};
|
|
10058
10157
|
ui$2.__hit = function (inner) {
|
|
10158
|
+
if (this.__box && this.__box.__hit(inner))
|
|
10159
|
+
return true;
|
|
10059
10160
|
const data = this.__;
|
|
10060
10161
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10061
10162
|
return true;
|
|
@@ -10104,6 +10205,15 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
|
10104
10205
|
return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10105
10206
|
};
|
|
10106
10207
|
|
|
10208
|
+
Text.prototype.__drawHitPath = function (canvas) {
|
|
10209
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
10210
|
+
canvas.beginPath();
|
|
10211
|
+
if (__letterSpacing < 0)
|
|
10212
|
+
this.__drawPathByBox(canvas);
|
|
10213
|
+
else
|
|
10214
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
10215
|
+
};
|
|
10216
|
+
|
|
10107
10217
|
function getSelector$1(ui) {
|
|
10108
10218
|
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10109
10219
|
}
|
|
@@ -10486,9 +10596,11 @@ const tempBox = new Bounds();
|
|
|
10486
10596
|
const tempPoint = {};
|
|
10487
10597
|
const tempScaleData = {};
|
|
10488
10598
|
function createData(leafPaint, image, paint, box) {
|
|
10489
|
-
const { blendMode, sync } = paint;
|
|
10599
|
+
const { blendMode, changeful, sync } = paint;
|
|
10490
10600
|
if (blendMode)
|
|
10491
10601
|
leafPaint.blendMode = blendMode;
|
|
10602
|
+
if (changeful)
|
|
10603
|
+
leafPaint.changeful = changeful;
|
|
10492
10604
|
if (sync)
|
|
10493
10605
|
leafPaint.sync = sync;
|
|
10494
10606
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -10721,40 +10833,32 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
10721
10833
|
}
|
|
10722
10834
|
|
|
10723
10835
|
const { abs: abs$2 } = Math;
|
|
10724
|
-
function checkImage(ui, canvas, paint,
|
|
10836
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
10725
10837
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
10726
|
-
const { pixelRatio } = canvas;
|
|
10727
|
-
if (!
|
|
10838
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
10839
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
10728
10840
|
return false;
|
|
10729
10841
|
}
|
|
10730
10842
|
else {
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
let { width, height } = data;
|
|
10735
|
-
width *= abs$2(scaleX) * pixelRatio;
|
|
10736
|
-
height *= abs$2(scaleY) * pixelRatio;
|
|
10737
|
-
if (data.scaleX) {
|
|
10738
|
-
width *= data.scaleX;
|
|
10739
|
-
height *= data.scaleY;
|
|
10740
|
-
}
|
|
10741
|
-
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
10843
|
+
if (allowDraw) {
|
|
10844
|
+
if (data.repeat) {
|
|
10845
|
+
allowDraw = false;
|
|
10742
10846
|
}
|
|
10743
10847
|
else {
|
|
10744
|
-
|
|
10848
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
10849
|
+
let { width, height } = data;
|
|
10850
|
+
width *= abs$2(scaleX) * pixelRatio;
|
|
10851
|
+
height *= abs$2(scaleY) * pixelRatio;
|
|
10852
|
+
if (data.scaleX) {
|
|
10853
|
+
width *= data.scaleX;
|
|
10854
|
+
height *= data.scaleY;
|
|
10855
|
+
}
|
|
10856
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
10857
|
+
}
|
|
10745
10858
|
}
|
|
10746
10859
|
}
|
|
10747
|
-
if (
|
|
10748
|
-
canvas
|
|
10749
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
10750
|
-
if (paint.blendMode)
|
|
10751
|
-
canvas.blendMode = paint.blendMode;
|
|
10752
|
-
if (data.opacity)
|
|
10753
|
-
canvas.opacity *= data.opacity;
|
|
10754
|
-
if (data.transform)
|
|
10755
|
-
canvas.transform(data.transform);
|
|
10756
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
10757
|
-
canvas.restore();
|
|
10860
|
+
if (allowDraw) {
|
|
10861
|
+
drawImage(ui, canvas, paint, data);
|
|
10758
10862
|
return true;
|
|
10759
10863
|
}
|
|
10760
10864
|
else {
|
|
@@ -10775,13 +10879,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
10775
10879
|
}
|
|
10776
10880
|
}
|
|
10777
10881
|
}
|
|
10882
|
+
function drawImage(ui, canvas, paint, data) {
|
|
10883
|
+
canvas.save();
|
|
10884
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
10885
|
+
if (paint.blendMode)
|
|
10886
|
+
canvas.blendMode = paint.blendMode;
|
|
10887
|
+
if (data.opacity)
|
|
10888
|
+
canvas.opacity *= data.opacity;
|
|
10889
|
+
if (data.transform)
|
|
10890
|
+
canvas.transform(data.transform);
|
|
10891
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
10892
|
+
canvas.restore();
|
|
10893
|
+
}
|
|
10778
10894
|
|
|
10779
10895
|
function recycleImage(attrName, data) {
|
|
10780
10896
|
const paints = data['_' + attrName];
|
|
10781
10897
|
if (paints instanceof Array) {
|
|
10782
|
-
let image, recycleMap, input, url;
|
|
10898
|
+
let paint, image, recycleMap, input, url;
|
|
10783
10899
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
10784
|
-
|
|
10900
|
+
paint = paints[i];
|
|
10901
|
+
image = paint.image;
|
|
10785
10902
|
url = image && image.url;
|
|
10786
10903
|
if (url) {
|
|
10787
10904
|
if (!recycleMap)
|
|
@@ -10796,8 +10913,6 @@ function recycleImage(attrName, data) {
|
|
|
10796
10913
|
}
|
|
10797
10914
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
10798
10915
|
}
|
|
10799
|
-
else
|
|
10800
|
-
paints[i].style = null;
|
|
10801
10916
|
}
|
|
10802
10917
|
}
|
|
10803
10918
|
return recycleMap;
|
|
@@ -10976,7 +11091,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
10976
11091
|
const offsetOutBounds = {};
|
|
10977
11092
|
function innerShadow(ui, current, shape) {
|
|
10978
11093
|
let copyBounds, spreadScale;
|
|
10979
|
-
const { __nowWorld: nowWorld, __layout
|
|
11094
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
10980
11095
|
const { innerShadow } = ui.__;
|
|
10981
11096
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
10982
11097
|
const other = current.getSameCanvas();
|
|
@@ -11730,6 +11845,28 @@ function targetAttr(fn) {
|
|
|
11730
11845
|
});
|
|
11731
11846
|
};
|
|
11732
11847
|
}
|
|
11848
|
+
function mergeConfigAttr() {
|
|
11849
|
+
return (target, key) => {
|
|
11850
|
+
defineKey(target, key, {
|
|
11851
|
+
get() {
|
|
11852
|
+
const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
|
|
11853
|
+
if (element && element.editConfig)
|
|
11854
|
+
Object.assign(mergeConfig, element.editConfig);
|
|
11855
|
+
if (dragPoint) {
|
|
11856
|
+
if (dragPoint.editConfig)
|
|
11857
|
+
Object.assign(mergeConfig, dragPoint.editConfig);
|
|
11858
|
+
if (mergeConfig.editSize === 'font-size')
|
|
11859
|
+
mergeConfig.lockRatio = true;
|
|
11860
|
+
if (dragPoint.pointType === 'resize-rotate') {
|
|
11861
|
+
mergeConfig.around || (mergeConfig.around = 'center');
|
|
11862
|
+
isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
|
|
11863
|
+
}
|
|
11864
|
+
}
|
|
11865
|
+
return this.mergedConfig = mergeConfig;
|
|
11866
|
+
}
|
|
11867
|
+
});
|
|
11868
|
+
};
|
|
11869
|
+
}
|
|
11733
11870
|
|
|
11734
11871
|
const { abs: abs$1 } = Math;
|
|
11735
11872
|
const { copy: copy$2, scale: scale$1 } = MatrixHelper;
|
|
@@ -11741,6 +11878,7 @@ class Stroker extends UI {
|
|
|
11741
11878
|
constructor() {
|
|
11742
11879
|
super();
|
|
11743
11880
|
this.list = [];
|
|
11881
|
+
this.visible = 0;
|
|
11744
11882
|
this.hittable = false;
|
|
11745
11883
|
this.strokeAlign = 'center';
|
|
11746
11884
|
}
|
|
@@ -11754,10 +11892,10 @@ class Stroker extends UI {
|
|
|
11754
11892
|
if (list.length) {
|
|
11755
11893
|
setListWithFn(bounds$2, list, worldBounds);
|
|
11756
11894
|
this.set(bounds$2);
|
|
11895
|
+
this.visible = true;
|
|
11757
11896
|
}
|
|
11758
|
-
else
|
|
11759
|
-
this.
|
|
11760
|
-
}
|
|
11897
|
+
else
|
|
11898
|
+
this.visible = 0;
|
|
11761
11899
|
}
|
|
11762
11900
|
__draw(canvas, options) {
|
|
11763
11901
|
const { list } = this;
|
|
@@ -11769,8 +11907,9 @@ class Stroker extends UI {
|
|
|
11769
11907
|
const { worldTransform, worldRenderBounds } = leaf;
|
|
11770
11908
|
if (worldRenderBounds.width && worldRenderBounds.height && (!bounds || bounds.hit(worldRenderBounds, options.matrix))) {
|
|
11771
11909
|
const aScaleX = abs$1(worldTransform.scaleX), aScaleY = abs$1(worldTransform.scaleY);
|
|
11910
|
+
copy$2(matrix$1, worldTransform);
|
|
11911
|
+
matrix$1.half = strokeWidth % 2;
|
|
11772
11912
|
if (aScaleX !== aScaleY) {
|
|
11773
|
-
copy$2(matrix$1, worldTransform);
|
|
11774
11913
|
scale$1(matrix$1, 1 / aScaleX, 1 / aScaleY);
|
|
11775
11914
|
canvas.setWorld(matrix$1, options.matrix);
|
|
11776
11915
|
canvas.beginPath();
|
|
@@ -11779,7 +11918,7 @@ class Stroker extends UI {
|
|
|
11779
11918
|
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
11780
11919
|
}
|
|
11781
11920
|
else {
|
|
11782
|
-
canvas.setWorld(
|
|
11921
|
+
canvas.setWorld(matrix$1, options.matrix);
|
|
11783
11922
|
canvas.beginPath();
|
|
11784
11923
|
if (leaf.__.__useArrow)
|
|
11785
11924
|
leaf.__drawPath(canvas);
|
|
@@ -11814,7 +11953,8 @@ class SelectArea extends Group {
|
|
|
11814
11953
|
super(data);
|
|
11815
11954
|
this.strokeArea = new Rect({ strokeAlign: 'center' });
|
|
11816
11955
|
this.fillArea = new Rect();
|
|
11817
|
-
this.visible =
|
|
11956
|
+
this.visible = 0;
|
|
11957
|
+
this.hittable = false;
|
|
11818
11958
|
this.addMany(this.fillArea, this.strokeArea);
|
|
11819
11959
|
}
|
|
11820
11960
|
setStyle(style, userStyle) {
|
|
@@ -12011,7 +12151,7 @@ class EditSelect extends Group {
|
|
|
12011
12151
|
if (e.multiTouch)
|
|
12012
12152
|
return;
|
|
12013
12153
|
if (this.dragging)
|
|
12014
|
-
this.originList = null, this.selectArea.visible =
|
|
12154
|
+
this.originList = null, this.selectArea.visible = 0;
|
|
12015
12155
|
}
|
|
12016
12156
|
onAutoMove(e) {
|
|
12017
12157
|
if (this.dragging) {
|
|
@@ -12159,8 +12299,11 @@ const EditDataHelper = {
|
|
|
12159
12299
|
scaleY = scaleY < 0 ? -scale : scale;
|
|
12160
12300
|
}
|
|
12161
12301
|
}
|
|
12162
|
-
scaleX
|
|
12163
|
-
|
|
12302
|
+
const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
|
|
12303
|
+
if (useScaleX)
|
|
12304
|
+
scaleX /= changedScaleX;
|
|
12305
|
+
if (useScaleY)
|
|
12306
|
+
scaleY /= changedScaleY;
|
|
12164
12307
|
if (!flipable) {
|
|
12165
12308
|
const { worldTransform } = element;
|
|
12166
12309
|
if (scaleX < 0)
|
|
@@ -12175,22 +12318,27 @@ const EditDataHelper = {
|
|
|
12175
12318
|
localBounds.scaleOf(element.getLocalPointByInner(origin), scaleX, scaleY);
|
|
12176
12319
|
if (!BoundsHelper.includes(allowBounds, localBounds)) {
|
|
12177
12320
|
const realBounds = localBounds.getIntersect(allowBounds);
|
|
12178
|
-
|
|
12179
|
-
|
|
12321
|
+
const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
|
|
12322
|
+
if (useScaleX)
|
|
12323
|
+
scaleX *= fitScaleX;
|
|
12324
|
+
if (useScaleY)
|
|
12325
|
+
scaleY *= fitScaleY;
|
|
12180
12326
|
}
|
|
12181
12327
|
}
|
|
12182
|
-
if (widthRange) {
|
|
12328
|
+
if (useScaleX && widthRange) {
|
|
12183
12329
|
const nowWidth = boxBounds.width * element.scaleX;
|
|
12184
12330
|
scaleX = within(nowWidth * scaleX, widthRange) / nowWidth;
|
|
12185
12331
|
}
|
|
12186
|
-
if (heightRange) {
|
|
12332
|
+
if (useScaleY && heightRange) {
|
|
12187
12333
|
const nowHeight = boxBounds.height * element.scaleY;
|
|
12188
12334
|
scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
|
|
12189
12335
|
}
|
|
12190
|
-
if (Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
12336
|
+
if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
12191
12337
|
scaleX = (scaleX < 0 ? -1 : 1) / worldBoxBounds.width;
|
|
12192
|
-
if (Math.abs(scaleY * worldBoxBounds.height) < 1)
|
|
12338
|
+
if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1)
|
|
12193
12339
|
scaleY = (scaleY < 0 ? -1 : 1) / worldBoxBounds.height;
|
|
12340
|
+
if (lockRatio && scaleX !== scaleY)
|
|
12341
|
+
scaleY = scaleX = Math.min(scaleX, scaleY);
|
|
12194
12342
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
12195
12343
|
},
|
|
12196
12344
|
getRotateData(bounds, direction, current, last, around) {
|
|
@@ -12361,7 +12509,7 @@ class EditBox extends Group {
|
|
|
12361
12509
|
this.view = new Group();
|
|
12362
12510
|
this.rect = new Box({ name: 'rect', hitFill: 'all', hitStroke: 'none', strokeAlign: 'center', hitRadius: 5 });
|
|
12363
12511
|
this.circle = new EditPoint({ name: 'circle', strokeAlign: 'center', around: 'center', cursor: 'crosshair', hitRadius: 5 });
|
|
12364
|
-
this.buttons = new Group({ around: 'center', hitSelf: false });
|
|
12512
|
+
this.buttons = new Group({ around: 'center', hitSelf: false, visible: 0 });
|
|
12365
12513
|
this.resizePoints = [];
|
|
12366
12514
|
this.rotatePoints = [];
|
|
12367
12515
|
this.resizeLines = [];
|
|
@@ -12416,12 +12564,13 @@ class EditBox extends Group {
|
|
|
12416
12564
|
}
|
|
12417
12565
|
}
|
|
12418
12566
|
update(bounds) {
|
|
12419
|
-
const {
|
|
12420
|
-
const {
|
|
12567
|
+
const { rect, circle, buttons, resizePoints, rotatePoints, resizeLines, editor } = this;
|
|
12568
|
+
const { mergeConfig, element, multiple, editMask } = editor;
|
|
12569
|
+
const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
|
|
12421
12570
|
this.visible = !element.locked;
|
|
12571
|
+
editMask.visible = mask ? true : 0;
|
|
12422
12572
|
if (this.view.worldOpacity) {
|
|
12423
12573
|
const { width, height } = bounds;
|
|
12424
|
-
const { rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
|
|
12425
12574
|
const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
|
|
12426
12575
|
const showPoints = editBox && !(hideOnSmall && width < smallSize && height < smallSize);
|
|
12427
12576
|
let point = {}, rotateP, resizeP, resizeL;
|
|
@@ -12456,10 +12605,12 @@ class EditBox extends Group {
|
|
|
12456
12605
|
if (rect.path)
|
|
12457
12606
|
rect.path = null;
|
|
12458
12607
|
rect.set(Object.assign(Object.assign({}, bounds), { visible: multiple ? true : editBox }));
|
|
12459
|
-
buttons.visible = showPoints && buttons.children.length > 0;
|
|
12608
|
+
buttons.visible = showPoints && buttons.children.length > 0 || 0;
|
|
12460
12609
|
if (buttons.visible)
|
|
12461
12610
|
this.layoutButtons(mergeConfig);
|
|
12462
12611
|
}
|
|
12612
|
+
else
|
|
12613
|
+
rect.set(bounds);
|
|
12463
12614
|
}
|
|
12464
12615
|
layoutCircle(config) {
|
|
12465
12616
|
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } = config;
|
|
@@ -12522,7 +12673,7 @@ class EditBox extends Group {
|
|
|
12522
12673
|
}
|
|
12523
12674
|
onDragStart(e) {
|
|
12524
12675
|
this.dragging = true;
|
|
12525
|
-
const point = this.dragPoint = e.current;
|
|
12676
|
+
const point = this.dragPoint = e.current, { pointType } = point;
|
|
12526
12677
|
const { editor, dragStartData } = this, { element } = editor;
|
|
12527
12678
|
if (point.name === 'rect') {
|
|
12528
12679
|
this.moving = true;
|
|
@@ -12533,43 +12684,53 @@ class EditBox extends Group {
|
|
|
12533
12684
|
dragStartData.point = { x: element.x, y: element.y };
|
|
12534
12685
|
dragStartData.bounds = Object.assign({}, element.getLayoutBounds('box', 'local'));
|
|
12535
12686
|
dragStartData.rotation = element.rotation;
|
|
12687
|
+
if (pointType && pointType.includes('resize'))
|
|
12688
|
+
ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
12536
12689
|
}
|
|
12537
12690
|
onDragEnd(e) {
|
|
12538
12691
|
this.dragging = false;
|
|
12539
12692
|
this.dragPoint = null;
|
|
12540
12693
|
this.moving = false;
|
|
12541
|
-
|
|
12694
|
+
const { name, pointType } = e.current;
|
|
12695
|
+
if (name === 'rect')
|
|
12542
12696
|
this.editor.opacity = 1;
|
|
12697
|
+
if (pointType && pointType.includes('resize'))
|
|
12698
|
+
ResizeEvent.resizingKeys = null;
|
|
12543
12699
|
}
|
|
12544
12700
|
onDrag(e) {
|
|
12545
12701
|
const { editor } = this;
|
|
12546
12702
|
const { pointType } = this.enterPoint = e.current;
|
|
12547
|
-
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !editor.mergeConfig.resizeable)
|
|
12703
|
+
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !editor.mergeConfig.resizeable) {
|
|
12548
12704
|
editor.onRotate(e);
|
|
12549
|
-
|
|
12705
|
+
if (pointType === 'resize-rotate')
|
|
12706
|
+
editor.onScale(e);
|
|
12707
|
+
}
|
|
12708
|
+
else if (pointType === 'resize')
|
|
12550
12709
|
editor.onScale(e);
|
|
12551
12710
|
if (pointType === 'skew')
|
|
12552
12711
|
editor.onSkew(e);
|
|
12553
12712
|
updateCursor(editor, e);
|
|
12554
12713
|
}
|
|
12555
12714
|
onArrow(e) {
|
|
12556
|
-
|
|
12557
|
-
|
|
12715
|
+
const { editor } = this;
|
|
12716
|
+
if (editor.editing && editor.mergeConfig.keyEvent) {
|
|
12717
|
+
let x = 0, y = 0;
|
|
12558
12718
|
const distance = e.shiftKey ? 10 : 1;
|
|
12559
12719
|
switch (e.code) {
|
|
12560
12720
|
case 'ArrowDown':
|
|
12561
|
-
|
|
12721
|
+
y = distance;
|
|
12562
12722
|
break;
|
|
12563
12723
|
case 'ArrowUp':
|
|
12564
|
-
|
|
12724
|
+
y = -distance;
|
|
12565
12725
|
break;
|
|
12566
12726
|
case 'ArrowLeft':
|
|
12567
|
-
|
|
12727
|
+
x = -distance;
|
|
12568
12728
|
break;
|
|
12569
12729
|
case 'ArrowRight':
|
|
12570
|
-
|
|
12730
|
+
x = distance;
|
|
12571
12731
|
}
|
|
12572
|
-
|
|
12732
|
+
if (x || y)
|
|
12733
|
+
editor.move(x, y);
|
|
12573
12734
|
}
|
|
12574
12735
|
}
|
|
12575
12736
|
onDoubleTap(e) {
|
|
@@ -12635,22 +12796,32 @@ class EditBox extends Group {
|
|
|
12635
12796
|
}
|
|
12636
12797
|
}
|
|
12637
12798
|
|
|
12799
|
+
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
12638
12800
|
class EditMask extends UI {
|
|
12639
12801
|
constructor(editor) {
|
|
12640
12802
|
super();
|
|
12641
12803
|
this.editor = editor;
|
|
12642
12804
|
this.hittable = false;
|
|
12805
|
+
this.visible = 0;
|
|
12806
|
+
}
|
|
12807
|
+
__updateWorldBounds() {
|
|
12808
|
+
Object.assign(this.__local, bigBounds);
|
|
12809
|
+
Object.assign(this.__world, bigBounds);
|
|
12643
12810
|
}
|
|
12644
12811
|
__draw(canvas, options) {
|
|
12645
|
-
const { editor } = this;
|
|
12646
|
-
|
|
12647
|
-
if (mask && editor.list.length) {
|
|
12648
|
-
const { rect } = editor.editBox;
|
|
12649
|
-
const { width, height } = rect.__;
|
|
12650
|
-
canvas.resetTransform();
|
|
12812
|
+
const { editor } = this, { mask } = editor.mergedConfig;
|
|
12813
|
+
if (mask && editor.editing) {
|
|
12651
12814
|
canvas.fillWorld(canvas.bounds, mask === true ? 'rgba(0,0,0,0.8)' : mask);
|
|
12652
|
-
|
|
12653
|
-
|
|
12815
|
+
if (options.bounds && !options.bounds.hit(editor.editBox.rect.__world, options.matrix))
|
|
12816
|
+
return;
|
|
12817
|
+
canvas.saveBlendMode('destination-out');
|
|
12818
|
+
editor.list.forEach(item => {
|
|
12819
|
+
item.__renderShape(canvas, options);
|
|
12820
|
+
const { __box, parent } = item;
|
|
12821
|
+
if ((item = __box) || ((item = parent) && parent.textBox))
|
|
12822
|
+
item.__renderShape(canvas, options);
|
|
12823
|
+
});
|
|
12824
|
+
canvas.restoreBlendMode();
|
|
12654
12825
|
}
|
|
12655
12826
|
}
|
|
12656
12827
|
destroy() {
|
|
@@ -12953,22 +13124,6 @@ class SimulateElement extends Rect {
|
|
|
12953
13124
|
}
|
|
12954
13125
|
|
|
12955
13126
|
class Editor extends Group {
|
|
12956
|
-
get mergeConfig() {
|
|
12957
|
-
const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
|
|
12958
|
-
if (element && element.editConfig)
|
|
12959
|
-
Object.assign(mergeConfig, element.editConfig);
|
|
12960
|
-
if (dragPoint) {
|
|
12961
|
-
if (dragPoint.editConfig)
|
|
12962
|
-
Object.assign(mergeConfig, dragPoint.editConfig);
|
|
12963
|
-
if (mergeConfig.editSize === 'font-size')
|
|
12964
|
-
mergeConfig.lockRatio = true;
|
|
12965
|
-
if (dragPoint.pointType === 'resize-rotate') {
|
|
12966
|
-
mergeConfig.around || (mergeConfig.around = 'center');
|
|
12967
|
-
isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
|
|
12968
|
-
}
|
|
12969
|
-
}
|
|
12970
|
-
return mergeConfig;
|
|
12971
|
-
}
|
|
12972
13127
|
get list() { return this.leafList.list; }
|
|
12973
13128
|
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
12974
13129
|
get editing() { return !!this.list.length; }
|
|
@@ -12982,7 +13137,6 @@ class Editor extends Group {
|
|
|
12982
13137
|
get buttons() { return this.editBox.buttons; }
|
|
12983
13138
|
constructor(userConfig, data) {
|
|
12984
13139
|
super(data);
|
|
12985
|
-
this.config = DataHelper.clone(config);
|
|
12986
13140
|
this.leafList = new LeafList();
|
|
12987
13141
|
this.openedGroupList = new LeafList();
|
|
12988
13142
|
this.simulateTarget = new SimulateElement(this);
|
|
@@ -12991,8 +13145,10 @@ class Editor extends Group {
|
|
|
12991
13145
|
this.selector = new EditSelect(this);
|
|
12992
13146
|
this.editMask = new EditMask(this);
|
|
12993
13147
|
this.targetEventIds = [];
|
|
13148
|
+
let mergedConfig = DataHelper.clone(config);
|
|
12994
13149
|
if (userConfig)
|
|
12995
|
-
|
|
13150
|
+
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
13151
|
+
this.mergedConfig = this.config = mergedConfig;
|
|
12996
13152
|
this.addMany(this.editMask, this.selector, this.editBox);
|
|
12997
13153
|
if (!Plugin.has('resize'))
|
|
12998
13154
|
this.config.editSize = 'scale';
|
|
@@ -13332,8 +13488,7 @@ class Editor extends Group {
|
|
|
13332
13488
|
}
|
|
13333
13489
|
}
|
|
13334
13490
|
emitInnerEvent(type) {
|
|
13335
|
-
const { innerEditor } = this;
|
|
13336
|
-
const { editTarget } = innerEditor;
|
|
13491
|
+
const { innerEditor } = this, { editTarget } = innerEditor;
|
|
13337
13492
|
const event = new InnerEditorEvent(type, { editTarget, innerEditor });
|
|
13338
13493
|
this.emitEvent(event);
|
|
13339
13494
|
editTarget.emitEvent(event);
|
|
@@ -13358,25 +13513,40 @@ class Editor extends Group {
|
|
|
13358
13513
|
this.leafList.update();
|
|
13359
13514
|
}
|
|
13360
13515
|
}
|
|
13516
|
+
onAppRenderStart(app) {
|
|
13517
|
+
if (this.targetChanged = app.children.some(leafer => leafer !== this.leafer && leafer.renderer.changed))
|
|
13518
|
+
this.editBox.forceRender();
|
|
13519
|
+
}
|
|
13520
|
+
onRenderStart() {
|
|
13521
|
+
if (this.targetChanged)
|
|
13522
|
+
this.update();
|
|
13523
|
+
}
|
|
13524
|
+
onKey(e) {
|
|
13525
|
+
updateCursor(this, e);
|
|
13526
|
+
}
|
|
13361
13527
|
listenTargetEvents() {
|
|
13362
13528
|
if (!this.targetEventIds.length) {
|
|
13363
|
-
const { app, leafer } = this;
|
|
13529
|
+
const { app, leafer, editBox, editMask } = this;
|
|
13364
13530
|
this.targetEventIds = [
|
|
13365
|
-
leafer.on_(RenderEvent.START, this.
|
|
13366
|
-
app.on_(RenderEvent.CHILD_START, this.
|
|
13531
|
+
leafer.on_(RenderEvent.START, this.onRenderStart, this),
|
|
13532
|
+
app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this),
|
|
13367
13533
|
app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
|
|
13368
13534
|
app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
|
|
13369
13535
|
app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
|
|
13370
|
-
app.on_([KeyEvent.HOLD, KeyEvent.UP],
|
|
13371
|
-
app.on_(KeyEvent.DOWN,
|
|
13536
|
+
app.on_([KeyEvent.HOLD, KeyEvent.UP], this.onKey, this),
|
|
13537
|
+
app.on_(KeyEvent.DOWN, editBox.onArrow, editBox)
|
|
13372
13538
|
];
|
|
13539
|
+
if (editMask.visible)
|
|
13540
|
+
editMask.forceRender();
|
|
13373
13541
|
}
|
|
13374
13542
|
}
|
|
13375
13543
|
removeTargetEvents() {
|
|
13376
|
-
const { targetEventIds } = this;
|
|
13544
|
+
const { targetEventIds, editMask } = this;
|
|
13377
13545
|
if (targetEventIds.length) {
|
|
13378
13546
|
this.off_(targetEventIds);
|
|
13379
13547
|
targetEventIds.length = 0;
|
|
13548
|
+
if (editMask.visible)
|
|
13549
|
+
editMask.forceRender();
|
|
13380
13550
|
}
|
|
13381
13551
|
}
|
|
13382
13552
|
destroy() {
|
|
@@ -13390,6 +13560,9 @@ class Editor extends Group {
|
|
|
13390
13560
|
}
|
|
13391
13561
|
}
|
|
13392
13562
|
}
|
|
13563
|
+
__decorate([
|
|
13564
|
+
mergeConfigAttr()
|
|
13565
|
+
], Editor.prototype, "mergeConfig", void 0);
|
|
13393
13566
|
__decorate([
|
|
13394
13567
|
targetAttr(onHover)
|
|
13395
13568
|
], Editor.prototype, "hoverTarget", void 0);
|
|
@@ -13454,9 +13627,7 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
13454
13627
|
const { moveX, moveY, editor } = e;
|
|
13455
13628
|
const { app, list } = editor;
|
|
13456
13629
|
app.lockLayout();
|
|
13457
|
-
list.forEach(target => {
|
|
13458
|
-
target.moveWorld(moveX, moveY);
|
|
13459
|
-
});
|
|
13630
|
+
list.forEach(target => { target.moveWorld(moveX, moveY); });
|
|
13460
13631
|
app.unlockLayout();
|
|
13461
13632
|
}
|
|
13462
13633
|
onScale(e) {
|
|
@@ -13465,12 +13636,10 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
13465
13636
|
app.lockLayout();
|
|
13466
13637
|
list.forEach(target => {
|
|
13467
13638
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
13468
|
-
if (transform)
|
|
13639
|
+
if (transform)
|
|
13469
13640
|
target.transformWorld(transform, resize);
|
|
13470
|
-
|
|
13471
|
-
else {
|
|
13641
|
+
else
|
|
13472
13642
|
target.scaleOfWorld(worldOrigin, scaleX, scaleY, resize);
|
|
13473
|
-
}
|
|
13474
13643
|
});
|
|
13475
13644
|
app.unlockLayout();
|
|
13476
13645
|
}
|
|
@@ -13480,12 +13649,10 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
13480
13649
|
app.lockLayout();
|
|
13481
13650
|
list.forEach(target => {
|
|
13482
13651
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
13483
|
-
if (transform)
|
|
13652
|
+
if (transform)
|
|
13484
13653
|
target.transformWorld(transform, resize);
|
|
13485
|
-
|
|
13486
|
-
else {
|
|
13654
|
+
else
|
|
13487
13655
|
target.rotateOfWorld(worldOrigin, rotation);
|
|
13488
|
-
}
|
|
13489
13656
|
});
|
|
13490
13657
|
app.unlockLayout();
|
|
13491
13658
|
}
|
|
@@ -13495,12 +13662,10 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
13495
13662
|
app.lockLayout();
|
|
13496
13663
|
list.forEach(target => {
|
|
13497
13664
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
13498
|
-
if (transform)
|
|
13665
|
+
if (transform)
|
|
13499
13666
|
target.transformWorld(transform, resize);
|
|
13500
|
-
|
|
13501
|
-
else {
|
|
13667
|
+
else
|
|
13502
13668
|
target.skewOfWorld(worldOrigin, skewX, skewY, resize);
|
|
13503
|
-
}
|
|
13504
13669
|
});
|
|
13505
13670
|
app.unlockLayout();
|
|
13506
13671
|
}
|
|
@@ -13788,16 +13953,21 @@ leaf.__scaleResize = function (scaleX, scaleY) {
|
|
|
13788
13953
|
scaleResize(this, scaleX, scaleY);
|
|
13789
13954
|
};
|
|
13790
13955
|
leaf.resizeWidth = function (width) {
|
|
13791
|
-
const scale = width / this.getBounds('box', 'local').width;
|
|
13956
|
+
const scale = width / this.getBounds('box', 'local').width || 1;
|
|
13792
13957
|
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
13793
13958
|
};
|
|
13794
13959
|
leaf.resizeHeight = function (height) {
|
|
13795
|
-
const scale = height / this.getBounds('box', 'local').height;
|
|
13960
|
+
const scale = height / this.getBounds('box', 'local').height || 1;
|
|
13796
13961
|
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
13797
13962
|
};
|
|
13798
13963
|
Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
13799
13964
|
const { app, editConfig } = this, editor = app && app.editor, dragPoint = editor && editor.dragPoint;
|
|
13800
|
-
|
|
13965
|
+
const { __autoWidth, __autoHeight, textAlign, verticalAlign } = this.__, { boxBounds } = this.__layout;
|
|
13966
|
+
if (__autoWidth && textAlign !== 'left' && scaleX !== 1)
|
|
13967
|
+
this.x += boxBounds.x;
|
|
13968
|
+
if (__autoHeight && verticalAlign !== 'top' && scaleY !== 1)
|
|
13969
|
+
this.y += boxBounds.y;
|
|
13970
|
+
if (this.__.resizeFontSize || (editConfig && editConfig.editSize === 'font-size') || (dragPoint && editor.mergedConfig.editSize === 'font-size')) {
|
|
13801
13971
|
scaleResizeFontSize(this, scaleX, scaleY, dragPoint && dragPoint.direction);
|
|
13802
13972
|
}
|
|
13803
13973
|
else {
|
|
@@ -14120,17 +14290,33 @@ interaction.transformEnd = function () {
|
|
|
14120
14290
|
this.transformer.transformEnd();
|
|
14121
14291
|
};
|
|
14122
14292
|
interaction.wheel = function (data) {
|
|
14123
|
-
const { wheel } = this.config;
|
|
14293
|
+
const { wheel, pointer } = this.config, { posDeltaSpeed, negDeltaSpeed } = wheel;
|
|
14124
14294
|
if (wheel.disabled)
|
|
14125
14295
|
return;
|
|
14296
|
+
if (data.deltaX > 0)
|
|
14297
|
+
posDeltaSpeed && (data.deltaX *= posDeltaSpeed);
|
|
14298
|
+
else
|
|
14299
|
+
negDeltaSpeed && (data.deltaX *= negDeltaSpeed);
|
|
14300
|
+
if (data.deltaY > 0)
|
|
14301
|
+
posDeltaSpeed && (data.deltaY *= posDeltaSpeed);
|
|
14302
|
+
else
|
|
14303
|
+
negDeltaSpeed && (data.deltaY *= negDeltaSpeed);
|
|
14126
14304
|
const scale = wheel.getScale ? wheel.getScale(data, wheel) : WheelEventHelper.getScale(data, wheel);
|
|
14127
|
-
scale !== 1
|
|
14305
|
+
if (scale !== 1)
|
|
14306
|
+
this.zoom(getZoomEventData(scale, data));
|
|
14307
|
+
else {
|
|
14308
|
+
const move = wheel.getMove ? wheel.getMove(data, wheel) : WheelEventHelper.getMove(data, wheel);
|
|
14309
|
+
if (pointer.snap)
|
|
14310
|
+
PointHelper.round(move);
|
|
14311
|
+
this.move(getMoveEventData(move, data));
|
|
14312
|
+
}
|
|
14128
14313
|
};
|
|
14129
14314
|
interaction.multiTouch = function (data, list) {
|
|
14130
14315
|
if (this.config.multiTouch.disabled)
|
|
14131
14316
|
return;
|
|
14132
14317
|
const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
|
|
14133
14318
|
Object.assign(data, center);
|
|
14319
|
+
this.pointerWaitCancel();
|
|
14134
14320
|
this.rotate(getRotateEventData(rotation, data));
|
|
14135
14321
|
this.zoom(getZoomEventData(scale, data));
|
|
14136
14322
|
this.move(getMoveEventData(move, data));
|
|
@@ -15119,7 +15305,7 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
15119
15305
|
const { editor } = this;
|
|
15120
15306
|
const { config } = editor.app;
|
|
15121
15307
|
const text = this.editTarget;
|
|
15122
|
-
text.
|
|
15308
|
+
text.textEditing = true;
|
|
15123
15309
|
this.isHTMLText = !(text instanceof Text);
|
|
15124
15310
|
this._keyEvent = config.keyEvent;
|
|
15125
15311
|
config.keyEvent = false;
|
|
@@ -15236,7 +15422,7 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
15236
15422
|
const { editTarget: text, editor, editDom: dom } = this;
|
|
15237
15423
|
if (text) {
|
|
15238
15424
|
this.onInput();
|
|
15239
|
-
text.
|
|
15425
|
+
text.textEditing = undefined;
|
|
15240
15426
|
if (editor.app)
|
|
15241
15427
|
editor.app.config.keyEvent = this._keyEvent;
|
|
15242
15428
|
editor.off_(this.eventIds);
|
|
@@ -15254,6 +15440,7 @@ TextEditor = __decorate([
|
|
|
15254
15440
|
], TextEditor);
|
|
15255
15441
|
|
|
15256
15442
|
Plugin.add('text-editor', 'editor');
|
|
15443
|
+
Text.addAttr('textEditing', false, surfaceType);
|
|
15257
15444
|
|
|
15258
15445
|
class HTMLTextData extends ImageData {
|
|
15259
15446
|
setText(value) {
|