@tmagic/editor 1.8.0-beta.13 → 1.8.0-beta.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.
Files changed (120) hide show
  1. package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +15 -3
  2. package/dist/es/components/ContentMenu.vue_vue_type_script_setup_true_lang.js +11 -4
  3. package/dist/es/components/FloatingBox.vue_vue_type_script_setup_true_lang.js +7 -2
  4. package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +4 -1
  5. package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +4 -1
  6. package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +80 -55
  7. package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +5 -1
  8. package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +4 -1
  9. package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +10 -7
  10. package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +4 -1
  11. package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +4 -1
  12. package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +4 -1
  13. package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +4 -1
  14. package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +4 -1
  15. package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +4 -1
  16. package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +8 -2
  17. package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +99 -64
  18. package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +4 -1
  19. package/dist/es/fields/PageFragmentSelect.vue_vue_type_script_setup_true_lang.js +4 -1
  20. package/dist/es/fields/StyleSetter/Index.vue_vue_type_script_setup_true_lang.js +5 -4
  21. package/dist/es/fields/StyleSetter/components/BackgroundPosition.vue_vue_type_script_setup_true_lang.js +4 -1
  22. package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +1 -1
  23. package/dist/es/fields/StyleSetter/icons/align-items/Center.js +31 -0
  24. package/dist/es/fields/StyleSetter/icons/align-items/FlexEnd.js +31 -0
  25. package/dist/es/fields/StyleSetter/icons/align-items/FlexStart.js +31 -0
  26. package/dist/es/fields/StyleSetter/icons/align-items/SpaceAround.js +50 -0
  27. package/dist/es/fields/StyleSetter/icons/align-items/SpaceBetween.js +50 -0
  28. package/dist/es/fields/StyleSetter/icons/background-repeat/NoRepeat.js +6 -6
  29. package/dist/es/fields/StyleSetter/icons/background-repeat/Repeat.js +5 -2
  30. package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatX.js +28 -5
  31. package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatY.js +31 -5
  32. package/dist/es/fields/StyleSetter/icons/flex-direction/Column.js +10 -2
  33. package/dist/es/fields/StyleSetter/icons/flex-direction/ColumnReverse.js +10 -2
  34. package/dist/es/fields/StyleSetter/icons/flex-direction/Row.js +10 -2
  35. package/dist/es/fields/StyleSetter/icons/flex-direction/RowReverse.js +10 -2
  36. package/dist/es/fields/StyleSetter/icons/justify-content/Center.js +16 -2
  37. package/dist/es/fields/StyleSetter/icons/justify-content/FlexEnd.js +18 -2
  38. package/dist/es/fields/StyleSetter/icons/justify-content/FlexStart.js +18 -2
  39. package/dist/es/fields/StyleSetter/icons/justify-content/SpaceAround.js +36 -2
  40. package/dist/es/fields/StyleSetter/icons/justify-content/SpaceBetween.js +32 -2
  41. package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +7 -6
  42. package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +6 -3
  43. package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +47 -25
  44. package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +4 -1
  45. package/dist/es/icons/DatasourceIcon.js +17 -0
  46. package/dist/es/index.js +2 -2
  47. package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +14 -10
  48. package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +10 -1
  49. package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +3 -3
  50. package/dist/es/plugin.js +2 -1
  51. package/dist/es/services/editor.js +54 -13
  52. package/dist/es/services/ui.js +5 -3
  53. package/dist/es/style.css +303 -40
  54. package/dist/es/utils/config.js +4 -1
  55. package/dist/es/utils/const.js +2 -2
  56. package/dist/es/utils/props.js +43 -29
  57. package/dist/style.css +303 -40
  58. package/dist/themes/magic-admin.css +3000 -0
  59. package/dist/tmagic-editor.umd.cjs +1066 -449
  60. package/package.json +7 -7
  61. package/src/Editor.vue +22 -1
  62. package/src/components/ContentMenu.vue +10 -2
  63. package/src/components/FloatingBox.vue +8 -2
  64. package/src/editorProps.ts +4 -0
  65. package/src/fields/CodeSelect.vue +54 -43
  66. package/src/fields/CodeSelectCol.vue +1 -0
  67. package/src/fields/DataSourceFieldSelect/Index.vue +14 -5
  68. package/src/fields/DisplayConds.vue +4 -1
  69. package/src/fields/EventSelect.vue +56 -32
  70. package/src/fields/StyleSetter/Index.vue +1 -4
  71. package/src/fields/StyleSetter/components/Border.vue +1 -1
  72. package/src/fields/StyleSetter/icons/align-items/Center.vue +19 -0
  73. package/src/fields/StyleSetter/icons/align-items/FlexEnd.vue +19 -0
  74. package/src/fields/StyleSetter/icons/align-items/FlexStart.vue +19 -0
  75. package/src/fields/StyleSetter/icons/align-items/SpaceAround.vue +34 -0
  76. package/src/fields/StyleSetter/icons/align-items/SpaceBetween.vue +34 -0
  77. package/src/fields/StyleSetter/icons/align-items/index.ts +5 -0
  78. package/src/fields/StyleSetter/icons/background-repeat/NoRepeat.vue +20 -4
  79. package/src/fields/StyleSetter/icons/background-repeat/Repeat.vue +10 -28
  80. package/src/fields/StyleSetter/icons/background-repeat/RepeatX.vue +4 -5
  81. package/src/fields/StyleSetter/icons/background-repeat/RepeatY.vue +4 -5
  82. package/src/fields/StyleSetter/icons/flex-direction/Column.vue +4 -3
  83. package/src/fields/StyleSetter/icons/flex-direction/ColumnReverse.vue +4 -3
  84. package/src/fields/StyleSetter/icons/flex-direction/Row.vue +4 -3
  85. package/src/fields/StyleSetter/icons/flex-direction/RowReverse.vue +4 -3
  86. package/src/fields/StyleSetter/icons/justify-content/Center.vue +5 -2
  87. package/src/fields/StyleSetter/icons/justify-content/FlexEnd.vue +15 -2
  88. package/src/fields/StyleSetter/icons/justify-content/FlexStart.vue +15 -2
  89. package/src/fields/StyleSetter/icons/justify-content/SpaceAround.vue +28 -3
  90. package/src/fields/StyleSetter/icons/justify-content/SpaceBetween.vue +28 -2
  91. package/src/fields/StyleSetter/pro/Background.vue +7 -2
  92. package/src/fields/StyleSetter/pro/Font.vue +3 -3
  93. package/src/fields/StyleSetter/pro/Layout.vue +98 -28
  94. package/src/icons/DatasourceIcon.vue +7 -0
  95. package/src/index.ts +3 -0
  96. package/src/layouts/Framework.vue +7 -1
  97. package/src/layouts/props-panel/PropsPanel.vue +19 -1
  98. package/src/layouts/sidebar/Sidebar.vue +3 -3
  99. package/src/plugin.ts +3 -2
  100. package/src/services/editor.ts +54 -11
  101. package/src/services/ui.ts +20 -5
  102. package/src/theme/code-block.scss +37 -0
  103. package/src/theme/common/var.scss +1 -1
  104. package/src/theme/component-list-panel.scss +2 -2
  105. package/src/theme/data-source-field.scss +4 -0
  106. package/src/theme/display-conds.scss +11 -0
  107. package/src/theme/event.scss +58 -4
  108. package/src/theme/framework.scss +4 -1
  109. package/src/theme/history-list-panel.scss +9 -9
  110. package/src/theme/nav-menu.scss +5 -1
  111. package/src/theme/props-panel.scss +2 -1
  112. package/src/theme/style-setter/border.scss +14 -5
  113. package/src/theme/theme.scss +1 -0
  114. package/src/theme/themes/magic-admin/index.scss +214 -0
  115. package/src/theme/ui-select.scss +1 -1
  116. package/src/type.ts +27 -6
  117. package/src/utils/config.ts +9 -1
  118. package/src/utils/const.ts +3 -2
  119. package/src/utils/props.ts +22 -9
  120. package/types/index.d.ts +88 -35
@@ -0,0 +1,7 @@
1
+ <template>
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
3
+ <path
4
+ d="M6.25 9.723C4.392 9.6095 2.804 9.137 1.875 8.4775V9.7495C1.875 10.6165 3.7665 11.3365 6.25 11.4745V12.348C4.392 12.2345 2.804 11.763 1.875 11.102V12.3745H1V4.0625C1 2.371 3.742 1 7.125 1C10.507 1 13.249 2.371 13.249 4.0625V6.8255H12.374V5.6405C11.3025 6.5295 9.352 7.1245 7.1245 7.1245C4.897 7.1245 2.947 6.5295 1.8745 5.6405V7.1245C1.8745 7.9915 3.7665 8.712 6.2495 8.85L6.25 9.723ZM7.125 14.999C3.742 14.999 1 13.8245 1 12.3745H1.875C1.875 13.3415 4.225 14.124 7.125 14.124V14.999ZM7.125 6.2495C10.024 6.2495 12.3745 5.2695 12.3745 4.0625C12.3745 2.855 10.0245 1.875 7.1245 1.875C4.225 1.875 1.8745 2.855 1.8745 4.0625C1.8745 5.2695 4.2255 6.2495 7.125 6.2495ZM14.7385 11.9895L14.1295 11.6345C14.1635 11.4485 14.1855 11.2585 14.1855 11.062C14.1843 10.8697 14.1655 10.6779 14.1295 10.489L14.7385 10.134C14.988 9.987 15.073 9.667 14.929 9.416L14.409 8.507C14.3752 8.44726 14.3299 8.39483 14.2757 8.35275C14.2215 8.31066 14.1595 8.27977 14.0933 8.26186C14.027 8.24395 13.9579 8.23938 13.8898 8.24842C13.8218 8.25745 13.7563 8.27992 13.697 8.3145L13.081 8.6735C12.7931 8.42269 12.4616 8.22694 12.103 8.096V7.6495C12.103 7.36 11.8705 7.1245 11.5825 7.1245H10.5415C10.4728 7.12476 10.4049 7.13855 10.3415 7.16507C10.2782 7.1916 10.2206 7.23034 10.1723 7.2791C10.1239 7.32785 10.0856 7.38565 10.0595 7.4492C10.0335 7.51276 10.0202 7.58082 10.0205 7.6495V8.096C9.66186 8.22694 9.33035 8.42269 9.0425 8.6735L8.4265 8.3145C8.36725 8.27999 8.30174 8.2576 8.23377 8.2486C8.1658 8.23961 8.09672 8.24419 8.03053 8.2621C7.96435 8.28001 7.90238 8.31088 7.84821 8.35292C7.79405 8.39495 7.74877 8.44733 7.715 8.507L7.195 9.417C7.12576 9.53751 7.10688 9.68047 7.14246 9.81482C7.17804 9.94917 7.2652 10.0641 7.385 10.1345L7.9945 10.489C7.9585 10.6775 7.9395 10.8695 7.9385 11.062C7.9385 11.2585 7.96 11.4485 7.9945 11.635L7.3855 11.99C7.1355 12.1365 7.0505 12.4565 7.1945 12.7075L7.715 13.6165C7.74877 13.6762 7.79405 13.7285 7.84821 13.7706C7.90238 13.8126 7.96435 13.8435 8.03053 13.8614C8.09672 13.8793 8.1658 13.8839 8.23377 13.8749C8.30174 13.8659 8.36725 13.8435 8.4265 13.809L9.0425 13.4505C9.33023 13.7015 9.66178 13.8972 10.0205 14.028V14.474C10.0205 14.764 10.2535 14.999 10.5415 14.999H11.5825C11.7211 14.9983 11.8538 14.9427 11.9514 14.8442C12.049 14.7458 12.1035 14.6126 12.103 14.474V14.028C12.4616 13.8971 12.7931 13.7013 13.081 13.4505L13.697 13.809C13.7563 13.8434 13.8218 13.8657 13.8897 13.8746C13.9577 13.8835 14.0267 13.8789 14.0929 13.861C14.159 13.8431 14.221 13.8123 14.2751 13.7703C14.3293 13.7283 14.3746 13.6761 14.4085 13.6165L14.929 12.7065C14.998 12.586 15.0168 12.4431 14.9811 12.3089C14.9454 12.1746 14.8583 12.0599 14.7385 11.9895ZM14.092 12.5065L13.852 12.915C13.8193 12.9693 13.7667 13.0086 13.7054 13.0246C13.6441 13.0406 13.579 13.0319 13.524 13.0005L12.8575 12.623C12.5109 13.0069 12.0497 13.2688 11.5425 13.37V13.889C11.5425 14.0185 11.4345 14.124 11.3015 14.124H10.822C10.7907 14.1243 10.7597 14.1184 10.7308 14.1067C10.7018 14.0949 10.6754 14.0776 10.6531 14.0557C10.6308 14.0338 10.6131 14.0077 10.6009 13.9789C10.5887 13.9502 10.5823 13.9193 10.582 13.888V13.37C10.0746 13.2689 9.61328 13.007 9.2665 12.623L8.6 13C8.54495 13.0316 8.47971 13.0403 8.4183 13.0243C8.35688 13.0083 8.30418 12.9689 8.2715 12.9145L8.0315 12.506C8.01582 12.4792 8.00564 12.4496 8.00158 12.4189C7.99752 12.3881 7.99965 12.3569 8.00785 12.327C8.01605 12.297 8.03016 12.2691 8.04933 12.2447C8.0685 12.2203 8.09236 12.2 8.1195 12.185L8.789 11.805C8.70604 11.5658 8.66313 11.3146 8.662 11.0615C8.662 10.8005 8.709 10.552 8.7895 10.3175L8.1195 9.9375C8.09247 9.92244 8.06872 9.90213 8.04964 9.87777C8.03056 9.85341 8.01654 9.82549 8.00839 9.79564C8.00024 9.76579 7.99813 9.73461 8.00218 9.70394C8.00624 9.67326 8.01637 9.64371 8.032 9.617L8.272 9.208C8.30467 9.15373 8.35729 9.1144 8.41858 9.09843C8.47988 9.08245 8.54499 9.09109 8.6 9.1225L9.2665 9.5005C9.61315 9.11663 10.0743 8.85468 10.5815 8.7535V8.235C10.5815 8.105 10.689 8 10.822 8H11.302C11.4345 8 11.542 8.105 11.542 8.236V8.754C12.0492 8.85518 12.5104 9.11713 12.857 9.501L13.524 9.123C13.579 9.09159 13.6441 9.08295 13.7054 9.09893C13.7667 9.1149 13.8193 9.15423 13.852 9.2085L14.092 9.6175C14.1077 9.64423 14.1179 9.67383 14.122 9.70455C14.1261 9.73528 14.124 9.76652 14.1159 9.79643C14.1077 9.82634 14.0937 9.85431 14.0745 9.87871C14.0554 9.90311 14.0316 9.92344 14.0045 9.9385L13.335 10.3185C13.4135 10.5525 13.462 10.801 13.462 11.062C13.462 11.3225 13.4145 11.571 13.335 11.8055L14.0045 12.1855C14.0316 12.2006 14.0554 12.2209 14.0745 12.2453C14.0937 12.2697 14.1077 12.2977 14.1159 12.3276C14.124 12.3575 14.1261 12.3887 14.122 12.4194C14.1179 12.4502 14.1077 12.4798 14.092 12.5065ZM11.062 9.7495C10.7139 9.7495 10.3801 9.88778 10.1339 10.1339C9.88778 10.3801 9.7495 10.7139 9.7495 11.062C9.7495 11.4101 9.88778 11.7439 10.1339 11.9901C10.3801 12.2362 10.7139 12.3745 11.062 12.3745C11.4101 12.3745 11.7439 12.2362 11.9901 11.9901C12.2362 11.7439 12.3745 11.4101 12.3745 11.062C12.3745 10.7139 12.2362 10.3801 11.9901 10.1339C11.7439 9.88778 11.4101 9.7495 11.062 9.7495ZM11.062 11.4995C10.946 11.4995 10.8347 11.4534 10.7526 11.3714C10.6706 11.2893 10.6245 11.178 10.6245 11.062C10.6245 10.946 10.6706 10.8347 10.7526 10.7526C10.8347 10.6706 10.946 10.6245 11.062 10.6245C11.178 10.6245 11.2893 10.6706 11.3714 10.7526C11.4534 10.8347 11.4995 10.946 11.4995 11.062C11.4995 11.178 11.4534 11.2893 11.3714 11.3714C11.2893 11.4534 11.178 11.4995 11.062 11.4995Z"
5
+ />
6
+ </svg>
7
+ </template>
package/src/index.ts CHANGED
@@ -32,6 +32,9 @@ export { DepTargetType } from '@tmagic/core';
32
32
  export * from './type';
33
33
  export * from './hooks';
34
34
  export * from './utils';
35
+ // `isGlobalFlat` 同时在 `@tmagic/design` 和 `./utils/config` 中存在,
36
+ // 通过显式重导一次消除 `export *` 带来的歧义,并固定使用 editor 自己那份。
37
+ export { isGlobalFlat } from './utils/config';
35
38
  export { default as TMagicEditor } from './Editor.vue';
36
39
  export { default as TMagicCodeEditor } from './layouts/CodeEditor.vue';
37
40
  export { default as editorService } from './services/editor';
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <div class="m-editor" ref="content" style="min-width: 900px">
2
+ <div
3
+ ref="content"
4
+ :class="['m-editor', theme ? `m-editor--${theme}` : '', theme ? `m-theme--${theme}` : '']"
5
+ style="min-width: 900px"
6
+ >
3
7
  <slot name="header"></slot>
4
8
 
5
9
  <slot name="nav"></slot>
@@ -97,6 +101,8 @@ const props = defineProps<{
97
101
  pageFilterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
98
102
  /** 是否隐藏左侧面板 */
99
103
  hideSidebar?: boolean;
104
+ /** 主题名称,会在根节点追加 `m-editor--<theme>` 修饰类 */
105
+ theme?: string;
100
106
  }>();
101
107
 
102
108
  const codeOptions = inject('codeOptions', {});
@@ -111,14 +111,31 @@ const styleFormConfig = [
111
111
  },
112
112
  ];
113
113
 
114
+ // 用单调递增序号标记每次 init 调用,只让"最新一次"的 await 结果落到 ref 上。
115
+ // 避免节点快速切换时多个 init 并发 + 解析顺序错乱导致 stale config 覆盖最新选中节点,
116
+ // 以及组件已卸载 / FormPanel 正在 remount 的中间态下写 ref 触发 Vue setRef 把 __vnode
117
+ // 设到 null 上的报错(TypeError: Cannot set properties of null (setting '__vnode'))。
118
+ let initSeq = 0;
119
+ let mounted = true;
120
+
114
121
  const init = async () => {
122
+ initSeq += 1;
123
+ const seq = initSeq;
124
+
115
125
  if (!node.value) {
126
+ if (seq !== initSeq || !mounted) return;
116
127
  curFormConfig.value = [];
117
128
  return;
118
129
  }
119
130
 
120
131
  const type = node.value.type || (node.value.items ? 'container' : 'text');
121
- curFormConfig.value = await propsService.getPropsConfig(type, { node: node.value });
132
+ const config = await propsService.getPropsConfig(type, { node: node.value });
133
+
134
+ // 期间被新一次 init 取代 / 组件已卸载,丢弃本次结果
135
+ if (seq !== initSeq || !mounted) return;
136
+ if (!node.value) return;
137
+
138
+ curFormConfig.value = config;
122
139
  values.value = node.value;
123
140
  };
124
141
 
@@ -126,6 +143,7 @@ watchEffect(init);
126
143
  propsService.on('props-configs-change', init);
127
144
 
128
145
  onBeforeUnmount(() => {
146
+ mounted = false;
129
147
  propsService.off('props-configs-change', init);
130
148
  });
131
149
 
@@ -155,7 +155,7 @@
155
155
 
156
156
  <script setup lang="ts">
157
157
  import { computed, nextTick, ref, watch } from 'vue';
158
- import { Close, Coin, EditPen, Goods, List } from '@element-plus/icons-vue';
158
+ import { Box, Close, Coin, EditPen, Finished } from '@element-plus/icons-vue';
159
159
 
160
160
  import FloatingBox from '@editor/components/FloatingBox.vue';
161
161
  import MIcon from '@editor/components/Icon.vue';
@@ -253,7 +253,7 @@ const getItemConfig = (data: SideItem): SideComponent => {
253
253
  [SideItemKey.COMPONENT_LIST]: {
254
254
  $key: SideItemKey.COMPONENT_LIST,
255
255
  type: 'component',
256
- icon: Goods,
256
+ icon: Box,
257
257
  text: '组件',
258
258
  component: ComponentListPanel,
259
259
  slots: {},
@@ -261,7 +261,7 @@ const getItemConfig = (data: SideItem): SideComponent => {
261
261
  layer: {
262
262
  $key: SideItemKey.LAYER,
263
263
  type: 'component',
264
- icon: List,
264
+ icon: Finished,
265
265
  text: '已选组件',
266
266
  props: {
267
267
  layerContentMenu: props.layerContentMenu,
package/src/plugin.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import type { App } from 'vue';
19
+ import { type App } from 'vue';
20
20
 
21
21
  import type { DesignPluginOptions } from '@tmagic/design';
22
22
  import designPlugin from '@tmagic/design';
@@ -56,6 +56,8 @@ const defaultInstallOpt: EditorInstallOptions = {
56
56
  customCreateMonacoEditor: (monaco, codeEditorEl, options) => monaco.editor.create(codeEditorEl, options),
57
57
  customCreateMonacoDiffEditor: (monaco, codeEditorEl, options) =>
58
58
  monaco.editor.createDiffEditor(codeEditorEl, options),
59
+
60
+ flat: false,
59
61
  };
60
62
 
61
63
  export default {
@@ -69,7 +71,6 @@ export default {
69
71
 
70
72
  app.config.globalProperties.$TMAGIC_EDITOR = option;
71
73
  setEditorConfig(option);
72
-
73
74
  app.component(`${Editor.name || 'MEditor'}`, Editor);
74
75
  app.component('magic-code-editor', CodeEditor);
75
76
  app.component('m-fields-ui-select', uiSelect);
@@ -550,6 +550,8 @@ class Editor extends BaseService {
550
550
  this.emit('change', {
551
551
  type: 'add',
552
552
  data: newNodes.map((node) => ({ node, page: this.getPageOfNode(node.id) })),
553
+ historySource,
554
+ doNotPushHistory,
553
555
  });
554
556
 
555
557
  return Array.isArray(addNode) ? newNodes : newNodes[0];
@@ -692,7 +694,7 @@ class Editor extends BaseService {
692
694
  }
693
695
 
694
696
  this.emit('remove', nodes);
695
- this.emit('change', { type: 'remove', data: changeItems });
697
+ this.emit('change', { type: 'remove', data: changeItems, historySource, doNotPushHistory });
696
698
  }
697
699
 
698
700
  public async doUpdate(
@@ -846,6 +848,8 @@ class Editor extends BaseService {
846
848
  this.emit('change', {
847
849
  type: 'update',
848
850
  data: updateData.map((node) => ({ node, page: this.getPageOfNode(node.newNode.id) })),
851
+ historySource,
852
+ doNotPushHistory,
849
853
  });
850
854
  return Array.isArray(config) ? updateData.map((item) => item.newNode) : updateData[0].newNode;
851
855
  }
@@ -1092,6 +1096,8 @@ class Editor extends BaseService {
1092
1096
  type: 'move-layer',
1093
1097
  data: [{ node, page: this.getPageOfNode(node.id) }],
1094
1098
  offset,
1099
+ historySource,
1100
+ doNotPushHistory,
1095
1101
  });
1096
1102
  }
1097
1103
 
@@ -1277,6 +1283,8 @@ class Editor extends BaseService {
1277
1283
  data: configs.map((node) => ({ node, page: this.getPageOfNode(node.id) })),
1278
1284
  targetIndex,
1279
1285
  targetParent,
1286
+ historySource,
1287
+ doNotPushHistory,
1280
1288
  });
1281
1289
  }
1282
1290
 
@@ -1878,10 +1886,12 @@ class Editor extends BaseService {
1878
1886
  /**
1879
1887
  * 应用历史操作(撤销 / 重做)
1880
1888
  *
1881
- * 所有 DSL 修改都走 `editor.add / remove / update`,并通过 `doNotPushHistory` 阻止再次入栈、
1882
- * `doNotSelect / doNotSwitchPage` 让选区由方法末尾的统一逻辑兜底。
1889
+ * 删除 / 更新类修改走 `editor.remove / update`,并通过 `doNotPushHistory` 阻止再次入栈、
1890
+ * `doNotSelect / doNotSwitchPage` 让选区由方法末尾的统一逻辑兜底;
1891
+ * 「重新插回节点」(撤销 remove / 重做 add)需按 step 记录的 parentId / index 精确还原,
1892
+ * 不走 this.add,由手工 splice + stage.add 完成后补发等价的 add / change 事件(见 emitHistoryInsertEvents)。
1883
1893
  *
1884
- * 注意:这些公开方法会发出 add / remove / update 事件,业务侧若需要区分"用户操作"与"撤销重做触发",
1894
+ * 注意:这些路径都会发出 add / remove / update / change 事件,业务侧若需要区分"用户操作"与"撤销重做触发",
1885
1895
  * 请监听 `history-change` 事件配合判断。
1886
1896
  *
1887
1897
  * @param step 操作记录
@@ -1894,7 +1904,14 @@ class Editor extends BaseService {
1894
1904
  const stage = this.get('stage');
1895
1905
  if (!root) return;
1896
1906
 
1897
- const commonOpts = { doNotSelect: true, doNotSwitchPage: true, doNotPushHistory: true } as const;
1907
+ // 撤销/重做内部复用 add/remove/update,透传被应用 step 上记录的 source,
1908
+ // 使其触发的 change 事件同样携带「历史来源」
1909
+ const commonOpts = {
1910
+ doNotSelect: true,
1911
+ doNotSwitchPage: true,
1912
+ doNotPushHistory: true,
1913
+ historySource: step.source,
1914
+ } as const;
1898
1915
 
1899
1916
  switch (step.opType) {
1900
1917
  case 'add': {
@@ -1910,17 +1927,22 @@ class Editor extends BaseService {
1910
1927
  }
1911
1928
  } else {
1912
1929
  // 重做 add:按记录的 parentId / index 把节点重新插回父容器。
1913
- // 按目标 index 升序逐个插入,先小后大避免索引漂移
1930
+ // 按目标 index 升序逐个插入,先小后大避免索引漂移。
1931
+ // 不走 this.add:doAdd 依赖当前选中节点(无选区时直接抛错),且只能插到选中节点之后 / 末尾,
1932
+ // 无法按 step 记录的 parentId / index 精确还原,还会重算 style 破坏已记录的终态位置。
1914
1933
  const sorted = [...items].sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
1934
+ const addedNodes: MNode[] = [];
1915
1935
  for (const { newSchema, parentId, index } of sorted) {
1916
1936
  if (!newSchema || parentId === undefined) continue;
1917
1937
  const parent = this.getNodeById(parentId, false) as MContainer | null;
1918
1938
  if (parent?.items) {
1939
+ const addedNode = cloneDeep(newSchema);
1919
1940
  if (typeof index === 'number' && index >= 0 && index < parent.items.length) {
1920
- parent.items.splice(index, 0, cloneDeep(newSchema));
1941
+ parent.items.splice(index, 0, addedNode);
1921
1942
  } else {
1922
- parent.items.push(cloneDeep(newSchema));
1943
+ parent.items.push(addedNode);
1923
1944
  }
1945
+ addedNodes.push(addedNode);
1924
1946
  await stage?.add({
1925
1947
  config: cloneDeep(newSchema),
1926
1948
  parent: cloneDeep(parent),
@@ -1929,19 +1951,23 @@ class Editor extends BaseService {
1929
1951
  });
1930
1952
  }
1931
1953
  }
1954
+ this.emitHistoryInsertEvents(addedNodes, step.source);
1932
1955
  }
1933
1956
  break;
1934
1957
  }
1935
1958
  case 'remove': {
1936
1959
  const items = step.diff ?? [];
1937
1960
  if (reverse) {
1938
- // 撤销 remove:按原 index 升序逐个插回(先小后大避免索引漂移)
1961
+ // 撤销 remove:按原 index 升序逐个插回(先小后大避免索引漂移);不走 this.add 的原因同上
1939
1962
  const sorted = [...items].sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
1963
+ const addedNodes: MNode[] = [];
1940
1964
  for (const { oldSchema, parentId, index } of sorted) {
1941
1965
  if (!oldSchema || parentId === undefined) continue;
1942
1966
  const parent = this.getNodeById(parentId, false) as MContainer | null;
1943
1967
  if (parent?.items) {
1944
- parent.items.splice(index ?? parent.items.length, 0, cloneDeep(oldSchema));
1968
+ const addedNode = cloneDeep(oldSchema);
1969
+ parent.items.splice(index ?? parent.items.length, 0, addedNode);
1970
+ addedNodes.push(addedNode);
1945
1971
  await stage?.add({
1946
1972
  config: cloneDeep(oldSchema),
1947
1973
  parent: cloneDeep(parent),
@@ -1950,6 +1976,7 @@ class Editor extends BaseService {
1950
1976
  });
1951
1977
  }
1952
1978
  }
1979
+ this.emitHistoryInsertEvents(addedNodes, step.source);
1953
1980
  } else {
1954
1981
  // 重做 remove:再删一次
1955
1982
  for (const { oldSchema } of items) {
@@ -1989,7 +2016,7 @@ class Editor extends BaseService {
1989
2016
  return cloneDeep(reverse ? oldNode : newNode);
1990
2017
  });
1991
2018
  if (configs.length) {
1992
- await this.update(configs, { doNotPushHistory: true });
2019
+ await this.update(configs, { doNotPushHistory: true, historySource: step.source });
1993
2020
  }
1994
2021
  break;
1995
2022
  }
@@ -2028,6 +2055,22 @@ class Editor extends BaseService {
2028
2055
  private selectedConfigExceptionHandler(config: MNode | Id): EditorNodeInfo {
2029
2056
  return resolveSelectedNode(config, (id) => this.getNodeInfo(id), this.state.root?.id);
2030
2057
  }
2058
+
2059
+ /**
2060
+ * 撤销 remove / 重做 add 通过手工 splice 按 step 记录的 parentId / index 精确还原节点(不走 this.add,原因见调用处注释),
2061
+ * 这里补齐与 this.add 等价的 add / change 事件,保证撤销/重做路径的事件行为与正向操作一致。
2062
+ */
2063
+ private emitHistoryInsertEvents(nodes: MNode[], source?: HistoryOpSource) {
2064
+ if (!nodes.length) return;
2065
+ this.emit('add', nodes);
2066
+ this.emit('change', {
2067
+ type: 'add',
2068
+ data: nodes.map((node) => ({ node, page: this.getPageOfNode(node.id) })),
2069
+ historySource: source,
2070
+ // 撤销/重做本身不再写入历史记录
2071
+ doNotPushHistory: true,
2072
+ });
2073
+ }
2031
2074
  }
2032
2075
 
2033
2076
  export type EditorService = Editor;
@@ -49,13 +49,14 @@ const state = shallowReactive<UiState>({
49
49
  width: 375,
50
50
  height: 817,
51
51
  },
52
+ // 先给 columnWidth 留占位,真正的 clamp 逻辑在 state 创建完成后
53
+ // 用 state.minLeftColumnWidth / state.minRightColumnWidth 作为下限重新赋值 —
54
+ // 这样以后从外部(比如 uiService.set('minLeftColumnWidth', ...))动态改最小宽度,
55
+ // 只改一处 state 字段即可,不用同步 MIN_* 常量。
52
56
  columnWidth: {
53
- left:
54
- storageService.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_LEFT_COLUMN_WIDTH,
57
+ left: 0,
55
58
  center: 0,
56
- right:
57
- storageService.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) ||
58
- DEFAULT_RIGHT_COLUMN_WIDTH,
59
+ right: 0,
59
60
  },
60
61
  minLeftColumnWidth: MIN_LEFT_COLUMN_WIDTH,
61
62
  minCenterColumnWidth: MIN_CENTER_COLUMN_WIDTH,
@@ -83,6 +84,20 @@ const state = shallowReactive<UiState>({
83
84
  },
84
85
  });
85
86
 
87
+ // 左右两栏宽度延后初始化:
88
+ // - 优先取 storage 里用户上次拖到的值;storage 空时回落到 DEFAULT_*;
89
+ // - 再用 state.min*ColumnWidth 兜底,防止历史 storage 里存的是老版本或用户拖过头
90
+ // 留下的"比当前 min 还小"的数值。放到 state 之后写是因为初始化时无法在同一个
91
+ // 对象字面量里读到自己的其它字段。
92
+ state.columnWidth.left = Math.max(
93
+ storageService.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_LEFT_COLUMN_WIDTH,
94
+ state.minLeftColumnWidth,
95
+ );
96
+ state.columnWidth.right = Math.max(
97
+ storageService.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_RIGHT_COLUMN_WIDTH,
98
+ state.minRightColumnWidth,
99
+ );
100
+
86
101
  const canUsePluginMethods = {
87
102
  async: ['zoom', 'calcZoom'] as const,
88
103
  sync: [] as const,
@@ -1,3 +1,40 @@
1
1
  .m-fields-code-select {
2
2
  width: 100%;
3
+ > .el-card.tmagic-design-card--flat {
4
+ background-color: transparent;
5
+ margin-bottom: 10px;
6
+ > .el-card__body {
7
+ padding-left: 0;
8
+ .code-select-content {
9
+ > .m-fields-group-list {
10
+ > .tmagic-design-card--flat.el-card {
11
+ padding-left: 16px;
12
+ padding-right: 16px;
13
+ margin-bottom: 10px;
14
+ border: 0 !important;
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ .el-card__body {
21
+ .tmagic-design-form-item {
22
+ margin-bottom: 18px;
23
+ }
24
+ }
25
+ .code-select-content {
26
+ > .m-fields-group-list {
27
+ > .tmagic-design-card--flat {
28
+ > .el-card__header {
29
+ padding: 16px 0;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ .create-button {
35
+ &.fullWidth {
36
+ width: 100%;
37
+ margin: 0 0 16px 0;
38
+ }
39
+ }
3
40
  }
@@ -1,4 +1,4 @@
1
- $theme-color: #2882e0;
1
+ $theme-color: var(--el-color-primary, #2882e0);
2
2
 
3
3
  $font-color: #313a40;
4
4
  $border-color: #d9dbdd;
@@ -77,9 +77,9 @@
77
77
  margin-bottom: 5px;
78
78
 
79
79
  &:hover {
80
- background: #2882e0;
80
+ background: var(--el-color-primary, #2882e0);
81
81
  color: #fff;
82
- border-color: #4e8be1;
82
+ border-color: var(--el-color-primary, #4e8be1);
83
83
  }
84
84
  }
85
85
 
@@ -5,6 +5,10 @@
5
5
  width: 100%;
6
6
  display: flex;
7
7
  align-items: center;
8
+ &.data-source-field-img-upload,
9
+ &.data-source-field-big-img-upload {
10
+ align-items: flex-start;
11
+ }
8
12
 
9
13
  .m-fields-select-action-button {
10
14
  margin-left: 5px;
@@ -0,0 +1,11 @@
1
+ .m-container-text.display-conds-title {
2
+ .tmagic-design-form-item {
3
+ .el-form-item__label {
4
+ color: #111;
5
+ font-weight: 500;
6
+ font-size: 16px;
7
+ }
8
+ line-height: 24px;
9
+ margin-bottom: 10px;
10
+ }
11
+ }
@@ -2,8 +2,29 @@
2
2
  width: 100%;
3
3
  .fullWidth {
4
4
  width: 100%;
5
+ box-sizing: border-box;
6
+ }
7
+ .event-select-container {
8
+ padding: 0 16px;
9
+ > .el-card.tmagic-design-card--flat {
10
+ > .el-card__header {
11
+ border-bottom: 1px solid #ebeef5;
12
+ }
13
+ > .el-card__body {
14
+ padding-bottom: 16px;
15
+ .m-fields-group-list-footer {
16
+ div {
17
+ justify-content: flex-start !important;
18
+ }
19
+ }
20
+ .el-card.tmagic-design-card--flat {
21
+ > .el-card__header {
22
+ padding: 16px 0;
23
+ }
24
+ }
25
+ }
26
+ }
5
27
  }
6
-
7
28
  .event-select-code {
8
29
  margin-left: 20px;
9
30
  width: auto;
@@ -36,10 +57,43 @@
36
57
  }
37
58
  }
38
59
 
39
- .el-form-item {
60
+ .event-select-container {
61
+ padding: 0 16px;
62
+ }
63
+
64
+ .event-select-header {
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: space-between;
68
+ margin-bottom: 8px;
69
+ .event-select-title {
70
+ color: #0f1113;
71
+ font-size: 16px;
72
+ font-weight: 500;
73
+ line-height: 24px;
74
+ }
75
+ }
76
+ .event-item-header {
77
+ position: relative;
78
+ width: 100%;
79
+ .event-item-title {
80
+ color: #0f1113;
81
+ font-size: 16px;
82
+ font-weight: 500;
83
+ line-height: 24px;
84
+ margin-bottom: 16px;
85
+ }
86
+ .event-item-delete-button {
87
+ position: absolute;
88
+ right: 0;
89
+ top: 0;
90
+ }
91
+
40
92
  .el-form-item {
41
- &.is-error {
42
- margin-bottom: 18px;
93
+ .el-form-item {
94
+ &.is-error {
95
+ margin-bottom: 18px;
96
+ }
43
97
  }
44
98
  }
45
99
  }
@@ -6,7 +6,10 @@
6
6
  width: 100%;
7
7
 
8
8
  &-content {
9
- height: calc(100% - #{$nav-height});
9
+ // nav-menu.scss 的 `--editor-nav-height` 联动:默认 fallback 到 SCSS
10
+ // `$nav-height`(35px),主题覆盖时两处会同时切成同一个高度,保证 nav 和
11
+ // 主内容区总高度 = 100%。
12
+ height: calc(100% - var(--editor-nav-height, #{$nav-height}));
10
13
  }
11
14
 
12
15
  &-framework-center {
@@ -21,7 +21,7 @@
21
21
  color: #909399;
22
22
 
23
23
  &:hover {
24
- color: #409eff;
24
+ color: var(--el-color-primary, #409eff);
25
25
  }
26
26
  }
27
27
 
@@ -96,7 +96,7 @@
96
96
  // 故这里仅作用于「非合并组」的单步条目,避免与卡片样式互相干扰。
97
97
  &.is-current:not(.m-editor-history-list-group.is-merged) {
98
98
  background-color: rgba(64, 158, 255, 0.1);
99
- box-shadow: inset 2px 0 0 #409eff;
99
+ box-shadow: inset 2px 0 0 var(--el-color-primary, #409eff);
100
100
 
101
101
  &:hover {
102
102
  background-color: rgba(64, 158, 255, 0.16);
@@ -104,7 +104,7 @@
104
104
 
105
105
  .m-editor-history-list-item-desc {
106
106
  font-weight: 600;
107
- color: #409eff;
107
+ color: var(--el-color-primary, #409eff);
108
108
  }
109
109
  }
110
110
  }
@@ -177,11 +177,11 @@
177
177
  &.is-current {
178
178
  background-color: rgba(64, 158, 255, 0.08);
179
179
  border-color: rgba(64, 158, 255, 0.3);
180
- border-left-color: #409eff;
180
+ border-left-color: var(--el-color-primary, #409eff);
181
181
  box-shadow: none; // 覆盖 .is-current 公共的 inset 阴影
182
182
 
183
183
  .m-editor-history-list-group-head {
184
- color: #409eff;
184
+ color: var(--el-color-primary, #409eff);
185
185
  }
186
186
  }
187
187
  }
@@ -216,7 +216,7 @@
216
216
  }
217
217
 
218
218
  &.is-current {
219
- color: #409eff;
219
+ color: var(--el-color-primary, #409eff);
220
220
  font-weight: 600;
221
221
  background-color: rgba(64, 158, 255, 0.08);
222
222
  border-radius: 3px;
@@ -231,7 +231,7 @@
231
231
  font-size: 10px;
232
232
  line-height: 16px;
233
233
  color: #fff;
234
- background-color: #409eff;
234
+ background-color: var(--el-color-primary, #409eff);
235
235
  font-weight: 500;
236
236
  }
237
237
 
@@ -395,7 +395,7 @@
395
395
  border-radius: 2px;
396
396
  font-size: 10px;
397
397
  line-height: 16px;
398
- color: #409eff;
398
+ color: var(--el-color-primary, #409eff);
399
399
  background-color: rgba(64, 158, 255, 0.1);
400
400
  cursor: pointer;
401
401
  user-select: none;
@@ -471,7 +471,7 @@
471
471
  flex: 1 1 auto;
472
472
  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
473
473
  font-size: 11px;
474
- color: #409eff;
474
+ color: var(--el-color-primary, #409eff);
475
475
  overflow: hidden;
476
476
  text-overflow: ellipsis;
477
477
  white-space: nowrap;
@@ -13,7 +13,11 @@
13
13
  font-weight: 400;
14
14
  box-sizing: border-box;
15
15
  margin: 0px;
16
- flex: 0 0 $nav-height;
16
+ // CSS 变量做主题化开关:默认没设 `--editor-nav-height` 时回落到
17
+ // SCSS 变量 `$nav-height`(common/var.scss,35px);主题(如 magic-admin)
18
+ // 只需在祖先节点声明 `--editor-nav-height: 40px` 即可运行时覆盖,避免
19
+ // 走 `@use with` 那条对加载顺序极敏感的 SCSS 模块配置路径。
20
+ flex: 0 0 var(--editor-nav-height, #{$nav-height});
17
21
  border-bottom: 1px solid #d8dee8;
18
22
 
19
23
  > div {
@@ -129,7 +129,8 @@
129
129
  > .m-container-tab {
130
130
  > .tmagic-design-tabs {
131
131
  > .el-tabs__content {
132
- padding-top: 55px;
132
+ margin-top: var(--el-tabs-header-height);
133
+ padding-top: 15px;
133
134
  }
134
135
  > .el-tabs__header.is-top {
135
136
  position: absolute;
@@ -1,5 +1,6 @@
1
1
  .border-box-container {
2
2
  display: flex;
3
+ --unuse-border-style: dashed;
3
4
  .border-icon-container {
4
5
  display: flex;
5
6
  flex-direction: column;
@@ -28,24 +29,32 @@
28
29
  border-color: var(--el-color-success, var(--td-success-color, #2ba471));
29
30
  }
30
31
  &.active {
32
+ border-color: var(--el-color-primary);
33
+ border-width: 1px;
34
+ // border-color: var(--el-color-primary, var(--td-brand-color, #0052d9));
35
+ }
36
+ &.center {
31
37
  border-width: 1px;
32
- border-color: var(--el-color-primary, var(--td-brand-color, #0052d9));
33
38
  }
34
39
  &.border-icon-top {
35
40
  border-top-width: 2px;
36
- border-style: solid dashed dashed dashed;
41
+ border-style: solid var(--unuse-border-style) var(--unuse-border-style)
42
+ var(--unuse-border-style);
37
43
  }
38
44
  &.border-icon-right {
39
45
  border-right-width: 2px;
40
- border-style: dashed solid dashed dashed;
46
+ border-style: var(--unuse-border-style) solid var(--unuse-border-style)
47
+ var(--unuse-border-style);
41
48
  }
42
49
  &.border-icon-bottom {
43
50
  border-bottom-width: 2px;
44
- border-style: dashed dashed solid dashed;
51
+ border-style: var(--unuse-border-style) var(--unuse-border-style) solid
52
+ var(--unuse-border-style);
45
53
  }
46
54
  &.border-icon-left {
47
55
  border-left-width: 2px;
48
- border-style: dashed dashed dashed solid;
56
+ border-style: var(--unuse-border-style) var(--unuse-border-style)
57
+ var(--unuse-border-style) solid;
49
58
  }
50
59
  }
51
60
  }