@meta2d/core 1.0.87 → 1.0.89
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/package.json +1 -1
- package/src/canvas/canvas.js +83 -49
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.js +3 -3
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/canvas/canvasTemplate.js +1 -1
- package/src/canvas/canvasTemplate.js.map +1 -1
- package/src/core.d.ts +1 -0
- package/src/core.js +96 -20
- package/src/core.js.map +1 -1
- package/src/diagrams/iframe.js +13 -4
- package/src/diagrams/iframe.js.map +1 -1
- package/src/dialog/dialog.d.ts +1 -0
- package/src/dialog/dialog.js +45 -20
- package/src/dialog/dialog.js.map +1 -1
- package/src/pen/model.d.ts +2 -1
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +97 -39
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +38 -27
- package/src/pen/text.js.map +1 -1
- package/src/scroll/scroll.d.ts +4 -1
- package/src/scroll/scroll.js +81 -8
- package/src/scroll/scroll.js.map +1 -1
- package/src/utils/time.js +2 -1
- package/src/utils/time.js.map +1 -1
- package/src/utils/tool.d.ts +1 -0
- package/src/utils/tool.js +4 -0
- package/src/utils/tool.js.map +1 -0
- package/src/utils/url.d.ts +1 -1
- package/src/utils/url.js +36 -4
- package/src/utils/url.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.js
CHANGED
|
@@ -15,6 +15,7 @@ import { MagnifierCanvas } from './magnifierCanvas';
|
|
|
15
15
|
import { lockedError } from '../utils/error';
|
|
16
16
|
import { Dialog } from '../dialog';
|
|
17
17
|
import { setter } from '../utils/object';
|
|
18
|
+
import { isNumber } from '../utils/tool';
|
|
18
19
|
import { Title } from '../title';
|
|
19
20
|
import { CanvasTemplate } from './canvasTemplate';
|
|
20
21
|
import { getLinePoints } from '../diagrams/line';
|
|
@@ -369,6 +370,12 @@ export class Canvas {
|
|
|
369
370
|
}
|
|
370
371
|
let data = JSON.parse(e.data);
|
|
371
372
|
if (typeof data === 'object') {
|
|
373
|
+
if (data.name === 'onload') {
|
|
374
|
+
this.dialog.iframe.contentWindow.postMessage(JSON.stringify({
|
|
375
|
+
name: 'dialog',
|
|
376
|
+
data: this.dialog.data
|
|
377
|
+
}), '*');
|
|
378
|
+
}
|
|
372
379
|
this.parent.doMessageEvent(data.name, JSON.stringify(data.data));
|
|
373
380
|
}
|
|
374
381
|
else {
|
|
@@ -2631,15 +2638,16 @@ export class Canvas {
|
|
|
2631
2638
|
pen.calculative.hover = false;
|
|
2632
2639
|
setChildrenActive(pen, false);
|
|
2633
2640
|
});
|
|
2634
|
-
|
|
2641
|
+
const activePens = [...this.store.active];
|
|
2635
2642
|
this.store.active = [];
|
|
2636
2643
|
this.activeRect = undefined;
|
|
2637
2644
|
this.sizeCPs = undefined;
|
|
2638
2645
|
this.store.activeAnchor = undefined;
|
|
2639
2646
|
this.patchFlags = true;
|
|
2647
|
+
!drawing && this.store.emitter.emit('inactive', activePens);
|
|
2640
2648
|
}
|
|
2641
2649
|
active(pens, emit = true) {
|
|
2642
|
-
if (this.store.active) {
|
|
2650
|
+
if (this.store.active && this.store.active.length) {
|
|
2643
2651
|
emit && this.store.emitter.emit('inactive', this.store.active);
|
|
2644
2652
|
for (const pen of this.store.active) {
|
|
2645
2653
|
pen.calculative.active = undefined;
|
|
@@ -4030,31 +4038,51 @@ export class Canvas {
|
|
|
4030
4038
|
pen.calculative.fontSize =
|
|
4031
4039
|
pen.fontSize * pen.calculative.worldRect.height;
|
|
4032
4040
|
}
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
pen.
|
|
4037
|
-
pen.
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
pen.
|
|
4043
|
-
pen.
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4041
|
+
if (isNumber(pen.iconSize)) {
|
|
4042
|
+
pen.calculative.iconSize = pen.iconSize * scale;
|
|
4043
|
+
}
|
|
4044
|
+
if (isNumber(pen.iconWidth)) {
|
|
4045
|
+
pen.calculative.iconWidth = pen.iconWidth * scale;
|
|
4046
|
+
}
|
|
4047
|
+
if (isNumber(pen.iconHeight)) {
|
|
4048
|
+
pen.calculative.iconHeight = pen.iconHeight * scale;
|
|
4049
|
+
}
|
|
4050
|
+
if (isNumber(pen.iconLeft)) {
|
|
4051
|
+
pen.calculative.iconLeft =
|
|
4052
|
+
pen.iconLeft < 1 && pen.iconLeft > -1
|
|
4053
|
+
? pen.iconLeft
|
|
4054
|
+
: pen.iconLeft * scale;
|
|
4055
|
+
}
|
|
4056
|
+
if (isNumber(pen.iconTop)) {
|
|
4057
|
+
pen.calculative.iconTop =
|
|
4058
|
+
pen.iconTop < 1 && pen.iconTop > -1 ? pen.iconTop : pen.iconTop * scale;
|
|
4059
|
+
}
|
|
4060
|
+
if (isNumber(pen.textWidth)) {
|
|
4061
|
+
pen.calculative.textWidth =
|
|
4062
|
+
pen.textWidth < 1 && pen.textWidth > -1
|
|
4063
|
+
? pen.textWidth
|
|
4064
|
+
: pen.textWidth * scale;
|
|
4065
|
+
}
|
|
4066
|
+
if (isNumber(pen.textHeight)) {
|
|
4067
|
+
pen.calculative.textHeight =
|
|
4068
|
+
pen.textHeight < 1 && pen.textHeight > -1
|
|
4069
|
+
? pen.textHeight
|
|
4070
|
+
: pen.textHeight * scale;
|
|
4071
|
+
}
|
|
4072
|
+
if (isNumber(pen.textLeft)) {
|
|
4073
|
+
pen.calculative.textLeft =
|
|
4074
|
+
pen.textLeft < 1 && pen.textLeft > -1
|
|
4075
|
+
? pen.textLeft * pen.calculative.worldRect.width
|
|
4076
|
+
: pen.textLeft * scale;
|
|
4077
|
+
}
|
|
4078
|
+
if (isNumber(pen.textTop)) {
|
|
4079
|
+
pen.calculative.textTop =
|
|
4080
|
+
pen.textTop < 1 && pen.textTop > -1 ? pen.textTop * pen.calculative.worldRect.height : pen.textTop * scale;
|
|
4081
|
+
}
|
|
4082
|
+
if (isNumber(pen.borderWidth)) {
|
|
4083
|
+
if (pen.type === PenType.Line && pen.borderWidth) {
|
|
4084
|
+
pen.calculative.borderWidth = pen.borderWidth * scale;
|
|
4085
|
+
}
|
|
4058
4086
|
}
|
|
4059
4087
|
}
|
|
4060
4088
|
updatePenRect(pen, { worldRectIsReady, playingAnimate, } = {}) {
|
|
@@ -4082,22 +4110,24 @@ export class Canvas {
|
|
|
4082
4110
|
});
|
|
4083
4111
|
}
|
|
4084
4112
|
pen.type && this.initLineRect(pen);
|
|
4085
|
-
if (pen.
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
pen.calculative.gradientTimer = setTimeout(() => {
|
|
4089
|
-
if (pen.calculative.lineGradient) {
|
|
4090
|
-
pen.calculative.lineGradient = null;
|
|
4113
|
+
if (pen.gradientColors || pen.lineGradientColors) {
|
|
4114
|
+
if (pen.calculative.gradientTimer) {
|
|
4115
|
+
clearTimeout(pen.calculative.gradientTimer);
|
|
4091
4116
|
}
|
|
4092
|
-
|
|
4093
|
-
pen.calculative.
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
pen.calculative.
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4117
|
+
pen.calculative.gradientTimer = setTimeout(() => {
|
|
4118
|
+
if (pen.calculative.lineGradient) {
|
|
4119
|
+
pen.calculative.lineGradient = null;
|
|
4120
|
+
}
|
|
4121
|
+
if (pen.calculative.gradient) {
|
|
4122
|
+
pen.calculative.gradient = null;
|
|
4123
|
+
}
|
|
4124
|
+
if (pen.calculative.radialGradient) {
|
|
4125
|
+
pen.calculative.radialGradient = null;
|
|
4126
|
+
}
|
|
4127
|
+
this.patchFlags = true;
|
|
4128
|
+
pen.calculative.gradientTimer = undefined;
|
|
4129
|
+
}, 50);
|
|
4130
|
+
}
|
|
4101
4131
|
}
|
|
4102
4132
|
initGlobalStyle() {
|
|
4103
4133
|
if (this.store.options.themeOnlyCanvas || this.store.data.themeOnlyCanvas) {
|
|
@@ -4107,15 +4137,16 @@ export class Canvas {
|
|
|
4107
4137
|
const data = {};
|
|
4108
4138
|
const theme = {};
|
|
4109
4139
|
themeKeys.forEach(key => {
|
|
4110
|
-
|
|
4140
|
+
// 过滤调 null undefined ''
|
|
4141
|
+
if (this.store.options[key] != null && this.store.options[key] !== '') {
|
|
4111
4142
|
options[key] = this.store.options[key];
|
|
4112
4143
|
}
|
|
4113
|
-
if (this.store.data[key] !==
|
|
4144
|
+
if (this.store.data[key] != null && this.store.data[key] !== '') {
|
|
4114
4145
|
data[key] = this.store.data[key];
|
|
4115
4146
|
}
|
|
4116
4147
|
if (this.store.data.theme) {
|
|
4117
4148
|
const value = this.store.theme[this.store.data.theme]?.[key];
|
|
4118
|
-
if (value !==
|
|
4149
|
+
if (value != null && value !== '') {
|
|
4119
4150
|
theme[key] = value;
|
|
4120
4151
|
}
|
|
4121
4152
|
}
|
|
@@ -4196,7 +4227,7 @@ export class Canvas {
|
|
|
4196
4227
|
pen.calculative.img) {
|
|
4197
4228
|
ctx.save();
|
|
4198
4229
|
ctxFlip(ctx, pen);
|
|
4199
|
-
if (pen.calculative.rotate) {
|
|
4230
|
+
if (pen.rotateByRoot || pen.calculative.rotate) {
|
|
4200
4231
|
ctxRotate(ctx, pen);
|
|
4201
4232
|
}
|
|
4202
4233
|
setGlobalAlpha(ctx, pen);
|
|
@@ -5555,7 +5586,10 @@ export class Canvas {
|
|
|
5555
5586
|
* @param angle 本次的旋转值,加到 pen.calculative.rotate 上
|
|
5556
5587
|
*/
|
|
5557
5588
|
rotatePen(pen, angle, rect) {
|
|
5558
|
-
if (pen.
|
|
5589
|
+
if (pen.rotateByRoot) {
|
|
5590
|
+
return;
|
|
5591
|
+
}
|
|
5592
|
+
if (pen.name === 'line') {
|
|
5559
5593
|
pen.calculative.worldAnchors.forEach((anchor) => {
|
|
5560
5594
|
rotatePoint(anchor, angle, rect.center);
|
|
5561
5595
|
});
|
|
@@ -6583,7 +6617,7 @@ export class Canvas {
|
|
|
6583
6617
|
this.store.emitter.emit('change', pen);
|
|
6584
6618
|
this.store.emitter.emit('valueUpdate', pen);
|
|
6585
6619
|
}
|
|
6586
|
-
else if (pen.text === this.inputDiv.dataset.value && pen.calculative.textLines.length == 0) {
|
|
6620
|
+
else if (pen.text === this.inputDiv.dataset.value && pen.calculative.textLines && pen.calculative.textLines.length == 0) {
|
|
6587
6621
|
calcTextRect(pen);
|
|
6588
6622
|
}
|
|
6589
6623
|
this.initTemplateCanvas([pen]);
|
|
@@ -7005,7 +7039,7 @@ export class Canvas {
|
|
|
7005
7039
|
this.updatePenRect(pen);
|
|
7006
7040
|
}
|
|
7007
7041
|
else {
|
|
7008
|
-
willCalcTextRect && calcTextRect(pen);
|
|
7042
|
+
!pen.hiddenText && willCalcTextRect && calcTextRect(pen);
|
|
7009
7043
|
willCalcIconRect && calcIconRect(this.store.pens, pen);
|
|
7010
7044
|
if (willUpdatePath) {
|
|
7011
7045
|
globalStore.path2dDraws[pen.name] &&
|