@tmagic/editor 1.8.2 → 1.8.3

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 (95) hide show
  1. package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +16 -24
  2. package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +2 -2
  3. package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  4. package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +1 -1
  5. package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +1 -1
  6. package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +1 -1
  7. package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +1 -1
  8. package/dist/es/fields/StyleSetter/configs.js +1 -1
  9. package/dist/es/fields/configs/codeSelect.js +5 -7
  10. package/dist/es/fields/configs/displayConds.js +8 -9
  11. package/dist/es/fields/configs/eventSelect.js +30 -27
  12. package/dist/es/hooks/use-stage.js +18 -18
  13. package/dist/es/index.js +9 -16
  14. package/dist/es/initService.js +33 -106
  15. package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +1 -1
  16. package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +2 -2
  17. package/dist/es/layouts/props-panel/use-style-panel.js +1 -1
  18. package/dist/es/sdk/index.js +151 -0
  19. package/dist/es/{services → sdk/services}/BaseService.js +1 -1
  20. package/dist/es/{services/codeBlock.js → sdk/services/CodeBlock.js} +37 -40
  21. package/dist/es/{services/componentList.js → sdk/services/ComponentList.js} +5 -6
  22. package/dist/es/{services/dataSource.js → sdk/services/DataSource.js} +38 -37
  23. package/dist/es/{services/dep.js → sdk/services/Dep.js} +24 -14
  24. package/dist/es/{services/editor.js → sdk/services/Editor.js} +124 -87
  25. package/dist/es/{services/events.js → sdk/services/Events.js} +13 -13
  26. package/dist/es/{services/history.js → sdk/services/History.js} +86 -33
  27. package/dist/es/{services/props.js → sdk/services/Props.js} +25 -26
  28. package/dist/es/{services/storage.js → sdk/services/WebStorage.js} +31 -8
  29. package/dist/es/sdk/utils/dep.js +100 -0
  30. package/dist/es/sdk/utils/operator.js +70 -0
  31. package/dist/es/sdk/utils/position.js +8 -0
  32. package/dist/es/sdk/utils/props.js +281 -0
  33. package/dist/es/sdk/validate/index.js +286 -0
  34. package/dist/es/sdk/wiring.js +163 -0
  35. package/dist/es/sdk.js +15 -0
  36. package/dist/es/services/keybinding.js +21 -21
  37. package/dist/es/services/sdk-instance.js +37 -0
  38. package/dist/es/services/stageOverlay.js +14 -14
  39. package/dist/es/services/ui.js +6 -6
  40. package/dist/es/utils/data-source/formConfigs/base.js +1 -1
  41. package/dist/es/utils/data-source/formConfigs/http.js +1 -1
  42. package/dist/es/utils/editor.js +2 -2
  43. package/dist/es/utils/event.js +25 -21
  44. package/dist/es/utils/operator.js +11 -57
  45. package/dist/es/utils/props.js +12 -282
  46. package/dist/es/utils/type-match-rules.js +10 -12
  47. package/dist/tmagic-editor-headless.umd.cjs +4690 -2891
  48. package/dist/tmagic-editor-sdk.umd.cjs +9911 -0
  49. package/dist/tmagic-editor.umd.cjs +14126 -13312
  50. package/package.json +12 -7
  51. package/src/Editor.vue +11 -9
  52. package/src/fields/configs/codeSelect.ts +6 -9
  53. package/src/fields/configs/displayConds.ts +10 -9
  54. package/src/fields/configs/eventSelect.ts +40 -25
  55. package/src/hooks/use-stage.ts +1 -1
  56. package/src/index.ts +11 -9
  57. package/src/initService.ts +59 -188
  58. package/src/layouts/Framework.vue +1 -1
  59. package/src/layouts/props-panel/PropsPanel.vue +1 -1
  60. package/src/layouts/props-panel/use-style-panel.ts +1 -1
  61. package/src/sdk/index.ts +264 -0
  62. package/src/{services/codeBlock.ts → sdk/services/CodeBlock.ts} +43 -38
  63. package/src/{services/componentList.ts → sdk/services/ComponentList.ts} +8 -7
  64. package/src/{services/dataSource.ts → sdk/services/DataSource.ts} +38 -32
  65. package/src/{services/dep.ts → sdk/services/Dep.ts} +24 -11
  66. package/src/{services/editor.ts → sdk/services/Editor.ts} +175 -86
  67. package/src/{services/events.ts → sdk/services/Events.ts} +15 -12
  68. package/src/{services/history.ts → sdk/services/History.ts} +100 -28
  69. package/src/{services/props.ts → sdk/services/Props.ts} +25 -25
  70. package/src/{services/storage.ts → sdk/services/WebStorage.ts} +41 -7
  71. package/src/sdk/type.ts +191 -0
  72. package/src/sdk/utils/dep.ts +196 -0
  73. package/src/sdk/utils/operator.ts +114 -0
  74. package/src/sdk/utils/position.ts +23 -0
  75. package/src/sdk/utils/props.ts +368 -0
  76. package/src/sdk/validate/index.ts +501 -0
  77. package/src/sdk/wiring.ts +211 -0
  78. package/src/sdk.ts +19 -0
  79. package/src/services/keybinding.ts +2 -2
  80. package/src/services/sdk-instance.ts +66 -0
  81. package/src/services/stageOverlay.ts +2 -2
  82. package/src/services/ui.ts +3 -3
  83. package/src/type.ts +9 -9
  84. package/src/utils/data-source/formConfigs/base.ts +1 -1
  85. package/src/utils/data-source/formConfigs/http.ts +1 -1
  86. package/src/utils/dep/collect-worker-client.ts +9 -6
  87. package/src/utils/dep/worker.ts +5 -0
  88. package/src/utils/editor.ts +2 -1
  89. package/src/utils/event.ts +36 -18
  90. package/src/utils/operator.ts +21 -87
  91. package/src/utils/props.ts +17 -332
  92. package/src/utils/type-match-rules.ts +1 -3
  93. package/types/index.d.ts +742 -528
  94. package/types/sdk.d.ts +2572 -0
  95. /package/src/{services → sdk/services}/BaseService.ts +0 -0
@@ -1,14 +1,22 @@
1
1
  import { toRaw } from 'vue';
2
- import { isEmpty } from 'lodash-es';
3
2
 
4
3
  import type { Id, MContainer, MNode } from '@tmagic/core';
5
- import { NodeType } from '@tmagic/core';
6
- import { calcValueByFontsize, getElById, isPage, isPageOrFragment } from '@tmagic/utils';
7
4
 
8
- import editorService from '@editor/services/editor';
9
- import propsService from '@editor/services/props';
5
+ import { editorService, propsService } from '@editor/services/sdk-instance';
10
6
  import type { AddMNode, PastePosition } from '@editor/type';
11
- import { generatePageNameByApp, getInitPositionStyle } from '@editor/utils/editor';
7
+
8
+ import {
9
+ beforePaste as sdkBeforePaste,
10
+ getAddParent as sdkGetAddParent,
11
+ getDefaultConfig as sdkGetDefaultConfig,
12
+ getPositionInContainer as sdkGetPositionInContainer,
13
+ } from '../sdk/utils/operator';
14
+
15
+ const getContext = () => ({
16
+ editor: editorService,
17
+ props: propsService,
18
+ reactivity: { toRaw } as any,
19
+ });
12
20
 
13
21
  /**
14
22
  * 粘贴前置操作:返回分配了新id以及校准了坐标的配置
@@ -16,55 +24,8 @@ import { generatePageNameByApp, getInitPositionStyle } from '@editor/utils/edito
16
24
  * @param config 待粘贴的元素配置(复制时保存的那份配置)
17
25
  * @returns
18
26
  */
19
- export const beforePaste = (position: PastePosition, config: MNode[], doc?: Document): MNode[] => {
20
- if (!config[0]?.style) return config;
21
- const curNode = editorService.get('node');
22
- // 将数组中第一个元素的坐标作为参照点
23
- const { left: referenceLeft, top: referenceTop } = config[0].style;
24
- // 坐标校准后的粘贴数据
25
- const pasteConfigs: MNode[] = config.map((configItem: MNode): MNode => {
26
- // 解构 position 对象,从 position 删除 offsetX、offsetY字段
27
- const { offsetX = 0, offsetY = 0, ...positionClone } = position;
28
- let pastePosition = positionClone;
29
-
30
- if (!isEmpty(pastePosition) && curNode?.items) {
31
- // 如果没有传入粘贴坐标则可能为键盘操作,不再转换
32
- // 如果粘贴时选中了容器,则将元素粘贴到容器内,坐标需要转换为相对于容器的坐标
33
- pastePosition = getPositionInContainer(pastePosition, curNode.id, doc);
34
- }
35
-
36
- // 将所有待粘贴元素坐标相对于多选第一个元素坐标重新计算,以保证多选粘贴后元素间距不变
37
- if (pastePosition.left && configItem.style?.left) {
38
- pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
39
- }
40
- if (pastePosition.top && configItem.style?.top) {
41
- pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
42
- }
43
- const pasteConfig = propsService.setNewItemId(configItem, false);
44
-
45
- if (pasteConfig.style) {
46
- const { left, top } = pasteConfig.style;
47
- // 判断能转换为数字时,做粘贴偏移量计算
48
- if (typeof left === 'number' || (!!left && !isNaN(Number(left)))) {
49
- pasteConfig.style.left = Number(left) + offsetX;
50
- }
51
- if (typeof top === 'number' || (!!top && !isNaN(Number(top)))) {
52
- pasteConfig.style.top = Number(top) + offsetY;
53
- }
54
-
55
- pasteConfig.style = {
56
- ...pasteConfig.style,
57
- ...pastePosition,
58
- };
59
- }
60
- const root = editorService.get('root');
61
- if (isPageOrFragment(pasteConfig) && root) {
62
- pasteConfig.name = generatePageNameByApp(root, isPage(pasteConfig) ? NodeType.PAGE : NodeType.PAGE_FRAGMENT);
63
- }
64
- return pasteConfig as MNode;
65
- });
66
- return pasteConfigs;
67
- };
27
+ export const beforePaste = (position: PastePosition, config: MNode[], doc?: Document): MNode[] =>
28
+ sdkBeforePaste(getContext(), position, config, doc);
68
29
 
69
30
  /**
70
31
  * 将元素粘贴到容器内时,将相对于画布坐标转换为相对于容器的坐标
@@ -72,37 +33,10 @@ export const beforePaste = (position: PastePosition, config: MNode[], doc?: Docu
72
33
  * @param id 元素id
73
34
  * @returns PastePosition 转换后的坐标
74
35
  */
75
- export const getPositionInContainer = (position: PastePosition = {}, id: Id, doc?: Document) => {
76
- let { left = 0, top = 0 } = position;
77
- const stageDoc = editorService.get('stage')?.renderer?.contentWindow?.document;
78
- const parentEl = stageDoc && getElById()(stageDoc, `${id}`);
79
- const parentElRect = parentEl?.getBoundingClientRect();
80
- left = left - calcValueByFontsize(doc, parentElRect?.left || 0);
81
- top = top - calcValueByFontsize(doc, parentElRect?.top || 0);
82
- return {
83
- left,
84
- top,
85
- };
86
- };
87
-
88
- export const getAddParent = (node: MNode) => {
89
- const curNode = editorService.get('node');
36
+ export const getPositionInContainer = (position: PastePosition = {}, id: Id, doc?: Document) =>
37
+ sdkGetPositionInContainer(getContext(), position, id, doc);
90
38
 
91
- let parentNode;
92
- if (isPage(node)) {
93
- parentNode = editorService.get('root');
94
- } else if (curNode?.items) {
95
- parentNode = curNode as MContainer;
96
- } else if (curNode?.id) {
97
- parentNode = editorService.getParentById(curNode.id, false);
98
- }
99
- return parentNode;
100
- };
39
+ export const getAddParent = (node: MNode) => sdkGetAddParent(getContext(), node);
101
40
 
102
- export const getDefaultConfig = async (addNode: AddMNode, parentNode: MContainer) => {
103
- const { type, inputEvent, ...config } = addNode;
104
- const layout = await editorService.getLayout(toRaw(parentNode), addNode as MNode);
105
- const newNode = { ...toRaw(await propsService.getPropsValue(type, config)) };
106
- newNode.style = getInitPositionStyle(newNode.style, layout);
107
- return newNode;
108
- };
41
+ export const getDefaultConfig = (addNode: AddMNode, parentNode: MContainer) =>
42
+ sdkGetDefaultConfig(getContext(), addNode, parentNode);
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
1
  /*
3
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
4
3
  *
@@ -16,341 +15,27 @@
16
15
  * See the License for the specific language governing permissions and
17
16
  * limitations under the License.
18
17
  */
19
- import {
20
- HookType,
21
- NODE_CONDS_KEY,
22
- NODE_CONDS_RESULT_KEY,
23
- NODE_DISABLE_CODE_BLOCK_KEY,
24
- NODE_DISABLE_DATA_SOURCE_KEY,
25
- } from '@tmagic/core';
26
- import { tMagicMessage } from '@tmagic/design';
27
- import type { ChildConfig, DisplayCondsConfig, FormConfig, TabConfig, TabPaneConfig } from '@tmagic/form';
28
-
29
- export const arrayOptions = [
30
- { text: '包含', value: 'include' },
31
- { text: '不包含', value: 'not_include' },
32
- ];
33
-
34
- export const eqOptions = [
35
- { text: '等于', value: '=' },
36
- { text: '不等于', value: '!=' },
37
- ];
38
-
39
- export const numberOptions = [
40
- { text: '大于', value: '>' },
41
- { text: '大于等于', value: '>=' },
42
- { text: '小于', value: '<' },
43
- { text: '小于等于', value: '<=' },
44
- { text: '在范围内', value: 'between' },
45
- { text: '不在范围内', value: 'not_between' },
46
- ];
47
-
48
- export const booleanOptions = [
49
- { text: '是', value: 'is' },
50
- { text: '不是', value: 'not' },
51
- ];
52
-
53
- /** 按字段类型返回条件运算符选项(UI 与 typeMatch 校验共用) */
54
- export const getCondOpOptionsByFieldType = (type: string) => {
55
- if (type === 'array') {
56
- return arrayOptions;
57
- }
58
-
59
- if (type === 'boolean' || type === 'null') {
60
- return booleanOptions;
61
- }
62
18
 
63
- if (type === 'number') {
64
- return [...eqOptions, ...numberOptions];
65
- }
66
-
67
- if (type === 'string') {
68
- return [...arrayOptions, ...eqOptions];
69
- }
70
-
71
- return [...arrayOptions, ...eqOptions, ...numberOptions];
72
- };
19
+ import { tMagicMessage } from '@tmagic/design';
20
+ import type { FormConfig } from '@tmagic/form';
73
21
 
74
- export const styleTabConfig: TabPaneConfig = {
75
- title: '样式',
76
- display: ({ services }: any) => !(services?.uiService?.get('showStylePanel') ?? true),
77
- items: [
78
- {
79
- name: 'style',
80
- labelWidth: '100px',
81
- type: 'style-setter',
82
- items: [
83
- {
84
- names: [
85
- 'display',
86
- 'flexDirection',
87
- 'justifyContent',
88
- 'alignItems',
89
- 'flexWrap',
90
- 'marginTop',
91
- 'marginRight',
92
- 'marginBottom',
93
- 'marginLeft',
94
- 'paddingTop',
95
- 'paddingRight',
96
- 'paddingBottom',
97
- 'paddingLeft',
98
- 'width',
99
- 'height',
100
- 'overflow',
101
- 'fontSize',
102
- 'lineHeight',
103
- 'fontWeight',
104
- 'color',
105
- 'textAlign',
106
- 'backgroundColor',
107
- 'backgroundImage',
108
- 'backgroundSize',
109
- 'backgroundPosition',
110
- 'backgroundRepeat',
111
- 'position',
112
- 'zIndex',
113
- 'top',
114
- 'right',
115
- 'bottom',
116
- 'left',
117
- 'borderRadius',
118
- 'borderTopWidth',
119
- 'borderTopStyle',
120
- 'borderTopColor',
121
- 'borderRightColor',
122
- 'borderRightWidth',
123
- 'borderRightStyle',
124
- 'borderRightColor',
125
- 'borderBottomWidth',
126
- 'borderBottomStyle',
127
- 'borderBottomColor',
128
- 'borderLeftStyle',
129
- 'borderLeftWidth',
130
- 'borderLeftColor',
131
- 'borderWidth',
132
- 'borderStyle',
133
- 'borderColor',
134
- 'opacity',
135
- ],
136
- } as unknown as ChildConfig,
137
- {
138
- name: 'transform',
139
- defaultValue: () => ({}),
140
- },
141
- ],
142
- },
143
- ],
144
- };
22
+ import type { FillConfigOptions } from '@editor/sdk/utils/props';
23
+ import { fillConfig as sdkFillConfig } from '@editor/sdk/utils/props';
145
24
 
146
- export const eventTabConfig: TabPaneConfig = {
147
- title: '事件',
148
- items: [
149
- {
150
- name: 'events',
151
- src: 'component',
152
- labelWidth: '100px',
153
- type: 'event-select',
154
- defaultValue: [],
155
- rules: [{ typeMatch: true }],
156
- },
157
- ],
158
- };
25
+ export * from '@editor/sdk/utils/props';
159
26
 
160
- export const advancedTabConfig: TabPaneConfig = {
161
- title: '高级',
162
- items: [
163
- {
164
- name: NODE_DISABLE_CODE_BLOCK_KEY,
165
- text: '禁用代码块',
166
- type: 'switch',
167
- defaultValue: false,
168
- extra: '开启后,配置的代码块将不会被执行',
169
- },
170
- {
171
- name: NODE_DISABLE_DATA_SOURCE_KEY,
172
- text: '禁用数据源',
173
- type: 'switch',
174
- defaultValue: false,
175
- extra: '开启后,组件内配置的数据源相关配置将不会被编译,显隐条件将失效',
176
- },
177
- {
178
- name: 'created',
179
- text: 'Created',
180
- labelPosition: 'top',
181
- type: 'code-select',
182
- titleExtra: '组件初始化时执行',
183
- rules: [
184
- { typeMatch: true, trigger: 'change' },
185
- {
186
- validator: ({ value, callback }: any) => {
187
- if (value && value.hookType !== HookType.CODE) {
188
- return callback('hookType 必须是 code');
189
- }
190
- callback();
191
- },
192
- },
193
- ],
194
- },
195
- {
196
- name: 'mounted',
197
- text: 'Mounted',
198
- labelPosition: 'top',
199
- type: 'code-select',
200
- titleExtra: '组件挂载到dom时执行',
201
- rules: [
202
- { typeMatch: true, trigger: 'change' },
203
- {
204
- validator: ({ value, callback }: any) => {
205
- if (value && value.hookType !== HookType.CODE) {
206
- return callback('hookType 必须是 code');
207
- }
208
- callback();
209
- },
210
- },
211
- ],
212
- },
213
- {
214
- name: 'display',
215
- text: 'Display',
216
- titleExtra: '控制组件是否渲染,关系的代码块返回值为false时不渲染',
217
- labelPosition: 'top',
218
- type: 'code-select',
219
- rules: [
220
- { typeMatch: true, trigger: 'change' },
221
- {
222
- validator: ({ value, callback }: any) => {
223
- if (value && value.hookType !== HookType.CODE) {
224
- return callback('hookType 必须是 code');
225
- }
226
- callback();
227
- },
228
- },
229
- ],
230
- },
231
- ],
232
- };
27
+ /** 浏览器端默认用 `navigator.clipboard` 复制,并用 `tMagicMessage` 提示 */
28
+ export const copyTextToClipboard = (text: string): Promise<void> => navigator.clipboard.writeText(text);
233
29
 
234
- export const displayTabConfig: TabPaneConfig<DisplayCondsConfig> = {
235
- title: '显示条件',
236
- display: (_state, { model }) => model.type !== 'page',
237
- items: [
238
- {
239
- name: NODE_CONDS_RESULT_KEY,
240
- type: 'select',
241
- text: '条件成立时',
242
- defaultValue: false,
243
- options: [
244
- { text: '显示', value: false },
245
- { text: '隐藏', value: true },
246
- ],
247
- extra: (_state, { model }) =>
248
- `条件成立时${model[NODE_CONDS_RESULT_KEY] ? '隐藏' : '显示'},不成立时${model[NODE_CONDS_RESULT_KEY] ? '显示' : '隐藏'};<br />同一条件组内的所有条件配置同时成立时表示该条件组成立,任意一个条件组成立时表示条件成立(条件组内为且的关系,条件组间为或的关系);<br />条件为空时表示成立;`,
249
- },
250
- {
251
- text: '条件组配置',
252
- static: true,
253
- className: 'display-conds-title',
254
- },
255
- {
256
- type: 'display-conds',
257
- name: NODE_CONDS_KEY,
258
- titlePrefix: '条件组',
259
- defaultValue: [],
260
- rules: [{ typeMatch: true }],
261
- },
262
- ],
30
+ export const notifyByDesign = (type: 'success' | 'error' | 'warning' | 'info', message: string) => {
31
+ const fn = (tMagicMessage as any)[type] ?? tMagicMessage;
32
+ fn(message);
263
33
  };
264
34
 
265
- /**
266
- * 统一为组件属性表单加上事件、高级、样式配置
267
- * @param config 组件属性配置
268
- * @returns Object
269
- */
270
- export const fillConfig = (
271
- config: FormConfig = [],
272
- {
273
- labelWidth = '80px',
274
- disabledDataSource = false,
275
- disabledCodeBlock = false,
276
- }: { labelWidth?: string; disabledDataSource?: boolean; disabledCodeBlock?: boolean } = {},
277
- ): FormConfig => {
278
- const propsConfig: FormConfig = [];
279
-
280
- // 组件类型,必须要有
281
- if (!config.find((item) => 'name' in item && item.name === 'type')) {
282
- propsConfig.push({
283
- text: 'type',
284
- name: 'type',
285
- type: 'hidden',
286
- });
287
- }
288
-
289
- if (!config.find((item) => 'name' in item && item.name === 'id')) {
290
- // 组件id,必须要有
291
- propsConfig.push({
292
- name: 'id',
293
- text: 'ID',
294
- type: 'text',
295
- // 走纯文本渲染,避免出现 disabled 的灰底输入框;append 仍正常显示。
296
- static: true,
297
-
298
- append: {
299
- type: 'icon',
300
- text: 'https://vip.image.video.qpic.cn/vupload/20260615/36cf7e1781493669935.svg',
301
- extra: '复制',
302
- handler: (vm, { model }) => {
303
- navigator.clipboard
304
- .writeText(`${model.id}`)
305
- .then(() => {
306
- tMagicMessage.success('已复制');
307
- })
308
- .catch(() => {
309
- tMagicMessage.error('复制失败');
310
- });
311
- },
312
- },
313
- });
314
- }
315
-
316
- if (!config.find((item) => 'name' in item && item.name === 'name')) {
317
- propsConfig.push({
318
- name: 'name',
319
- text: '组件名称',
320
- });
321
- }
322
-
323
- const noCodeAdvancedTabItems = advancedTabConfig.items.filter(
324
- (item) => 'type' in item && item.type !== 'code-select',
325
- );
326
-
327
- if (noCodeAdvancedTabItems.length > 0 && disabledCodeBlock) {
328
- advancedTabConfig.items = noCodeAdvancedTabItems;
329
- }
330
-
331
- const tabConfig: TabConfig = {
332
- type: 'tab',
333
- labelWidth,
334
- className: 'magic-right-panel-tabs-top',
335
- items: [
336
- {
337
- title: '属性',
338
- items: [...propsConfig, ...config],
339
- },
340
- { ...styleTabConfig },
341
- { ...eventTabConfig },
342
- ],
343
- };
344
-
345
- if (!disabledCodeBlock) {
346
- tabConfig.items.push({ ...advancedTabConfig });
347
- } else if (noCodeAdvancedTabItems.length > 0) {
348
- tabConfig.items.push({ ...advancedTabConfig });
349
- }
350
-
351
- if (!disabledDataSource) {
352
- tabConfig.items.push({ ...displayTabConfig });
353
- }
354
-
355
- return [tabConfig];
356
- };
35
+ /** 与 SDK 的 `fillConfig` 一致,区别是默认接入浏览器的剪贴板与消息提示 */
36
+ export const fillConfig = (config: FormConfig = [], options: FillConfigOptions = {}): FormConfig =>
37
+ sdkFillConfig(config, {
38
+ copyText: copyTextToClipboard,
39
+ notify: notifyByDesign,
40
+ ...options,
41
+ });
@@ -35,9 +35,7 @@ import {
35
35
  removeDataSourceFieldPrefix,
36
36
  } from '@tmagic/utils';
37
37
 
38
- import codeBlockService from '@editor/services/codeBlock';
39
- import dataSourceService from '@editor/services/dataSource';
40
- import editorService from '@editor/services/editor';
38
+ import { codeBlockService, dataSourceService, editorService } from '@editor/services/sdk-instance';
41
39
  import { getFieldType, resolveFieldByPath } from '@editor/utils/data-source';
42
40
  import {
43
41
  arrayOptions,