@meta2d/core 1.0.61 → 1.0.63
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 +4 -3
- package/src/canvas/canvas.js +52 -24
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +10 -4
- package/src/core.js +192 -11
- package/src/core.js.map +1 -1
- package/src/event/event.d.ts +7 -1
- package/src/event/event.js +1 -0
- package/src/event/event.js.map +1 -1
- package/src/message/index.d.ts +1 -0
- package/src/message/index.js +2 -0
- package/src/message/index.js.map +1 -0
- package/src/message/message.d.ts +28 -0
- package/src/message/message.js +162 -0
- package/src/message/message.js.map +1 -0
- package/src/pen/model.d.ts +10 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.d.ts +1 -0
- package/src/pen/render.js +41 -3
- package/src/pen/render.js.map +1 -1
- package/src/popconfirm/index.d.ts +1 -0
- package/src/popconfirm/index.js +2 -0
- package/src/popconfirm/index.js.map +1 -0
- package/src/popconfirm/popconfirm.d.ts +21 -0
- package/src/popconfirm/popconfirm.js +135 -0
- package/src/popconfirm/popconfirm.js.map +1 -0
- package/src/store/store.d.ts +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { Meta2d } from '../core';
|
|
|
14
14
|
import { Dialog } from '../dialog';
|
|
15
15
|
import { Title } from '../title';
|
|
16
16
|
import { CanvasTemplate } from './canvasTemplate';
|
|
17
|
+
import { Popconfirm } from '../popconfirm';
|
|
17
18
|
export declare const movingSuffix: "-moving";
|
|
18
19
|
export declare class Canvas {
|
|
19
20
|
parent: Meta2d;
|
|
@@ -106,9 +107,9 @@ export declare class Canvas {
|
|
|
106
107
|
};
|
|
107
108
|
inputParent: HTMLDivElement;
|
|
108
109
|
inputDiv: HTMLDivElement;
|
|
109
|
-
inputRight: HTMLDivElement;
|
|
110
110
|
dropdown: HTMLUListElement;
|
|
111
111
|
tooltip: Tooltip;
|
|
112
|
+
popconfirm: Popconfirm;
|
|
112
113
|
title: Title;
|
|
113
114
|
mousePos: Point;
|
|
114
115
|
scroll: Scroll;
|
|
@@ -144,7 +145,7 @@ export declare class Canvas {
|
|
|
144
145
|
ondrop: (event: DragEvent) => Promise<void>;
|
|
145
146
|
dropPens(pens: Pen[], e: Point): Promise<void>;
|
|
146
147
|
randomCombineId(pen: Pen, pens: Pen[], parentId?: string): Pen;
|
|
147
|
-
addPens(pens: Pen[], history?: boolean): Promise<Pen[]>;
|
|
148
|
+
addPens(pens: Pen[], history?: boolean, abs?: boolean): Promise<Pen[]>;
|
|
148
149
|
ontouchstart: (e: TouchEvent) => void;
|
|
149
150
|
ontouchmove: (event: TouchEvent) => void;
|
|
150
151
|
ontouchend: (event: TouchEvent) => void;
|
|
@@ -238,7 +239,7 @@ export declare class Canvas {
|
|
|
238
239
|
inAnchor(pt: Point, pen: Pen, anchor: Point): HoverType;
|
|
239
240
|
resize(w?: number, h?: number): void;
|
|
240
241
|
clearCanvas(): void;
|
|
241
|
-
addPen(pen: Pen, history?: boolean, emit?: boolean): Promise<Pen>;
|
|
242
|
+
addPen(pen: Pen, history?: boolean, emit?: boolean, abs?: boolean): Promise<Pen>;
|
|
242
243
|
pushHistory(action: EditAction): void;
|
|
243
244
|
undo(): void;
|
|
244
245
|
redo(): void;
|
package/src/canvas/canvas.js
CHANGED
|
@@ -18,6 +18,7 @@ import { setter } from '../utils/object';
|
|
|
18
18
|
import { Title } from '../title';
|
|
19
19
|
import { CanvasTemplate } from './canvasTemplate';
|
|
20
20
|
import { getLinePoints } from '../diagrams/line';
|
|
21
|
+
import { Popconfirm } from '../popconfirm';
|
|
21
22
|
export const movingSuffix = '-moving';
|
|
22
23
|
export class Canvas {
|
|
23
24
|
parent;
|
|
@@ -94,9 +95,10 @@ export class Canvas {
|
|
|
94
95
|
inputParent = document.createElement('div');
|
|
95
96
|
// input = document.createElement('textarea');
|
|
96
97
|
inputDiv = document.createElement('div');
|
|
97
|
-
inputRight = document.createElement('div');
|
|
98
|
+
// inputRight = document.createElement('div');
|
|
98
99
|
dropdown = document.createElement('ul');
|
|
99
100
|
tooltip;
|
|
101
|
+
popconfirm;
|
|
100
102
|
title;
|
|
101
103
|
mousePos = { x: 0, y: 0 };
|
|
102
104
|
scroll;
|
|
@@ -126,13 +128,13 @@ export class Canvas {
|
|
|
126
128
|
this.canvasImage = new CanvasImage(parentElement, store);
|
|
127
129
|
this.canvasImage.canvas.style.zIndex = '4';
|
|
128
130
|
this.magnifierCanvas = new MagnifierCanvas(this, parentElement, store);
|
|
129
|
-
this.magnifierCanvas.canvas.style.zIndex = '
|
|
131
|
+
this.magnifierCanvas.canvas.style.zIndex = '5';
|
|
130
132
|
this.externalElements.style.position = 'absolute';
|
|
131
133
|
this.externalElements.style.left = '0';
|
|
132
134
|
this.externalElements.style.top = '0';
|
|
133
135
|
this.externalElements.style.outline = 'none';
|
|
134
136
|
this.externalElements.style.background = 'transparent';
|
|
135
|
-
this.externalElements.style.zIndex = '
|
|
137
|
+
this.externalElements.style.zIndex = '5';
|
|
136
138
|
parentElement.style.position = 'relative';
|
|
137
139
|
parentElement.appendChild(this.externalElements);
|
|
138
140
|
this.createInput();
|
|
@@ -143,6 +145,7 @@ export class Canvas {
|
|
|
143
145
|
let hover = this.store.data.pens.find((item) => item.calculative.hover === true);
|
|
144
146
|
setHover(hover, false);
|
|
145
147
|
};
|
|
148
|
+
this.popconfirm = new Popconfirm(parentElement, store);
|
|
146
149
|
this.dialog = new Dialog(parentElement);
|
|
147
150
|
this.title = new Title(parentElement);
|
|
148
151
|
if (this.store.options.scroll) {
|
|
@@ -1229,7 +1232,7 @@ export class Canvas {
|
|
|
1229
1232
|
pen.children = newChildren;
|
|
1230
1233
|
return pen;
|
|
1231
1234
|
}
|
|
1232
|
-
async addPens(pens, history) {
|
|
1235
|
+
async addPens(pens, history, abs) {
|
|
1233
1236
|
if (this.beforeAddPens && (await this.beforeAddPens(pens)) != true) {
|
|
1234
1237
|
return [];
|
|
1235
1238
|
}
|
|
@@ -1238,6 +1241,12 @@ export class Canvas {
|
|
|
1238
1241
|
if (this.beforeAddPen && this.beforeAddPen(pen) != true) {
|
|
1239
1242
|
continue;
|
|
1240
1243
|
}
|
|
1244
|
+
if (abs) {
|
|
1245
|
+
pen.x = pen.x * this.store.data.scale + this.store.data.origin.x;
|
|
1246
|
+
pen.y = pen.y * this.store.data.scale + this.store.data.origin.y;
|
|
1247
|
+
pen.width = pen.width * this.store.data.scale;
|
|
1248
|
+
pen.height = pen.height * this.store.data.scale;
|
|
1249
|
+
}
|
|
1241
1250
|
this.makePen(pen);
|
|
1242
1251
|
list.push(pen);
|
|
1243
1252
|
}
|
|
@@ -1462,6 +1471,7 @@ export class Canvas {
|
|
|
1462
1471
|
this.mouseRight = MouseRight.Down;
|
|
1463
1472
|
}
|
|
1464
1473
|
this.hideInput();
|
|
1474
|
+
this.popconfirm.hide();
|
|
1465
1475
|
if (this.store.data.locked === LockState.Disable ||
|
|
1466
1476
|
(e.buttons !== 1 && e.buttons !== 2)) {
|
|
1467
1477
|
this.hoverType = HoverType.None;
|
|
@@ -3210,13 +3220,19 @@ export class Canvas {
|
|
|
3210
3220
|
this.canvasImage.clear();
|
|
3211
3221
|
this.canvasImageBottom.clear();
|
|
3212
3222
|
}
|
|
3213
|
-
async addPen(pen, history, emit) {
|
|
3223
|
+
async addPen(pen, history, emit, abs) {
|
|
3214
3224
|
if (this.beforeAddPens && (await this.beforeAddPens([pen])) != true) {
|
|
3215
3225
|
return;
|
|
3216
3226
|
}
|
|
3217
3227
|
if (this.beforeAddPen && this.beforeAddPen(pen) != true) {
|
|
3218
3228
|
return;
|
|
3219
3229
|
}
|
|
3230
|
+
if (abs) {
|
|
3231
|
+
pen.x = pen.x * this.store.data.scale + this.store.data.origin.x;
|
|
3232
|
+
pen.y = pen.y * this.store.data.scale + this.store.data.origin.y;
|
|
3233
|
+
pen.width = pen.width * this.store.data.scale;
|
|
3234
|
+
pen.height = pen.height * this.store.data.scale;
|
|
3235
|
+
}
|
|
3220
3236
|
this.makePen(pen);
|
|
3221
3237
|
this.active([pen]);
|
|
3222
3238
|
this.render();
|
|
@@ -6149,15 +6165,15 @@ export class Canvas {
|
|
|
6149
6165
|
this.inputDiv.contentEditable =
|
|
6150
6166
|
pen.disableInput == undefined ? 'true' : pen.disableInput.toString();
|
|
6151
6167
|
if (pen.dropdownList && this.dropdown.style.display !== 'block') {
|
|
6152
|
-
if (!this.store.data.locked) {
|
|
6153
|
-
|
|
6154
|
-
}
|
|
6168
|
+
// if (!this.store.data.locked) {
|
|
6169
|
+
// this.inputRight.style.display = 'none';
|
|
6170
|
+
// }
|
|
6155
6171
|
this.dropdown.style.background = pen.dropdownBackground || '#fff';
|
|
6156
6172
|
this.dropdown.style.color = pen.dropdownColor || '#bdc7db';
|
|
6157
6173
|
this.setDropdownList();
|
|
6158
6174
|
}
|
|
6159
6175
|
else {
|
|
6160
|
-
this.inputRight.style.display = 'none';
|
|
6176
|
+
// this.inputRight.style.display = 'none';
|
|
6161
6177
|
}
|
|
6162
6178
|
this.inputDiv.contentEditable = 'true';
|
|
6163
6179
|
this.inputDiv.focus();
|
|
@@ -6385,10 +6401,10 @@ export class Canvas {
|
|
|
6385
6401
|
};
|
|
6386
6402
|
createInput() {
|
|
6387
6403
|
this.inputParent.classList.add('meta2d-input');
|
|
6388
|
-
this.inputRight.classList.add('right');
|
|
6404
|
+
// this.inputRight.classList.add('right');
|
|
6389
6405
|
this.inputDiv.classList.add('input-div');
|
|
6390
6406
|
this.inputParent.appendChild(this.inputDiv);
|
|
6391
|
-
this.inputParent.appendChild(this.inputRight);
|
|
6407
|
+
// this.inputParent.appendChild(this.inputRight);
|
|
6392
6408
|
this.dropdown.onmouseleave = () => {
|
|
6393
6409
|
this.store.hover = null;
|
|
6394
6410
|
};
|
|
@@ -6397,9 +6413,9 @@ export class Canvas {
|
|
|
6397
6413
|
this.inputParent.onmousedown = this.stopPropagation;
|
|
6398
6414
|
this.inputDiv.onmousedown = this.stopPropagation;
|
|
6399
6415
|
this.inputDiv.contentEditable = 'false';
|
|
6400
|
-
this.inputRight.onmousedown = this.stopPropagation;
|
|
6416
|
+
// this.inputRight.onmousedown = this.stopPropagation;
|
|
6401
6417
|
this.dropdown.onmousedown = this.stopPropagation;
|
|
6402
|
-
this.inputRight.style.transform = 'rotate(135deg)';
|
|
6418
|
+
// this.inputRight.style.transform = 'rotate(135deg)';
|
|
6403
6419
|
let sheet;
|
|
6404
6420
|
for (let i = 0; i < document.styleSheets.length; i++) {
|
|
6405
6421
|
if (document.styleSheets[i].title === 'le5le.com') {
|
|
@@ -6493,11 +6509,11 @@ export class Canvas {
|
|
|
6493
6509
|
const pen = this.store.pens[this.inputDiv.dataset.penId];
|
|
6494
6510
|
if (this.dropdown.style.display === 'block') {
|
|
6495
6511
|
this.dropdown.style.display = 'none';
|
|
6496
|
-
this.inputRight.style.transform = 'rotate(135deg)';
|
|
6512
|
+
// this.inputRight.style.transform = 'rotate(135deg)';
|
|
6497
6513
|
}
|
|
6498
6514
|
else if (pen?.dropdownList && this.store.data.locked) {
|
|
6499
6515
|
this.dropdown.style.display = 'block';
|
|
6500
|
-
this.inputRight.style.transform = 'rotate(315deg)';
|
|
6516
|
+
// this.inputRight.style.transform = 'rotate(315deg)';
|
|
6501
6517
|
}
|
|
6502
6518
|
this.store.emitter.emit('clickInput', pen);
|
|
6503
6519
|
};
|
|
@@ -6538,15 +6554,15 @@ export class Canvas {
|
|
|
6538
6554
|
return;
|
|
6539
6555
|
}
|
|
6540
6556
|
this.dropdown.style.display = 'block';
|
|
6541
|
-
this.inputRight.style.display = 'block';
|
|
6542
|
-
setTimeout(() => {
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
});
|
|
6557
|
+
// this.inputRight.style.display = 'block';
|
|
6558
|
+
// setTimeout(() => {
|
|
6559
|
+
// this.inputRight.style.transform = 'rotate(315deg)';
|
|
6560
|
+
// (this.inputRight.style as any).zoom = this.store.data.scale;
|
|
6561
|
+
// });
|
|
6546
6562
|
if (!pen || !pen.dropdownList) {
|
|
6547
6563
|
this.dropdown.style.display = 'none';
|
|
6548
|
-
this.inputRight.style.display = 'none';
|
|
6549
|
-
this.inputRight.style.transform = 'rotate(135deg)';
|
|
6564
|
+
// this.inputRight.style.display = 'none';
|
|
6565
|
+
// this.inputRight.style.transform = 'rotate(135deg)';
|
|
6550
6566
|
return;
|
|
6551
6567
|
}
|
|
6552
6568
|
if (!pen.dropdownList.length) {
|
|
@@ -6715,7 +6731,12 @@ export class Canvas {
|
|
|
6715
6731
|
// 单属性
|
|
6716
6732
|
if (k.indexOf('.') === -1) {
|
|
6717
6733
|
if (k === 'rotate') {
|
|
6718
|
-
|
|
6734
|
+
if (pen.disableRotate) { //当图元禁止旋转时不重新设置旋转角度
|
|
6735
|
+
pen.rotate = pen.calculative.rotate || 0;
|
|
6736
|
+
}
|
|
6737
|
+
else {
|
|
6738
|
+
oldRotate = pen.calculative.rotate || 0;
|
|
6739
|
+
}
|
|
6719
6740
|
}
|
|
6720
6741
|
else if (k === 'canvasLayer' || k === 'isBottom' || k === 'showChild') {
|
|
6721
6742
|
containIsBottom = true;
|
|
@@ -6724,7 +6745,9 @@ export class Canvas {
|
|
|
6724
6745
|
willRenderImage = true;
|
|
6725
6746
|
}
|
|
6726
6747
|
if (typeof pen[k] !== 'object' || k === 'lineDash') {
|
|
6727
|
-
pen.
|
|
6748
|
+
if (!pen.disableRotate || k !== 'rotate') { //当图元禁止旋转时不重新设置旋转角度
|
|
6749
|
+
pen.calculative[k] = data[k];
|
|
6750
|
+
}
|
|
6728
6751
|
}
|
|
6729
6752
|
if (needCalcTextRectProps.includes(k)) {
|
|
6730
6753
|
willCalcTextRect = true;
|
|
@@ -7221,12 +7244,16 @@ export class Canvas {
|
|
|
7221
7244
|
this.render();
|
|
7222
7245
|
}
|
|
7223
7246
|
showMagnifier() {
|
|
7247
|
+
this.magnifierCanvas.canvas.style.zIndex = '100';
|
|
7248
|
+
this.externalElements.style.zIndex = '101';
|
|
7224
7249
|
this.magnifierCanvas.magnifier = true;
|
|
7225
7250
|
this.magnifierCanvas.updateDomOffscreen();
|
|
7226
7251
|
this.externalElements.style.cursor = 'default';
|
|
7227
7252
|
this.render();
|
|
7228
7253
|
}
|
|
7229
7254
|
hideMagnifier() {
|
|
7255
|
+
this.magnifierCanvas.canvas.style.zIndex = '5';
|
|
7256
|
+
this.externalElements.style.zIndex = '5';
|
|
7230
7257
|
this.magnifierCanvas.magnifier = false;
|
|
7231
7258
|
this.externalElements.style.cursor = 'default';
|
|
7232
7259
|
this.render();
|
|
@@ -7603,6 +7630,7 @@ export class Canvas {
|
|
|
7603
7630
|
this.tooltip?.destroy();
|
|
7604
7631
|
this.dialog?.destroy();
|
|
7605
7632
|
this.title?.destroy();
|
|
7633
|
+
this.popconfirm?.destroy();
|
|
7606
7634
|
// ios
|
|
7607
7635
|
this.externalElements.removeEventListener('gesturestart', this.onGesturestart);
|
|
7608
7636
|
this.externalElements.ondragover = (e) => e.preventDefault();
|