build-dxf 0.0.19-7 → 0.0.19-9
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/build.d.ts +20 -0
- package/src/build.js +24 -3
- package/src/index.css +765 -1
- package/src/index.js +4 -2
- package/src/index2.js +4 -402
- package/src/index3.js +154 -45
- package/src/selectLocalFile.js +443 -21
- package/src/utils/ComponentManager/ComponentManager.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/pages/EditorTool.vue.d.ts +4 -1
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/DomEventRegister.d.ts +5 -2
package/src/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { D, M, i, c } from "./build.js";
|
|
2
1
|
import "three";
|
|
2
|
+
import { D, M, i, c, g, d } from "./build.js";
|
|
3
3
|
export {
|
|
4
4
|
D as DxfSystem,
|
|
5
5
|
M as ModelDataPlugin,
|
|
6
6
|
i as components,
|
|
7
|
-
c as createEditor
|
|
7
|
+
c as createEditor,
|
|
8
|
+
g as getFileAll,
|
|
9
|
+
d as getGlobalDxfSystem
|
|
8
10
|
};
|
package/src/index2.js
CHANGED
|
@@ -1,208 +1,10 @@
|
|
|
1
1
|
import { C as Component, P as Point, V as Variable, D as DxfSystem, M as ModelDataPlugin, a as DetailsPoint, W as WhiteModel } from "./build.js";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import { Group
|
|
3
|
+
import { Group } from "three";
|
|
4
4
|
import "clipper-lib";
|
|
5
5
|
import "dxf-writer";
|
|
6
|
-
import {
|
|
7
|
-
import { CSS2DObject, CSS2DRenderer } from "three/addons/renderers/CSS2DRenderer.js";
|
|
8
|
-
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
9
|
-
import * as TWEEN from "@tweenjs/tween.js";
|
|
6
|
+
import { E as ElButton, R as Renderer, L as Lines, D as DomEventRegister, a as DomContainer, b as ElCheckbox, S as SelectLocalFile } from "./selectLocalFile.js";
|
|
10
7
|
import { defineComponent, createElementBlock, openBlock, createElementVNode, toDisplayString, createVNode, unref, withCtx, createTextVNode, createApp, ref, watch, onMounted, onUnmounted, createCommentVNode, createStaticVNode } from "vue";
|
|
11
|
-
import { E as ElButton, L as Lines, a as ElCheckbox, S as SelectLocalFile } from "./selectLocalFile.js";
|
|
12
|
-
THREE.Object3D.DEFAULT_UP = new THREE.Vector3(0, 0, 1);
|
|
13
|
-
class Renderer extends Component {
|
|
14
|
-
static name = "Renderer";
|
|
15
|
-
static CSS2DObject = CSS2DObject;
|
|
16
|
-
static CSS3DObject = CSS3DObject;
|
|
17
|
-
static CSS3DSprite = CSS3DSprite;
|
|
18
|
-
static Group = THREE.Group;
|
|
19
|
-
static Object3D = THREE.Object3D;
|
|
20
|
-
static Mesh = THREE.Mesh;
|
|
21
|
-
static Line = THREE.Line;
|
|
22
|
-
static LineSegments = THREE.LineSegments;
|
|
23
|
-
static Points = THREE.Points;
|
|
24
|
-
scene;
|
|
25
|
-
camera;
|
|
26
|
-
renderer;
|
|
27
|
-
orbitControls;
|
|
28
|
-
resizeObserver;
|
|
29
|
-
description;
|
|
30
|
-
html2DRenderer;
|
|
31
|
-
html3DRenderer;
|
|
32
|
-
container = new THREE.Group();
|
|
33
|
-
onUpdate;
|
|
34
|
-
onResize;
|
|
35
|
-
tweenTaskList = [];
|
|
36
|
-
constructor(description) {
|
|
37
|
-
super();
|
|
38
|
-
this.description = description;
|
|
39
|
-
const {
|
|
40
|
-
scene = new THREE.Scene(),
|
|
41
|
-
camera = new THREE.PerspectiveCamera(45, 1, 0.01, 1e3)
|
|
42
|
-
} = description;
|
|
43
|
-
this.camera = camera;
|
|
44
|
-
this.scene = scene;
|
|
45
|
-
scene.add(this.container);
|
|
46
|
-
this.renderer = new THREE.WebGLRenderer({
|
|
47
|
-
canvas: this.description.canvas,
|
|
48
|
-
antialias: true
|
|
49
|
-
});
|
|
50
|
-
this.renderer.setPixelRatio(window.devicePixelRatio);
|
|
51
|
-
if (description.htmlRenderer) {
|
|
52
|
-
if (description.htmlRenderer["2d"]) {
|
|
53
|
-
this.html2DRenderer = new CSS2DRenderer();
|
|
54
|
-
Object.assign(this.html2DRenderer.domElement.style, { position: "absolute", left: "0px", top: "0px" });
|
|
55
|
-
description.htmlRenderer["2d"].appendChild(this.html2DRenderer.domElement);
|
|
56
|
-
}
|
|
57
|
-
if (description.htmlRenderer["3d"]) {
|
|
58
|
-
this.html3DRenderer = new CSS3DRenderer();
|
|
59
|
-
Object.assign(this.html3DRenderer.domElement.style, { position: "absolute", left: "0px", top: "0px" });
|
|
60
|
-
description.htmlRenderer["3d"].appendChild(this.html3DRenderer.domElement);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (description.orbitControls) {
|
|
64
|
-
this.orbitControls = new OrbitControls(this.camera, description.orbitControls.domElement);
|
|
65
|
-
Object.assign(this.orbitControls, description.orbitControls);
|
|
66
|
-
}
|
|
67
|
-
if (this.description.resizeObserver) {
|
|
68
|
-
const dom = this.description.resizeObserver;
|
|
69
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
70
|
-
const camera2 = this.camera;
|
|
71
|
-
const { width, height } = dom.getBoundingClientRect();
|
|
72
|
-
this.renderer.setSize(width, height);
|
|
73
|
-
if (this.html2DRenderer) this.html2DRenderer.setSize(width, height);
|
|
74
|
-
if (this.html3DRenderer) this.html3DRenderer.setSize(width, height);
|
|
75
|
-
if (camera2 instanceof THREE.PerspectiveCamera) {
|
|
76
|
-
camera2.aspect = width / height;
|
|
77
|
-
} else if (camera2 instanceof THREE.OrthographicCamera) {
|
|
78
|
-
camera2.left = -width * 0.5;
|
|
79
|
-
camera2.right = width * 0.5;
|
|
80
|
-
camera2.top = height * 0.5;
|
|
81
|
-
camera2.bottom = -height * 0.5;
|
|
82
|
-
}
|
|
83
|
-
camera2.updateProjectionMatrix();
|
|
84
|
-
this.onResize && this.onResize(width, height);
|
|
85
|
-
this.dispatchEvent({ type: "resize", width, height });
|
|
86
|
-
});
|
|
87
|
-
this.resizeObserver.observe(dom);
|
|
88
|
-
}
|
|
89
|
-
this.renderer.setAnimationLoop(() => {
|
|
90
|
-
if (this.html2DRenderer) this.html2DRenderer.render(this.scene, this.camera);
|
|
91
|
-
if (this.html3DRenderer) this.html3DRenderer.render(this.scene, this.camera);
|
|
92
|
-
this.renderer.render(this.scene, this.camera);
|
|
93
|
-
if (this.orbitControls && this.orbitControls.enabled) this.orbitControls.update();
|
|
94
|
-
this.tweenTaskList.forEach((tween) => tween.update());
|
|
95
|
-
this.onUpdate && this.onUpdate();
|
|
96
|
-
this.parent?.components.forEach((c) => c.dispatchEvent({ type: "update" }));
|
|
97
|
-
});
|
|
98
|
-
this.scene.add(new THREE.AmbientLight(16777215, 0.5));
|
|
99
|
-
this.scene.background = new THREE.Color(3355443);
|
|
100
|
-
const directLight = new THREE.DirectionalLight(16777215, 4);
|
|
101
|
-
directLight.position.set(100, -100, 100);
|
|
102
|
-
this.scene.add(directLight);
|
|
103
|
-
camera.position.set(10, 10, 10);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* 世界坐标转屏幕坐标
|
|
107
|
-
* @param worldPosition
|
|
108
|
-
* @param camera
|
|
109
|
-
* @param renderer
|
|
110
|
-
* @returns
|
|
111
|
-
*/
|
|
112
|
-
worldToScreenPosition(worldPosition) {
|
|
113
|
-
const vector = new THREE.Vector3();
|
|
114
|
-
vector.copy(worldPosition);
|
|
115
|
-
vector.project(this.camera);
|
|
116
|
-
const x = (vector.x * 0.5 + 0.5) * this.renderer.domElement.clientWidth;
|
|
117
|
-
const z = (-vector.z * 0.5 + 0.5) * this.renderer.domElement.clientHeight;
|
|
118
|
-
return new THREE.Vector2(x, z);
|
|
119
|
-
}
|
|
120
|
-
cameraPositionRecord = [];
|
|
121
|
-
/**
|
|
122
|
-
* 相机
|
|
123
|
-
* @param position
|
|
124
|
-
* @param lookAt
|
|
125
|
-
* @param onEnd
|
|
126
|
-
*/
|
|
127
|
-
cameraTo(position, lookAt, onEnd) {
|
|
128
|
-
this.cameraPositionRecord.push([
|
|
129
|
-
this.camera.position.clone(),
|
|
130
|
-
this.camera.quaternion.clone()
|
|
131
|
-
]);
|
|
132
|
-
const tween = new TWEEN.Tween(this.camera.position);
|
|
133
|
-
tween.to(position, 600);
|
|
134
|
-
tween.start();
|
|
135
|
-
tween.onUpdate(() => {
|
|
136
|
-
this.camera.lookAt(lookAt);
|
|
137
|
-
});
|
|
138
|
-
tween.onComplete(() => {
|
|
139
|
-
const i = this.tweenTaskList.indexOf(tween);
|
|
140
|
-
this.tweenTaskList.splice(i, 1);
|
|
141
|
-
onEnd && onEnd();
|
|
142
|
-
});
|
|
143
|
-
this.tweenTaskList.push(tween);
|
|
144
|
-
}
|
|
145
|
-
cameraBack() {
|
|
146
|
-
if (this.cameraPositionRecord.length) {
|
|
147
|
-
const [pos, quat] = this.cameraPositionRecord.pop();
|
|
148
|
-
this.camera.position.copy(pos);
|
|
149
|
-
this.camera.quaternion.copy(quat);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* 创建点
|
|
154
|
-
* @param pos
|
|
155
|
-
*/
|
|
156
|
-
createPointMesh(pos, size = 0.02, parameters, parent = this.container) {
|
|
157
|
-
const box = new THREE.Mesh(
|
|
158
|
-
new THREE.SphereGeometry(size),
|
|
159
|
-
new THREE.MeshBasicMaterial(parameters)
|
|
160
|
-
);
|
|
161
|
-
if (pos instanceof Point) box.position.set(pos.x, pos.y, 0);
|
|
162
|
-
else if (pos instanceof THREE.Vector3) box.position.copy(pos);
|
|
163
|
-
parent.add(box);
|
|
164
|
-
return box;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 创建文本
|
|
168
|
-
* @param text
|
|
169
|
-
* @param pos
|
|
170
|
-
* @param style
|
|
171
|
-
*/
|
|
172
|
-
createText(text, pos, style, parent = this.container) {
|
|
173
|
-
const div = document.createElement("div");
|
|
174
|
-
div.innerHTML = text;
|
|
175
|
-
div.style.pointerEvents = "none";
|
|
176
|
-
Object.assign(div.style, { fontSize: "10px", color: "#ffffff", ...style });
|
|
177
|
-
const css2DObject = new Renderer.CSS2DObject(div);
|
|
178
|
-
if (pos instanceof Point) css2DObject.position.set(pos.x, pos.y, 0);
|
|
179
|
-
else if (pos instanceof THREE.Vector3) css2DObject.position.copy(pos);
|
|
180
|
-
parent.add(css2DObject);
|
|
181
|
-
return css2DObject;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 创建几何缓冲区
|
|
185
|
-
* @param map
|
|
186
|
-
* @param count
|
|
187
|
-
*/
|
|
188
|
-
createLineSegments(map, count, parameters, parent = this.container) {
|
|
189
|
-
const geometry = new THREE.BufferGeometry();
|
|
190
|
-
Object.keys(map).forEach((key) => {
|
|
191
|
-
const value = map[key];
|
|
192
|
-
geometry.setAttribute(key, new THREE.BufferAttribute(new Float32Array(value), value.length / count));
|
|
193
|
-
});
|
|
194
|
-
const lineSegmentList = new THREE.LineSegments(geometry, new THREE.LineBasicMaterial({ ...parameters }));
|
|
195
|
-
parent.add(lineSegmentList);
|
|
196
|
-
return lineSegmentList;
|
|
197
|
-
}
|
|
198
|
-
destroy() {
|
|
199
|
-
if (this.resizeObserver) {
|
|
200
|
-
this.renderer.dispose();
|
|
201
|
-
this.resizeObserver.disconnect();
|
|
202
|
-
this.resizeObserver = void 0;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
8
|
function drawLinePathToPng(points, width, height, color = "#fff", lineWidth = 2) {
|
|
207
9
|
const can = document.createElement("canvas"), ctx = can.getContext("2d");
|
|
208
10
|
can.width = width;
|
|
@@ -456,42 +258,6 @@ class DetailsPointRender extends Component {
|
|
|
456
258
|
renderer.camera.updateProjectionMatrix();
|
|
457
259
|
}
|
|
458
260
|
}
|
|
459
|
-
class DomContainer extends Component {
|
|
460
|
-
static name = "DomContainer";
|
|
461
|
-
domElement = document.createElement("div");
|
|
462
|
-
canvas = document.createElement("canvas");
|
|
463
|
-
html2DRenderer = document.createElement("div");
|
|
464
|
-
html3DRenderer = document.createElement("div");
|
|
465
|
-
constructor() {
|
|
466
|
-
super();
|
|
467
|
-
this.domElement.id = "build-dxf-container";
|
|
468
|
-
this.domElement.appendChild(this.canvas);
|
|
469
|
-
this.domElement.appendChild(this.html3DRenderer);
|
|
470
|
-
this.domElement.appendChild(this.html2DRenderer);
|
|
471
|
-
Object.assign(this.domElement.style, {
|
|
472
|
-
width: "100%",
|
|
473
|
-
height: "100%",
|
|
474
|
-
position: "relative",
|
|
475
|
-
userSelect: "none"
|
|
476
|
-
});
|
|
477
|
-
Object.assign(this.html3DRenderer.style, {
|
|
478
|
-
position: "absolute",
|
|
479
|
-
left: 0,
|
|
480
|
-
top: 0,
|
|
481
|
-
// zIndex: 9,
|
|
482
|
-
width: "100%",
|
|
483
|
-
height: "100%"
|
|
484
|
-
});
|
|
485
|
-
Object.assign(this.html2DRenderer.style, {
|
|
486
|
-
position: "absolute",
|
|
487
|
-
left: 0,
|
|
488
|
-
top: 0,
|
|
489
|
-
// zIndex: 10,
|
|
490
|
-
width: "100%",
|
|
491
|
-
height: "100%"
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
261
|
class OriginalLineRender extends Component {
|
|
496
262
|
static name = "OriginalLineRender";
|
|
497
263
|
Dxf = null;
|
|
@@ -618,172 +384,6 @@ class ModelDataRender extends Component {
|
|
|
618
384
|
variable?.addEventListener("currentKeyUp", (e) => e.value === "e" && variable.set("whiteModelVisible", !variable.whiteModelVisible));
|
|
619
385
|
}
|
|
620
386
|
}
|
|
621
|
-
class DomEventRegister extends Component {
|
|
622
|
-
static name = "DomEventRegister";
|
|
623
|
-
cancelDefaultBehaviorList = [];
|
|
624
|
-
pointer = new Vector2();
|
|
625
|
-
_isMouseEnter = false;
|
|
626
|
-
set isMouseEnter(isMouseEnter) {
|
|
627
|
-
if (this._isMouseEnter === isMouseEnter) return;
|
|
628
|
-
this._isMouseEnter = isMouseEnter;
|
|
629
|
-
}
|
|
630
|
-
get isMouseEnter() {
|
|
631
|
-
return this._isMouseEnter;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* 组件被添加到父组件上时调用
|
|
635
|
-
*/
|
|
636
|
-
onAddFromParent() {
|
|
637
|
-
this.initMouseMoveEventProxy();
|
|
638
|
-
this.initKeyEvent();
|
|
639
|
-
this.initWheelEvent();
|
|
640
|
-
this.autoBodyCursor();
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* 初始化鼠标事件代理(判断鼠标是否在domElement上)
|
|
644
|
-
*/
|
|
645
|
-
initMouseMoveEventProxy() {
|
|
646
|
-
const domContainer = this.parent?.findComponentByType(DomContainer), domElement = domContainer.domElement, variable = this.parent?.findComponentByType(Variable), globalMousemoveFun = (e) => {
|
|
647
|
-
const rect = domElement.getBoundingClientRect(), offsetX = e.clientX - rect.left, offsetY = e.clientY - rect.top;
|
|
648
|
-
if (offsetX >= 0 && offsetY >= 0 && offsetX <= rect.width && offsetY <= rect.height) {
|
|
649
|
-
this.pointer.set(offsetX, offsetY);
|
|
650
|
-
this.dispatchEvent({
|
|
651
|
-
type: "mousemove",
|
|
652
|
-
x: offsetX,
|
|
653
|
-
y: offsetY,
|
|
654
|
-
moveX: e.movementX,
|
|
655
|
-
moveY: e.movementY
|
|
656
|
-
});
|
|
657
|
-
this.isMouseEnter = true;
|
|
658
|
-
} else {
|
|
659
|
-
this.isMouseEnter = false;
|
|
660
|
-
}
|
|
661
|
-
}, globalMousedownFun = (e) => {
|
|
662
|
-
if (!this.isMouseEnter) return;
|
|
663
|
-
const rect = domElement.getBoundingClientRect();
|
|
664
|
-
variable.set("currentMouseDown", "mouse_" + e.button);
|
|
665
|
-
this.dispatchEvent({
|
|
666
|
-
type: "mousedown",
|
|
667
|
-
x: e.clientX - rect.left,
|
|
668
|
-
y: e.clientY - rect.top
|
|
669
|
-
});
|
|
670
|
-
}, globalMouseupFun = (e) => {
|
|
671
|
-
if (!this.isMouseEnter) return;
|
|
672
|
-
variable.set("currentMouseUp", "mouse_" + e.button);
|
|
673
|
-
};
|
|
674
|
-
document.addEventListener("mousemove", globalMousemoveFun);
|
|
675
|
-
document.addEventListener("mousedown", globalMousedownFun);
|
|
676
|
-
document.addEventListener("mouseup", globalMouseupFun);
|
|
677
|
-
this.addEventRecord("destory", () => {
|
|
678
|
-
document.removeEventListener("mousemove", globalMousemoveFun);
|
|
679
|
-
document.removeEventListener("mousedown", globalMousedownFun);
|
|
680
|
-
document.removeEventListener("mouseup", globalMouseupFun);
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* 初始化键盘事件
|
|
685
|
-
*/
|
|
686
|
-
initKeyEvent() {
|
|
687
|
-
const variable = this.parent?.findComponentByType(Variable);
|
|
688
|
-
document.body.tabIndex = 1;
|
|
689
|
-
const onKeyup = (e) => {
|
|
690
|
-
if (!this.isMouseEnter) return;
|
|
691
|
-
const key = e.key.toLocaleLowerCase();
|
|
692
|
-
variable.set("currentKeyUp", key);
|
|
693
|
-
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
694
|
-
const element = this.cancelDefaultBehaviorList[i];
|
|
695
|
-
if (element(e)) e.preventDefault();
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
document.body.addEventListener("keyup", onKeyup);
|
|
699
|
-
const onKeydown = (e) => {
|
|
700
|
-
if (!this.isMouseEnter) return;
|
|
701
|
-
const key = e.key.toLocaleLowerCase();
|
|
702
|
-
variable.set("currentKeyDown", key);
|
|
703
|
-
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
704
|
-
const element = this.cancelDefaultBehaviorList[i];
|
|
705
|
-
if (element(e)) e.preventDefault();
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
document.body.addEventListener("keydown", onKeydown);
|
|
709
|
-
const onFocus = () => variable.set("focus", true);
|
|
710
|
-
document.body.addEventListener("focus", onFocus);
|
|
711
|
-
const onBlur = () => variable.set("focus", false);
|
|
712
|
-
document.body.addEventListener("blur", onBlur);
|
|
713
|
-
this.addEventRecord("destory", () => {
|
|
714
|
-
document.body.removeEventListener("keyup", onKeyup);
|
|
715
|
-
document.body.removeEventListener("keydown", onKeydown);
|
|
716
|
-
document.body.removeEventListener("focus", onFocus);
|
|
717
|
-
document.body.removeEventListener("blur", onBlur);
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* 初始化滚轮事件
|
|
722
|
-
*/
|
|
723
|
-
initWheelEvent() {
|
|
724
|
-
const variable = this.parent?.findComponentByType(Variable);
|
|
725
|
-
const onWheel = (e) => variable.set("currentWheel", e.wheelDelta);
|
|
726
|
-
document.body.addEventListener("wheel", onWheel);
|
|
727
|
-
this.addEventRecord("destory", () => {
|
|
728
|
-
document.body.removeEventListener("wheel", onWheel);
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* 根据domElement的cursor自动设置body的cursor
|
|
733
|
-
*/
|
|
734
|
-
autoBodyCursor() {
|
|
735
|
-
const domContainer = this.parent?.findComponentByType(DomContainer), domElement = domContainer.domElement;
|
|
736
|
-
let bodyCursor = null;
|
|
737
|
-
this.addEventListener("update", () => {
|
|
738
|
-
if (this.isMouseEnter) {
|
|
739
|
-
if (bodyCursor === null) {
|
|
740
|
-
bodyCursor = document.body.style.cursor;
|
|
741
|
-
}
|
|
742
|
-
document.body.style.cursor = domElement.style.cursor;
|
|
743
|
-
} else {
|
|
744
|
-
if (bodyCursor !== null) {
|
|
745
|
-
document.body.style.cursor = bodyCursor;
|
|
746
|
-
bodyCursor = null;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
*
|
|
753
|
-
* @param callBack
|
|
754
|
-
*/
|
|
755
|
-
addCancelDefaultBehavior(callBack) {
|
|
756
|
-
this.cancelDefaultBehaviorList.push(callBack);
|
|
757
|
-
return this;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
*
|
|
761
|
-
* @param el
|
|
762
|
-
* @param callBack
|
|
763
|
-
* @param offset
|
|
764
|
-
* @param condition
|
|
765
|
-
*/
|
|
766
|
-
dragMoveHelper(el, callBack, offset = { x: 0, y: 0 }, condition = () => true) {
|
|
767
|
-
el.addEventListener("mousedown", () => {
|
|
768
|
-
if (!condition()) return;
|
|
769
|
-
const move = (e) => {
|
|
770
|
-
offset.x += e.movementX;
|
|
771
|
-
offset.y += e.movementY;
|
|
772
|
-
callBack({ ...offset }, e.movementX, e.movementY);
|
|
773
|
-
};
|
|
774
|
-
const end = () => {
|
|
775
|
-
document.removeEventListener("mousemove", move);
|
|
776
|
-
document.removeEventListener("mouseup", end);
|
|
777
|
-
};
|
|
778
|
-
document.addEventListener("mousemove", move);
|
|
779
|
-
document.addEventListener("mouseup", end);
|
|
780
|
-
});
|
|
781
|
-
callBack({ ...offset }, 0, 0);
|
|
782
|
-
}
|
|
783
|
-
destroy() {
|
|
784
|
-
this.canceEventRecord("destory");
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
387
|
class EventInput extends Component {
|
|
788
388
|
static name = "EventInput";
|
|
789
389
|
keyList = /* @__PURE__ */ new Set();
|
|
@@ -822,6 +422,8 @@ class EventInput extends Component {
|
|
|
822
422
|
this.mouseList.clear();
|
|
823
423
|
});
|
|
824
424
|
this.addEventListener("codeChange", this._computedkeyCombination.bind(this));
|
|
425
|
+
this.addKeyCombination("save", ["control", "s"]);
|
|
426
|
+
this.addCancelDefaultBehavior((input) => input.isOnlyKeyDowns(["control", "s"]));
|
|
825
427
|
}
|
|
826
428
|
/** 添加取消浏览器默认行为规则
|
|
827
429
|
* @param callBack
|