@tmagic/editor 1.5.0 → 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 (72) hide show
  1. package/dist/{style.css → tmagic-editor.css} +153 -6
  2. package/dist/tmagic-editor.js +906 -527
  3. package/dist/tmagic-editor.umd.cjs +931 -551
  4. package/package.json +10 -10
  5. package/src/Editor.vue +18 -5
  6. package/src/components/CodeBlockEditor.vue +3 -3
  7. package/src/components/CodeParams.vue +2 -2
  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 +3 -1
  16. package/src/fields/DataSourceInput.vue +2 -2
  17. package/src/fields/DataSourceMethods.vue +2 -2
  18. package/src/fields/DataSourceMocks.vue +0 -1
  19. package/src/fields/EventSelect.vue +0 -1
  20. package/src/fields/KeyValue.vue +2 -2
  21. package/src/hooks/use-code-block-edit.ts +2 -2
  22. package/src/hooks/use-getso.ts +7 -7
  23. package/src/index.ts +2 -1
  24. package/src/layouts/CodeEditor.vue +2 -2
  25. package/src/layouts/Framework.vue +5 -8
  26. package/src/layouts/NavMenu.vue +2 -2
  27. package/src/layouts/page-bar/PageBar.vue +3 -3
  28. package/src/layouts/page-bar/PageBarScrollContainer.vue +3 -3
  29. package/src/layouts/props-panel/FormPanel.vue +123 -0
  30. package/src/layouts/props-panel/PropsPanel.vue +146 -0
  31. package/src/layouts/props-panel/use-style-panel.ts +29 -0
  32. package/src/layouts/sidebar/Sidebar.vue +4 -1
  33. package/src/layouts/sidebar/code-block/CodeBlockList.vue +12 -1
  34. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +35 -4
  35. package/src/layouts/sidebar/code-block/useContentMenu.ts +83 -0
  36. package/src/layouts/sidebar/data-source/DataSourceList.vue +8 -8
  37. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +40 -4
  38. package/src/layouts/sidebar/data-source/useContentMenu.ts +81 -0
  39. package/src/layouts/sidebar/layer/LayerMenu.vue +7 -13
  40. package/src/layouts/sidebar/layer/LayerPanel.vue +11 -4
  41. package/src/layouts/sidebar/layer/use-click.ts +2 -2
  42. package/src/layouts/sidebar/layer/use-keybinding.ts +2 -2
  43. package/src/layouts/workspace/Workspace.vue +9 -2
  44. package/src/layouts/workspace/viewer/NodeListMenu.vue +3 -3
  45. package/src/layouts/workspace/viewer/Stage.vue +18 -6
  46. package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
  47. package/src/layouts/workspace/viewer/ViewerMenu.vue +4 -6
  48. package/src/services/storage.ts +2 -1
  49. package/src/services/ui.ts +1 -0
  50. package/src/theme/common/var.scss +12 -10
  51. package/src/theme/component-list-panel.scss +9 -7
  52. package/src/theme/content-menu.scss +7 -5
  53. package/src/theme/data-source.scss +3 -1
  54. package/src/theme/floating-box.scss +4 -2
  55. package/src/theme/framework.scss +7 -5
  56. package/src/theme/index.scss +4 -5
  57. package/src/theme/key-value.scss +2 -2
  58. package/src/theme/layer-panel.scss +3 -1
  59. package/src/theme/layout.scss +1 -1
  60. package/src/theme/nav-menu.scss +7 -5
  61. package/src/theme/page-bar.scss +17 -15
  62. package/src/theme/props-panel.scss +81 -1
  63. package/src/theme/resizer.scss +1 -1
  64. package/src/theme/sidebar.scss +4 -2
  65. package/src/theme/stage.scss +3 -1
  66. package/src/theme/theme.scss +28 -28
  67. package/src/theme/tree.scss +14 -12
  68. package/src/type.ts +8 -0
  69. package/src/utils/content-menu.ts +2 -2
  70. package/src/utils/props.ts +45 -3
  71. package/types/index.d.ts +1796 -1230
  72. package/src/layouts/PropsPanel.vue +0 -131
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.0",
2
+ "version": "1.5.1",
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.0",
62
- "@tmagic/form": "1.5.0",
63
- "@tmagic/stage": "1.5.0",
64
- "@tmagic/utils": "1.5.0",
65
- "@tmagic/table": "1.5.0"
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"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/events": "^3.0.0",
@@ -70,20 +70,20 @@
70
70
  "@types/node": "^18.19.0",
71
71
  "@types/serialize-javascript": "^5.0.1",
72
72
  "@types/sortablejs": "^1.15.8",
73
- "@vitejs/plugin-vue": "^5.1.3",
73
+ "@vitejs/plugin-vue": "^5.2.1",
74
74
  "@vue/compiler-sfc": "^3.5.12",
75
75
  "@vue/test-utils": "^2.4.6",
76
76
  "rimraf": "^3.0.2",
77
- "sass": "^1.78.0",
77
+ "sass": "^1.83.0",
78
78
  "tsc-alias": "^1.8.5",
79
79
  "type-fest": "^4.10.3",
80
- "vite": "^5.4.10"
80
+ "vite": "^6.0.3"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "monaco-editor": "^0.48.0",
84
84
  "typescript": "*",
85
85
  "vue": ">=3.5.0",
86
- "@tmagic/core": "1.5.0"
86
+ "@tmagic/core": "1.5.1"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "typescript": {
package/src/Editor.vue CHANGED
@@ -96,9 +96,9 @@
96
96
  <PropsPanel
97
97
  :extend-state="extendFormState"
98
98
  :disabled-show-src="disabledShowSrc"
99
- @mounted="(instance: any) => $emit('props-panel-mounted', instance)"
100
- @form-error="(e: any) => $emit('props-form-error', e)"
101
- @submit-error="(e: any) => $emit('props-submit-error', e)"
99
+ @mounted="propsPanelMountedHandler"
100
+ @form-error="propsPanelFormErrorHandler"
101
+ @submit-error="propsPanelSubmitErrorHandler"
102
102
  >
103
103
  <template #props-panel-header>
104
104
  <slot name="props-panel-header"></slot>
@@ -134,7 +134,8 @@ import type { MApp } from '@tmagic/core';
134
134
 
135
135
  import Framework from './layouts/Framework.vue';
136
136
  import TMagicNavMenu from './layouts/NavMenu.vue';
137
- import PropsPanel from './layouts/PropsPanel.vue';
137
+ import FormPanel from './layouts/props-panel/FormPanel.vue';
138
+ import PropsPanel from './layouts/props-panel/PropsPanel.vue';
138
139
  import Sidebar from './layouts/sidebar/Sidebar.vue';
139
140
  import Workspace from './layouts/workspace/Workspace.vue';
140
141
  import codeBlockService from './services/codeBlock';
@@ -177,7 +178,7 @@ defineOptions({
177
178
  });
178
179
 
179
180
  const emit = defineEmits<{
180
- 'props-panel-mounted': [instance: InstanceType<typeof PropsPanel>];
181
+ 'props-panel-mounted': [instance: InstanceType<typeof FormPanel>];
181
182
  'update:modelValue': [value: MApp | null];
182
183
  'props-form-error': [e: any];
183
184
  'props-submit-error': [e: any];
@@ -231,5 +232,17 @@ provide('stageOptions', stageOptions);
231
232
 
232
233
  provide<EventBus>('eventBus', new EventEmitter());
233
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
+
234
247
  defineExpose(services);
235
248
  </script>
@@ -59,7 +59,7 @@
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';
@@ -104,7 +104,7 @@ const { height: codeBlockEditorHeight } = useEditorContentHeight();
104
104
  const difVisible = ref(false);
105
105
  const { rect: windowRect } = useWindowRect();
106
106
 
107
- const magicVsEditor = ref<InstanceType<typeof CodeEditor>>();
107
+ const magicVsEditor = useTemplateRef<InstanceType<typeof CodeEditor>>('magicVsEditor');
108
108
 
109
109
  const diffChange = () => {
110
110
  if (!magicVsEditor.value || !formBox.value?.form) {
@@ -224,7 +224,7 @@ const errorHandler = (error: any) => {
224
224
  tMagicMessage.error(error.message);
225
225
  };
226
226
 
227
- const formBox = ref<InstanceType<typeof MFormBox>>();
227
+ const formBox = useTemplateRef<InstanceType<typeof MFormBox>>('formBox');
228
228
 
229
229
  const changedValue = ref<CodeBlockContent>();
230
230
  const changeHandler = (values: CodeBlockContent) => {
@@ -11,7 +11,7 @@
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
16
  import { type ContainerChangeEventData, type FormConfig, type FormValue, MForm } from '@tmagic/form';
17
17
 
@@ -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
  {
@@ -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
  };
@@ -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,7 +94,7 @@ 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;
@@ -123,4 +124,5 @@ export const defaultEditorProps = {
123
124
  canSelect: (el: HTMLElement) => Boolean(getIdFromEl()(el)),
124
125
  isContainer: (el: HTMLElement) => el.classList.contains('magic-ui-container'),
125
126
  codeOptions: () => ({}),
127
+ customContentMenu: (menus: (MenuButton | MenuComponent)[]) => menus,
126
128
  };
@@ -48,7 +48,7 @@
48
48
  </template>
49
49
 
50
50
  <script setup lang="ts">
51
- import { computed, inject, nextTick, ref, watch } from 'vue';
51
+ import { computed, inject, nextTick, ref, useTemplateRef, watch } from 'vue';
52
52
  import { Coin } from '@element-plus/icons-vue';
53
53
 
54
54
  import type { DataSchema, DataSourceSchema } from '@tmagic/core';
@@ -83,7 +83,7 @@ const emit = defineEmits<{
83
83
 
84
84
  const { dataSourceService } = inject<Services>('services') || {};
85
85
 
86
- const autocomplete = ref<InstanceType<typeof TMagicAutocomplete>>();
86
+ const autocomplete = useTemplateRef<InstanceType<typeof TMagicAutocomplete>>('autocomplete');
87
87
  const isFocused = ref(false);
88
88
  const state = ref('');
89
89
  const displayState = ref<{ value: string; type: 'var' | 'text' }[]>([]);
@@ -21,7 +21,7 @@
21
21
  </template>
22
22
 
23
23
  <script setup lang="ts">
24
- import { nextTick, ref } from 'vue';
24
+ import { nextTick, ref, useTemplateRef } from 'vue';
25
25
  import { cloneDeep } from 'lodash-es';
26
26
 
27
27
  import type { CodeBlockContent } from '@tmagic/core';
@@ -51,7 +51,7 @@ const props = withDefaults(
51
51
  const emit = defineEmits(['change']);
52
52
 
53
53
  const codeConfig = ref<CodeBlockContent>();
54
- const codeBlockEditor = ref<InstanceType<typeof CodeBlockEditor>>();
54
+ const codeBlockEditor = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
55
55
 
56
56
  let editIndex = -1;
57
57
 
@@ -15,7 +15,6 @@
15
15
  >
16
16
  <template #body>
17
17
  <MFormBox
18
- ref="addDialog"
19
18
  label-width="120px"
20
19
  :config="formConfig"
21
20
  :values="formValues"
@@ -2,7 +2,6 @@
2
2
  <div class="m-fields-event-select">
3
3
  <m-form-table
4
4
  v-if="isOldVersion"
5
- ref="eventForm"
6
5
  name="events"
7
6
  :size="size"
8
7
  :disabled="disabled"
@@ -9,7 +9,7 @@
9
9
  :size="size"
10
10
  @change="keyChangeHandler"
11
11
  ></TMagicInput>
12
- <span class="m-fileds-key-value-delimiter">:</span>
12
+ <span class="m-fields-key-value-delimiter">:</span>
13
13
  <TMagicInput
14
14
  placeholder="value"
15
15
  v-model="records[index][1]"
@@ -19,7 +19,7 @@
19
19
  ></TMagicInput>
20
20
 
21
21
  <TMagicButton
22
- class="m-fileds-key-value-delete"
22
+ class="m-fields-key-value-delete"
23
23
  type="danger"
24
24
  :size="size"
25
25
  :disabled="disabled"
@@ -1,4 +1,4 @@
1
- import { nextTick, ref } from 'vue';
1
+ import { nextTick, ref, useTemplateRef } from 'vue';
2
2
  import { cloneDeep } from 'lodash-es';
3
3
 
4
4
  import type { CodeBlockContent } from '@tmagic/core';
@@ -10,7 +10,7 @@ import type { CodeBlockService } from '@editor/services/codeBlock';
10
10
  export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
11
11
  const codeConfig = ref<CodeBlockContent>();
12
12
  const codeId = ref<string>();
13
- const codeBlockEditor = ref<InstanceType<typeof CodeBlockEditor>>();
13
+ const codeBlockEditor = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
14
14
 
15
15
  // 新增代码块
16
16
  const createCodeBlock = async () => {
@@ -1,9 +1,9 @@
1
- import { onBeforeUnmount, onMounted, type Ref, ref } from 'vue';
1
+ import { onBeforeUnmount, onMounted, ref, type ShallowRef } from 'vue';
2
2
  import Gesto, { type OnDrag } from 'gesto';
3
3
 
4
- export const useGetSo = (target: Ref<HTMLElement | undefined>, emit: (evt: 'change', e: OnDrag<Gesto>) => void) => {
4
+ export const useGetSo = (target: ShallowRef<HTMLElement | null>, emit: (evt: 'change', e: OnDrag<Gesto>) => void) => {
5
5
  let getso: Gesto;
6
- const isDraging = ref(false);
6
+ const isDragging = ref(false);
7
7
 
8
8
  onMounted(() => {
9
9
  if (!target.value) return;
@@ -17,19 +17,19 @@ export const useGetSo = (target: Ref<HTMLElement | undefined>, emit: (evt: 'chan
17
17
  emit('change', e);
18
18
  })
19
19
  .on('dragStart', () => {
20
- isDraging.value = true;
20
+ isDragging.value = true;
21
21
  })
22
22
  .on('dragEnd', () => {
23
- isDraging.value = false;
23
+ isDragging.value = false;
24
24
  });
25
25
  });
26
26
 
27
27
  onBeforeUnmount(() => {
28
28
  getso?.unset();
29
- isDraging.value = false;
29
+ isDragging.value = false;
30
30
  });
31
31
 
32
32
  return {
33
- isDraging,
33
+ isDragging,
34
34
  };
35
35
  };
package/src/index.ts CHANGED
@@ -91,7 +91,8 @@ export { default as KeyValue } from './fields/KeyValue.vue';
91
91
  export { default as CodeBlockList } from './layouts/sidebar/code-block/CodeBlockList.vue';
92
92
  export { default as CodeBlockListPanel } from './layouts/sidebar/code-block/CodeBlockListPanel.vue';
93
93
  export { default as DataSourceConfigPanel } from './layouts/sidebar/data-source/DataSourceConfigPanel.vue';
94
- export { default as PropsPanel } from './layouts/PropsPanel.vue';
94
+ export { default as PropsPanel } from './layouts/props-panel/PropsPanel.vue';
95
+ export { default as PropsFormPanel } from './layouts/props-panel/FormPanel.vue';
95
96
  export { default as ToolButton } from './components/ToolButton.vue';
96
97
  export { default as ContentMenu } from './components/ContentMenu.vue';
97
98
  export { default as Icon } from './components/Icon.vue';
@@ -15,7 +15,7 @@
15
15
  </template>
16
16
 
17
17
  <script lang="ts" setup>
18
- import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
18
+ import { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
19
19
  import { FullScreen } from '@element-plus/icons-vue';
20
20
  import { throttle } from 'lodash-es';
21
21
  import serialize from 'serialize-javascript';
@@ -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 = ref<HTMLDivElement>();
96
+ const codeEditor = useTemplateRef<HTMLDivElement>('codeEditor');
97
97
 
98
98
  const resizeObserver = new globalThis.ResizeObserver(
99
99
  throttle((): void => {
@@ -20,7 +20,7 @@
20
20
  v-model:left="columnWidth.left"
21
21
  v-model:right="columnWidth.right"
22
22
  :min-left="65"
23
- :min-right="20"
23
+ :min-right="420"
24
24
  :min-center="100"
25
25
  :width="frameworkRect?.width || 0"
26
26
  @change="columnWidthChange"
@@ -50,9 +50,7 @@
50
50
  </template>
51
51
 
52
52
  <template v-if="page" #right>
53
- <TMagicScrollbar>
54
- <slot name="props-panel"></slot>
55
- </TMagicScrollbar>
53
+ <slot name="props-panel"></slot>
56
54
  </template>
57
55
  </SplitView>
58
56
 
@@ -62,10 +60,9 @@
62
60
  </template>
63
61
 
64
62
  <script lang="ts" setup>
65
- import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue';
63
+ import { computed, inject, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
66
64
 
67
65
  import type { MPage, MPageFragment } from '@tmagic/core';
68
- import { TMagicScrollbar } from '@tmagic/design';
69
66
 
70
67
  import SplitView from '@editor/components/SplitView.vue';
71
68
  import type { FrameworkSlots, GetColumnWidth, PageBarSortOptions, Services } from '@editor/type';
@@ -93,8 +90,8 @@ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
93
90
  const codeOptions = inject('codeOptions', {});
94
91
  const { editorService, uiService } = inject<Services>('services') || {};
95
92
 
96
- const content = ref<HTMLDivElement>();
97
- const splitView = ref<InstanceType<typeof SplitView>>();
93
+ const content = useTemplateRef<HTMLDivElement>('content');
94
+ const splitView = useTemplateRef<InstanceType<typeof SplitView>>('splitView');
98
95
 
99
96
  const root = computed(() => editorService?.get('root'));
100
97
  const page = computed(() => editorService?.get('page'));
@@ -7,7 +7,7 @@
7
7
  </template>
8
8
 
9
9
  <script lang="ts" setup>
10
- import { computed, inject, markRaw, onBeforeUnmount, onMounted, ref } from 'vue';
10
+ import { computed, inject, markRaw, onBeforeUnmount, onMounted, useTemplateRef } from 'vue';
11
11
  import { Back, Delete, FullScreen, Grid, Memo, Right, ScaleToOriginal, ZoomIn, ZoomOut } from '@element-plus/icons-vue';
12
12
 
13
13
  import { NodeType } from '@tmagic/core';
@@ -190,7 +190,7 @@ const resizeObserver = new ResizeObserver(() => {
190
190
  });
191
191
  }
192
192
  });
193
- const navMenu = ref<HTMLDivElement>();
193
+ const navMenu = useTemplateRef<HTMLDivElement>('navMenu');
194
194
  onMounted(() => {
195
195
  navMenu.value && resizeObserver.observe(navMenu.value);
196
196
  });
@@ -68,7 +68,7 @@
68
68
  </template>
69
69
 
70
70
  <script lang="ts" setup>
71
- import { computed, inject, ref, watch } from 'vue';
71
+ import { computed, inject, ref, useTemplateRef, watch } from 'vue';
72
72
  import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
73
73
 
74
74
  import { type Id, type MPage, type MPageFragment, NodeType } from '@tmagic/core';
@@ -144,8 +144,8 @@ const remove = (node: MPage | MPageFragment) => {
144
144
  editorService?.remove(node);
145
145
  };
146
146
 
147
- const pageBarScrollContainer = ref<InstanceType<typeof PageBarScrollContainer>>();
148
- const pageBarItems = ref<HTMLDivElement[]>();
147
+ const pageBarScrollContainer = useTemplateRef<InstanceType<typeof PageBarScrollContainer>>('pageBarScrollContainer');
148
+ const pageBarItems = useTemplateRef<HTMLDivElement[]>('pageBarItems');
149
149
  watch(page, (page) => {
150
150
  if (
151
151
  !page ||
@@ -24,7 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script setup lang="ts">
27
- import { computed, inject, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
27
+ import { computed, inject, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
28
28
  import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
29
29
  import Sortable, { type SortableEvent } from 'sortablejs';
30
30
 
@@ -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 = ref<HTMLElement>();
49
+ const itemsContainer = useTemplateRef<HTMLElement>('itemsContainer');
50
50
  const canScroll = ref(false);
51
51
 
52
52
  const showAddPageButton = computed(() => uiService?.get('showAddPageButton'));
@@ -75,7 +75,7 @@ const resizeObserver = new ResizeObserver(() => {
75
75
  setCanScroll();
76
76
  });
77
77
 
78
- const pageBar = ref<HTMLDivElement>();
78
+ const pageBar = useTemplateRef<HTMLDivElement>('pageBar');
79
79
  onMounted(() => {
80
80
  pageBar.value && resizeObserver.observe(pageBar.value);
81
81
  });