@epxing/designer 5.3.0-beta.1 → 5.3.0-beta.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 (249) hide show
  1. package/API.md +5 -4
  2. package/README.md +46 -45
  3. package/dist/src/index.js +1 -0
  4. package/dist/src/page-designer/PageConfigPreview.js +1 -0
  5. package/dist/src/page-designer/PageDesigner.js +12 -0
  6. package/dist/src/page-designer/designer.js +22 -0
  7. package/dist/src/page-designer/index.js +1 -0
  8. package/dist/src/page-designer/mixins/dragSourceMixin.js +1 -0
  9. package/dist/src/page-designer/page-variable-panel/JsonEditor.js +1 -0
  10. package/dist/src/page-designer/page-variable-panel/PageVariablePanel.js +1 -0
  11. package/dist/src/page-designer/page-variable-panel/index.js +1 -0
  12. package/dist/src/page-designer/page-variable-panel/jsonlint.js +1 -0
  13. package/dist/src/page-designer/previews/add-form/Preview.js +2 -1
  14. package/dist/src/page-designer/previews/add-form/Preview.vue.js +19 -8
  15. package/dist/src/page-designer/previews/add-form-item/Preview.js +1 -0
  16. package/dist/src/page-designer/previews/button/Preview.js +1 -0
  17. package/dist/src/page-designer/previews/card/Preview.js +1 -0
  18. package/dist/src/page-designer/previews/carousel/CarouselItemPreview.js +1 -0
  19. package/dist/src/page-designer/previews/carousel/Preview.js +1 -0
  20. package/dist/src/page-designer/previews/collapse/CollapseItemPreview.js +1 -0
  21. package/dist/src/page-designer/previews/collapse/Preview.js +1 -0
  22. package/dist/src/page-designer/previews/dropdown/Preview.js +1 -0
  23. package/dist/src/page-designer/previews/entity-list/Preview.js +1 -0
  24. package/dist/src/page-designer/previews/entity-sub-list/Preview.js +1 -0
  25. package/dist/src/page-designer/previews/entity-virtual-list/Preview.js +1 -0
  26. package/dist/src/page-designer/previews/form-field/preview/Checkbox.js +1 -0
  27. package/dist/src/page-designer/previews/form-field/preview/Date.js +1 -0
  28. package/dist/src/page-designer/previews/form-field/preview/Input.js +1 -0
  29. package/dist/src/page-designer/previews/form-field/preview/InputNumber.js +1 -0
  30. package/dist/src/page-designer/previews/form-field/preview/Object.js +1 -0
  31. package/dist/src/page-designer/previews/form-field/preview/Radio.js +1 -0
  32. package/dist/src/page-designer/previews/form-field/preview/Select.js +1 -0
  33. package/dist/src/page-designer/previews/form-field/preview/Textarea.js +1 -0
  34. package/dist/src/page-designer/previews/grid/Preview.js +1 -0
  35. package/dist/src/page-designer/previews/html/Preview.js +1 -0
  36. package/dist/src/page-designer/previews/icon/Preview.js +1 -0
  37. package/dist/src/page-designer/previews/image/Preview.js +1 -0
  38. package/dist/src/page-designer/previews/index.js +1 -0
  39. package/dist/src/page-designer/previews/layout/ColumnPreview.js +1 -0
  40. package/dist/src/page-designer/previews/layout/Preview.js +1 -0
  41. package/dist/src/page-designer/previews/num/Preview.js +1 -0
  42. package/dist/src/page-designer/previews/page-tabs/Preview.js +1 -0
  43. package/dist/src/page-designer/previews/step/Preview.js +1 -0
  44. package/dist/src/page-designer/previews/tabs/Preview.js +1 -0
  45. package/dist/src/page-designer/previews/tabs/tab-pane/Preview.js +1 -0
  46. package/dist/src/page-designer/previews/text/Preview.js +1 -0
  47. package/dist/src/page-designer/previews/text-editor/Preview.js +1 -0
  48. package/dist/src/page-designer/previews/video/Preview.js +1 -0
  49. package/dist/src/page-designer/setting-panel/Advance.js +1 -0
  50. package/dist/src/page-designer/setting-panel/CodeEditor.js +1 -0
  51. package/dist/src/page-designer/setting-panel/Property.js +1 -0
  52. package/dist/src/page-designer/setting-panel/Setting.js +47 -10
  53. package/dist/src/page-designer/setting-panel/Style.js +1 -0
  54. package/dist/src/page-designer/setting-panel/css-editor/CssEditor.js +1 -0
  55. package/dist/src/page-designer/setting-panel/css-editor/css-hint.js +1 -0
  56. package/dist/src/page-designer/setting-panel/index.js +1 -0
  57. package/dist/src/page-designer/template-attribute-panel/TemplateAttributePanel.js +1 -0
  58. package/dist/src/page-designer/template-attribute-panel/index.js +1 -0
  59. package/dist/src/page-designer/template-library/Library.js +1 -0
  60. package/dist/src/page-designer/template-library/index.js +1 -0
  61. package/dist/src/page-designer/widget-library/Base.js +1 -0
  62. package/dist/src/page-designer/widget-library/Library.js +1 -0
  63. package/dist/src/page-designer/widget-library/index.js +1 -0
  64. package/dist/src/page-designer/widget-preview/Container.js +1 -0
  65. package/dist/src/page-designer/widget-preview/DragGhost.js +1 -0
  66. package/dist/src/page-designer/widget-preview/DropZoneOverlay.js +1 -0
  67. package/dist/src/page-designer/widget-preview/HoverOverlay.js +1 -0
  68. package/dist/src/page-designer/widget-preview/Mixin.js +1 -0
  69. package/dist/src/page-designer/widget-preview/Placeholder.js +1 -0
  70. package/dist/src/page-designer/widget-preview/Preview.js +1 -0
  71. package/dist/src/page-designer/widget-preview/PreviewItem.js +1 -0
  72. package/dist/src/page-designer/widget-preview/SelectedOverlay.js +1 -0
  73. package/dist/src/page-designer/widget-preview/Template.js +1 -0
  74. package/dist/src/page-designer/widget-preview/WidgetWrapper.js +1 -0
  75. package/dist/src/page-designer/widget-preview/directive.js +1 -0
  76. package/dist/src/page-designer/widget-preview/dropPosition.js +1 -0
  77. package/dist/src/page-designer/widget-preview/index.js +1 -0
  78. package/dist/src/page-designer/widget-preview/overlayPositionMixin.js +1 -0
  79. package/dist/src/page-designer/widget-preview/resolvePreviewName.js +1 -0
  80. package/dist/src/page-designer/widget-tree/Item.js +1 -0
  81. package/dist/src/page-designer/widget-tree/Tree.js +1 -0
  82. package/dist/src/page-designer/widget-tree/index.js +1 -0
  83. package/dist/src/visual/AddForm.js +1 -0
  84. package/dist/src/visual/AddFormItem.js +1 -0
  85. package/dist/src/visual/AppIndex.js +1 -0
  86. package/dist/src/visual/ApplyForm.js +1 -0
  87. package/dist/src/visual/AttributeList.js +1 -0
  88. package/dist/src/visual/BasePage.js +1 -0
  89. package/dist/src/visual/Button.js +1 -0
  90. package/dist/src/visual/CardNum.js +1 -0
  91. package/dist/src/visual/CategoryList.js +1 -0
  92. package/dist/src/visual/Chart.js +1 -0
  93. package/dist/src/visual/ChartNew.js +1 -0
  94. package/dist/src/visual/CheckForm.js +1 -0
  95. package/dist/src/visual/ClientList.js +1 -0
  96. package/dist/src/visual/CodeManage.js +1 -0
  97. package/dist/src/visual/Component.js +1 -0
  98. package/dist/src/visual/ComponentList.js +1 -0
  99. package/dist/src/visual/Config.js +1 -0
  100. package/dist/src/visual/ConfigItem.js +1 -0
  101. package/dist/src/visual/ConfigSelectItems.js +1 -0
  102. package/dist/src/visual/CreatePage.js +1 -0
  103. package/dist/src/visual/DashboardDiv.js +1 -0
  104. package/dist/src/visual/DashboardTabs.js +1 -0
  105. package/dist/src/visual/DashboardWidget.js +1 -0
  106. package/dist/src/visual/DblogList.js +1 -0
  107. package/dist/src/visual/EntityAddPage.js +1 -0
  108. package/dist/src/visual/EntityApplyPage.js +1 -0
  109. package/dist/src/visual/EntityCardList.js +1 -0
  110. package/dist/src/visual/EntityCheckPage.js +1 -0
  111. package/dist/src/visual/EntityFindPage.js +1 -0
  112. package/dist/src/visual/EntityList.js +1 -0
  113. package/dist/src/visual/EntityListPage.js +1 -0
  114. package/dist/src/visual/EntityNoSubmitSubList.js +1 -0
  115. package/dist/src/visual/EntityRightSubList.js +1 -0
  116. package/dist/src/visual/EntitySubAdd.js +1 -0
  117. package/dist/src/visual/EntitySubGridItem.js +1 -0
  118. package/dist/src/visual/EntitySubList.js +1 -0
  119. package/dist/src/visual/EntityTreeFindPage.js +1 -0
  120. package/dist/src/visual/EntityTreeManage.js +1 -0
  121. package/dist/src/visual/EntityTreePage.js +1 -0
  122. package/dist/src/visual/ExcelPreview.js +1 -0
  123. package/dist/src/visual/FormField.js +1 -0
  124. package/dist/src/visual/HeaderNew.js +1 -0
  125. package/dist/src/visual/Html.js +1 -0
  126. package/dist/src/visual/Import.js +1 -0
  127. package/dist/src/visual/InterfaceSubList.js +1 -0
  128. package/dist/src/visual/ListFirst.js +1 -0
  129. package/dist/src/visual/MEntityAddPage.js +1 -0
  130. package/dist/src/visual/MEntityList.js +1 -0
  131. package/dist/src/visual/MEntityListPage.js +1 -0
  132. package/dist/src/visual/MEntitySubList.js +1 -0
  133. package/dist/src/visual/MetaList.js +1 -0
  134. package/dist/src/visual/ModuleIndexPage.js +1 -0
  135. package/dist/src/visual/ModuleList.js +1 -0
  136. package/dist/src/visual/NavAddForm.js +1 -0
  137. package/dist/src/visual/NavFormCatalogItem.js +1 -0
  138. package/dist/src/visual/NumItem.js +1 -0
  139. package/dist/src/visual/NumStatistic.js +1 -0
  140. package/dist/src/visual/OrgChart.js +1 -0
  141. package/dist/src/visual/PageCatalog.js +1 -0
  142. package/dist/src/visual/PageConfig.js +1 -0
  143. package/dist/src/visual/PageTabs.js +1 -0
  144. package/dist/src/visual/Progress.js +1 -0
  145. package/dist/src/visual/ProgressItem.js +1 -0
  146. package/dist/src/visual/SystemManager.js +1 -0
  147. package/dist/src/visual/Title.js +1 -0
  148. package/dist/src/visual/TodoList.js +1 -0
  149. package/dist/src/visual/UserFormItem.js +1 -0
  150. package/dist/src/visual/UserManage.js +1 -0
  151. package/dist/src/visual/chart/CircularPie.js +1 -0
  152. package/dist/src/visual/chart/Column.js +1 -0
  153. package/dist/src/visual/chart/HoriColumn.js +1 -0
  154. package/dist/src/visual/chart/Line.js +1 -0
  155. package/dist/src/visual/chart/Pie.js +1 -0
  156. package/dist/src/visual/config/Background.js +1 -0
  157. package/dist/src/visual/config/Chart.js +1 -0
  158. package/dist/src/visual/config/Checkbox.js +1 -0
  159. package/dist/src/visual/config/Color.js +1 -0
  160. package/dist/src/visual/config/DesignReport.js +1 -0
  161. package/dist/src/visual/config/Event.js +1 -0
  162. package/dist/src/visual/config/Field.js +1 -0
  163. package/dist/src/visual/config/Font.js +1 -0
  164. package/dist/src/visual/config/FormItem.js +1 -0
  165. package/dist/src/visual/config/Function.js +1 -0
  166. package/dist/src/visual/config/Html.js +1 -0
  167. package/dist/src/visual/config/Image.js +1 -0
  168. package/dist/src/visual/config/Input.js +1 -0
  169. package/dist/src/visual/config/LazyDialog.js +1 -0
  170. package/dist/src/visual/config/List.js +1 -0
  171. package/dist/src/visual/config/ListField.js +1 -0
  172. package/dist/src/visual/config/MField.js +1 -0
  173. package/dist/src/visual/config/Number.js +1 -0
  174. package/dist/src/visual/config/Object.js +1 -0
  175. package/dist/src/visual/config/Operate.js +1 -0
  176. package/dist/src/visual/config/OperateItem.js +1 -0
  177. package/dist/src/visual/config/Options.js +1 -0
  178. package/dist/src/visual/config/OrderField.js +1 -0
  179. package/dist/src/visual/config/Page.js +1 -0
  180. package/dist/src/visual/config/Params.js +1 -0
  181. package/dist/src/visual/config/Radio.js +1 -0
  182. package/dist/src/visual/config/Row.js +1 -0
  183. package/dist/src/visual/config/Scope.js +1 -0
  184. package/dist/src/visual/config/Select.js +1 -0
  185. package/dist/src/visual/config/Switch.js +1 -0
  186. package/dist/src/visual/config/Textarea.js +1 -0
  187. package/dist/src/visual/config/Tree.js +1 -0
  188. package/dist/src/visual/config/remote-cache.js +1 -0
  189. package/dist/src/visual/config/show-condition.js +1 -0
  190. package/dist/src/visual/config/variable-sources.js +1 -0
  191. package/dist/src/visual/config/wait-ref.js +1 -0
  192. package/dist/src/visual/config-page/ComponentLibrary.js +1 -0
  193. package/dist/src/visual/config-page/ComponentLibraryDialog.js +9 -2
  194. package/dist/src/visual/config-page/ComponentList.js +1 -0
  195. package/dist/src/visual/config-page/ComponentPreview.js +1 -0
  196. package/dist/src/visual/config-page/ConfigOption.js +1 -0
  197. package/dist/src/visual/config-page/ConfigPanel.js +1 -0
  198. package/dist/src/visual/config-page/Dashboard.js +1 -0
  199. package/dist/src/visual/config-page/DashboardDesign.js +1 -0
  200. package/dist/src/visual/config-page/DashboardGlobalConfig.js +1 -0
  201. package/dist/src/visual/config-page/DashboardMobile.js +2 -1
  202. package/dist/src/visual/config-page/DashboardSetting.js +1 -0
  203. package/dist/src/visual/config-page/PagePreview.js +1 -0
  204. package/dist/src/visual/config-page/StyleConfig.js +1 -0
  205. package/dist/src/visual/config-page/VisualConfigPage.js +1 -0
  206. package/dist/src/visual/config-page/dashboard-theme-setting/Background.js +1 -0
  207. package/dist/src/visual/config-page/dashboard-theme-setting/Border.js +1 -0
  208. package/dist/src/visual/config-page/dashboard-theme-setting/Font.js +1 -0
  209. package/dist/src/visual/config-page/dashboard-theme-setting/Index.js +1 -0
  210. package/dist/src/visual/config-page/dashboard-theme-setting/Shadow.js +1 -0
  211. package/dist/src/visual/config-page/index.js +1 -0
  212. package/dist/src/visual/index.js +1 -0
  213. package/dist/src/visual/mixins/innerGridMixin.js +1 -0
  214. package/dist/src/visual/search/Filter.js +1 -0
  215. package/dist/src/visual/step/Index.js +1 -0
  216. package/dist/src/visual/step/Item.js +1 -0
  217. package/dist/src/visual/widgets/CardFormItemVisual.js +1 -0
  218. package/dist/src/visual/widgets/CarouselVisual.js +1 -0
  219. package/dist/src/visual/widgets/CollapseVisual.js +1 -0
  220. package/dist/src/visual/widgets/DropdownVisual.js +1 -0
  221. package/dist/src/visual/widgets/LayoutConfig.js +1 -0
  222. package/dist/src/visual/widgets/ListVisual.js +1 -0
  223. package/dist/src/visual/widgets/MEntityListFindVisual.js +1 -0
  224. package/dist/src/visual/widgets/ProcessFormItemVisual.js +1 -0
  225. package/dist/src/visual/widgets/TabsConfig.js +1 -0
  226. package/dist/style.css +116 -112
  227. package/package.json +10 -9
  228. package/src/index.js +27 -27
  229. package/src/page-designer/PageDesigner.vue +11 -0
  230. package/src/page-designer/designer.js +1322 -1299
  231. package/src/page-designer/previews/add-form/Preview.vue +43 -44
  232. package/src/page-designer/setting-panel/Setting.vue +24 -2
  233. package/src/page-designer/widget-preview/Mixin.js +285 -285
  234. package/src/page-designer/widget-preview/Preview.vue +322 -322
  235. package/src/page-designer/widget-preview/WidgetWrapper.vue +197 -197
  236. package/src/page-designer/widget-preview/directive.js +258 -258
  237. package/src/visual/CategoryList.vue +563 -563
  238. package/src/visual/ComponentList.vue +280 -280
  239. package/src/visual/CreatePage.vue +389 -389
  240. package/src/visual/EntityCardList.vue +449 -449
  241. package/src/visual/EntityList.vue +838 -838
  242. package/src/visual/config-page/ComponentLibraryDialog.vue +7 -1
  243. package/src/visual/config-page/DashboardMobile.vue +934 -934
  244. package/src/visual/widgets/ProcessFormItemVisual.vue +58 -58
  245. package/types/index.d.ts +22 -22
  246. package/types/page-designer.d.ts +3 -3
  247. package/types/visual-component.d.ts +1 -1
  248. package/types/visual-entity-list.d.ts +1 -1
  249. package/types/visual-entity-sub-list.d.ts +1 -1
@@ -1,285 +1,285 @@
1
- import PreviewItem from './PreviewItem.vue'
2
- import util from '@epxing/core/src/runtime-utils/util'
3
- import { createDropCache, clearDropCache, insertIndex, insertLineRect } from './dropPosition'
4
- function appendCss (id, css) {
5
- const formatCss = css.replace(/:current/g, '.css_' + id).replace(/url\s*\(([\w+-/.\s]+)\)/g, (str, $1) => {
6
- return `url(${util.getFileUrl($1)})`
7
- })
8
- const element = document.getElementById('style_' + id)
9
- if (element) {
10
- element.textContent = formatCss
11
- } else {
12
- const style = document.createElement('style')
13
- style.id = 'style_' + id
14
- style.textContent = formatCss
15
-
16
- style.setAttribute('type', 'text/css')
17
- document.head.appendChild(style)
18
- }
19
- }
20
- function removeCss (id) {
21
- const element = document.getElementById('style_' + id)
22
- if (element) document.head.removeChild(element)
23
- }
24
-
25
- export default {
26
- props: {
27
- designer: {
28
- type: Object
29
- },
30
- widget: {
31
- type: Object
32
- },
33
- pageRelationList: {
34
- type: Array
35
- },
36
- templateInfo: {
37
- type: Object
38
- }
39
- },
40
- data () {
41
- return {
42
- }
43
- },
44
- components: {
45
- 'widget-preview': PreviewItem
46
- },
47
- computed: {
48
- $isMobile () {
49
- return this.designer.terminal === 'mobile' ? true : this.$store.state.config.isMobile
50
- },
51
- selectedWidget () {
52
- return this.designer.selectedWidget
53
- },
54
- widgetInfo () {
55
- return this.designer.getWidgetByType(this.widget.contentType) || {}
56
- },
57
- childWidgetList: {
58
- get () {
59
- return this.widget.items || []
60
- },
61
- set (v) {
62
- this.designer.updateWidget(this.widget.id, { items: v })
63
- }
64
- },
65
- style () {
66
- const { style = {} } = this.widget
67
- const _style = { ...style }
68
- if (this.$configs.height && !style.height) {
69
- const height = this.$configs.height.includes('%') ? this.$configs.height : this.$configs.height + 'px'
70
- _style.height = height
71
- }
72
- if (_style.backgroundImage) {
73
- _style.backgroundImage = _style.backgroundImage.replace(/url\s*\(([\w+-/.\s]+)\)/g, (str, $1) => {
74
- return `url(${util.getFileUrl($1)})`
75
- })
76
- }
77
- return _style
78
- },
79
- widgetStyle () {
80
- const { style = {} } = this.widget
81
- return style
82
- },
83
- $configs () {
84
- const { id, configs = {} } = this.widget
85
- if (this.templateInfo) {
86
- // 获取当前组件的配置 获取模板的配置
87
- const templateConfig = this.designer.widgetConfig[this.templateInfo.id] || {}
88
- const { itemConfigs } = this.templateInfo.content
89
- const _configs = { ...configs, ...(itemConfigs[id] || {}) }
90
- for (const key in _configs) {
91
- const item = _configs[key]
92
- if (typeof item === 'string') {
93
- _configs[key] = item.replace(/@\[([\w-.|$#]+)\]/g, (macth, key) => templateConfig[key] || '')
94
- .replace(/\{\{([\w-.|$#]+)\}\}/g, (macth, key) => `⌊${key}⌉`)
95
- .replace(/\$\[([\w-.|$#]+)\]/g, (macth, key) => `⌊${key}⌉`)
96
- }
97
- }
98
- return _configs
99
- } else {
100
- const widgetConfig = this.designer.widgetConfig[id] || {}
101
- // 将变量转为⌊⌉『』
102
- const allConfigs = { ...widgetConfig, ...configs }
103
- const _configs = {}
104
- for (const key in allConfigs) {
105
- const item = allConfigs[key]
106
- if (typeof item === 'string') {
107
- _configs[key] = item.replace(/\{\{([\w-.|$#]+)\}\}/g, (macth, key) => `⌊${key}⌉`).replace(/\$\[([\w-.|$#]+)\]/g, (macth, key) => `⌊${key}⌉`)
108
- } else {
109
- _configs[key] = item
110
- }
111
- }
112
- return _configs
113
- }
114
- },
115
- $metaId () {
116
- const { metaId } = this.$configs
117
- return metaId || this.designer.page.metaId
118
- }
119
- },
120
- watch: {
121
- 'widget.css' (v) {
122
- appendCss(this.widget.id, this.widget.css)
123
- }
124
- },
125
- mounted () {
126
- if (this.widget.css) {
127
- appendCss(this.widget.id, this.widget.css)
128
- }
129
- if (this.$el) {
130
- if (this.$el.classList) {
131
- this.$el.classList.add('css_' + this.widget.id)
132
- } else {
133
- this.$el.className += ' css_' + this.widget.id
134
- }
135
- }
136
-
137
- // 自动为容器组件绑定拖拽事件
138
- const isContainer = this.widgetInfo.CONTAINER === '1' || (this.widget.items !== undefined)
139
- if (isContainer && this.$el) {
140
- // 保存事件处理器引用,用于销毁时移除
141
- this._dragEnterHandler = this.onContainerDragEnter.bind(this)
142
- this._dragOverHandler = (e) => {
143
- e.preventDefault()
144
- this.onContainerDragOver(e)
145
- }
146
- this._dragLeaveHandler = this.onContainerDragLeave.bind(this)
147
- this._dropHandler = (e) => {
148
- e.preventDefault()
149
- e.stopPropagation() // 阻止事件继续冒泡到父容器
150
- this.onContainerDrop(e)
151
- }
152
-
153
- // 使用 capture 阶段捕获事件,优先于子元素处理
154
- this.$el.addEventListener('dragenter', this._dragEnterHandler, false)
155
- this.$el.addEventListener('dragover', this._dragOverHandler, false)
156
- this.$el.addEventListener('dragleave', this._dragLeaveHandler, false)
157
- this.$el.addEventListener('drop', this._dropHandler, false)
158
- }
159
- },
160
- unmounted () {
161
- removeCss(this.widget.id)
162
-
163
- // 清除可能存在的离开定时器
164
- if (this._dragLeaveTimer) {
165
- clearTimeout(this._dragLeaveTimer)
166
- this._dragLeaveTimer = null
167
- }
168
- if (this._dragFrame) {
169
- cancelAnimationFrame(this._dragFrame)
170
- this._dragFrame = null
171
- }
172
-
173
- // 移除拖拽事件监听
174
- if (this._dragEnterHandler && this.$el) {
175
- this.$el.removeEventListener('dragenter', this._dragEnterHandler)
176
- this.$el.removeEventListener('dragover', this._dragOverHandler)
177
- this.$el.removeEventListener('dragleave', this._dragLeaveHandler)
178
- this.$el.removeEventListener('drop', this._dropHandler)
179
- }
180
- },
181
- methods: {
182
- // ========== 容器拖拽通用方法 ==========
183
- // 判断是否是从组件库或模板库拖拽
184
- isDraggingFromLibrary (e) {
185
- const hasData = e.dataTransfer && e.dataTransfer.types && e.dataTransfer.types.includes('text/plain')
186
- if (!hasData) return false
187
-
188
- // 尝试获取数据判断类型(注意:在 dragover 中无法获取数据,只能在 drop 中获取)
189
- // 所以这里只能做基本判断
190
- return true
191
- },
192
-
193
- // 是否在拖画布上已有的组件(否则是组件库 / 模板库):读拖拽状态,不再每次 querySelector
194
- isDraggingWidget () {
195
- return this.designer.dragState.dragSource === 'preview'
196
- },
197
-
198
- // 是否容器组件:有 CONTAINER 标记或有 items
199
- isContainerWidget () {
200
- return this.widgetInfo.CONTAINER === '1' || (this.widget.items !== undefined)
201
- },
202
-
203
- // 容器拖拽进入:重新测量一次 children,之后的 dragover 复用缓存
204
- onContainerDragEnter (e) {
205
- if (!this.isContainerWidget() || !this.isDraggingFromLibrary(e)) return
206
- e.preventDefault()
207
- e.stopPropagation()
208
- if (this._dragLeaveTimer) {
209
- clearTimeout(this._dragLeaveTimer)
210
- this._dragLeaveTimer = null
211
- }
212
- if (!this._dropCache) this._dropCache = createDropCache()
213
- clearDropCache(this._dropCache)
214
- this.designer.setDragOverTarget({ type: 'container', widgetId: this.widget.id })
215
- this.designer.setDragOverTargetElement(this.$el)
216
- this.designer.setPreviewDragTarget({ widgetId: this.widget.id, position: 'inside' })
217
- },
218
-
219
- // 容器拖拽悬停:只记坐标 + 允许放置;插入位置的计算与状态更新合并到下一帧
220
- onContainerDragOver (e) {
221
- if (!this.isContainerWidget() || !this.isDraggingFromLibrary(e)) return
222
- e.preventDefault()
223
- e.stopPropagation()
224
- e.dataTransfer.dropEffect = this.isDraggingWidget() ? 'move' : 'copy'
225
- this._dragClientX = e.clientX
226
- this._dragClientY = e.clientY
227
- this.scheduleDragFrame()
228
- },
229
-
230
- scheduleDragFrame () {
231
- if (this._dragFrame) return
232
- this._dragFrame = requestAnimationFrame(() => {
233
- this._dragFrame = null
234
- if (this._dragClientY === undefined || !this.designer.dragState.isDragging) return
235
- // 事件被 stopPropagation 后到不了 document,悬浮窗位置在这里更新
236
- this.designer.updateDragGhostPosition(this._dragClientX, this._dragClientY)
237
- // 列表元素(子类可以覆盖 getDropListElement 方法自定义)
238
- const listEl = this.getDropListElement ? this.getDropListElement() : this.$el
239
- if (!this._dropCache) this._dropCache = createDropCache()
240
- const lineRect = insertLineRect(this._dropCache, listEl, this._dragClientY)
241
- if (lineRect) this.designer.setDragInsertLine(lineRect)
242
- this.designer.setPreviewDragTarget({ widgetId: this.widget.id, index: insertIndex(this._dropCache, listEl, this._dragClientY), position: 'inside' })
243
- })
244
- },
245
-
246
- // 容器拖拽离开:relatedTarget 为空(离开窗口)或不在当前元素内才算真正离开
247
- onContainerDragLeave (e) {
248
- if (!this.isContainerWidget()) return
249
- const relatedTarget = e.relatedTarget
250
- if (!relatedTarget || !this.$el.contains(relatedTarget)) {
251
- // 小延迟避免在子元素之间快速移动时误判
252
- if (this._dragLeaveTimer) clearTimeout(this._dragLeaveTimer)
253
- this._dragLeaveTimer = setTimeout(() => {
254
- if (this.designer.dragOverTarget?.widgetId === this.widget.id) {
255
- this.designer.clearDragOverTarget()
256
- this.designer.clearDragInsertLine()
257
- this.designer.clearPreviewDragTarget()
258
- }
259
- if (this._dropCache) clearDropCache(this._dropCache)
260
- this._dragLeaveTimer = null
261
- }, 30)
262
- }
263
- },
264
-
265
- // 容器放置
266
- onContainerDrop (e) {
267
- if (!this.isContainerWidget()) return
268
- e.preventDefault()
269
- e.stopPropagation()
270
- if (this._dragLeaveTimer) {
271
- clearTimeout(this._dragLeaveTimer)
272
- this._dragLeaveTimer = null
273
- }
274
- this.designer.clearDragOverTarget()
275
- this.designer.clearDragInsertLine()
276
- this.designer.clearPreviewDragTarget()
277
- const listEl = this.getDropListElement ? this.getDropListElement() : this.$el
278
- if (!this._dropCache) this._dropCache = createDropCache()
279
- const index = insertIndex(this._dropCache, listEl, e.clientY)
280
- clearDropCache(this._dropCache)
281
- // 使用 designer 的统一拖拽处理方法;不在这里发 drag-end,让 dragend 事件自然触发
282
- this.designer.handleDrop({ dataTransfer: e.dataTransfer, target: { type: 'container', widgetId: this.widget.id, index } })
283
- }
284
- }
285
- }
1
+ import PreviewItem from './PreviewItem.vue'
2
+ import util from '@epxing/core/src/runtime-utils/util'
3
+ import { createDropCache, clearDropCache, insertIndex, insertLineRect } from './dropPosition'
4
+ function appendCss (id, css) {
5
+ const formatCss = css.replace(/:current/g, '.css_' + id).replace(/url\s*\(([\w+-/.\s]+)\)/g, (str, $1) => {
6
+ return `url(${util.getFileUrl($1)})`
7
+ })
8
+ const element = document.getElementById('style_' + id)
9
+ if (element) {
10
+ element.textContent = formatCss
11
+ } else {
12
+ const style = document.createElement('style')
13
+ style.id = 'style_' + id
14
+ style.textContent = formatCss
15
+
16
+ style.setAttribute('type', 'text/css')
17
+ document.head.appendChild(style)
18
+ }
19
+ }
20
+ function removeCss (id) {
21
+ const element = document.getElementById('style_' + id)
22
+ if (element) document.head.removeChild(element)
23
+ }
24
+
25
+ export default {
26
+ props: {
27
+ designer: {
28
+ type: Object
29
+ },
30
+ widget: {
31
+ type: Object
32
+ },
33
+ pageRelationList: {
34
+ type: Array
35
+ },
36
+ templateInfo: {
37
+ type: Object
38
+ }
39
+ },
40
+ data () {
41
+ return {
42
+ }
43
+ },
44
+ components: {
45
+ 'widget-preview': PreviewItem
46
+ },
47
+ computed: {
48
+ $isMobile () {
49
+ return this.designer.terminal === 'mobile' ? true : this.$store.state.config.isMobile
50
+ },
51
+ selectedWidget () {
52
+ return this.designer.selectedWidget
53
+ },
54
+ widgetInfo () {
55
+ return this.designer.getWidgetByType(this.widget.contentType) || {}
56
+ },
57
+ childWidgetList: {
58
+ get () {
59
+ return this.widget.items || []
60
+ },
61
+ set (v) {
62
+ this.designer.updateWidget(this.widget.id, { items: v })
63
+ }
64
+ },
65
+ style () {
66
+ const { style = {} } = this.widget
67
+ const _style = { ...style }
68
+ if (this.$configs.height && !style.height) {
69
+ const height = this.$configs.height.includes('%') ? this.$configs.height : this.$configs.height + 'px'
70
+ _style.height = height
71
+ }
72
+ if (_style.backgroundImage) {
73
+ _style.backgroundImage = _style.backgroundImage.replace(/url\s*\(([\w+-/.\s]+)\)/g, (str, $1) => {
74
+ return `url(${util.getFileUrl($1)})`
75
+ })
76
+ }
77
+ return _style
78
+ },
79
+ widgetStyle () {
80
+ const { style = {} } = this.widget
81
+ return style
82
+ },
83
+ $configs () {
84
+ const { id, configs = {} } = this.widget
85
+ if (this.templateInfo) {
86
+ // 获取当前组件的配置 获取模板的配置
87
+ const templateConfig = this.designer.widgetConfig[this.templateInfo.id] || {}
88
+ const { itemConfigs } = this.templateInfo.content
89
+ const _configs = { ...configs, ...(itemConfigs[id] || {}) }
90
+ for (const key in _configs) {
91
+ const item = _configs[key]
92
+ if (typeof item === 'string') {
93
+ _configs[key] = item.replace(/@\[([\w-.|$#]+)\]/g, (macth, key) => templateConfig[key] || '')
94
+ .replace(/\{\{([\w-.|$#]+)\}\}/g, (macth, key) => `⌊${key}⌉`)
95
+ .replace(/\$\[([\w-.|$#]+)\]/g, (macth, key) => `⌊${key}⌉`)
96
+ }
97
+ }
98
+ return _configs
99
+ } else {
100
+ const widgetConfig = this.designer.widgetConfig[id] || {}
101
+ // 将变量转为⌊⌉『』
102
+ const allConfigs = { ...widgetConfig, ...configs }
103
+ const _configs = {}
104
+ for (const key in allConfigs) {
105
+ const item = allConfigs[key]
106
+ if (typeof item === 'string') {
107
+ _configs[key] = item.replace(/\{\{([\w-.|$#]+)\}\}/g, (macth, key) => `⌊${key}⌉`).replace(/\$\[([\w-.|$#]+)\]/g, (macth, key) => `⌊${key}⌉`)
108
+ } else {
109
+ _configs[key] = item
110
+ }
111
+ }
112
+ return _configs
113
+ }
114
+ },
115
+ $metaId () {
116
+ const { metaId } = this.$configs
117
+ return metaId || this.designer.page.metaId
118
+ }
119
+ },
120
+ watch: {
121
+ 'widget.css' (v) {
122
+ appendCss(this.widget.id, this.widget.css)
123
+ }
124
+ },
125
+ mounted () {
126
+ if (this.widget.css) {
127
+ appendCss(this.widget.id, this.widget.css)
128
+ }
129
+ if (this.$el) {
130
+ if (this.$el.classList) {
131
+ this.$el.classList.add('css_' + this.widget.id)
132
+ } else {
133
+ this.$el.className += ' css_' + this.widget.id
134
+ }
135
+ }
136
+
137
+ // 自动为容器组件绑定拖拽事件
138
+ const isContainer = this.widgetInfo.CONTAINER === '1' || (this.widget.items !== undefined)
139
+ if (isContainer && this.$el) {
140
+ // 保存事件处理器引用,用于销毁时移除
141
+ this._dragEnterHandler = this.onContainerDragEnter.bind(this)
142
+ this._dragOverHandler = (e) => {
143
+ e.preventDefault()
144
+ this.onContainerDragOver(e)
145
+ }
146
+ this._dragLeaveHandler = this.onContainerDragLeave.bind(this)
147
+ this._dropHandler = (e) => {
148
+ e.preventDefault()
149
+ e.stopPropagation() // 阻止事件继续冒泡到父容器
150
+ this.onContainerDrop(e)
151
+ }
152
+
153
+ // 使用 capture 阶段捕获事件,优先于子元素处理
154
+ this.$el.addEventListener('dragenter', this._dragEnterHandler, false)
155
+ this.$el.addEventListener('dragover', this._dragOverHandler, false)
156
+ this.$el.addEventListener('dragleave', this._dragLeaveHandler, false)
157
+ this.$el.addEventListener('drop', this._dropHandler, false)
158
+ }
159
+ },
160
+ unmounted () {
161
+ removeCss(this.widget.id)
162
+
163
+ // 清除可能存在的离开定时器
164
+ if (this._dragLeaveTimer) {
165
+ clearTimeout(this._dragLeaveTimer)
166
+ this._dragLeaveTimer = null
167
+ }
168
+ if (this._dragFrame) {
169
+ cancelAnimationFrame(this._dragFrame)
170
+ this._dragFrame = null
171
+ }
172
+
173
+ // 移除拖拽事件监听
174
+ if (this._dragEnterHandler && this.$el) {
175
+ this.$el.removeEventListener('dragenter', this._dragEnterHandler)
176
+ this.$el.removeEventListener('dragover', this._dragOverHandler)
177
+ this.$el.removeEventListener('dragleave', this._dragLeaveHandler)
178
+ this.$el.removeEventListener('drop', this._dropHandler)
179
+ }
180
+ },
181
+ methods: {
182
+ // ========== 容器拖拽通用方法 ==========
183
+ // 判断是否是从组件库或模板库拖拽
184
+ isDraggingFromLibrary (e) {
185
+ const hasData = e.dataTransfer && e.dataTransfer.types && e.dataTransfer.types.includes('text/plain')
186
+ if (!hasData) return false
187
+
188
+ // 尝试获取数据判断类型(注意:在 dragover 中无法获取数据,只能在 drop 中获取)
189
+ // 所以这里只能做基本判断
190
+ return true
191
+ },
192
+
193
+ // 是否在拖画布上已有的组件(否则是组件库 / 模板库):读拖拽状态,不再每次 querySelector
194
+ isDraggingWidget () {
195
+ return this.designer.dragState.dragSource === 'preview'
196
+ },
197
+
198
+ // 是否容器组件:有 CONTAINER 标记或有 items
199
+ isContainerWidget () {
200
+ return this.widgetInfo.CONTAINER === '1' || (this.widget.items !== undefined)
201
+ },
202
+
203
+ // 容器拖拽进入:重新测量一次 children,之后的 dragover 复用缓存
204
+ onContainerDragEnter (e) {
205
+ if (!this.isContainerWidget() || !this.isDraggingFromLibrary(e)) return
206
+ e.preventDefault()
207
+ e.stopPropagation()
208
+ if (this._dragLeaveTimer) {
209
+ clearTimeout(this._dragLeaveTimer)
210
+ this._dragLeaveTimer = null
211
+ }
212
+ if (!this._dropCache) this._dropCache = createDropCache()
213
+ clearDropCache(this._dropCache)
214
+ this.designer.setDragOverTarget({ type: 'container', widgetId: this.widget.id })
215
+ this.designer.setDragOverTargetElement(this.$el)
216
+ this.designer.setPreviewDragTarget({ widgetId: this.widget.id, position: 'inside' })
217
+ },
218
+
219
+ // 容器拖拽悬停:只记坐标 + 允许放置;插入位置的计算与状态更新合并到下一帧
220
+ onContainerDragOver (e) {
221
+ if (!this.isContainerWidget() || !this.isDraggingFromLibrary(e)) return
222
+ e.preventDefault()
223
+ e.stopPropagation()
224
+ e.dataTransfer.dropEffect = this.isDraggingWidget() ? 'move' : 'copy'
225
+ this._dragClientX = e.clientX
226
+ this._dragClientY = e.clientY
227
+ this.scheduleDragFrame()
228
+ },
229
+
230
+ scheduleDragFrame () {
231
+ if (this._dragFrame) return
232
+ this._dragFrame = requestAnimationFrame(() => {
233
+ this._dragFrame = null
234
+ if (this._dragClientY === undefined || !this.designer.dragState.isDragging) return
235
+ // 事件被 stopPropagation 后到不了 document,悬浮窗位置在这里更新
236
+ this.designer.updateDragGhostPosition(this._dragClientX, this._dragClientY)
237
+ // 列表元素(子类可以覆盖 getDropListElement 方法自定义)
238
+ const listEl = this.getDropListElement ? this.getDropListElement() : this.$el
239
+ if (!this._dropCache) this._dropCache = createDropCache()
240
+ const lineRect = insertLineRect(this._dropCache, listEl, this._dragClientY)
241
+ if (lineRect) this.designer.setDragInsertLine(lineRect)
242
+ this.designer.setPreviewDragTarget({ widgetId: this.widget.id, index: insertIndex(this._dropCache, listEl, this._dragClientY), position: 'inside' })
243
+ })
244
+ },
245
+
246
+ // 容器拖拽离开:relatedTarget 为空(离开窗口)或不在当前元素内才算真正离开
247
+ onContainerDragLeave (e) {
248
+ if (!this.isContainerWidget()) return
249
+ const relatedTarget = e.relatedTarget
250
+ if (!relatedTarget || !this.$el.contains(relatedTarget)) {
251
+ // 小延迟避免在子元素之间快速移动时误判
252
+ if (this._dragLeaveTimer) clearTimeout(this._dragLeaveTimer)
253
+ this._dragLeaveTimer = setTimeout(() => {
254
+ if (this.designer.dragOverTarget?.widgetId === this.widget.id) {
255
+ this.designer.clearDragOverTarget()
256
+ this.designer.clearDragInsertLine()
257
+ this.designer.clearPreviewDragTarget()
258
+ }
259
+ if (this._dropCache) clearDropCache(this._dropCache)
260
+ this._dragLeaveTimer = null
261
+ }, 30)
262
+ }
263
+ },
264
+
265
+ // 容器放置
266
+ onContainerDrop (e) {
267
+ if (!this.isContainerWidget()) return
268
+ e.preventDefault()
269
+ e.stopPropagation()
270
+ if (this._dragLeaveTimer) {
271
+ clearTimeout(this._dragLeaveTimer)
272
+ this._dragLeaveTimer = null
273
+ }
274
+ this.designer.clearDragOverTarget()
275
+ this.designer.clearDragInsertLine()
276
+ this.designer.clearPreviewDragTarget()
277
+ const listEl = this.getDropListElement ? this.getDropListElement() : this.$el
278
+ if (!this._dropCache) this._dropCache = createDropCache()
279
+ const index = insertIndex(this._dropCache, listEl, e.clientY)
280
+ clearDropCache(this._dropCache)
281
+ // 使用 designer 的统一拖拽处理方法;不在这里发 drag-end,让 dragend 事件自然触发
282
+ this.designer.handleDrop({ dataTransfer: e.dataTransfer, target: { type: 'container', widgetId: this.widget.id, index } })
283
+ }
284
+ }
285
+ }