@meta2d/core 1.0.95 → 1.0.97
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.d.ts +3 -0
- package/src/canvas/canvas.js +120 -2
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +2 -2
- package/src/core.js +19 -7
- package/src/core.js.map +1 -1
- package/src/dialog/dialog.d.ts +6 -0
- package/src/dialog/dialog.js +29 -4
- package/src/dialog/dialog.js.map +1 -1
- package/src/pen/model.d.ts +2 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +17 -0
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +19 -1
- package/src/pen/text.js.map +1 -1
- package/src/store/store.d.ts +1 -0
- package/src/store/store.js.map +1 -1
- package/src/utils/tool.js +1 -1
- package/src/utils/tool.js.map +1 -1
- package/src/utils/url.js +2 -0
- package/src/utils/url.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.d.ts
CHANGED
|
@@ -234,6 +234,7 @@ export declare class Canvas {
|
|
|
234
234
|
calibrateMouse: (pt: Point) => Point;
|
|
235
235
|
clearHover(): void;
|
|
236
236
|
private getContainerHover;
|
|
237
|
+
lastHoverType: HoverType;
|
|
237
238
|
private getHover;
|
|
238
239
|
private inPens;
|
|
239
240
|
private dockInAnchor;
|
|
@@ -277,6 +278,8 @@ export declare class Canvas {
|
|
|
277
278
|
private renderPenContainChild;
|
|
278
279
|
renderBorder: () => void;
|
|
279
280
|
renderHoverPoint: () => void;
|
|
281
|
+
renderPensAnchors: () => void;
|
|
282
|
+
renderAnchors: (pen: Pen) => void;
|
|
280
283
|
transTimeout: any;
|
|
281
284
|
translate(x?: number, y?: number): void;
|
|
282
285
|
onMovePens(): void;
|
package/src/canvas/canvas.js
CHANGED
|
@@ -2811,6 +2811,7 @@ export class Canvas {
|
|
|
2811
2811
|
}
|
|
2812
2812
|
}
|
|
2813
2813
|
};
|
|
2814
|
+
lastHoverType = HoverType.None;
|
|
2814
2815
|
getHover = (pt) => {
|
|
2815
2816
|
if (this.dragRect) {
|
|
2816
2817
|
return;
|
|
@@ -2897,7 +2898,9 @@ export class Canvas {
|
|
|
2897
2898
|
if (this.store.lastHover) {
|
|
2898
2899
|
this.store.lastHover.calculative.hover = false;
|
|
2899
2900
|
setHover(getParent(this.store.lastHover, true) || this.store.lastHover, false);
|
|
2900
|
-
this.store.
|
|
2901
|
+
if (this.store.pens[this.store.lastHover.id]) {
|
|
2902
|
+
this.store.emitter.emit('leave', this.store.lastHover);
|
|
2903
|
+
}
|
|
2901
2904
|
this.tooltip.hide();
|
|
2902
2905
|
}
|
|
2903
2906
|
if (this.store.hover) {
|
|
@@ -2908,6 +2911,14 @@ export class Canvas {
|
|
|
2908
2911
|
}
|
|
2909
2912
|
this.store.lastHover = this.store.hover;
|
|
2910
2913
|
}
|
|
2914
|
+
if ([HoverType.LineAnchor, HoverType.NodeAnchor].includes(hoverType) &&
|
|
2915
|
+
![HoverType.LineAnchor, HoverType.NodeAnchor].includes(this.lastHoverType)) {
|
|
2916
|
+
this.store.emitter.emit("enterAnchor", {
|
|
2917
|
+
pen: this.store.hover,
|
|
2918
|
+
anchor: this.store.hoverAnchor,
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2921
|
+
this.lastHoverType = hoverType;
|
|
2911
2922
|
this.store.hover?.onMouseMove?.(this.store.hover, this.mousePos);
|
|
2912
2923
|
};
|
|
2913
2924
|
inPens = (pt, pens) => {
|
|
@@ -4197,6 +4208,7 @@ export class Canvas {
|
|
|
4197
4208
|
globalThis.debugRender && console.timeEnd('renderPens');
|
|
4198
4209
|
this.renderBorder();
|
|
4199
4210
|
this.renderHoverPoint();
|
|
4211
|
+
this.renderPensAnchors();
|
|
4200
4212
|
offscreenCtx.restore();
|
|
4201
4213
|
if (this.magnifierCanvas.magnifier) {
|
|
4202
4214
|
this.magnifierCanvas.render();
|
|
@@ -4217,7 +4229,9 @@ export class Canvas {
|
|
|
4217
4229
|
continue;
|
|
4218
4230
|
}
|
|
4219
4231
|
// if (pen.template) {
|
|
4220
|
-
if (pen.canvasLayer === CanvasLayer.CanvasTemplate
|
|
4232
|
+
if (pen.canvasLayer === CanvasLayer.CanvasTemplate
|
|
4233
|
+
|| pen.canvasLayer === CanvasLayer.CanvasImageBottom
|
|
4234
|
+
|| pen.canvasLayer === CanvasLayer.CanvasImage) {
|
|
4221
4235
|
continue;
|
|
4222
4236
|
}
|
|
4223
4237
|
// if (pen.name === 'combine' && !pen.draw){
|
|
@@ -4478,6 +4492,106 @@ export class Canvas {
|
|
|
4478
4492
|
}
|
|
4479
4493
|
ctx.restore();
|
|
4480
4494
|
};
|
|
4495
|
+
renderPensAnchors = () => {
|
|
4496
|
+
// 总是显示锚点 不受locked影响
|
|
4497
|
+
for (const pen of this.store.data.pens) {
|
|
4498
|
+
if (!isFinite(pen.x)) {
|
|
4499
|
+
continue;
|
|
4500
|
+
}
|
|
4501
|
+
if (pen.anchorVisible === true) {
|
|
4502
|
+
this.renderAnchors(pen);
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
};
|
|
4506
|
+
renderAnchors = (pen) => {
|
|
4507
|
+
const ctx = this.offscreen.getContext("2d");
|
|
4508
|
+
ctx.save();
|
|
4509
|
+
ctx.translate(0.5, 0.5);
|
|
4510
|
+
ctx.strokeStyle = pen.anchorColor || this.store.styles.anchorColor;
|
|
4511
|
+
ctx.fillStyle = pen.anchorBackground || this.store.options.anchorBackground;
|
|
4512
|
+
pen.calculative.worldAnchors.forEach((anchor) => {
|
|
4513
|
+
if (anchor.hidden || anchor.locked > LockState.DisableEdit) {
|
|
4514
|
+
return;
|
|
4515
|
+
}
|
|
4516
|
+
if (anchor === this.store.hoverAnchor) {
|
|
4517
|
+
ctx.save();
|
|
4518
|
+
const hoverAnchorColor = pen.hoverAnchorColor || this.store.options.hoverAnchorColor;
|
|
4519
|
+
ctx.strokeStyle = hoverAnchorColor;
|
|
4520
|
+
ctx.fillStyle = hoverAnchorColor;
|
|
4521
|
+
}
|
|
4522
|
+
ctx.beginPath();
|
|
4523
|
+
let size = anchor.radius || pen.anchorRadius || this.store.options.anchorRadius;
|
|
4524
|
+
if (pen.type && !anchor.radius && !pen.anchorRadius) {
|
|
4525
|
+
size = 3;
|
|
4526
|
+
if (pen.calculative.lineWidth > 3) {
|
|
4527
|
+
size = pen.calculative.lineWidth;
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
if (anchor.type === PointType.Line) {
|
|
4531
|
+
//旋转的情况
|
|
4532
|
+
let _rotate = this.store.pens[anchor.penId].rotate || 0;
|
|
4533
|
+
if (this.store.pens[anchor.penId].calculative.flipX) {
|
|
4534
|
+
_rotate *= -1;
|
|
4535
|
+
}
|
|
4536
|
+
if (this.store.pens[anchor.penId].calculative.flipY) {
|
|
4537
|
+
_rotate *= -1;
|
|
4538
|
+
}
|
|
4539
|
+
let rotate = anchor.rotate + _rotate;
|
|
4540
|
+
if (this.store.pens[anchor.penId].calculative.flipX) {
|
|
4541
|
+
rotate *= -1;
|
|
4542
|
+
}
|
|
4543
|
+
if (this.store.pens[anchor.penId].calculative.flipY) {
|
|
4544
|
+
rotate *= -1;
|
|
4545
|
+
}
|
|
4546
|
+
ctx.save();
|
|
4547
|
+
ctx.translate(anchor.x, anchor.y);
|
|
4548
|
+
ctx.rotate((rotate * Math.PI) / 180);
|
|
4549
|
+
ctx.translate(-anchor.x, -anchor.y);
|
|
4550
|
+
ctx.rect(anchor.x - (anchor.length * this.store.data.scale) / 2, anchor.y - size, anchor.length * this.store.data.scale, size * 2);
|
|
4551
|
+
ctx.restore();
|
|
4552
|
+
}
|
|
4553
|
+
else {
|
|
4554
|
+
ctx.arc(anchor.x, anchor.y, size, 0, Math.PI * 2);
|
|
4555
|
+
}
|
|
4556
|
+
if (pen.type && this.store.hoverAnchor === anchor) {
|
|
4557
|
+
ctx.save();
|
|
4558
|
+
ctx.strokeStyle = pen.activeColor || this.store.styles.activeColor;
|
|
4559
|
+
ctx.fillStyle = ctx.strokeStyle;
|
|
4560
|
+
}
|
|
4561
|
+
else if (anchor.color || anchor.background) {
|
|
4562
|
+
ctx.save();
|
|
4563
|
+
ctx.strokeStyle = anchor.color;
|
|
4564
|
+
ctx.fillStyle = anchor.background;
|
|
4565
|
+
}
|
|
4566
|
+
ctx.fill();
|
|
4567
|
+
ctx.stroke();
|
|
4568
|
+
if (anchor === this.store.hoverAnchor) {
|
|
4569
|
+
ctx.restore();
|
|
4570
|
+
}
|
|
4571
|
+
if (pen.type && this.store.hoverAnchor === anchor) {
|
|
4572
|
+
ctx.restore();
|
|
4573
|
+
}
|
|
4574
|
+
else if (anchor.color || anchor.background) {
|
|
4575
|
+
ctx.restore();
|
|
4576
|
+
}
|
|
4577
|
+
//根父节点
|
|
4578
|
+
if (!pen.parentId && pen.children && pen.children.length > 0) {
|
|
4579
|
+
if (anchor === this.store.hoverAnchor) {
|
|
4580
|
+
ctx.save();
|
|
4581
|
+
ctx.beginPath();
|
|
4582
|
+
ctx.lineWidth = 3;
|
|
4583
|
+
const hoverAnchorColor = pen.hoverAnchorColor || this.store.options.hoverAnchorColor;
|
|
4584
|
+
if (globalThis.pSBC) {
|
|
4585
|
+
ctx.strokeStyle = globalThis.pSBC(0.5, hoverAnchorColor);
|
|
4586
|
+
}
|
|
4587
|
+
ctx.arc(anchor.x, anchor.y, size + 1.5, 0, Math.PI * 2);
|
|
4588
|
+
ctx.stroke();
|
|
4589
|
+
ctx.restore();
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
});
|
|
4593
|
+
ctx.restore();
|
|
4594
|
+
};
|
|
4481
4595
|
transTimeout;
|
|
4482
4596
|
translate(x = 0, y = 0) {
|
|
4483
4597
|
this.store.data.x += x * this.store.data.scale;
|
|
@@ -6404,6 +6518,10 @@ export class Canvas {
|
|
|
6404
6518
|
this.dropdown.style.color = pen.dropdownColor || '#bdc7db';
|
|
6405
6519
|
this.dropdown.style.width = this.inputParent.style.width;
|
|
6406
6520
|
this.dropdown.style.fontSize = (pen.fontSize || 12) + 'px';
|
|
6521
|
+
const inputRect = this.inputDiv.getBoundingClientRect();
|
|
6522
|
+
let maxH = window.innerHeight - inputRect.top - inputRect.height;
|
|
6523
|
+
maxH = maxH > 200 ? 200 : maxH;
|
|
6524
|
+
this.dropdown.style.maxHeight = maxH + 'px';
|
|
6407
6525
|
this.setDropdownList();
|
|
6408
6526
|
this.externalElements.style.zIndex = '9999';
|
|
6409
6527
|
}
|