@leafer-editor/worker 1.0.10 → 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 +65 -52
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +65 -52
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.js
CHANGED
|
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
|
|
|
111
111
|
return rotation - oldRotation;
|
|
112
112
|
},
|
|
113
113
|
float(num, maxLength) {
|
|
114
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
114
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
117
|
},
|
|
@@ -4168,20 +4168,17 @@ var LeaferUI = (function (exports) {
|
|
|
4168
4168
|
}
|
|
4169
4169
|
return true;
|
|
4170
4170
|
},
|
|
4171
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4171
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4172
4172
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4173
4173
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4174
|
-
L$3.moveLocal(t, local.x, local.y);
|
|
4174
|
+
L$3.moveLocal(t, local.x, local.y, transition);
|
|
4175
4175
|
},
|
|
4176
|
-
moveLocal(t, x, y = 0) {
|
|
4177
|
-
if (typeof x === 'object')
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
t.x += x;
|
|
4183
|
-
t.y += y;
|
|
4184
|
-
}
|
|
4176
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4177
|
+
if (typeof x === 'object')
|
|
4178
|
+
y = x.y, x = x.x;
|
|
4179
|
+
x += t.x;
|
|
4180
|
+
y += t.y;
|
|
4181
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4185
4182
|
},
|
|
4186
4183
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4187
4184
|
L$3.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5561,11 +5558,11 @@ var LeaferUI = (function (exports) {
|
|
|
5561
5558
|
transform(matrix, resize) {
|
|
5562
5559
|
transform(this, matrix, resize);
|
|
5563
5560
|
}
|
|
5564
|
-
move(x, y) {
|
|
5565
|
-
moveLocal(this, x, y);
|
|
5561
|
+
move(x, y, transition) {
|
|
5562
|
+
moveLocal(this, x, y, transition);
|
|
5566
5563
|
}
|
|
5567
|
-
moveInner(x, y) {
|
|
5568
|
-
moveWorld(this, x, y, true);
|
|
5564
|
+
moveInner(x, y, transition) {
|
|
5565
|
+
moveWorld(this, x, y, true, transition);
|
|
5569
5566
|
}
|
|
5570
5567
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5571
5568
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5579,8 +5576,8 @@ var LeaferUI = (function (exports) {
|
|
|
5579
5576
|
transformWorld(worldTransform, resize) {
|
|
5580
5577
|
transformWorld(this, worldTransform, resize);
|
|
5581
5578
|
}
|
|
5582
|
-
moveWorld(x, y) {
|
|
5583
|
-
moveWorld(this, x, y);
|
|
5579
|
+
moveWorld(x, y, transition) {
|
|
5580
|
+
moveWorld(this, x, y, false, transition);
|
|
5584
5581
|
}
|
|
5585
5582
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5586
5583
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5978,7 +5975,7 @@ var LeaferUI = (function (exports) {
|
|
|
5978
5975
|
}
|
|
5979
5976
|
}
|
|
5980
5977
|
|
|
5981
|
-
const version = "1.0
|
|
5978
|
+
const version = "1.1.0";
|
|
5982
5979
|
|
|
5983
5980
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5984
5981
|
get allowBackgroundColor() { return true; }
|
|
@@ -7408,11 +7405,15 @@ var LeaferUI = (function (exports) {
|
|
|
7408
7405
|
super(data);
|
|
7409
7406
|
}
|
|
7410
7407
|
reset(_data) { }
|
|
7411
|
-
set(data,
|
|
7412
|
-
if (
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7408
|
+
set(data, transition) {
|
|
7409
|
+
if (transition) {
|
|
7410
|
+
if (transition === 'temp') {
|
|
7411
|
+
this.lockNormalStyle = true;
|
|
7412
|
+
Object.assign(this, data);
|
|
7413
|
+
this.lockNormalStyle = false;
|
|
7414
|
+
}
|
|
7415
|
+
else
|
|
7416
|
+
this.animate(data, transition);
|
|
7416
7417
|
}
|
|
7417
7418
|
else
|
|
7418
7419
|
Object.assign(this, data);
|
|
@@ -7722,17 +7723,17 @@ var LeaferUI = (function (exports) {
|
|
|
7722
7723
|
if (!this.children)
|
|
7723
7724
|
this.children = [];
|
|
7724
7725
|
}
|
|
7725
|
-
set(data,
|
|
7726
|
+
set(data, transition) {
|
|
7726
7727
|
if (data.children) {
|
|
7727
7728
|
const { children } = data;
|
|
7728
7729
|
delete data.children;
|
|
7729
7730
|
this.children ? this.clear() : this.__setBranch();
|
|
7730
|
-
super.set(data,
|
|
7731
|
+
super.set(data, transition);
|
|
7731
7732
|
children.forEach(child => this.add(child));
|
|
7732
7733
|
data.children = children;
|
|
7733
7734
|
}
|
|
7734
7735
|
else
|
|
7735
|
-
super.set(data,
|
|
7736
|
+
super.set(data, transition);
|
|
7736
7737
|
}
|
|
7737
7738
|
toJSON(options) {
|
|
7738
7739
|
const data = super.toJSON(options);
|
|
@@ -7845,8 +7846,8 @@ var LeaferUI = (function (exports) {
|
|
|
7845
7846
|
}
|
|
7846
7847
|
onInit() { }
|
|
7847
7848
|
initType(_type) { }
|
|
7848
|
-
set(data) {
|
|
7849
|
-
this.waitInit(() => { super.set(data); });
|
|
7849
|
+
set(data, transition) {
|
|
7850
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7850
7851
|
}
|
|
7851
7852
|
start() {
|
|
7852
7853
|
clearTimeout(this.__startTimer);
|
|
@@ -9035,10 +9036,8 @@ var LeaferUI = (function (exports) {
|
|
|
9035
9036
|
this.data = data;
|
|
9036
9037
|
}
|
|
9037
9038
|
static getValidMove(leaf, start, total) {
|
|
9038
|
-
const { draggable, dragBounds
|
|
9039
|
-
|
|
9040
|
-
move.x += start.x - x;
|
|
9041
|
-
move.y += start.y - y;
|
|
9039
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9040
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9042
9041
|
if (dragBounds)
|
|
9043
9042
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9044
9043
|
if (draggable === 'x')
|
|
@@ -9048,8 +9047,7 @@ var LeaferUI = (function (exports) {
|
|
|
9048
9047
|
return move;
|
|
9049
9048
|
}
|
|
9050
9049
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9051
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9052
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9050
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9053
9051
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9054
9052
|
if (!change)
|
|
9055
9053
|
move = Object.assign({}, move);
|
|
@@ -9101,9 +9099,7 @@ var LeaferUI = (function (exports) {
|
|
|
9101
9099
|
return this.getLocalMove(relative, true);
|
|
9102
9100
|
}
|
|
9103
9101
|
getPageBounds() {
|
|
9104
|
-
const total = this.getPageTotal();
|
|
9105
|
-
const start = this.getPagePoint();
|
|
9106
|
-
const bounds = {};
|
|
9102
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9107
9103
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9108
9104
|
BoundsHelper.unsign(bounds);
|
|
9109
9105
|
return bounds;
|
|
@@ -10491,6 +10487,8 @@ var LeaferUI = (function (exports) {
|
|
|
10491
10487
|
case 'center':
|
|
10492
10488
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10493
10489
|
canvas.stroke();
|
|
10490
|
+
if (options.__useArrow)
|
|
10491
|
+
strokeArrow(ui, canvas);
|
|
10494
10492
|
break;
|
|
10495
10493
|
case 'inside':
|
|
10496
10494
|
canvas.save();
|
|
@@ -10528,6 +10526,8 @@ var LeaferUI = (function (exports) {
|
|
|
10528
10526
|
case 'center':
|
|
10529
10527
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
10530
10528
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
10529
|
+
if (options.__useArrow)
|
|
10530
|
+
strokeArrow(ui, canvas);
|
|
10531
10531
|
break;
|
|
10532
10532
|
case 'inside':
|
|
10533
10533
|
canvas.save();
|
|
@@ -10553,6 +10553,14 @@ var LeaferUI = (function (exports) {
|
|
|
10553
10553
|
}
|
|
10554
10554
|
}
|
|
10555
10555
|
}
|
|
10556
|
+
function strokeArrow(ui, canvas) {
|
|
10557
|
+
if (ui.__.dashPattern) {
|
|
10558
|
+
canvas.beginPath();
|
|
10559
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
10560
|
+
canvas.dashPattern = null;
|
|
10561
|
+
canvas.stroke();
|
|
10562
|
+
}
|
|
10563
|
+
}
|
|
10556
10564
|
|
|
10557
10565
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
10558
10566
|
function shape(ui, current, options) {
|
|
@@ -14378,13 +14386,13 @@ ${filterStyle}
|
|
|
14378
14386
|
const angle = { connect: half, offset: { x: -0.71, bevelJoin: 0.36, roundJoin: 0.22 }, path: [1, -3, -3, 2, 0, 0, 2, -3, 3] };
|
|
14379
14387
|
const angleSide = { connect: half, offset: { x: -1.207, bevelJoin: 0.854, roundJoin: 0.707 }, path: [1, -3, -3, 2, 0, 0, 2, -1, 0] };
|
|
14380
14388
|
const triangleLinePath = [1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0];
|
|
14381
|
-
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] };
|
|
14389
|
+
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] };
|
|
14382
14390
|
const arrowLinePath = [1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0];
|
|
14383
|
-
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] };
|
|
14384
|
-
const triangleFlip = { offset: half, path: [...triangle.path], };
|
|
14391
|
+
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] };
|
|
14392
|
+
const triangleFlip = { offset: half, path: [...triangle.path], dashPath: [1, -2.5, 0, 2, -1, 0] };
|
|
14385
14393
|
rotate(triangleFlip.path, 180, { x: -1.5, y: 0 });
|
|
14386
14394
|
const circleLine = { connect: { x: -1.3 }, path: [1, 1.8, -0.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0], };
|
|
14387
|
-
const circle = { connect: { x: 0.5 }, path: [...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0] };
|
|
14395
|
+
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] };
|
|
14388
14396
|
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] };
|
|
14389
14397
|
const square = { path: [...squareLine.path, 2, -1.4, -0.49, 2, 1, -0.49, 1, -1.4, 0.49, 2, 1, 0.49] };
|
|
14390
14398
|
const diamondLine = DataHelper.clone(squareLine);
|
|
@@ -14406,12 +14414,14 @@ ${filterStyle}
|
|
|
14406
14414
|
'diamond-line': diamondLine,
|
|
14407
14415
|
mark,
|
|
14408
14416
|
};
|
|
14409
|
-
function getArrowPath(ui, arrow, from, to, scale, connectOffset) {
|
|
14417
|
+
function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
|
|
14410
14418
|
const { strokeCap, strokeJoin } = ui.__;
|
|
14411
|
-
const { offset, connect, path } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
|
|
14419
|
+
const { offset, connect, path, dashPath } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
|
|
14412
14420
|
let connectX = connect ? connect.x : 0;
|
|
14413
14421
|
let offsetX = offset ? offset.x : 0;
|
|
14414
14422
|
const data = [...path];
|
|
14423
|
+
if (hasDashPattern && dashPath)
|
|
14424
|
+
data.push(...dashPath);
|
|
14415
14425
|
if (strokeCap !== 'none')
|
|
14416
14426
|
connectX -= 0.5;
|
|
14417
14427
|
if (offset) {
|
|
@@ -14435,7 +14445,7 @@ ${filterStyle}
|
|
|
14435
14445
|
const PathArrowModule = {
|
|
14436
14446
|
list: arrows,
|
|
14437
14447
|
addArrows(ui, changeRenderPath) {
|
|
14438
|
-
const { startArrow, endArrow, strokeWidth, __pathForRender: data } = ui.__;
|
|
14448
|
+
const { startArrow, endArrow, strokeWidth, dashPattern, __pathForRender: data } = ui.__;
|
|
14439
14449
|
let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== 'none';
|
|
14440
14450
|
while (i < len) {
|
|
14441
14451
|
command = data[i];
|
|
@@ -14494,17 +14504,20 @@ ${filterStyle}
|
|
|
14494
14504
|
if (count === 2 && useStartArrow)
|
|
14495
14505
|
copy(second, command === L ? now : last);
|
|
14496
14506
|
if (i === len) {
|
|
14497
|
-
const
|
|
14507
|
+
const path = ui.__.__pathForRender = changeRenderPath ? [...data] : data;
|
|
14508
|
+
const pathForArrow = ui.__.__pathForArrow = [];
|
|
14498
14509
|
if (useStartArrow) {
|
|
14499
|
-
|
|
14510
|
+
const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
|
|
14511
|
+
dashPattern ? pathForArrow.push(...startArrowPath) : path.push(...startArrowPath);
|
|
14500
14512
|
if (connectPoint.x) {
|
|
14501
14513
|
getDistancePoint(first, second, -connectPoint.x, true);
|
|
14502
|
-
|
|
14503
|
-
|
|
14514
|
+
path[1] = second.x;
|
|
14515
|
+
path[2] = second.y;
|
|
14504
14516
|
}
|
|
14505
14517
|
}
|
|
14506
14518
|
if (endArrow && endArrow !== 'none') {
|
|
14507
|
-
|
|
14519
|
+
const endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
|
|
14520
|
+
dashPattern ? pathForArrow.push(...endArrowPath) : path.push(...endArrowPath);
|
|
14508
14521
|
if (connectPoint.x) {
|
|
14509
14522
|
getDistancePoint(now, last, -connectPoint.x, true);
|
|
14510
14523
|
let index;
|
|
@@ -14523,7 +14536,7 @@ ${filterStyle}
|
|
|
14523
14536
|
break;
|
|
14524
14537
|
}
|
|
14525
14538
|
if (index)
|
|
14526
|
-
setPoint(
|
|
14539
|
+
setPoint(path, last, index);
|
|
14527
14540
|
}
|
|
14528
14541
|
}
|
|
14529
14542
|
}
|
|
@@ -14648,7 +14661,7 @@ ${filterStyle}
|
|
|
14648
14661
|
style.position = 'fixed';
|
|
14649
14662
|
style.transformOrigin = 'left top';
|
|
14650
14663
|
style.boxSizing = 'border-box';
|
|
14651
|
-
this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
|
|
14664
|
+
this.isHTMLText ? div.innerHTML = String(text.text) : div.innerText = String(text.text);
|
|
14652
14665
|
const { view } = editor.app;
|
|
14653
14666
|
(this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
|
|
14654
14667
|
this.eventIds = [
|