@tmagic/editor 1.4.3 → 1.4.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 (33) hide show
  1. package/dist/style.css +15 -1
  2. package/dist/tmagic-editor.js +1236 -1162
  3. package/dist/tmagic-editor.umd.cjs +1254 -1179
  4. package/package.json +11 -11
  5. package/src/Editor.vue +6 -1
  6. package/src/editorProps.ts +3 -0
  7. package/src/fields/CodeSelectCol.vue +26 -18
  8. package/src/fields/DataSourceFieldSelect.vue +20 -20
  9. package/src/fields/DataSourceMethodSelect.vue +25 -31
  10. package/src/fields/DataSourceSelect.vue +49 -13
  11. package/src/fields/EventSelect.vue +8 -6
  12. package/src/hooks/use-editor-content-height.ts +11 -5
  13. package/src/layouts/PropsPanel.vue +3 -1
  14. package/src/layouts/sidebar/Sidebar.vue +24 -8
  15. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +6 -1
  16. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +6 -1
  17. package/src/services/ui.ts +1 -0
  18. package/src/theme/data-source-field.scss +12 -0
  19. package/src/theme/props-panel.scss +1 -1
  20. package/src/theme/theme.scss +1 -0
  21. package/src/type.ts +31 -2
  22. package/types/components/ContentMenu.vue.d.ts +3 -3
  23. package/types/components/ToolButton.vue.d.ts +2 -2
  24. package/types/editorProps.d.ts +3 -0
  25. package/types/layouts/PropsPanel.vue.d.ts +2 -0
  26. package/types/layouts/sidebar/Sidebar.vue.d.ts +7 -7
  27. package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +2 -2
  28. package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +4 -4
  29. package/types/layouts/sidebar/layer/use-click.d.ts +13 -13
  30. package/types/layouts/workspace/Workspace.vue.d.ts +4 -4
  31. package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +2 -2
  32. package/types/services/ui.d.ts +18 -0
  33. package/types/type.d.ts +26 -2
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.3",
2
+ "version": "1.4.4",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -42,14 +42,14 @@
42
42
  "dependencies": {
43
43
  "@babel/core": "^7.18.0",
44
44
  "@element-plus/icons-vue": "^2.3.1",
45
- "@tmagic/core": "1.4.3",
46
- "@tmagic/dep": "1.4.3",
47
- "@tmagic/design": "1.4.3",
48
- "@tmagic/form": "1.4.3",
49
- "@tmagic/schema": "1.4.3",
50
- "@tmagic/stage": "1.4.3",
51
- "@tmagic/table": "1.4.3",
52
- "@tmagic/utils": "1.4.3",
45
+ "@tmagic/core": "1.4.4",
46
+ "@tmagic/dep": "1.4.4",
47
+ "@tmagic/design": "1.4.4",
48
+ "@tmagic/form": "1.4.4",
49
+ "@tmagic/schema": "1.4.4",
50
+ "@tmagic/stage": "1.4.4",
51
+ "@tmagic/table": "1.4.4",
52
+ "@tmagic/utils": "1.4.4",
53
53
  "buffer": "^6.0.3",
54
54
  "color": "^3.1.3",
55
55
  "emmet-monaco-es": "^5.3.0",
@@ -63,8 +63,8 @@
63
63
  "vue": "^3.4.21"
64
64
  },
65
65
  "peerDependencies": {
66
- "@tmagic/design": "1.4.3",
67
- "@tmagic/form": "1.4.3",
66
+ "@tmagic/design": "1.4.4",
67
+ "@tmagic/form": "1.4.4",
68
68
  "monaco-editor": "^0.47.0",
69
69
  "vue": "^3.4.21"
70
70
  },
package/src/Editor.vue CHANGED
@@ -81,6 +81,7 @@
81
81
  <slot name="props-panel">
82
82
  <PropsPanel
83
83
  :extend-state="extendFormState"
84
+ :disabled-show-src="disabledShowSrc"
84
85
  @mounted="(instance: any) => $emit('props-panel-mounted', instance)"
85
86
  @form-error="(e: any) => $emit('props-form-error', e)"
86
87
  @submit-error="(e: any) => $emit('props-submit-error', e)"
@@ -109,6 +110,8 @@
109
110
  </template>
110
111
 
111
112
  <script lang="ts" setup>
113
+ import { EventEmitter } from 'events';
114
+
112
115
  import { provide } from 'vue';
113
116
 
114
117
  import type { MApp } from '@tmagic/schema';
@@ -133,7 +136,7 @@ import uiService from './services/ui';
133
136
  import keybindingConfig from './utils/keybinding-config';
134
137
  import { defaultEditorProps, EditorProps } from './editorProps';
135
138
  import { initServiceEvents, initServiceState } from './initService';
136
- import type { FrameworkSlots, PropsPanelSlots, Services, SidebarSlots, WorkspaceSlots } from './type';
139
+ import type { EventBus, FrameworkSlots, PropsPanelSlots, Services, SidebarSlots, WorkspaceSlots } from './type';
137
140
 
138
141
  defineSlots<
139
142
  FrameworkSlots &
@@ -202,5 +205,7 @@ provide('services', services);
202
205
  provide('codeOptions', props.codeOptions);
203
206
  provide('stageOptions', stageOptions);
204
207
 
208
+ provide<EventBus>('eventBus', new EventEmitter());
209
+
205
210
  defineExpose(services);
206
211
  </script>
@@ -80,6 +80,8 @@ export interface EditorProps {
80
80
  disabledPageFragment?: boolean;
81
81
  /** 禁用双击在浮层中单独编辑选中组件 */
82
82
  disabledStageOverlay?: boolean;
83
+ /** 禁用属性配置面板右下角显示源码的按钮 */
84
+ disabledShowSrc?: boolean;
83
85
  /** 中间工作区域中画布渲染的内容 */
84
86
  render?: (stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>;
85
87
  /** 选中时会在画布上复制出一个大小相同的dom,实际拖拽的是这个dom,此方法用于干预这个dom的生成方式 */
@@ -101,6 +103,7 @@ export const defaultEditorProps = {
101
103
  containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
102
104
  containerHighlightDuration: 800,
103
105
  containerHighlightType: ContainerHighlightType.DEFAULT,
106
+ disabledShowSrc: false,
104
107
  componentGroupList: () => [],
105
108
  datasourceList: () => [],
106
109
  menu: () => ({ left: [], right: [] }),
@@ -2,15 +2,23 @@
2
2
  <div class="m-fields-code-select-col">
3
3
  <div class="code-select-container">
4
4
  <!-- 代码块下拉框 -->
5
- <m-form-container
5
+ <MContainer
6
6
  class="select"
7
7
  :config="selectConfig"
8
8
  :model="model"
9
9
  :size="size"
10
10
  @change="onParamsChangeHandler"
11
- ></m-form-container>
11
+ ></MContainer>
12
+
12
13
  <!-- 查看/编辑按钮 -->
13
- <Icon v-if="model[name]" class="icon" :icon="!notEditable ? Edit : View" @click="editCode(model[name])"></Icon>
14
+ <TMagicButton
15
+ v-if="model[name] && hasCodeBlockSidePanel"
16
+ class="m-fields-select-action-button"
17
+ :size="size"
18
+ @click="editCode(model[name])"
19
+ >
20
+ <MIcon :icon="!notEditable ? Edit : View"></MIcon>
21
+ </TMagicButton>
14
22
  </div>
15
23
 
16
24
  <!-- 参数填写框 -->
@@ -23,14 +31,6 @@
23
31
  :params-config="paramsConfig"
24
32
  @change="onParamsChangeHandler"
25
33
  ></CodeParams>
26
-
27
- <CodeBlockEditor
28
- ref="codeBlockEditor"
29
- v-if="codeConfig"
30
- :disabled="notEditable"
31
- :content="codeConfig"
32
- @submit="submitCodeBlockHandler"
33
- ></CodeBlockEditor>
34
34
  </div>
35
35
  </template>
36
36
 
@@ -39,14 +39,14 @@ import { computed, inject, ref, watch } from 'vue';
39
39
  import { Edit, View } from '@element-plus/icons-vue';
40
40
  import { isEmpty, map } from 'lodash-es';
41
41
 
42
- import { createValues, type FieldProps, filterFunction, type FormState } from '@tmagic/form';
42
+ import { TMagicButton } from '@tmagic/design';
43
+ import { createValues, type FieldProps, filterFunction, type FormState, MContainer } from '@tmagic/form';
43
44
  import type { Id } from '@tmagic/schema';
44
45
 
45
- import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
46
46
  import CodeParams from '@editor/components/CodeParams.vue';
47
- import Icon from '@editor/components/Icon.vue';
48
- import { useCodeBlockEdit } from '@editor/hooks/use-code-block-edit';
49
- import type { CodeParamStatement, CodeSelectColConfig, Services } from '@editor/type';
47
+ import MIcon from '@editor/components/Icon.vue';
48
+ import type { CodeParamStatement, CodeSelectColConfig, EventBus, Services } from '@editor/type';
49
+ import { SideItemKey } from '@editor/type';
50
50
 
51
51
  defineOptions({
52
52
  name: 'MFieldsCodeSelectCol',
@@ -54,13 +54,19 @@ defineOptions({
54
54
 
55
55
  const mForm = inject<FormState | undefined>('mForm');
56
56
  const services = inject<Services>('services');
57
+ const eventBus = inject<EventBus>('eventBus');
57
58
  const emit = defineEmits(['change']);
58
59
 
59
- const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
60
60
  const props = withDefaults(defineProps<FieldProps<CodeSelectColConfig>>(), {
61
61
  disabled: false,
62
62
  });
63
63
 
64
+ const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
65
+
66
+ const hasCodeBlockSidePanel = computed(() =>
67
+ (services?.uiService.get('sideBarItems') || []).find((item) => item.$key === SideItemKey.CODE_BLOCK),
68
+ );
69
+
64
70
  /**
65
71
  * 根据代码块id获取代码块参数配置
66
72
  * @param codeId 代码块ID
@@ -127,5 +133,7 @@ const onParamsChangeHandler = (value: any) => {
127
133
  emit('change', props.model);
128
134
  };
129
135
 
130
- const { codeBlockEditor, codeConfig, editCode, submitCodeBlockHandler } = useCodeBlockEdit(services?.codeBlockService);
136
+ const editCode = (id: string) => {
137
+ eventBus?.emit('edit-code', id);
138
+ };
131
139
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div style="width: 100%; display: flex; align-items: center">
2
+ <div class="m-fields-data-source-field-select">
3
3
  <component
4
4
  style="width: 100%"
5
5
  :is="tagName"
@@ -14,13 +14,15 @@
14
14
  :prop="`${prop}${prop ? '.' : ''}${name}`"
15
15
  @change="onChangeHandler"
16
16
  ></component>
17
+
17
18
  <TMagicButton
18
- v-if="(showDataSourceFieldSelect || !config.fieldConfig) && selectedDataSourceId"
19
- style="margin-left: 5px"
19
+ v-if="(showDataSourceFieldSelect || !config.fieldConfig) && selectedDataSourceId && hasDataSourceSidePanel"
20
+ class="m-fields-select-action-button"
20
21
  :size="size"
21
22
  @click="editHandler(selectedDataSourceId)"
22
- ><MIcon :icon="Edit"></MIcon
23
+ ><MIcon :icon="!notEditable ? Edit : View"></MIcon
23
24
  ></TMagicButton>
25
+
24
26
  <TMagicButton
25
27
  v-if="config.fieldConfig"
26
28
  style="margin-left: 5px"
@@ -29,43 +31,41 @@
29
31
  @click="showDataSourceFieldSelect = !showDataSourceFieldSelect"
30
32
  ><MIcon :icon="Coin"></MIcon
31
33
  ></TMagicButton>
32
-
33
- <DataSourceConfigPanel
34
- ref="editDialog"
35
- :disabled="!editable"
36
- :values="dataSourceValues"
37
- :title="dialogTitle"
38
- @submit="submitDataSourceHandler"
39
- ></DataSourceConfigPanel>
40
34
  </div>
41
35
  </template>
42
36
 
43
37
  <script setup lang="ts">
44
38
  import { computed, inject, ref, resolveComponent, watch } from 'vue';
45
- import { Coin, Edit } from '@element-plus/icons-vue';
39
+ import { Coin, Edit, View } from '@element-plus/icons-vue';
46
40
 
47
41
  import { TMagicButton } from '@tmagic/design';
48
42
  import type { CascaderConfig, CascaderOption, FieldProps, FormState } from '@tmagic/form';
49
- import { MCascader } from '@tmagic/form';
43
+ import { filterFunction, MCascader } from '@tmagic/form';
50
44
  import type { DataSchema, DataSourceFieldType } from '@tmagic/schema';
51
45
  import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
52
46
 
53
47
  import MIcon from '@editor/components/Icon.vue';
54
- import { useDataSourceEdit } from '@editor/hooks/use-data-source-edit';
55
- import DataSourceConfigPanel from '@editor/layouts/sidebar/data-source/DataSourceConfigPanel.vue';
56
- import type { DataSourceFieldSelectConfig, Services } from '@editor/type';
48
+ import type { DataSourceFieldSelectConfig, EventBus, Services } from '@editor/type';
49
+ import { SideItemKey } from '@editor/type';
57
50
 
58
51
  defineOptions({
59
52
  name: 'MFieldsDataSourceFieldSelect',
60
53
  });
61
54
 
62
55
  const services = inject<Services>('services');
56
+ const eventBus = inject<EventBus>('eventBus');
63
57
  const emit = defineEmits(['change']);
64
58
 
65
59
  const props = withDefaults(defineProps<FieldProps<DataSourceFieldSelectConfig>>(), {
66
60
  disabled: false,
67
61
  });
68
62
 
63
+ const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
64
+
65
+ const hasDataSourceSidePanel = computed(() =>
66
+ (services?.uiService.get('sideBarItems') || []).find((item) => item.$key === SideItemKey.DATA_SOURCE),
67
+ );
68
+
69
69
  const selectedDataSourceId = computed(() => {
70
70
  const value = props.model[props.name];
71
71
  if (!Array.isArray(value) || !value.length) {
@@ -181,7 +181,7 @@ const onChangeHandler = (value: any) => {
181
181
  emit('change', value);
182
182
  };
183
183
 
184
- const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(
185
- services?.dataSourceService,
186
- );
184
+ const editHandler = (id: string) => {
185
+ eventBus?.emit('edit-data-source', id);
186
+ };
187
187
  </script>
@@ -1,18 +1,22 @@
1
1
  <template>
2
2
  <div class="m-fields-data-source-method-select">
3
3
  <div class="data-source-method-select-container">
4
- <m-form-container
4
+ <MContainer
5
5
  class="select"
6
6
  :config="cascaderConfig"
7
7
  :model="model"
8
+ :size="size"
8
9
  @change="onChangeHandler"
9
- ></m-form-container>
10
- <Icon
11
- v-if="model[name] && isCustomMethod"
12
- class="icon"
13
- :icon="!notEditable ? Edit : View"
10
+ ></MContainer>
11
+
12
+ <TMagicButton
13
+ v-if="model[name] && isCustomMethod && hasDataSourceSidePanel"
14
+ class="m-fields-select-action-button"
15
+ :size="size"
14
16
  @click="editCodeHandler"
15
- ></Icon>
17
+ >
18
+ <MIcon :icon="!notEditable ? Edit : View"></MIcon>
19
+ </TMagicButton>
16
20
  </div>
17
21
 
18
22
  <CodeParams
@@ -24,14 +28,6 @@
24
28
  :params-config="paramsConfig"
25
29
  @change="onChangeHandler"
26
30
  ></CodeParams>
27
-
28
- <CodeBlockEditor
29
- ref="codeBlockEditor"
30
- v-if="codeConfig"
31
- :disabled="notEditable"
32
- :content="codeConfig"
33
- @submit="submitCodeBlockHandler"
34
- ></CodeBlockEditor>
35
31
  </div>
36
32
  </template>
37
33
 
@@ -39,14 +35,14 @@
39
35
  import { computed, inject, ref } from 'vue';
40
36
  import { Edit, View } from '@element-plus/icons-vue';
41
37
 
42
- import { createValues, type FieldProps, filterFunction, type FormState } from '@tmagic/form';
43
- import type { CodeBlockContent, Id } from '@tmagic/schema';
38
+ import { TMagicButton } from '@tmagic/design';
39
+ import { createValues, type FieldProps, filterFunction, type FormState, MContainer } from '@tmagic/form';
40
+ import type { Id } from '@tmagic/schema';
44
41
 
45
- import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
46
42
  import CodeParams from '@editor/components/CodeParams.vue';
47
- import Icon from '@editor/components/Icon.vue';
48
- import { useDataSourceMethod } from '@editor/hooks/use-data-source-method';
49
- import type { CodeParamStatement, DataSourceMethodSelectConfig, Services } from '@editor/type';
43
+ import MIcon from '@editor/components/Icon.vue';
44
+ import type { CodeParamStatement, DataSourceMethodSelectConfig, EventBus, Services } from '@editor/type';
45
+ import { SideItemKey } from '@editor/type';
50
46
 
51
47
  defineOptions({
52
48
  name: 'MFieldsDataSourceMethodSelect',
@@ -54,6 +50,8 @@ defineOptions({
54
50
 
55
51
  const mForm = inject<FormState | undefined>('mForm');
56
52
  const services = inject<Services>('services');
53
+ const eventBus = inject<EventBus>('eventBus');
54
+
57
55
  const emit = defineEmits(['change']);
58
56
 
59
57
  const dataSourceService = services?.dataSourceService;
@@ -62,6 +60,10 @@ const props = withDefaults(defineProps<FieldProps<DataSourceMethodSelectConfig>>
62
60
  disabled: false,
63
61
  });
64
62
 
63
+ const hasDataSourceSidePanel = computed(() =>
64
+ (services?.uiService.get('sideBarItems') || []).find((item) => item.$key === SideItemKey.DATA_SOURCE),
65
+ );
66
+
65
67
  const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
66
68
 
67
69
  const dataSources = computed(() => dataSourceService?.get('dataSources'));
@@ -139,21 +141,13 @@ const onChangeHandler = (value: any) => {
139
141
  emit('change', props.model);
140
142
  };
141
143
 
142
- const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
143
-
144
144
  const editCodeHandler = () => {
145
- const [id, name] = props.model[props.name];
145
+ const [id] = props.model[props.name];
146
146
 
147
147
  const dataSource = dataSourceService?.getDataSourceById(id);
148
148
 
149
149
  if (!dataSource) return;
150
150
 
151
- editCode(dataSource, name);
152
-
153
- setParamsConfig([id, name]);
154
- };
155
-
156
- const submitCodeBlockHandler = (value: CodeBlockContent) => {
157
- submitCode(value);
151
+ eventBus?.emit('edit-data-source', id);
158
152
  };
159
153
  </script>
@@ -1,22 +1,36 @@
1
1
  <template>
2
- <MSelect
3
- :model="model"
4
- :name="name"
5
- :size="size"
6
- :prop="prop"
7
- :disabled="disabled"
8
- :config="selectConfig"
9
- :last-values="lastValues"
10
- @change="changeHandler"
11
- ></MSelect>
2
+ <div class="m-fields-data-source-select">
3
+ <MSelect
4
+ :model="model"
5
+ :name="name"
6
+ :size="size"
7
+ :prop="prop"
8
+ :disabled="disabled"
9
+ :config="selectConfig"
10
+ :last-values="lastValues"
11
+ @change="changeHandler"
12
+ ></MSelect>
13
+
14
+ <TMagicButton
15
+ v-if="model[name] && hasDataSourceSidePanel"
16
+ class="m-fields-select-action-button"
17
+ :size="size"
18
+ @click="editHandler"
19
+ ><MIcon :icon="!notEditable ? Edit : View"></MIcon
20
+ ></TMagicButton>
21
+ </div>
12
22
  </template>
13
23
 
14
24
  <script setup lang="ts">
15
25
  import { computed, inject } from 'vue';
26
+ import { Edit, View } from '@element-plus/icons-vue';
16
27
 
17
- import { type FieldProps, MSelect, type SelectConfig } from '@tmagic/form';
28
+ import { TMagicButton } from '@tmagic/design';
29
+ import { type FieldProps, filterFunction, type FormState, MSelect, type SelectConfig } from '@tmagic/form';
18
30
 
19
- import type { DataSourceSelect, Services } from '../type';
31
+ import MIcon from '@editor/components/Icon.vue';
32
+ import type { DataSourceSelect, EventBus, Services } from '@editor/type';
33
+ import { SideItemKey } from '@editor/type';
20
34
 
21
35
  defineOptions({
22
36
  name: 'MFieldsDataSourceSelect',
@@ -28,10 +42,18 @@ const props = withDefaults(defineProps<FieldProps<DataSourceSelect>>(), {
28
42
  disabled: false,
29
43
  });
30
44
 
31
- const { dataSourceService } = inject<Services>('services') || {};
45
+ const mForm = inject<FormState | undefined>('mForm');
46
+ const { dataSourceService, uiService } = inject<Services>('services') || {};
47
+ const eventBus = inject<EventBus>('eventBus');
32
48
 
33
49
  const dataSources = computed(() => dataSourceService?.get('dataSources') || []);
34
50
 
51
+ const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
52
+
53
+ const hasDataSourceSidePanel = computed(() =>
54
+ (uiService?.get('sideBarItems') || []).find((item) => item.$key === SideItemKey.DATA_SOURCE),
55
+ );
56
+
35
57
  const selectConfig = computed<SelectConfig>(() => {
36
58
  const { type, dataSourceType, value, ...config } = props.config;
37
59
 
@@ -59,4 +81,18 @@ const selectConfig = computed<SelectConfig>(() => {
59
81
  const changeHandler = (value: any) => {
60
82
  emit('change', value);
61
83
  };
84
+
85
+ const editHandler = () => {
86
+ const value = props.model[props.name];
87
+
88
+ if (!value) return;
89
+
90
+ const id = typeof value === 'string' ? value : value.dataSourceId;
91
+
92
+ const dataSource = dataSourceService?.getDataSourceById(id);
93
+
94
+ if (!dataSource) return;
95
+
96
+ eventBus?.emit('edit-data-source', id);
97
+ };
62
98
  </script>
@@ -15,7 +15,7 @@
15
15
  <TMagicButton class="create-button" type="primary" :size="size" :disabled="disabled" @click="addEvent()"
16
16
  >添加事件</TMagicButton
17
17
  >
18
- <m-form-panel
18
+ <MPanel
19
19
  v-for="(cardItem, index) in model[name]"
20
20
  :key="index"
21
21
  :disabled="disabled"
@@ -26,14 +26,14 @@
26
26
  @change="onChangeHandler"
27
27
  >
28
28
  <template #header>
29
- <m-form-container
29
+ <MContainer
30
30
  class="fullWidth"
31
31
  :config="eventNameConfig"
32
32
  :model="cardItem"
33
33
  :disabled="disabled"
34
34
  :size="size"
35
35
  @change="onChangeHandler"
36
- ></m-form-container>
36
+ ></MContainer>
37
37
  <TMagicButton
38
38
  style="color: #f56c6c"
39
39
  link
@@ -43,7 +43,7 @@
43
43
  @click="removeEvent(index)"
44
44
  ></TMagicButton>
45
45
  </template>
46
- </m-form-panel>
46
+ </MPanel>
47
47
  </div>
48
48
  </div>
49
49
  </template>
@@ -55,7 +55,8 @@ import { has } from 'lodash-es';
55
55
 
56
56
  import type { EventOption } from '@tmagic/core';
57
57
  import { TMagicButton } from '@tmagic/design';
58
- import type { FieldProps, FormState } from '@tmagic/form';
58
+ import type { FieldProps, FormState, PanelConfig } from '@tmagic/form';
59
+ import { MContainer, MPanel } from '@tmagic/form';
59
60
  import { ActionType } from '@tmagic/schema';
60
61
 
61
62
  import type { CodeSelectColConfig, DataSourceMethodSelectConfig, EventSelectConfig, Services } from '@editor/type';
@@ -227,7 +228,8 @@ const tableConfig = computed(() => ({
227
228
  }));
228
229
 
229
230
  // 组件动作组表单配置
230
- const actionsConfig = computed(() => ({
231
+ const actionsConfig = computed<PanelConfig>(() => ({
232
+ type: 'panel',
231
233
  items: [
232
234
  {
233
235
  type: 'group-list',
@@ -1,4 +1,4 @@
1
- import { computed, inject, ref, watchEffect } from 'vue';
1
+ import { computed, inject, ref, watch } from 'vue';
2
2
 
3
3
  import type { Services } from '@editor/type';
4
4
 
@@ -9,10 +9,16 @@ export const useEditorContentHeight = () => {
9
9
  const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
10
10
 
11
11
  const height = ref(0);
12
- watchEffect(() => {
13
- if (height.value > 0 && height.value === editorContentHeight.value) return;
14
- height.value = editorContentHeight.value;
15
- });
12
+ watch(
13
+ editorContentHeight,
14
+ () => {
15
+ if (height.value > 0 && height.value === editorContentHeight.value) return;
16
+ height.value = editorContentHeight.value;
17
+ },
18
+ {
19
+ immediate: true,
20
+ },
21
+ );
16
22
 
17
23
  return {
18
24
  height,
@@ -3,7 +3,7 @@
3
3
  <slot name="props-panel-header"></slot>
4
4
  <MForm
5
5
  ref="configForm"
6
- :class="`m-editor-props-panel ${propsPanelSize}`"
6
+ :class="propsPanelSize"
7
7
  :popper-class="`m-editor-props-panel-popper ${propsPanelSize}`"
8
8
  :size="propsPanelSize"
9
9
  :init-values="values"
@@ -14,6 +14,7 @@
14
14
  ></MForm>
15
15
 
16
16
  <TMagicButton
17
+ v-if="!disabledShowSrc"
17
18
  class="m-editor-props-panel-src-icon"
18
19
  circle
19
20
  size="large"
@@ -57,6 +58,7 @@ defineOptions({
57
58
  });
58
59
 
59
60
  defineProps<{
61
+ disabledShowSrc?: boolean;
60
62
  extendState?: (state: FormState) => Record<string, any> | Promise<Record<string, any>>;
61
63
  }>();
62
64
 
@@ -8,7 +8,8 @@
8
8
  draggable="true"
9
9
  :key="config.$key ?? index"
10
10
  :class="{ 'is-active': activeTabName === config.text }"
11
- @click="activeTabName = config.text || `${index}`"
11
+ :style="config.tabStyle || {}"
12
+ @click="activeTabName = config.text || config.$key || `${index}`"
12
13
  @dragstart="dragstartHandler"
13
14
  @dragend="dragendHandler(config.$key, $event)"
14
15
  >
@@ -20,7 +21,7 @@
20
21
  class="m-editor-sidebar-content"
21
22
  v-for="(config, index) in sideBarItems"
22
23
  :key="config.$key ?? index"
23
- v-show="activeTabName === config.text"
24
+ v-show="[config.text, config.$key, `${index}`].includes(activeTabName)"
24
25
  >
25
26
  <component
26
27
  v-if="config && !floatBoxStates[config.$key]?.status"
@@ -151,6 +152,7 @@ import {
151
152
  type SidebarSlots,
152
153
  type SideComponent,
153
154
  type SideItem,
155
+ SideItemKey,
154
156
  } from '@editor/type';
155
157
 
156
158
  import CodeBlockListPanel from './code-block/CodeBlockListPanel.vue';
@@ -171,7 +173,11 @@ const props = withDefaults(
171
173
  customContentMenu?: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
172
174
  }>(),
173
175
  {
174
- data: () => ({ type: 'tabs', status: '组件', items: ['component-list', 'layer', 'code-block', 'data-source'] }),
176
+ data: () => ({
177
+ type: 'tabs',
178
+ status: '组件',
179
+ items: [SideItemKey.COMPONENT_LIST, SideItemKey.LAYER, SideItemKey.CODE_BLOCK, SideItemKey.DATA_SOURCE],
180
+ }),
175
181
  },
176
182
  );
177
183
 
@@ -184,8 +190,8 @@ const activeTabName = ref(props.data?.status);
184
190
 
185
191
  const getItemConfig = (data: SideItem): SideComponent => {
186
192
  const map: Record<string, SideComponent> = {
187
- 'component-list': {
188
- $key: 'component-list',
193
+ [SideItemKey.COMPONENT_LIST]: {
194
+ $key: SideItemKey.COMPONENT_LIST,
189
195
  type: 'component',
190
196
  icon: Goods,
191
197
  text: '组件',
@@ -204,7 +210,7 @@ const getItemConfig = (data: SideItem): SideComponent => {
204
210
  component: LayerPanel,
205
211
  slots: {},
206
212
  },
207
- 'code-block': {
213
+ [SideItemKey.CODE_BLOCK]: {
208
214
  $key: 'code-block',
209
215
  type: 'component',
210
216
  icon: EditPen,
@@ -212,8 +218,8 @@ const getItemConfig = (data: SideItem): SideComponent => {
212
218
  component: CodeBlockListPanel,
213
219
  slots: {},
214
220
  },
215
- 'data-source': {
216
- $key: 'data-source',
221
+ [SideItemKey.DATA_SOURCE]: {
222
+ $key: SideItemKey.DATA_SOURCE,
217
223
  type: 'component',
218
224
  icon: Coin,
219
225
  text: '数据源',
@@ -227,6 +233,16 @@ const getItemConfig = (data: SideItem): SideComponent => {
227
233
 
228
234
  const sideBarItems = computed(() => props.data.items.map((item) => getItemConfig(item)));
229
235
 
236
+ watch(
237
+ sideBarItems,
238
+ (items) => {
239
+ services?.uiService.set('sideBarItems', items);
240
+ },
241
+ {
242
+ immediate: true,
243
+ },
244
+ );
245
+
230
246
  watch(
231
247
  () => props.data.status,
232
248
  (status) => {