@leafer-editor/worker 1.0.4 → 1.0.6
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 +391 -293
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +391 -293
- package/dist/worker.module.min.js +1 -1
- package/package.json +9 -9
package/dist/worker.js
CHANGED
|
@@ -555,6 +555,12 @@ var LeaferUI = (function (exports) {
|
|
|
555
555
|
to.y = t.y + sin$4(r) * distance;
|
|
556
556
|
return to;
|
|
557
557
|
},
|
|
558
|
+
toNumberPoints(originPoints) {
|
|
559
|
+
let points = originPoints;
|
|
560
|
+
if (typeof originPoints[0] === 'object')
|
|
561
|
+
points = [], originPoints.forEach(p => points.push(p.x, p.y));
|
|
562
|
+
return points;
|
|
563
|
+
},
|
|
558
564
|
reset(t) {
|
|
559
565
|
P$7.reset(t);
|
|
560
566
|
}
|
|
@@ -1545,7 +1551,10 @@ var LeaferUI = (function (exports) {
|
|
|
1545
1551
|
|
|
1546
1552
|
class LeafData {
|
|
1547
1553
|
get __useNaturalRatio() { return true; }
|
|
1548
|
-
get __isLinePath() {
|
|
1554
|
+
get __isLinePath() {
|
|
1555
|
+
const { path } = this;
|
|
1556
|
+
return path && path.length === 6 && path[0] === 1;
|
|
1557
|
+
}
|
|
1549
1558
|
get __blendMode() {
|
|
1550
1559
|
if (this.eraser && this.eraser !== 'path')
|
|
1551
1560
|
return 'destination-out';
|
|
@@ -2308,11 +2317,12 @@ var LeaferUI = (function (exports) {
|
|
|
2308
2317
|
|
|
2309
2318
|
const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$4, PI: PI$2, sqrt: sqrt$1, pow } = Math;
|
|
2310
2319
|
const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
|
|
2311
|
-
const { set } = PointHelper;
|
|
2320
|
+
const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
|
|
2312
2321
|
const { M: M$8, L: L$9, C: C$8, Q: Q$7, Z: Z$7 } = PathCommandMap;
|
|
2313
2322
|
const tempPoint$2 = {};
|
|
2314
2323
|
const BezierHelper = {
|
|
2315
|
-
points(data,
|
|
2324
|
+
points(data, originPoints, curve, close) {
|
|
2325
|
+
let points = toNumberPoints$1(originPoints);
|
|
2316
2326
|
data.push(M$8, points[0], points[1]);
|
|
2317
2327
|
if (curve && points.length > 5) {
|
|
2318
2328
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
@@ -2821,6 +2831,27 @@ var LeaferUI = (function (exports) {
|
|
|
2821
2831
|
}
|
|
2822
2832
|
return data;
|
|
2823
2833
|
},
|
|
2834
|
+
objectToCanvasData(list) {
|
|
2835
|
+
const data = [];
|
|
2836
|
+
list.forEach(item => {
|
|
2837
|
+
switch (item.name) {
|
|
2838
|
+
case 'M':
|
|
2839
|
+
data.push(M$7, item.x, item.y);
|
|
2840
|
+
break;
|
|
2841
|
+
case 'L':
|
|
2842
|
+
data.push(L$8, item.x, item.y);
|
|
2843
|
+
break;
|
|
2844
|
+
case 'C':
|
|
2845
|
+
data.push(C$7, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
|
|
2846
|
+
break;
|
|
2847
|
+
case 'Q':
|
|
2848
|
+
data.push(Q$6, item.x1, item.y1, item.x, item.y);
|
|
2849
|
+
break;
|
|
2850
|
+
case 'Z': data.push(Z$6);
|
|
2851
|
+
}
|
|
2852
|
+
});
|
|
2853
|
+
return data;
|
|
2854
|
+
},
|
|
2824
2855
|
copyData(data, old, index, count) {
|
|
2825
2856
|
for (let i = index, end = index + count; i < end; i++) {
|
|
2826
2857
|
data.push(old[i]);
|
|
@@ -4059,7 +4090,7 @@ var LeaferUI = (function (exports) {
|
|
|
4059
4090
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4060
4091
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
4061
4092
|
waitAutoLayout = true;
|
|
4062
|
-
updateMatrix$
|
|
4093
|
+
updateMatrix$3(leaf, checkAutoLayout, waitAutoLayout);
|
|
4063
4094
|
if (leaf.isBranch) {
|
|
4064
4095
|
const { children } = leaf;
|
|
4065
4096
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
@@ -4229,7 +4260,7 @@ var LeaferUI = (function (exports) {
|
|
|
4229
4260
|
}
|
|
4230
4261
|
};
|
|
4231
4262
|
const L$3 = LeafHelper;
|
|
4232
|
-
const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$
|
|
4263
|
+
const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$3, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$3;
|
|
4233
4264
|
function moveByMatrix(t, matrix) {
|
|
4234
4265
|
const { e, f } = t.__localMatrix;
|
|
4235
4266
|
t.x += matrix.e - e;
|
|
@@ -4758,6 +4789,7 @@ var LeaferUI = (function (exports) {
|
|
|
4758
4789
|
}
|
|
4759
4790
|
}
|
|
4760
4791
|
RenderEvent.REQUEST = 'render.request';
|
|
4792
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4761
4793
|
RenderEvent.START = 'render.start';
|
|
4762
4794
|
RenderEvent.BEFORE = 'render.before';
|
|
4763
4795
|
RenderEvent.RENDER = 'render';
|
|
@@ -4933,7 +4965,7 @@ var LeaferUI = (function (exports) {
|
|
|
4933
4965
|
const debug$8 = Debug.get('setAttr');
|
|
4934
4966
|
const LeafDataProxy = {
|
|
4935
4967
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4936
|
-
if (this.
|
|
4968
|
+
if (this.leaferIsCreated) {
|
|
4937
4969
|
const oldValue = this.__.__getInput(name);
|
|
4938
4970
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4939
4971
|
debug$8.warn(this.innerName, name, newValue);
|
|
@@ -5003,9 +5035,9 @@ var LeaferUI = (function (exports) {
|
|
|
5003
5035
|
}
|
|
5004
5036
|
};
|
|
5005
5037
|
|
|
5006
|
-
const { updateMatrix: updateMatrix$
|
|
5038
|
+
const { updateMatrix: updateMatrix$2, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5007
5039
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5008
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5040
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$8 } = BoundsHelper;
|
|
5009
5041
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
5010
5042
|
const LeafBounds = {
|
|
5011
5043
|
__updateWorldBounds() {
|
|
@@ -5088,7 +5120,7 @@ var LeaferUI = (function (exports) {
|
|
|
5088
5120
|
const b = this.__layout.boxBounds;
|
|
5089
5121
|
const data = this.__;
|
|
5090
5122
|
if (data.__pathInputed) {
|
|
5091
|
-
toBounds$2(data.
|
|
5123
|
+
toBounds$2(data.path, b);
|
|
5092
5124
|
}
|
|
5093
5125
|
else {
|
|
5094
5126
|
b.x = 0;
|
|
@@ -5100,7 +5132,7 @@ var LeaferUI = (function (exports) {
|
|
|
5100
5132
|
__updateAutoLayout() {
|
|
5101
5133
|
this.__layout.matrixChanged = true;
|
|
5102
5134
|
if (this.isBranch) {
|
|
5103
|
-
if (this.
|
|
5135
|
+
if (this.leaferIsReady)
|
|
5104
5136
|
this.leafer.layouter.addExtra(this);
|
|
5105
5137
|
if (this.__.flow) {
|
|
5106
5138
|
if (this.__layout.boxChanged)
|
|
@@ -5116,7 +5148,7 @@ var LeaferUI = (function (exports) {
|
|
|
5116
5148
|
}
|
|
5117
5149
|
}
|
|
5118
5150
|
else {
|
|
5119
|
-
updateMatrix$
|
|
5151
|
+
updateMatrix$2(this);
|
|
5120
5152
|
}
|
|
5121
5153
|
},
|
|
5122
5154
|
__updateNaturalSize() {
|
|
@@ -5126,11 +5158,11 @@ var LeaferUI = (function (exports) {
|
|
|
5126
5158
|
},
|
|
5127
5159
|
__updateStrokeBounds() {
|
|
5128
5160
|
const layout = this.__layout;
|
|
5129
|
-
copyAndSpread$
|
|
5161
|
+
copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5130
5162
|
},
|
|
5131
5163
|
__updateRenderBounds() {
|
|
5132
5164
|
const layout = this.__layout;
|
|
5133
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5165
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$8(layout.renderBounds, layout.strokeBounds);
|
|
5134
5166
|
}
|
|
5135
5167
|
};
|
|
5136
5168
|
|
|
@@ -5161,7 +5193,7 @@ var LeaferUI = (function (exports) {
|
|
|
5161
5193
|
if (this.__worldOpacity) {
|
|
5162
5194
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5163
5195
|
this.__drawRenderPath(canvas);
|
|
5164
|
-
this.
|
|
5196
|
+
this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
|
|
5165
5197
|
}
|
|
5166
5198
|
},
|
|
5167
5199
|
__updateWorldOpacity() {
|
|
@@ -5235,6 +5267,8 @@ var LeaferUI = (function (exports) {
|
|
|
5235
5267
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5236
5268
|
get __DataProcessor() { return LeafData; }
|
|
5237
5269
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5270
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5271
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5238
5272
|
get isLeafer() { return false; }
|
|
5239
5273
|
get isBranch() { return false; }
|
|
5240
5274
|
get isBranchLeaf() { return false; }
|
|
@@ -5676,10 +5710,17 @@ var LeaferUI = (function (exports) {
|
|
|
5676
5710
|
add(child, index) {
|
|
5677
5711
|
if (child === this)
|
|
5678
5712
|
return;
|
|
5713
|
+
const noIndex = index === undefined;
|
|
5714
|
+
if (!child.__) {
|
|
5715
|
+
if (child instanceof Array)
|
|
5716
|
+
return child.forEach(item => { this.add(item, index); noIndex || index++; });
|
|
5717
|
+
else
|
|
5718
|
+
child = UICreator.get(child.tag, child);
|
|
5719
|
+
}
|
|
5679
5720
|
if (child.parent)
|
|
5680
5721
|
child.parent.remove(child);
|
|
5681
5722
|
child.parent = this;
|
|
5682
|
-
|
|
5723
|
+
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5683
5724
|
if (child.isBranch)
|
|
5684
5725
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5685
5726
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
@@ -5693,15 +5734,17 @@ var LeaferUI = (function (exports) {
|
|
|
5693
5734
|
}
|
|
5694
5735
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5695
5736
|
}
|
|
5696
|
-
addMany(...children) {
|
|
5697
|
-
children.forEach(child => this.add(child));
|
|
5698
|
-
}
|
|
5737
|
+
addMany(...children) { this.add(children); }
|
|
5699
5738
|
remove(child, destroy) {
|
|
5700
5739
|
if (child) {
|
|
5701
|
-
if (child.
|
|
5702
|
-
|
|
5740
|
+
if (child.__) {
|
|
5741
|
+
if (child.animationOut)
|
|
5742
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5743
|
+
else
|
|
5744
|
+
this.__remove(child, destroy);
|
|
5745
|
+
}
|
|
5703
5746
|
else
|
|
5704
|
-
this.
|
|
5747
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5705
5748
|
}
|
|
5706
5749
|
else if (child === undefined) {
|
|
5707
5750
|
super.remove(null, destroy);
|
|
@@ -5919,7 +5962,7 @@ var LeaferUI = (function (exports) {
|
|
|
5919
5962
|
}
|
|
5920
5963
|
}
|
|
5921
5964
|
|
|
5922
|
-
const version = "1.0.
|
|
5965
|
+
const version = "1.0.6";
|
|
5923
5966
|
|
|
5924
5967
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5925
5968
|
get allowBackgroundColor() { return true; }
|
|
@@ -6105,7 +6148,7 @@ var LeaferUI = (function (exports) {
|
|
|
6105
6148
|
|
|
6106
6149
|
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
|
|
6107
6150
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
6108
|
-
function updateMatrix(updateList, levelList) {
|
|
6151
|
+
function updateMatrix$1(updateList, levelList) {
|
|
6109
6152
|
let layout;
|
|
6110
6153
|
updateList.list.forEach(leaf => {
|
|
6111
6154
|
layout = leaf.__layout;
|
|
@@ -6273,7 +6316,7 @@ var LeaferUI = (function (exports) {
|
|
|
6273
6316
|
target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
|
|
6274
6317
|
this.extraBlock = null;
|
|
6275
6318
|
updateList.sort();
|
|
6276
|
-
updateMatrix(updateList, this.__levelList);
|
|
6319
|
+
updateMatrix$1(updateList, this.__levelList);
|
|
6277
6320
|
updateBounds(this.__levelList);
|
|
6278
6321
|
updateChange(updateList);
|
|
6279
6322
|
if (this.extraBlock)
|
|
@@ -6388,6 +6431,7 @@ var LeaferUI = (function (exports) {
|
|
|
6388
6431
|
this.totalBounds = new Bounds();
|
|
6389
6432
|
debug$6.log(target.innerName, '--->');
|
|
6390
6433
|
try {
|
|
6434
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6391
6435
|
this.emitRender(RenderEvent.START);
|
|
6392
6436
|
this.renderOnce(callback);
|
|
6393
6437
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6685,7 +6729,7 @@ var LeaferUI = (function (exports) {
|
|
|
6685
6729
|
if (child.isBranch) {
|
|
6686
6730
|
if (hit || child.__ignoreHitWorld) {
|
|
6687
6731
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
6688
|
-
if (child.isBranchLeaf
|
|
6732
|
+
if (child.isBranchLeaf)
|
|
6689
6733
|
this.hitChild(child, point);
|
|
6690
6734
|
}
|
|
6691
6735
|
}
|
|
@@ -6898,6 +6942,13 @@ var LeaferUI = (function (exports) {
|
|
|
6898
6942
|
|
|
6899
6943
|
const TextConvert = {};
|
|
6900
6944
|
const ColorConvert = {};
|
|
6945
|
+
const UnitConvert = {
|
|
6946
|
+
number(value, percentRefer) {
|
|
6947
|
+
if (typeof value === 'object')
|
|
6948
|
+
return value.type === 'percent' ? value.value * percentRefer : value.value;
|
|
6949
|
+
return value;
|
|
6950
|
+
}
|
|
6951
|
+
};
|
|
6901
6952
|
const PathArrow = {};
|
|
6902
6953
|
const Paint = {};
|
|
6903
6954
|
const PaintImage = {};
|
|
@@ -6918,7 +6969,7 @@ var LeaferUI = (function (exports) {
|
|
|
6918
6969
|
}
|
|
6919
6970
|
};
|
|
6920
6971
|
|
|
6921
|
-
const { parse } = PathConvert;
|
|
6972
|
+
const { parse, objectToCanvasData } = PathConvert;
|
|
6922
6973
|
const emptyPaint = {};
|
|
6923
6974
|
const debug$5 = Debug.get('UIData');
|
|
6924
6975
|
class UIData extends LeafData {
|
|
@@ -6932,10 +6983,11 @@ var LeaferUI = (function (exports) {
|
|
|
6932
6983
|
scaleX = -scaleX;
|
|
6933
6984
|
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
6934
6985
|
}
|
|
6935
|
-
else
|
|
6986
|
+
else
|
|
6936
6987
|
return strokeWidth;
|
|
6937
|
-
}
|
|
6938
6988
|
}
|
|
6989
|
+
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
6990
|
+
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
6939
6991
|
get __autoWidth() { return !this._width; }
|
|
6940
6992
|
get __autoHeight() { return !this._height; }
|
|
6941
6993
|
get __autoSide() { return !this._width || !this._height; }
|
|
@@ -6952,9 +7004,8 @@ var LeaferUI = (function (exports) {
|
|
|
6952
7004
|
this.__leaf.scaleX *= -1;
|
|
6953
7005
|
debug$5.warn('width < 0, instead -scaleX ', this);
|
|
6954
7006
|
}
|
|
6955
|
-
else
|
|
7007
|
+
else
|
|
6956
7008
|
this._width = value;
|
|
6957
|
-
}
|
|
6958
7009
|
}
|
|
6959
7010
|
setHeight(value) {
|
|
6960
7011
|
if (value < 0) {
|
|
@@ -6962,9 +7013,8 @@ var LeaferUI = (function (exports) {
|
|
|
6962
7013
|
this.__leaf.scaleY *= -1;
|
|
6963
7014
|
debug$5.warn('height < 0, instead -scaleY', this);
|
|
6964
7015
|
}
|
|
6965
|
-
else
|
|
7016
|
+
else
|
|
6966
7017
|
this._height = value;
|
|
6967
|
-
}
|
|
6968
7018
|
}
|
|
6969
7019
|
setFill(value) {
|
|
6970
7020
|
if (this.__naturalWidth)
|
|
@@ -7005,9 +7055,10 @@ var LeaferUI = (function (exports) {
|
|
|
7005
7055
|
}
|
|
7006
7056
|
}
|
|
7007
7057
|
setPath(value) {
|
|
7008
|
-
|
|
7058
|
+
const isString = typeof value === 'string';
|
|
7059
|
+
if (isString || (value && typeof value[0] === 'object')) {
|
|
7009
7060
|
this.__setInput('path', value);
|
|
7010
|
-
this._path = parse(value);
|
|
7061
|
+
this._path = isString ? parse(value) : objectToCanvasData(value);
|
|
7011
7062
|
}
|
|
7012
7063
|
else {
|
|
7013
7064
|
if (this.__input)
|
|
@@ -7022,12 +7073,8 @@ var LeaferUI = (function (exports) {
|
|
|
7022
7073
|
value = value.filter((item) => item.visible !== false);
|
|
7023
7074
|
this._shadow = value.length ? value : null;
|
|
7024
7075
|
}
|
|
7025
|
-
else
|
|
7026
|
-
this._shadow = value.visible
|
|
7027
|
-
}
|
|
7028
|
-
else {
|
|
7029
|
-
this._shadow = null;
|
|
7030
|
-
}
|
|
7076
|
+
else
|
|
7077
|
+
this._shadow = value && value.visible !== false ? [value] : null;
|
|
7031
7078
|
}
|
|
7032
7079
|
setInnerShadow(value) {
|
|
7033
7080
|
this.__setInput('innerShadow', value);
|
|
@@ -7036,12 +7083,8 @@ var LeaferUI = (function (exports) {
|
|
|
7036
7083
|
value = value.filter((item) => item.visible !== false);
|
|
7037
7084
|
this._innerShadow = value.length ? value : null;
|
|
7038
7085
|
}
|
|
7039
|
-
else
|
|
7040
|
-
this._innerShadow = value.visible
|
|
7041
|
-
}
|
|
7042
|
-
else {
|
|
7043
|
-
this._innerShadow = null;
|
|
7044
|
-
}
|
|
7086
|
+
else
|
|
7087
|
+
this._innerShadow = value && value.visible !== false ? [value] : null;
|
|
7045
7088
|
}
|
|
7046
7089
|
__computePaint() {
|
|
7047
7090
|
const { fill, stroke } = this.__input;
|
|
@@ -7052,24 +7095,19 @@ var LeaferUI = (function (exports) {
|
|
|
7052
7095
|
this.__needComputePaint = false;
|
|
7053
7096
|
}
|
|
7054
7097
|
}
|
|
7055
|
-
const UnitConvert = {
|
|
7056
|
-
number(value, percentRefer) {
|
|
7057
|
-
if (typeof value === 'object')
|
|
7058
|
-
return value.type === 'percent' ? value.value * percentRefer : value.value;
|
|
7059
|
-
return value;
|
|
7060
|
-
}
|
|
7061
|
-
};
|
|
7062
7098
|
|
|
7063
7099
|
class GroupData extends UIData {
|
|
7064
7100
|
}
|
|
7065
7101
|
|
|
7066
7102
|
class BoxData extends GroupData {
|
|
7067
7103
|
get __boxStroke() { return !this.__pathInputed; }
|
|
7104
|
+
get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
|
|
7105
|
+
get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
|
|
7068
7106
|
}
|
|
7069
7107
|
|
|
7070
7108
|
class LeaferData extends GroupData {
|
|
7071
|
-
__getInputData() {
|
|
7072
|
-
const data = super.__getInputData();
|
|
7109
|
+
__getInputData(names, options) {
|
|
7110
|
+
const data = super.__getInputData(names, options);
|
|
7073
7111
|
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
7074
7112
|
return data;
|
|
7075
7113
|
}
|
|
@@ -7096,6 +7134,7 @@ var LeaferUI = (function (exports) {
|
|
|
7096
7134
|
}
|
|
7097
7135
|
|
|
7098
7136
|
class PathData extends UIData {
|
|
7137
|
+
get __pathInputed() { return 2; }
|
|
7099
7138
|
}
|
|
7100
7139
|
|
|
7101
7140
|
class PenData extends GroupData {
|
|
@@ -7142,16 +7181,18 @@ var LeaferUI = (function (exports) {
|
|
|
7142
7181
|
delete data.fill;
|
|
7143
7182
|
return data;
|
|
7144
7183
|
}
|
|
7145
|
-
__getInputData() {
|
|
7146
|
-
const data = super.__getInputData();
|
|
7184
|
+
__getInputData(names, options) {
|
|
7185
|
+
const data = super.__getInputData(names, options);
|
|
7147
7186
|
delete data.fill;
|
|
7148
7187
|
return data;
|
|
7149
7188
|
}
|
|
7150
7189
|
}
|
|
7151
7190
|
|
|
7152
7191
|
class CanvasData extends RectData {
|
|
7153
|
-
|
|
7154
|
-
|
|
7192
|
+
get __isCanvas() { return true; }
|
|
7193
|
+
get __drawAfterFill() { return true; }
|
|
7194
|
+
__getInputData(names, options) {
|
|
7195
|
+
const data = super.__getInputData(names, options);
|
|
7155
7196
|
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7156
7197
|
return data;
|
|
7157
7198
|
}
|
|
@@ -7178,16 +7219,12 @@ var LeaferUI = (function (exports) {
|
|
|
7178
7219
|
let width = 0;
|
|
7179
7220
|
const { shadow, innerShadow, blur, backgroundBlur } = this.__;
|
|
7180
7221
|
if (shadow)
|
|
7181
|
-
shadow.forEach(item =>
|
|
7182
|
-
width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5);
|
|
7183
|
-
});
|
|
7222
|
+
shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
|
|
7184
7223
|
if (blur)
|
|
7185
7224
|
width = Math.max(width, blur);
|
|
7186
7225
|
let shapeWidth = width = Math.ceil(width);
|
|
7187
7226
|
if (innerShadow)
|
|
7188
|
-
innerShadow.forEach(item =>
|
|
7189
|
-
shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5);
|
|
7190
|
-
});
|
|
7227
|
+
innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
|
|
7191
7228
|
if (backgroundBlur)
|
|
7192
7229
|
shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
7193
7230
|
this.__layout.renderShapeSpread = shapeWidth;
|
|
@@ -7269,6 +7306,16 @@ var LeaferUI = (function (exports) {
|
|
|
7269
7306
|
if (stroke && !ignoreStroke)
|
|
7270
7307
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7271
7308
|
}
|
|
7309
|
+
},
|
|
7310
|
+
__drawAfterFill(canvas, options) {
|
|
7311
|
+
if (this.__.__clipAfterFill) {
|
|
7312
|
+
canvas.save();
|
|
7313
|
+
this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
|
|
7314
|
+
this.__drawContent(canvas, options);
|
|
7315
|
+
canvas.restore();
|
|
7316
|
+
}
|
|
7317
|
+
else
|
|
7318
|
+
this.__drawContent(canvas, options);
|
|
7272
7319
|
}
|
|
7273
7320
|
};
|
|
7274
7321
|
function drawFast(ui, canvas, options) {
|
|
@@ -7335,8 +7382,8 @@ var LeaferUI = (function (exports) {
|
|
|
7335
7382
|
return pen;
|
|
7336
7383
|
}
|
|
7337
7384
|
get editConfig() { return undefined; }
|
|
7338
|
-
get editOuter() { return
|
|
7339
|
-
get editInner() { return '
|
|
7385
|
+
get editOuter() { return ''; }
|
|
7386
|
+
get editInner() { return ''; }
|
|
7340
7387
|
constructor(data) {
|
|
7341
7388
|
super(data);
|
|
7342
7389
|
}
|
|
@@ -7347,9 +7394,8 @@ var LeaferUI = (function (exports) {
|
|
|
7347
7394
|
Object.assign(this, data);
|
|
7348
7395
|
this.lockNormalStyle = false;
|
|
7349
7396
|
}
|
|
7350
|
-
else
|
|
7397
|
+
else
|
|
7351
7398
|
Object.assign(this, data);
|
|
7352
|
-
}
|
|
7353
7399
|
}
|
|
7354
7400
|
get(name) {
|
|
7355
7401
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -7395,12 +7441,7 @@ var LeaferUI = (function (exports) {
|
|
|
7395
7441
|
this.__drawPathByData(canvas, this.__.path);
|
|
7396
7442
|
}
|
|
7397
7443
|
__drawPathByData(drawer, data) {
|
|
7398
|
-
|
|
7399
|
-
PathDrawer.drawPathByData(drawer, data);
|
|
7400
|
-
}
|
|
7401
|
-
else {
|
|
7402
|
-
this.__drawPathByBox(drawer);
|
|
7403
|
-
}
|
|
7444
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
7404
7445
|
}
|
|
7405
7446
|
__drawPathByBox(drawer) {
|
|
7406
7447
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
@@ -7408,9 +7449,8 @@ var LeaferUI = (function (exports) {
|
|
|
7408
7449
|
const { cornerRadius } = this.__;
|
|
7409
7450
|
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
7410
7451
|
}
|
|
7411
|
-
else
|
|
7452
|
+
else
|
|
7412
7453
|
drawer.rect(x, y, width, height);
|
|
7413
|
-
}
|
|
7414
7454
|
}
|
|
7415
7455
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7416
7456
|
return needPlugin('animate');
|
|
@@ -7657,23 +7697,13 @@ var LeaferUI = (function (exports) {
|
|
|
7657
7697
|
if (data.children) {
|
|
7658
7698
|
const { children } = data;
|
|
7659
7699
|
delete data.children;
|
|
7660
|
-
|
|
7661
|
-
this.__setBranch();
|
|
7662
|
-
}
|
|
7663
|
-
else {
|
|
7664
|
-
this.clear();
|
|
7665
|
-
}
|
|
7700
|
+
this.children ? this.clear() : this.__setBranch();
|
|
7666
7701
|
super.set(data, isTemp);
|
|
7667
|
-
|
|
7668
|
-
children.forEach(childData => {
|
|
7669
|
-
child = childData.__ ? childData : UICreator.get(childData.tag, childData);
|
|
7670
|
-
this.add(child);
|
|
7671
|
-
});
|
|
7702
|
+
children.forEach(child => this.add(child));
|
|
7672
7703
|
data.children = children;
|
|
7673
7704
|
}
|
|
7674
|
-
else
|
|
7705
|
+
else
|
|
7675
7706
|
super.set(data, isTemp);
|
|
7676
|
-
}
|
|
7677
7707
|
}
|
|
7678
7708
|
toJSON(options) {
|
|
7679
7709
|
const data = super.toJSON(options);
|
|
@@ -8093,10 +8123,9 @@ var LeaferUI = (function (exports) {
|
|
|
8093
8123
|
registerUI()
|
|
8094
8124
|
], exports.Rect);
|
|
8095
8125
|
|
|
8096
|
-
const
|
|
8097
|
-
const group$1 = exports.Group.prototype;
|
|
8126
|
+
const { copy: copy$6, add, includes: includes$1 } = BoundsHelper;
|
|
8127
|
+
const rect$1 = exports.Rect.prototype, group$1 = exports.Group.prototype;
|
|
8098
8128
|
const childrenRenderBounds = {};
|
|
8099
|
-
const { copy: copy$6, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8100
8129
|
exports.Box = class Box extends exports.Group {
|
|
8101
8130
|
get __tag() { return 'Box'; }
|
|
8102
8131
|
get isBranchLeaf() { return true; }
|
|
@@ -8106,37 +8135,31 @@ var LeaferUI = (function (exports) {
|
|
|
8106
8135
|
}
|
|
8107
8136
|
__updateStrokeSpread() { return 0; }
|
|
8108
8137
|
__updateRectRenderSpread() { return 0; }
|
|
8109
|
-
__updateRenderSpread() {
|
|
8110
|
-
return this.__updateRectRenderSpread() || -1;
|
|
8111
|
-
}
|
|
8138
|
+
__updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
|
|
8112
8139
|
__updateRectBoxBounds() { }
|
|
8113
|
-
__updateBoxBounds(
|
|
8140
|
+
__updateBoxBounds(_secondLayout) {
|
|
8114
8141
|
const data = this.__;
|
|
8115
8142
|
if (this.children.length) {
|
|
8116
8143
|
if (data.__autoSide) {
|
|
8117
|
-
if (this.leafer && this.leafer.ready)
|
|
8118
|
-
this.leafer.layouter.addExtra(this);
|
|
8119
8144
|
super.__updateBoxBounds();
|
|
8120
8145
|
const { boxBounds } = this.__layout;
|
|
8121
8146
|
if (!data.__autoSize) {
|
|
8122
|
-
if (data.__autoWidth)
|
|
8123
|
-
boxBounds.width += boxBounds.x, boxBounds.
|
|
8124
|
-
|
|
8125
|
-
|
|
8147
|
+
if (data.__autoWidth) {
|
|
8148
|
+
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
8149
|
+
boxBounds.height = data.height, boxBounds.y = 0;
|
|
8150
|
+
}
|
|
8151
|
+
else {
|
|
8152
|
+
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
8153
|
+
boxBounds.width = data.width, boxBounds.x = 0;
|
|
8154
|
+
}
|
|
8126
8155
|
}
|
|
8127
|
-
if (secondLayout && data.flow && data.padding)
|
|
8128
|
-
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8129
8156
|
this.__updateNaturalSize();
|
|
8130
8157
|
}
|
|
8131
|
-
else
|
|
8158
|
+
else
|
|
8132
8159
|
this.__updateRectBoxBounds();
|
|
8133
|
-
}
|
|
8134
|
-
if (data.flow)
|
|
8135
|
-
this.__updateContentBounds();
|
|
8136
8160
|
}
|
|
8137
|
-
else
|
|
8161
|
+
else
|
|
8138
8162
|
this.__updateRectBoxBounds();
|
|
8139
|
-
}
|
|
8140
8163
|
}
|
|
8141
8164
|
__updateStrokeBounds() { }
|
|
8142
8165
|
__updateRenderBounds() {
|
|
@@ -8146,14 +8169,13 @@ var LeaferUI = (function (exports) {
|
|
|
8146
8169
|
super.__updateRenderBounds();
|
|
8147
8170
|
copy$6(childrenRenderBounds, renderBounds);
|
|
8148
8171
|
this.__updateRectRenderBounds();
|
|
8149
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds)
|
|
8172
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8173
|
+
if (isOverflow && this.__.overflow !== 'hide')
|
|
8174
|
+
add(renderBounds, childrenRenderBounds);
|
|
8150
8175
|
}
|
|
8151
|
-
else
|
|
8176
|
+
else
|
|
8152
8177
|
this.__updateRectRenderBounds();
|
|
8153
|
-
|
|
8154
|
-
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8155
|
-
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
8156
|
-
add(renderBounds, childrenRenderBounds);
|
|
8178
|
+
!this.isOverflow !== !isOverflow && (this.isOverflow = isOverflow);
|
|
8157
8179
|
}
|
|
8158
8180
|
__updateRectRenderBounds() { }
|
|
8159
8181
|
__updateRectChange() { }
|
|
@@ -8173,20 +8195,9 @@ var LeaferUI = (function (exports) {
|
|
|
8173
8195
|
this.__renderGroup(canvas, options);
|
|
8174
8196
|
}
|
|
8175
8197
|
}
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
if (this.
|
|
8179
|
-
canvas.save();
|
|
8180
|
-
canvas.clip();
|
|
8181
|
-
if (length)
|
|
8182
|
-
this.__renderGroup(canvas, options);
|
|
8183
|
-
canvas.restore();
|
|
8184
|
-
}
|
|
8185
|
-
else {
|
|
8186
|
-
if (length)
|
|
8187
|
-
this.__renderGroup(canvas, options);
|
|
8188
|
-
}
|
|
8189
|
-
if (this.__.stroke && length) {
|
|
8198
|
+
__drawContent(canvas, options) {
|
|
8199
|
+
this.__renderGroup(canvas, options);
|
|
8200
|
+
if (this.__.__hasStroke) {
|
|
8190
8201
|
canvas.setWorld(this.__nowWorld);
|
|
8191
8202
|
this.__drawRenderPath(canvas);
|
|
8192
8203
|
}
|
|
@@ -8198,6 +8209,9 @@ var LeaferUI = (function (exports) {
|
|
|
8198
8209
|
__decorate([
|
|
8199
8210
|
dataType(false)
|
|
8200
8211
|
], exports.Box.prototype, "resizeChildren", void 0);
|
|
8212
|
+
__decorate([
|
|
8213
|
+
dataType(false)
|
|
8214
|
+
], exports.Box.prototype, "textBox", void 0);
|
|
8201
8215
|
__decorate([
|
|
8202
8216
|
affectRenderBoundsType('show')
|
|
8203
8217
|
], exports.Box.prototype, "overflow", void 0);
|
|
@@ -8347,17 +8361,15 @@ var LeaferUI = (function (exports) {
|
|
|
8347
8361
|
if (data.__useArrow)
|
|
8348
8362
|
PathArrow.addArrows(this, false);
|
|
8349
8363
|
}
|
|
8350
|
-
else
|
|
8364
|
+
else
|
|
8351
8365
|
super.__updateRenderPath();
|
|
8352
|
-
}
|
|
8353
8366
|
}
|
|
8354
8367
|
__updateBoxBounds() {
|
|
8355
8368
|
if (this.points) {
|
|
8356
8369
|
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
8357
8370
|
}
|
|
8358
|
-
else
|
|
8371
|
+
else
|
|
8359
8372
|
super.__updateBoxBounds();
|
|
8360
|
-
}
|
|
8361
8373
|
}
|
|
8362
8374
|
};
|
|
8363
8375
|
__decorate([
|
|
@@ -8495,7 +8507,6 @@ var LeaferUI = (function (exports) {
|
|
|
8495
8507
|
super(data);
|
|
8496
8508
|
this.canvas = Creator.canvas(this.__);
|
|
8497
8509
|
this.context = this.canvas.context;
|
|
8498
|
-
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8499
8510
|
if (data && data.url)
|
|
8500
8511
|
this.drawImage(data.url);
|
|
8501
8512
|
}
|
|
@@ -8508,8 +8519,7 @@ var LeaferUI = (function (exports) {
|
|
|
8508
8519
|
});
|
|
8509
8520
|
}
|
|
8510
8521
|
draw(ui, offset, scale, rotation) {
|
|
8511
|
-
ui.
|
|
8512
|
-
const matrix = new Matrix(ui.__world).invert();
|
|
8522
|
+
const matrix = new Matrix(ui.worldTransform).invert();
|
|
8513
8523
|
const m = new Matrix();
|
|
8514
8524
|
if (offset)
|
|
8515
8525
|
m.translate(offset.x, offset.y);
|
|
@@ -8524,17 +8534,9 @@ var LeaferUI = (function (exports) {
|
|
|
8524
8534
|
paint() {
|
|
8525
8535
|
this.forceRender();
|
|
8526
8536
|
}
|
|
8527
|
-
|
|
8528
|
-
const { width, height
|
|
8529
|
-
|
|
8530
|
-
canvas.save();
|
|
8531
|
-
canvas.clip();
|
|
8532
|
-
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8533
|
-
canvas.restore();
|
|
8534
|
-
}
|
|
8535
|
-
else {
|
|
8536
|
-
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8537
|
-
}
|
|
8537
|
+
__drawContent(canvas, _options) {
|
|
8538
|
+
const { width, height } = this.__, { view } = this.canvas;
|
|
8539
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8538
8540
|
}
|
|
8539
8541
|
__updateSize() {
|
|
8540
8542
|
const { canvas } = this;
|
|
@@ -8578,7 +8580,6 @@ var LeaferUI = (function (exports) {
|
|
|
8578
8580
|
const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
|
|
8579
8581
|
exports.Text = class Text extends exports.UI {
|
|
8580
8582
|
get __tag() { return 'Text'; }
|
|
8581
|
-
get editInner() { return 'TextEditor'; }
|
|
8582
8583
|
get textDrawData() {
|
|
8583
8584
|
this.__layout.update();
|
|
8584
8585
|
return this.__.__textDrawData;
|
|
@@ -8727,6 +8728,9 @@ var LeaferUI = (function (exports) {
|
|
|
8727
8728
|
__decorate([
|
|
8728
8729
|
boundsType('top')
|
|
8729
8730
|
], exports.Text.prototype, "verticalAlign", void 0);
|
|
8731
|
+
__decorate([
|
|
8732
|
+
boundsType(true)
|
|
8733
|
+
], exports.Text.prototype, "autoSizeAlign", void 0);
|
|
8730
8734
|
__decorate([
|
|
8731
8735
|
boundsType('normal')
|
|
8732
8736
|
], exports.Text.prototype, "textWrap", void 0);
|
|
@@ -8741,7 +8745,6 @@ var LeaferUI = (function (exports) {
|
|
|
8741
8745
|
get __tag() { return 'Path'; }
|
|
8742
8746
|
constructor(data) {
|
|
8743
8747
|
super(data);
|
|
8744
|
-
this.__.__pathInputed = 2;
|
|
8745
8748
|
}
|
|
8746
8749
|
};
|
|
8747
8750
|
__decorate([
|
|
@@ -8824,21 +8827,17 @@ var LeaferUI = (function (exports) {
|
|
|
8824
8827
|
this.tree = this.addLeafer(tree);
|
|
8825
8828
|
if (sky || editor)
|
|
8826
8829
|
this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
|
|
8827
|
-
if (editor)
|
|
8828
|
-
this.editor = Creator.editor(editor);
|
|
8829
|
-
this.sky.add(this.editor);
|
|
8830
|
-
}
|
|
8830
|
+
if (editor)
|
|
8831
|
+
this.sky.add(this.editor = Creator.editor(editor));
|
|
8831
8832
|
}
|
|
8832
8833
|
}
|
|
8833
8834
|
__setApp() {
|
|
8834
8835
|
const { canvas } = this;
|
|
8835
8836
|
const { realCanvas, view } = this.config;
|
|
8836
|
-
if (realCanvas || view === this.canvas.view || !canvas.parentView)
|
|
8837
|
+
if (realCanvas || view === this.canvas.view || !canvas.parentView)
|
|
8837
8838
|
this.realCanvas = true;
|
|
8838
|
-
|
|
8839
|
-
else {
|
|
8839
|
+
else
|
|
8840
8840
|
canvas.unrealCanvas();
|
|
8841
|
-
}
|
|
8842
8841
|
this.leafer = this;
|
|
8843
8842
|
this.watcher.disable();
|
|
8844
8843
|
this.layouter.disable();
|
|
@@ -9244,10 +9243,7 @@ var LeaferUI = (function (exports) {
|
|
|
9244
9243
|
leafer.getValidMove = function (moveX, moveY) {
|
|
9245
9244
|
const { scroll, disabled } = this.app.config.move;
|
|
9246
9245
|
if (scroll) {
|
|
9247
|
-
|
|
9248
|
-
moveY = 0;
|
|
9249
|
-
else
|
|
9250
|
-
moveX = 0;
|
|
9246
|
+
Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
|
|
9251
9247
|
if (scroll === 'limit') {
|
|
9252
9248
|
const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
|
|
9253
9249
|
const right = x + width - this.width, bottom = y + height - this.height;
|
|
@@ -9447,9 +9443,10 @@ var LeaferUI = (function (exports) {
|
|
|
9447
9443
|
this.dragData = getDragEventData(data, data, data);
|
|
9448
9444
|
this.canAnimate = this.canDragOut = true;
|
|
9449
9445
|
}
|
|
9450
|
-
getList() {
|
|
9446
|
+
getList(realDraggable, hover) {
|
|
9451
9447
|
const { proxy } = this.interaction.selector;
|
|
9452
|
-
|
|
9448
|
+
const hasProxyList = proxy && proxy.list.length, dragList = exports.DragEvent.list || this.draggableList || emptyList;
|
|
9449
|
+
return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
|
|
9453
9450
|
}
|
|
9454
9451
|
checkDrag(data, canDrag) {
|
|
9455
9452
|
const { interaction } = this;
|
|
@@ -9474,8 +9471,8 @@ var LeaferUI = (function (exports) {
|
|
|
9474
9471
|
this.dragging = canDrag && PointerButton.left(data);
|
|
9475
9472
|
if (this.dragging) {
|
|
9476
9473
|
this.interaction.emit(exports.DragEvent.START, this.dragData);
|
|
9477
|
-
this.
|
|
9478
|
-
this.setDragStartPoints(this.
|
|
9474
|
+
this.getDraggableList(this.dragData.path);
|
|
9475
|
+
this.setDragStartPoints(this.realDraggableList = this.getList(true));
|
|
9479
9476
|
}
|
|
9480
9477
|
}
|
|
9481
9478
|
}
|
|
@@ -9483,12 +9480,12 @@ var LeaferUI = (function (exports) {
|
|
|
9483
9480
|
this.dragStartPoints = {};
|
|
9484
9481
|
list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
|
|
9485
9482
|
}
|
|
9486
|
-
|
|
9483
|
+
getDraggableList(path) {
|
|
9487
9484
|
let leaf;
|
|
9488
9485
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
9489
9486
|
leaf = path.list[i];
|
|
9490
|
-
if ((leaf.
|
|
9491
|
-
this.
|
|
9487
|
+
if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
|
|
9488
|
+
this.draggableList = new LeafList(leaf);
|
|
9492
9489
|
break;
|
|
9493
9490
|
}
|
|
9494
9491
|
}
|
|
@@ -9513,7 +9510,7 @@ var LeaferUI = (function (exports) {
|
|
|
9513
9510
|
}
|
|
9514
9511
|
dragReal() {
|
|
9515
9512
|
const { running } = this.interaction;
|
|
9516
|
-
const list = this.
|
|
9513
|
+
const list = this.realDraggableList;
|
|
9517
9514
|
if (list.length && running) {
|
|
9518
9515
|
const { totalX, totalY } = this.dragData;
|
|
9519
9516
|
list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
|
|
@@ -9602,7 +9599,7 @@ var LeaferUI = (function (exports) {
|
|
|
9602
9599
|
this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
|
|
9603
9600
|
}
|
|
9604
9601
|
dragReset() {
|
|
9605
|
-
exports.DragEvent.list = exports.DragEvent.data = this.
|
|
9602
|
+
exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9606
9603
|
}
|
|
9607
9604
|
checkDragOut(data) {
|
|
9608
9605
|
const { interaction } = this;
|
|
@@ -9743,6 +9740,7 @@ var LeaferUI = (function (exports) {
|
|
|
9743
9740
|
touch: {
|
|
9744
9741
|
preventDefault: true
|
|
9745
9742
|
},
|
|
9743
|
+
multiTouch: {},
|
|
9746
9744
|
cursor: true,
|
|
9747
9745
|
keyEvent: true
|
|
9748
9746
|
};
|
|
@@ -9869,6 +9867,8 @@ var LeaferUI = (function (exports) {
|
|
|
9869
9867
|
this.pointerUp(data);
|
|
9870
9868
|
}
|
|
9871
9869
|
multiTouch(data, list) {
|
|
9870
|
+
if (this.config.multiTouch.disabled)
|
|
9871
|
+
return;
|
|
9872
9872
|
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
9873
9873
|
this.rotate(getRotateEventData(center, angle, data));
|
|
9874
9874
|
this.zoom(getZoomEventData(center, scale, data));
|
|
@@ -10058,7 +10058,7 @@ var LeaferUI = (function (exports) {
|
|
|
10058
10058
|
data = this.hoverData;
|
|
10059
10059
|
if (!data)
|
|
10060
10060
|
return;
|
|
10061
|
-
this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
|
|
10061
|
+
this.findPath(data, { exclude: this.dragger.getList(false, true), name: exports.PointerEvent.MOVE });
|
|
10062
10062
|
this.hoverData = data;
|
|
10063
10063
|
}
|
|
10064
10064
|
updateCursor(data) {
|
|
@@ -10080,7 +10080,7 @@ var LeaferUI = (function (exports) {
|
|
|
10080
10080
|
const { path } = data;
|
|
10081
10081
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
10082
10082
|
leaf = path.list[i];
|
|
10083
|
-
cursor = leaf.syncEventer
|
|
10083
|
+
cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
|
|
10084
10084
|
if (cursor)
|
|
10085
10085
|
break;
|
|
10086
10086
|
}
|
|
@@ -10262,7 +10262,7 @@ var LeaferUI = (function (exports) {
|
|
|
10262
10262
|
if (isHitPixel) {
|
|
10263
10263
|
const { renderBounds } = this.__layout;
|
|
10264
10264
|
const size = Platform.image.hitCanvasSize;
|
|
10265
|
-
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds
|
|
10265
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
10266
10266
|
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
10267
10267
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10268
10268
|
h.clear();
|
|
@@ -10318,15 +10318,14 @@ var LeaferUI = (function (exports) {
|
|
|
10318
10318
|
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
10319
10319
|
};
|
|
10320
10320
|
|
|
10321
|
-
const ui$2 =
|
|
10322
|
-
|
|
10323
|
-
rect.__updateHitCanvas = function () {
|
|
10321
|
+
const ui$2 = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
|
|
10322
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
10324
10323
|
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10325
10324
|
ui$2.__updateHitCanvas.call(this);
|
|
10326
10325
|
else if (this.__hitCanvas)
|
|
10327
10326
|
this.__hitCanvas = null;
|
|
10328
10327
|
};
|
|
10329
|
-
rect.__hitFill = function (inner) {
|
|
10328
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
10330
10329
|
return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10331
10330
|
};
|
|
10332
10331
|
|
|
@@ -10665,7 +10664,7 @@ var LeaferUI = (function (exports) {
|
|
|
10665
10664
|
shape
|
|
10666
10665
|
};
|
|
10667
10666
|
|
|
10668
|
-
let origin = {};
|
|
10667
|
+
let origin$1 = {};
|
|
10669
10668
|
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
|
|
10670
10669
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10671
10670
|
const transform = get$3();
|
|
@@ -10705,11 +10704,11 @@ var LeaferUI = (function (exports) {
|
|
|
10705
10704
|
}
|
|
10706
10705
|
}
|
|
10707
10706
|
}
|
|
10708
|
-
origin.x = box.x + x;
|
|
10709
|
-
origin.y = box.y + y;
|
|
10710
|
-
translate$1(transform, origin.x, origin.y);
|
|
10707
|
+
origin$1.x = box.x + x;
|
|
10708
|
+
origin$1.y = box.y + y;
|
|
10709
|
+
translate$1(transform, origin$1.x, origin$1.y);
|
|
10711
10710
|
if (scaleX)
|
|
10712
|
-
scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10711
|
+
scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
|
|
10713
10712
|
data.transform = transform;
|
|
10714
10713
|
}
|
|
10715
10714
|
|
|
@@ -10825,9 +10824,10 @@ var LeaferUI = (function (exports) {
|
|
|
10825
10824
|
onLoadError(ui, event, image.error);
|
|
10826
10825
|
}
|
|
10827
10826
|
else {
|
|
10828
|
-
|
|
10829
|
-
|
|
10827
|
+
if (firstUse) {
|
|
10828
|
+
ignoreRender(ui, true);
|
|
10830
10829
|
onLoad(ui, event);
|
|
10830
|
+
}
|
|
10831
10831
|
leafPaint.loadId = image.load(() => {
|
|
10832
10832
|
ignoreRender(ui, false);
|
|
10833
10833
|
if (!ui.destroyed) {
|
|
@@ -10975,7 +10975,7 @@ var LeaferUI = (function (exports) {
|
|
|
10975
10975
|
}
|
|
10976
10976
|
if (allowPaint) {
|
|
10977
10977
|
canvas.save();
|
|
10978
|
-
canvas.clip();
|
|
10978
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
10979
10979
|
if (paint.blendMode)
|
|
10980
10980
|
canvas.blendMode = paint.blendMode;
|
|
10981
10981
|
if (data.opacity)
|
|
@@ -11439,14 +11439,15 @@ var LeaferUI = (function (exports) {
|
|
|
11439
11439
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
11440
11440
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
11441
11441
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
11442
|
-
let textDrawData, rows = [], bounds;
|
|
11442
|
+
let textDrawData, rows = [], bounds$1, findMaxWidth;
|
|
11443
11443
|
function createRows(drawData, content, style) {
|
|
11444
11444
|
textDrawData = drawData;
|
|
11445
11445
|
rows = drawData.rows;
|
|
11446
|
-
bounds = drawData.bounds;
|
|
11446
|
+
bounds$1 = drawData.bounds;
|
|
11447
|
+
findMaxWidth = !bounds$1.width && !style.autoSizeAlign;
|
|
11447
11448
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
11448
11449
|
const { canvas } = Platform;
|
|
11449
|
-
const { width, height } = bounds;
|
|
11450
|
+
const { width, height } = bounds$1;
|
|
11450
11451
|
const charMode = width || height || __letterSpacing || (textCase !== 'none');
|
|
11451
11452
|
if (charMode) {
|
|
11452
11453
|
const wrap = style.textWrap !== 'none';
|
|
@@ -11528,7 +11529,10 @@ var LeaferUI = (function (exports) {
|
|
|
11528
11529
|
else {
|
|
11529
11530
|
content.split('\n').forEach(content => {
|
|
11530
11531
|
textDrawData.paraNumber++;
|
|
11531
|
-
|
|
11532
|
+
rowWidth = canvas.measureText(content).width;
|
|
11533
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
11534
|
+
if (findMaxWidth)
|
|
11535
|
+
setMaxWidth();
|
|
11532
11536
|
});
|
|
11533
11537
|
}
|
|
11534
11538
|
}
|
|
@@ -11557,12 +11561,18 @@ var LeaferUI = (function (exports) {
|
|
|
11557
11561
|
startCharSize = 0;
|
|
11558
11562
|
}
|
|
11559
11563
|
row.width = rowWidth;
|
|
11560
|
-
if (bounds.width)
|
|
11564
|
+
if (bounds$1.width)
|
|
11561
11565
|
trimRight(row);
|
|
11566
|
+
else if (findMaxWidth)
|
|
11567
|
+
setMaxWidth();
|
|
11562
11568
|
rows.push(row);
|
|
11563
11569
|
row = { words: [] };
|
|
11564
11570
|
rowWidth = 0;
|
|
11565
11571
|
}
|
|
11572
|
+
function setMaxWidth() {
|
|
11573
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
11574
|
+
textDrawData.maxWidth = rowWidth;
|
|
11575
|
+
}
|
|
11566
11576
|
|
|
11567
11577
|
const CharMode = 0;
|
|
11568
11578
|
const WordMode = 1;
|
|
@@ -11634,34 +11644,32 @@ var LeaferUI = (function (exports) {
|
|
|
11634
11644
|
|
|
11635
11645
|
function layoutText(drawData, style) {
|
|
11636
11646
|
const { rows, bounds } = drawData;
|
|
11637
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
11647
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
11638
11648
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11639
11649
|
let starY = __baseLine;
|
|
11640
11650
|
if (__clipText && realHeight > height) {
|
|
11641
11651
|
realHeight = Math.max(height, __lineHeight);
|
|
11642
11652
|
drawData.overflow = rows.length;
|
|
11643
11653
|
}
|
|
11644
|
-
else {
|
|
11654
|
+
else if (height || autoSizeAlign) {
|
|
11645
11655
|
switch (verticalAlign) {
|
|
11646
11656
|
case 'middle':
|
|
11647
11657
|
y += (height - realHeight) / 2;
|
|
11648
11658
|
break;
|
|
11649
|
-
case 'bottom':
|
|
11650
|
-
y += (height - realHeight);
|
|
11659
|
+
case 'bottom': y += (height - realHeight);
|
|
11651
11660
|
}
|
|
11652
11661
|
}
|
|
11653
11662
|
starY += y;
|
|
11654
|
-
let row, rowX, rowWidth;
|
|
11663
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
11655
11664
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11656
11665
|
row = rows[i];
|
|
11657
11666
|
row.x = x;
|
|
11658
11667
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
11659
11668
|
switch (textAlign) {
|
|
11660
11669
|
case 'center':
|
|
11661
|
-
row.x += (
|
|
11670
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
11662
11671
|
break;
|
|
11663
|
-
case 'right':
|
|
11664
|
-
row.x += width - row.width;
|
|
11672
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
11665
11673
|
}
|
|
11666
11674
|
}
|
|
11667
11675
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -11766,14 +11774,14 @@ var LeaferUI = (function (exports) {
|
|
|
11766
11774
|
let height = style.__getInput('height') || 0;
|
|
11767
11775
|
const { textDecoration, __font, __padding: padding } = style;
|
|
11768
11776
|
if (padding) {
|
|
11769
|
-
if (width)
|
|
11777
|
+
if (width)
|
|
11778
|
+
x = padding[left$3], width -= (padding[right$3] + padding[left$3]);
|
|
11779
|
+
else if (!style.autoSizeAlign)
|
|
11770
11780
|
x = padding[left$3];
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
if (
|
|
11781
|
+
if (height)
|
|
11782
|
+
y = padding[top$2], height -= (padding[top$2] + padding[bottom$2]);
|
|
11783
|
+
else if (!style.autoSizeAlign)
|
|
11774
11784
|
y = padding[top$2];
|
|
11775
|
-
height -= (padding[top$2] + padding[bottom$2]);
|
|
11776
|
-
}
|
|
11777
11785
|
}
|
|
11778
11786
|
const drawData = {
|
|
11779
11787
|
bounds: { x, y, width, height },
|
|
@@ -11793,22 +11801,20 @@ var LeaferUI = (function (exports) {
|
|
|
11793
11801
|
return drawData;
|
|
11794
11802
|
}
|
|
11795
11803
|
function padAutoText(padding, drawData, style, width, height) {
|
|
11796
|
-
if (!width) {
|
|
11804
|
+
if (!width && style.autoSizeAlign) {
|
|
11797
11805
|
switch (style.textAlign) {
|
|
11798
11806
|
case 'left':
|
|
11799
11807
|
offsetText(drawData, 'x', padding[left$3]);
|
|
11800
11808
|
break;
|
|
11801
|
-
case 'right':
|
|
11802
|
-
offsetText(drawData, 'x', -padding[right$3]);
|
|
11809
|
+
case 'right': offsetText(drawData, 'x', -padding[right$3]);
|
|
11803
11810
|
}
|
|
11804
11811
|
}
|
|
11805
|
-
if (!height) {
|
|
11812
|
+
if (!height && style.autoSizeAlign) {
|
|
11806
11813
|
switch (style.verticalAlign) {
|
|
11807
11814
|
case 'top':
|
|
11808
11815
|
offsetText(drawData, 'y', padding[top$2]);
|
|
11809
11816
|
break;
|
|
11810
|
-
case 'bottom':
|
|
11811
|
-
offsetText(drawData, 'y', -padding[bottom$2]);
|
|
11817
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom$2]);
|
|
11812
11818
|
}
|
|
11813
11819
|
}
|
|
11814
11820
|
}
|
|
@@ -12170,8 +12176,9 @@ var LeaferUI = (function (exports) {
|
|
|
12170
12176
|
leaf.path = leaf.__.path;
|
|
12171
12177
|
}
|
|
12172
12178
|
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
12173
|
-
|
|
12174
|
-
|
|
12179
|
+
const { points } = leaf;
|
|
12180
|
+
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
12181
|
+
leaf.points = points;
|
|
12175
12182
|
}
|
|
12176
12183
|
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
12177
12184
|
const { children } = group;
|
|
@@ -12330,31 +12337,29 @@ var LeaferUI = (function (exports) {
|
|
|
12330
12337
|
const { list } = this;
|
|
12331
12338
|
if (list.length) {
|
|
12332
12339
|
let leaf;
|
|
12333
|
-
const { stroke, strokeWidth, fill } =
|
|
12334
|
-
const { bounds } = options;
|
|
12340
|
+
const data = this.__, { stroke, strokeWidth, fill } = data, { bounds } = options;
|
|
12335
12341
|
for (let i = 0; i < list.length; i++) {
|
|
12336
12342
|
leaf = list[i];
|
|
12337
|
-
|
|
12338
|
-
|
|
12343
|
+
const { worldTransform, worldRenderBounds } = leaf;
|
|
12344
|
+
if (bounds && bounds.hit(worldRenderBounds, options.matrix)) {
|
|
12345
|
+
const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
|
|
12339
12346
|
if (aScaleX !== aScaleY) {
|
|
12340
|
-
copy$2(matrix,
|
|
12347
|
+
copy$2(matrix, worldTransform);
|
|
12341
12348
|
scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
|
|
12342
12349
|
canvas.setWorld(matrix, options.matrix);
|
|
12343
12350
|
canvas.beginPath();
|
|
12344
|
-
|
|
12351
|
+
data.strokeWidth = strokeWidth;
|
|
12345
12352
|
const { x, y, width, height } = leaf.__layout.boxBounds;
|
|
12346
12353
|
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
12347
12354
|
}
|
|
12348
12355
|
else {
|
|
12349
|
-
canvas.setWorld(
|
|
12356
|
+
canvas.setWorld(worldTransform, options.matrix);
|
|
12350
12357
|
canvas.beginPath();
|
|
12351
|
-
if (leaf.__.__useArrow)
|
|
12358
|
+
if (leaf.__.__useArrow)
|
|
12352
12359
|
leaf.__drawPath(canvas);
|
|
12353
|
-
|
|
12354
|
-
else {
|
|
12360
|
+
else
|
|
12355
12361
|
leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
|
|
12356
|
-
|
|
12357
|
-
this.__.strokeWidth = strokeWidth / abs(leaf.__world.scaleX);
|
|
12362
|
+
data.strokeWidth = strokeWidth / abs(worldTransform.scaleX);
|
|
12358
12363
|
}
|
|
12359
12364
|
if (stroke)
|
|
12360
12365
|
typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
|
|
@@ -12362,7 +12367,7 @@ var LeaferUI = (function (exports) {
|
|
|
12362
12367
|
typeof fill === 'string' ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
|
|
12363
12368
|
}
|
|
12364
12369
|
}
|
|
12365
|
-
|
|
12370
|
+
data.strokeWidth = strokeWidth;
|
|
12366
12371
|
}
|
|
12367
12372
|
}
|
|
12368
12373
|
destroy() {
|
|
@@ -12913,7 +12918,6 @@ var LeaferUI = (function (exports) {
|
|
|
12913
12918
|
this.editor = editor;
|
|
12914
12919
|
this.visible = false;
|
|
12915
12920
|
this.create();
|
|
12916
|
-
this.rect.syncEventer = editor;
|
|
12917
12921
|
this.__listenEvents();
|
|
12918
12922
|
}
|
|
12919
12923
|
create() {
|
|
@@ -12953,8 +12957,11 @@ var LeaferUI = (function (exports) {
|
|
|
12953
12957
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
12954
12958
|
rect.set(Object.assign({ stroke, strokeWidth }, (mergeConfig.rect || {})));
|
|
12955
12959
|
rect.hittable = !single && !!moveable;
|
|
12956
|
-
|
|
12957
|
-
|
|
12960
|
+
rect.syncEventer = single && this.editor;
|
|
12961
|
+
if (single && moveable) {
|
|
12962
|
+
element.syncEventer = rect;
|
|
12963
|
+
this.app.interaction.bottomList = [{ target: rect, proxy: element }];
|
|
12964
|
+
}
|
|
12958
12965
|
}
|
|
12959
12966
|
update(bounds) {
|
|
12960
12967
|
this.visible = !this.editor.element.locked;
|
|
@@ -13126,6 +13133,11 @@ var LeaferUI = (function (exports) {
|
|
|
13126
13133
|
if (editor.single) {
|
|
13127
13134
|
const { element } = editor;
|
|
13128
13135
|
if (element.isBranch) {
|
|
13136
|
+
if (element.textBox) {
|
|
13137
|
+
const find = element.children.find(item => item.editable && item instanceof exports.Text);
|
|
13138
|
+
if (find)
|
|
13139
|
+
return editor.openInnerEditor(find);
|
|
13140
|
+
}
|
|
13129
13141
|
editor.openGroup(element);
|
|
13130
13142
|
editor.target = editor.selector.findDeepOne(e);
|
|
13131
13143
|
}
|
|
@@ -13271,12 +13283,12 @@ ${filterStyle}
|
|
|
13271
13283
|
skewable: true
|
|
13272
13284
|
};
|
|
13273
13285
|
|
|
13286
|
+
const bounds = new Bounds();
|
|
13274
13287
|
function simulate(editor) {
|
|
13275
|
-
const { simulateTarget,
|
|
13276
|
-
const {
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
simulateTarget.reset({ x: (x - worldX) / scaleX, y: (y - worldY) / scaleY, width: width / scaleX, height: height / scaleY });
|
|
13288
|
+
const { simulateTarget, list } = editor;
|
|
13289
|
+
const { zoomLayer } = list[0].leafer.zoomLayer;
|
|
13290
|
+
simulateTarget.safeChange(() => simulateTarget.reset(bounds.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
|
|
13291
|
+
zoomLayer.add(simulateTarget);
|
|
13280
13292
|
}
|
|
13281
13293
|
|
|
13282
13294
|
function onTarget(editor, oldValue) {
|
|
@@ -13285,6 +13297,7 @@ ${filterStyle}
|
|
|
13285
13297
|
editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
|
|
13286
13298
|
}
|
|
13287
13299
|
else {
|
|
13300
|
+
editor.simulateTarget.remove();
|
|
13288
13301
|
editor.leafList.reset();
|
|
13289
13302
|
editor.closeInnerEditor();
|
|
13290
13303
|
}
|
|
@@ -13339,7 +13352,7 @@ ${filterStyle}
|
|
|
13339
13352
|
const ungroupList = [];
|
|
13340
13353
|
app.lockLayout();
|
|
13341
13354
|
list.forEach(leaf => {
|
|
13342
|
-
if (leaf.isBranch) {
|
|
13355
|
+
if (leaf.isBranch && !leaf.isBranchLeaf) {
|
|
13343
13356
|
const { parent, children } = leaf;
|
|
13344
13357
|
while (children.length) {
|
|
13345
13358
|
ungroupList.push(children[0]);
|
|
@@ -13410,17 +13423,77 @@ ${filterStyle}
|
|
|
13410
13423
|
EditorGroupEvent.OPEN = 'editor.open_group';
|
|
13411
13424
|
EditorGroupEvent.CLOSE = 'editor.close_group';
|
|
13412
13425
|
|
|
13426
|
+
const { updateMatrix } = LeafHelper;
|
|
13427
|
+
const checkMap = { x: 1, y: 1, scaleX: 1, scaleY: 1, rotation: 1, skewX: 1, skewY: 1 }, origin = 'top-left';
|
|
13428
|
+
class SimulateElement extends exports.Rect {
|
|
13429
|
+
get __tag() { return 'SimulateElement'; }
|
|
13430
|
+
constructor(editor) {
|
|
13431
|
+
super();
|
|
13432
|
+
this.checkChange = true;
|
|
13433
|
+
this.canChange = true;
|
|
13434
|
+
this.visible = this.hittable = false;
|
|
13435
|
+
this.on(PropertyEvent.CHANGE, (event) => {
|
|
13436
|
+
if (this.checkChange && checkMap[event.attrName]) {
|
|
13437
|
+
const { attrName, newValue, oldValue } = event;
|
|
13438
|
+
const addValue = attrName[0] === 's' ? (newValue || 1) / (oldValue || 1) : (newValue || 0) - (oldValue || 0);
|
|
13439
|
+
this.canChange = false;
|
|
13440
|
+
const data = this.__;
|
|
13441
|
+
data[attrName] = oldValue;
|
|
13442
|
+
updateMatrix(this.parent);
|
|
13443
|
+
updateMatrix(this);
|
|
13444
|
+
const oldMatrix = new Matrix(this.__world);
|
|
13445
|
+
data[attrName] = newValue;
|
|
13446
|
+
this.__layout.rotationChange();
|
|
13447
|
+
updateMatrix(this);
|
|
13448
|
+
this.changedTransform = new Matrix(this.__world).divide(oldMatrix);
|
|
13449
|
+
switch (attrName) {
|
|
13450
|
+
case 'x':
|
|
13451
|
+
editor.move(addValue, 0);
|
|
13452
|
+
break;
|
|
13453
|
+
case 'y':
|
|
13454
|
+
editor.move(0, addValue);
|
|
13455
|
+
break;
|
|
13456
|
+
case 'rotation':
|
|
13457
|
+
editor.rotateOf(origin, addValue);
|
|
13458
|
+
break;
|
|
13459
|
+
case 'scaleX':
|
|
13460
|
+
editor.scaleOf(origin, addValue, 1);
|
|
13461
|
+
break;
|
|
13462
|
+
case 'scaleY':
|
|
13463
|
+
editor.scaleOf(origin, 1, addValue);
|
|
13464
|
+
break;
|
|
13465
|
+
case 'skewX':
|
|
13466
|
+
editor.skewOf(origin, addValue, 0);
|
|
13467
|
+
break;
|
|
13468
|
+
case 'skewY':
|
|
13469
|
+
editor.skewOf(origin, 0, addValue);
|
|
13470
|
+
}
|
|
13471
|
+
this.canChange = true;
|
|
13472
|
+
}
|
|
13473
|
+
});
|
|
13474
|
+
}
|
|
13475
|
+
safeChange(changeFn) {
|
|
13476
|
+
if (this.canChange) {
|
|
13477
|
+
this.checkChange = false;
|
|
13478
|
+
changeFn();
|
|
13479
|
+
this.checkChange = true;
|
|
13480
|
+
}
|
|
13481
|
+
}
|
|
13482
|
+
}
|
|
13483
|
+
|
|
13413
13484
|
class Editor extends exports.Group {
|
|
13414
13485
|
get mergeConfig() {
|
|
13415
13486
|
const { element, config } = this;
|
|
13416
13487
|
return this.single && element.editConfig ? Object.assign(Object.assign({}, config), element.editConfig) : config;
|
|
13417
13488
|
}
|
|
13418
13489
|
get list() { return this.leafList.list; }
|
|
13490
|
+
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
13419
13491
|
get editing() { return !!this.list.length; }
|
|
13420
13492
|
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13421
13493
|
get multiple() { return this.list.length > 1; }
|
|
13422
13494
|
get single() { return this.list.length === 1; }
|
|
13423
13495
|
get dragging() { return this.editBox.dragging; }
|
|
13496
|
+
get moving() { return this.editBox.moving; }
|
|
13424
13497
|
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13425
13498
|
get buttons() { return this.editBox.buttons; }
|
|
13426
13499
|
constructor(userConfig, data) {
|
|
@@ -13428,7 +13501,7 @@ ${filterStyle}
|
|
|
13428
13501
|
this.config = DataHelper.clone(config);
|
|
13429
13502
|
this.leafList = new LeafList();
|
|
13430
13503
|
this.openedGroupList = new LeafList();
|
|
13431
|
-
this.simulateTarget = new
|
|
13504
|
+
this.simulateTarget = new SimulateElement(this);
|
|
13432
13505
|
this.editBox = new EditBox(this);
|
|
13433
13506
|
this.editToolList = {};
|
|
13434
13507
|
this.selector = new EditSelect(this);
|
|
@@ -13566,18 +13639,18 @@ ${filterStyle}
|
|
|
13566
13639
|
this.skewOf(origin, skewX, skewY);
|
|
13567
13640
|
}
|
|
13568
13641
|
move(x, y = 0) {
|
|
13569
|
-
if (!this.
|
|
13642
|
+
if (!this.checkTransform('moveable'))
|
|
13570
13643
|
return;
|
|
13571
13644
|
const { element } = this;
|
|
13572
13645
|
const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
|
|
13646
|
+
if (this.multiple)
|
|
13647
|
+
element.safeChange(() => element.move(x, y));
|
|
13573
13648
|
const event = new EditorMoveEvent(EditorMoveEvent.MOVE, { target: element, editor: this, moveX: world.x, moveY: world.y });
|
|
13574
13649
|
this.editTool.onMove(event);
|
|
13575
13650
|
this.emitEvent(event);
|
|
13576
|
-
if (this.multiple)
|
|
13577
|
-
element.move(x, y);
|
|
13578
13651
|
}
|
|
13579
13652
|
scaleWithDrag(data) {
|
|
13580
|
-
if (!this.
|
|
13653
|
+
if (!this.checkTransform('resizeable'))
|
|
13581
13654
|
return;
|
|
13582
13655
|
const { element } = this;
|
|
13583
13656
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) }));
|
|
@@ -13585,50 +13658,53 @@ ${filterStyle}
|
|
|
13585
13658
|
this.emitEvent(event);
|
|
13586
13659
|
}
|
|
13587
13660
|
scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
|
|
13588
|
-
if (!this.
|
|
13661
|
+
if (!this.checkTransform('resizeable'))
|
|
13589
13662
|
return;
|
|
13590
13663
|
const { element } = this;
|
|
13591
13664
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13592
|
-
const transform = this.multiple && this.getChangedTransform(() => element.scaleOf(origin, scaleX, scaleY));
|
|
13665
|
+
const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.scaleOf(origin, scaleX, scaleY)));
|
|
13593
13666
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX, scaleY, transform });
|
|
13594
13667
|
this.editTool.onScale(event);
|
|
13595
13668
|
this.emitEvent(event);
|
|
13596
13669
|
}
|
|
13597
13670
|
flip(axis) {
|
|
13598
|
-
if (this.
|
|
13671
|
+
if (!this.checkTransform('resizeable'))
|
|
13599
13672
|
return;
|
|
13600
13673
|
const { element } = this;
|
|
13601
13674
|
const worldOrigin = this.getWorldOrigin('center');
|
|
13602
|
-
const transform = this.multiple ? this.getChangedTransform(() => element.flip(axis)) : new Matrix(LeafHelper.getFlipTransform(element, axis));
|
|
13675
|
+
const transform = this.multiple ? this.getChangedTransform(() => element.safeChange(() => element.flip(axis))) : new Matrix(LeafHelper.getFlipTransform(element, axis));
|
|
13603
13676
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform });
|
|
13604
13677
|
this.editTool.onScale(event);
|
|
13605
13678
|
this.emitEvent(event);
|
|
13606
13679
|
}
|
|
13607
13680
|
rotateOf(origin, rotation) {
|
|
13608
|
-
if (!this.
|
|
13681
|
+
if (!this.checkTransform('rotateable'))
|
|
13609
13682
|
return;
|
|
13610
13683
|
const { element } = this;
|
|
13611
13684
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13612
|
-
const transform = this.multiple && this.getChangedTransform(() => element.rotateOf(origin, rotation));
|
|
13685
|
+
const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.rotateOf(origin, rotation)));
|
|
13613
13686
|
const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, { target: element, editor: this, worldOrigin, rotation, transform });
|
|
13614
13687
|
this.editTool.onRotate(event);
|
|
13615
13688
|
this.emitEvent(event);
|
|
13616
13689
|
}
|
|
13617
13690
|
skewOf(origin, skewX, skewY = 0, _resize) {
|
|
13618
|
-
if (!this.
|
|
13691
|
+
if (!this.checkTransform('skewable'))
|
|
13619
13692
|
return;
|
|
13620
13693
|
const { element } = this;
|
|
13621
13694
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13622
|
-
const transform = this.multiple && this.getChangedTransform(() => element.skewOf(origin, skewX, skewY));
|
|
13695
|
+
const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.skewOf(origin, skewX, skewY)));
|
|
13623
13696
|
const event = new EditorSkewEvent(EditorSkewEvent.SKEW, { target: element, editor: this, worldOrigin, skewX, skewY, transform });
|
|
13624
13697
|
this.editTool.onSkew(event);
|
|
13625
13698
|
this.emitEvent(event);
|
|
13626
13699
|
}
|
|
13700
|
+
checkTransform(type) { return this.element && !this.element.locked && this.mergeConfig[type]; }
|
|
13627
13701
|
getWorldOrigin(origin) {
|
|
13628
13702
|
return this.element.getWorldPoint(LeafHelper.getInnerOrigin(this.element, origin));
|
|
13629
13703
|
}
|
|
13630
13704
|
getChangedTransform(func) {
|
|
13631
13705
|
const { element } = this;
|
|
13706
|
+
if (this.multiple && !element.canChange)
|
|
13707
|
+
return element.changedTransform;
|
|
13632
13708
|
const oldMatrix = new Matrix(element.worldTransform);
|
|
13633
13709
|
func();
|
|
13634
13710
|
return new Matrix(element.worldTransform).divide(oldMatrix);
|
|
@@ -13685,11 +13761,11 @@ ${filterStyle}
|
|
|
13685
13761
|
this.emitEvent(event);
|
|
13686
13762
|
group.emitEvent(event);
|
|
13687
13763
|
}
|
|
13688
|
-
openInnerEditor(target) {
|
|
13689
|
-
if (target)
|
|
13764
|
+
openInnerEditor(target, select) {
|
|
13765
|
+
if (target && select)
|
|
13690
13766
|
this.target = target;
|
|
13691
13767
|
if (this.single) {
|
|
13692
|
-
const editTarget = this.element;
|
|
13768
|
+
const editTarget = target || this.element;
|
|
13693
13769
|
const tag = editTarget.editInner;
|
|
13694
13770
|
if (tag && EditToolCreator.list[tag]) {
|
|
13695
13771
|
this.editTool.unload();
|
|
@@ -13741,14 +13817,15 @@ ${filterStyle}
|
|
|
13741
13817
|
}
|
|
13742
13818
|
listenTargetEvents() {
|
|
13743
13819
|
if (!this.targetEventIds.length) {
|
|
13744
|
-
const { leafer } = this
|
|
13820
|
+
const { app, leafer } = this;
|
|
13745
13821
|
this.targetEventIds = [
|
|
13746
|
-
this.app.on_(exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true),
|
|
13747
|
-
this.app.on_(exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
|
|
13748
|
-
this.app.on_(exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
|
|
13749
13822
|
leafer.on_(RenderEvent.START, this.update, this),
|
|
13750
|
-
|
|
13751
|
-
|
|
13823
|
+
app.on_(RenderEvent.CHILD_START, this.forceRender, this),
|
|
13824
|
+
app.on_(exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true),
|
|
13825
|
+
app.on_(exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
|
|
13826
|
+
app.on_(exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
|
|
13827
|
+
app.on_([exports.KeyEvent.HOLD, exports.KeyEvent.UP], (e) => { updateCursor(this, e); }),
|
|
13828
|
+
app.on_(exports.KeyEvent.DOWN, this.editBox.onArrow, this.editBox)
|
|
13752
13829
|
];
|
|
13753
13830
|
}
|
|
13754
13831
|
}
|
|
@@ -13764,7 +13841,8 @@ ${filterStyle}
|
|
|
13764
13841
|
this.simulateTarget.destroy();
|
|
13765
13842
|
Object.values(this.editToolList).forEach(item => item.destroy());
|
|
13766
13843
|
this.editToolList = {};
|
|
13767
|
-
this.target = this.hoverTarget =
|
|
13844
|
+
this.target = this.hoverTarget = null;
|
|
13845
|
+
this.simulateTarget = this.editTool = this.innerEditor = null;
|
|
13768
13846
|
super.destroy();
|
|
13769
13847
|
}
|
|
13770
13848
|
}
|
|
@@ -13881,10 +13959,7 @@ ${filterStyle}
|
|
|
13881
13959
|
}
|
|
13882
13960
|
update() {
|
|
13883
13961
|
const { editor, editBox } = this;
|
|
13884
|
-
const {
|
|
13885
|
-
if (editor.multiple)
|
|
13886
|
-
simulateTarget.parent.updateLayout();
|
|
13887
|
-
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = element.getLayoutBounds('box', editor, true);
|
|
13962
|
+
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = editor.element.getLayoutBounds('box', editor, true);
|
|
13888
13963
|
editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
13889
13964
|
editBox.update({ x: 0, y: 0, width, height });
|
|
13890
13965
|
this.onUpdate();
|
|
@@ -13899,7 +13974,7 @@ ${filterStyle}
|
|
|
13899
13974
|
], exports.EditTool);
|
|
13900
13975
|
|
|
13901
13976
|
const { left, right } = exports.Direction9;
|
|
13902
|
-
const { move, copy: copy$1 } = PointHelper;
|
|
13977
|
+
const { move, copy: copy$1, toNumberPoints } = PointHelper;
|
|
13903
13978
|
exports.LineEditTool = class LineEditTool extends exports.EditTool {
|
|
13904
13979
|
constructor() {
|
|
13905
13980
|
super(...arguments);
|
|
@@ -13941,14 +14016,8 @@ ${filterStyle}
|
|
|
13941
14016
|
}
|
|
13942
14017
|
getInnerMove(ui, event, lockRatio) {
|
|
13943
14018
|
const movePoint = event.getInnerMove(ui);
|
|
13944
|
-
if (lockRatio)
|
|
13945
|
-
|
|
13946
|
-
movePoint.y = 0;
|
|
13947
|
-
}
|
|
13948
|
-
else {
|
|
13949
|
-
movePoint.x = 0;
|
|
13950
|
-
}
|
|
13951
|
-
}
|
|
14019
|
+
if (lockRatio)
|
|
14020
|
+
Math.abs(movePoint.x) > Math.abs(movePoint.y) ? movePoint.y = 0 : movePoint.x = 0;
|
|
13952
14021
|
return movePoint;
|
|
13953
14022
|
}
|
|
13954
14023
|
getFromToByPath(path) {
|
|
@@ -13957,7 +14026,8 @@ ${filterStyle}
|
|
|
13957
14026
|
to: { x: path[4], y: path[5] }
|
|
13958
14027
|
};
|
|
13959
14028
|
}
|
|
13960
|
-
getFromToByPoints(
|
|
14029
|
+
getFromToByPoints(originPoints) {
|
|
14030
|
+
const points = toNumberPoints(originPoints);
|
|
13961
14031
|
return {
|
|
13962
14032
|
from: { x: points[0], y: points[1] },
|
|
13963
14033
|
to: { x: points[2], y: points[3] }
|
|
@@ -14010,6 +14080,15 @@ ${filterStyle}
|
|
|
14010
14080
|
], exports.LineEditTool);
|
|
14011
14081
|
|
|
14012
14082
|
Creator.editor = function (options) { return new Editor(options); };
|
|
14083
|
+
defineKey(exports.UI.prototype, 'editOuter', {
|
|
14084
|
+
get() { return this.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }
|
|
14085
|
+
});
|
|
14086
|
+
defineKey(exports.UI.prototype, 'editInner', {
|
|
14087
|
+
get() { return 'PathEditor'; }
|
|
14088
|
+
});
|
|
14089
|
+
defineKey(exports.Text.prototype, 'editInner', {
|
|
14090
|
+
get() { return 'TextEditor'; }
|
|
14091
|
+
});
|
|
14013
14092
|
exports.UI.setEditConfig = function (config) {
|
|
14014
14093
|
defineKey(this.prototype, 'editConfig', {
|
|
14015
14094
|
get() { return typeof config === 'function' ? config(this) : config; }
|
|
@@ -14573,18 +14652,7 @@ ${filterStyle}
|
|
|
14573
14652
|
style.position = 'fixed';
|
|
14574
14653
|
style.transformOrigin = 'left top';
|
|
14575
14654
|
style.boxSizing = 'border-box';
|
|
14576
|
-
|
|
14577
|
-
div.innerHTML = text.text;
|
|
14578
|
-
this.textScale = 1;
|
|
14579
|
-
}
|
|
14580
|
-
else {
|
|
14581
|
-
div.innerText = text.text;
|
|
14582
|
-
const { scaleX, scaleY } = text.worldTransform;
|
|
14583
|
-
this.textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
14584
|
-
const fontSize = text.fontSize * this.textScale;
|
|
14585
|
-
if (fontSize < 12)
|
|
14586
|
-
this.textScale *= 12 / fontSize;
|
|
14587
|
-
}
|
|
14655
|
+
this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
|
|
14588
14656
|
const { view } = editor.app;
|
|
14589
14657
|
(this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
|
|
14590
14658
|
this.eventIds = [
|
|
@@ -14633,16 +14701,46 @@ ${filterStyle}
|
|
|
14633
14701
|
this.editor.closeInnerEditor();
|
|
14634
14702
|
}
|
|
14635
14703
|
onUpdate() {
|
|
14636
|
-
const { editTarget: text
|
|
14637
|
-
|
|
14638
|
-
|
|
14704
|
+
const { editTarget: text } = this;
|
|
14705
|
+
let textScale = 1;
|
|
14706
|
+
if (!this.isHTMLText) {
|
|
14707
|
+
const { scaleX, scaleY } = text.worldTransform;
|
|
14708
|
+
textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
14709
|
+
const fontSize = text.fontSize * textScale;
|
|
14710
|
+
if (fontSize < 12)
|
|
14711
|
+
textScale *= 12 / text.fontSize;
|
|
14712
|
+
}
|
|
14713
|
+
this.textScale = textScale;
|
|
14639
14714
|
const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
|
|
14715
|
+
let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14716
|
+
let { width, height } = text;
|
|
14717
|
+
x -= window.scrollX, y -= window.scrollY, width *= textScale, height *= textScale;
|
|
14718
|
+
const data = text.__;
|
|
14719
|
+
if (data.__autoWidth && data.autoSizeAlign) {
|
|
14720
|
+
width += 20;
|
|
14721
|
+
switch (data.textAlign) {
|
|
14722
|
+
case 'center':
|
|
14723
|
+
x -= width / 2;
|
|
14724
|
+
break;
|
|
14725
|
+
case 'right': x -= width;
|
|
14726
|
+
}
|
|
14727
|
+
}
|
|
14728
|
+
if (data.__autoHeight && data.autoSizeAlign) {
|
|
14729
|
+
height += 20;
|
|
14730
|
+
switch (data.verticalAlign) {
|
|
14731
|
+
case 'middle':
|
|
14732
|
+
y -= height / 2;
|
|
14733
|
+
break;
|
|
14734
|
+
case 'bottom': y -= height;
|
|
14735
|
+
}
|
|
14736
|
+
}
|
|
14737
|
+
const { style } = this.editDom;
|
|
14640
14738
|
style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
14641
|
-
style.left = x
|
|
14642
|
-
style.top = y
|
|
14643
|
-
style.width =
|
|
14644
|
-
style.height =
|
|
14645
|
-
this.isHTMLText || updateStyle(this.editDom, text,
|
|
14739
|
+
style.left = x + 'px';
|
|
14740
|
+
style.top = y + 'px';
|
|
14741
|
+
style.width = width + 'px';
|
|
14742
|
+
style.height = height + 'px';
|
|
14743
|
+
this.isHTMLText || updateStyle(this.editDom, text, textScale);
|
|
14646
14744
|
}
|
|
14647
14745
|
onUnload() {
|
|
14648
14746
|
const { editTarget: text, editor, editDom: dom } = this;
|