@tmagic/editor 1.8.0-manmanyu.12 → 1.8.0-manmanyu.14

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.
@@ -67,11 +67,18 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
67
67
  const hasCurrent = computed(() => payload.value?.currentValue !== void 0 && payload.value?.currentValue !== null);
68
68
  /** 是否存在该步「修改后的值」:不存在(如仅删除)时「与修改前对比」无意义,置灰禁用。 */
69
69
  const hasValue = computed(() => payload.value?.value !== void 0 && payload.value?.value !== null);
70
+ /** 指定模式当前是否可用:before 依赖「修改后的值」,current 依赖「当前值」。 */
71
+ const isModeAvailable = (m) => m === "current" ? hasCurrent.value : hasValue.value;
70
72
  /**
71
73
  * 计算 open 时的初始对比模式:
72
- * 没有「修改后的值」但有当前值时(「与修改前对比」不可用),默认进入「与当前对比」;否则默认「与修改前对比」。
74
+ * - 调用方通过 payload.mode 指定且该模式可用时,优先使用指定模式;
75
+ * - 否则没有「修改后的值」但有当前值时(「与修改前对比」不可用),默认进入「与当前对比」;
76
+ * - 其余情况默认「与修改前对比」。
73
77
  */
74
- const resolveInitialMode = () => !hasValue.value && hasCurrent.value ? "current" : "before";
78
+ const resolveInitialMode = (specified) => {
79
+ if (specified && isModeAvailable(specified)) return specified;
80
+ return !hasValue.value && hasCurrent.value ? "current" : "before";
81
+ };
75
82
  /** 左侧(旧/参照)值 */
76
83
  const leftValue = computed(() => {
77
84
  if (!payload.value) return {};
@@ -114,7 +121,7 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
114
121
  });
115
122
  const open = (p) => {
116
123
  payload.value = p;
117
- mode.value = resolveInitialMode();
124
+ mode.value = resolveInitialMode(p.mode);
118
125
  viewMode.value = "form";
119
126
  visible.value = true;
120
127
  };
@@ -47,6 +47,7 @@ var mountHistoryDiffDialog = async (options) => {
47
47
  loadConfig: options.loadConfig,
48
48
  selfDiffFieldTypes: options.selfDiffFieldTypes,
49
49
  compareFormState: options.compareFormState,
50
+ width: options.width,
50
51
  onClose: options.onClose
51
52
  });
52
53
  if (options.appContext) Object.assign(app._context, options.appContext);
@@ -125,7 +126,7 @@ var viewHistoryDiffDialog = async (payload, options) => {
125
126
  */
126
127
  var useHistoryRevert = (options = {}, services) => {
127
128
  const appContext = options.appContext ?? getCurrentInstance()?.appContext ?? null;
128
- const { extendState, getPropsPanelFormState } = options;
129
+ const { extendState, getPropsPanelFormState, dialogWidth } = options;
129
130
  /** 目标数据已被删除、无法回滚时的统一提示。 */
130
131
  const showRevertTargetMissing = () => {
131
132
  tMagicMessage.error("回滚失败:该记录对应的数据已被删除");
@@ -146,7 +147,8 @@ var useHistoryRevert = (options = {}, services) => {
146
147
  appContext,
147
148
  extendState,
148
149
  services,
149
- ...extra
150
+ ...extra,
151
+ width: extra?.width ?? dialogWidth
150
152
  });
151
153
  return confirmRevert();
152
154
  };
@@ -227,6 +229,7 @@ var useHistoryRevert = (options = {}, services) => {
227
229
  appContext,
228
230
  extendState,
229
231
  services,
232
+ width: dialogWidth,
230
233
  compareFormState: getPropsPanelFormState?.()
231
234
  });
232
235
  };
@@ -235,7 +238,8 @@ var useHistoryRevert = (options = {}, services) => {
235
238
  if (payload) return viewHistoryDiffDialog(payload, {
236
239
  appContext,
237
240
  extendState,
238
- services
241
+ services,
242
+ width: dialogWidth
239
243
  });
240
244
  };
241
245
  const onCodeBlockDiff = (id, index) => {
@@ -243,7 +247,8 @@ var useHistoryRevert = (options = {}, services) => {
243
247
  if (payload) return viewHistoryDiffDialog(payload, {
244
248
  appContext,
245
249
  extendState,
246
- services
250
+ services,
251
+ width: dialogWidth
247
252
  });
248
253
  };
249
254
  /**
@@ -269,7 +274,8 @@ var useHistoryRevert = (options = {}, services) => {
269
274
  }
270
275
  if (!await runRevert(revertOptions.diffPayload ?? null, {
271
276
  loadConfig: revertOptions.loadConfig,
272
- selfDiffFieldTypes: revertOptions.selfDiffFieldTypes
277
+ selfDiffFieldTypes: revertOptions.selfDiffFieldTypes,
278
+ width: revertOptions.width
273
279
  })) return null;
274
280
  return await revertOptions.revert();
275
281
  };
@@ -282,7 +288,8 @@ var useHistoryRevert = (options = {}, services) => {
282
288
  appContext,
283
289
  extendState,
284
290
  services,
285
- ...extra
291
+ ...extra,
292
+ width: extra?.width ?? dialogWidth
286
293
  });
287
294
  };
288
295
  return {
@@ -11552,11 +11552,18 @@
11552
11552
  const hasCurrent = (0, vue.computed)(() => payload.value?.currentValue !== void 0 && payload.value?.currentValue !== null);
11553
11553
  /** 是否存在该步「修改后的值」:不存在(如仅删除)时「与修改前对比」无意义,置灰禁用。 */
11554
11554
  const hasValue = (0, vue.computed)(() => payload.value?.value !== void 0 && payload.value?.value !== null);
11555
+ /** 指定模式当前是否可用:before 依赖「修改后的值」,current 依赖「当前值」。 */
11556
+ const isModeAvailable = (m) => m === "current" ? hasCurrent.value : hasValue.value;
11555
11557
  /**
11556
11558
  * 计算 open 时的初始对比模式:
11557
- * 没有「修改后的值」但有当前值时(「与修改前对比」不可用),默认进入「与当前对比」;否则默认「与修改前对比」。
11559
+ * - 调用方通过 payload.mode 指定且该模式可用时,优先使用指定模式;
11560
+ * - 否则没有「修改后的值」但有当前值时(「与修改前对比」不可用),默认进入「与当前对比」;
11561
+ * - 其余情况默认「与修改前对比」。
11558
11562
  */
11559
- const resolveInitialMode = () => !hasValue.value && hasCurrent.value ? "current" : "before";
11563
+ const resolveInitialMode = (specified) => {
11564
+ if (specified && isModeAvailable(specified)) return specified;
11565
+ return !hasValue.value && hasCurrent.value ? "current" : "before";
11566
+ };
11560
11567
  /** 左侧(旧/参照)值 */
11561
11568
  const leftValue = (0, vue.computed)(() => {
11562
11569
  if (!payload.value) return {};
@@ -11599,7 +11606,7 @@
11599
11606
  });
11600
11607
  const open = (p) => {
11601
11608
  payload.value = p;
11602
- mode.value = resolveInitialMode();
11609
+ mode.value = resolveInitialMode(p.mode);
11603
11610
  viewMode.value = "form";
11604
11611
  visible.value = true;
11605
11612
  };
@@ -11825,6 +11832,7 @@
11825
11832
  loadConfig: options.loadConfig,
11826
11833
  selfDiffFieldTypes: options.selfDiffFieldTypes,
11827
11834
  compareFormState: options.compareFormState,
11835
+ width: options.width,
11828
11836
  onClose: options.onClose
11829
11837
  });
11830
11838
  if (options.appContext) Object.assign(app._context, options.appContext);
@@ -11903,7 +11911,7 @@
11903
11911
  */
11904
11912
  var useHistoryRevert = (options = {}, services) => {
11905
11913
  const appContext = options.appContext ?? (0, vue.getCurrentInstance)()?.appContext ?? null;
11906
- const { extendState, getPropsPanelFormState } = options;
11914
+ const { extendState, getPropsPanelFormState, dialogWidth } = options;
11907
11915
  /** 目标数据已被删除、无法回滚时的统一提示。 */
11908
11916
  const showRevertTargetMissing = () => {
11909
11917
  _tmagic_design.tMagicMessage.error("回滚失败:该记录对应的数据已被删除");
@@ -11924,7 +11932,8 @@
11924
11932
  appContext,
11925
11933
  extendState,
11926
11934
  services,
11927
- ...extra
11935
+ ...extra,
11936
+ width: extra?.width ?? dialogWidth
11928
11937
  });
11929
11938
  return confirmRevert();
11930
11939
  };
@@ -12005,6 +12014,7 @@
12005
12014
  appContext,
12006
12015
  extendState,
12007
12016
  services,
12017
+ width: dialogWidth,
12008
12018
  compareFormState: getPropsPanelFormState?.()
12009
12019
  });
12010
12020
  };
@@ -12013,7 +12023,8 @@
12013
12023
  if (payload) return viewHistoryDiffDialog(payload, {
12014
12024
  appContext,
12015
12025
  extendState,
12016
- services
12026
+ services,
12027
+ width: dialogWidth
12017
12028
  });
12018
12029
  };
12019
12030
  const onCodeBlockDiff = (id, index) => {
@@ -12021,7 +12032,8 @@
12021
12032
  if (payload) return viewHistoryDiffDialog(payload, {
12022
12033
  appContext,
12023
12034
  extendState,
12024
- services
12035
+ services,
12036
+ width: dialogWidth
12025
12037
  });
12026
12038
  };
12027
12039
  /**
@@ -12047,7 +12059,8 @@
12047
12059
  }
12048
12060
  if (!await runRevert(revertOptions.diffPayload ?? null, {
12049
12061
  loadConfig: revertOptions.loadConfig,
12050
- selfDiffFieldTypes: revertOptions.selfDiffFieldTypes
12062
+ selfDiffFieldTypes: revertOptions.selfDiffFieldTypes,
12063
+ width: revertOptions.width
12051
12064
  })) return null;
12052
12065
  return await revertOptions.revert();
12053
12066
  };
@@ -12060,7 +12073,8 @@
12060
12073
  appContext,
12061
12074
  extendState,
12062
12075
  services,
12063
- ...extra
12076
+ ...extra,
12077
+ width: extra?.width ?? dialogWidth
12064
12078
  });
12065
12079
  };
12066
12080
  return {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0-manmanyu.12",
2
+ "version": "1.8.0-manmanyu.14",
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": "^7.0.0",
60
60
  "sortablejs": "^1.15.6",
61
- "@tmagic/design": "1.8.0-manmanyu.12",
62
- "@tmagic/form": "1.8.0-manmanyu.12",
63
- "@tmagic/stage": "1.8.0-manmanyu.12",
64
- "@tmagic/utils": "1.8.0-manmanyu.12",
65
- "@tmagic/table": "1.8.0-manmanyu.12"
61
+ "@tmagic/design": "1.8.0-manmanyu.14",
62
+ "@tmagic/form": "1.8.0-manmanyu.14",
63
+ "@tmagic/table": "1.8.0-manmanyu.14",
64
+ "@tmagic/utils": "1.8.0-manmanyu.14",
65
+ "@tmagic/stage": "1.8.0-manmanyu.14"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/events": "^3.0.3",
@@ -76,7 +76,7 @@
76
76
  "type-fest": "^5.2.0",
77
77
  "typescript": "^6.0.3",
78
78
  "vue": "^3.5.38",
79
- "@tmagic/core": "1.8.0-manmanyu.12"
79
+ "@tmagic/core": "1.8.0-manmanyu.14"
80
80
  },
81
81
  "peerDependenciesMeta": {
82
82
  "typescript": {
@@ -162,11 +162,19 @@ const hasCurrent = computed(() => payload.value?.currentValue !== undefined && p
162
162
  /** 是否存在该步「修改后的值」:不存在(如仅删除)时「与修改前对比」无意义,置灰禁用。 */
163
163
  const hasValue = computed(() => payload.value?.value !== undefined && payload.value?.value !== null);
164
164
 
165
+ /** 指定模式当前是否可用:before 依赖「修改后的值」,current 依赖「当前值」。 */
166
+ const isModeAvailable = (m: DiffMode): boolean => (m === 'current' ? hasCurrent.value : hasValue.value);
167
+
165
168
  /**
166
169
  * 计算 open 时的初始对比模式:
167
- * 没有「修改后的值」但有当前值时(「与修改前对比」不可用),默认进入「与当前对比」;否则默认「与修改前对比」。
170
+ * - 调用方通过 payload.mode 指定且该模式可用时,优先使用指定模式;
171
+ * - 否则没有「修改后的值」但有当前值时(「与修改前对比」不可用),默认进入「与当前对比」;
172
+ * - 其余情况默认「与修改前对比」。
168
173
  */
169
- const resolveInitialMode = (): DiffMode => (!hasValue.value && hasCurrent.value ? 'current' : 'before');
174
+ const resolveInitialMode = (specified?: DiffMode): DiffMode => {
175
+ if (specified && isModeAvailable(specified)) return specified;
176
+ return !hasValue.value && hasCurrent.value ? 'current' : 'before';
177
+ };
170
178
 
171
179
  /** 左侧(旧/参照)值 */
172
180
  const leftValue = computed<Record<string, any>>(() => {
@@ -222,8 +230,8 @@ const targetText = computed(() => {
222
230
  const open = (p: DiffDialogPayload) => {
223
231
  payload.value = p;
224
232
  // 每次打开按 payload 重置对比模式(hasValue / hasCurrent 依赖 payload,需先赋值):
225
- // 无「修改后的值」但有当前值时默认「与当前对比」,否则默认「与修改前对比」
226
- mode.value = resolveInitialMode();
233
+ // 优先使用 payload.mode 指定的模式;不可用或未指定时按数据自动推断。
234
+ mode.value = resolveInitialMode(p.mode);
227
235
  // 默认回到表单对比形态,避免残留上一次选择的源码模式
228
236
  viewMode.value = 'form';
229
237
  visible.value = true;
@@ -94,6 +94,7 @@ const mountHistoryDiffDialog = async (
94
94
  loadConfig: options.loadConfig,
95
95
  selfDiffFieldTypes: options.selfDiffFieldTypes,
96
96
  compareFormState: options.compareFormState,
97
+ width: options.width,
97
98
  onClose: options.onClose,
98
99
  });
99
100
  if (options.appContext) {
@@ -192,7 +193,7 @@ const viewHistoryDiffDialog = async (
192
193
  export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services?: Services) => {
193
194
  // 自动捕获调用方所在组件的 appContext(在 setup 中调用时),业务方亦可显式覆盖。
194
195
  const appContext = options.appContext ?? getCurrentInstance()?.appContext ?? null;
195
- const { extendState, getPropsPanelFormState } = options;
196
+ const { extendState, getPropsPanelFormState, dialogWidth } = options;
196
197
 
197
198
  /** 目标数据已被删除、无法回滚时的统一提示。 */
198
199
  const showRevertTargetMissing = () => {
@@ -216,7 +217,13 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services
216
217
  */
217
218
  const runRevert = (payload: DiffDialogPayload | null, extra?: CustomDiffFormOptions): Promise<boolean> => {
218
219
  if (payload) {
219
- return confirmRevertWithDiffDialog(payload, { appContext, extendState, services, ...extra });
220
+ return confirmRevertWithDiffDialog(payload, {
221
+ appContext,
222
+ extendState,
223
+ services,
224
+ ...extra,
225
+ width: extra?.width ?? dialogWidth,
226
+ });
220
227
  }
221
228
  return confirmRevert();
222
229
  };
@@ -334,6 +341,7 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services
334
341
  appContext,
335
342
  extendState,
336
343
  services,
344
+ width: dialogWidth,
337
345
  compareFormState: getPropsPanelFormState?.(),
338
346
  });
339
347
  }
@@ -341,12 +349,12 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services
341
349
 
342
350
  const onDataSourceDiff = (id: string | number, index: number): Promise<void> | void => {
343
351
  const payload = buildDataSourceDiffPayload(id, index);
344
- if (payload) return viewHistoryDiffDialog(payload, { appContext, extendState, services });
352
+ if (payload) return viewHistoryDiffDialog(payload, { appContext, extendState, services, width: dialogWidth });
345
353
  };
346
354
 
347
355
  const onCodeBlockDiff = (id: string | number, index: number): Promise<void> | void => {
348
356
  const payload = buildCodeBlockDiffPayload(id, index);
349
- if (payload) return viewHistoryDiffDialog(payload, { appContext, extendState, services });
357
+ if (payload) return viewHistoryDiffDialog(payload, { appContext, extendState, services, width: dialogWidth });
350
358
  };
351
359
 
352
360
  /**
@@ -373,6 +381,7 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services
373
381
  const confirmed = await runRevert(revertOptions.diffPayload ?? null, {
374
382
  loadConfig: revertOptions.loadConfig,
375
383
  selfDiffFieldTypes: revertOptions.selfDiffFieldTypes,
384
+ width: revertOptions.width,
376
385
  });
377
386
  if (!confirmed) return null;
378
387
  return await revertOptions.revert();
@@ -383,7 +392,14 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services
383
392
  * 可透传 `loadConfig` / `selfDiffFieldTypes`。payload 为 null(不可对比)时静默返回。
384
393
  */
385
394
  const viewDiff = (payload: DiffDialogPayload | null, extra?: CustomDiffFormOptions): Promise<void> | void => {
386
- if (payload) return viewHistoryDiffDialog(payload, { appContext, extendState, services, ...extra });
395
+ if (payload)
396
+ return viewHistoryDiffDialog(payload, {
397
+ appContext,
398
+ extendState,
399
+ services,
400
+ ...extra,
401
+ width: extra?.width ?? dialogWidth,
402
+ });
387
403
  };
388
404
 
389
405
  return {
package/src/type.ts CHANGED
@@ -1352,6 +1352,14 @@ export interface DiffDialogPayload {
1352
1352
  targetLabel?: string;
1353
1353
  /** 用于标题展示的目标 id */
1354
1354
  id?: string | number;
1355
+ /**
1356
+ * 指定打开时的初始对比模式:
1357
+ * - before:该步骤修改前 vs 修改后
1358
+ * - current:该步骤修改后 vs 当前最新值
1359
+ * 不传时按是否存在「修改后的值」/「当前值」自动推断。
1360
+ * 若指定的模式当前不可用(对应数据缺失),将回退到自动推断结果。
1361
+ */
1362
+ mode?: 'before' | 'current';
1355
1363
  }
1356
1364
 
1357
1365
  /**
@@ -1408,6 +1416,12 @@ export interface UseHistoryRevertOptions {
1408
1416
  * 以保证两处 filterFunction 读取到一致的运行态上下文。
1409
1417
  */
1410
1418
  getPropsPanelFormState?: () => FormState | undefined;
1419
+ /**
1420
+ * 内置页面 / 数据源 / 代码块的差异 / 回滚确认弹窗默认宽度(透传给 TMagicDialog 的 `width`),
1421
+ * 如 `'1200px'` / `'80%'`。缺省时使用弹窗内置默认宽度(900px)。
1422
+ * 业务自有历史(`viewDiff` / `confirmAndRevert`)可在调用时通过各自入参的 `width` 单独覆盖。
1423
+ */
1424
+ dialogWidth?: string;
1411
1425
  }
1412
1426
 
1413
1427
  /**
@@ -1428,6 +1442,11 @@ export interface CustomDiffFormOptions {
1428
1442
  * 对比弹窗会用它覆盖 CompareForm 中同名扩展字段,避免上下文不一致。
1429
1443
  */
1430
1444
  compareFormState?: FormState;
1445
+ /**
1446
+ * 差异 / 确认回滚弹窗宽度(透传给 HistoryDiffDialog 的 TMagicDialog `width`),
1447
+ * 如 `'1200px'` / `'80%'`。缺省时使用弹窗内置默认宽度(900px)。
1448
+ */
1449
+ width?: string;
1431
1450
  }
1432
1451
 
1433
1452
  /**
package/types/index.d.ts CHANGED
@@ -2588,6 +2588,14 @@ interface DiffDialogPayload {
2588
2588
  targetLabel?: string;
2589
2589
  /** 用于标题展示的目标 id */
2590
2590
  id?: string | number;
2591
+ /**
2592
+ * 指定打开时的初始对比模式:
2593
+ * - before:该步骤修改前 vs 修改后
2594
+ * - current:该步骤修改后 vs 当前最新值
2595
+ * 不传时按是否存在「修改后的值」/「当前值」自动推断。
2596
+ * 若指定的模式当前不可用(对应数据缺失),将回退到自动推断结果。
2597
+ */
2598
+ mode?: 'before' | 'current';
2591
2599
  }
2592
2600
  /**
2593
2601
  * 一组「描述 + 可操作性」的判定函数集合。页面 / 数据源 / 代码块及业务自定义历史
@@ -2641,6 +2649,12 @@ interface UseHistoryRevertOptions {
2641
2649
  * 以保证两处 filterFunction 读取到一致的运行态上下文。
2642
2650
  */
2643
2651
  getPropsPanelFormState?: () => FormState | undefined;
2652
+ /**
2653
+ * 内置页面 / 数据源 / 代码块的差异 / 回滚确认弹窗默认宽度(透传给 TMagicDialog 的 `width`),
2654
+ * 如 `'1200px'` / `'80%'`。缺省时使用弹窗内置默认宽度(900px)。
2655
+ * 业务自有历史(`viewDiff` / `confirmAndRevert`)可在调用时通过各自入参的 `width` 单独覆盖。
2656
+ */
2657
+ dialogWidth?: string;
2644
2658
  }
2645
2659
  /**
2646
2660
  * 业务自有历史(如管理台「模块」)做差异对比时所需的额外渲染入参。
@@ -2660,6 +2674,11 @@ interface CustomDiffFormOptions {
2660
2674
  * 对比弹窗会用它覆盖 CompareForm 中同名扩展字段,避免上下文不一致。
2661
2675
  */
2662
2676
  compareFormState?: FormState;
2677
+ /**
2678
+ * 差异 / 确认回滚弹窗宽度(透传给 HistoryDiffDialog 的 TMagicDialog `width`),
2679
+ * 如 `'1200px'` / `'80%'`。缺省时使用弹窗内置默认宽度(900px)。
2680
+ */
2681
+ width?: string;
2663
2682
  }
2664
2683
  /**
2665
2684
  * 业务自有历史复用「单步回滚」交互({@link useHistoryRevert} 的 `confirmAndRevert`)的入参。