build-dxf 0.0.19 → 0.0.20-10
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/README.md +30 -0
- package/package.json +1 -3
- package/src/build.d.ts +23 -1
- package/src/build.js +70 -16
- package/src/index.css +661 -1
- package/src/index.js +4 -2
- package/src/index2.js +9 -3681
- package/src/index3.js +1546 -410
- package/src/pages/Editor.vue.d.ts +3 -1
- package/src/selectLocalFile.js +444 -21
- package/src/utils/CommandManager/CommandFlow.d.ts +16 -0
- package/src/utils/CommandManager/CommandManager.d.ts +23 -0
- package/src/utils/ComponentManager/Component.d.ts +1 -0
- package/src/utils/ComponentManager/ComponentManager.d.ts +1 -1
- package/src/utils/DxfSystem/components/Dxf.d.ts +1 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/CommandFlowComponent.d.ts +13 -3
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/ConnectionLine.d.ts +33 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/Default.d.ts +5 -19
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DeleteSelectLine.d.ts +28 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DeleteSelectWindow.d.ts +33 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawDoorLine.d.ts +19 -3
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawLine.d.ts +22 -5
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawWindow.d.ts +22 -2
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/IntersectionConnectionLine.d.ts +33 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/MergeLine.d.ts +32 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/PointDrag.d.ts +16 -2
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/SelectAll.d.ts +30 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/VerticalCorrection.d.ts +63 -0
- package/src/utils/DxfSystem/plugin/Editor/components/Editor.d.ts +7 -0
- package/src/utils/DxfSystem/plugin/Editor/components/index.d.ts +1 -0
- package/src/utils/DxfSystem/plugin/Editor/index.d.ts +8 -1
- package/src/utils/DxfSystem/plugin/Editor/pages/EditorTool.vue.d.ts +5 -1
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/DomEventRegister.d.ts +28 -6
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/Renderer.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/RenderPlugin/index.d.ts +2 -1
- package/src/utils/Quadtree/LineSegment.d.ts +2 -1
- package/src/utils/Quadtree/Point.d.ts +2 -1
- package/src/components/Editor.vue.d.ts +0 -26
- package/src/pages/Editor02.vue.d.ts +0 -4
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
2
|
+
dom: HTMLDivElement;
|
|
3
|
+
}, HTMLDivElement>;
|
|
2
4
|
export default _default;
|
package/src/selectLocalFile.js
CHANGED
|
@@ -1,5 +1,206 @@
|
|
|
1
|
-
import { getCurrentInstance, inject, ref, computed, unref, shallowRef, watchEffect, readonly, getCurrentScope, onScopeDispose, onMounted, nextTick, isRef, warn, provide, defineComponent, createElementBlock, openBlock, mergeProps, renderSlot, createElementVNode, watch, toRef, onUnmounted, useSlots, Text, createBlock, resolveDynamicComponent, withCtx, createCommentVNode, Fragment, normalizeClass, reactive, toRaw, withDirectives, withModifiers, vModelCheckbox, createTextVNode, toDisplayString, normalizeStyle, toRefs } from "vue";
|
|
2
1
|
import * as THREE from "three";
|
|
2
|
+
import { Vector2 } from "three";
|
|
3
|
+
import { CSS3DObject, CSS3DSprite, CSS3DRenderer } from "three/addons/renderers/CSS3DRenderer.js";
|
|
4
|
+
import { CSS2DObject, CSS2DRenderer } from "three/addons/renderers/CSS2DRenderer.js";
|
|
5
|
+
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
6
|
+
import * as TWEEN from "@tweenjs/tween.js";
|
|
7
|
+
import { C as Component, P as Point, V as Variable } from "./build.js";
|
|
8
|
+
import { getCurrentInstance, inject, ref, computed, unref, shallowRef, watchEffect, readonly, getCurrentScope, onScopeDispose, onMounted, nextTick, isRef, warn, provide, defineComponent, createElementBlock, openBlock, mergeProps, renderSlot, createElementVNode, watch, toRef, onUnmounted, useSlots, Text, createBlock, resolveDynamicComponent, withCtx, createCommentVNode, Fragment, normalizeClass, reactive, toRaw, withDirectives, withModifiers, vModelCheckbox, createTextVNode, toDisplayString, normalizeStyle, toRefs } from "vue";
|
|
9
|
+
THREE.Object3D.DEFAULT_UP = new THREE.Vector3(0, 0, 1);
|
|
10
|
+
class Renderer extends Component {
|
|
11
|
+
static name = "Renderer";
|
|
12
|
+
static CSS2DObject = CSS2DObject;
|
|
13
|
+
static CSS3DObject = CSS3DObject;
|
|
14
|
+
static CSS3DSprite = CSS3DSprite;
|
|
15
|
+
static Group = THREE.Group;
|
|
16
|
+
static Object3D = THREE.Object3D;
|
|
17
|
+
static Mesh = THREE.Mesh;
|
|
18
|
+
static Line = THREE.Line;
|
|
19
|
+
static LineSegments = THREE.LineSegments;
|
|
20
|
+
static Points = THREE.Points;
|
|
21
|
+
scene;
|
|
22
|
+
camera;
|
|
23
|
+
renderer;
|
|
24
|
+
orbitControls;
|
|
25
|
+
resizeObserver;
|
|
26
|
+
description;
|
|
27
|
+
html2DRenderer;
|
|
28
|
+
html3DRenderer;
|
|
29
|
+
container = new THREE.Group();
|
|
30
|
+
onUpdate;
|
|
31
|
+
onResize;
|
|
32
|
+
tweenTaskList = [];
|
|
33
|
+
constructor(description) {
|
|
34
|
+
super();
|
|
35
|
+
this.description = description;
|
|
36
|
+
const {
|
|
37
|
+
scene = new THREE.Scene(),
|
|
38
|
+
camera = new THREE.PerspectiveCamera(45, 1, 0.01, 1e3)
|
|
39
|
+
} = description;
|
|
40
|
+
this.camera = camera;
|
|
41
|
+
this.scene = scene;
|
|
42
|
+
scene.add(this.container);
|
|
43
|
+
this.renderer = new THREE.WebGLRenderer({
|
|
44
|
+
canvas: this.description.canvas,
|
|
45
|
+
antialias: true
|
|
46
|
+
});
|
|
47
|
+
this.renderer.setPixelRatio(window.devicePixelRatio);
|
|
48
|
+
if (description.htmlRenderer) {
|
|
49
|
+
if (description.htmlRenderer["2d"]) {
|
|
50
|
+
this.html2DRenderer = new CSS2DRenderer();
|
|
51
|
+
Object.assign(this.html2DRenderer.domElement.style, { position: "absolute", left: "0px", top: "0px" });
|
|
52
|
+
description.htmlRenderer["2d"].appendChild(this.html2DRenderer.domElement);
|
|
53
|
+
}
|
|
54
|
+
if (description.htmlRenderer["3d"]) {
|
|
55
|
+
this.html3DRenderer = new CSS3DRenderer();
|
|
56
|
+
Object.assign(this.html3DRenderer.domElement.style, { position: "absolute", left: "0px", top: "0px" });
|
|
57
|
+
description.htmlRenderer["3d"].appendChild(this.html3DRenderer.domElement);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (description.orbitControls) {
|
|
61
|
+
this.orbitControls = new OrbitControls(this.camera, description.orbitControls.domElement);
|
|
62
|
+
Object.assign(this.orbitControls, description.orbitControls);
|
|
63
|
+
}
|
|
64
|
+
if (this.description.resizeObserver) {
|
|
65
|
+
const dom = this.description.resizeObserver;
|
|
66
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
67
|
+
const camera2 = this.camera;
|
|
68
|
+
const { width, height } = dom.getBoundingClientRect();
|
|
69
|
+
this.renderer.setSize(width, height);
|
|
70
|
+
if (this.html2DRenderer) this.html2DRenderer.setSize(width, height);
|
|
71
|
+
if (this.html3DRenderer) this.html3DRenderer.setSize(width, height);
|
|
72
|
+
if (this.orbitControls) {
|
|
73
|
+
if (camera2 instanceof THREE.PerspectiveCamera) {
|
|
74
|
+
camera2.aspect = width / height;
|
|
75
|
+
} else if (camera2 instanceof THREE.OrthographicCamera) {
|
|
76
|
+
camera2.left = -width * 0.5;
|
|
77
|
+
camera2.right = width * 0.5;
|
|
78
|
+
camera2.top = height * 0.5;
|
|
79
|
+
camera2.bottom = -height * 0.5;
|
|
80
|
+
}
|
|
81
|
+
camera2.updateProjectionMatrix();
|
|
82
|
+
}
|
|
83
|
+
this.onResize && this.onResize(width, height);
|
|
84
|
+
this.dispatchEvent({ type: "resize", width, height });
|
|
85
|
+
});
|
|
86
|
+
this.resizeObserver.observe(dom);
|
|
87
|
+
}
|
|
88
|
+
this.renderer.setAnimationLoop(() => {
|
|
89
|
+
if (this.html2DRenderer) this.html2DRenderer.render(this.scene, this.camera);
|
|
90
|
+
if (this.html3DRenderer) this.html3DRenderer.render(this.scene, this.camera);
|
|
91
|
+
this.renderer.render(this.scene, this.camera);
|
|
92
|
+
if (this.orbitControls && this.orbitControls.enabled) this.orbitControls.update();
|
|
93
|
+
this.tweenTaskList.forEach((tween) => tween.update());
|
|
94
|
+
this.onUpdate && this.onUpdate();
|
|
95
|
+
this.parent?.components.forEach((c) => c.dispatchEvent({ type: "update" }));
|
|
96
|
+
});
|
|
97
|
+
this.scene.add(new THREE.AmbientLight(16777215, 0.5));
|
|
98
|
+
this.scene.background = new THREE.Color(3355443);
|
|
99
|
+
const directLight = new THREE.DirectionalLight(16777215, 4);
|
|
100
|
+
directLight.position.set(100, -100, 100);
|
|
101
|
+
this.scene.add(directLight);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 世界坐标转屏幕坐标
|
|
105
|
+
* @param worldPosition
|
|
106
|
+
* @param camera
|
|
107
|
+
* @param renderer
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
worldToScreenPosition(worldPosition) {
|
|
111
|
+
const vector = new THREE.Vector3();
|
|
112
|
+
vector.copy(worldPosition);
|
|
113
|
+
vector.project(this.camera);
|
|
114
|
+
const x = (vector.x * 0.5 + 0.5) * this.renderer.domElement.clientWidth;
|
|
115
|
+
const z = (-vector.z * 0.5 + 0.5) * this.renderer.domElement.clientHeight;
|
|
116
|
+
return new THREE.Vector2(x, z);
|
|
117
|
+
}
|
|
118
|
+
cameraPositionRecord = [];
|
|
119
|
+
/**
|
|
120
|
+
* 相机
|
|
121
|
+
* @param position
|
|
122
|
+
* @param lookAt
|
|
123
|
+
* @param onEnd
|
|
124
|
+
*/
|
|
125
|
+
cameraTo(position, lookAt, onEnd) {
|
|
126
|
+
this.cameraPositionRecord.push([
|
|
127
|
+
this.camera.position.clone(),
|
|
128
|
+
this.camera.quaternion.clone()
|
|
129
|
+
]);
|
|
130
|
+
const tween = new TWEEN.Tween(this.camera.position);
|
|
131
|
+
tween.to(position, 600);
|
|
132
|
+
tween.start();
|
|
133
|
+
tween.onUpdate(() => {
|
|
134
|
+
this.camera.lookAt(lookAt);
|
|
135
|
+
});
|
|
136
|
+
tween.onComplete(() => {
|
|
137
|
+
const i = this.tweenTaskList.indexOf(tween);
|
|
138
|
+
this.tweenTaskList.splice(i, 1);
|
|
139
|
+
onEnd && onEnd();
|
|
140
|
+
});
|
|
141
|
+
this.tweenTaskList.push(tween);
|
|
142
|
+
}
|
|
143
|
+
cameraBack() {
|
|
144
|
+
if (this.cameraPositionRecord.length) {
|
|
145
|
+
const [pos, quat] = this.cameraPositionRecord.pop();
|
|
146
|
+
this.camera.position.copy(pos);
|
|
147
|
+
this.camera.quaternion.copy(quat);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 创建点
|
|
152
|
+
* @param pos
|
|
153
|
+
*/
|
|
154
|
+
createPointMesh(pos, size = 0.02, parameters, parent = this.container) {
|
|
155
|
+
const box = new THREE.Mesh(
|
|
156
|
+
new THREE.SphereGeometry(size),
|
|
157
|
+
new THREE.MeshBasicMaterial(parameters)
|
|
158
|
+
);
|
|
159
|
+
if (pos instanceof Point) box.position.set(pos.x, pos.y, 0);
|
|
160
|
+
else if (pos instanceof THREE.Vector3) box.position.copy(pos);
|
|
161
|
+
parent.add(box);
|
|
162
|
+
return box;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 创建文本
|
|
166
|
+
* @param text
|
|
167
|
+
* @param pos
|
|
168
|
+
* @param style
|
|
169
|
+
*/
|
|
170
|
+
createText(text, pos, style, parent = this.container) {
|
|
171
|
+
const div = document.createElement("div");
|
|
172
|
+
div.innerHTML = text;
|
|
173
|
+
div.style.pointerEvents = "none";
|
|
174
|
+
Object.assign(div.style, { fontSize: "10px", color: "#ffffff", ...style });
|
|
175
|
+
const css2DObject = new Renderer.CSS2DObject(div);
|
|
176
|
+
if (pos instanceof Point) css2DObject.position.set(pos.x, pos.y, 0);
|
|
177
|
+
else if (pos instanceof THREE.Vector3) css2DObject.position.copy(pos);
|
|
178
|
+
parent.add(css2DObject);
|
|
179
|
+
return css2DObject;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 创建几何缓冲区
|
|
183
|
+
* @param map
|
|
184
|
+
* @param count
|
|
185
|
+
*/
|
|
186
|
+
createLineSegments(map, count, parameters, parent = this.container) {
|
|
187
|
+
const geometry = new THREE.BufferGeometry();
|
|
188
|
+
Object.keys(map).forEach((key) => {
|
|
189
|
+
const value = map[key];
|
|
190
|
+
geometry.setAttribute(key, new THREE.BufferAttribute(new Float32Array(value), value.length / count));
|
|
191
|
+
});
|
|
192
|
+
const lineSegmentList = new THREE.LineSegments(geometry, new THREE.LineBasicMaterial({ ...parameters }));
|
|
193
|
+
parent.add(lineSegmentList);
|
|
194
|
+
return lineSegmentList;
|
|
195
|
+
}
|
|
196
|
+
destroy() {
|
|
197
|
+
if (this.resizeObserver) {
|
|
198
|
+
this.renderer.dispose();
|
|
199
|
+
this.resizeObserver.disconnect();
|
|
200
|
+
this.resizeObserver = void 0;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
3
204
|
const configProviderContextKey = Symbol();
|
|
4
205
|
const defaultNamespace = "el";
|
|
5
206
|
const statePrefix = "is-";
|
|
@@ -3667,6 +3868,225 @@ class Lines extends THREE.LineSegments {
|
|
|
3667
3868
|
});
|
|
3668
3869
|
}
|
|
3669
3870
|
}
|
|
3871
|
+
class DomContainer extends Component {
|
|
3872
|
+
static name = "DomContainer";
|
|
3873
|
+
domElement = document.createElement("div");
|
|
3874
|
+
canvas = document.createElement("canvas");
|
|
3875
|
+
html2DRenderer = document.createElement("div");
|
|
3876
|
+
html3DRenderer = document.createElement("div");
|
|
3877
|
+
constructor() {
|
|
3878
|
+
super();
|
|
3879
|
+
this.domElement.id = "build-dxf-container";
|
|
3880
|
+
this.domElement.appendChild(this.canvas);
|
|
3881
|
+
this.domElement.appendChild(this.html3DRenderer);
|
|
3882
|
+
this.domElement.appendChild(this.html2DRenderer);
|
|
3883
|
+
Object.assign(this.domElement.style, {
|
|
3884
|
+
width: "100%",
|
|
3885
|
+
height: "100%",
|
|
3886
|
+
position: "relative",
|
|
3887
|
+
userSelect: "none"
|
|
3888
|
+
});
|
|
3889
|
+
Object.assign(this.html3DRenderer.style, {
|
|
3890
|
+
position: "absolute",
|
|
3891
|
+
left: 0,
|
|
3892
|
+
top: 0,
|
|
3893
|
+
// zIndex: 9,
|
|
3894
|
+
width: "100%",
|
|
3895
|
+
height: "100%"
|
|
3896
|
+
});
|
|
3897
|
+
Object.assign(this.html2DRenderer.style, {
|
|
3898
|
+
position: "absolute",
|
|
3899
|
+
left: 0,
|
|
3900
|
+
top: 0,
|
|
3901
|
+
// zIndex: 10,
|
|
3902
|
+
width: "100%",
|
|
3903
|
+
height: "100%"
|
|
3904
|
+
});
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
class DomEventRegister extends Component {
|
|
3908
|
+
static name = "DomEventRegister";
|
|
3909
|
+
cancelDefaultBehaviorList = [];
|
|
3910
|
+
pointer = new Vector2();
|
|
3911
|
+
_isMouseEnter = false;
|
|
3912
|
+
set isMouseEnter(isMouseEnter) {
|
|
3913
|
+
if (this._isMouseEnter === isMouseEnter) return;
|
|
3914
|
+
this._isMouseEnter = isMouseEnter;
|
|
3915
|
+
}
|
|
3916
|
+
get isMouseEnter() {
|
|
3917
|
+
return this._isMouseEnter;
|
|
3918
|
+
}
|
|
3919
|
+
_mouseMoveEventProxylock = false;
|
|
3920
|
+
set mouseMoveEventProxylock(lock) {
|
|
3921
|
+
this._mouseMoveEventProxylock = lock;
|
|
3922
|
+
if (lock) {
|
|
3923
|
+
this._isMouseEnter = false;
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
get mouseMoveEventProxylock() {
|
|
3927
|
+
return this._mouseMoveEventProxylock;
|
|
3928
|
+
}
|
|
3929
|
+
/**
|
|
3930
|
+
* 组件被添加到父组件上时调用
|
|
3931
|
+
*/
|
|
3932
|
+
onAddFromParent() {
|
|
3933
|
+
this.initMouseMoveEventProxy();
|
|
3934
|
+
this.initKeyEvent();
|
|
3935
|
+
this.initWheelEvent();
|
|
3936
|
+
this.autoBodyCursor();
|
|
3937
|
+
}
|
|
3938
|
+
/**
|
|
3939
|
+
* 初始化鼠标事件代理(判断鼠标是否在domElement上)
|
|
3940
|
+
*/
|
|
3941
|
+
initMouseMoveEventProxy() {
|
|
3942
|
+
const domContainer = this.parent?.findComponentByType(DomContainer), domElement = domContainer.domElement, variable = this.parent?.findComponentByType(Variable), globalMousemoveFun = (e) => {
|
|
3943
|
+
if (this._mouseMoveEventProxylock) return;
|
|
3944
|
+
const rect = domElement.getBoundingClientRect(), offsetX = e.clientX - rect.left, offsetY = e.clientY - rect.top;
|
|
3945
|
+
if (offsetX >= 0 && offsetY >= 0 && offsetX <= rect.width && offsetY <= rect.height) {
|
|
3946
|
+
this.pointer.set(offsetX, offsetY);
|
|
3947
|
+
this.dispatchEvent({
|
|
3948
|
+
type: "mousemove",
|
|
3949
|
+
x: offsetX,
|
|
3950
|
+
y: offsetY,
|
|
3951
|
+
moveX: e.movementX,
|
|
3952
|
+
moveY: e.movementY
|
|
3953
|
+
});
|
|
3954
|
+
this.isMouseEnter = true;
|
|
3955
|
+
} else {
|
|
3956
|
+
this.isMouseEnter = false;
|
|
3957
|
+
}
|
|
3958
|
+
}, globalMousedownFun = (e) => {
|
|
3959
|
+
if (!this.isMouseEnter) return;
|
|
3960
|
+
const rect = domElement.getBoundingClientRect(), offsetX = e.clientX - rect.left, offsetY = e.clientY - rect.top;
|
|
3961
|
+
this.pointer.set(offsetX, offsetY);
|
|
3962
|
+
variable.set("currentMouseDown", "mouse_" + e.button);
|
|
3963
|
+
this.dispatchEvent({
|
|
3964
|
+
type: "mousedown",
|
|
3965
|
+
x: offsetX,
|
|
3966
|
+
y: offsetY
|
|
3967
|
+
});
|
|
3968
|
+
}, globalMouseupFun = (e) => {
|
|
3969
|
+
if (!this.isMouseEnter) return;
|
|
3970
|
+
variable.set("currentMouseUp", "mouse_" + e.button);
|
|
3971
|
+
};
|
|
3972
|
+
document.addEventListener("mousemove", globalMousemoveFun);
|
|
3973
|
+
document.addEventListener("mousedown", globalMousedownFun);
|
|
3974
|
+
document.addEventListener("mouseup", globalMouseupFun);
|
|
3975
|
+
this.addEventRecord("destory", () => {
|
|
3976
|
+
document.removeEventListener("mousemove", globalMousemoveFun);
|
|
3977
|
+
document.removeEventListener("mousedown", globalMousedownFun);
|
|
3978
|
+
document.removeEventListener("mouseup", globalMouseupFun);
|
|
3979
|
+
});
|
|
3980
|
+
}
|
|
3981
|
+
/**
|
|
3982
|
+
* 初始化键盘事件
|
|
3983
|
+
*/
|
|
3984
|
+
initKeyEvent() {
|
|
3985
|
+
const variable = this.parent?.findComponentByType(Variable);
|
|
3986
|
+
document.body.tabIndex = 1;
|
|
3987
|
+
const onKeyup = (e) => {
|
|
3988
|
+
if (!this.isMouseEnter) return;
|
|
3989
|
+
const key = e.key.toLocaleLowerCase();
|
|
3990
|
+
variable.set("currentKeyUp", key);
|
|
3991
|
+
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
3992
|
+
const element = this.cancelDefaultBehaviorList[i];
|
|
3993
|
+
if (element(e)) e.preventDefault();
|
|
3994
|
+
}
|
|
3995
|
+
};
|
|
3996
|
+
document.body.addEventListener("keyup", onKeyup);
|
|
3997
|
+
const onKeydown = (e) => {
|
|
3998
|
+
if (!this.isMouseEnter) return;
|
|
3999
|
+
const key = e.key.toLocaleLowerCase();
|
|
4000
|
+
variable.set("currentKeyDown", key);
|
|
4001
|
+
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
4002
|
+
const element = this.cancelDefaultBehaviorList[i];
|
|
4003
|
+
if (element(e)) e.preventDefault();
|
|
4004
|
+
}
|
|
4005
|
+
};
|
|
4006
|
+
document.body.addEventListener("keydown", onKeydown);
|
|
4007
|
+
const onFocus = () => variable.set("focus", true);
|
|
4008
|
+
document.body.addEventListener("focus", onFocus);
|
|
4009
|
+
const onBlur = () => variable.set("focus", false);
|
|
4010
|
+
document.body.addEventListener("blur", onBlur);
|
|
4011
|
+
this.addEventRecord("destory", () => {
|
|
4012
|
+
document.body.removeEventListener("keyup", onKeyup);
|
|
4013
|
+
document.body.removeEventListener("keydown", onKeydown);
|
|
4014
|
+
document.body.removeEventListener("focus", onFocus);
|
|
4015
|
+
document.body.removeEventListener("blur", onBlur);
|
|
4016
|
+
});
|
|
4017
|
+
}
|
|
4018
|
+
/**
|
|
4019
|
+
* 初始化滚轮事件
|
|
4020
|
+
*/
|
|
4021
|
+
initWheelEvent() {
|
|
4022
|
+
const variable = this.parent?.findComponentByType(Variable);
|
|
4023
|
+
const onWheel = (e) => variable.set("currentWheel", e.wheelDelta);
|
|
4024
|
+
document.body.addEventListener("wheel", onWheel);
|
|
4025
|
+
this.addEventRecord("destory", () => {
|
|
4026
|
+
document.body.removeEventListener("wheel", onWheel);
|
|
4027
|
+
});
|
|
4028
|
+
}
|
|
4029
|
+
/**
|
|
4030
|
+
* 根据domElement的cursor自动设置body的cursor
|
|
4031
|
+
*/
|
|
4032
|
+
autoBodyCursor() {
|
|
4033
|
+
const domContainer = this.parent?.findComponentByType(DomContainer), domElement = domContainer.domElement;
|
|
4034
|
+
let bodyCursor = null;
|
|
4035
|
+
this.addEventListener("update", () => {
|
|
4036
|
+
if (this._mouseMoveEventProxylock) return;
|
|
4037
|
+
if (this.isMouseEnter) {
|
|
4038
|
+
if (bodyCursor === null) {
|
|
4039
|
+
bodyCursor = document.body.style.cursor;
|
|
4040
|
+
}
|
|
4041
|
+
document.body.style.cursor = domElement.style.cursor;
|
|
4042
|
+
} else {
|
|
4043
|
+
if (bodyCursor !== null) {
|
|
4044
|
+
document.body.style.cursor = bodyCursor;
|
|
4045
|
+
bodyCursor = null;
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
});
|
|
4049
|
+
}
|
|
4050
|
+
/**
|
|
4051
|
+
*
|
|
4052
|
+
* @param callBack
|
|
4053
|
+
*/
|
|
4054
|
+
addCancelDefaultBehavior(callBack) {
|
|
4055
|
+
this.cancelDefaultBehaviorList.push(callBack);
|
|
4056
|
+
return this;
|
|
4057
|
+
}
|
|
4058
|
+
/**
|
|
4059
|
+
*
|
|
4060
|
+
* @param el
|
|
4061
|
+
* @param callBack
|
|
4062
|
+
* @param offset
|
|
4063
|
+
* @param condition
|
|
4064
|
+
*/
|
|
4065
|
+
static dragMoveHelper(el, callBack, offset = { x: 0, y: 0 }, condition = () => true) {
|
|
4066
|
+
function onMousedown() {
|
|
4067
|
+
if (!condition()) return;
|
|
4068
|
+
const move = (e) => {
|
|
4069
|
+
offset.x += e.movementX;
|
|
4070
|
+
offset.y += e.movementY;
|
|
4071
|
+
callBack({ ...offset }, e.movementX, e.movementY);
|
|
4072
|
+
};
|
|
4073
|
+
const end = () => {
|
|
4074
|
+
document.removeEventListener("mousemove", move);
|
|
4075
|
+
document.removeEventListener("mouseup", end);
|
|
4076
|
+
};
|
|
4077
|
+
document.addEventListener("mousemove", move);
|
|
4078
|
+
document.addEventListener("mouseup", end);
|
|
4079
|
+
}
|
|
4080
|
+
el.addEventListener("mousedown", onMousedown);
|
|
4081
|
+
callBack({ ...offset }, 0, 0);
|
|
4082
|
+
return () => {
|
|
4083
|
+
el.removeEventListener("mousedown", onMousedown);
|
|
4084
|
+
};
|
|
4085
|
+
}
|
|
4086
|
+
destroy() {
|
|
4087
|
+
this.canceEventRecord("destory");
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
3670
4090
|
function selectLocalFileFun() {
|
|
3671
4091
|
return new Promise((resolve) => {
|
|
3672
4092
|
const input = document.createElement("input");
|
|
@@ -3710,36 +4130,39 @@ const SelectLocalFile = Object.assign(selectLocalFileFun, {
|
|
|
3710
4130
|
}
|
|
3711
4131
|
});
|
|
3712
4132
|
export {
|
|
3713
|
-
|
|
4133
|
+
isElement as A,
|
|
4134
|
+
withInstallFunction as B,
|
|
4135
|
+
DomEventRegister as D,
|
|
3714
4136
|
ElButton as E,
|
|
3715
4137
|
Lines as L,
|
|
4138
|
+
Renderer as R,
|
|
3716
4139
|
SelectLocalFile as S,
|
|
3717
4140
|
TypeComponentsMap as T,
|
|
3718
4141
|
_export_sfc as _,
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
4142
|
+
DomContainer as a,
|
|
4143
|
+
ElCheckbox as b,
|
|
4144
|
+
isClient as c,
|
|
4145
|
+
tryOnMounted as d,
|
|
4146
|
+
identity as e,
|
|
4147
|
+
buildProps as f,
|
|
4148
|
+
definePropType as g,
|
|
4149
|
+
isNumber as h,
|
|
3727
4150
|
isString as i,
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
4151
|
+
addUnit as j,
|
|
4152
|
+
useEmptyValuesProps as k,
|
|
4153
|
+
useSizeProp as l,
|
|
4154
|
+
iconPropType as m,
|
|
3732
4155
|
noop as n,
|
|
3733
|
-
|
|
4156
|
+
useGlobalComponentSettings as o,
|
|
3734
4157
|
provideGlobalConfig as p,
|
|
3735
|
-
|
|
4158
|
+
ElIcon as q,
|
|
3736
4159
|
resolveUnref as r,
|
|
3737
|
-
|
|
4160
|
+
TypeComponents as s,
|
|
3738
4161
|
tryOnScopeDispose as t,
|
|
3739
4162
|
useNamespace as u,
|
|
3740
|
-
|
|
4163
|
+
useTimeoutFn as v,
|
|
3741
4164
|
withInstall as w,
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
4165
|
+
isString$1 as x,
|
|
4166
|
+
isFunction$1 as y,
|
|
4167
|
+
isBoolean as z
|
|
3745
4168
|
};
|
|
@@ -18,6 +18,22 @@ export declare class CommandFlow extends EventDispatcher<{
|
|
|
18
18
|
finally: {};
|
|
19
19
|
}> {
|
|
20
20
|
list: CommandFlowCallBack[];
|
|
21
|
+
rollbacklist: ((data?: any) => void)[];
|
|
22
|
+
revokeRollbacklist: ((data?: any) => void)[];
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param operation
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
21
28
|
add(operation: CommandFlowCallBack): this;
|
|
29
|
+
/** 添加回滚回调列表
|
|
30
|
+
* @param callBack
|
|
31
|
+
*/
|
|
32
|
+
addRollback(callBack: (data?: any) => void): this;
|
|
33
|
+
/** 添加撤回回滚回调列表
|
|
34
|
+
* @param callBack
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
addRevokeRollback(callBack: (data?: any) => void): this;
|
|
22
38
|
}
|
|
23
39
|
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { EventDispatcher } from '../ComponentManager';
|
|
2
2
|
import { CommandFlow } from './CommandFlow';
|
|
3
|
+
export type Operation = {
|
|
4
|
+
name: string;
|
|
5
|
+
data: any;
|
|
6
|
+
};
|
|
3
7
|
export declare class CommandManager extends EventDispatcher<{
|
|
4
8
|
startedBefore: {
|
|
5
9
|
name: string;
|
|
@@ -31,6 +35,12 @@ export declare class CommandManager extends EventDispatcher<{
|
|
|
31
35
|
finally: {
|
|
32
36
|
name: string;
|
|
33
37
|
};
|
|
38
|
+
rollback: {
|
|
39
|
+
name: string;
|
|
40
|
+
};
|
|
41
|
+
revokeRollback: {
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
34
44
|
}> {
|
|
35
45
|
commandFlowMap: Map<string, CommandFlow>;
|
|
36
46
|
lock: boolean;
|
|
@@ -40,6 +50,11 @@ export declare class CommandManager extends EventDispatcher<{
|
|
|
40
50
|
private _disabled;
|
|
41
51
|
set disabled(disabled: boolean);
|
|
42
52
|
get disabled(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 操作记录
|
|
55
|
+
*/
|
|
56
|
+
operationList: Operation[];
|
|
57
|
+
rollbackList: Operation[];
|
|
43
58
|
constructor();
|
|
44
59
|
/** 添加命令流
|
|
45
60
|
* @param name
|
|
@@ -56,4 +71,12 @@ export declare class CommandManager extends EventDispatcher<{
|
|
|
56
71
|
/** 取消当前命令
|
|
57
72
|
*/
|
|
58
73
|
cancel(): void;
|
|
74
|
+
/**
|
|
75
|
+
* 回滚
|
|
76
|
+
*/
|
|
77
|
+
rollback(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 撤销回滚
|
|
80
|
+
*/
|
|
81
|
+
revokeRollback(): boolean;
|
|
59
82
|
}
|
|
@@ -10,6 +10,7 @@ export declare class Component<TEventMap extends {} = {}> extends EventDispatche
|
|
|
10
10
|
update: {};
|
|
11
11
|
} & TEventMap> {
|
|
12
12
|
parent?: ComponentManager;
|
|
13
|
+
destroyed: boolean;
|
|
13
14
|
constructor(...arg: any[]);
|
|
14
15
|
onAddFromParent(parent: ComponentManager): void;
|
|
15
16
|
onRemoveFromParent(parent: ComponentManager): void;
|
|
@@ -32,7 +32,7 @@ export declare class ComponentManager<TEventMap extends {} = {}> extends EventDi
|
|
|
32
32
|
* 查找所有符合条件的组件
|
|
33
33
|
* @param callBack
|
|
34
34
|
*/
|
|
35
|
-
findComponents(predicate: (component: Component, index: number) => boolean): Component<{}>
|
|
35
|
+
findComponents(predicate: (component: Component, index: number) => boolean): Component<{}>[];
|
|
36
36
|
/**
|
|
37
37
|
*
|
|
38
38
|
* @param type
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Component } from '../../../../../ComponentManager';
|
|
1
|
+
import { Component, ComponentManager } from '../../../../../ComponentManager';
|
|
2
2
|
import { Editor } from '../Editor';
|
|
3
3
|
import { EventInput, Renderer } from '../../../RenderPlugin/components';
|
|
4
4
|
import { CommandManager } from '../../../../../CommandManager';
|
|
5
5
|
import { RenderManager } from '../RenderManager';
|
|
6
|
+
import { Default } from './Default';
|
|
6
7
|
export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Component<TEventMap> {
|
|
7
8
|
private _renderer?;
|
|
8
9
|
get renderer(): Renderer;
|
|
@@ -16,9 +17,18 @@ export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Com
|
|
|
16
17
|
get renderManager(): RenderManager;
|
|
17
18
|
private _commandManager?;
|
|
18
19
|
get commandManager(): CommandManager;
|
|
20
|
+
private _default?;
|
|
21
|
+
get default(): Default;
|
|
19
22
|
interruptKeys: string[];
|
|
23
|
+
commandName: string;
|
|
24
|
+
constructor();
|
|
25
|
+
onAddFromParent(parent: ComponentManager): void;
|
|
20
26
|
/**
|
|
21
|
-
*
|
|
27
|
+
* 取消
|
|
28
|
+
*/
|
|
29
|
+
cancel(): void;
|
|
30
|
+
/**
|
|
31
|
+
* 创建中断处理命令节点
|
|
22
32
|
* @returns
|
|
23
33
|
*/
|
|
24
34
|
createInterrupt(): (next: any, data: any) => void;
|
|
@@ -32,5 +42,5 @@ export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Com
|
|
|
32
42
|
* 创建清理
|
|
33
43
|
* @returns
|
|
34
44
|
*/
|
|
35
|
-
createFinally(): () => void;
|
|
45
|
+
createFinally(keys?: string[]): () => void;
|
|
36
46
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CommandFlowComponent } from './CommandFlowComponent';
|
|
2
|
+
import { ComponentManager } from '../../../../../ComponentManager';
|
|
3
|
+
/**
|
|
4
|
+
* 连接选择的线段
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConnectionLine extends CommandFlowComponent<{}> {
|
|
7
|
+
static name: string;
|
|
8
|
+
shortcutKeys: string[];
|
|
9
|
+
static commandName: string;
|
|
10
|
+
onAddFromParent(parent: ComponentManager): void;
|
|
11
|
+
/**
|
|
12
|
+
* 进入命令约束
|
|
13
|
+
*/
|
|
14
|
+
private constraint;
|
|
15
|
+
/** 连接
|
|
16
|
+
* @param next
|
|
17
|
+
*/
|
|
18
|
+
private connection;
|
|
19
|
+
/** 成功
|
|
20
|
+
* @param next
|
|
21
|
+
* @param selectLines
|
|
22
|
+
*/
|
|
23
|
+
private completed;
|
|
24
|
+
/** 回滚操作
|
|
25
|
+
* @param data
|
|
26
|
+
*/
|
|
27
|
+
private rollback;
|
|
28
|
+
/** 撤回回滚
|
|
29
|
+
* @param lines
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
private revokeRollback;
|
|
33
|
+
}
|