@tmagic/editor 1.5.20 → 1.5.22

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.
@@ -19,7 +19,7 @@
19
19
 
20
20
  import { NODE_CONDS_KEY } from '@tmagic/core';
21
21
  import { tMagicMessage } from '@tmagic/design';
22
- import type { FormConfig, FormState, TabPaneConfig } from '@tmagic/form';
22
+ import type { FormConfig, FormState, TabConfig, TabPaneConfig } from '@tmagic/form';
23
23
 
24
24
  export const arrayOptions = [
25
25
  { text: '包含', value: 'include' },
@@ -165,7 +165,14 @@ export const displayTabConfig: TabPaneConfig = {
165
165
  * @param config 组件属性配置
166
166
  * @returns Object
167
167
  */
168
- export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormConfig => {
168
+ export const fillConfig = (
169
+ config: FormConfig = [],
170
+ {
171
+ labelWidth = '80px',
172
+ disabledDataSource = false,
173
+ disabledCodeBlock = false,
174
+ }: { labelWidth?: string; disabledDataSource?: boolean; disabledCodeBlock?: boolean } = {},
175
+ ): FormConfig => {
169
176
  const propsConfig: FormConfig = [];
170
177
 
171
178
  // 组件类型,必须要有
@@ -208,20 +215,34 @@ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormCo
208
215
  });
209
216
  }
210
217
 
211
- return [
212
- {
213
- type: 'tab',
214
- labelWidth,
215
- items: [
216
- {
217
- title: '属性',
218
- items: [...propsConfig, ...config],
219
- },
220
- { ...styleTabConfig },
221
- { ...eventTabConfig },
222
- { ...advancedTabConfig },
223
- { ...displayTabConfig },
224
- ],
225
- },
226
- ];
218
+ const noCodeAdvancedTabItems = advancedTabConfig.items.filter((item) => item.type !== 'code-select');
219
+
220
+ if (noCodeAdvancedTabItems.length > 0 && disabledCodeBlock) {
221
+ advancedTabConfig.items = noCodeAdvancedTabItems;
222
+ }
223
+
224
+ const tabConfig: TabConfig = {
225
+ type: 'tab',
226
+ labelWidth,
227
+ items: [
228
+ {
229
+ title: '属性',
230
+ items: [...propsConfig, ...config],
231
+ },
232
+ { ...styleTabConfig },
233
+ { ...eventTabConfig },
234
+ ],
235
+ };
236
+
237
+ if (!disabledCodeBlock) {
238
+ tabConfig.items.push({ ...advancedTabConfig });
239
+ } else if (noCodeAdvancedTabItems.length > 0) {
240
+ tabConfig.items.push({ ...advancedTabConfig });
241
+ }
242
+
243
+ if (!disabledDataSource) {
244
+ tabConfig.items.push({ ...displayTabConfig });
245
+ }
246
+
247
+ return [tabConfig];
227
248
  };