@tmagic/editor 1.5.12 → 1.5.13

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.12",
2
+ "version": "1.5.13",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -58,11 +58,11 @@
58
58
  "moveable": "^0.53.0",
59
59
  "serialize-javascript": "^6.0.0",
60
60
  "sortablejs": "^1.15.2",
61
- "@tmagic/design": "1.5.12",
62
- "@tmagic/form": "1.5.12",
63
- "@tmagic/stage": "1.5.12",
64
- "@tmagic/table": "1.5.12",
65
- "@tmagic/utils": "1.5.12"
61
+ "@tmagic/design": "1.5.13",
62
+ "@tmagic/stage": "1.5.13",
63
+ "@tmagic/form": "1.5.13",
64
+ "@tmagic/table": "1.5.13",
65
+ "@tmagic/utils": "1.5.13"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/events": "^3.0.0",
@@ -76,7 +76,7 @@
76
76
  "monaco-editor": "^0.48.0",
77
77
  "typescript": "*",
78
78
  "vue": ">=3.5.0",
79
- "@tmagic/core": "1.5.12"
79
+ "@tmagic/core": "1.5.13"
80
80
  },
81
81
  "peerDependenciesMeta": {
82
82
  "typescript": {
@@ -59,7 +59,7 @@
59
59
  </template>
60
60
 
61
61
  <script lang="ts" setup>
62
- import { computed, inject, Ref, ref, useTemplateRef } from 'vue';
62
+ import { computed, inject, nextTick, Ref, ref, useTemplateRef, watch } from 'vue';
63
63
 
64
64
  import type { CodeBlockContent } from '@tmagic/core';
65
65
  import { TMagicButton, TMagicDialog, tMagicMessage, tMagicMessageBox, TMagicTag } from '@tmagic/design';
@@ -95,6 +95,8 @@ const props = defineProps<{
95
95
 
96
96
  const emit = defineEmits<{
97
97
  submit: [values: CodeBlockContent, eventData: ContainerChangeEventData];
98
+ close: [];
99
+ open: [];
98
100
  }>();
99
101
 
100
102
  const { codeBlockService, uiService } = useServices();
@@ -261,6 +263,16 @@ const closedHandler = () => {
261
263
  const parentFloating = inject<Ref<HTMLDivElement | null>>('parentFloating', ref(null));
262
264
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
263
265
 
266
+ watch(boxVisible, (visible) => {
267
+ nextTick(() => {
268
+ if (!visible) {
269
+ emit('close');
270
+ } else {
271
+ emit('open');
272
+ }
273
+ });
274
+ });
275
+
264
276
  defineExpose({
265
277
  async show() {
266
278
  calcBoxPosition();
@@ -37,7 +37,7 @@
37
37
  </template>
38
38
 
39
39
  <script lang="ts" setup>
40
- import { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue';
40
+ import { computed, nextTick, onBeforeUnmount, onMounted, type Ref, ref, useTemplateRef } from 'vue';
41
41
 
42
42
  import { useZIndex } from '@tmagic/design';
43
43
 
@@ -73,7 +73,7 @@ const menuEl = useTemplateRef<HTMLDivElement>('menu');
73
73
  const buttonRefs = useTemplateRef<InstanceType<typeof ToolButton>[]>('buttons');
74
74
  const subMenuRef = useTemplateRef<any>('subMenu');
75
75
  const visible = ref(false);
76
- const subMenuData = ref<(MenuButton | MenuComponent)[]>([]);
76
+ const subMenuData: Ref<(MenuButton | MenuComponent)[]> = ref<(MenuButton | MenuComponent)[]>([]);
77
77
  const zIndex = useZIndex();
78
78
  const curZIndex = ref<number>(0);
79
79
 
@@ -173,6 +173,7 @@ const nodeContentMenuHandler = (event: MouseEvent, data: TreeNodeData) => {
173
173
  };
174
174
 
175
175
  defineExpose({
176
+ nodeStatusMap,
176
177
  filter: filterTextChangeHandler,
177
178
  deleteCode,
178
179
  });
@@ -32,6 +32,8 @@
32
32
  :disabled="!editable"
33
33
  :content="codeConfig"
34
34
  @submit="submitCodeBlockHandler"
35
+ @close="editDialogCloseHandler"
36
+ @open="editDialogOpenHandler"
35
37
  ></CodeBlockEditor>
36
38
 
37
39
  <Teleport to="body">
@@ -87,7 +89,7 @@ const { codeBlockService } = useServices();
87
89
 
88
90
  const editable = computed(() => codeBlockService.getEditStatus());
89
91
 
90
- const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } =
92
+ const { codeId, codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } =
91
93
  useCodeBlockEdit(codeBlockService);
92
94
 
93
95
  const codeBlockListRef = useTemplateRef<InstanceType<typeof CodeBlockList>>('codeBlockList');
@@ -100,6 +102,22 @@ eventBus?.on('edit-code', (id: string) => {
100
102
  editCode(id);
101
103
  });
102
104
 
105
+ const editDialogOpenHandler = () => {
106
+ if (codeBlockListRef.value) {
107
+ for (const [statusId, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
108
+ status.selected = statusId === codeId.value;
109
+ }
110
+ }
111
+ };
112
+
113
+ const editDialogCloseHandler = () => {
114
+ if (codeBlockListRef.value) {
115
+ for (const [, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
116
+ status.selected = false;
117
+ }
118
+ }
119
+ };
120
+
103
121
  const {
104
122
  nodeContentMenuHandler,
105
123
  menuData: contentMenuData,
@@ -22,7 +22,7 @@
22
22
  </template>
23
23
 
24
24
  <script setup lang="ts">
25
- import { inject, Ref, ref, watchEffect } from 'vue';
25
+ import { inject, nextTick, Ref, ref, watch, watchEffect } from 'vue';
26
26
 
27
27
  import type { DataSourceSchema } from '@tmagic/core';
28
28
  import { tMagicMessage } from '@tmagic/design';
@@ -48,6 +48,8 @@ const width = defineModel<number>('width', { default: 670 });
48
48
 
49
49
  const emit = defineEmits<{
50
50
  submit: [v: any, eventData: ContainerChangeEventData];
51
+ close: [];
52
+ open: [id: string];
51
53
  }>();
52
54
 
53
55
  const { uiService, dataSourceService } = useServices();
@@ -73,6 +75,16 @@ const errorHandler = (error: any) => {
73
75
  tMagicMessage.error(error.message);
74
76
  };
75
77
 
78
+ watch(boxVisible, (visible) => {
79
+ nextTick(() => {
80
+ if (!visible) {
81
+ emit('close');
82
+ } else if (initValues.value?.id) {
83
+ emit('open', initValues.value.id);
84
+ }
85
+ });
86
+ });
87
+
76
88
  defineExpose({
77
89
  show() {
78
90
  calcBoxPosition();
@@ -178,6 +178,7 @@ const nodeContentMenuHandler = (event: MouseEvent, data: TreeNodeData) => {
178
178
  };
179
179
 
180
180
  defineExpose({
181
+ nodeStatusMap,
181
182
  filter: filterTextChangeHandler,
182
183
  });
183
184
  </script>
@@ -45,6 +45,8 @@
45
45
  :values="dataSourceValues"
46
46
  :title="dialogTitle"
47
47
  @submit="submitDataSourceHandler"
48
+ @close="editDialogCloseHandler"
49
+ @open="editDialogOpenHandler"
48
50
  ></DataSourceConfigPanel>
49
51
 
50
52
  <Teleport to="body">
@@ -93,6 +95,22 @@ const { dataSourceService } = useServices();
93
95
  const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } =
94
96
  useDataSourceEdit(dataSourceService);
95
97
 
98
+ const editDialogOpenHandler = (id: string) => {
99
+ if (dataSourceList.value) {
100
+ for (const [statusId, status] of dataSourceList.value.nodeStatusMap.entries()) {
101
+ status.selected = statusId === id;
102
+ }
103
+ }
104
+ };
105
+
106
+ const editDialogCloseHandler = () => {
107
+ if (dataSourceList.value) {
108
+ for (const [, status] of dataSourceList.value.nodeStatusMap.entries()) {
109
+ status.selected = false;
110
+ }
111
+ }
112
+ };
113
+
96
114
  const datasourceTypeList = computed(() =>
97
115
  [
98
116
  { text: '基础', type: 'base' },