@leafer-editor/worker 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.js +146 -105
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +146 -105
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.module.js
CHANGED
|
@@ -108,7 +108,7 @@ const MathHelper = {
|
|
|
108
108
|
return rotation - oldRotation;
|
|
109
109
|
},
|
|
110
110
|
float(num, maxLength) {
|
|
111
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
111
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
112
112
|
num = round(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
114
|
},
|
|
@@ -1411,14 +1411,13 @@ const UICreator = {
|
|
|
1411
1411
|
list: {},
|
|
1412
1412
|
register(UI) {
|
|
1413
1413
|
const { __tag: tag } = UI.prototype;
|
|
1414
|
-
if (list$3[tag])
|
|
1414
|
+
if (list$3[tag])
|
|
1415
1415
|
debug$f.repeat(tag);
|
|
1416
|
-
|
|
1417
|
-
else {
|
|
1418
|
-
list$3[tag] = UI;
|
|
1419
|
-
}
|
|
1416
|
+
list$3[tag] = UI;
|
|
1420
1417
|
},
|
|
1421
1418
|
get(tag, data, x, y, width, height) {
|
|
1419
|
+
if (!list$3[tag])
|
|
1420
|
+
debug$f.error('not register ' + tag);
|
|
1422
1421
|
const ui = new list$3[tag](data);
|
|
1423
1422
|
if (x !== undefined) {
|
|
1424
1423
|
ui.x = x;
|
|
@@ -1442,7 +1441,7 @@ const EventCreator = {
|
|
|
1442
1441
|
Object.keys(Event).forEach(key => {
|
|
1443
1442
|
name = Event[key];
|
|
1444
1443
|
if (typeof name === 'string')
|
|
1445
|
-
nameList[name]
|
|
1444
|
+
nameList[name] && debug$e.repeat(name), nameList[name] = Event;
|
|
1446
1445
|
});
|
|
1447
1446
|
},
|
|
1448
1447
|
changeName(oldName, newName) {
|
|
@@ -1644,7 +1643,7 @@ class LeafData {
|
|
|
1644
1643
|
const t = this;
|
|
1645
1644
|
if (t.blendMode === 'pass-through') {
|
|
1646
1645
|
const leaf = this.__leaf;
|
|
1647
|
-
if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
|
|
1646
|
+
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
|
|
1648
1647
|
t.__single = true;
|
|
1649
1648
|
}
|
|
1650
1649
|
else if (t.__single) {
|
|
@@ -2042,8 +2041,9 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2042
2041
|
takeCanvas = this.getSameCanvas();
|
|
2043
2042
|
takeCanvas.copyWorld(this);
|
|
2044
2043
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2044
|
+
const s = this.size;
|
|
2045
|
+
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2046
|
+
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2047
2047
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2048
2048
|
if (this.context && !this.unreal) {
|
|
2049
2049
|
this.updateViewSize();
|
|
@@ -2157,6 +2157,17 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2157
2157
|
if (!onlyResetTransform)
|
|
2158
2158
|
this.useWorldTransform();
|
|
2159
2159
|
}
|
|
2160
|
+
useGrayscaleAlpha(bounds) {
|
|
2161
|
+
this.setTempBounds(bounds, true, true);
|
|
2162
|
+
let alpha, pixel;
|
|
2163
|
+
const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
|
|
2164
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
2165
|
+
pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
|
|
2166
|
+
if (alpha = data[i + 3])
|
|
2167
|
+
data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
|
|
2168
|
+
}
|
|
2169
|
+
context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
|
|
2170
|
+
}
|
|
2160
2171
|
useMask(maskCanvas, fromBounds, toBounds) {
|
|
2161
2172
|
this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
|
|
2162
2173
|
}
|
|
@@ -2167,7 +2178,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2167
2178
|
if (blendMode)
|
|
2168
2179
|
this.blendMode = blendMode;
|
|
2169
2180
|
this.fillStyle = color;
|
|
2170
|
-
|
|
2181
|
+
this.setTempBounds(bounds);
|
|
2171
2182
|
this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2172
2183
|
if (blendMode)
|
|
2173
2184
|
this.blendMode = 'source-over';
|
|
@@ -2176,22 +2187,18 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2176
2187
|
if (blendMode)
|
|
2177
2188
|
this.blendMode = blendMode;
|
|
2178
2189
|
this.strokeStyle = color;
|
|
2179
|
-
|
|
2190
|
+
this.setTempBounds(bounds);
|
|
2180
2191
|
this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2181
2192
|
if (blendMode)
|
|
2182
2193
|
this.blendMode = 'source-over';
|
|
2183
2194
|
}
|
|
2184
2195
|
clearWorld(bounds, ceilPixel) {
|
|
2185
|
-
|
|
2186
|
-
if (ceilPixel)
|
|
2187
|
-
tempBounds$1.ceil();
|
|
2196
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2188
2197
|
this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2189
2198
|
}
|
|
2190
2199
|
clipWorld(bounds, ceilPixel) {
|
|
2191
2200
|
this.beginPath();
|
|
2192
|
-
|
|
2193
|
-
if (ceilPixel)
|
|
2194
|
-
tempBounds$1.ceil();
|
|
2201
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2195
2202
|
this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2196
2203
|
this.clip();
|
|
2197
2204
|
}
|
|
@@ -2199,6 +2206,14 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2199
2206
|
const { pixelRatio } = this;
|
|
2200
2207
|
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2201
2208
|
}
|
|
2209
|
+
setTempBounds(bounds, ceil, intersect) {
|
|
2210
|
+
tempBounds$1.set(bounds);
|
|
2211
|
+
if (intersect)
|
|
2212
|
+
tempBounds$1.intersect(this.bounds);
|
|
2213
|
+
tempBounds$1.scale(this.pixelRatio);
|
|
2214
|
+
if (ceil)
|
|
2215
|
+
tempBounds$1.ceil();
|
|
2216
|
+
}
|
|
2202
2217
|
isSameSize(size) {
|
|
2203
2218
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2204
2219
|
}
|
|
@@ -4150,20 +4165,17 @@ const LeafHelper = {
|
|
|
4150
4165
|
}
|
|
4151
4166
|
return true;
|
|
4152
4167
|
},
|
|
4153
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4168
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4154
4169
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4155
4170
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4156
|
-
L$3.moveLocal(t, local.x, local.y);
|
|
4171
|
+
L$3.moveLocal(t, local.x, local.y, transition);
|
|
4157
4172
|
},
|
|
4158
|
-
moveLocal(t, x, y = 0) {
|
|
4159
|
-
if (typeof x === 'object')
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
t.x += x;
|
|
4165
|
-
t.y += y;
|
|
4166
|
-
}
|
|
4173
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4174
|
+
if (typeof x === 'object')
|
|
4175
|
+
y = x.y, x = x.x;
|
|
4176
|
+
x += t.x;
|
|
4177
|
+
y += t.y;
|
|
4178
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4167
4179
|
},
|
|
4168
4180
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4169
4181
|
L$3.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5212,13 +5224,14 @@ const BranchRender = {
|
|
|
5212
5224
|
this.__.__checkSingle();
|
|
5213
5225
|
},
|
|
5214
5226
|
__render(canvas, options) {
|
|
5227
|
+
this.__nowWorld = this.__getNowWorld(options);
|
|
5215
5228
|
if (this.__worldOpacity) {
|
|
5216
5229
|
if (this.__.__single) {
|
|
5217
5230
|
if (this.__.eraser === 'path')
|
|
5218
5231
|
return this.__renderEraser(canvas, options);
|
|
5219
5232
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5220
5233
|
this.__renderBranch(tempCanvas, options);
|
|
5221
|
-
const nowWorld = this.
|
|
5234
|
+
const nowWorld = this.__nowWorld;
|
|
5222
5235
|
canvas.opacity = this.__.opacity;
|
|
5223
5236
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
|
|
5224
5237
|
tempCanvas.recycle(nowWorld);
|
|
@@ -5542,11 +5555,11 @@ let Leaf = class Leaf {
|
|
|
5542
5555
|
transform(matrix, resize) {
|
|
5543
5556
|
transform(this, matrix, resize);
|
|
5544
5557
|
}
|
|
5545
|
-
move(x, y) {
|
|
5546
|
-
moveLocal(this, x, y);
|
|
5558
|
+
move(x, y, transition) {
|
|
5559
|
+
moveLocal(this, x, y, transition);
|
|
5547
5560
|
}
|
|
5548
|
-
moveInner(x, y) {
|
|
5549
|
-
moveWorld(this, x, y, true);
|
|
5561
|
+
moveInner(x, y, transition) {
|
|
5562
|
+
moveWorld(this, x, y, true, transition);
|
|
5550
5563
|
}
|
|
5551
5564
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5552
5565
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5560,8 +5573,8 @@ let Leaf = class Leaf {
|
|
|
5560
5573
|
transformWorld(worldTransform, resize) {
|
|
5561
5574
|
transformWorld(this, worldTransform, resize);
|
|
5562
5575
|
}
|
|
5563
|
-
moveWorld(x, y) {
|
|
5564
|
-
moveWorld(this, x, y);
|
|
5576
|
+
moveWorld(x, y, transition) {
|
|
5577
|
+
moveWorld(this, x, y, false, transition);
|
|
5565
5578
|
}
|
|
5566
5579
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5567
5580
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5959,7 +5972,7 @@ class LeafLevelList {
|
|
|
5959
5972
|
}
|
|
5960
5973
|
}
|
|
5961
5974
|
|
|
5962
|
-
const version = "1.0
|
|
5975
|
+
const version = "1.1.0";
|
|
5963
5976
|
|
|
5964
5977
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5965
5978
|
get allowBackgroundColor() { return true; }
|
|
@@ -6428,7 +6441,8 @@ class Renderer {
|
|
|
6428
6441
|
this.totalBounds = new Bounds();
|
|
6429
6442
|
debug$6.log(target.innerName, '--->');
|
|
6430
6443
|
try {
|
|
6431
|
-
target.
|
|
6444
|
+
if (!target.isApp)
|
|
6445
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6432
6446
|
this.emitRender(RenderEvent.START);
|
|
6433
6447
|
this.renderOnce(callback);
|
|
6434
6448
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6982,6 +6996,12 @@ class UIData extends LeafData {
|
|
|
6982
6996
|
return strokeWidth;
|
|
6983
6997
|
}
|
|
6984
6998
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
6999
|
+
get __hasMultiPaint() {
|
|
7000
|
+
const t = this;
|
|
7001
|
+
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
7002
|
+
return true;
|
|
7003
|
+
return t.fill && this.__hasStroke;
|
|
7004
|
+
}
|
|
6985
7005
|
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
6986
7006
|
get __autoWidth() { return !this._width; }
|
|
6987
7007
|
get __autoHeight() { return !this._height; }
|
|
@@ -7351,9 +7371,8 @@ const RectRender = {
|
|
|
7351
7371
|
canvas.strokeRect(half, half, width, height);
|
|
7352
7372
|
canvas.restore();
|
|
7353
7373
|
}
|
|
7354
|
-
else
|
|
7374
|
+
else
|
|
7355
7375
|
canvas.strokeRect(half, half, width, height);
|
|
7356
|
-
}
|
|
7357
7376
|
break;
|
|
7358
7377
|
case 'outside':
|
|
7359
7378
|
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
@@ -7383,11 +7402,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7383
7402
|
super(data);
|
|
7384
7403
|
}
|
|
7385
7404
|
reset(_data) { }
|
|
7386
|
-
set(data,
|
|
7387
|
-
if (
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7405
|
+
set(data, transition) {
|
|
7406
|
+
if (transition) {
|
|
7407
|
+
if (transition === 'temp') {
|
|
7408
|
+
this.lockNormalStyle = true;
|
|
7409
|
+
Object.assign(this, data);
|
|
7410
|
+
this.lockNormalStyle = false;
|
|
7411
|
+
}
|
|
7412
|
+
else
|
|
7413
|
+
this.animate(data, transition);
|
|
7391
7414
|
}
|
|
7392
7415
|
else
|
|
7393
7416
|
Object.assign(this, data);
|
|
@@ -7578,6 +7601,15 @@ __decorate([
|
|
|
7578
7601
|
__decorate([
|
|
7579
7602
|
boundsType(0)
|
|
7580
7603
|
], UI.prototype, "padding", void 0);
|
|
7604
|
+
__decorate([
|
|
7605
|
+
boundsType(false)
|
|
7606
|
+
], UI.prototype, "lockRatio", void 0);
|
|
7607
|
+
__decorate([
|
|
7608
|
+
boundsType()
|
|
7609
|
+
], UI.prototype, "widthRange", void 0);
|
|
7610
|
+
__decorate([
|
|
7611
|
+
boundsType()
|
|
7612
|
+
], UI.prototype, "heightRange", void 0);
|
|
7581
7613
|
__decorate([
|
|
7582
7614
|
dataType(false)
|
|
7583
7615
|
], UI.prototype, "draggable", void 0);
|
|
@@ -7688,17 +7720,17 @@ let Group = class Group extends UI {
|
|
|
7688
7720
|
if (!this.children)
|
|
7689
7721
|
this.children = [];
|
|
7690
7722
|
}
|
|
7691
|
-
set(data,
|
|
7723
|
+
set(data, transition) {
|
|
7692
7724
|
if (data.children) {
|
|
7693
7725
|
const { children } = data;
|
|
7694
7726
|
delete data.children;
|
|
7695
7727
|
this.children ? this.clear() : this.__setBranch();
|
|
7696
|
-
super.set(data,
|
|
7728
|
+
super.set(data, transition);
|
|
7697
7729
|
children.forEach(child => this.add(child));
|
|
7698
7730
|
data.children = children;
|
|
7699
7731
|
}
|
|
7700
7732
|
else
|
|
7701
|
-
super.set(data,
|
|
7733
|
+
super.set(data, transition);
|
|
7702
7734
|
}
|
|
7703
7735
|
toJSON(options) {
|
|
7704
7736
|
const data = super.toJSON(options);
|
|
@@ -7811,8 +7843,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7811
7843
|
}
|
|
7812
7844
|
onInit() { }
|
|
7813
7845
|
initType(_type) { }
|
|
7814
|
-
set(data) {
|
|
7815
|
-
this.waitInit(() => { super.set(data); });
|
|
7846
|
+
set(data, transition) {
|
|
7847
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7816
7848
|
}
|
|
7817
7849
|
start() {
|
|
7818
7850
|
clearTimeout(this.__startTimer);
|
|
@@ -7869,8 +7901,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7869
7901
|
__onResize(event) {
|
|
7870
7902
|
this.emitEvent(event);
|
|
7871
7903
|
DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
|
|
7872
|
-
if (!event.width || !event.height)
|
|
7873
|
-
debug$4.warn('w = 0 or h = 0');
|
|
7874
7904
|
setTimeout(() => { if (this.canvasManager)
|
|
7875
7905
|
this.canvasManager.clearRecycled(); }, 0);
|
|
7876
7906
|
}
|
|
@@ -8195,9 +8225,6 @@ __decorate([
|
|
|
8195
8225
|
__decorate([
|
|
8196
8226
|
dataType(false)
|
|
8197
8227
|
], Box.prototype, "resizeChildren", void 0);
|
|
8198
|
-
__decorate([
|
|
8199
|
-
dataType(false)
|
|
8200
|
-
], Box.prototype, "textBox", void 0);
|
|
8201
8228
|
__decorate([
|
|
8202
8229
|
affectRenderBoundsType('show')
|
|
8203
8230
|
], Box.prototype, "overflow", void 0);
|
|
@@ -8952,19 +8979,13 @@ class UIEvent extends Event {
|
|
|
8952
8979
|
Object.assign(this, params);
|
|
8953
8980
|
}
|
|
8954
8981
|
getBoxPoint(relative) {
|
|
8955
|
-
|
|
8956
|
-
relative = this.current;
|
|
8957
|
-
return relative.getBoxPoint(this);
|
|
8982
|
+
return (relative || this.current).getBoxPoint(this);
|
|
8958
8983
|
}
|
|
8959
8984
|
getInnerPoint(relative) {
|
|
8960
|
-
|
|
8961
|
-
relative = this.current;
|
|
8962
|
-
return relative.getInnerPoint(this);
|
|
8985
|
+
return (relative || this.current).getInnerPoint(this);
|
|
8963
8986
|
}
|
|
8964
8987
|
getLocalPoint(relative) {
|
|
8965
|
-
|
|
8966
|
-
relative = this.current;
|
|
8967
|
-
return relative.getLocalPoint(this);
|
|
8988
|
+
return (relative || this.current).getLocalPoint(this);
|
|
8968
8989
|
}
|
|
8969
8990
|
getPagePoint() {
|
|
8970
8991
|
return this.current.getPagePoint(this);
|
|
@@ -9012,10 +9033,8 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9012
9033
|
this.data = data;
|
|
9013
9034
|
}
|
|
9014
9035
|
static getValidMove(leaf, start, total) {
|
|
9015
|
-
const { draggable, dragBounds
|
|
9016
|
-
|
|
9017
|
-
move.x += start.x - x;
|
|
9018
|
-
move.y += start.y - y;
|
|
9036
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9037
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9019
9038
|
if (dragBounds)
|
|
9020
9039
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9021
9040
|
if (draggable === 'x')
|
|
@@ -9025,8 +9044,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9025
9044
|
return move;
|
|
9026
9045
|
}
|
|
9027
9046
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9028
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9029
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9047
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9030
9048
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9031
9049
|
if (!change)
|
|
9032
9050
|
move = Object.assign({}, move);
|
|
@@ -9078,9 +9096,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9078
9096
|
return this.getLocalMove(relative, true);
|
|
9079
9097
|
}
|
|
9080
9098
|
getPageBounds() {
|
|
9081
|
-
const total = this.getPageTotal();
|
|
9082
|
-
const start = this.getPagePoint();
|
|
9083
|
-
const bounds = {};
|
|
9099
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9084
9100
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9085
9101
|
BoundsHelper.unsign(bounds);
|
|
9086
9102
|
return bounds;
|
|
@@ -9198,7 +9214,8 @@ const debug$3 = Debug.get('LeaferTypeCreator');
|
|
|
9198
9214
|
const LeaferTypeCreator = {
|
|
9199
9215
|
list: {},
|
|
9200
9216
|
register(name, fn) {
|
|
9201
|
-
list$1[name]
|
|
9217
|
+
list$1[name] && debug$3.repeat(name);
|
|
9218
|
+
list$1[name] = fn;
|
|
9202
9219
|
},
|
|
9203
9220
|
run(name, leafer) {
|
|
9204
9221
|
const fn = list$1[name];
|
|
@@ -10467,6 +10484,8 @@ function stroke(stroke, ui, canvas) {
|
|
|
10467
10484
|
case 'center':
|
|
10468
10485
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10469
10486
|
canvas.stroke();
|
|
10487
|
+
if (options.__useArrow)
|
|
10488
|
+
strokeArrow(ui, canvas);
|
|
10470
10489
|
break;
|
|
10471
10490
|
case 'inside':
|
|
10472
10491
|
canvas.save();
|
|
@@ -10504,6 +10523,8 @@ function strokes(strokes, ui, canvas) {
|
|
|
10504
10523
|
case 'center':
|
|
10505
10524
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
10506
10525
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
10526
|
+
if (options.__useArrow)
|
|
10527
|
+
strokeArrow(ui, canvas);
|
|
10507
10528
|
break;
|
|
10508
10529
|
case 'inside':
|
|
10509
10530
|
canvas.save();
|
|
@@ -10529,6 +10550,14 @@ function strokes(strokes, ui, canvas) {
|
|
|
10529
10550
|
}
|
|
10530
10551
|
}
|
|
10531
10552
|
}
|
|
10553
|
+
function strokeArrow(ui, canvas) {
|
|
10554
|
+
if (ui.__.dashPattern) {
|
|
10555
|
+
canvas.beginPath();
|
|
10556
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
10557
|
+
canvas.dashPattern = null;
|
|
10558
|
+
canvas.stroke();
|
|
10559
|
+
}
|
|
10560
|
+
}
|
|
10532
10561
|
|
|
10533
10562
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
10534
10563
|
function shape(ui, current, options) {
|
|
@@ -11214,16 +11243,16 @@ const EffectModule = {
|
|
|
11214
11243
|
|
|
11215
11244
|
const { excludeRenderBounds } = LeafBoundsHelper;
|
|
11216
11245
|
Group.prototype.__renderMask = function (canvas, options) {
|
|
11217
|
-
let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
|
|
11246
|
+
let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
|
|
11218
11247
|
const { children } = this;
|
|
11219
11248
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
11220
|
-
child = children[i];
|
|
11221
|
-
if (
|
|
11249
|
+
child = children[i], mask = child.__.mask;
|
|
11250
|
+
if (mask) {
|
|
11222
11251
|
if (currentMask) {
|
|
11223
11252
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
11224
11253
|
maskCanvas = contentCanvas = null;
|
|
11225
11254
|
}
|
|
11226
|
-
if (
|
|
11255
|
+
if (mask === 'path' || mask === 'clipping-path') {
|
|
11227
11256
|
if (child.opacity < 1) {
|
|
11228
11257
|
currentMask = 'opacity-path';
|
|
11229
11258
|
maskOpacity = child.opacity;
|
|
@@ -11237,14 +11266,14 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
11237
11266
|
child.__clip(contentCanvas || canvas, options);
|
|
11238
11267
|
}
|
|
11239
11268
|
else {
|
|
11240
|
-
currentMask = 'alpha';
|
|
11269
|
+
currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
|
|
11241
11270
|
if (!maskCanvas)
|
|
11242
11271
|
maskCanvas = getCanvas(canvas);
|
|
11243
11272
|
if (!contentCanvas)
|
|
11244
11273
|
contentCanvas = getCanvas(canvas);
|
|
11245
11274
|
child.__render(maskCanvas, options);
|
|
11246
11275
|
}
|
|
11247
|
-
if (
|
|
11276
|
+
if (!(mask === 'clipping' || mask === 'clipping-path'))
|
|
11248
11277
|
continue;
|
|
11249
11278
|
}
|
|
11250
11279
|
if (excludeRenderBounds(child, options))
|
|
@@ -11255,6 +11284,8 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
11255
11284
|
};
|
|
11256
11285
|
function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
|
|
11257
11286
|
switch (maskMode) {
|
|
11287
|
+
case 'grayscale':
|
|
11288
|
+
maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
|
|
11258
11289
|
case 'alpha':
|
|
11259
11290
|
usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
|
|
11260
11291
|
break;
|
|
@@ -11959,15 +11990,12 @@ const canvas = LeaferCanvasBase.prototype;
|
|
|
11959
11990
|
const debug$1 = Debug.get('@leafer-ui/export');
|
|
11960
11991
|
canvas.export = function (filename, options) {
|
|
11961
11992
|
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
11962
|
-
if (filename.includes('.'))
|
|
11993
|
+
if (filename.includes('.'))
|
|
11963
11994
|
return this.saveAs(filename, quality);
|
|
11964
|
-
|
|
11965
|
-
else if (blob) {
|
|
11995
|
+
else if (blob)
|
|
11966
11996
|
return this.toBlob(filename, quality);
|
|
11967
|
-
|
|
11968
|
-
else {
|
|
11997
|
+
else
|
|
11969
11998
|
return this.toDataURL(filename, quality);
|
|
11970
|
-
}
|
|
11971
11999
|
};
|
|
11972
12000
|
canvas.toBlob = function (type, quality) {
|
|
11973
12001
|
return new Promise((resolve) => {
|
|
@@ -13009,7 +13037,7 @@ class EditBox extends Group {
|
|
|
13009
13037
|
}
|
|
13010
13038
|
getPointStyle(userStyle) {
|
|
13011
13039
|
const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.editor.mergeConfig;
|
|
13012
|
-
const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius };
|
|
13040
|
+
const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0 };
|
|
13013
13041
|
return userStyle ? Object.assign(defaultStyle, userStyle) : defaultStyle;
|
|
13014
13042
|
}
|
|
13015
13043
|
getPointsStyle() {
|
|
@@ -13091,9 +13119,10 @@ class EditBox extends Group {
|
|
|
13091
13119
|
const { editor } = this;
|
|
13092
13120
|
if (editor.single) {
|
|
13093
13121
|
const { element } = editor;
|
|
13094
|
-
if (element.isBranch) {
|
|
13122
|
+
if (element.isBranch && !element.editInner) {
|
|
13095
13123
|
if (element.textBox) {
|
|
13096
|
-
const
|
|
13124
|
+
const { children } = element;
|
|
13125
|
+
const find = children.find(item => item.editable && item instanceof Text) || children.find(item => item instanceof Text);
|
|
13097
13126
|
if (find)
|
|
13098
13127
|
return editor.openInnerEditor(find);
|
|
13099
13128
|
}
|
|
@@ -13353,7 +13382,8 @@ const EditToolCreator = {
|
|
|
13353
13382
|
list: {},
|
|
13354
13383
|
register(EditTool) {
|
|
13355
13384
|
const { tag } = EditTool.prototype;
|
|
13356
|
-
list[tag]
|
|
13385
|
+
list[tag] && debug.repeat(tag);
|
|
13386
|
+
list[tag] = EditTool;
|
|
13357
13387
|
},
|
|
13358
13388
|
get(tag, editor) {
|
|
13359
13389
|
return new list[tag](editor);
|
|
@@ -14047,12 +14077,16 @@ LineEditTool = __decorate([
|
|
|
14047
14077
|
], LineEditTool);
|
|
14048
14078
|
|
|
14049
14079
|
Creator.editor = function (options) { return new Editor(options); };
|
|
14080
|
+
dataType(false)(Box.prototype, 'textBox');
|
|
14050
14081
|
defineKey(UI.prototype, 'editOuter', {
|
|
14051
14082
|
get() { return this.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }
|
|
14052
14083
|
});
|
|
14053
14084
|
defineKey(UI.prototype, 'editInner', {
|
|
14054
14085
|
get() { return 'PathEditor'; }
|
|
14055
14086
|
});
|
|
14087
|
+
defineKey(Group.prototype, 'editInner', {
|
|
14088
|
+
get() { return ''; }
|
|
14089
|
+
});
|
|
14056
14090
|
defineKey(Text.prototype, 'editInner', {
|
|
14057
14091
|
get() { return 'TextEditor'; }
|
|
14058
14092
|
});
|
|
@@ -14349,13 +14383,13 @@ const half = { x: -0.5 };
|
|
|
14349
14383
|
const angle = { connect: half, offset: { x: -0.71, bevelJoin: 0.36, roundJoin: 0.22 }, path: [1, -3, -3, 2, 0, 0, 2, -3, 3] };
|
|
14350
14384
|
const angleSide = { connect: half, offset: { x: -1.207, bevelJoin: 0.854, roundJoin: 0.707 }, path: [1, -3, -3, 2, 0, 0, 2, -1, 0] };
|
|
14351
14385
|
const triangleLinePath = [1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0];
|
|
14352
|
-
const triangle = { connect: half, offset: { x: -0.9, bevelJoin: 0.624, roundJoin: 0.4 }, path: [...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1] };
|
|
14386
|
+
const triangle = { connect: half, offset: { x: -0.9, bevelJoin: 0.624, roundJoin: 0.4 }, path: [...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1], dashPath: [1, -2, 0, 2, -0.5, 0] };
|
|
14353
14387
|
const arrowLinePath = [1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0];
|
|
14354
|
-
const arrow = { connect: half, offset: { x: -1.1, bevelJoin: 0.872, roundJoin: 0.6 }, path: [...arrowLinePath, 1, -2.25, 0.95, 2, -2.25, -0.95] };
|
|
14355
|
-
const triangleFlip = { offset: half, path: [...triangle.path], };
|
|
14388
|
+
const arrow = { connect: half, offset: { x: -1.1, bevelJoin: 0.872, roundJoin: 0.6 }, path: [...arrowLinePath, 1, -2.25, 0.95, 2, -2.25, -0.95], dashPath: [1, -3, 0, 2, -0.5, 0] };
|
|
14389
|
+
const triangleFlip = { offset: half, path: [...triangle.path], dashPath: [1, -2.5, 0, 2, -1, 0] };
|
|
14356
14390
|
rotate(triangleFlip.path, 180, { x: -1.5, y: 0 });
|
|
14357
14391
|
const circleLine = { connect: { x: -1.3 }, path: [1, 1.8, -0.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0], };
|
|
14358
|
-
const circle = { connect: { x: 0.5 }, path: [...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0] };
|
|
14392
|
+
const circle = { connect: { x: 0.5 }, path: [...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0], dashPath: [1, -0.5, 0, 2, 0.5, 0] };
|
|
14359
14393
|
const squareLine = { connect: { x: -1.3 }, path: [1, -1.4, 0, 2, -1.4, -1.4, 2, 1.4, -1.4, 2, 1.4, 1.4, 2, -1.4, 1.4, 2, -1.4, 0] };
|
|
14360
14394
|
const square = { path: [...squareLine.path, 2, -1.4, -0.49, 2, 1, -0.49, 1, -1.4, 0.49, 2, 1, 0.49] };
|
|
14361
14395
|
const diamondLine = DataHelper.clone(squareLine);
|
|
@@ -14377,12 +14411,14 @@ const arrows = {
|
|
|
14377
14411
|
'diamond-line': diamondLine,
|
|
14378
14412
|
mark,
|
|
14379
14413
|
};
|
|
14380
|
-
function getArrowPath(ui, arrow, from, to, scale, connectOffset) {
|
|
14414
|
+
function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
|
|
14381
14415
|
const { strokeCap, strokeJoin } = ui.__;
|
|
14382
|
-
const { offset, connect, path } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
|
|
14416
|
+
const { offset, connect, path, dashPath } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
|
|
14383
14417
|
let connectX = connect ? connect.x : 0;
|
|
14384
14418
|
let offsetX = offset ? offset.x : 0;
|
|
14385
14419
|
const data = [...path];
|
|
14420
|
+
if (hasDashPattern && dashPath)
|
|
14421
|
+
data.push(...dashPath);
|
|
14386
14422
|
if (strokeCap !== 'none')
|
|
14387
14423
|
connectX -= 0.5;
|
|
14388
14424
|
if (offset) {
|
|
@@ -14406,7 +14442,7 @@ const last = {}, now = {};
|
|
|
14406
14442
|
const PathArrowModule = {
|
|
14407
14443
|
list: arrows,
|
|
14408
14444
|
addArrows(ui, changeRenderPath) {
|
|
14409
|
-
const { startArrow, endArrow, strokeWidth, __pathForRender: data } = ui.__;
|
|
14445
|
+
const { startArrow, endArrow, strokeWidth, dashPattern, __pathForRender: data } = ui.__;
|
|
14410
14446
|
let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== 'none';
|
|
14411
14447
|
while (i < len) {
|
|
14412
14448
|
command = data[i];
|
|
@@ -14465,17 +14501,20 @@ const PathArrowModule = {
|
|
|
14465
14501
|
if (count === 2 && useStartArrow)
|
|
14466
14502
|
copy(second, command === L ? now : last);
|
|
14467
14503
|
if (i === len) {
|
|
14468
|
-
const
|
|
14504
|
+
const path = ui.__.__pathForRender = changeRenderPath ? [...data] : data;
|
|
14505
|
+
const pathForArrow = ui.__.__pathForArrow = [];
|
|
14469
14506
|
if (useStartArrow) {
|
|
14470
|
-
|
|
14507
|
+
const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
|
|
14508
|
+
dashPattern ? pathForArrow.push(...startArrowPath) : path.push(...startArrowPath);
|
|
14471
14509
|
if (connectPoint.x) {
|
|
14472
14510
|
getDistancePoint(first, second, -connectPoint.x, true);
|
|
14473
|
-
|
|
14474
|
-
|
|
14511
|
+
path[1] = second.x;
|
|
14512
|
+
path[2] = second.y;
|
|
14475
14513
|
}
|
|
14476
14514
|
}
|
|
14477
14515
|
if (endArrow && endArrow !== 'none') {
|
|
14478
|
-
|
|
14516
|
+
const endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
|
|
14517
|
+
dashPattern ? pathForArrow.push(...endArrowPath) : path.push(...endArrowPath);
|
|
14479
14518
|
if (connectPoint.x) {
|
|
14480
14519
|
getDistancePoint(now, last, -connectPoint.x, true);
|
|
14481
14520
|
let index;
|
|
@@ -14494,7 +14533,7 @@ const PathArrowModule = {
|
|
|
14494
14533
|
break;
|
|
14495
14534
|
}
|
|
14496
14535
|
if (index)
|
|
14497
|
-
setPoint(
|
|
14536
|
+
setPoint(path, last, index);
|
|
14498
14537
|
}
|
|
14499
14538
|
}
|
|
14500
14539
|
}
|
|
@@ -14619,7 +14658,7 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14619
14658
|
style.position = 'fixed';
|
|
14620
14659
|
style.transformOrigin = 'left top';
|
|
14621
14660
|
style.boxSizing = 'border-box';
|
|
14622
|
-
this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
|
|
14661
|
+
this.isHTMLText ? div.innerHTML = String(text.text) : div.innerText = String(text.text);
|
|
14623
14662
|
const { view } = editor.app;
|
|
14624
14663
|
(this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
|
|
14625
14664
|
this.eventIds = [
|
|
@@ -14680,8 +14719,10 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14680
14719
|
this.textScale = textScale;
|
|
14681
14720
|
const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
|
|
14682
14721
|
let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14722
|
+
if (!this.inBody)
|
|
14723
|
+
x -= window.scrollX, y -= window.scrollY;
|
|
14683
14724
|
let { width, height } = text;
|
|
14684
|
-
|
|
14725
|
+
width *= textScale, height *= textScale;
|
|
14685
14726
|
const data = text.__;
|
|
14686
14727
|
if (data.__autoWidth && data.autoSizeAlign) {
|
|
14687
14728
|
width += 20;
|