@leafer-editor/worker 1.0.3 → 1.0.5
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 +265 -162
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +265 -162
- package/dist/worker.module.min.js +1 -1
- package/package.json +9 -8
package/dist/worker.module.js
CHANGED
|
@@ -4056,7 +4056,7 @@ const LeafHelper = {
|
|
|
4056
4056
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4057
4057
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
4058
4058
|
waitAutoLayout = true;
|
|
4059
|
-
updateMatrix$
|
|
4059
|
+
updateMatrix$3(leaf, checkAutoLayout, waitAutoLayout);
|
|
4060
4060
|
if (leaf.isBranch) {
|
|
4061
4061
|
const { children } = leaf;
|
|
4062
4062
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
@@ -4226,7 +4226,7 @@ const LeafHelper = {
|
|
|
4226
4226
|
}
|
|
4227
4227
|
};
|
|
4228
4228
|
const L$3 = LeafHelper;
|
|
4229
|
-
const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$
|
|
4229
|
+
const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$3, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$3;
|
|
4230
4230
|
function moveByMatrix(t, matrix) {
|
|
4231
4231
|
const { e, f } = t.__localMatrix;
|
|
4232
4232
|
t.x += matrix.e - e;
|
|
@@ -4483,15 +4483,16 @@ class LeafLayout {
|
|
|
4483
4483
|
}
|
|
4484
4484
|
getLayoutBounds(type, relative = 'world', unscale) {
|
|
4485
4485
|
const { leaf } = this;
|
|
4486
|
-
let point, matrix, bounds = this.getInnerBounds(type);
|
|
4486
|
+
let point, matrix, layoutBounds, bounds = this.getInnerBounds(type);
|
|
4487
4487
|
switch (relative) {
|
|
4488
4488
|
case 'world':
|
|
4489
4489
|
point = leaf.getWorldPoint(bounds);
|
|
4490
4490
|
matrix = leaf.__world;
|
|
4491
4491
|
break;
|
|
4492
4492
|
case 'local':
|
|
4493
|
+
const { scaleX, scaleY, rotation, skewX, skewY } = leaf.__;
|
|
4494
|
+
layoutBounds = { scaleX, scaleY, rotation, skewX, skewY };
|
|
4493
4495
|
point = leaf.getLocalPointByInner(bounds);
|
|
4494
|
-
matrix = leaf.__localMatrix;
|
|
4495
4496
|
break;
|
|
4496
4497
|
case 'inner':
|
|
4497
4498
|
point = bounds;
|
|
@@ -4503,7 +4504,8 @@ class LeafLayout {
|
|
|
4503
4504
|
point = leaf.getWorldPoint(bounds, relative);
|
|
4504
4505
|
matrix = getRelativeWorld$1(leaf, relative, true);
|
|
4505
4506
|
}
|
|
4506
|
-
|
|
4507
|
+
if (!layoutBounds)
|
|
4508
|
+
layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4507
4509
|
copy$9(layoutBounds, bounds);
|
|
4508
4510
|
PointHelper.copy(layoutBounds, point);
|
|
4509
4511
|
if (unscale) {
|
|
@@ -4753,6 +4755,7 @@ class RenderEvent extends Event {
|
|
|
4753
4755
|
}
|
|
4754
4756
|
}
|
|
4755
4757
|
RenderEvent.REQUEST = 'render.request';
|
|
4758
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4756
4759
|
RenderEvent.START = 'render.start';
|
|
4757
4760
|
RenderEvent.BEFORE = 'render.before';
|
|
4758
4761
|
RenderEvent.RENDER = 'render';
|
|
@@ -4928,7 +4931,7 @@ const { isFinite } = Number;
|
|
|
4928
4931
|
const debug$8 = Debug.get('setAttr');
|
|
4929
4932
|
const LeafDataProxy = {
|
|
4930
4933
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4931
|
-
if (this.
|
|
4934
|
+
if (this.leaferIsCreated) {
|
|
4932
4935
|
const oldValue = this.__.__getInput(name);
|
|
4933
4936
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4934
4937
|
debug$8.warn(this.innerName, name, newValue);
|
|
@@ -4998,9 +5001,9 @@ const LeafMatrix = {
|
|
|
4998
5001
|
}
|
|
4999
5002
|
};
|
|
5000
5003
|
|
|
5001
|
-
const { updateMatrix: updateMatrix$
|
|
5004
|
+
const { updateMatrix: updateMatrix$2, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5002
5005
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5003
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5006
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$8 } = BoundsHelper;
|
|
5004
5007
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
5005
5008
|
const LeafBounds = {
|
|
5006
5009
|
__updateWorldBounds() {
|
|
@@ -5083,7 +5086,7 @@ const LeafBounds = {
|
|
|
5083
5086
|
const b = this.__layout.boxBounds;
|
|
5084
5087
|
const data = this.__;
|
|
5085
5088
|
if (data.__pathInputed) {
|
|
5086
|
-
toBounds$2(data.
|
|
5089
|
+
toBounds$2(data.path, b);
|
|
5087
5090
|
}
|
|
5088
5091
|
else {
|
|
5089
5092
|
b.x = 0;
|
|
@@ -5095,7 +5098,7 @@ const LeafBounds = {
|
|
|
5095
5098
|
__updateAutoLayout() {
|
|
5096
5099
|
this.__layout.matrixChanged = true;
|
|
5097
5100
|
if (this.isBranch) {
|
|
5098
|
-
if (this.
|
|
5101
|
+
if (this.leaferIsReady)
|
|
5099
5102
|
this.leafer.layouter.addExtra(this);
|
|
5100
5103
|
if (this.__.flow) {
|
|
5101
5104
|
if (this.__layout.boxChanged)
|
|
@@ -5111,7 +5114,7 @@ const LeafBounds = {
|
|
|
5111
5114
|
}
|
|
5112
5115
|
}
|
|
5113
5116
|
else {
|
|
5114
|
-
updateMatrix$
|
|
5117
|
+
updateMatrix$2(this);
|
|
5115
5118
|
}
|
|
5116
5119
|
},
|
|
5117
5120
|
__updateNaturalSize() {
|
|
@@ -5121,11 +5124,11 @@ const LeafBounds = {
|
|
|
5121
5124
|
},
|
|
5122
5125
|
__updateStrokeBounds() {
|
|
5123
5126
|
const layout = this.__layout;
|
|
5124
|
-
copyAndSpread$
|
|
5127
|
+
copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5125
5128
|
},
|
|
5126
5129
|
__updateRenderBounds() {
|
|
5127
5130
|
const layout = this.__layout;
|
|
5128
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5131
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$8(layout.renderBounds, layout.strokeBounds);
|
|
5129
5132
|
}
|
|
5130
5133
|
};
|
|
5131
5134
|
|
|
@@ -5230,6 +5233,8 @@ let Leaf = class Leaf {
|
|
|
5230
5233
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5231
5234
|
get __DataProcessor() { return LeafData; }
|
|
5232
5235
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5236
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5237
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5233
5238
|
get isLeafer() { return false; }
|
|
5234
5239
|
get isBranch() { return false; }
|
|
5235
5240
|
get isBranchLeaf() { return false; }
|
|
@@ -5671,6 +5676,7 @@ let Branch = class Branch extends Leaf {
|
|
|
5671
5676
|
add(child, index) {
|
|
5672
5677
|
if (child === this)
|
|
5673
5678
|
return;
|
|
5679
|
+
child.__ || (child = UICreator.get(child.tag, child));
|
|
5674
5680
|
if (child.parent)
|
|
5675
5681
|
child.parent.remove(child);
|
|
5676
5682
|
child.parent = this;
|
|
@@ -5693,10 +5699,14 @@ let Branch = class Branch extends Leaf {
|
|
|
5693
5699
|
}
|
|
5694
5700
|
remove(child, destroy) {
|
|
5695
5701
|
if (child) {
|
|
5696
|
-
if (child.
|
|
5697
|
-
|
|
5702
|
+
if (child.__) {
|
|
5703
|
+
if (child.animationOut)
|
|
5704
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5705
|
+
else
|
|
5706
|
+
this.__remove(child, destroy);
|
|
5707
|
+
}
|
|
5698
5708
|
else
|
|
5699
|
-
this.
|
|
5709
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5700
5710
|
}
|
|
5701
5711
|
else if (child === undefined) {
|
|
5702
5712
|
super.remove(null, destroy);
|
|
@@ -5914,7 +5924,7 @@ class LeafLevelList {
|
|
|
5914
5924
|
}
|
|
5915
5925
|
}
|
|
5916
5926
|
|
|
5917
|
-
const version = "1.0.
|
|
5927
|
+
const version = "1.0.5";
|
|
5918
5928
|
|
|
5919
5929
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5920
5930
|
get allowBackgroundColor() { return true; }
|
|
@@ -6100,7 +6110,7 @@ class Watcher {
|
|
|
6100
6110
|
|
|
6101
6111
|
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
|
|
6102
6112
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
6103
|
-
function updateMatrix(updateList, levelList) {
|
|
6113
|
+
function updateMatrix$1(updateList, levelList) {
|
|
6104
6114
|
let layout;
|
|
6105
6115
|
updateList.list.forEach(leaf => {
|
|
6106
6116
|
layout = leaf.__layout;
|
|
@@ -6268,7 +6278,7 @@ class Layouter {
|
|
|
6268
6278
|
target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
|
|
6269
6279
|
this.extraBlock = null;
|
|
6270
6280
|
updateList.sort();
|
|
6271
|
-
updateMatrix(updateList, this.__levelList);
|
|
6281
|
+
updateMatrix$1(updateList, this.__levelList);
|
|
6272
6282
|
updateBounds(this.__levelList);
|
|
6273
6283
|
updateChange(updateList);
|
|
6274
6284
|
if (this.extraBlock)
|
|
@@ -6383,6 +6393,7 @@ class Renderer {
|
|
|
6383
6393
|
this.totalBounds = new Bounds();
|
|
6384
6394
|
debug$6.log(target.innerName, '--->');
|
|
6385
6395
|
try {
|
|
6396
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6386
6397
|
this.emitRender(RenderEvent.START);
|
|
6387
6398
|
this.renderOnce(callback);
|
|
6388
6399
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6680,7 +6691,7 @@ class Picker {
|
|
|
6680
6691
|
if (child.isBranch) {
|
|
6681
6692
|
if (hit || child.__ignoreHitWorld) {
|
|
6682
6693
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
6683
|
-
if (child.isBranchLeaf
|
|
6694
|
+
if (child.isBranchLeaf)
|
|
6684
6695
|
this.hitChild(child, point);
|
|
6685
6696
|
}
|
|
6686
6697
|
}
|
|
@@ -7390,12 +7401,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7390
7401
|
this.__drawPathByData(canvas, this.__.path);
|
|
7391
7402
|
}
|
|
7392
7403
|
__drawPathByData(drawer, data) {
|
|
7393
|
-
|
|
7394
|
-
PathDrawer.drawPathByData(drawer, data);
|
|
7395
|
-
}
|
|
7396
|
-
else {
|
|
7397
|
-
this.__drawPathByBox(drawer);
|
|
7398
|
-
}
|
|
7404
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
7399
7405
|
}
|
|
7400
7406
|
__drawPathByBox(drawer) {
|
|
7401
7407
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
@@ -7403,9 +7409,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7403
7409
|
const { cornerRadius } = this.__;
|
|
7404
7410
|
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
7405
7411
|
}
|
|
7406
|
-
else
|
|
7412
|
+
else
|
|
7407
7413
|
drawer.rect(x, y, width, height);
|
|
7408
|
-
}
|
|
7409
7414
|
}
|
|
7410
7415
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7411
7416
|
return needPlugin('animate');
|
|
@@ -7414,10 +7419,10 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7414
7419
|
export(filename, options) {
|
|
7415
7420
|
return Export.export(this, filename, options);
|
|
7416
7421
|
}
|
|
7417
|
-
clone(
|
|
7422
|
+
clone(data) {
|
|
7418
7423
|
const json = this.toJSON();
|
|
7419
|
-
if (
|
|
7420
|
-
Object.assign(json,
|
|
7424
|
+
if (data)
|
|
7425
|
+
Object.assign(json, data);
|
|
7421
7426
|
return UI_1.one(json);
|
|
7422
7427
|
}
|
|
7423
7428
|
static one(data, x, y, width, height) {
|
|
@@ -8088,10 +8093,9 @@ Rect = __decorate([
|
|
|
8088
8093
|
registerUI()
|
|
8089
8094
|
], Rect);
|
|
8090
8095
|
|
|
8091
|
-
const
|
|
8092
|
-
const group$1 = Group.prototype;
|
|
8096
|
+
const { copy: copy$6, add, includes: includes$1 } = BoundsHelper;
|
|
8097
|
+
const rect$1 = Rect.prototype, group$1 = Group.prototype;
|
|
8093
8098
|
const childrenRenderBounds = {};
|
|
8094
|
-
const { copy: copy$6, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8095
8099
|
let Box = class Box extends Group {
|
|
8096
8100
|
get __tag() { return 'Box'; }
|
|
8097
8101
|
get isBranchLeaf() { return true; }
|
|
@@ -8105,29 +8109,27 @@ let Box = class Box extends Group {
|
|
|
8105
8109
|
return this.__updateRectRenderSpread() || -1;
|
|
8106
8110
|
}
|
|
8107
8111
|
__updateRectBoxBounds() { }
|
|
8108
|
-
__updateBoxBounds(
|
|
8112
|
+
__updateBoxBounds(_secondLayout) {
|
|
8109
8113
|
const data = this.__;
|
|
8110
8114
|
if (this.children.length) {
|
|
8111
8115
|
if (data.__autoSide) {
|
|
8112
|
-
if (this.leafer && this.leafer.ready)
|
|
8113
|
-
this.leafer.layouter.addExtra(this);
|
|
8114
8116
|
super.__updateBoxBounds();
|
|
8115
8117
|
const { boxBounds } = this.__layout;
|
|
8116
8118
|
if (!data.__autoSize) {
|
|
8117
|
-
if (data.__autoWidth)
|
|
8118
|
-
boxBounds.width += boxBounds.x, boxBounds.
|
|
8119
|
-
|
|
8120
|
-
|
|
8119
|
+
if (data.__autoWidth) {
|
|
8120
|
+
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
8121
|
+
boxBounds.height = data.height, boxBounds.y = 0;
|
|
8122
|
+
}
|
|
8123
|
+
else {
|
|
8124
|
+
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
8125
|
+
boxBounds.width = data.width, boxBounds.x = 0;
|
|
8126
|
+
}
|
|
8121
8127
|
}
|
|
8122
|
-
if (secondLayout && data.flow && data.padding)
|
|
8123
|
-
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8124
8128
|
this.__updateNaturalSize();
|
|
8125
8129
|
}
|
|
8126
8130
|
else {
|
|
8127
8131
|
this.__updateRectBoxBounds();
|
|
8128
8132
|
}
|
|
8129
|
-
if (data.flow)
|
|
8130
|
-
this.__updateContentBounds();
|
|
8131
8133
|
}
|
|
8132
8134
|
else {
|
|
8133
8135
|
this.__updateRectBoxBounds();
|
|
@@ -8193,6 +8195,9 @@ __decorate([
|
|
|
8193
8195
|
__decorate([
|
|
8194
8196
|
dataType(false)
|
|
8195
8197
|
], Box.prototype, "resizeChildren", void 0);
|
|
8198
|
+
__decorate([
|
|
8199
|
+
dataType(false)
|
|
8200
|
+
], Box.prototype, "textBox", void 0);
|
|
8196
8201
|
__decorate([
|
|
8197
8202
|
affectRenderBoundsType('show')
|
|
8198
8203
|
], Box.prototype, "overflow", void 0);
|
|
@@ -8722,6 +8727,9 @@ __decorate([
|
|
|
8722
8727
|
__decorate([
|
|
8723
8728
|
boundsType('top')
|
|
8724
8729
|
], Text.prototype, "verticalAlign", void 0);
|
|
8730
|
+
__decorate([
|
|
8731
|
+
boundsType(true)
|
|
8732
|
+
], Text.prototype, "autoSizeAlign", void 0);
|
|
8725
8733
|
__decorate([
|
|
8726
8734
|
boundsType('normal')
|
|
8727
8735
|
], Text.prototype, "textWrap", void 0);
|
|
@@ -9442,9 +9450,10 @@ class Dragger {
|
|
|
9442
9450
|
this.dragData = getDragEventData(data, data, data);
|
|
9443
9451
|
this.canAnimate = this.canDragOut = true;
|
|
9444
9452
|
}
|
|
9445
|
-
getList() {
|
|
9453
|
+
getList(realDraggable, hover) {
|
|
9446
9454
|
const { proxy } = this.interaction.selector;
|
|
9447
|
-
|
|
9455
|
+
const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList;
|
|
9456
|
+
return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
|
|
9448
9457
|
}
|
|
9449
9458
|
checkDrag(data, canDrag) {
|
|
9450
9459
|
const { interaction } = this;
|
|
@@ -9469,8 +9478,8 @@ class Dragger {
|
|
|
9469
9478
|
this.dragging = canDrag && PointerButton.left(data);
|
|
9470
9479
|
if (this.dragging) {
|
|
9471
9480
|
this.interaction.emit(DragEvent.START, this.dragData);
|
|
9472
|
-
this.
|
|
9473
|
-
this.setDragStartPoints(this.
|
|
9481
|
+
this.getDraggableList(this.dragData.path);
|
|
9482
|
+
this.setDragStartPoints(this.realDraggableList = this.getList(true));
|
|
9474
9483
|
}
|
|
9475
9484
|
}
|
|
9476
9485
|
}
|
|
@@ -9478,12 +9487,12 @@ class Dragger {
|
|
|
9478
9487
|
this.dragStartPoints = {};
|
|
9479
9488
|
list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
|
|
9480
9489
|
}
|
|
9481
|
-
|
|
9490
|
+
getDraggableList(path) {
|
|
9482
9491
|
let leaf;
|
|
9483
9492
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
9484
9493
|
leaf = path.list[i];
|
|
9485
|
-
if ((leaf.
|
|
9486
|
-
this.
|
|
9494
|
+
if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
|
|
9495
|
+
this.draggableList = new LeafList(leaf);
|
|
9487
9496
|
break;
|
|
9488
9497
|
}
|
|
9489
9498
|
}
|
|
@@ -9508,7 +9517,7 @@ class Dragger {
|
|
|
9508
9517
|
}
|
|
9509
9518
|
dragReal() {
|
|
9510
9519
|
const { running } = this.interaction;
|
|
9511
|
-
const list = this.
|
|
9520
|
+
const list = this.realDraggableList;
|
|
9512
9521
|
if (list.length && running) {
|
|
9513
9522
|
const { totalX, totalY } = this.dragData;
|
|
9514
9523
|
list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
|
|
@@ -9597,7 +9606,7 @@ class Dragger {
|
|
|
9597
9606
|
this.interaction.emit(DragEvent.LEAVE, data, dragEnterPath);
|
|
9598
9607
|
}
|
|
9599
9608
|
dragReset() {
|
|
9600
|
-
DragEvent.list = DragEvent.data = this.
|
|
9609
|
+
DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9601
9610
|
}
|
|
9602
9611
|
checkDragOut(data) {
|
|
9603
9612
|
const { interaction } = this;
|
|
@@ -9738,6 +9747,7 @@ const config$1 = {
|
|
|
9738
9747
|
touch: {
|
|
9739
9748
|
preventDefault: true
|
|
9740
9749
|
},
|
|
9750
|
+
multiTouch: {},
|
|
9741
9751
|
cursor: true,
|
|
9742
9752
|
keyEvent: true
|
|
9743
9753
|
};
|
|
@@ -9864,6 +9874,8 @@ class InteractionBase {
|
|
|
9864
9874
|
this.pointerUp(data);
|
|
9865
9875
|
}
|
|
9866
9876
|
multiTouch(data, list) {
|
|
9877
|
+
if (this.config.multiTouch.disabled)
|
|
9878
|
+
return;
|
|
9867
9879
|
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
9868
9880
|
this.rotate(getRotateEventData(center, angle, data));
|
|
9869
9881
|
this.zoom(getZoomEventData(center, scale, data));
|
|
@@ -10053,7 +10065,7 @@ class InteractionBase {
|
|
|
10053
10065
|
data = this.hoverData;
|
|
10054
10066
|
if (!data)
|
|
10055
10067
|
return;
|
|
10056
|
-
this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
|
|
10068
|
+
this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE });
|
|
10057
10069
|
this.hoverData = data;
|
|
10058
10070
|
}
|
|
10059
10071
|
updateCursor(data) {
|
|
@@ -10075,7 +10087,7 @@ class InteractionBase {
|
|
|
10075
10087
|
const { path } = data;
|
|
10076
10088
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
10077
10089
|
leaf = path.list[i];
|
|
10078
|
-
cursor = leaf.syncEventer
|
|
10090
|
+
cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
|
|
10079
10091
|
if (cursor)
|
|
10080
10092
|
break;
|
|
10081
10093
|
}
|
|
@@ -10257,7 +10269,7 @@ ui$3.__updateHitCanvas = function () {
|
|
|
10257
10269
|
if (isHitPixel) {
|
|
10258
10270
|
const { renderBounds } = this.__layout;
|
|
10259
10271
|
const size = Platform.image.hitCanvasSize;
|
|
10260
|
-
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds
|
|
10272
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
10261
10273
|
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
10262
10274
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10263
10275
|
h.clear();
|
|
@@ -10313,15 +10325,14 @@ ui$3.__hit = function (inner) {
|
|
|
10313
10325
|
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
10314
10326
|
};
|
|
10315
10327
|
|
|
10316
|
-
const ui$2 =
|
|
10317
|
-
|
|
10318
|
-
rect.__updateHitCanvas = function () {
|
|
10328
|
+
const ui$2 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
|
|
10329
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
10319
10330
|
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10320
10331
|
ui$2.__updateHitCanvas.call(this);
|
|
10321
10332
|
else if (this.__hitCanvas)
|
|
10322
10333
|
this.__hitCanvas = null;
|
|
10323
10334
|
};
|
|
10324
|
-
rect.__hitFill = function (inner) {
|
|
10335
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
10325
10336
|
return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10326
10337
|
};
|
|
10327
10338
|
|
|
@@ -10660,7 +10671,7 @@ const PaintModule = {
|
|
|
10660
10671
|
shape
|
|
10661
10672
|
};
|
|
10662
10673
|
|
|
10663
|
-
let origin = {};
|
|
10674
|
+
let origin$1 = {};
|
|
10664
10675
|
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
|
|
10665
10676
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10666
10677
|
const transform = get$3();
|
|
@@ -10700,11 +10711,11 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
10700
10711
|
}
|
|
10701
10712
|
}
|
|
10702
10713
|
}
|
|
10703
|
-
origin.x = box.x + x;
|
|
10704
|
-
origin.y = box.y + y;
|
|
10705
|
-
translate$1(transform, origin.x, origin.y);
|
|
10714
|
+
origin$1.x = box.x + x;
|
|
10715
|
+
origin$1.y = box.y + y;
|
|
10716
|
+
translate$1(transform, origin$1.x, origin$1.y);
|
|
10706
10717
|
if (scaleX)
|
|
10707
|
-
scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
10718
|
+
scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
|
|
10708
10719
|
data.transform = transform;
|
|
10709
10720
|
}
|
|
10710
10721
|
|
|
@@ -10820,9 +10831,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
10820
10831
|
onLoadError(ui, event, image.error);
|
|
10821
10832
|
}
|
|
10822
10833
|
else {
|
|
10823
|
-
|
|
10824
|
-
|
|
10834
|
+
if (firstUse) {
|
|
10835
|
+
ignoreRender(ui, true);
|
|
10825
10836
|
onLoad(ui, event);
|
|
10837
|
+
}
|
|
10826
10838
|
leafPaint.loadId = image.load(() => {
|
|
10827
10839
|
ignoreRender(ui, false);
|
|
10828
10840
|
if (!ui.destroyed) {
|
|
@@ -11434,14 +11446,15 @@ const { trimRight } = TextRowHelper;
|
|
|
11434
11446
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
11435
11447
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
11436
11448
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
11437
|
-
let textDrawData, rows = [], bounds;
|
|
11449
|
+
let textDrawData, rows = [], bounds$1, findMaxWidth;
|
|
11438
11450
|
function createRows(drawData, content, style) {
|
|
11439
11451
|
textDrawData = drawData;
|
|
11440
11452
|
rows = drawData.rows;
|
|
11441
|
-
bounds = drawData.bounds;
|
|
11453
|
+
bounds$1 = drawData.bounds;
|
|
11454
|
+
findMaxWidth = !bounds$1.width && !style.autoSizeAlign;
|
|
11442
11455
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
11443
11456
|
const { canvas } = Platform;
|
|
11444
|
-
const { width, height } = bounds;
|
|
11457
|
+
const { width, height } = bounds$1;
|
|
11445
11458
|
const charMode = width || height || __letterSpacing || (textCase !== 'none');
|
|
11446
11459
|
if (charMode) {
|
|
11447
11460
|
const wrap = style.textWrap !== 'none';
|
|
@@ -11523,7 +11536,10 @@ function createRows(drawData, content, style) {
|
|
|
11523
11536
|
else {
|
|
11524
11537
|
content.split('\n').forEach(content => {
|
|
11525
11538
|
textDrawData.paraNumber++;
|
|
11526
|
-
|
|
11539
|
+
rowWidth = canvas.measureText(content).width;
|
|
11540
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
11541
|
+
if (findMaxWidth)
|
|
11542
|
+
setMaxWidth();
|
|
11527
11543
|
});
|
|
11528
11544
|
}
|
|
11529
11545
|
}
|
|
@@ -11552,12 +11568,18 @@ function addRow() {
|
|
|
11552
11568
|
startCharSize = 0;
|
|
11553
11569
|
}
|
|
11554
11570
|
row.width = rowWidth;
|
|
11555
|
-
if (bounds.width)
|
|
11571
|
+
if (bounds$1.width)
|
|
11556
11572
|
trimRight(row);
|
|
11573
|
+
else if (findMaxWidth)
|
|
11574
|
+
setMaxWidth();
|
|
11557
11575
|
rows.push(row);
|
|
11558
11576
|
row = { words: [] };
|
|
11559
11577
|
rowWidth = 0;
|
|
11560
11578
|
}
|
|
11579
|
+
function setMaxWidth() {
|
|
11580
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
11581
|
+
textDrawData.maxWidth = rowWidth;
|
|
11582
|
+
}
|
|
11561
11583
|
|
|
11562
11584
|
const CharMode = 0;
|
|
11563
11585
|
const WordMode = 1;
|
|
@@ -11629,34 +11651,32 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
11629
11651
|
|
|
11630
11652
|
function layoutText(drawData, style) {
|
|
11631
11653
|
const { rows, bounds } = drawData;
|
|
11632
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
11654
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
11633
11655
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11634
11656
|
let starY = __baseLine;
|
|
11635
11657
|
if (__clipText && realHeight > height) {
|
|
11636
11658
|
realHeight = Math.max(height, __lineHeight);
|
|
11637
11659
|
drawData.overflow = rows.length;
|
|
11638
11660
|
}
|
|
11639
|
-
else {
|
|
11661
|
+
else if (height || autoSizeAlign) {
|
|
11640
11662
|
switch (verticalAlign) {
|
|
11641
11663
|
case 'middle':
|
|
11642
11664
|
y += (height - realHeight) / 2;
|
|
11643
11665
|
break;
|
|
11644
|
-
case 'bottom':
|
|
11645
|
-
y += (height - realHeight);
|
|
11666
|
+
case 'bottom': y += (height - realHeight);
|
|
11646
11667
|
}
|
|
11647
11668
|
}
|
|
11648
11669
|
starY += y;
|
|
11649
|
-
let row, rowX, rowWidth;
|
|
11670
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
11650
11671
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11651
11672
|
row = rows[i];
|
|
11652
11673
|
row.x = x;
|
|
11653
11674
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
11654
11675
|
switch (textAlign) {
|
|
11655
11676
|
case 'center':
|
|
11656
|
-
row.x += (
|
|
11677
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
11657
11678
|
break;
|
|
11658
|
-
case 'right':
|
|
11659
|
-
row.x += width - row.width;
|
|
11679
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
11660
11680
|
}
|
|
11661
11681
|
}
|
|
11662
11682
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -11761,14 +11781,14 @@ function getDrawData(content, style) {
|
|
|
11761
11781
|
let height = style.__getInput('height') || 0;
|
|
11762
11782
|
const { textDecoration, __font, __padding: padding } = style;
|
|
11763
11783
|
if (padding) {
|
|
11764
|
-
if (width)
|
|
11784
|
+
if (width)
|
|
11785
|
+
x = padding[left$3], width -= (padding[right$3] + padding[left$3]);
|
|
11786
|
+
else if (!style.autoSizeAlign)
|
|
11765
11787
|
x = padding[left$3];
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
if (
|
|
11788
|
+
if (height)
|
|
11789
|
+
y = padding[top$2], height -= (padding[top$2] + padding[bottom$2]);
|
|
11790
|
+
else if (!style.autoSizeAlign)
|
|
11769
11791
|
y = padding[top$2];
|
|
11770
|
-
height -= (padding[top$2] + padding[bottom$2]);
|
|
11771
|
-
}
|
|
11772
11792
|
}
|
|
11773
11793
|
const drawData = {
|
|
11774
11794
|
bounds: { x, y, width, height },
|
|
@@ -11788,22 +11808,20 @@ function getDrawData(content, style) {
|
|
|
11788
11808
|
return drawData;
|
|
11789
11809
|
}
|
|
11790
11810
|
function padAutoText(padding, drawData, style, width, height) {
|
|
11791
|
-
if (!width) {
|
|
11811
|
+
if (!width && style.autoSizeAlign) {
|
|
11792
11812
|
switch (style.textAlign) {
|
|
11793
11813
|
case 'left':
|
|
11794
11814
|
offsetText(drawData, 'x', padding[left$3]);
|
|
11795
11815
|
break;
|
|
11796
|
-
case 'right':
|
|
11797
|
-
offsetText(drawData, 'x', -padding[right$3]);
|
|
11816
|
+
case 'right': offsetText(drawData, 'x', -padding[right$3]);
|
|
11798
11817
|
}
|
|
11799
11818
|
}
|
|
11800
|
-
if (!height) {
|
|
11819
|
+
if (!height && style.autoSizeAlign) {
|
|
11801
11820
|
switch (style.verticalAlign) {
|
|
11802
11821
|
case 'top':
|
|
11803
11822
|
offsetText(drawData, 'y', padding[top$2]);
|
|
11804
11823
|
break;
|
|
11805
|
-
case 'bottom':
|
|
11806
|
-
offsetText(drawData, 'y', -padding[bottom$2]);
|
|
11824
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom$2]);
|
|
11807
11825
|
}
|
|
11808
11826
|
}
|
|
11809
11827
|
}
|
|
@@ -12325,31 +12343,29 @@ class Stroker extends UI {
|
|
|
12325
12343
|
const { list } = this;
|
|
12326
12344
|
if (list.length) {
|
|
12327
12345
|
let leaf;
|
|
12328
|
-
const { stroke, strokeWidth, fill } =
|
|
12329
|
-
const { bounds } = options;
|
|
12346
|
+
const data = this.__, { stroke, strokeWidth, fill } = data, { bounds } = options;
|
|
12330
12347
|
for (let i = 0; i < list.length; i++) {
|
|
12331
12348
|
leaf = list[i];
|
|
12332
|
-
|
|
12333
|
-
|
|
12349
|
+
const { worldTransform, worldRenderBounds } = leaf;
|
|
12350
|
+
if (bounds && bounds.hit(worldRenderBounds, options.matrix)) {
|
|
12351
|
+
const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
|
|
12334
12352
|
if (aScaleX !== aScaleY) {
|
|
12335
|
-
copy$2(matrix,
|
|
12353
|
+
copy$2(matrix, worldTransform);
|
|
12336
12354
|
scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
|
|
12337
12355
|
canvas.setWorld(matrix, options.matrix);
|
|
12338
12356
|
canvas.beginPath();
|
|
12339
|
-
|
|
12357
|
+
data.strokeWidth = strokeWidth;
|
|
12340
12358
|
const { x, y, width, height } = leaf.__layout.boxBounds;
|
|
12341
12359
|
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
12342
12360
|
}
|
|
12343
12361
|
else {
|
|
12344
|
-
canvas.setWorld(
|
|
12362
|
+
canvas.setWorld(worldTransform, options.matrix);
|
|
12345
12363
|
canvas.beginPath();
|
|
12346
|
-
if (leaf.__.__useArrow)
|
|
12364
|
+
if (leaf.__.__useArrow)
|
|
12347
12365
|
leaf.__drawPath(canvas);
|
|
12348
|
-
|
|
12349
|
-
else {
|
|
12366
|
+
else
|
|
12350
12367
|
leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
|
|
12351
|
-
|
|
12352
|
-
this.__.strokeWidth = strokeWidth / abs(leaf.__world.scaleX);
|
|
12368
|
+
data.strokeWidth = strokeWidth / abs(worldTransform.scaleX);
|
|
12353
12369
|
}
|
|
12354
12370
|
if (stroke)
|
|
12355
12371
|
typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
|
|
@@ -12357,7 +12373,7 @@ class Stroker extends UI {
|
|
|
12357
12373
|
typeof fill === 'string' ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
|
|
12358
12374
|
}
|
|
12359
12375
|
}
|
|
12360
|
-
|
|
12376
|
+
data.strokeWidth = strokeWidth;
|
|
12361
12377
|
}
|
|
12362
12378
|
}
|
|
12363
12379
|
destroy() {
|
|
@@ -12735,7 +12751,6 @@ const EditDataHelper = {
|
|
|
12735
12751
|
scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
|
|
12736
12752
|
}
|
|
12737
12753
|
toPoint(around || align, boxBounds, origin, true);
|
|
12738
|
-
console.log({ origin, scaleX, scaleY, direction, lockRatio, around });
|
|
12739
12754
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
12740
12755
|
},
|
|
12741
12756
|
getRotateData(bounds, direction, current, last, around) {
|
|
@@ -12909,7 +12924,6 @@ class EditBox extends Group {
|
|
|
12909
12924
|
this.editor = editor;
|
|
12910
12925
|
this.visible = false;
|
|
12911
12926
|
this.create();
|
|
12912
|
-
this.rect.syncEventer = editor;
|
|
12913
12927
|
this.__listenEvents();
|
|
12914
12928
|
}
|
|
12915
12929
|
create() {
|
|
@@ -12949,8 +12963,11 @@ class EditBox extends Group {
|
|
|
12949
12963
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
12950
12964
|
rect.set(Object.assign({ stroke, strokeWidth }, (mergeConfig.rect || {})));
|
|
12951
12965
|
rect.hittable = !single && !!moveable;
|
|
12952
|
-
|
|
12953
|
-
|
|
12966
|
+
rect.syncEventer = single && this.editor;
|
|
12967
|
+
if (single && moveable) {
|
|
12968
|
+
element.syncEventer = rect;
|
|
12969
|
+
this.app.interaction.bottomList = [{ target: rect, proxy: element }];
|
|
12970
|
+
}
|
|
12954
12971
|
}
|
|
12955
12972
|
update(bounds) {
|
|
12956
12973
|
this.visible = !this.editor.element.locked;
|
|
@@ -13122,6 +13139,11 @@ class EditBox extends Group {
|
|
|
13122
13139
|
if (editor.single) {
|
|
13123
13140
|
const { element } = editor;
|
|
13124
13141
|
if (element.isBranch) {
|
|
13142
|
+
if (element.textBox) {
|
|
13143
|
+
const find = element.children.find(item => item.editable && item instanceof Text);
|
|
13144
|
+
if (find)
|
|
13145
|
+
return editor.openInnerEditor(find);
|
|
13146
|
+
}
|
|
13125
13147
|
editor.openGroup(element);
|
|
13126
13148
|
editor.target = editor.selector.findDeepOne(e);
|
|
13127
13149
|
}
|
|
@@ -13267,12 +13289,12 @@ const config = {
|
|
|
13267
13289
|
skewable: true
|
|
13268
13290
|
};
|
|
13269
13291
|
|
|
13292
|
+
const bounds = new Bounds();
|
|
13270
13293
|
function simulate(editor) {
|
|
13271
|
-
const { simulateTarget,
|
|
13272
|
-
const {
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
simulateTarget.reset({ x: (x - worldX) / scaleX, y: (y - worldY) / scaleY, width: width / scaleX, height: height / scaleY });
|
|
13294
|
+
const { simulateTarget, list } = editor;
|
|
13295
|
+
const { zoomLayer } = list[0].leafer.zoomLayer;
|
|
13296
|
+
simulateTarget.safeChange(() => simulateTarget.reset(bounds.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
|
|
13297
|
+
zoomLayer.add(simulateTarget);
|
|
13276
13298
|
}
|
|
13277
13299
|
|
|
13278
13300
|
function onTarget(editor, oldValue) {
|
|
@@ -13281,6 +13303,7 @@ function onTarget(editor, oldValue) {
|
|
|
13281
13303
|
editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
|
|
13282
13304
|
}
|
|
13283
13305
|
else {
|
|
13306
|
+
editor.simulateTarget.remove();
|
|
13284
13307
|
editor.leafList.reset();
|
|
13285
13308
|
editor.closeInnerEditor();
|
|
13286
13309
|
}
|
|
@@ -13335,7 +13358,7 @@ const EditorHelper = {
|
|
|
13335
13358
|
const ungroupList = [];
|
|
13336
13359
|
app.lockLayout();
|
|
13337
13360
|
list.forEach(leaf => {
|
|
13338
|
-
if (leaf.isBranch) {
|
|
13361
|
+
if (leaf.isBranch && !leaf.isBranchLeaf) {
|
|
13339
13362
|
const { parent, children } = leaf;
|
|
13340
13363
|
while (children.length) {
|
|
13341
13364
|
ungroupList.push(children[0]);
|
|
@@ -13406,17 +13429,77 @@ EditorGroupEvent.UNGROUP = 'editor.ungroup';
|
|
|
13406
13429
|
EditorGroupEvent.OPEN = 'editor.open_group';
|
|
13407
13430
|
EditorGroupEvent.CLOSE = 'editor.close_group';
|
|
13408
13431
|
|
|
13432
|
+
const { updateMatrix } = LeafHelper;
|
|
13433
|
+
const checkMap = { x: 1, y: 1, scaleX: 1, scaleY: 1, rotation: 1, skewX: 1, skewY: 1 }, origin = 'top-left';
|
|
13434
|
+
class SimulateElement extends Rect {
|
|
13435
|
+
get __tag() { return 'SimulateElement'; }
|
|
13436
|
+
constructor(editor) {
|
|
13437
|
+
super();
|
|
13438
|
+
this.checkChange = true;
|
|
13439
|
+
this.canChange = true;
|
|
13440
|
+
this.visible = this.hittable = false;
|
|
13441
|
+
this.on(PropertyEvent.CHANGE, (event) => {
|
|
13442
|
+
if (this.checkChange && checkMap[event.attrName]) {
|
|
13443
|
+
const { attrName, newValue, oldValue } = event;
|
|
13444
|
+
const addValue = attrName[0] === 's' ? (newValue || 1) / (oldValue || 1) : (newValue || 0) - (oldValue || 0);
|
|
13445
|
+
this.canChange = false;
|
|
13446
|
+
const data = this.__;
|
|
13447
|
+
data[attrName] = oldValue;
|
|
13448
|
+
updateMatrix(this.parent);
|
|
13449
|
+
updateMatrix(this);
|
|
13450
|
+
const oldMatrix = new Matrix(this.__world);
|
|
13451
|
+
data[attrName] = newValue;
|
|
13452
|
+
this.__layout.rotationChange();
|
|
13453
|
+
updateMatrix(this);
|
|
13454
|
+
this.changedTransform = new Matrix(this.__world).divide(oldMatrix);
|
|
13455
|
+
switch (attrName) {
|
|
13456
|
+
case 'x':
|
|
13457
|
+
editor.move(addValue, 0);
|
|
13458
|
+
break;
|
|
13459
|
+
case 'y':
|
|
13460
|
+
editor.move(0, addValue);
|
|
13461
|
+
break;
|
|
13462
|
+
case 'rotation':
|
|
13463
|
+
editor.rotateOf(origin, addValue);
|
|
13464
|
+
break;
|
|
13465
|
+
case 'scaleX':
|
|
13466
|
+
editor.scaleOf(origin, addValue, 1);
|
|
13467
|
+
break;
|
|
13468
|
+
case 'scaleY':
|
|
13469
|
+
editor.scaleOf(origin, 1, addValue);
|
|
13470
|
+
break;
|
|
13471
|
+
case 'skewX':
|
|
13472
|
+
editor.skewOf(origin, addValue, 0);
|
|
13473
|
+
break;
|
|
13474
|
+
case 'skewY':
|
|
13475
|
+
editor.skewOf(origin, 0, addValue);
|
|
13476
|
+
}
|
|
13477
|
+
this.canChange = true;
|
|
13478
|
+
}
|
|
13479
|
+
});
|
|
13480
|
+
}
|
|
13481
|
+
safeChange(changeFn) {
|
|
13482
|
+
if (this.canChange) {
|
|
13483
|
+
this.checkChange = false;
|
|
13484
|
+
changeFn();
|
|
13485
|
+
this.checkChange = true;
|
|
13486
|
+
}
|
|
13487
|
+
}
|
|
13488
|
+
}
|
|
13489
|
+
|
|
13409
13490
|
class Editor extends Group {
|
|
13410
13491
|
get mergeConfig() {
|
|
13411
13492
|
const { element, config } = this;
|
|
13412
13493
|
return this.single && element.editConfig ? Object.assign(Object.assign({}, config), element.editConfig) : config;
|
|
13413
13494
|
}
|
|
13414
13495
|
get list() { return this.leafList.list; }
|
|
13496
|
+
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
13415
13497
|
get editing() { return !!this.list.length; }
|
|
13416
13498
|
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13417
13499
|
get multiple() { return this.list.length > 1; }
|
|
13418
13500
|
get single() { return this.list.length === 1; }
|
|
13419
13501
|
get dragging() { return this.editBox.dragging; }
|
|
13502
|
+
get moving() { return this.editBox.moving; }
|
|
13420
13503
|
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13421
13504
|
get buttons() { return this.editBox.buttons; }
|
|
13422
13505
|
constructor(userConfig, data) {
|
|
@@ -13424,7 +13507,7 @@ class Editor extends Group {
|
|
|
13424
13507
|
this.config = DataHelper.clone(config);
|
|
13425
13508
|
this.leafList = new LeafList();
|
|
13426
13509
|
this.openedGroupList = new LeafList();
|
|
13427
|
-
this.simulateTarget = new
|
|
13510
|
+
this.simulateTarget = new SimulateElement(this);
|
|
13428
13511
|
this.editBox = new EditBox(this);
|
|
13429
13512
|
this.editToolList = {};
|
|
13430
13513
|
this.selector = new EditSelect(this);
|
|
@@ -13562,18 +13645,18 @@ class Editor extends Group {
|
|
|
13562
13645
|
this.skewOf(origin, skewX, skewY);
|
|
13563
13646
|
}
|
|
13564
13647
|
move(x, y = 0) {
|
|
13565
|
-
if (!this.
|
|
13648
|
+
if (!this.checkTransform('moveable'))
|
|
13566
13649
|
return;
|
|
13567
13650
|
const { element } = this;
|
|
13568
13651
|
const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
|
|
13652
|
+
if (this.multiple)
|
|
13653
|
+
element.safeChange(() => element.move(x, y));
|
|
13569
13654
|
const event = new EditorMoveEvent(EditorMoveEvent.MOVE, { target: element, editor: this, moveX: world.x, moveY: world.y });
|
|
13570
13655
|
this.editTool.onMove(event);
|
|
13571
13656
|
this.emitEvent(event);
|
|
13572
|
-
if (this.multiple)
|
|
13573
|
-
element.move(x, y);
|
|
13574
13657
|
}
|
|
13575
13658
|
scaleWithDrag(data) {
|
|
13576
|
-
if (!this.
|
|
13659
|
+
if (!this.checkTransform('resizeable'))
|
|
13577
13660
|
return;
|
|
13578
13661
|
const { element } = this;
|
|
13579
13662
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) }));
|
|
@@ -13581,50 +13664,53 @@ class Editor extends Group {
|
|
|
13581
13664
|
this.emitEvent(event);
|
|
13582
13665
|
}
|
|
13583
13666
|
scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
|
|
13584
|
-
if (!this.
|
|
13667
|
+
if (!this.checkTransform('resizeable'))
|
|
13585
13668
|
return;
|
|
13586
13669
|
const { element } = this;
|
|
13587
13670
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13588
|
-
const transform = this.multiple && this.getChangedTransform(() => element.scaleOf(origin, scaleX, scaleY));
|
|
13671
|
+
const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.scaleOf(origin, scaleX, scaleY)));
|
|
13589
13672
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX, scaleY, transform });
|
|
13590
13673
|
this.editTool.onScale(event);
|
|
13591
13674
|
this.emitEvent(event);
|
|
13592
13675
|
}
|
|
13593
13676
|
flip(axis) {
|
|
13594
|
-
if (this.
|
|
13677
|
+
if (!this.checkTransform('resizeable'))
|
|
13595
13678
|
return;
|
|
13596
13679
|
const { element } = this;
|
|
13597
13680
|
const worldOrigin = this.getWorldOrigin('center');
|
|
13598
|
-
const transform = this.multiple ? this.getChangedTransform(() => element.flip(axis)) : new Matrix(LeafHelper.getFlipTransform(element, axis));
|
|
13681
|
+
const transform = this.multiple ? this.getChangedTransform(() => element.safeChange(() => element.flip(axis))) : new Matrix(LeafHelper.getFlipTransform(element, axis));
|
|
13599
13682
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform });
|
|
13600
13683
|
this.editTool.onScale(event);
|
|
13601
13684
|
this.emitEvent(event);
|
|
13602
13685
|
}
|
|
13603
13686
|
rotateOf(origin, rotation) {
|
|
13604
|
-
if (!this.
|
|
13687
|
+
if (!this.checkTransform('rotateable'))
|
|
13605
13688
|
return;
|
|
13606
13689
|
const { element } = this;
|
|
13607
13690
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13608
|
-
const transform = this.multiple && this.getChangedTransform(() => element.rotateOf(origin, rotation));
|
|
13691
|
+
const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.rotateOf(origin, rotation)));
|
|
13609
13692
|
const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, { target: element, editor: this, worldOrigin, rotation, transform });
|
|
13610
13693
|
this.editTool.onRotate(event);
|
|
13611
13694
|
this.emitEvent(event);
|
|
13612
13695
|
}
|
|
13613
13696
|
skewOf(origin, skewX, skewY = 0, _resize) {
|
|
13614
|
-
if (!this.
|
|
13697
|
+
if (!this.checkTransform('skewable'))
|
|
13615
13698
|
return;
|
|
13616
13699
|
const { element } = this;
|
|
13617
13700
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13618
|
-
const transform = this.multiple && this.getChangedTransform(() => element.skewOf(origin, skewX, skewY));
|
|
13701
|
+
const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.skewOf(origin, skewX, skewY)));
|
|
13619
13702
|
const event = new EditorSkewEvent(EditorSkewEvent.SKEW, { target: element, editor: this, worldOrigin, skewX, skewY, transform });
|
|
13620
13703
|
this.editTool.onSkew(event);
|
|
13621
13704
|
this.emitEvent(event);
|
|
13622
13705
|
}
|
|
13706
|
+
checkTransform(type) { return this.element && !this.element.locked && this.mergeConfig[type]; }
|
|
13623
13707
|
getWorldOrigin(origin) {
|
|
13624
13708
|
return this.element.getWorldPoint(LeafHelper.getInnerOrigin(this.element, origin));
|
|
13625
13709
|
}
|
|
13626
13710
|
getChangedTransform(func) {
|
|
13627
13711
|
const { element } = this;
|
|
13712
|
+
if (this.multiple && !element.canChange)
|
|
13713
|
+
return element.changedTransform;
|
|
13628
13714
|
const oldMatrix = new Matrix(element.worldTransform);
|
|
13629
13715
|
func();
|
|
13630
13716
|
return new Matrix(element.worldTransform).divide(oldMatrix);
|
|
@@ -13681,11 +13767,11 @@ class Editor extends Group {
|
|
|
13681
13767
|
this.emitEvent(event);
|
|
13682
13768
|
group.emitEvent(event);
|
|
13683
13769
|
}
|
|
13684
|
-
openInnerEditor(target) {
|
|
13685
|
-
if (target)
|
|
13770
|
+
openInnerEditor(target, select) {
|
|
13771
|
+
if (target && select)
|
|
13686
13772
|
this.target = target;
|
|
13687
13773
|
if (this.single) {
|
|
13688
|
-
const editTarget = this.element;
|
|
13774
|
+
const editTarget = target || this.element;
|
|
13689
13775
|
const tag = editTarget.editInner;
|
|
13690
13776
|
if (tag && EditToolCreator.list[tag]) {
|
|
13691
13777
|
this.editTool.unload();
|
|
@@ -13737,14 +13823,15 @@ class Editor extends Group {
|
|
|
13737
13823
|
}
|
|
13738
13824
|
listenTargetEvents() {
|
|
13739
13825
|
if (!this.targetEventIds.length) {
|
|
13740
|
-
const { leafer } = this
|
|
13826
|
+
const { app, leafer } = this;
|
|
13741
13827
|
this.targetEventIds = [
|
|
13742
|
-
this.app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
|
|
13743
|
-
this.app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
|
|
13744
|
-
this.app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
|
|
13745
13828
|
leafer.on_(RenderEvent.START, this.update, this),
|
|
13746
|
-
|
|
13747
|
-
|
|
13829
|
+
app.on_(RenderEvent.CHILD_START, this.forceRender, this),
|
|
13830
|
+
app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
|
|
13831
|
+
app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
|
|
13832
|
+
app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
|
|
13833
|
+
app.on_([KeyEvent.HOLD, KeyEvent.UP], (e) => { updateCursor(this, e); }),
|
|
13834
|
+
app.on_(KeyEvent.DOWN, this.editBox.onArrow, this.editBox)
|
|
13748
13835
|
];
|
|
13749
13836
|
}
|
|
13750
13837
|
}
|
|
@@ -13877,10 +13964,7 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
13877
13964
|
}
|
|
13878
13965
|
update() {
|
|
13879
13966
|
const { editor, editBox } = this;
|
|
13880
|
-
const {
|
|
13881
|
-
if (editor.multiple)
|
|
13882
|
-
simulateTarget.parent.updateLayout();
|
|
13883
|
-
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = element.getLayoutBounds('box', editor, true);
|
|
13967
|
+
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = editor.element.getLayoutBounds('box', editor, true);
|
|
13884
13968
|
editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
13885
13969
|
editBox.update({ x: 0, y: 0, width, height });
|
|
13886
13970
|
this.onUpdate();
|
|
@@ -14569,18 +14653,7 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14569
14653
|
style.position = 'fixed';
|
|
14570
14654
|
style.transformOrigin = 'left top';
|
|
14571
14655
|
style.boxSizing = 'border-box';
|
|
14572
|
-
|
|
14573
|
-
div.innerHTML = text.text;
|
|
14574
|
-
this.textScale = 1;
|
|
14575
|
-
}
|
|
14576
|
-
else {
|
|
14577
|
-
div.innerText = text.text;
|
|
14578
|
-
const { scaleX, scaleY } = text.worldTransform;
|
|
14579
|
-
this.textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
14580
|
-
const fontSize = text.fontSize * this.textScale;
|
|
14581
|
-
if (fontSize < 12)
|
|
14582
|
-
this.textScale *= 12 / fontSize;
|
|
14583
|
-
}
|
|
14656
|
+
this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
|
|
14584
14657
|
const { view } = editor.app;
|
|
14585
14658
|
(this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
|
|
14586
14659
|
this.eventIds = [
|
|
@@ -14629,16 +14702,46 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14629
14702
|
this.editor.closeInnerEditor();
|
|
14630
14703
|
}
|
|
14631
14704
|
onUpdate() {
|
|
14632
|
-
const { editTarget: text
|
|
14633
|
-
|
|
14634
|
-
|
|
14705
|
+
const { editTarget: text } = this;
|
|
14706
|
+
let textScale = 1;
|
|
14707
|
+
if (!this.isHTMLText) {
|
|
14708
|
+
const { scaleX, scaleY } = text.worldTransform;
|
|
14709
|
+
textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
14710
|
+
const fontSize = text.fontSize * textScale;
|
|
14711
|
+
if (fontSize < 12)
|
|
14712
|
+
textScale *= 12 / text.fontSize;
|
|
14713
|
+
}
|
|
14714
|
+
this.textScale = textScale;
|
|
14635
14715
|
const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
|
|
14716
|
+
let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14717
|
+
let { width, height } = text;
|
|
14718
|
+
x -= window.scrollX, y -= window.scrollY, width *= textScale, height *= textScale;
|
|
14719
|
+
const data = text.__;
|
|
14720
|
+
if (data.__autoWidth && data.autoSizeAlign) {
|
|
14721
|
+
width += 20;
|
|
14722
|
+
switch (data.textAlign) {
|
|
14723
|
+
case 'center':
|
|
14724
|
+
x -= width / 2;
|
|
14725
|
+
break;
|
|
14726
|
+
case 'right': x -= width;
|
|
14727
|
+
}
|
|
14728
|
+
}
|
|
14729
|
+
if (data.__autoHeight && data.autoSizeAlign) {
|
|
14730
|
+
height += 20;
|
|
14731
|
+
switch (data.verticalAlign) {
|
|
14732
|
+
case 'middle':
|
|
14733
|
+
y -= height / 2;
|
|
14734
|
+
break;
|
|
14735
|
+
case 'bottom': y -= height;
|
|
14736
|
+
}
|
|
14737
|
+
}
|
|
14738
|
+
const { style } = this.editDom;
|
|
14636
14739
|
style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
14637
|
-
style.left = x
|
|
14638
|
-
style.top = y
|
|
14639
|
-
style.width =
|
|
14640
|
-
style.height =
|
|
14641
|
-
this.isHTMLText || updateStyle(this.editDom, text,
|
|
14740
|
+
style.left = x + 'px';
|
|
14741
|
+
style.top = y + 'px';
|
|
14742
|
+
style.width = width + 'px';
|
|
14743
|
+
style.height = height + 'px';
|
|
14744
|
+
this.isHTMLText || updateStyle(this.editDom, text, textScale);
|
|
14642
14745
|
}
|
|
14643
14746
|
onUnload() {
|
|
14644
14747
|
const { editTarget: text, editor, editDom: dom } = this;
|