@tmagic/editor 1.5.3 → 1.5.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.
Files changed (36) hide show
  1. package/dist/tmagic-editor.js +454 -446
  2. package/dist/tmagic-editor.umd.cjs +453 -445
  3. package/package.json +7 -7
  4. package/src/components/CodeBlockEditor.vue +3 -3
  5. package/src/components/CodeParams.vue +2 -2
  6. package/src/components/ContentMenu.vue +13 -13
  7. package/src/components/FloatingBox.vue +9 -9
  8. package/src/components/Resizer.vue +2 -2
  9. package/src/components/ScrollBar.vue +6 -7
  10. package/src/components/ScrollViewer.vue +6 -6
  11. package/src/components/SplitView.vue +2 -2
  12. package/src/fields/DataSourceInput.vue +3 -3
  13. package/src/fields/DataSourceMethods.vue +4 -4
  14. package/src/hooks/use-code-block-edit.ts +5 -5
  15. package/src/initService.ts +104 -66
  16. package/src/layouts/CodeEditor.vue +6 -6
  17. package/src/layouts/Framework.vue +5 -5
  18. package/src/layouts/NavMenu.vue +6 -3
  19. package/src/layouts/page-bar/PageBar.vue +13 -13
  20. package/src/layouts/page-bar/PageBarScrollContainer.vue +12 -11
  21. package/src/layouts/props-panel/FormPanel.vue +6 -6
  22. package/src/layouts/props-panel/PropsPanel.vue +4 -2
  23. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +3 -3
  24. package/src/layouts/sidebar/layer/LayerMenu.vue +2 -2
  25. package/src/layouts/sidebar/layer/LayerPanel.vue +5 -4
  26. package/src/layouts/sidebar/layer/use-click.ts +4 -6
  27. package/src/layouts/workspace/viewer/NodeListMenu.vue +5 -5
  28. package/src/layouts/workspace/viewer/Stage.vue +13 -13
  29. package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
  30. package/src/layouts/workspace/viewer/ViewerMenu.vue +3 -3
  31. package/src/services/componentList.ts +2 -2
  32. package/src/services/dep.ts +8 -2
  33. package/src/services/stageOverlay.ts +2 -2
  34. package/src/services/ui.ts +2 -2
  35. package/src/utils/idle-task.ts +26 -10
  36. package/types/index.d.ts +7 -60
@@ -93,7 +93,7 @@ let vsDiffEditor: monaco.editor.IStandaloneDiffEditor | null = null;
93
93
 
94
94
  const values = ref('');
95
95
  const loading = ref(false);
96
- const codeEditor = useTemplateRef<HTMLDivElement>('codeEditor');
96
+ const codeEditorEl = useTemplateRef<HTMLDivElement>('codeEditor');
97
97
 
98
98
  const resizeObserver = new globalThis.ResizeObserver(
99
99
  throttle((): void => {
@@ -122,7 +122,7 @@ const getEditorValue = () =>
122
122
  (props.type === 'diff' ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || '';
123
123
 
124
124
  const init = async () => {
125
- if (!codeEditor.value) return;
125
+ if (!codeEditorEl.value) return;
126
126
 
127
127
  const options = {
128
128
  value: values.value,
@@ -132,9 +132,9 @@ const init = async () => {
132
132
  };
133
133
 
134
134
  if (props.type === 'diff') {
135
- vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
135
+ vsDiffEditor = monaco.editor.createDiffEditor(codeEditorEl.value, options);
136
136
  } else {
137
- vsEditor = monaco.editor.create(codeEditor.value, options);
137
+ vsEditor = monaco.editor.create(codeEditorEl.value, options);
138
138
  }
139
139
 
140
140
  setEditorValue(props.initValues, props.modifiedValues);
@@ -143,7 +143,7 @@ const init = async () => {
143
143
 
144
144
  emit('initd', vsEditor);
145
145
 
146
- codeEditor.value.addEventListener('keydown', (e) => {
146
+ codeEditorEl.value.addEventListener('keydown', (e) => {
147
147
  if (e.keyCode === 83 && (navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey)) {
148
148
  e.preventDefault();
149
149
  e.stopPropagation();
@@ -163,7 +163,7 @@ const init = async () => {
163
163
  });
164
164
  }
165
165
 
166
- resizeObserver.observe(codeEditor.value);
166
+ resizeObserver.observe(codeEditorEl.value);
167
167
  };
168
168
 
169
169
  watch(
@@ -90,8 +90,8 @@ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
90
90
  const codeOptions = inject('codeOptions', {});
91
91
  const { editorService, uiService } = inject<Services>('services') || {};
92
92
 
93
- const content = useTemplateRef<HTMLDivElement>('content');
94
- const splitView = useTemplateRef<InstanceType<typeof SplitView>>('splitView');
93
+ const contentEl = useTemplateRef<HTMLDivElement>('content');
94
+ const splitViewRef = useTemplateRef<InstanceType<typeof SplitView>>('splitView');
95
95
 
96
96
  const root = computed(() => editorService?.get('root'));
97
97
  const page = computed(() => editorService?.get('page'));
@@ -115,7 +115,7 @@ const columnWidth = ref<Partial<GetColumnWidth>>({
115
115
  });
116
116
 
117
117
  watch(pageLength, () => {
118
- splitView.value?.updateWidth();
118
+ splitViewRef.value?.updateWidth();
119
119
  });
120
120
 
121
121
  watch(
@@ -146,8 +146,8 @@ const resizerObserver = new ResizeObserver((entries) => {
146
146
  });
147
147
 
148
148
  onMounted(() => {
149
- if (content.value) {
150
- resizerObserver.observe(content.value);
149
+ if (contentEl.value) {
150
+ resizerObserver.observe(contentEl.value);
151
151
  }
152
152
  });
153
153
 
@@ -179,8 +179,10 @@ const buttons = computed(() => {
179
179
  return data;
180
180
  });
181
181
 
182
+ const navMenuEl = useTemplateRef<HTMLDivElement>('navMenu');
183
+
182
184
  const resizeObserver = new ResizeObserver(() => {
183
- const rect = navMenu.value?.getBoundingClientRect();
185
+ const rect = navMenuEl.value?.getBoundingClientRect();
184
186
  if (rect) {
185
187
  uiService?.set('navMenuRect', {
186
188
  left: rect.left,
@@ -190,10 +192,11 @@ const resizeObserver = new ResizeObserver(() => {
190
192
  });
191
193
  }
192
194
  });
193
- const navMenu = useTemplateRef<HTMLDivElement>('navMenu');
195
+
194
196
  onMounted(() => {
195
- navMenu.value && resizeObserver.observe(navMenu.value);
197
+ navMenuEl.value && resizeObserver.observe(navMenuEl.value);
196
198
  });
199
+
197
200
  onBeforeUnmount(() => {
198
201
  resizeObserver.disconnect();
199
202
  });
@@ -144,40 +144,40 @@ const remove = (node: MPage | MPageFragment) => {
144
144
  editorService?.remove(node);
145
145
  };
146
146
 
147
- const pageBarScrollContainer = useTemplateRef<InstanceType<typeof PageBarScrollContainer>>('pageBarScrollContainer');
148
- const pageBarItems = useTemplateRef<HTMLDivElement[]>('pageBarItems');
147
+ const pageBarScrollContainerRef = useTemplateRef<InstanceType<typeof PageBarScrollContainer>>('pageBarScrollContainer');
148
+ const pageBarItemEls = useTemplateRef<HTMLDivElement[]>('pageBarItems');
149
149
  watch(page, (page) => {
150
150
  if (
151
151
  !page ||
152
- !pageBarScrollContainer.value?.itemsContainerWidth ||
153
- !pageBarItems.value ||
154
- pageBarItems.value.length < 2
152
+ !pageBarScrollContainerRef.value?.itemsContainerWidth ||
153
+ !pageBarItemEls.value ||
154
+ pageBarItemEls.value.length < 2
155
155
  ) {
156
156
  return;
157
157
  }
158
158
 
159
- const firstItem = pageBarItems.value[0];
160
- const lastItem = pageBarItems.value[pageBarItems.value.length - 1];
159
+ const firstItem = pageBarItemEls.value[0];
160
+ const lastItem = pageBarItemEls.value[pageBarItemEls.value.length - 1];
161
161
 
162
162
  if (page.id === firstItem.dataset.pageId) {
163
- pageBarScrollContainer.value.scroll('start');
163
+ pageBarScrollContainerRef.value.scroll('start');
164
164
  } else if (page.id === lastItem.dataset.pageId) {
165
- pageBarScrollContainer.value.scroll('end');
165
+ pageBarScrollContainerRef.value.scroll('end');
166
166
  } else {
167
- const pageItem = pageBarItems.value.find((item) => item.dataset.pageId === page.id);
167
+ const pageItem = pageBarItemEls.value.find((item) => item.dataset.pageId === page.id);
168
168
  if (!pageItem) {
169
169
  return;
170
170
  }
171
171
 
172
172
  const pageItemRect = pageItem.getBoundingClientRect();
173
173
  const offsetLeft = pageItemRect.left - firstItem.getBoundingClientRect().left;
174
- const { itemsContainerWidth } = pageBarScrollContainer.value;
174
+ const { itemsContainerWidth } = pageBarScrollContainerRef.value;
175
175
 
176
176
  const left = itemsContainerWidth - offsetLeft - pageItemRect.width;
177
177
 
178
- const translateLeft = pageBarScrollContainer.value.getTranslateLeft();
178
+ const translateLeft = pageBarScrollContainerRef.value.getTranslateLeft();
179
179
  if (offsetLeft + translateLeft < 0 || offsetLeft + pageItemRect.width > itemsContainerWidth - translateLeft) {
180
- pageBarScrollContainer.value.scrollTo(left);
180
+ pageBarScrollContainerRef.value.scrollTo(left);
181
181
  }
182
182
  }
183
183
  });
@@ -46,7 +46,7 @@ const services = inject<Services>('services');
46
46
  const editorService = services?.editorService;
47
47
  const uiService = services?.uiService;
48
48
 
49
- const itemsContainer = useTemplateRef<HTMLElement>('itemsContainer');
49
+ const itemsContainerEl = useTemplateRef<HTMLElement>('itemsContainer');
50
50
  const canScroll = ref(false);
51
51
 
52
52
  const showAddPageButton = computed(() => uiService?.get('showAddPageButton'));
@@ -54,19 +54,21 @@ const showPageListButton = computed(() => uiService?.get('showPageListButton'));
54
54
 
55
55
  const itemsContainerWidth = ref(0);
56
56
 
57
+ const pageBarEl = useTemplateRef<HTMLDivElement>('pageBar');
58
+
57
59
  const setCanScroll = () => {
58
60
  // 减去新增、搜索、页面列表、左移、右移5个按钮的宽度
59
61
  // 37 = icon width 16 + padding 10 * 2 + border-right 1
60
62
  itemsContainerWidth.value =
61
- (pageBar.value?.clientWidth || 0) -
63
+ (pageBarEl.value?.clientWidth || 0) -
62
64
  37 * 2 -
63
65
  37 -
64
66
  (showAddPageButton.value ? 37 : 21) -
65
67
  (showPageListButton.value ? 37 : 0);
66
68
 
67
69
  nextTick(() => {
68
- if (itemsContainer.value) {
69
- canScroll.value = itemsContainer.value.scrollWidth - itemsContainerWidth.value > 1;
70
+ if (itemsContainerEl.value) {
71
+ canScroll.value = itemsContainerEl.value.scrollWidth - itemsContainerWidth.value > 1;
70
72
  }
71
73
  });
72
74
  };
@@ -75,9 +77,8 @@ const resizeObserver = new ResizeObserver(() => {
75
77
  setCanScroll();
76
78
  });
77
79
 
78
- const pageBar = useTemplateRef<HTMLDivElement>('pageBar');
79
80
  onMounted(() => {
80
- pageBar.value && resizeObserver.observe(pageBar.value);
81
+ pageBarEl.value && resizeObserver.observe(pageBarEl.value);
81
82
  });
82
83
 
83
84
  onBeforeUnmount(() => {
@@ -87,9 +88,9 @@ onBeforeUnmount(() => {
87
88
  let translateLeft = 0;
88
89
 
89
90
  const scroll = (type: 'left' | 'right' | 'start' | 'end') => {
90
- if (!itemsContainer.value || !canScroll.value) return;
91
+ if (!itemsContainerEl.value || !canScroll.value) return;
91
92
 
92
- const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
93
+ const maxScrollLeft = itemsContainerEl.value.scrollWidth - itemsContainerWidth.value;
93
94
 
94
95
  if (type === 'left') {
95
96
  scrollTo(translateLeft + 200);
@@ -103,8 +104,8 @@ const scroll = (type: 'left' | 'right' | 'start' | 'end') => {
103
104
  };
104
105
 
105
106
  const scrollTo = (value: number) => {
106
- if (!itemsContainer.value || !canScroll.value) return;
107
- const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
107
+ if (!itemsContainerEl.value || !canScroll.value) return;
108
+ const maxScrollLeft = itemsContainerEl.value.scrollWidth - itemsContainerWidth.value;
108
109
 
109
110
  if (value >= 0) {
110
111
  value = 0;
@@ -116,7 +117,7 @@ const scrollTo = (value: number) => {
116
117
 
117
118
  translateLeft = value;
118
119
 
119
- itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
120
+ itemsContainerEl.value.style.transform = `translate(${translateLeft}px, 0px)`;
120
121
  };
121
122
 
122
123
  watch(
@@ -88,12 +88,12 @@ const propsPanelSize = computed(() => services?.uiService.get('propsPanelSize')
88
88
  const { height: editorContentHeight } = useEditorContentHeight();
89
89
  const stage = computed(() => services?.editorService.get('stage'));
90
90
 
91
- const configForm = useTemplateRef<InstanceType<typeof MForm>>('configForm');
91
+ const configFormRef = useTemplateRef<InstanceType<typeof MForm>>('configForm');
92
92
 
93
93
  watchEffect(() => {
94
- if (configForm.value) {
95
- configForm.value.formState.stage = stage.value;
96
- configForm.value.formState.services = services;
94
+ if (configFormRef.value) {
95
+ configFormRef.value.formState.stage = stage.value;
96
+ configFormRef.value.formState.services = services;
97
97
  }
98
98
  });
99
99
 
@@ -104,7 +104,7 @@ onMounted(() => {
104
104
 
105
105
  const submit = async (v: FormValue, eventData: ContainerChangeEventData) => {
106
106
  try {
107
- const values = await configForm.value?.submitForm();
107
+ const values = await configFormRef.value?.submitForm();
108
108
  emit('submit', values, eventData);
109
109
  } catch (e: any) {
110
110
  emit('submit-error', e);
@@ -119,5 +119,5 @@ const saveCode = (values: any) => {
119
119
  emit('submit', props.codeValueKey ? { [props.codeValueKey]: values } : values);
120
120
  };
121
121
 
122
- defineExpose({ configForm, submit });
122
+ defineExpose({ configForm: configFormRef, submit });
123
123
  </script>
@@ -148,8 +148,10 @@ const errorHandler = (e: any) => {
148
148
  emit('form-error', e);
149
149
  };
150
150
 
151
- const mountedHandler = (e: InstanceType<typeof FormPanel>) => {
152
- emit('mounted', e);
151
+ const mountedHandler = () => {
152
+ if (propertyFormPanelRef.value) {
153
+ emit('mounted', propertyFormPanelRef.value);
154
+ }
153
155
  };
154
156
 
155
157
  const propsPanelEl = useTemplateRef('propsPanel');
@@ -89,10 +89,10 @@ const editable = computed(() => codeBlockService?.getEditStatus());
89
89
  const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } =
90
90
  useCodeBlockEdit(codeBlockService);
91
91
 
92
- const codeBlockList = useTemplateRef<InstanceType<typeof CodeBlockList>>('codeBlockList');
92
+ const codeBlockListRef = useTemplateRef<InstanceType<typeof CodeBlockList>>('codeBlockList');
93
93
 
94
94
  const filterTextChangeHandler = (val: string) => {
95
- codeBlockList.value?.filter(val);
95
+ codeBlockListRef.value?.filter(val);
96
96
  };
97
97
 
98
98
  eventBus?.on('edit-code', (id: string) => {
@@ -104,7 +104,7 @@ const {
104
104
  menuData: contentMenuData,
105
105
  contentMenuHideHandler,
106
106
  } = useContentMenu((id: string) => {
107
- codeBlockList.value?.deleteCode(id);
107
+ codeBlockListRef.value?.deleteCode(id);
108
108
  });
109
109
  const menuData = computed<(MenuButton | MenuComponent)[]>(() => props.customContentMenu(contentMenuData, 'code-block'));
110
110
  </script>
@@ -27,7 +27,7 @@ const emit = defineEmits<{
27
27
  }>();
28
28
 
29
29
  const services = inject<Services>('services');
30
- const menu = useTemplateRef<InstanceType<typeof ContentMenu>>('menu');
30
+ const menuRef = useTemplateRef<InstanceType<typeof ContentMenu>>('menu');
31
31
  const node = computed(() => services?.editorService.get('node'));
32
32
  const nodes = computed(() => services?.editorService.get('nodes'));
33
33
  const componentList = computed(() => services?.componentListService.getList() || []);
@@ -113,7 +113,7 @@ const menuData = computed<(MenuButton | MenuComponent)[]>(() =>
113
113
  );
114
114
 
115
115
  const show = (e: MouseEvent) => {
116
- menu.value?.show(e);
116
+ menuRef.value?.show(e);
117
117
  };
118
118
 
119
119
  defineExpose({
@@ -87,13 +87,13 @@ defineProps<{
87
87
  const services = inject<Services>('services');
88
88
  const editorService = services?.editorService;
89
89
 
90
- const tree = useTemplateRef<InstanceType<typeof Tree>>('tree');
90
+ const treeRef = useTemplateRef<InstanceType<typeof Tree>>('tree');
91
91
 
92
92
  const page = computed(() => editorService?.get('page'));
93
93
  const nodeData = computed<TreeNodeData[]>(() => (!page.value ? [] : [page.value]));
94
94
 
95
95
  const { nodeStatusMap } = useNodeStatus(services);
96
- const { isCtrlKeyDown } = useKeybinding(services, tree);
96
+ const { isCtrlKeyDown } = useKeybinding(services, treeRef);
97
97
 
98
98
  const filterNodeMethod = (v: string, data: MNode): boolean => {
99
99
  let name = '';
@@ -121,10 +121,11 @@ const collapseAllHandler = () => {
121
121
 
122
122
  const { handleDragStart, handleDragEnd, handleDragLeave, handleDragOver } = useDrag(services);
123
123
 
124
+ // 右键菜单
125
+ const menuRef = useTemplateRef<InstanceType<typeof LayerMenu>>('menu');
124
126
  const {
125
- menu,
126
127
  nodeClickHandler,
127
128
  nodeContentMenuHandler,
128
129
  highlightHandler: mouseenterHandler,
129
- } = useClick(services, isCtrlKeyDown, nodeStatusMap);
130
+ } = useClick(services, isCtrlKeyDown, nodeStatusMap, menuRef);
130
131
  </script>
@@ -1,4 +1,4 @@
1
- import { computed, type ComputedRef, nextTick, type Ref, useTemplateRef } from 'vue';
1
+ import { computed, type ComputedRef, nextTick, type Ref, type ShallowRef } from 'vue';
2
2
  import { throttle } from 'lodash-es';
3
3
 
4
4
  import { Id, MNode } from '@tmagic/core';
@@ -13,6 +13,7 @@ export const useClick = (
13
13
  services: Services | undefined,
14
14
  isCtrlKeyDown: Ref<boolean>,
15
15
  nodeStatusMap: ComputedRef<Map<Id, LayerNodeStatus> | undefined>,
16
+ menuRef: ShallowRef<InstanceType<typeof LayerMenu> | null>,
16
17
  ) => {
17
18
  const isMultiSelect = computed(() => isCtrlKeyDown.value && !services?.editorService.get('disabledMultiSelect'));
18
19
 
@@ -98,11 +99,8 @@ export const useClick = (
98
99
  });
99
100
  };
100
101
 
101
- // 右键菜单
102
- const menu = useTemplateRef<InstanceType<typeof LayerMenu>>('menu');
103
-
104
102
  return {
105
- menu,
103
+ menuRef,
106
104
 
107
105
  nodeClickHandler,
108
106
 
@@ -114,7 +112,7 @@ export const useClick = (
114
112
  nodeClickHandler(event, data);
115
113
  }
116
114
 
117
- menu.value?.show(event);
115
+ menuRef.value?.show(event);
118
116
  },
119
117
 
120
118
  highlightHandler,
@@ -39,8 +39,8 @@ const editorService = services?.editorService;
39
39
 
40
40
  const visible = ref(false);
41
41
  const buttonVisible = ref(false);
42
- const button = useTemplateRef<HTMLDivElement>('button');
43
- const box = useTemplateRef<InstanceType<typeof FloatingBox>>('box');
42
+ const buttonEl = useTemplateRef<HTMLDivElement>('button');
43
+ const boxRef = useTemplateRef<InstanceType<typeof FloatingBox>>('box');
44
44
 
45
45
  const stage = computed(() => editorService?.get('stage'));
46
46
  const page = computed(() => editorService?.get('page'));
@@ -99,14 +99,14 @@ const menuPosition = ref({
99
99
  });
100
100
 
101
101
  watch(visible, async (visible) => {
102
- if (!button.value || !visible) {
102
+ if (!buttonEl.value || !visible) {
103
103
  return;
104
104
  }
105
105
 
106
106
  await nextTick();
107
107
 
108
- const rect = button.value.getBoundingClientRect();
109
- const height = box.value?.target?.clientHeight || 0;
108
+ const rect = buttonEl.value.getBoundingClientRect();
109
+ const height = boxRef.value?.target?.clientHeight || 0;
110
110
 
111
111
  menuPosition.value = {
112
112
  left: rect.left + rect.width + 5,
@@ -14,7 +14,7 @@
14
14
  width: 60,
15
15
  height: 50,
16
16
  }"
17
- @click="stageWrap?.container?.focus()"
17
+ @click="stageWrapRef?.container?.focus()"
18
18
  >
19
19
  <div
20
20
  class="m-editor-stage-container"
@@ -95,9 +95,9 @@ const services = inject<Services>('services');
95
95
 
96
96
  const stageLoading = computed(() => services?.editorService.get('stageLoading') || false);
97
97
 
98
- const stageWrap = useTemplateRef<InstanceType<typeof ScrollViewer>>('stageWrap');
99
- const stageContainer = useTemplateRef<HTMLDivElement>('stageContainer');
100
- const menu = useTemplateRef<InstanceType<typeof ViewerMenu>>('menu');
98
+ const stageWrapRef = useTemplateRef<InstanceType<typeof ScrollViewer>>('stageWrap');
99
+ const stageContainerEl = useTemplateRef<HTMLDivElement>('stageContainer');
100
+ const menuRef = useTemplateRef<InstanceType<typeof ViewerMenu>>('menu');
101
101
 
102
102
  const nodes = computed(() => services?.editorService.get('nodes') || []);
103
103
  const isMultiSelect = computed(() => nodes.value.length > 1);
@@ -111,18 +111,18 @@ const node = computed(() => services?.editorService.get('node'));
111
111
  watchEffect(() => {
112
112
  if (stage || !page.value) return;
113
113
 
114
- if (!stageContainer.value) return;
114
+ if (!stageContainerEl.value) return;
115
115
  if (!(props.stageOptions?.runtimeUrl || props.stageOptions?.render) || !root.value) return;
116
116
 
117
117
  stage = useStage(props.stageOptions);
118
118
 
119
119
  stage.on('select', () => {
120
- stageWrap.value?.container?.focus();
120
+ stageWrapRef.value?.container?.focus();
121
121
  });
122
122
 
123
123
  services?.editorService.set('stage', markRaw(stage));
124
124
 
125
- stage.mount(stageContainer.value);
125
+ stage.mount(stageContainerEl.value);
126
126
 
127
127
  if (!node.value?.id) {
128
128
  return;
@@ -188,9 +188,9 @@ const resizeObserver = new ResizeObserver((entries) => {
188
188
  });
189
189
 
190
190
  onMounted(() => {
191
- if (stageWrap.value?.container) {
192
- resizeObserver.observe(stageWrap.value.container);
193
- services?.keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrap.value.container);
191
+ if (stageWrapRef.value?.container) {
192
+ resizeObserver.observe(stageWrapRef.value.container);
193
+ services?.keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrapRef.value.container);
194
194
  }
195
195
  });
196
196
 
@@ -206,7 +206,7 @@ const parseDSL = getEditorConfig('parseDSL');
206
206
 
207
207
  const contextmenuHandler = (e: MouseEvent) => {
208
208
  e.preventDefault();
209
- menu.value?.show(e);
209
+ menuRef.value?.show(e);
210
210
  };
211
211
 
212
212
  const dragoverHandler = (e: DragEvent) => {
@@ -239,10 +239,10 @@ const dropHandler = async (e: DragEvent) => {
239
239
  parent = services?.editorService.getNodeById(parentId, false) as MContainer;
240
240
  }
241
241
 
242
- if (parent && stageContainer.value && stage) {
242
+ if (parent && stageContainerEl.value && stage) {
243
243
  const layout = await services?.editorService.getLayout(parent);
244
244
 
245
- const containerRect = stageContainer.value.getBoundingClientRect();
245
+ const containerRect = stageContainerEl.value.getBoundingClientRect();
246
246
  const { scrollTop, scrollLeft } = stage.mask!;
247
247
  const { style = {} } = config.data;
248
248
 
@@ -19,7 +19,7 @@ const services = inject<Services>('services');
19
19
 
20
20
  const stageOptions = inject<StageOptions>('stageOptions');
21
21
 
22
- const stageOverlay = useTemplateRef<HTMLDivElement>('stageOverlay');
22
+ const stageOverlayEl = useTemplateRef<HTMLDivElement>('stageOverlay');
23
23
 
24
24
  const stageOverlayVisible = computed(() => services?.stageOverlayService.get('stageOverlayVisible'));
25
25
  const wrapWidth = computed(() => services?.stageOverlayService.get('wrapWidth') || 0);
@@ -42,7 +42,7 @@ watch(stage, (stage) => {
42
42
  }
43
43
  });
44
44
 
45
- watch(stageOverlay, (stageOverlay) => {
45
+ watch(stageOverlayEl, (stageOverlay) => {
46
46
  if (!services) return;
47
47
 
48
48
  const subStage = services.stageOverlayService.createStage(stageOptions);
@@ -31,7 +31,7 @@ const props = withDefaults(
31
31
 
32
32
  const services = inject<Services>('services');
33
33
  const editorService = services?.editorService;
34
- const menu = useTemplateRef<InstanceType<typeof ContentMenu>>('menu');
34
+ const menuRef = useTemplateRef<InstanceType<typeof ContentMenu>>('menu');
35
35
  const canCenter = ref(false);
36
36
 
37
37
  const node = computed(() => editorService?.get('node'));
@@ -52,7 +52,7 @@ const menuData = computed<(MenuButton | MenuComponent)[]>(() =>
52
52
  },
53
53
  },
54
54
  useCopyMenu(),
55
- usePasteMenu(menu),
55
+ usePasteMenu(menuRef),
56
56
  {
57
57
  type: 'divider',
58
58
  direction: 'horizontal',
@@ -136,7 +136,7 @@ watch(
136
136
  );
137
137
 
138
138
  const show = (e: MouseEvent) => {
139
- menu.value?.show(e);
139
+ menuRef.value?.show(e);
140
140
  };
141
141
 
142
142
  defineExpose({ show });
@@ -16,14 +16,14 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { reactive } from 'vue';
19
+ import { shallowReactive } from 'vue';
20
20
 
21
21
  import type { ComponentGroup, ComponentGroupState } from '@editor/type';
22
22
 
23
23
  import BaseService from './BaseService';
24
24
 
25
25
  class ComponentList extends BaseService {
26
- private state = reactive<ComponentGroupState>({
26
+ private state = shallowReactive<ComponentGroupState>({
27
27
  list: [],
28
28
  });
29
29
 
@@ -15,7 +15,7 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- import { reactive } from 'vue';
18
+ import { reactive, shallowReactive } from 'vue';
19
19
 
20
20
  import type { DepExtendedData, Id, MNode, Target, TargetNode } from '@tmagic/core';
21
21
  import { DepTargetType, Watcher } from '@tmagic/core';
@@ -29,6 +29,7 @@ export interface DepEvents {
29
29
  'add-target': [target: Target];
30
30
  'remove-target': [id: string | number];
31
31
  collected: [nodes: MNode[], deep: boolean];
32
+ 'ds-collected': [nodes: MNode[], deep: boolean];
32
33
  }
33
34
 
34
35
  interface State {
@@ -40,7 +41,7 @@ type StateKey = keyof State;
40
41
  const idleTask = new IdleTask<{ node: TargetNode; deep: boolean; target: Target }>();
41
42
 
42
43
  class Dep extends BaseService {
43
- private state = reactive<State>({
44
+ private state = shallowReactive<State>({
44
45
  collecting: false,
45
46
  });
46
47
 
@@ -96,6 +97,7 @@ class Dep extends BaseService {
96
97
  this.set('collecting', false);
97
98
 
98
99
  this.emit('collected', nodes, deep);
100
+ this.emit('ds-collected', nodes, deep);
99
101
  }
100
102
 
101
103
  public collectIdle(nodes: MNode[], depExtendedData: DepExtendedData = {}, deep = false, type?: DepTargetType) {
@@ -119,6 +121,9 @@ class Dep extends BaseService {
119
121
  this.set('collecting', false);
120
122
  resolve();
121
123
  });
124
+ idleTask.once('hight-level-finish', () => {
125
+ this.emit('ds-collected', nodes, deep);
126
+ });
122
127
  });
123
128
  }
124
129
 
@@ -185,6 +190,7 @@ class Dep extends BaseService {
185
190
  deep: false,
186
191
  target,
187
192
  },
193
+ target.type === DepTargetType.DATA_SOURCE,
188
194
  );
189
195
 
190
196
  if (deep && Array.isArray(node.items) && node.items.length) {
@@ -1,4 +1,4 @@
1
- import { reactive } from 'vue';
1
+ import { shallowReactive } from 'vue';
2
2
  import type { Writable } from 'type-fest';
3
3
 
4
4
  import StageCore from '@tmagic/stage';
@@ -17,7 +17,7 @@ const canUsePluginMethods = {
17
17
  type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
18
18
 
19
19
  class StageOverlay extends BaseService {
20
- private state: StageOverlayState = reactive({
20
+ private state: StageOverlayState = shallowReactive({
21
21
  wrapDiv: document.createElement('div'),
22
22
  sourceEl: null,
23
23
  contentEl: null,
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { reactive } from 'vue';
19
+ import { shallowReactive } from 'vue';
20
20
  import type { Writable } from 'type-fest';
21
21
 
22
22
  import { convertToNumber } from '@tmagic/utils';
@@ -26,7 +26,7 @@ import type { AsyncHookPlugin, StageRect, UiState } from '@editor/type';
26
26
 
27
27
  import BaseService from './BaseService';
28
28
 
29
- const state = reactive<UiState>({
29
+ const state = shallowReactive<UiState>({
30
30
  uiSelectMode: false,
31
31
  showSrc: false,
32
32
  showStylePanel: true,