@meta2d/core 1.0.87 → 1.0.88
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 +35 -22
- 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.js +9 -1
- package/src/core.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 +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +51 -20
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +3 -3
- package/src/pen/text.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.js
CHANGED
|
@@ -369,6 +369,12 @@ export class Canvas {
|
|
|
369
369
|
}
|
|
370
370
|
let data = JSON.parse(e.data);
|
|
371
371
|
if (typeof data === 'object') {
|
|
372
|
+
if (data.name === 'onload') {
|
|
373
|
+
this.dialog.iframe.contentWindow.postMessage(JSON.stringify({
|
|
374
|
+
name: 'dialog',
|
|
375
|
+
data: this.dialog.data
|
|
376
|
+
}), '*');
|
|
377
|
+
}
|
|
372
378
|
this.parent.doMessageEvent(data.name, JSON.stringify(data.data));
|
|
373
379
|
}
|
|
374
380
|
else {
|
|
@@ -2631,15 +2637,16 @@ export class Canvas {
|
|
|
2631
2637
|
pen.calculative.hover = false;
|
|
2632
2638
|
setChildrenActive(pen, false);
|
|
2633
2639
|
});
|
|
2634
|
-
|
|
2640
|
+
const activePens = [...this.store.active];
|
|
2635
2641
|
this.store.active = [];
|
|
2636
2642
|
this.activeRect = undefined;
|
|
2637
2643
|
this.sizeCPs = undefined;
|
|
2638
2644
|
this.store.activeAnchor = undefined;
|
|
2639
2645
|
this.patchFlags = true;
|
|
2646
|
+
!drawing && this.store.emitter.emit('inactive', activePens);
|
|
2640
2647
|
}
|
|
2641
2648
|
active(pens, emit = true) {
|
|
2642
|
-
if (this.store.active) {
|
|
2649
|
+
if (this.store.active && this.store.active.length) {
|
|
2643
2650
|
emit && this.store.emitter.emit('inactive', this.store.active);
|
|
2644
2651
|
for (const pen of this.store.active) {
|
|
2645
2652
|
pen.calculative.active = undefined;
|
|
@@ -4082,22 +4089,24 @@ export class Canvas {
|
|
|
4082
4089
|
});
|
|
4083
4090
|
}
|
|
4084
4091
|
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;
|
|
4091
|
-
}
|
|
4092
|
-
if (pen.calculative.gradient) {
|
|
4093
|
-
pen.calculative.gradient = null;
|
|
4094
|
-
}
|
|
4095
|
-
if (pen.calculative.radialGradient) {
|
|
4096
|
-
pen.calculative.radialGradient = null;
|
|
4092
|
+
if (pen.gradientColors || pen.lineGradientColors) {
|
|
4093
|
+
if (pen.calculative.gradientTimer) {
|
|
4094
|
+
clearTimeout(pen.calculative.gradientTimer);
|
|
4097
4095
|
}
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4096
|
+
pen.calculative.gradientTimer = setTimeout(() => {
|
|
4097
|
+
if (pen.calculative.lineGradient) {
|
|
4098
|
+
pen.calculative.lineGradient = null;
|
|
4099
|
+
}
|
|
4100
|
+
if (pen.calculative.gradient) {
|
|
4101
|
+
pen.calculative.gradient = null;
|
|
4102
|
+
}
|
|
4103
|
+
if (pen.calculative.radialGradient) {
|
|
4104
|
+
pen.calculative.radialGradient = null;
|
|
4105
|
+
}
|
|
4106
|
+
this.patchFlags = true;
|
|
4107
|
+
pen.calculative.gradientTimer = undefined;
|
|
4108
|
+
}, 50);
|
|
4109
|
+
}
|
|
4101
4110
|
}
|
|
4102
4111
|
initGlobalStyle() {
|
|
4103
4112
|
if (this.store.options.themeOnlyCanvas || this.store.data.themeOnlyCanvas) {
|
|
@@ -4107,15 +4116,16 @@ export class Canvas {
|
|
|
4107
4116
|
const data = {};
|
|
4108
4117
|
const theme = {};
|
|
4109
4118
|
themeKeys.forEach(key => {
|
|
4110
|
-
|
|
4119
|
+
// 过滤调 null undefined ''
|
|
4120
|
+
if (this.store.options[key] != null && this.store.options[key] !== '') {
|
|
4111
4121
|
options[key] = this.store.options[key];
|
|
4112
4122
|
}
|
|
4113
|
-
if (this.store.data[key] !==
|
|
4123
|
+
if (this.store.data[key] != null && this.store.data[key] !== '') {
|
|
4114
4124
|
data[key] = this.store.data[key];
|
|
4115
4125
|
}
|
|
4116
4126
|
if (this.store.data.theme) {
|
|
4117
4127
|
const value = this.store.theme[this.store.data.theme]?.[key];
|
|
4118
|
-
if (value !==
|
|
4128
|
+
if (value != null && value !== '') {
|
|
4119
4129
|
theme[key] = value;
|
|
4120
4130
|
}
|
|
4121
4131
|
}
|
|
@@ -4196,7 +4206,7 @@ export class Canvas {
|
|
|
4196
4206
|
pen.calculative.img) {
|
|
4197
4207
|
ctx.save();
|
|
4198
4208
|
ctxFlip(ctx, pen);
|
|
4199
|
-
if (pen.calculative.rotate) {
|
|
4209
|
+
if (pen.rotateByRoot || pen.calculative.rotate) {
|
|
4200
4210
|
ctxRotate(ctx, pen);
|
|
4201
4211
|
}
|
|
4202
4212
|
setGlobalAlpha(ctx, pen);
|
|
@@ -5555,7 +5565,10 @@ export class Canvas {
|
|
|
5555
5565
|
* @param angle 本次的旋转值,加到 pen.calculative.rotate 上
|
|
5556
5566
|
*/
|
|
5557
5567
|
rotatePen(pen, angle, rect) {
|
|
5558
|
-
if (pen.
|
|
5568
|
+
if (pen.rotateByRoot) {
|
|
5569
|
+
return;
|
|
5570
|
+
}
|
|
5571
|
+
if (pen.name === 'line') {
|
|
5559
5572
|
pen.calculative.worldAnchors.forEach((anchor) => {
|
|
5560
5573
|
rotatePoint(anchor, angle, rect.center);
|
|
5561
5574
|
});
|