@tmagic/editor 1.8.0-manmanyu.21 → 1.8.0-manmanyu.23

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 (37) hide show
  1. package/dist/es/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +4 -0
  2. package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +5 -2
  3. package/dist/es/components/FloatingBox.vue_vue_type_script_setup_true_lang.js +56 -13
  4. package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +7 -0
  5. package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +4 -0
  6. package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +6 -3
  7. package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +4 -1
  8. package/dist/es/layouts/history-list/useHistoryRevert.js +7 -3
  9. package/dist/es/layouts/props-panel/use-style-panel.js +3 -2
  10. package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +3 -0
  11. package/dist/es/layouts/sidebar/data-source/DataSourceConfigPanel.vue_vue_type_script_setup_true_lang.js +4 -0
  12. package/dist/es/layouts/workspace/viewer/NodeListMenu.vue_vue_type_script_setup_true_lang.js +8 -2
  13. package/dist/es/services/ui.js +3 -0
  14. package/dist/es/style.css +9 -1
  15. package/dist/es/utils/const.js +1 -1
  16. package/dist/style.css +9 -1
  17. package/dist/themes/magic-admin.css +37 -13
  18. package/dist/tmagic-editor.umd.cjs +114 -25
  19. package/package.json +7 -7
  20. package/src/components/CodeBlockEditor.vue +3 -0
  21. package/src/components/CompareForm.vue +7 -0
  22. package/src/components/FloatingBox.vue +71 -7
  23. package/src/fields/DataSourceFields.vue +5 -0
  24. package/src/fields/DataSourceMocks.vue +3 -0
  25. package/src/layouts/Framework.vue +7 -6
  26. package/src/layouts/history-list/HistoryDiffDialog.vue +11 -1
  27. package/src/layouts/history-list/useHistoryRevert.ts +4 -0
  28. package/src/layouts/props-panel/use-style-panel.ts +4 -3
  29. package/src/layouts/sidebar/Sidebar.vue +2 -0
  30. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +3 -0
  31. package/src/layouts/workspace/viewer/NodeListMenu.vue +4 -1
  32. package/src/services/ui.ts +6 -0
  33. package/src/theme/floating-box.scss +9 -1
  34. package/src/theme/themes/magic-admin/index.scss +44 -18
  35. package/src/type.ts +12 -0
  36. package/src/utils/const.ts +2 -2
  37. package/types/index.d.ts +26 -4
@@ -8182,7 +8182,7 @@
8182
8182
  var PROPS_PANEL_WIDTH_STORAGE_KEY = "$MagicEditorPropsPanelWidthData";
8183
8183
  var DEFAULT_LEFT_COLUMN_WIDTH = 310;
8184
8184
  var DEFAULT_RIGHT_COLUMN_WIDTH = 480;
8185
- var MIN_LEFT_COLUMN_WIDTH = 252;
8185
+ var MIN_LEFT_COLUMN_WIDTH = 260;
8186
8186
  var MIN_CENTER_COLUMN_WIDTH = 400;
8187
8187
  var MIN_RIGHT_COLUMN_WIDTH = 300;
8188
8188
  var H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
@@ -8207,6 +8207,9 @@
8207
8207
  center: 0,
8208
8208
  right: storage_default.getItem("$MagicEditorRightColumnWidthData", { protocol: Protocol.NUMBER }) || 480
8209
8209
  },
8210
+ minLeftColumnWidth: 260,
8211
+ minCenterColumnWidth: 400,
8212
+ minRightColumnWidth: 300,
8210
8213
  showGuides: true,
8211
8214
  hasGuides: false,
8212
8215
  showRule: true,
@@ -10360,6 +10363,9 @@
10360
10363
  const pageLength = (0, vue.computed)(() => editorService.get("pageLength") || 0);
10361
10364
  const showSrc = (0, vue.computed)(() => uiService.get("showSrc"));
10362
10365
  const columnWidth = (0, vue.computed)(() => uiService.get("columnWidth"));
10366
+ const minLeftColumnWidth = (0, vue.computed)(() => uiService.get("minLeftColumnWidth"));
10367
+ const minCenterColumnWidth = (0, vue.computed)(() => uiService.get("minCenterColumnWidth"));
10368
+ const minRightColumnWidth = (0, vue.computed)(() => uiService.get("minRightColumnWidth"));
10363
10369
  (0, vue.watch)(pageLength, () => {
10364
10370
  splitViewRef.value?.updateWidth();
10365
10371
  });
@@ -10426,9 +10432,9 @@
10426
10432
  "right-class": "m-editor-framework-right",
10427
10433
  left: __props.hideSidebar ? void 0 : columnWidth.value.left,
10428
10434
  right: columnWidth.value.right,
10429
- "min-left": __props.hideSidebar ? 0 : (0, vue.unref)(252),
10430
- "min-right": (0, vue.unref)(300),
10431
- "min-center": (0, vue.unref)(400),
10435
+ "min-left": __props.hideSidebar ? 0 : minLeftColumnWidth.value,
10436
+ "min-right": minRightColumnWidth.value,
10437
+ "min-center": minCenterColumnWidth.value,
10432
10438
  width: frameworkRect.value.width,
10433
10439
  onChange: columnWidthChange
10434
10440
  }, (0, vue.createSlots)({
@@ -11303,6 +11309,7 @@
11303
11309
  },
11304
11310
  baseFormState: {},
11305
11311
  selfDiffFieldTypes: {},
11312
+ size: {},
11306
11313
  loadConfig: {},
11307
11314
  services: {}
11308
11315
  },
@@ -11463,13 +11470,15 @@
11463
11470
  "label-width": __props.labelWidth,
11464
11471
  "extend-state": mergedExtendState,
11465
11472
  "show-diff": showDiff,
11466
- "self-diff-field-types": __props.selfDiffFieldTypes
11473
+ "self-diff-field-types": __props.selfDiffFieldTypes,
11474
+ size: __props.size
11467
11475
  }, null, 8, [
11468
11476
  "config",
11469
11477
  "init-values",
11470
11478
  "last-values",
11471
11479
  "label-width",
11472
- "self-diff-field-types"
11480
+ "self-diff-field-types",
11481
+ "size"
11473
11482
  ])) : (0, vue.createCommentVNode)("v-if", true)], 4);
11474
11483
  };
11475
11484
  }
@@ -11514,6 +11523,7 @@
11514
11523
  extendState: {},
11515
11524
  loadConfig: {},
11516
11525
  width: { default: "900px" },
11526
+ size: {},
11517
11527
  isConfirm: { type: Boolean },
11518
11528
  onConfirm: {},
11519
11529
  selfDiffFieldTypes: {},
@@ -11744,6 +11754,7 @@
11744
11754
  "load-config": __props.loadConfig,
11745
11755
  "self-diff-field-types": __props.selfDiffFieldTypes,
11746
11756
  services: props.services,
11757
+ size: props.size,
11747
11758
  height: "70vh"
11748
11759
  }, null, 8, [
11749
11760
  "category",
@@ -11755,7 +11766,8 @@
11755
11766
  "extend-state",
11756
11767
  "load-config",
11757
11768
  "self-diff-field-types",
11758
- "services"
11769
+ "services",
11770
+ "size"
11759
11771
  ])) : ((0, vue.openBlock)(), (0, vue.createBlock)(CodeEditor_default, {
11760
11772
  key: 2,
11761
11773
  type: "diff",
@@ -11834,6 +11846,7 @@
11834
11846
  selfDiffFieldTypes: options.selfDiffFieldTypes,
11835
11847
  compareFormState: options.compareFormState,
11836
11848
  width: options.width,
11849
+ size: options.size ?? options.services?.uiService?.get("propsPanelSize"),
11837
11850
  onClose: options.onClose
11838
11851
  });
11839
11852
  if (options.appContext) Object.assign(app._context, options.appContext);
@@ -11934,7 +11947,8 @@
11934
11947
  extendState,
11935
11948
  services,
11936
11949
  ...extra,
11937
- width: extra?.width ?? dialogWidth
11950
+ width: extra?.width ?? dialogWidth,
11951
+ size: extra?.size
11938
11952
  });
11939
11953
  return confirmRevert();
11940
11954
  };
@@ -12061,7 +12075,8 @@
12061
12075
  if (!await runRevert(revertOptions.diffPayload ?? null, {
12062
12076
  loadConfig: revertOptions.loadConfig,
12063
12077
  selfDiffFieldTypes: revertOptions.selfDiffFieldTypes,
12064
- width: revertOptions.width
12078
+ width: revertOptions.width,
12079
+ size: revertOptions.size
12065
12080
  })) return null;
12066
12081
  return await revertOptions.revert();
12067
12082
  };
@@ -12075,7 +12090,8 @@
12075
12090
  extendState,
12076
12091
  services,
12077
12092
  ...extra,
12078
- width: extra?.width ?? dialogWidth
12093
+ width: extra?.width ?? dialogWidth,
12094
+ size: extra?.size
12079
12095
  });
12080
12096
  };
12081
12097
  return {
@@ -12949,8 +12965,9 @@
12949
12965
  columnWidth.center += propsPanelWidth.value;
12950
12966
  }
12951
12967
  if (columnWidth.center < 0) {
12952
- columnWidth.right = columnWidth.right + columnWidth.center - 400;
12953
- columnWidth.center = 400;
12968
+ const minCenterColumnWidth = uiService.get("minCenterColumnWidth");
12969
+ columnWidth.right = columnWidth.right + columnWidth.center - minCenterColumnWidth;
12970
+ columnWidth.center = minCenterColumnWidth;
12954
12971
  propsPanelWidth.value = columnWidth.right / 2;
12955
12972
  }
12956
12973
  storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnWidth.right, { protocol: Protocol.NUMBER });
@@ -13160,6 +13177,9 @@
13160
13177
  top: 0
13161
13178
  }) },
13162
13179
  title: { default: "" },
13180
+ bodyStyle: {},
13181
+ initialStyle: { default: () => ({}) },
13182
+ frameworkWidth: { default: 0 },
13163
13183
  beforeClose: {}
13164
13184
  }, {
13165
13185
  "width": { default: 0 },
@@ -13197,19 +13217,51 @@
13197
13217
  if (targetEl.value) return targetEl.value.clientHeight - titleHeight.value;
13198
13218
  return "auto";
13199
13219
  });
13200
- const { uiService } = useServices();
13201
- const frameworkWidth = (0, vue.computed)(() => uiService.get("frameworkRect").width || 0);
13202
13220
  const style = (0, vue.computed)(() => {
13203
13221
  let { left } = props.position;
13204
- if (width.value) left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
13222
+ const frameworkWidth = props.frameworkWidth || globalThis.window?.innerWidth || 0;
13223
+ if (width.value && frameworkWidth) left = left + width.value > frameworkWidth ? frameworkWidth - width.value : left;
13205
13224
  return {
13206
13225
  left: `${left}px`,
13207
13226
  top: `${props.position.top}px`,
13208
13227
  width: width.value ? `${width.value}px` : "auto",
13209
- height: height.value ? `${height.value}px` : "auto"
13228
+ height: height.value ? `${height.value}px` : "auto",
13229
+ ...props.initialStyle
13210
13230
  };
13211
13231
  });
13212
13232
  let moveable$1 = null;
13233
+ let dragMask = null;
13234
+ let dragMaskVisible = false;
13235
+ const bindDragMaskSafety = () => {
13236
+ globalThis.window?.addEventListener("pointerup", hideDragMask, true);
13237
+ globalThis.window?.addEventListener("blur", hideDragMask);
13238
+ globalThis.document?.addEventListener("visibilitychange", hideDragMask);
13239
+ };
13240
+ const unbindDragMaskSafety = () => {
13241
+ globalThis.window?.removeEventListener("pointerup", hideDragMask, true);
13242
+ globalThis.window?.removeEventListener("blur", hideDragMask);
13243
+ globalThis.document?.removeEventListener("visibilitychange", hideDragMask);
13244
+ };
13245
+ const showDragMask = () => {
13246
+ if (dragMaskVisible) return;
13247
+ if (!dragMask) {
13248
+ dragMask = globalThis.document.createElement("div");
13249
+ dragMask.className = "m-editor-float-box-drag-mask";
13250
+ }
13251
+ globalThis.document.body.appendChild(dragMask);
13252
+ dragMaskVisible = true;
13253
+ bindDragMaskSafety();
13254
+ const setMaskZIndex = () => {
13255
+ if (dragMask) dragMask.style.zIndex = `${curZIndex.value + 1}`;
13256
+ };
13257
+ setMaskZIndex();
13258
+ (0, vue.nextTick)(setMaskZIndex);
13259
+ };
13260
+ const hideDragMask = () => {
13261
+ unbindDragMaskSafety();
13262
+ dragMask?.parentNode?.removeChild(dragMask);
13263
+ dragMaskVisible = false;
13264
+ };
13213
13265
  const initMoveable = () => {
13214
13266
  moveable$1 = new moveable.default(globalThis.document.body, {
13215
13267
  className: "m-editor-floating-box-moveable",
@@ -13232,6 +13284,10 @@
13232
13284
  position: "css"
13233
13285
  }
13234
13286
  });
13287
+ moveable$1.on("drag", showDragMask);
13288
+ moveable$1.on("resize", showDragMask);
13289
+ moveable$1.on("dragEnd", hideDragMask);
13290
+ moveable$1.on("resizeEnd", hideDragMask);
13235
13291
  moveable$1.on("drag", (e) => {
13236
13292
  e.target.style.transform = e.transform;
13237
13293
  });
@@ -13244,6 +13300,7 @@
13244
13300
  });
13245
13301
  };
13246
13302
  const destroyMoveable = () => {
13303
+ hideDragMask();
13247
13304
  moveable$1?.destroy();
13248
13305
  moveable$1 = null;
13249
13306
  };
@@ -13283,15 +13340,16 @@
13283
13340
  return visible.value ? ((0, vue.openBlock)(), (0, vue.createBlock)(vue.Teleport, {
13284
13341
  key: 0,
13285
13342
  to: "body"
13286
- }, [(0, vue.createElementVNode)("div", {
13343
+ }, [(0, vue.createElementVNode)("div", (0, vue.mergeProps)({
13287
13344
  ref: "target",
13288
- class: (0, vue.normalizeClass)(["m-editor-float-box", (0, vue.unref)(themeClass)]),
13289
- style: (0, vue.normalizeStyle)({
13345
+ class: ["m-editor-float-box", (0, vue.unref)(themeClass)]
13346
+ }, _ctx.$attrs, {
13347
+ style: {
13290
13348
  ...style.value,
13291
13349
  zIndex: curZIndex.value
13292
- }),
13350
+ },
13293
13351
  onMousedown: nextZIndex
13294
- }, [(0, vue.createElementVNode)("div", _hoisted_1$56, [(0, vue.renderSlot)(_ctx.$slots, "title", {}, () => [(0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(__props.title), 1)]), (0, vue.createElementVNode)("div", null, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
13352
+ }), [(0, vue.createElementVNode)("div", _hoisted_1$56, [(0, vue.renderSlot)(_ctx.$slots, "title", {}, () => [(0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(__props.title), 1)]), (0, vue.createElementVNode)("div", null, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
13295
13353
  link: "",
13296
13354
  size: "small",
13297
13355
  onClick: closeHandler
@@ -13300,8 +13358,11 @@
13300
13358
  _: 1
13301
13359
  })])], 512), (0, vue.createElementVNode)("div", {
13302
13360
  class: "m-editor-float-box-body",
13303
- style: (0, vue.normalizeStyle)({ height: `${bodyHeight.value}px` })
13304
- }, [(0, vue.renderSlot)(_ctx.$slots, "body")], 4)], 38)])) : (0, vue.createCommentVNode)("v-if", true);
13361
+ style: (0, vue.normalizeStyle)({
13362
+ height: `${bodyHeight.value}px`,
13363
+ ...__props.bodyStyle
13364
+ })
13365
+ }, [(0, vue.renderSlot)(_ctx.$slots, "body")], 4)], 16)])) : (0, vue.createCommentVNode)("v-if", true);
13305
13366
  };
13306
13367
  }
13307
13368
  });
@@ -13423,6 +13484,7 @@
13423
13484
  changedValue.value = void 0;
13424
13485
  };
13425
13486
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, (0, vue.inject)("parentFloating", (0, vue.ref)(null)));
13487
+ const frameworkWidth = (0, vue.computed)(() => uiService.get("frameworkRect")?.width || 0);
13426
13488
  (0, vue.watch)(boxVisible, (visible) => {
13427
13489
  (0, vue.nextTick)(() => {
13428
13490
  if (!visible) emit("close");
@@ -13448,7 +13510,9 @@
13448
13510
  "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
13449
13511
  height: (0, vue.unref)(codeBlockEditorHeight),
13450
13512
  "onUpdate:height": _cache[3] || (_cache[3] = ($event) => (0, vue.isRef)(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
13513
+ "body-style": { padding: "0 16px" },
13451
13514
  title: __props.content.name ? `${__props.disabled ? "查看" : "编辑"}${__props.content.name}` : "新增代码",
13515
+ "framework-width": frameworkWidth.value,
13452
13516
  position: (0, vue.unref)(boxPosition),
13453
13517
  "before-close": beforeClose
13454
13518
  }, {
@@ -13490,6 +13554,7 @@
13490
13554
  "width",
13491
13555
  "height",
13492
13556
  "title",
13557
+ "framework-width",
13493
13558
  "position"
13494
13559
  ]),
13495
13560
  ((0, vue.openBlock)(), (0, vue.createBlock)(vue.Teleport, { to: "body" }, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicDialog), {
@@ -14377,6 +14442,7 @@
14377
14442
  const dataSourceConfig = (0, vue.ref)([]);
14378
14443
  const { height: editorHeight } = useEditorContentHeight();
14379
14444
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, (0, vue.inject)("parentFloating", (0, vue.ref)(null)));
14445
+ const frameworkWidth = (0, vue.computed)(() => uiService.get("frameworkRect")?.width || 0);
14380
14446
  /** 供「方法定义」tab 内的字段消费,用于打开数据源详情后自动打开指定方法 */
14381
14447
  (0, vue.provide)("editingDataSourceMethodName", (0, vue.computed)(() => props.editMethodName));
14382
14448
  /** 供「数据定义」tab 内的字段消费,用于打开数据源详情后自动打开指定字段 */
@@ -14415,6 +14481,7 @@
14415
14481
  });
14416
14482
  return (_ctx, _cache) => {
14417
14483
  return (0, vue.openBlock)(), (0, vue.createBlock)(FloatingBox_default, {
14484
+ "body-style": { padding: "0 16px" },
14418
14485
  visible: boxVisible.value,
14419
14486
  "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
14420
14487
  width: width.value,
@@ -14422,6 +14489,7 @@
14422
14489
  height: (0, vue.unref)(editorHeight),
14423
14490
  "onUpdate:height": _cache[2] || (_cache[2] = ($event) => (0, vue.isRef)(editorHeight) ? editorHeight.value = $event : null),
14424
14491
  title: __props.title,
14492
+ "framework-width": frameworkWidth.value,
14425
14493
  position: (0, vue.unref)(boxPosition)
14426
14494
  }, {
14427
14495
  body: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_form.MFormBox), {
@@ -14445,6 +14513,7 @@
14445
14513
  "width",
14446
14514
  "height",
14447
14515
  "title",
14516
+ "framework-width",
14448
14517
  "position"
14449
14518
  ]);
14450
14519
  };
@@ -15774,6 +15843,7 @@
15774
15843
  const taskLength = (0, vue.computed)(() => depService.get("taskLength"));
15775
15844
  const tipsBarVisible = (0, vue.ref)(true);
15776
15845
  const columnLeftWidth = (0, vue.computed)(() => uiService.get("columnWidth")[ColumnLayout.LEFT]);
15846
+ const frameworkWidth = (0, vue.computed)(() => uiService.get("frameworkRect")?.width || 0);
15777
15847
  const { height: editorContentHeight } = useEditorContentHeight();
15778
15848
  const columnLeftHeight = (0, vue.ref)(0);
15779
15849
  const unWatchEditorContentHeight = (0, vue.watch)(editorContentHeight, (height) => {
@@ -16014,6 +16084,7 @@
16014
16084
  "onUpdate:height": _cache[2] || (_cache[2] = ($event) => columnLeftHeight.value = $event),
16015
16085
  width: columnLeftWidth.value,
16016
16086
  title: config.text,
16087
+ "framework-width": frameworkWidth.value,
16017
16088
  position: {
16018
16089
  left: (0, vue.unref)(floatBoxStates)[config.$key].left,
16019
16090
  top: (0, vue.unref)(floatBoxStates)[config.$key].top
@@ -16030,6 +16101,7 @@
16030
16101
  "height",
16031
16102
  "width",
16032
16103
  "title",
16104
+ "framework-width",
16033
16105
  "position"
16034
16106
  ])) : (0, vue.createCommentVNode)("v-if", true)], 64);
16035
16107
  }), 256))]))], 64);
@@ -16219,7 +16291,8 @@
16219
16291
  __name: "NodeListMenu",
16220
16292
  setup(__props) {
16221
16293
  const services = useServices();
16222
- const { editorService } = services;
16294
+ const { editorService, uiService } = services;
16295
+ const frameworkWidth = (0, vue.computed)(() => uiService.get("frameworkRect")?.width || 0);
16223
16296
  const visible = (0, vue.ref)(false);
16224
16297
  const buttonVisible = (0, vue.ref)(false);
16225
16298
  const buttonEl = (0, vue.useTemplateRef)("button");
@@ -16279,6 +16352,7 @@
16279
16352
  visible: visible.value,
16280
16353
  "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => visible.value = $event),
16281
16354
  title: "当前位置下的组件",
16355
+ "framework-width": frameworkWidth.value,
16282
16356
  position: menuPosition.value
16283
16357
  }, {
16284
16358
  body: (0, vue.withCtx)(() => [(0, vue.createVNode)(Tree_default, {
@@ -16288,7 +16362,11 @@
16288
16362
  onNodeClick: clickHandler
16289
16363
  }, null, 8, ["data", "node-status-map"])]),
16290
16364
  _: 1
16291
- }, 8, ["visible", "position"])) : (0, vue.createCommentVNode)("v-if", true)], 64);
16365
+ }, 8, [
16366
+ "visible",
16367
+ "framework-width",
16368
+ "position"
16369
+ ])) : (0, vue.createCommentVNode)("v-if", true)], 64);
16292
16370
  };
16293
16371
  }
16294
16372
  });
@@ -19924,6 +20002,7 @@
19924
20002
  const addFromJsonDialogVisible = (0, vue.useModel)(__props, "visible1");
19925
20003
  const { height: editorHeight } = useEditorContentHeight();
19926
20004
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, (0, vue.inject)("parentFloating", (0, vue.ref)(null)));
20005
+ const frameworkWidth = (0, vue.computed)(() => uiService.get("frameworkRect")?.width || 0);
19927
20006
  /**
19928
20007
  * 由 DataSourceConfigPanel 注入:打开数据源详情后需要直接打开的字段路径(字段名数组)。
19929
20008
  * 当前层消费 path[0],并把剩余路径下发给嵌套字段,实现逐层打开。
@@ -19964,6 +20043,7 @@
19964
20043
  _: 1
19965
20044
  }, 8, ["disabled"])])) : (0, vue.createCommentVNode)("v-if", true),
19966
20045
  (0, vue.createVNode)(FloatingBox_default, {
20046
+ "body-style": { padding: "0 16px" },
19967
20047
  visible: addDialogVisible.value,
19968
20048
  "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
19969
20049
  width: width.value,
@@ -19971,6 +20051,7 @@
19971
20051
  height: (0, vue.unref)(editorHeight),
19972
20052
  "onUpdate:height": _cache[4] || (_cache[4] = ($event) => (0, vue.isRef)(editorHeight) ? editorHeight.value = $event : null),
19973
20053
  title: fieldTitle.value,
20054
+ "framework-width": frameworkWidth.value,
19974
20055
  position: (0, vue.unref)(boxPosition)
19975
20056
  }, {
19976
20057
  body: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_form.MFormBox), {
@@ -19993,9 +20074,11 @@
19993
20074
  "width",
19994
20075
  "height",
19995
20076
  "title",
20077
+ "framework-width",
19996
20078
  "position"
19997
20079
  ]),
19998
20080
  (0, vue.createVNode)(FloatingBox_default, {
20081
+ "body-style": { padding: "0 16px" },
19999
20082
  visible: addFromJsonDialogVisible.value,
20000
20083
  "onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
20001
20084
  width: width.value,
@@ -20003,6 +20086,7 @@
20003
20086
  height: (0, vue.unref)(editorHeight),
20004
20087
  "onUpdate:height": _cache[7] || (_cache[7] = ($event) => (0, vue.isRef)(editorHeight) ? editorHeight.value = $event : null),
20005
20088
  title: "快速添加数据定义",
20089
+ "framework-width": frameworkWidth.value,
20006
20090
  position: (0, vue.unref)(boxPosition)
20007
20091
  }, {
20008
20092
  body: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_form.MFormBox), {
@@ -20016,6 +20100,7 @@
20016
20100
  "visible",
20017
20101
  "width",
20018
20102
  "height",
20103
+ "framework-width",
20019
20104
  "position"
20020
20105
  ])
20021
20106
  ]);
@@ -20235,6 +20320,7 @@
20235
20320
  const addDialogVisible = (0, vue.useModel)(__props, "visible");
20236
20321
  const { height: editorHeight } = useEditorContentHeight();
20237
20322
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, (0, vue.inject)("parentFloating", (0, vue.ref)(null)));
20323
+ const frameworkWidth = (0, vue.computed)(() => uiService.get("frameworkRect")?.width || 0);
20238
20324
  return (_ctx, _cache) => {
20239
20325
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$40, [
20240
20326
  (0, vue.createVNode)((0, vue.unref)(_tmagic_table.MagicTable), {
@@ -20252,6 +20338,7 @@
20252
20338
  _: 1
20253
20339
  }, 8, ["disabled"])])) : (0, vue.createCommentVNode)("v-if", true),
20254
20340
  (0, vue.createVNode)(FloatingBox_default, {
20341
+ "body-style": { padding: "0 16px" },
20255
20342
  visible: addDialogVisible.value,
20256
20343
  "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
20257
20344
  width: width.value,
@@ -20259,6 +20346,7 @@
20259
20346
  height: (0, vue.unref)(editorHeight),
20260
20347
  "onUpdate:height": _cache[3] || (_cache[3] = ($event) => (0, vue.isRef)(editorHeight) ? editorHeight.value = $event : null),
20261
20348
  title: drawerTitle.value,
20349
+ "framework-width": frameworkWidth.value,
20262
20350
  position: (0, vue.unref)(boxPosition)
20263
20351
  }, {
20264
20352
  body: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_form.MFormBox), {
@@ -20279,6 +20367,7 @@
20279
20367
  "width",
20280
20368
  "height",
20281
20369
  "title",
20370
+ "framework-width",
20282
20371
  "position"
20283
20372
  ])
20284
20373
  ]);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0-manmanyu.21",
2
+ "version": "1.8.0-manmanyu.23",
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.21",
62
- "@tmagic/table": "1.8.0-manmanyu.21",
63
- "@tmagic/form": "1.8.0-manmanyu.21",
64
- "@tmagic/utils": "1.8.0-manmanyu.21",
65
- "@tmagic/stage": "1.8.0-manmanyu.21"
61
+ "@tmagic/design": "1.8.0-manmanyu.23",
62
+ "@tmagic/form": "1.8.0-manmanyu.23",
63
+ "@tmagic/table": "1.8.0-manmanyu.23",
64
+ "@tmagic/utils": "1.8.0-manmanyu.23",
65
+ "@tmagic/stage": "1.8.0-manmanyu.23"
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.21"
79
+ "@tmagic/core": "1.8.0-manmanyu.23"
80
80
  },
81
81
  "peerDependenciesMeta": {
82
82
  "typescript": {
@@ -4,7 +4,9 @@
4
4
  v-model:visible="boxVisible"
5
5
  v-model:width="width"
6
6
  v-model:height="codeBlockEditorHeight"
7
+ :body-style="{ padding: '0 16px' }"
7
8
  :title="content.name ? `${disabled ? '查看' : '编辑'}${content.name}` : '新增代码'"
9
+ :framework-width="frameworkWidth"
8
10
  :position="boxPosition"
9
11
  :before-close="beforeClose"
10
12
  >
@@ -206,6 +208,7 @@ const closedHandler = () => {
206
208
 
207
209
  const parentFloating = inject<Ref<HTMLDivElement | null>>('parentFloating', ref(null));
208
210
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
211
+ const frameworkWidth = computed(() => uiService.get('frameworkRect')?.width || 0);
209
212
 
210
213
  watch(boxVisible, (visible) => {
211
214
  nextTick(() => {
@@ -13,6 +13,7 @@
13
13
  :extend-state="mergedExtendState"
14
14
  :show-diff="showDiff"
15
15
  :self-diff-field-types="selfDiffFieldTypes"
16
+ :size="size"
16
17
  ></MForm>
17
18
  </div>
18
19
  </template>
@@ -22,6 +23,7 @@ import { computed, inject, provide, type Ref, ref, type ShallowRef, useTemplateR
22
23
  import { isEqual } from 'lodash-es';
23
24
 
24
25
  import { type CodeBlockContent, type DataSourceSchema, HookType, type MNode } from '@tmagic/core';
26
+ import { type FieldSize } from '@tmagic/design';
25
27
  import { type FormConfig, type FormState, type FormValue, MForm } from '@tmagic/form';
26
28
 
27
29
  import type { CompareCategory, CompareFormLoadConfig, Services } from '@editor/type';
@@ -68,6 +70,11 @@ const props = withDefaults(
68
70
  baseFormState?: FormState;
69
71
  /** 需要走 self diff 的字段类型(例如 mod-cond)。 */
70
72
  selfDiffFieldTypes?: string[];
73
+ /**
74
+ * 表单内组件的尺寸(透传给 MForm 的 `size`),可选 'large' | 'default' | 'small'。
75
+ * 缺省时使用 MForm 内置默认尺寸。
76
+ */
77
+ size?: FieldSize;
71
78
  /**
72
79
  * 自定义 FormConfig 加载逻辑。传入后将接管内置的按 `category`(node/data-source/code-block)
73
80
  * 取配置逻辑,调用方可根据业务自行返回(或异步返回)表单配置。可通过
@@ -3,6 +3,7 @@
3
3
  <div
4
4
  ref="target"
5
5
  :class="['m-editor-float-box', themeClass]"
6
+ v-bind="$attrs"
6
7
  :style="{ ...style, zIndex: curZIndex }"
7
8
  @mousedown="nextZIndex"
8
9
  >
@@ -14,7 +15,7 @@
14
15
  <TMagicButton link size="small" @click="closeHandler"><MIcon :icon="Close"></MIcon></TMagicButton>
15
16
  </div>
16
17
  </div>
17
- <div class="m-editor-float-box-body" :style="{ height: `${bodyHeight}px` }">
18
+ <div class="m-editor-float-box-body" :style="{ height: `${bodyHeight}px`, ...bodyStyle }">
18
19
  <slot name="body"></slot>
19
20
  </div>
20
21
  </div>
@@ -22,14 +23,13 @@
22
23
  </template>
23
24
 
24
25
  <script setup lang="ts">
25
- import { computed, nextTick, onBeforeUnmount, provide, ref, useTemplateRef, watch } from 'vue';
26
+ import { computed, type CSSProperties, nextTick, onBeforeUnmount, provide, ref, useTemplateRef, watch } from 'vue';
26
27
  import { Close } from '@element-plus/icons-vue';
27
28
  import VanillaMoveable from 'moveable';
28
29
 
29
30
  import { TMagicButton, useThemeClass, useZIndex } from '@tmagic/design';
30
31
 
31
32
  import MIcon from '@editor/components/Icon.vue';
32
- import { useServices } from '@editor/hooks/use-services';
33
33
 
34
34
  interface Position {
35
35
  left: number;
@@ -44,11 +44,18 @@ const props = withDefaults(
44
44
  defineProps<{
45
45
  position?: Position;
46
46
  title?: string;
47
+ bodyStyle?: CSSProperties;
48
+ /** 浮窗初始样式,会与内部计算样式合并,外部传入优先 */
49
+ initialStyle?: CSSProperties;
50
+ /** 用于约束浮窗 left 的容器宽度,传入时按宽度收敛 left,避免超出右边界;默认取视窗宽度 */
51
+ frameworkWidth?: number;
47
52
  beforeClose?: (_done: (_cancel?: boolean) => void) => void;
48
53
  }>(),
49
54
  {
50
55
  title: '',
51
56
  position: () => ({ left: 0, top: 0 }),
57
+ initialStyle: () => ({}),
58
+ frameworkWidth: 0,
52
59
  },
53
60
  );
54
61
 
@@ -77,12 +84,11 @@ const bodyHeight = computed(() => {
77
84
  return 'auto';
78
85
  });
79
86
 
80
- const { uiService } = useServices();
81
- const frameworkWidth = computed(() => uiService.get('frameworkRect').width || 0);
82
87
  const style = computed(() => {
83
88
  let { left } = props.position;
84
- if (width.value) {
85
- left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
89
+ const frameworkWidth = props.frameworkWidth || globalThis.window?.innerWidth || 0;
90
+ if (width.value && frameworkWidth) {
91
+ left = left + width.value > frameworkWidth ? frameworkWidth - width.value : left;
86
92
  }
87
93
 
88
94
  return {
@@ -90,11 +96,60 @@ const style = computed(() => {
90
96
  top: `${props.position.top}px`,
91
97
  width: width.value ? `${width.value}px` : 'auto',
92
98
  height: height.value ? `${height.value}px` : 'auto',
99
+ ...props.initialStyle,
93
100
  };
94
101
  });
95
102
 
96
103
  let moveable: VanillaMoveable | null = null;
97
104
 
105
+ // 拖拽/缩放时用于覆盖 iframe 的遮罩,防止鼠标进入 iframe 区域后事件被 iframe 吞掉导致拖拽丢失
106
+ let dragMask: HTMLDivElement | null = null;
107
+ let dragMaskVisible = false;
108
+
109
+ // 兜底:正常情况下遮罩由 moveable 的 dragEnd/resizeEnd 移除;但某些极端场景
110
+ // (拖拽中鼠标移出窗口后松开、alt-tab 切走窗口失焦、标签页被隐藏等)结束事件不会触发,
111
+ // 会导致全屏透明遮罩残留、整个编辑器无法点击。这里挂全局 pointerup/blur/visibilitychange 强制收尾。
112
+ const bindDragMaskSafety = () => {
113
+ globalThis.window?.addEventListener('pointerup', hideDragMask, true);
114
+ globalThis.window?.addEventListener('blur', hideDragMask);
115
+ globalThis.document?.addEventListener('visibilitychange', hideDragMask);
116
+ };
117
+
118
+ const unbindDragMaskSafety = () => {
119
+ globalThis.window?.removeEventListener('pointerup', hideDragMask, true);
120
+ globalThis.window?.removeEventListener('blur', hideDragMask);
121
+ globalThis.document?.removeEventListener('visibilitychange', hideDragMask);
122
+ };
123
+
124
+ const showDragMask = () => {
125
+ if (dragMaskVisible) {
126
+ return;
127
+ }
128
+ if (!dragMask) {
129
+ dragMask = globalThis.document.createElement('div');
130
+ dragMask.className = 'm-editor-float-box-drag-mask';
131
+ }
132
+ globalThis.document.body.appendChild(dragMask);
133
+ dragMaskVisible = true;
134
+ bindDragMaskSafety();
135
+
136
+ // 拖拽标题时,root 上的 @mousedown="nextZIndex" 会把浮窗 z-index 抬高,
137
+ // 若此时才读取会拿到旧值导致遮罩被浮窗(及其内部 iframe)盖住,故用 nextTick 在 z-index 稳定后再设置到浮窗之上
138
+ const setMaskZIndex = () => {
139
+ if (dragMask) {
140
+ dragMask.style.zIndex = `${curZIndex.value + 1}`;
141
+ }
142
+ };
143
+ setMaskZIndex();
144
+ nextTick(setMaskZIndex);
145
+ };
146
+
147
+ const hideDragMask = () => {
148
+ unbindDragMaskSafety();
149
+ dragMask?.parentNode?.removeChild(dragMask);
150
+ dragMaskVisible = false;
151
+ };
152
+
98
153
  const initMoveable = () => {
99
154
  moveable = new VanillaMoveable(globalThis.document.body, {
100
155
  className: 'm-editor-floating-box-moveable',
@@ -112,6 +167,14 @@ const initMoveable = () => {
112
167
  bounds: { left: 0, top: 0, right: 0, bottom: 0, position: 'css' },
113
168
  });
114
169
 
170
+ // 仅在真正发生拖拽/缩放位移时插入遮罩:moveable 的 dragStart/resizeStart 在 mousedown 时即触发,
171
+ // 若此时就盖遮罩,会盖住浮窗本身导致 mouseup 落在遮罩上、关闭按钮的 click 无法触发(点击关闭不了)。
172
+ // 改为在 drag/resize(实际位移)时才显示,纯点击不再触发遮罩。
173
+ moveable.on('drag', showDragMask);
174
+ moveable.on('resize', showDragMask);
175
+ moveable.on('dragEnd', hideDragMask);
176
+ moveable.on('resizeEnd', hideDragMask);
177
+
115
178
  moveable.on('drag', (e) => {
116
179
  e.target.style.transform = e.transform;
117
180
  });
@@ -126,6 +189,7 @@ const initMoveable = () => {
126
189
  };
127
190
 
128
191
  const destroyMoveable = () => {
192
+ hideDragMask();
129
193
  moveable?.destroy();
130
194
  moveable = null;
131
195
  };