@tmagic/editor 1.5.0-beta.9 → 1.5.1

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 (99) hide show
  1. package/dist/{style.css → tmagic-editor.css} +228 -22
  2. package/dist/tmagic-editor.js +1670 -1012
  3. package/dist/tmagic-editor.umd.cjs +1705 -1048
  4. package/package.json +14 -12
  5. package/src/Editor.vue +24 -6
  6. package/src/components/CodeBlockEditor.vue +14 -8
  7. package/src/components/CodeParams.vue +5 -5
  8. package/src/components/ContentMenu.vue +18 -18
  9. package/src/components/FloatingBox.vue +3 -3
  10. package/src/components/Resizer.vue +4 -4
  11. package/src/components/ScrollBar.vue +3 -3
  12. package/src/components/ScrollViewer.vue +3 -3
  13. package/src/components/SplitView.vue +2 -2
  14. package/src/components/ToolButton.vue +2 -1
  15. package/src/editorProps.ts +6 -2
  16. package/src/fields/Code.vue +1 -2
  17. package/src/fields/CodeSelect.vue +13 -11
  18. package/src/fields/CodeSelectCol.vue +32 -5
  19. package/src/fields/CondOpSelect.vue +5 -2
  20. package/src/fields/DataSourceFields.vue +31 -12
  21. package/src/fields/DataSourceInput.vue +2 -2
  22. package/src/fields/DataSourceMethods.vue +72 -14
  23. package/src/fields/DataSourceMocks.vue +0 -1
  24. package/src/fields/DisplayConds.vue +8 -3
  25. package/src/fields/EventSelect.vue +28 -12
  26. package/src/fields/KeyValue.vue +17 -12
  27. package/src/fields/UISelect.vue +6 -3
  28. package/src/hooks/index.ts +0 -1
  29. package/src/hooks/use-code-block-edit.ts +3 -3
  30. package/src/hooks/use-data-source-edit.ts +3 -2
  31. package/src/hooks/use-filter.ts +1 -1
  32. package/src/hooks/use-getso.ts +7 -7
  33. package/src/hooks/use-node-status.ts +2 -2
  34. package/src/index.ts +2 -1
  35. package/src/initService.ts +177 -74
  36. package/src/layouts/CodeEditor.vue +2 -2
  37. package/src/layouts/Framework.vue +13 -12
  38. package/src/layouts/NavMenu.vue +2 -2
  39. package/src/layouts/page-bar/AddButton.vue +29 -9
  40. package/src/layouts/page-bar/PageBar.vue +79 -66
  41. package/src/layouts/page-bar/PageBarScrollContainer.vue +84 -98
  42. package/src/layouts/page-bar/PageList.vue +5 -3
  43. package/src/layouts/page-bar/Search.vue +67 -0
  44. package/src/layouts/props-panel/FormPanel.vue +123 -0
  45. package/src/layouts/props-panel/PropsPanel.vue +146 -0
  46. package/src/layouts/props-panel/use-style-panel.ts +29 -0
  47. package/src/layouts/sidebar/Sidebar.vue +7 -1
  48. package/src/layouts/sidebar/code-block/CodeBlockList.vue +18 -2
  49. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +35 -4
  50. package/src/layouts/sidebar/code-block/useContentMenu.ts +83 -0
  51. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +7 -5
  52. package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -8
  53. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +40 -4
  54. package/src/layouts/sidebar/data-source/useContentMenu.ts +81 -0
  55. package/src/layouts/sidebar/layer/LayerMenu.vue +7 -13
  56. package/src/layouts/sidebar/layer/LayerPanel.vue +11 -4
  57. package/src/layouts/sidebar/layer/use-click.ts +2 -2
  58. package/src/layouts/sidebar/layer/use-keybinding.ts +2 -2
  59. package/src/layouts/sidebar/layer/use-node-status.ts +2 -3
  60. package/src/layouts/workspace/Workspace.vue +13 -3
  61. package/src/layouts/workspace/viewer/NodeListMenu.vue +3 -3
  62. package/src/layouts/workspace/viewer/Stage.vue +41 -11
  63. package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
  64. package/src/layouts/workspace/viewer/ViewerMenu.vue +4 -6
  65. package/src/services/dataSource.ts +12 -5
  66. package/src/services/dep.ts +61 -13
  67. package/src/services/editor.ts +46 -51
  68. package/src/services/storage.ts +2 -1
  69. package/src/services/ui.ts +1 -0
  70. package/src/theme/common/var.scss +12 -10
  71. package/src/theme/component-list-panel.scss +9 -7
  72. package/src/theme/content-menu.scss +7 -5
  73. package/src/theme/data-source.scss +3 -1
  74. package/src/theme/floating-box.scss +4 -2
  75. package/src/theme/framework.scss +7 -5
  76. package/src/theme/index.scss +4 -5
  77. package/src/theme/key-value.scss +2 -2
  78. package/src/theme/layer-panel.scss +3 -1
  79. package/src/theme/layout.scss +1 -1
  80. package/src/theme/nav-menu.scss +7 -5
  81. package/src/theme/page-bar.scss +51 -27
  82. package/src/theme/props-panel.scss +81 -1
  83. package/src/theme/resizer.scss +1 -1
  84. package/src/theme/search-input.scss +1 -0
  85. package/src/theme/sidebar.scss +4 -2
  86. package/src/theme/stage.scss +3 -1
  87. package/src/theme/theme.scss +28 -28
  88. package/src/theme/tree.scss +14 -12
  89. package/src/type.ts +10 -1
  90. package/src/utils/content-menu.ts +2 -2
  91. package/src/utils/data-source/formConfigs/http.ts +2 -0
  92. package/src/utils/data-source/index.ts +2 -2
  93. package/src/utils/editor.ts +78 -22
  94. package/src/utils/idle-task.ts +36 -4
  95. package/src/utils/props.ts +48 -6
  96. package/types/index.d.ts +2312 -2080
  97. package/src/hooks/use-data-source-method.ts +0 -100
  98. package/src/layouts/PropsPanel.vue +0 -131
  99. package/src/layouts/page-bar/SwitchTypeButton.vue +0 -45
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.0-beta.9",
2
+ "version": "1.5.1",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -32,6 +32,7 @@
32
32
  "node": ">=18"
33
33
  },
34
34
  "repository": {
35
+ "directory": "packages/editor",
35
36
  "type": "git",
36
37
  "url": "https://github.com/Tencent/tmagic-editor.git"
37
38
  },
@@ -48,6 +49,7 @@
48
49
  "@element-plus/icons-vue": "^2.3.1",
49
50
  "buffer": "^6.0.3",
50
51
  "color": "^3.1.3",
52
+ "deep-object-diff": "^1.1.9",
51
53
  "emmet-monaco-es": "^5.3.0",
52
54
  "events": "^3.3.0",
53
55
  "gesto": "^1.19.1",
@@ -56,11 +58,11 @@
56
58
  "moveable": "^0.53.0",
57
59
  "serialize-javascript": "^6.0.0",
58
60
  "sortablejs": "^1.15.2",
59
- "@tmagic/table": "1.5.0-beta.9",
60
- "@tmagic/design": "1.5.0-beta.9",
61
- "@tmagic/form": "1.5.0-beta.9",
62
- "@tmagic/stage": "1.5.0-beta.9",
63
- "@tmagic/utils": "1.5.0-beta.9"
61
+ "@tmagic/design": "1.5.1",
62
+ "@tmagic/stage": "1.5.1",
63
+ "@tmagic/form": "1.5.1",
64
+ "@tmagic/table": "1.5.1",
65
+ "@tmagic/utils": "1.5.1"
64
66
  },
65
67
  "devDependencies": {
66
68
  "@types/events": "^3.0.0",
@@ -68,20 +70,20 @@
68
70
  "@types/node": "^18.19.0",
69
71
  "@types/serialize-javascript": "^5.0.1",
70
72
  "@types/sortablejs": "^1.15.8",
71
- "@vitejs/plugin-vue": "^5.1.3",
72
- "@vue/compiler-sfc": "^3.5.0",
73
+ "@vitejs/plugin-vue": "^5.2.1",
74
+ "@vue/compiler-sfc": "^3.5.12",
73
75
  "@vue/test-utils": "^2.4.6",
74
76
  "rimraf": "^3.0.2",
75
- "sass": "^1.78.0",
77
+ "sass": "^1.83.0",
76
78
  "tsc-alias": "^1.8.5",
77
79
  "type-fest": "^4.10.3",
78
- "vite": "^5.4.3"
80
+ "vite": "^6.0.3"
79
81
  },
80
82
  "peerDependencies": {
81
83
  "monaco-editor": "^0.48.0",
82
84
  "typescript": "*",
83
- "vue": "^3.5.0",
84
- "@tmagic/core": "1.5.0-beta.9"
85
+ "vue": ">=3.5.0",
86
+ "@tmagic/core": "1.5.1"
85
87
  },
86
88
  "peerDependenciesMeta": {
87
89
  "typescript": {
package/src/Editor.vue CHANGED
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <Framework :disabled-page-fragment="disabledPageFragment" :page-bar-sort-options="pageBarSortOptions">
2
+ <Framework
3
+ :disabled-page-fragment="disabledPageFragment"
4
+ :page-bar-sort-options="pageBarSortOptions"
5
+ :page-filter-function="pageFilterFunction"
6
+ >
3
7
  <template #header>
4
8
  <slot name="header"></slot>
5
9
  </template>
@@ -92,9 +96,9 @@
92
96
  <PropsPanel
93
97
  :extend-state="extendFormState"
94
98
  :disabled-show-src="disabledShowSrc"
95
- @mounted="(instance: any) => $emit('props-panel-mounted', instance)"
96
- @form-error="(e: any) => $emit('props-form-error', e)"
97
- @submit-error="(e: any) => $emit('props-submit-error', e)"
99
+ @mounted="propsPanelMountedHandler"
100
+ @form-error="propsPanelFormErrorHandler"
101
+ @submit-error="propsPanelSubmitErrorHandler"
98
102
  >
99
103
  <template #props-panel-header>
100
104
  <slot name="props-panel-header"></slot>
@@ -114,6 +118,7 @@
114
118
  </template>
115
119
 
116
120
  <template #page-bar><slot name="page-bar"></slot></template>
121
+ <template #page-bar-add-button><slot name="page-bar-add-button"></slot></template>
117
122
  <template #page-bar-title="{ page }"><slot name="page-bar-title" :page="page"></slot></template>
118
123
  <template #page-bar-popover="{ page }"><slot name="page-bar-popover" :page="page"></slot></template>
119
124
  <template #page-list-popover="{ list }"><slot name="page-list-popover" :list="list"></slot></template>
@@ -129,7 +134,8 @@ import type { MApp } from '@tmagic/core';
129
134
 
130
135
  import Framework from './layouts/Framework.vue';
131
136
  import TMagicNavMenu from './layouts/NavMenu.vue';
132
- import PropsPanel from './layouts/PropsPanel.vue';
137
+ import FormPanel from './layouts/props-panel/FormPanel.vue';
138
+ import PropsPanel from './layouts/props-panel/PropsPanel.vue';
133
139
  import Sidebar from './layouts/sidebar/Sidebar.vue';
134
140
  import Workspace from './layouts/workspace/Workspace.vue';
135
141
  import codeBlockService from './services/codeBlock';
@@ -172,7 +178,7 @@ defineOptions({
172
178
  });
173
179
 
174
180
  const emit = defineEmits<{
175
- 'props-panel-mounted': [instance: InstanceType<typeof PropsPanel>];
181
+ 'props-panel-mounted': [instance: InstanceType<typeof FormPanel>];
176
182
  'update:modelValue': [value: MApp | null];
177
183
  'props-form-error': [e: any];
178
184
  'props-submit-error': [e: any];
@@ -226,5 +232,17 @@ provide('stageOptions', stageOptions);
226
232
 
227
233
  provide<EventBus>('eventBus', new EventEmitter());
228
234
 
235
+ const propsPanelMountedHandler = (e: InstanceType<typeof FormPanel>) => {
236
+ emit('props-panel-mounted', e);
237
+ };
238
+
239
+ const propsPanelSubmitErrorHandler = (e: any) => {
240
+ emit('props-submit-error', e);
241
+ };
242
+
243
+ const propsPanelFormErrorHandler = (e: any) => {
244
+ emit('props-form-error', e);
245
+ };
246
+
229
247
  defineExpose(services);
230
248
  </script>
@@ -59,11 +59,17 @@
59
59
  </template>
60
60
 
61
61
  <script lang="ts" setup>
62
- import { computed, inject, Ref, ref } from 'vue';
62
+ import { computed, inject, Ref, ref, useTemplateRef } from 'vue';
63
63
 
64
64
  import type { CodeBlockContent } from '@tmagic/core';
65
65
  import { TMagicButton, TMagicDialog, tMagicMessage, tMagicMessageBox, TMagicTag } from '@tmagic/design';
66
- import { type FormConfig, type FormState, MFormBox, type TableColumnConfig } from '@tmagic/form';
66
+ import {
67
+ type ContainerChangeEventData,
68
+ type FormConfig,
69
+ type FormState,
70
+ MFormBox,
71
+ type TableColumnConfig,
72
+ } from '@tmagic/form';
67
73
 
68
74
  import FloatingBox from '@editor/components/FloatingBox.vue';
69
75
  import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
@@ -88,7 +94,7 @@ const props = defineProps<{
88
94
  }>();
89
95
 
90
96
  const emit = defineEmits<{
91
- submit: [values: CodeBlockContent];
97
+ submit: [values: CodeBlockContent, eventData: ContainerChangeEventData];
92
98
  }>();
93
99
 
94
100
  const services = inject<Services>('services');
@@ -98,7 +104,7 @@ const { height: codeBlockEditorHeight } = useEditorContentHeight();
98
104
  const difVisible = ref(false);
99
105
  const { rect: windowRect } = useWindowRect();
100
106
 
101
- const magicVsEditor = ref<InstanceType<typeof CodeEditor>>();
107
+ const magicVsEditor = useTemplateRef<InstanceType<typeof CodeEditor>>('magicVsEditor');
102
108
 
103
109
  const diffChange = () => {
104
110
  if (!magicVsEditor.value || !formBox.value?.form) {
@@ -209,16 +215,16 @@ const functionConfig = computed<FormConfig>(() => [
209
215
  },
210
216
  ]);
211
217
 
212
- const submitForm = (values: CodeBlockContent) => {
218
+ const submitForm = (values: CodeBlockContent, data: ContainerChangeEventData) => {
213
219
  changedValue.value = undefined;
214
- emit('submit', values);
220
+ emit('submit', values, data);
215
221
  };
216
222
 
217
223
  const errorHandler = (error: any) => {
218
224
  tMagicMessage.error(error.message);
219
225
  };
220
226
 
221
- const formBox = ref<InstanceType<typeof MFormBox>>();
227
+ const formBox = useTemplateRef<InstanceType<typeof MFormBox>>('formBox');
222
228
 
223
229
  const changedValue = ref<CodeBlockContent>();
224
230
  const changeHandler = (values: CodeBlockContent) => {
@@ -238,7 +244,7 @@ const beforeClose = (done: (cancel?: boolean) => void) => {
238
244
  distinguishCancelAndClose: true,
239
245
  })
240
246
  .then(() => {
241
- changedValue.value && submitForm(changedValue.value);
247
+ changedValue.value && submitForm(changedValue.value, { changeRecords: formBox.value?.form?.changeRecords });
242
248
  done();
243
249
  })
244
250
  .catch((action: string) => {
@@ -11,9 +11,9 @@
11
11
  </template>
12
12
 
13
13
  <script lang="ts" setup>
14
- import { computed, ref } from 'vue';
14
+ import { computed, useTemplateRef } from 'vue';
15
15
 
16
- import { FormConfig, MForm } from '@tmagic/form';
16
+ import { type ContainerChangeEventData, type FormConfig, type FormValue, MForm } from '@tmagic/form';
17
17
 
18
18
  import type { CodeParamStatement } from '@editor/type';
19
19
  import { error } from '@editor/utils';
@@ -32,7 +32,7 @@ const props = defineProps<{
32
32
 
33
33
  const emit = defineEmits(['change']);
34
34
 
35
- const form = ref<InstanceType<typeof MForm>>();
35
+ const form = useTemplateRef<InstanceType<typeof MForm>>('form');
36
36
 
37
37
  const getFormConfig = (items: FormConfig = []) => [
38
38
  {
@@ -59,10 +59,10 @@ const codeParamsConfig = computed(() =>
59
59
  /**
60
60
  * 参数值修改更新
61
61
  */
62
- const onParamsChangeHandler = async () => {
62
+ const onParamsChangeHandler = async (v: FormValue, eventData: ContainerChangeEventData) => {
63
63
  try {
64
64
  const value = await form.value?.submitForm(true);
65
- emit('change', value);
65
+ emit('change', value, eventData);
66
66
  } catch (e) {
67
67
  error(e);
68
68
  }
@@ -6,6 +6,7 @@
6
6
  ref="menu"
7
7
  :style="menuStyle"
8
8
  @mouseenter="mouseenterHandler()"
9
+ @contextmenu.prevent
9
10
  >
10
11
  <slot name="title"></slot>
11
12
  <div>
@@ -36,7 +37,7 @@
36
37
  </template>
37
38
 
38
39
  <script lang="ts" setup>
39
- import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
40
+ import { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue';
40
41
 
41
42
  import { useZIndex } from '@tmagic/design';
42
43
 
@@ -68,9 +69,9 @@ const emit = defineEmits<{
68
69
  mouseenter: [];
69
70
  }>();
70
71
 
71
- const menu = ref<HTMLDivElement>();
72
- const buttons = ref<InstanceType<typeof ToolButton>[]>();
73
- const subMenu = ref<any>();
72
+ const menu = useTemplateRef<HTMLDivElement>('menu');
73
+ const buttons = useTemplateRef<InstanceType<typeof ToolButton>[]>('buttons');
74
+ const subMenu = useTemplateRef<any>('subMenu');
74
75
  const visible = ref(false);
75
76
  const subMenuData = ref<(MenuButton | MenuComponent)[]>([]);
76
77
  const zIndex = useZIndex();
@@ -82,8 +83,8 @@ const menuPosition = ref({
82
83
  });
83
84
 
84
85
  const menuStyle = computed(() => ({
85
- top: `${menuPosition.value.top}px`,
86
- left: `${menuPosition.value.left}px`,
86
+ top: `${menuPosition.value.top + 2}px`,
87
+ left: `${menuPosition.value.left + 2}px`,
87
88
  zIndex: curZIndex.value,
88
89
  }));
89
90
 
@@ -98,10 +99,12 @@ const hide = () => {
98
99
  emit('hide');
99
100
  };
100
101
 
101
- const clickHandler = () => {
102
+ const clickHandler = (event: MouseEvent) => {
102
103
  if (!props.autoHide) return;
103
104
 
104
- hide();
105
+ if (event.button === 0) {
106
+ hide();
107
+ }
105
108
  };
106
109
 
107
110
  const outsideClickHideHandler = (e: MouseEvent) => {
@@ -132,18 +135,15 @@ const setPosition = (e: { clientY: number; clientX: number }) => {
132
135
  };
133
136
 
134
137
  const show = (e?: { clientY: number; clientX: number }) => {
135
- // 加setTimeout是以为,如果菜单中的按钮监听的是mouseup,那么菜单显示出来时鼠标如果正好在菜单上就会马上触发按钮的mouseup
136
- setTimeout(() => {
137
- visible.value = true;
138
+ visible.value = true;
138
139
 
139
- nextTick(() => {
140
- e && setPosition(e);
140
+ nextTick(() => {
141
+ e && setPosition(e);
141
142
 
142
- curZIndex.value = zIndex.nextZIndex();
143
+ curZIndex.value = zIndex.nextZIndex();
143
144
 
144
- emit('show');
145
- });
146
- }, 300);
145
+ emit('show');
146
+ });
147
147
  };
148
148
 
149
149
  const showSubMenu = (item: MenuButton | MenuComponent, index: number) => {
@@ -166,7 +166,7 @@ const showSubMenu = (item: MenuButton | MenuComponent, index: number) => {
166
166
  y = rect.top;
167
167
  }
168
168
  subMenu.value?.show({
169
- clientX: menu.value.offsetLeft + menu.value.clientWidth,
169
+ clientX: menu.value.offsetLeft + menu.value.clientWidth - 2,
170
170
  clientY: y,
171
171
  });
172
172
  }
@@ -17,7 +17,7 @@
17
17
  </template>
18
18
 
19
19
  <script setup lang="ts">
20
- import { computed, inject, nextTick, onBeforeUnmount, provide, ref, watch } from 'vue';
20
+ import { computed, inject, nextTick, onBeforeUnmount, provide, ref, useTemplateRef, watch } from 'vue';
21
21
  import { Close } from '@element-plus/icons-vue';
22
22
  import VanillaMoveable from 'moveable';
23
23
 
@@ -47,8 +47,8 @@ const props = withDefaults(
47
47
  },
48
48
  );
49
49
 
50
- const target = ref<HTMLDivElement>();
51
- const titleEl = ref<HTMLDivElement>();
50
+ const target = useTemplateRef<HTMLDivElement>('target');
51
+ const titleEl = useTemplateRef<HTMLDivElement>('titleEl');
52
52
 
53
53
  const zIndex = useZIndex();
54
54
  const curZIndex = ref<number>(0);
@@ -1,11 +1,11 @@
1
1
  <template>
2
- <span ref="target" class="m-editor-resizer" :class="{ 'm-editor-resizer-draging': isDraging }">
2
+ <span ref="target" class="m-editor-resizer" :class="{ 'm-editor-resizer-dragging': isDragging }">
3
3
  <slot></slot>
4
4
  </span>
5
5
  </template>
6
6
 
7
7
  <script lang="ts" setup>
8
- import { ref } from 'vue';
8
+ import { useTemplateRef } from 'vue';
9
9
  import type { OnDrag } from 'gesto';
10
10
 
11
11
  import { useGetSo } from '@editor/hooks/use-getso';
@@ -18,6 +18,6 @@ const emit = defineEmits<{
18
18
  change: [e: OnDrag];
19
19
  }>();
20
20
 
21
- const target = ref<HTMLSpanElement>();
22
- const { isDraging } = useGetSo(target, emit);
21
+ const target = useTemplateRef<HTMLSpanElement>('target');
22
+ const { isDragging } = useGetSo(target, emit);
23
23
  </script>
@@ -5,7 +5,7 @@
5
5
  </template>
6
6
 
7
7
  <script lang="ts" setup>
8
- import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
8
+ import { computed, onBeforeUnmount, onMounted, useTemplateRef } from 'vue';
9
9
  import Gesto from 'gesto';
10
10
 
11
11
  defineOptions({
@@ -21,8 +21,8 @@ const props = defineProps<{
21
21
 
22
22
  const emit = defineEmits(['scroll']);
23
23
 
24
- const bar = ref<HTMLDivElement>();
25
- const thumb = ref<HTMLDivElement>();
24
+ const bar = useTemplateRef<HTMLDivElement>('bar');
25
+ const thumb = useTemplateRef<HTMLDivElement>('thumb');
26
26
 
27
27
  const thumbSize = computed(() => props.size * (props.size / props.scrollSize));
28
28
  const thumbPos = computed(() => (props.pos / props.scrollSize) * props.size);
@@ -25,7 +25,7 @@
25
25
  </template>
26
26
 
27
27
  <script lang="ts" setup>
28
- import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
28
+ import { computed, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
29
29
 
30
30
  import { isNumber } from '@tmagic/utils';
31
31
 
@@ -63,8 +63,8 @@ const props = withDefaults(
63
63
  },
64
64
  );
65
65
 
66
- const container = ref<HTMLDivElement>();
67
- const el = ref<HTMLDivElement>();
66
+ const container = useTemplateRef<HTMLDivElement>('container');
67
+ const el = useTemplateRef<HTMLDivElement>('el');
68
68
  const style = computed(
69
69
  () => `
70
70
  width: ${isNumber(`${props.width}`) ? `${props.width}px` : props.width};
@@ -21,7 +21,7 @@
21
21
  </template>
22
22
 
23
23
  <script lang="ts" setup>
24
- import { computed, onBeforeUnmount, onMounted, ref, watchEffect } from 'vue';
24
+ import { computed, onBeforeUnmount, onMounted, ref, useTemplateRef, watchEffect } from 'vue';
25
25
  import { OnDrag } from 'gesto';
26
26
 
27
27
  import Resizer from './Resizer.vue';
@@ -51,7 +51,7 @@ const props = withDefaults(
51
51
  },
52
52
  );
53
53
 
54
- const el = ref<HTMLElement>();
54
+ const el = useTemplateRef<HTMLElement>('el');
55
55
 
56
56
  const hasLeft = computed(() => typeof props.left !== 'undefined');
57
57
  const hasRight = computed(() => typeof props.right !== 'undefined');
@@ -131,7 +131,8 @@ const mousedownHandler = (item: MenuButton | MenuComponent, event: MouseEvent) =
131
131
 
132
132
  const mouseupHandler = (item: MenuButton | MenuComponent, event: MouseEvent) => {
133
133
  if (props.eventType !== 'mouseup') return;
134
- if (item.type === 'button') {
134
+
135
+ if (item.type === 'button' && event.button === 0) {
135
136
  buttonHandler(item, event);
136
137
  }
137
138
  };
@@ -1,4 +1,4 @@
1
- import type { DataSourceSchema, EventOption, Id, MApp, MNode } from '@tmagic/core';
1
+ import type { DataSourceSchema, EventOption, Id, MApp, MNode, MPage, MPageFragment } from '@tmagic/core';
2
2
  import type { FormConfig, FormState } from '@tmagic/form';
3
3
  import StageCore, {
4
4
  CONTAINER_HIGHLIGHT_CLASS_NAME,
@@ -13,6 +13,7 @@ import { getIdFromEl } from '@tmagic/utils';
13
13
 
14
14
  import type {
15
15
  ComponentGroup,
16
+ CustomContentMenuFunction,
16
17
  DatasourceTypeOption,
17
18
  MenuBarData,
18
19
  MenuButton,
@@ -93,10 +94,12 @@ export interface EditorProps {
93
94
  /** 用于设置画布上的dom是否可以被拖入其中 */
94
95
  isContainer?: (el: HTMLElement) => boolean | Promise<boolean>;
95
96
  /** 用于自定义组件树与画布的右键菜单 */
96
- customContentMenu?: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
97
+ customContentMenu?: CustomContentMenuFunction;
97
98
  extendFormState?: (state: FormState) => Record<string, any> | Promise<Record<string, any>>;
98
99
  /** 页面顺序拖拽配置参数 */
99
100
  pageBarSortOptions?: PageBarSortOptions;
101
+ /** 页面搜索函数 */
102
+ pageFilterFunction?: (page: MPage | MPageFragment, keyword: string) => boolean;
100
103
  }
101
104
 
102
105
  export const defaultEditorProps = {
@@ -121,4 +124,5 @@ export const defaultEditorProps = {
121
124
  canSelect: (el: HTMLElement) => Boolean(getIdFromEl()(el)),
122
125
  isContainer: (el: HTMLElement) => el.classList.contains('magic-ui-container'),
123
126
  codeOptions: () => ({}),
127
+ customContentMenu: (menus: (MenuButton | MenuComponent)[]) => menus,
124
128
  };
@@ -25,7 +25,7 @@ const emit = defineEmits<{
25
25
  change: [value: string | any];
26
26
  }>();
27
27
 
28
- const props = withDefaults(
28
+ withDefaults(
29
29
  defineProps<
30
30
  FieldProps<
31
31
  {
@@ -44,7 +44,6 @@ const props = withDefaults(
44
44
  );
45
45
 
46
46
  const save = (v: string | any) => {
47
- props.model[props.name] = v;
48
47
  emit('change', v);
49
48
  };
50
49
  </script>
@@ -21,8 +21,8 @@ import { isEmpty } from 'lodash-es';
21
21
 
22
22
  import { HookCodeType, HookType } from '@tmagic/core';
23
23
  import { TMagicCard } from '@tmagic/design';
24
- import type { FieldProps, FormItem } from '@tmagic/form';
25
- import { FormState, MContainer } from '@tmagic/form';
24
+ import type { ContainerChangeEventData, FieldProps, FormItem, GroupListConfig } from '@tmagic/form';
25
+ import { MContainer } from '@tmagic/form';
26
26
 
27
27
  import type { Services } from '@editor/type';
28
28
 
@@ -30,7 +30,9 @@ defineOptions({
30
30
  name: 'MFieldsCodeSelect',
31
31
  });
32
32
 
33
- const emit = defineEmits(['change']);
33
+ const emit = defineEmits<{
34
+ change: [v: any, eventData: ContainerChangeEventData];
35
+ }>();
34
36
 
35
37
  const services = inject<Services>('services');
36
38
 
@@ -45,12 +47,12 @@ const props = withDefaults(
45
47
  {},
46
48
  );
47
49
 
48
- const codeConfig = computed(() => ({
50
+ const codeConfig = computed<GroupListConfig>(() => ({
49
51
  type: 'group-list',
50
52
  name: 'hookData',
51
53
  enableToggleMode: false,
52
54
  expandAll: true,
53
- title: (mForm: FormState, { model, index }: any) => {
55
+ title: (mForm, { model, index }: any) => {
54
56
  if (model.codeType === HookCodeType.DATA_SOURCE_METHOD) {
55
57
  if (Array.isArray(model.codeId)) {
56
58
  if (model.codeId.length < 2) {
@@ -78,11 +80,13 @@ const codeConfig = computed(() => ({
78
80
  { value: HookCodeType.DATA_SOURCE_METHOD, text: '数据源方法' },
79
81
  ],
80
82
  defaultValue: 'code',
81
- onChange: (mForm: FormState, v: HookCodeType, { model }: any) => {
83
+ onChange: (mForm, v: HookCodeType, { model, prop, changeRecords }) => {
82
84
  if (v === HookCodeType.DATA_SOURCE_METHOD) {
83
85
  model.codeId = [];
86
+ changeRecords.push({ propPath: prop.replace('codeType', 'codeId'), value: [] });
84
87
  } else {
85
88
  model.codeId = '';
89
+ changeRecords.push({ propPath: prop.replace('codeType', 'codeId'), value: '' });
86
90
  }
87
91
 
88
92
  return v;
@@ -93,7 +97,7 @@ const codeConfig = computed(() => ({
93
97
  name: 'codeId',
94
98
  span: 18,
95
99
  labelWidth: 0,
96
- display: (mForm: FormState, { model }: any) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
100
+ display: (mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
97
101
  notEditable: () => !services?.codeBlockService.getEditStatus(),
98
102
  },
99
103
  {
@@ -101,7 +105,7 @@ const codeConfig = computed(() => ({
101
105
  name: 'codeId',
102
106
  span: 18,
103
107
  labelWidth: 0,
104
- display: (mForm: FormState, { model }: any) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
108
+ display: (mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
105
109
  notEditable: () => !services?.dataSourceService.get('editable'),
106
110
  },
107
111
  ],
@@ -126,7 +130,5 @@ watch(
126
130
  },
127
131
  );
128
132
 
129
- const changeHandler = async () => {
130
- emit('change', props.model[props.name]);
131
- };
133
+ const changeHandler = (v: any, eventData: ContainerChangeEventData) => emit('change', v, eventData);
132
134
  </script>
@@ -7,7 +7,7 @@
7
7
  :config="selectConfig"
8
8
  :model="model"
9
9
  :size="size"
10
- @change="onParamsChangeHandler"
10
+ @change="onCodeIdChangeHandler"
11
11
  ></MContainer>
12
12
 
13
13
  <!-- 查看/编辑按钮 -->
@@ -41,7 +41,14 @@ import { isEmpty, map } from 'lodash-es';
41
41
 
42
42
  import type { Id } from '@tmagic/core';
43
43
  import { TMagicButton } from '@tmagic/design';
44
- import { createValues, type FieldProps, filterFunction, type FormState, MContainer } from '@tmagic/form';
44
+ import {
45
+ type ContainerChangeEventData,
46
+ createValues,
47
+ type FieldProps,
48
+ filterFunction,
49
+ type FormState,
50
+ MContainer,
51
+ } from '@tmagic/form';
45
52
 
46
53
  import CodeParams from '@editor/components/CodeParams.vue';
47
54
  import MIcon from '@editor/components/Icon.vue';
@@ -55,7 +62,9 @@ defineOptions({
55
62
  const mForm = inject<FormState | undefined>('mForm');
56
63
  const services = inject<Services>('services');
57
64
  const eventBus = inject<EventBus>('eventBus');
58
- const emit = defineEmits(['change']);
65
+ const emit = defineEmits<{
66
+ change: [v: any, eventData: ContainerChangeEventData];
67
+ }>();
59
68
 
60
69
  const props = withDefaults(defineProps<FieldProps<CodeSelectColConfig>>(), {
61
70
  disabled: false,
@@ -125,12 +134,30 @@ const selectConfig = {
125
134
  },
126
135
  };
127
136
 
137
+ const onCodeIdChangeHandler = (value: any) => {
138
+ props.model.params = value.params;
139
+ emit('change', props.model, {
140
+ changeRecords: [
141
+ {
142
+ propPath: props.prop,
143
+ value: value[props.name],
144
+ },
145
+ ],
146
+ });
147
+ };
148
+
128
149
  /**
129
150
  * 参数值修改更新
130
151
  */
131
- const onParamsChangeHandler = (value: any) => {
152
+ const onParamsChangeHandler = (value: any, eventData: ContainerChangeEventData) => {
132
153
  props.model.params = value.params;
133
- emit('change', props.model);
154
+ emit('change', props.model, {
155
+ ...eventData,
156
+ changeRecords: (eventData.changeRecords || []).map((item) => ({
157
+ prop: `${props.prop.replace(props.name, '')}${item.propPath}`,
158
+ value: item.value,
159
+ })),
160
+ });
134
161
  };
135
162
 
136
163
  const editCode = (id: string) => {
@@ -39,7 +39,10 @@ defineOptions({
39
39
  name: 'MFieldsCondOpSelect',
40
40
  });
41
41
 
42
- const emit = defineEmits(['change']);
42
+ const emit = defineEmits<{
43
+ change: [value: string];
44
+ }>();
45
+
43
46
  const { dataSourceService } = inject<Services>('services') || {};
44
47
 
45
48
  const props = defineProps<FieldProps<CondOpSelectConfig>>();
@@ -81,7 +84,7 @@ const options = computed(() => {
81
84
  return [...arrayOptions, ...eqOptions, ...numberOptions];
82
85
  });
83
86
 
84
- const fieldChangeHandler = (v: string[]) => {
87
+ const fieldChangeHandler = (v: string) => {
85
88
  emit('change', v);
86
89
  };
87
90
  </script>