@tmagic/editor 1.3.0-alpha.18 → 1.3.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.0-alpha.18",
2
+ "version": "1.3.0-alpha.19",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -46,13 +46,13 @@
46
46
  "dependencies": {
47
47
  "@babel/core": "^7.18.0",
48
48
  "@element-plus/icons-vue": "^2.0.9",
49
- "@tmagic/core": "1.3.0-alpha.18",
50
- "@tmagic/design": "1.3.0-alpha.18",
51
- "@tmagic/form": "1.3.0-alpha.18",
52
- "@tmagic/schema": "1.3.0-alpha.18",
53
- "@tmagic/stage": "1.3.0-alpha.18",
54
- "@tmagic/table": "1.3.0-alpha.18",
55
- "@tmagic/utils": "1.3.0-alpha.18",
49
+ "@tmagic/core": "1.3.0-alpha.19",
50
+ "@tmagic/design": "1.3.0-alpha.19",
51
+ "@tmagic/form": "1.3.0-alpha.19",
52
+ "@tmagic/schema": "1.3.0-alpha.19",
53
+ "@tmagic/stage": "1.3.0-alpha.19",
54
+ "@tmagic/table": "1.3.0-alpha.19",
55
+ "@tmagic/utils": "1.3.0-alpha.19",
56
56
  "buffer": "^6.0.3",
57
57
  "color": "^3.1.3",
58
58
  "events": "^3.3.0",
@@ -64,8 +64,8 @@
64
64
  "vue": "^3.3.4"
65
65
  },
66
66
  "peerDependencies": {
67
- "@tmagic/design": "1.3.0-alpha.18",
68
- "@tmagic/form": "1.3.0-alpha.18",
67
+ "@tmagic/design": "1.3.0-alpha.19",
68
+ "@tmagic/form": "1.3.0-alpha.19",
69
69
  "monaco-editor": "^0.41.0",
70
70
  "vue": "^3.3.4"
71
71
  },
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <MFormDrawer
3
+ class="m-editor-code-block-editor"
3
4
  ref="fomDrawer"
4
5
  label-width="80px"
5
6
  :close-on-press-escape="false"
@@ -28,9 +29,10 @@ defineOptions({
28
29
  name: 'MEditorCodeBlockEditor',
29
30
  });
30
31
 
31
- defineProps<{
32
+ const props = defineProps<{
32
33
  content: CodeBlockContent;
33
34
  disabled?: boolean;
35
+ isDataSource?: boolean;
34
36
  }>();
35
37
 
36
38
  const emit = defineEmits<{
@@ -40,7 +42,9 @@ const emit = defineEmits<{
40
42
  const services = inject<Services>('services');
41
43
 
42
44
  const columnWidth = computed(() => services?.uiService.get('columnWidth'));
43
- const size = computed(() => (columnWidth.value ? columnWidth.value.center + columnWidth.value.right : 600));
45
+ const size = computed(() =>
46
+ columnWidth.value ? columnWidth.value.center + columnWidth.value.right - (props.isDataSource ? 100 : 0) : 600,
47
+ );
44
48
 
45
49
  const codeEditorHeight = ref('600px');
46
50
 
@@ -80,16 +84,26 @@ const functionConfig = computed(() => [
80
84
  name: 'name',
81
85
  },
82
86
  {
83
- text: '注释',
87
+ text: '描述',
84
88
  name: 'desc',
85
89
  },
90
+ {
91
+ text: '执行时机',
92
+ name: 'timing',
93
+ type: 'select',
94
+ options: [
95
+ { text: '初始化前', value: 'beforeInit' },
96
+ { text: '初始化后', value: 'afterInit' },
97
+ ],
98
+ display: () => props.isDataSource,
99
+ },
86
100
  {
87
101
  type: 'table',
88
102
  border: true,
89
103
  text: '参数',
90
104
  enableFullscreen: false,
105
+ enableToggleMode: false,
91
106
  name: 'params',
92
- maxHeight: '300px',
93
107
  dropSort: false,
94
108
  items: [
95
109
  {
@@ -99,7 +113,7 @@ const functionConfig = computed(() => [
99
113
  },
100
114
  {
101
115
  type: 'text',
102
- label: '注释',
116
+ label: '描述',
103
117
  name: 'extra',
104
118
  },
105
119
  services?.codeBlockService.getParamsColConfig() || defaultParamColConfig,
@@ -138,7 +152,7 @@ const fomDrawer = ref<InstanceType<typeof MFormDrawer>>();
138
152
  const openHandler = () => {
139
153
  setTimeout(() => {
140
154
  if (fomDrawer.value) {
141
- const height = fomDrawer.value?.bodyHeight - 468;
155
+ const height = fomDrawer.value?.bodyHeight - 348 - (props.isDataSource ? 50 : 0);
142
156
  codeEditorHeight.value = `${height > 100 ? height : 600}px`;
143
157
  }
144
158
  });
@@ -43,8 +43,8 @@ import type { Id } from '@tmagic/schema';
43
43
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
44
44
  import CodeParams from '@editor/components/CodeParams.vue';
45
45
  import Icon from '@editor/components/Icon.vue';
46
+ import { useCodeBlockEdit } from '@editor/hooks/use-code-block-edit';
46
47
  import type { CodeParamStatement, CodeSelectColConfig, Services } from '@editor/type';
47
- import { useCodeBlockEdit } from '@editor/utils/use-code-block-edit';
48
48
 
49
49
  defineOptions({
50
50
  name: 'MEditorCodeSelectCol',
@@ -6,15 +6,16 @@
6
6
  <TMagicButton size="small" type="primary" :disabled="disabled" plain @click="newHandler()">添加</TMagicButton>
7
7
  </div>
8
8
 
9
- <MFormDialog
9
+ <MFormDrawer
10
10
  ref="addDialog"
11
+ label-width="80px"
11
12
  :title="filedTitle"
12
13
  :config="dataSourceFieldsConfig"
13
14
  :values="fieldValues"
14
15
  :parentValues="model[name]"
15
16
  :disabled="disabled"
16
17
  @submit="fieldChange"
17
- ></MFormDialog>
18
+ ></MFormDrawer>
18
19
  </div>
19
20
  </template>
20
21
 
@@ -22,7 +23,7 @@
22
23
  import { ref } from 'vue';
23
24
 
24
25
  import { TMagicButton, tMagicMessageBox } from '@tmagic/design';
25
- import { FieldProps, FormConfig, FormState, MFormDialog } from '@tmagic/form';
26
+ import { FieldProps, FormConfig, FormState, MFormDrawer } from '@tmagic/form';
26
27
  import { MagicTable } from '@tmagic/table';
27
28
 
28
29
  defineOptions({
@@ -42,7 +43,7 @@ const props = withDefaults(
42
43
 
43
44
  const emit = defineEmits(['change']);
44
45
 
45
- const addDialog = ref<InstanceType<typeof MFormDialog>>();
46
+ const addDialog = ref<InstanceType<typeof MFormDrawer>>();
46
47
  const fieldValues = ref<Record<string, any>>({});
47
48
  const filedTitle = ref('');
48
49
 
@@ -77,6 +78,10 @@ const fieldColumns = [
77
78
  label: '属性描述',
78
79
  prop: 'desc',
79
80
  },
81
+ {
82
+ label: '默认值',
83
+ prop: 'defaultValue',
84
+ },
80
85
  {
81
86
  label: '操作',
82
87
  fixed: 'right',
@@ -154,6 +159,7 @@ const dataSourceFieldsConfig: FormConfig = [
154
159
  {
155
160
  name: 'description',
156
161
  text: '描述',
162
+ type: 'textarea',
157
163
  },
158
164
  {
159
165
  name: 'defaultValue',
@@ -40,8 +40,8 @@ import type { CodeBlockContent, Id } from '@tmagic/schema';
40
40
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
41
41
  import CodeParams from '@editor/components/CodeParams.vue';
42
42
  import Icon from '@editor/components/Icon.vue';
43
+ import { useDataSourceMethod } from '@editor/hooks/use-data-source-method';
43
44
  import type { CodeParamStatement, DataSourceMethodSelectConfig, Services } from '@editor/type';
44
- import { useDataSourceMethod } from '@editor/utils/use-data-source-method';
45
45
 
46
46
  defineOptions({
47
47
  name: 'MEditorDataSourceMethodSelect',
@@ -9,10 +9,11 @@
9
9
  </div>
10
10
 
11
11
  <CodeBlockEditor
12
- ref="codeBlockEditor"
13
12
  v-if="codeConfig"
13
+ ref="codeBlockEditor"
14
14
  :disabled="disabled"
15
15
  :content="codeConfig"
16
+ :is-data-source="true"
16
17
  @submit="submitCodeHandler"
17
18
  ></CodeBlockEditor>
18
19
  </div>
@@ -25,8 +26,8 @@ import type { CodeBlockContent } from '@tmagic/schema';
25
26
  import { MagicTable } from '@tmagic/table';
26
27
 
27
28
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
29
+ import { useDataSourceMethod } from '@editor/hooks/use-data-source-method';
28
30
  import type { CodeParamStatement } from '@editor/type';
29
- import { useDataSourceMethod } from '@editor/utils/use-data-source-method';
30
31
 
31
32
  defineOptions({
32
33
  name: 'MEditorDataSourceMethods',
@@ -53,9 +54,13 @@ const methodColumns = [
53
54
  prop: 'name',
54
55
  },
55
56
  {
56
- label: '注释',
57
+ label: '描述',
57
58
  prop: 'desc',
58
59
  },
60
+ {
61
+ label: '执行时机',
62
+ prop: 'timing',
63
+ },
59
64
  {
60
65
  label: '参数',
61
66
  prop: 'params',
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making TMagicEditor available.
3
+ *
4
+ * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ export * from './use-code-block-edit';
20
+ export * from './use-data-source-method';
21
+ export * from './use-stage';
@@ -5,8 +5,7 @@ import { tMagicMessage } from '@tmagic/design';
5
5
  import type { CodeBlockContent, DataSourceSchema } from '@tmagic/schema';
6
6
 
7
7
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
8
-
9
- import { getConfig } from './config';
8
+ import { getConfig } from '@editor/utils/config';
10
9
 
11
10
  export const useDataSourceMethod = () => {
12
11
  const codeConfig = ref<CodeBlockContent>();
@@ -6,8 +6,7 @@ import StageCore, { GuidesType, RemoveEventData, SortEventData, UpdateEventData
6
6
  import editorService from '@editor/services/editor';
7
7
  import uiService from '@editor/services/ui';
8
8
  import { H_GUIDE_LINE_STORAGE_KEY, StageOptions, V_GUIDE_LINE_STORAGE_KEY } from '@editor/type';
9
-
10
- import { getGuideLineFromCache } from './editor';
9
+ import { getGuideLineFromCache } from '@editor/utils/editor';
11
10
 
12
11
  const root = computed(() => editorService.get('root'));
13
12
  const page = computed(() => editorService.get('page'));
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ import './theme/index.scss';
39
39
 
40
40
  export type { MoveableOptions } from '@tmagic/stage';
41
41
  export * from './type';
42
+ export * from './hooks';
42
43
  export * from './utils';
43
44
  export { default as TMagicEditor } from './Editor.vue';
44
45
  export { default as TMagicCodeEditor } from './layouts/CodeEditor.vue';
@@ -35,8 +35,8 @@ import type { Id } from '@tmagic/schema';
35
35
 
36
36
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
37
37
  import SearchInput from '@editor/components/SearchInput.vue';
38
+ import { useCodeBlockEdit } from '@editor/hooks/use-code-block-edit';
38
39
  import type { CodeDeleteErrorType, Services } from '@editor/type';
39
- import { useCodeBlockEdit } from '@editor/utils/use-code-block-edit';
40
40
 
41
41
  import CodeBlockList from './CodeBlockList.vue';
42
42
 
@@ -36,9 +36,9 @@ import type { MContainer } from '@tmagic/schema';
36
36
  import StageCore, { calcValueByFontsize, getOffset, Runtime } from '@tmagic/stage';
37
37
 
38
38
  import ScrollViewer from '@editor/components/ScrollViewer.vue';
39
+ import { useStage } from '@editor/hooks/use-stage';
39
40
  import { Layout, MenuButton, MenuComponent, Services, StageOptions } from '@editor/type';
40
41
  import { getConfig } from '@editor/utils/config';
41
- import { useStage } from '@editor/utils/stage';
42
42
 
43
43
  import ViewerMenu from './ViewerMenu.vue';
44
44
 
@@ -24,3 +24,13 @@
24
24
  display: none;
25
25
  }
26
26
  }
27
+
28
+ .m-editor-code-block-editor {
29
+ .tmagic-design-table {
30
+ height: 180px;
31
+ }
32
+
33
+ .el-drawer__body {
34
+ padding: 10px 20px;
35
+ }
36
+ }
@@ -20,5 +20,4 @@ export * from './config';
20
20
  export * from './props';
21
21
  export * from './logger';
22
22
  export * from './editor';
23
- export * from './stage';
24
23
  export * from './operator';
@@ -2,12 +2,14 @@ import type { CodeBlockContent } from '@tmagic/schema';
2
2
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
3
  content: CodeBlockContent;
4
4
  disabled?: boolean | undefined;
5
+ isDataSource?: boolean | undefined;
5
6
  }>, {
6
7
  show(): void;
7
8
  hide(): void;
8
9
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
9
10
  content: CodeBlockContent;
10
11
  disabled?: boolean | undefined;
12
+ isDataSource?: boolean | undefined;
11
13
  }>>>, {}, {}>;
12
14
  export default _default;
13
15
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,7 +1,7 @@
1
1
  import type { MenuButton, MenuComponent } from '../type';
2
2
  declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
3
  data?: MenuButton | MenuComponent | undefined;
4
- eventType?: "mousedown" | "click" | "mouseup" | undefined;
4
+ eventType?: "click" | "mousedown" | "mouseup" | undefined;
5
5
  }>, {
6
6
  data: () => {
7
7
  type: string;
@@ -10,7 +10,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
10
10
  eventType: string;
11
11
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
12
12
  data?: MenuButton | MenuComponent | undefined;
13
- eventType?: "mousedown" | "click" | "mouseup" | undefined;
13
+ eventType?: "click" | "mousedown" | "mouseup" | undefined;
14
14
  }>, {
15
15
  data: () => {
16
16
  type: string;
@@ -19,7 +19,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
19
19
  eventType: string;
20
20
  }>>>, {
21
21
  data: MenuButton | MenuComponent;
22
- eventType: "mousedown" | "click" | "mouseup";
22
+ eventType: "click" | "mousedown" | "mouseup";
23
23
  }, {}>;
24
24
  export default _default;
25
25
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -0,0 +1,3 @@
1
+ export * from './use-code-block-edit';
2
+ export * from './use-data-source-method';
3
+ export * from './use-stage';
@@ -54,6 +54,7 @@ export declare const useCodeBlockEdit: (codeBlockService?: CodeBlockService) =>
54
54
  style?: unknown;
55
55
  readonly content: CodeBlockContent;
56
56
  readonly disabled?: boolean | undefined;
57
+ readonly isDataSource?: boolean | undefined;
57
58
  };
58
59
  $attrs: {
59
60
  [x: string]: unknown;
@@ -76,6 +77,9 @@ export declare const useCodeBlockEdit: (codeBlockService?: CodeBlockService) =>
76
77
  disabled: {
77
78
  type: import("vue").PropType<boolean>;
78
79
  };
80
+ isDataSource: {
81
+ type: import("vue").PropType<boolean>;
82
+ };
79
83
  }>>, {
80
84
  show(): void;
81
85
  hide(): void;
@@ -107,6 +111,9 @@ export declare const useCodeBlockEdit: (codeBlockService?: CodeBlockService) =>
107
111
  disabled: {
108
112
  type: import("vue").PropType<boolean>;
109
113
  };
114
+ isDataSource: {
115
+ type: import("vue").PropType<boolean>;
116
+ };
110
117
  }>> & import("vue").ShallowUnwrapRef<{
111
118
  show(): void;
112
119
  hide(): void;
@@ -52,6 +52,7 @@ export declare const useDataSourceMethod: () => {
52
52
  style?: unknown;
53
53
  readonly content: CodeBlockContent;
54
54
  readonly disabled?: boolean | undefined;
55
+ readonly isDataSource?: boolean | undefined;
55
56
  };
56
57
  $attrs: {
57
58
  [x: string]: unknown;
@@ -74,6 +75,9 @@ export declare const useDataSourceMethod: () => {
74
75
  disabled: {
75
76
  type: import("vue").PropType<boolean>;
76
77
  };
78
+ isDataSource: {
79
+ type: import("vue").PropType<boolean>;
80
+ };
77
81
  }>>, {
78
82
  show(): void;
79
83
  hide(): void;
@@ -105,6 +109,9 @@ export declare const useDataSourceMethod: () => {
105
109
  disabled: {
106
110
  type: import("vue").PropType<boolean>;
107
111
  };
112
+ isDataSource: {
113
+ type: import("vue").PropType<boolean>;
114
+ };
108
115
  }>> & import("vue").ShallowUnwrapRef<{
109
116
  show(): void;
110
117
  hide(): void;
package/types/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { InstallOptions } from './type';
3
3
  import './theme/index.scss';
4
4
  export type { MoveableOptions } from '@tmagic/stage';
5
5
  export * from './type';
6
+ export * from './hooks';
6
7
  export * from './utils';
7
8
  export { default as TMagicEditor } from './Editor.vue';
8
9
  export { default as TMagicCodeEditor } from './layouts/CodeEditor.vue';
@@ -2,5 +2,4 @@ export * from './config';
2
2
  export * from './props';
3
3
  export * from './logger';
4
4
  export * from './editor';
5
- export * from './stage';
6
5
  export * from './operator';
File without changes