@mx-sose-front/mx-sose-graph 1.1.3 → 1.1.4
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/dist/index.d.ts +177 -9
- package/dist/index.esm.js +4569 -63119
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -39
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +10 -1
- package/src/components/ContextMenu/ContextMenu.vue +10 -10
- package/src/components/DiagramListTooltip/DiagramListTooltip.vue +7 -12
- package/src/components/InteractionLayer.vue +323 -157
- package/src/components/LineStyle/LineStyleMarker.vue +1 -1
- package/src/components/{NameEditor.vue → NameEditor/NameEditor.vue} +4 -4
- package/src/components/{SelectionBox.vue → SelectionBox/SelectionBox.vue} +5 -5
- package/src/components/Shape/Block.vue +1 -1
- package/src/constants/edgeShapeKeys.ts +43 -3
- package/src/constants/index.ts +19 -4
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useHighlight.ts +223 -0
- package/src/hooks/useNameEdit.ts +234 -0
- package/src/{utils/resizeUtils.ts → hooks/useResize.ts} +55 -155
- package/src/index.ts +4 -1
- package/src/render/shape-renderer.ts +59 -46
- package/src/statics/icons/createMenu/show.png +0 -0
- package/src/statics/icons/createMenu/tree.png +0 -0
- package/src/statics/icons/createMenu//345/261/225/347/244/272/347/253/257/345/217/243/345/261/236/346/200/247@3x.png +0 -0
- package/src/statics/icons/createMenu//345/261/225/347/244/272/350/277/236/347/272/277@3x.png +0 -0
- package/src/statics/icons/createMenu//346/211/200/345/234/250/345/233/276/350/241/250@3x.png +0 -0
- package/src/store/graphStore.ts +185 -65
- package/src/types/index.ts +4 -2
- package/src/types/interactionLayer.ts +1 -0
- package/src/utils/batchAutoExpand.ts +65 -0
- package/src/utils/compartment.ts +78 -4
- package/src/utils/containers.ts +24 -10
- package/src/utils/contextMenuUtils.ts +106 -147
- package/src/utils/drag.ts +10 -5
- package/src/utils/edgeUtils.ts +3 -4
- package/src/utils/graphDragService.ts +27 -23
- package/src/utils/iconLoader.ts +7 -7
- package/src/utils/keyboardUtils.ts +195 -32
- package/src/utils/pinUtils.ts +1 -2
- package/src/utils/shapeOps/shapeOps.ts +168 -0
- package/src/utils/viewportCulling.ts +193 -0
- package/src/view/graph.vue +115 -60
- package/src/utils/highlightUtils.ts +0 -162
- package/src/utils/nameEditUtils.ts +0 -137
- /package/src/statics/icons/createMenu/{scissors.png → cut.png} +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { ref, nextTick, type Ref } from 'vue';
|
|
2
|
-
import type { Shape } from '../types';
|
|
3
|
-
|
|
4
|
-
export interface NameEditOptions {
|
|
5
|
-
onNameChange?: (oldName: string, newName: string) => void;
|
|
6
|
-
validateName?: (name: string) => string | null; // 返回错误信息,null表示验证通过
|
|
7
|
-
onEditStart?: () => void;
|
|
8
|
-
onEditEnd?: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class NameEditManager {
|
|
12
|
-
private isEditing: Ref<boolean>;
|
|
13
|
-
private editingName: Ref<string>;
|
|
14
|
-
private nameInput: Ref<HTMLInputElement | undefined | null>;
|
|
15
|
-
private options: NameEditOptions;
|
|
16
|
-
|
|
17
|
-
constructor(options: NameEditOptions = {}) {
|
|
18
|
-
this.isEditing = ref(false);
|
|
19
|
-
this.editingName = ref('');
|
|
20
|
-
this.nameInput = ref<HTMLInputElement>();
|
|
21
|
-
this.options = options;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// 获取响应式状态
|
|
25
|
-
get editingState() {
|
|
26
|
-
return {
|
|
27
|
-
isEditingName: this.isEditing,
|
|
28
|
-
editingName: this.editingName,
|
|
29
|
-
nameInput: this.nameInput
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// 设置名称输入框引用
|
|
34
|
-
setNameInput(input: HTMLInputElement | null) {
|
|
35
|
-
this.nameInput.value = input;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 开始编辑名称
|
|
39
|
-
async startEdit(shape: Shape | null): Promise<void> {
|
|
40
|
-
if (!shape || this.isEditing.value) return;
|
|
41
|
-
|
|
42
|
-
this.isEditing.value = true;
|
|
43
|
-
this.editingName.value = shape.name;
|
|
44
|
-
|
|
45
|
-
// 触发开始编辑回调
|
|
46
|
-
this.options.onEditStart?.();
|
|
47
|
-
|
|
48
|
-
await nextTick();
|
|
49
|
-
|
|
50
|
-
// 聚焦并选中文本
|
|
51
|
-
this.nameInput.value?.focus();
|
|
52
|
-
this.nameInput.value?.select();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 完成编辑
|
|
56
|
-
finishEdit(shape: Shape | null): void {
|
|
57
|
-
if (!shape || !this.isEditing.value) return;
|
|
58
|
-
|
|
59
|
-
const newName = this.editingName.value.trim();
|
|
60
|
-
const oldName = shape.name;
|
|
61
|
-
|
|
62
|
-
if (newName && newName !== oldName) {
|
|
63
|
-
// 验证名称
|
|
64
|
-
const validationError = this.options.validateName?.(newName);
|
|
65
|
-
if (validationError) {
|
|
66
|
-
// 如果验证失败,可以显示错误提示
|
|
67
|
-
console.warn('名称验证失败:', validationError);
|
|
68
|
-
this.cancelEdit();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 调用名称变更回调
|
|
73
|
-
this.options.onNameChange?.(oldName, newName);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
this.isEditing.value = false;
|
|
77
|
-
this.editingName.value = '';
|
|
78
|
-
this.options.onEditEnd?.();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// 取消编辑
|
|
82
|
-
cancelEdit(): void {
|
|
83
|
-
this.isEditing.value = false;
|
|
84
|
-
this.editingName.value = '';
|
|
85
|
-
this.options.onEditEnd?.();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// 处理键盘事件
|
|
89
|
-
handleKeyUp(event: KeyboardEvent, shape: Shape | null): void {
|
|
90
|
-
if (event.key === 'Enter') {
|
|
91
|
-
this.finishEdit(shape);
|
|
92
|
-
} else if (event.key === 'Escape') {
|
|
93
|
-
this.cancelEdit();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// 处理失焦事件
|
|
98
|
-
handleBlur(shape: Shape | null): void {
|
|
99
|
-
this.finishEdit(shape);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// 判断是否可以编辑
|
|
103
|
-
canEdit(shape: Shape | null): boolean {
|
|
104
|
-
return !!shape &&
|
|
105
|
-
shape.shapeKey !== 'ConceptRole' &&
|
|
106
|
-
!this.isEditing.value;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 获取名称显示文本
|
|
110
|
-
getDisplayName(shape: Shape | null): string {
|
|
111
|
-
return shape?.name || '';
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 重置状态
|
|
115
|
-
reset(): void {
|
|
116
|
-
this.isEditing.value = false;
|
|
117
|
-
this.editingName.value = '';
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 便捷创建函数
|
|
122
|
-
export function createNameEditManager(options?: NameEditOptions): NameEditManager {
|
|
123
|
-
return new NameEditManager(options);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// 默认验证函数
|
|
127
|
-
export function defaultNameValidator(name: string): string | null {
|
|
128
|
-
if (!name.trim()) {
|
|
129
|
-
return '名称不能为空';
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (name.length > 100) {
|
|
133
|
-
return '名称长度不能超过100个字符';
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
File without changes
|