@leafer-in/editor 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.cjs +25 -223
- package/dist/editor.esm.js +21 -219
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +26 -225
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.js +1 -1
- package/package.json +5 -5
- package/src/display/EditSelect.ts +2 -1
- package/src/display/Stroker.ts +18 -4
- package/src/index.ts +3 -2
- package/types/index.d.ts +1 -0
package/dist/editor.cjs
CHANGED
|
@@ -1,220 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var resize = require('@leafer-in/resize');
|
|
3
4
|
var draw = require('@leafer-ui/draw');
|
|
4
5
|
var core = require('@leafer-ui/core');
|
|
5
6
|
|
|
6
|
-
const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = draw.PathCommandMap;
|
|
7
|
-
const PathScaler = {
|
|
8
|
-
scale(data, scaleX, scaleY) {
|
|
9
|
-
if (!data)
|
|
10
|
-
return;
|
|
11
|
-
let command;
|
|
12
|
-
let i = 0, len = data.length;
|
|
13
|
-
while (i < len) {
|
|
14
|
-
command = data[i];
|
|
15
|
-
switch (command) {
|
|
16
|
-
case M:
|
|
17
|
-
case L:
|
|
18
|
-
scalePoints(data, scaleX, scaleY, i, 1);
|
|
19
|
-
i += 3;
|
|
20
|
-
break;
|
|
21
|
-
case C:
|
|
22
|
-
scalePoints(data, scaleX, scaleY, i, 3);
|
|
23
|
-
i += 7;
|
|
24
|
-
break;
|
|
25
|
-
case Q:
|
|
26
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
27
|
-
i += 5;
|
|
28
|
-
break;
|
|
29
|
-
case Z:
|
|
30
|
-
i += 1;
|
|
31
|
-
break;
|
|
32
|
-
case N:
|
|
33
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
34
|
-
i += 5;
|
|
35
|
-
break;
|
|
36
|
-
case D:
|
|
37
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
38
|
-
i += 9;
|
|
39
|
-
break;
|
|
40
|
-
case X:
|
|
41
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
42
|
-
i += 6;
|
|
43
|
-
break;
|
|
44
|
-
case G:
|
|
45
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
46
|
-
i += 9;
|
|
47
|
-
break;
|
|
48
|
-
case F:
|
|
49
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
50
|
-
i += 5;
|
|
51
|
-
break;
|
|
52
|
-
case O:
|
|
53
|
-
data[i] = G;
|
|
54
|
-
data.splice(i + 4, 0, data[i + 3], 0);
|
|
55
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
56
|
-
i += 7 + 2;
|
|
57
|
-
len += 2;
|
|
58
|
-
break;
|
|
59
|
-
case P:
|
|
60
|
-
data[i] = F;
|
|
61
|
-
data.splice(i + 4, 0, data[i + 3]);
|
|
62
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
63
|
-
i += 4 + 1;
|
|
64
|
-
len += 1;
|
|
65
|
-
break;
|
|
66
|
-
case U:
|
|
67
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
68
|
-
i += 6;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
scalePoints(data, scaleX, scaleY, start, pointCount) {
|
|
74
|
-
for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
|
|
75
|
-
data[i] *= scaleX;
|
|
76
|
-
data[i + 1] *= scaleY;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const { scalePoints } = PathScaler;
|
|
81
|
-
|
|
82
|
-
const matrix$1 = draw.MatrixHelper.get();
|
|
83
|
-
const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottom: bottom$1, left: left$2 } = draw.Direction9;
|
|
84
|
-
function scaleResize(leaf, scaleX, scaleY) {
|
|
85
|
-
if (leaf.pathInputed) {
|
|
86
|
-
scaleResizePath(leaf, scaleX, scaleY);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
if (scaleX !== 1)
|
|
90
|
-
leaf.width *= scaleX;
|
|
91
|
-
if (scaleY !== 1)
|
|
92
|
-
leaf.height *= scaleY;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function scaleResizeFontSize(leaf, scaleX, scaleY) {
|
|
96
|
-
const { app } = leaf;
|
|
97
|
-
const editor = app && app.editor;
|
|
98
|
-
let fontScale = scaleX;
|
|
99
|
-
if (editor.editing) {
|
|
100
|
-
const layout = leaf.__layout;
|
|
101
|
-
let { width, height } = layout.boxBounds;
|
|
102
|
-
width *= scaleY - scaleX;
|
|
103
|
-
height *= scaleX - scaleY;
|
|
104
|
-
switch (editor.resizeDirection) {
|
|
105
|
-
case top$1:
|
|
106
|
-
case bottom$1:
|
|
107
|
-
fontScale = scaleY;
|
|
108
|
-
layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
|
|
109
|
-
break;
|
|
110
|
-
case left$2:
|
|
111
|
-
case right$2:
|
|
112
|
-
layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
|
|
113
|
-
break;
|
|
114
|
-
case topLeft$1:
|
|
115
|
-
case topRight$1:
|
|
116
|
-
layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
leaf.fontSize *= fontScale;
|
|
121
|
-
const data = leaf.__;
|
|
122
|
-
if (!data.__autoWidth)
|
|
123
|
-
leaf.width *= fontScale;
|
|
124
|
-
if (!data.__autoHeight)
|
|
125
|
-
leaf.height *= fontScale;
|
|
126
|
-
}
|
|
127
|
-
function scaleResizePath(leaf, scaleX, scaleY) {
|
|
128
|
-
PathScaler.scale(leaf.__.path, scaleX, scaleY);
|
|
129
|
-
leaf.path = leaf.__.path;
|
|
130
|
-
}
|
|
131
|
-
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
132
|
-
const { points } = leaf;
|
|
133
|
-
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
134
|
-
leaf.points = points;
|
|
135
|
-
}
|
|
136
|
-
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
137
|
-
const { children } = group;
|
|
138
|
-
for (let i = 0; i < children.length; i++) {
|
|
139
|
-
matrix$1.a = scaleX;
|
|
140
|
-
matrix$1.d = scaleY;
|
|
141
|
-
children[i].transform(matrix$1, true);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const leaf = draw.Leaf.prototype;
|
|
146
|
-
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
147
|
-
const data = this;
|
|
148
|
-
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
149
|
-
data.scaleX *= scaleX;
|
|
150
|
-
data.scaleY *= scaleY;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
if (scaleX < 0)
|
|
154
|
-
data.scaleX *= -1, scaleX = -scaleX;
|
|
155
|
-
if (scaleY < 0)
|
|
156
|
-
data.scaleY *= -1, scaleY = -scaleY;
|
|
157
|
-
this.__scaleResize(scaleX, scaleY);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
161
|
-
scaleResize(this, scaleX, scaleY);
|
|
162
|
-
};
|
|
163
|
-
leaf.resizeWidth = function (width) {
|
|
164
|
-
const scale = width / this.getBounds('box', 'local').width;
|
|
165
|
-
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
166
|
-
};
|
|
167
|
-
leaf.resizeHeight = function (height) {
|
|
168
|
-
const scale = height / this.getBounds('box', 'local').height;
|
|
169
|
-
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
170
|
-
};
|
|
171
|
-
draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
172
|
-
if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
|
|
173
|
-
scaleResizeFontSize(this, scaleX, scaleY);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
scaleResize(this, scaleX, scaleY);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
draw.Path.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
180
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
181
|
-
};
|
|
182
|
-
draw.Line.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
183
|
-
if (this.pathInputed) {
|
|
184
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
185
|
-
}
|
|
186
|
-
else if (this.points) {
|
|
187
|
-
scaleResizePoints(this, scaleX, scaleY);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
this.width *= scaleX;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
draw.Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
194
|
-
if (this.pathInputed) {
|
|
195
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
196
|
-
}
|
|
197
|
-
else if (this.points) {
|
|
198
|
-
scaleResizePoints(this, scaleX, scaleY);
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
scaleResize(this, scaleX, scaleY);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
draw.Group.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
205
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
206
|
-
};
|
|
207
|
-
draw.Box.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
208
|
-
if (this.__.__autoSize && this.children.length) {
|
|
209
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
scaleResize(this, scaleX, scaleY);
|
|
213
|
-
if (this.__.resizeChildren)
|
|
214
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
7
|
/******************************************************************************
|
|
219
8
|
Copyright (c) Microsoft Corporation.
|
|
220
9
|
|
|
@@ -301,9 +90,12 @@ function targetAttr(fn) {
|
|
|
301
90
|
};
|
|
302
91
|
}
|
|
303
92
|
|
|
304
|
-
const matrix = draw.MatrixHelper.get();
|
|
305
93
|
const { abs } = Math;
|
|
306
94
|
const { copy: copy$1, scale } = draw.MatrixHelper;
|
|
95
|
+
const { setListWithFn } = draw.BoundsHelper;
|
|
96
|
+
const { worldBounds } = draw.LeafBoundsHelper;
|
|
97
|
+
const matrix = draw.getMatrixData();
|
|
98
|
+
const bounds$1 = draw.getBoundsData();
|
|
307
99
|
class Stroker extends draw.UI {
|
|
308
100
|
constructor() {
|
|
309
101
|
super();
|
|
@@ -314,6 +106,17 @@ class Stroker extends draw.UI {
|
|
|
314
106
|
setTarget(target, style) {
|
|
315
107
|
this.set(style);
|
|
316
108
|
this.target = target;
|
|
109
|
+
this.update();
|
|
110
|
+
}
|
|
111
|
+
update() {
|
|
112
|
+
const { list } = this;
|
|
113
|
+
if (list.length) {
|
|
114
|
+
setListWithFn(bounds$1, list, worldBounds);
|
|
115
|
+
this.set(bounds$1);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.width = this.height = 1;
|
|
119
|
+
}
|
|
317
120
|
}
|
|
318
121
|
__draw(canvas, options) {
|
|
319
122
|
const { list } = this;
|
|
@@ -323,7 +126,7 @@ class Stroker extends draw.UI {
|
|
|
323
126
|
for (let i = 0; i < list.length; i++) {
|
|
324
127
|
leaf = list[i];
|
|
325
128
|
const { worldTransform, worldRenderBounds } = leaf;
|
|
326
|
-
if (bounds
|
|
129
|
+
if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
|
|
327
130
|
const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
|
|
328
131
|
if (aScaleX !== aScaleY) {
|
|
329
132
|
copy$1(matrix, worldTransform);
|
|
@@ -363,7 +166,6 @@ __decorate([
|
|
|
363
166
|
function onTarget$1(stroker) {
|
|
364
167
|
const value = stroker.target;
|
|
365
168
|
stroker.list = value ? (value instanceof Array ? value : [value]) : [];
|
|
366
|
-
stroker.forceUpdate();
|
|
367
169
|
}
|
|
368
170
|
|
|
369
171
|
class SelectArea extends draw.Group {
|
|
@@ -448,8 +250,8 @@ class EditSelect extends draw.Group {
|
|
|
448
250
|
}
|
|
449
251
|
}
|
|
450
252
|
update() {
|
|
451
|
-
|
|
452
|
-
|
|
253
|
+
this.hoverStroker.update();
|
|
254
|
+
this.targetStroker.update();
|
|
453
255
|
}
|
|
454
256
|
onPointerMove(e) {
|
|
455
257
|
const { app, editor } = this;
|
|
@@ -2118,13 +1920,13 @@ exports.EditorScaleEvent = EditorScaleEvent;
|
|
|
2118
1920
|
exports.EditorSkewEvent = EditorSkewEvent;
|
|
2119
1921
|
exports.InnerEditor = InnerEditor;
|
|
2120
1922
|
exports.InnerEditorEvent = InnerEditorEvent;
|
|
2121
|
-
exports.PathScaler = PathScaler;
|
|
2122
1923
|
exports.SelectArea = SelectArea;
|
|
2123
1924
|
exports.Stroker = Stroker;
|
|
2124
1925
|
exports.registerEditTool = registerEditTool;
|
|
2125
1926
|
exports.registerInnerEditor = registerInnerEditor;
|
|
2126
|
-
|
|
2127
|
-
exports.
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
1927
|
+
Object.keys(resize).forEach(function (k) {
|
|
1928
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1929
|
+
enumerable: true,
|
|
1930
|
+
get: function () { return resize[k]; }
|
|
1931
|
+
});
|
|
1932
|
+
});
|
package/dist/editor.esm.js
CHANGED
|
@@ -1,218 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export * from '@leafer-in/resize';
|
|
2
|
+
import { Event, defineKey, getMatrixData, getBoundsData, UI, Paint, MatrixHelper, BoundsHelper, LeafBoundsHelper, Group, Rect, Answer, Bounds, LeafList, PointHelper, AroundHelper, MathHelper, Direction9, Box, Text, Matrix, Debug, PropertyEvent, LeafHelper, DataHelper, RenderEvent, getPointData, Creator, dataType } from '@leafer-ui/draw';
|
|
2
3
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent, KeyEvent } from '@leafer-ui/core';
|
|
3
4
|
|
|
4
|
-
const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = PathCommandMap;
|
|
5
|
-
const PathScaler = {
|
|
6
|
-
scale(data, scaleX, scaleY) {
|
|
7
|
-
if (!data)
|
|
8
|
-
return;
|
|
9
|
-
let command;
|
|
10
|
-
let i = 0, len = data.length;
|
|
11
|
-
while (i < len) {
|
|
12
|
-
command = data[i];
|
|
13
|
-
switch (command) {
|
|
14
|
-
case M:
|
|
15
|
-
case L:
|
|
16
|
-
scalePoints(data, scaleX, scaleY, i, 1);
|
|
17
|
-
i += 3;
|
|
18
|
-
break;
|
|
19
|
-
case C:
|
|
20
|
-
scalePoints(data, scaleX, scaleY, i, 3);
|
|
21
|
-
i += 7;
|
|
22
|
-
break;
|
|
23
|
-
case Q:
|
|
24
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
25
|
-
i += 5;
|
|
26
|
-
break;
|
|
27
|
-
case Z:
|
|
28
|
-
i += 1;
|
|
29
|
-
break;
|
|
30
|
-
case N:
|
|
31
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
32
|
-
i += 5;
|
|
33
|
-
break;
|
|
34
|
-
case D:
|
|
35
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
36
|
-
i += 9;
|
|
37
|
-
break;
|
|
38
|
-
case X:
|
|
39
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
40
|
-
i += 6;
|
|
41
|
-
break;
|
|
42
|
-
case G:
|
|
43
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
44
|
-
i += 9;
|
|
45
|
-
break;
|
|
46
|
-
case F:
|
|
47
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
48
|
-
i += 5;
|
|
49
|
-
break;
|
|
50
|
-
case O:
|
|
51
|
-
data[i] = G;
|
|
52
|
-
data.splice(i + 4, 0, data[i + 3], 0);
|
|
53
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
54
|
-
i += 7 + 2;
|
|
55
|
-
len += 2;
|
|
56
|
-
break;
|
|
57
|
-
case P:
|
|
58
|
-
data[i] = F;
|
|
59
|
-
data.splice(i + 4, 0, data[i + 3]);
|
|
60
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
61
|
-
i += 4 + 1;
|
|
62
|
-
len += 1;
|
|
63
|
-
break;
|
|
64
|
-
case U:
|
|
65
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
66
|
-
i += 6;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
scalePoints(data, scaleX, scaleY, start, pointCount) {
|
|
72
|
-
for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
|
|
73
|
-
data[i] *= scaleX;
|
|
74
|
-
data[i + 1] *= scaleY;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const { scalePoints } = PathScaler;
|
|
79
|
-
|
|
80
|
-
const matrix$1 = MatrixHelper.get();
|
|
81
|
-
const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottom: bottom$1, left: left$2 } = Direction9;
|
|
82
|
-
function scaleResize(leaf, scaleX, scaleY) {
|
|
83
|
-
if (leaf.pathInputed) {
|
|
84
|
-
scaleResizePath(leaf, scaleX, scaleY);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
if (scaleX !== 1)
|
|
88
|
-
leaf.width *= scaleX;
|
|
89
|
-
if (scaleY !== 1)
|
|
90
|
-
leaf.height *= scaleY;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function scaleResizeFontSize(leaf, scaleX, scaleY) {
|
|
94
|
-
const { app } = leaf;
|
|
95
|
-
const editor = app && app.editor;
|
|
96
|
-
let fontScale = scaleX;
|
|
97
|
-
if (editor.editing) {
|
|
98
|
-
const layout = leaf.__layout;
|
|
99
|
-
let { width, height } = layout.boxBounds;
|
|
100
|
-
width *= scaleY - scaleX;
|
|
101
|
-
height *= scaleX - scaleY;
|
|
102
|
-
switch (editor.resizeDirection) {
|
|
103
|
-
case top$1:
|
|
104
|
-
case bottom$1:
|
|
105
|
-
fontScale = scaleY;
|
|
106
|
-
layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
|
|
107
|
-
break;
|
|
108
|
-
case left$2:
|
|
109
|
-
case right$2:
|
|
110
|
-
layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
|
|
111
|
-
break;
|
|
112
|
-
case topLeft$1:
|
|
113
|
-
case topRight$1:
|
|
114
|
-
layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
leaf.fontSize *= fontScale;
|
|
119
|
-
const data = leaf.__;
|
|
120
|
-
if (!data.__autoWidth)
|
|
121
|
-
leaf.width *= fontScale;
|
|
122
|
-
if (!data.__autoHeight)
|
|
123
|
-
leaf.height *= fontScale;
|
|
124
|
-
}
|
|
125
|
-
function scaleResizePath(leaf, scaleX, scaleY) {
|
|
126
|
-
PathScaler.scale(leaf.__.path, scaleX, scaleY);
|
|
127
|
-
leaf.path = leaf.__.path;
|
|
128
|
-
}
|
|
129
|
-
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
130
|
-
const { points } = leaf;
|
|
131
|
-
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
132
|
-
leaf.points = points;
|
|
133
|
-
}
|
|
134
|
-
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
135
|
-
const { children } = group;
|
|
136
|
-
for (let i = 0; i < children.length; i++) {
|
|
137
|
-
matrix$1.a = scaleX;
|
|
138
|
-
matrix$1.d = scaleY;
|
|
139
|
-
children[i].transform(matrix$1, true);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const leaf = Leaf.prototype;
|
|
144
|
-
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
145
|
-
const data = this;
|
|
146
|
-
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
147
|
-
data.scaleX *= scaleX;
|
|
148
|
-
data.scaleY *= scaleY;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
if (scaleX < 0)
|
|
152
|
-
data.scaleX *= -1, scaleX = -scaleX;
|
|
153
|
-
if (scaleY < 0)
|
|
154
|
-
data.scaleY *= -1, scaleY = -scaleY;
|
|
155
|
-
this.__scaleResize(scaleX, scaleY);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
159
|
-
scaleResize(this, scaleX, scaleY);
|
|
160
|
-
};
|
|
161
|
-
leaf.resizeWidth = function (width) {
|
|
162
|
-
const scale = width / this.getBounds('box', 'local').width;
|
|
163
|
-
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
164
|
-
};
|
|
165
|
-
leaf.resizeHeight = function (height) {
|
|
166
|
-
const scale = height / this.getBounds('box', 'local').height;
|
|
167
|
-
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
168
|
-
};
|
|
169
|
-
Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
170
|
-
if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
|
|
171
|
-
scaleResizeFontSize(this, scaleX, scaleY);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
scaleResize(this, scaleX, scaleY);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
Path.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
178
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
179
|
-
};
|
|
180
|
-
Line.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
181
|
-
if (this.pathInputed) {
|
|
182
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
183
|
-
}
|
|
184
|
-
else if (this.points) {
|
|
185
|
-
scaleResizePoints(this, scaleX, scaleY);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
this.width *= scaleX;
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
192
|
-
if (this.pathInputed) {
|
|
193
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
194
|
-
}
|
|
195
|
-
else if (this.points) {
|
|
196
|
-
scaleResizePoints(this, scaleX, scaleY);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
scaleResize(this, scaleX, scaleY);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
Group.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
203
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
204
|
-
};
|
|
205
|
-
Box.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
206
|
-
if (this.__.__autoSize && this.children.length) {
|
|
207
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
scaleResize(this, scaleX, scaleY);
|
|
211
|
-
if (this.__.resizeChildren)
|
|
212
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
5
|
/******************************************************************************
|
|
217
6
|
Copyright (c) Microsoft Corporation.
|
|
218
7
|
|
|
@@ -299,9 +88,12 @@ function targetAttr(fn) {
|
|
|
299
88
|
};
|
|
300
89
|
}
|
|
301
90
|
|
|
302
|
-
const matrix = MatrixHelper.get();
|
|
303
91
|
const { abs } = Math;
|
|
304
92
|
const { copy: copy$1, scale } = MatrixHelper;
|
|
93
|
+
const { setListWithFn } = BoundsHelper;
|
|
94
|
+
const { worldBounds } = LeafBoundsHelper;
|
|
95
|
+
const matrix = getMatrixData();
|
|
96
|
+
const bounds$1 = getBoundsData();
|
|
305
97
|
class Stroker extends UI {
|
|
306
98
|
constructor() {
|
|
307
99
|
super();
|
|
@@ -312,6 +104,17 @@ class Stroker extends UI {
|
|
|
312
104
|
setTarget(target, style) {
|
|
313
105
|
this.set(style);
|
|
314
106
|
this.target = target;
|
|
107
|
+
this.update();
|
|
108
|
+
}
|
|
109
|
+
update() {
|
|
110
|
+
const { list } = this;
|
|
111
|
+
if (list.length) {
|
|
112
|
+
setListWithFn(bounds$1, list, worldBounds);
|
|
113
|
+
this.set(bounds$1);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.width = this.height = 1;
|
|
117
|
+
}
|
|
315
118
|
}
|
|
316
119
|
__draw(canvas, options) {
|
|
317
120
|
const { list } = this;
|
|
@@ -321,7 +124,7 @@ class Stroker extends UI {
|
|
|
321
124
|
for (let i = 0; i < list.length; i++) {
|
|
322
125
|
leaf = list[i];
|
|
323
126
|
const { worldTransform, worldRenderBounds } = leaf;
|
|
324
|
-
if (bounds
|
|
127
|
+
if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
|
|
325
128
|
const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
|
|
326
129
|
if (aScaleX !== aScaleY) {
|
|
327
130
|
copy$1(matrix, worldTransform);
|
|
@@ -361,7 +164,6 @@ __decorate([
|
|
|
361
164
|
function onTarget$1(stroker) {
|
|
362
165
|
const value = stroker.target;
|
|
363
166
|
stroker.list = value ? (value instanceof Array ? value : [value]) : [];
|
|
364
|
-
stroker.forceUpdate();
|
|
365
167
|
}
|
|
366
168
|
|
|
367
169
|
class SelectArea extends Group {
|
|
@@ -446,8 +248,8 @@ class EditSelect extends Group {
|
|
|
446
248
|
}
|
|
447
249
|
}
|
|
448
250
|
update() {
|
|
449
|
-
|
|
450
|
-
|
|
251
|
+
this.hoverStroker.update();
|
|
252
|
+
this.targetStroker.update();
|
|
451
253
|
}
|
|
452
254
|
onPointerMove(e) {
|
|
453
255
|
const { app, editor } = this;
|
|
@@ -2100,4 +1902,4 @@ UI.setEditInner = function (editorName) {
|
|
|
2100
1902
|
});
|
|
2101
1903
|
};
|
|
2102
1904
|
|
|
2103
|
-
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, LineEditTool,
|
|
1905
|
+
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, LineEditTool, SelectArea, Stroker, registerEditTool, registerInnerEditor };
|