@meta2d/core 1.1.4 → 1.1.6
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 +40 -40
- package/src/canvas/canvas.js +27 -11
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.js +36 -18
- package/src/core.js.map +1 -1
- package/src/diagrams/iterator.d.ts +0 -0
- package/src/diagrams/iterator.js +109 -0
- package/src/diagrams/iterator.js.map +1 -0
- package/src/dialog/dialog.js +60 -60
- package/src/message/message.js +18 -18
- package/src/options.d.ts +1 -0
- package/src/options.js +1 -0
- package/src/options.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 +2 -1
- package/src/pen/render.js.map +1 -1
- package/src/store/store.js +2 -1
- package/src/store/store.js.map +1 -1
- package/src/tooltip/tooltip.js +3 -0
- package/src/tooltip/tooltip.js.map +1 -1
- package/src/utils/debounce.d.ts +4 -0
- package/src/utils/debounce.js +19 -0
- package/src/utils/debounce.js.map +1 -1
- package/src/utils/jetLinks.js +7 -7
package/src/core.js
CHANGED
|
@@ -237,7 +237,7 @@ export class Meta2d {
|
|
|
237
237
|
let keys = url.match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
238
238
|
if (keys) {
|
|
239
239
|
keys?.forEach((key) => {
|
|
240
|
-
url = url.replace(`\${${key}}`, pen
|
|
240
|
+
url = url.replace(`\${${key}}`, getter(pen, key) || this.getDynamicParam(key));
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -262,7 +262,7 @@ export class Meta2d {
|
|
|
262
262
|
let keys = __value.match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
263
263
|
if (keys) {
|
|
264
264
|
keys.forEach((key) => {
|
|
265
|
-
__value = __value.replace(`\${${key}}`, pen
|
|
265
|
+
__value = __value.replace(`\${${key}}`, getter(pen, key) || this.getDynamicParam(key));
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
_value[key] = __value;
|
|
@@ -447,7 +447,7 @@ export class Meta2d {
|
|
|
447
447
|
let keys = e.params.match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
448
448
|
if (keys) {
|
|
449
449
|
keys?.forEach((key) => {
|
|
450
|
-
url = url.replace(`\${${key}}`, pen
|
|
450
|
+
url = url.replace(`\${${key}}`, getter(pen, key) || this.getDynamicParam(key));
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
453
|
}
|
|
@@ -505,13 +505,13 @@ export class Meta2d {
|
|
|
505
505
|
const _pen = e.params ? this.findOne(e.params) : pen;
|
|
506
506
|
for (let key in value) {
|
|
507
507
|
if (value[key] === undefined || value[key] === '') {
|
|
508
|
-
value[key] = _pen
|
|
508
|
+
value[key] = getter(_pen, key);
|
|
509
509
|
}
|
|
510
510
|
else if (typeof value[key] === 'string' &&
|
|
511
511
|
value[key]?.indexOf('${') > -1) {
|
|
512
512
|
let keys = value[key].match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
513
513
|
if (keys?.length) {
|
|
514
|
-
value[key] = _pen[
|
|
514
|
+
value[key] = getter(_pen, key[0]) ?? this.getDynamicParam(keys[0]);
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
}
|
|
@@ -535,7 +535,10 @@ export class Meta2d {
|
|
|
535
535
|
return;
|
|
536
536
|
}
|
|
537
537
|
let params = queryURLParams(_pen.iframe.split('?')[1]);
|
|
538
|
-
|
|
538
|
+
let value = this.getSendData(e.data, pen);
|
|
539
|
+
if (e.list) {
|
|
540
|
+
value = this.getEventData(e.list, pen);
|
|
541
|
+
}
|
|
539
542
|
_pen.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({
|
|
540
543
|
name: e.value,
|
|
541
544
|
id: params.id,
|
|
@@ -548,7 +551,10 @@ export class Meta2d {
|
|
|
548
551
|
console.warn('[meta2d] Emit value must be a string');
|
|
549
552
|
return;
|
|
550
553
|
}
|
|
551
|
-
|
|
554
|
+
let value = this.getSendData(e.data, pen);
|
|
555
|
+
if (e.list) {
|
|
556
|
+
value = this.getEventData(e.list, pen);
|
|
557
|
+
}
|
|
552
558
|
window.parent.postMessage(JSON.stringify({ name: e.value, data: value }), '*');
|
|
553
559
|
return;
|
|
554
560
|
};
|
|
@@ -570,7 +576,7 @@ export class Meta2d {
|
|
|
570
576
|
}
|
|
571
577
|
getSendData(data, cpen) {
|
|
572
578
|
const value = {};
|
|
573
|
-
data
|
|
579
|
+
data?.forEach((item) => {
|
|
574
580
|
if (item.prop) {
|
|
575
581
|
if (item.id && item.id !== '固定值') {
|
|
576
582
|
const pen = this.findOne(item.id);
|
|
@@ -684,8 +690,8 @@ export class Meta2d {
|
|
|
684
690
|
//图纸更新
|
|
685
691
|
const data = await getMeta2dData(this.store, id);
|
|
686
692
|
if (data) {
|
|
693
|
+
this.canvas.opening = true;
|
|
687
694
|
this.open(data);
|
|
688
|
-
this.canvas.opening = false;
|
|
689
695
|
this.lock(1);
|
|
690
696
|
const width = this.store.data.width || this.store.options.width;
|
|
691
697
|
const height = this.store.data.height || this.store.options.height;
|
|
@@ -695,6 +701,7 @@ export class Meta2d {
|
|
|
695
701
|
else {
|
|
696
702
|
this.fitView(true, 10);
|
|
697
703
|
}
|
|
704
|
+
this.render(true);
|
|
698
705
|
// document.title = data.name + "-" + window.name;
|
|
699
706
|
}
|
|
700
707
|
}
|
|
@@ -1552,7 +1559,7 @@ export class Meta2d {
|
|
|
1552
1559
|
this.canvas.setPenRect(pen, rect, render);
|
|
1553
1560
|
}
|
|
1554
1561
|
startAnimate(idOrTagOrPens, params) {
|
|
1555
|
-
this.stopAnimate(idOrTagOrPens);
|
|
1562
|
+
// this.stopAnimate(idOrTagOrPens);
|
|
1556
1563
|
let pens;
|
|
1557
1564
|
// 没有参数 则播放有自动播放属性的动画
|
|
1558
1565
|
if (!idOrTagOrPens) {
|
|
@@ -1565,9 +1572,19 @@ export class Meta2d {
|
|
|
1565
1572
|
}
|
|
1566
1573
|
else if (typeof idOrTagOrPens === 'string') {
|
|
1567
1574
|
pens = this.find(idOrTagOrPens);
|
|
1575
|
+
pens.forEach((pen) => {
|
|
1576
|
+
if (!pen.calculative.pause || pen.currentAnimation !== params) {
|
|
1577
|
+
this.stopAnimate([pen]);
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1568
1580
|
}
|
|
1569
1581
|
else {
|
|
1570
1582
|
pens = idOrTagOrPens;
|
|
1583
|
+
pens.forEach((pen) => {
|
|
1584
|
+
if (!pen.calculative.pause || pen.currentAnimation !== params) {
|
|
1585
|
+
this.stopAnimate([pen]);
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1571
1588
|
}
|
|
1572
1589
|
if (!pens.length) {
|
|
1573
1590
|
return;
|
|
@@ -4262,12 +4279,12 @@ export class Meta2d {
|
|
|
4262
4279
|
}
|
|
4263
4280
|
let mySerializedSVG = ctx.getSerializedSvg();
|
|
4264
4281
|
if (defs?.length) {
|
|
4265
|
-
mySerializedSVG = mySerializedSVG.replace('<defs/>', `<defs>
|
|
4266
|
-
<style type="text/css">
|
|
4267
|
-
${defs.join('\n')}
|
|
4268
|
-
</style>
|
|
4269
|
-
{{bk}}
|
|
4270
|
-
</defs>
|
|
4282
|
+
mySerializedSVG = mySerializedSVG.replace('<defs/>', `<defs>
|
|
4283
|
+
<style type="text/css">
|
|
4284
|
+
${defs.join('\n')}
|
|
4285
|
+
</style>
|
|
4286
|
+
{{bk}}
|
|
4287
|
+
</defs>
|
|
4271
4288
|
{{bkRect}}`);
|
|
4272
4289
|
}
|
|
4273
4290
|
if (background) {
|
|
@@ -4336,7 +4353,7 @@ export class Meta2d {
|
|
|
4336
4353
|
else {
|
|
4337
4354
|
ratio = w > h ? w : h;
|
|
4338
4355
|
}
|
|
4339
|
-
if (this.store.data.fits?.length) {
|
|
4356
|
+
if (fill && this.store.data.fits?.length) {
|
|
4340
4357
|
this.canvas.opening = true;
|
|
4341
4358
|
}
|
|
4342
4359
|
// 该方法直接更改画布的 scale 属性,所以比率应该乘以当前 scale
|
|
@@ -4688,7 +4705,7 @@ export class Meta2d {
|
|
|
4688
4705
|
ratio = w > h ? w : h;
|
|
4689
4706
|
}
|
|
4690
4707
|
}
|
|
4691
|
-
if (this.store.data.fits?.length) {
|
|
4708
|
+
if (fill && this.store.data.fits?.length) {
|
|
4692
4709
|
this.canvas.opening = true;
|
|
4693
4710
|
}
|
|
4694
4711
|
// 该方法直接更改画布的 scale 属性,所以比率应该乘以当前 scale
|
|
@@ -6069,6 +6086,7 @@ export class Meta2d {
|
|
|
6069
6086
|
globalStore.canvasDraws = {};
|
|
6070
6087
|
globalStore.anchors = {};
|
|
6071
6088
|
globalStore.htmlElements = {};
|
|
6089
|
+
globalStore.lineAnimateDraws = {};
|
|
6072
6090
|
}
|
|
6073
6091
|
}
|
|
6074
6092
|
}
|