Commit 0208a797483daebcb36c131dcdc3f8f5df092342

Authored by ly525
1 parent 73ff900d

fix: set z-index for element

front-end/h5/src/components/core/models/element.js
@@ -4,7 +4,7 @@ import { parsePx } from '../../../utils/element.js' @@ -4,7 +4,7 @@ import { parsePx } from '../../../utils/element.js'
4 const disabledPluginsForEditMode = ['lbp-form-input', 'lbp-form-button'] 4 const disabledPluginsForEditMode = ['lbp-form-input', 'lbp-form-button']
5 const clone = (value) => JSON.parse(JSON.stringify(value)) 5 const clone = (value) => JSON.parse(JSON.stringify(value))
6 6
7 -const defaultProps = { 7 +const defaultStyle = {
8 top: 100, 8 top: 100,
9 left: 100, 9 left: 100,
10 width: 100, 10 width: 100,
@@ -19,7 +19,7 @@ const defaultProps = { @@ -19,7 +19,7 @@ const defaultProps = {
19 class Element { 19 class Element {
20 constructor (ele) { 20 constructor (ele) {
21 this.name = ele.name 21 this.name = ele.name
22 - this.uuid = +new Date() 22 + this.uuid = ele.uuid || +new Date()
23 /** 23 /**
24 * #!zh: 24 * #!zh:
25 * 之前版本代码:https://github.com/ly525/luban-h5/blob/a7875cbc73c0d18bc2459985ca3ce1d4dc44f141/front-end/h5/src/components/core/models/element.js#L21 25 * 之前版本代码:https://github.com/ly525/luban-h5/blob/a7875cbc73c0d18bc2459985ca3ce1d4dc44f141/front-end/h5/src/components/core/models/element.js#L21
@@ -32,19 +32,10 @@ class Element { @@ -32,19 +32,10 @@ class Element {
32 * element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误 32 * element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误
33 */ 33 */
34 this.pluginProps = (typeof ele.pluginProps === 'object' && clone(ele.pluginProps)) || this.getDefaultPluginProps(ele.editorConfig || {}) 34 this.pluginProps = (typeof ele.pluginProps === 'object' && clone(ele.pluginProps)) || this.getDefaultPluginProps(ele.editorConfig || {})
35 - const commonStyle = (typeof ele.commonStyle === 'object' && clone(ele.commonStyle)) || this.getDefaultCommonStyle()  
36 - this.commonStyle = {  
37 - ...commonStyle,  
38 - zindex: ele.zindex  
39 - }  
40 - 35 + this.commonStyle = (typeof ele.commonStyle === 'object' && clone(ele.commonStyle)) || { ...defaultStyle }
41 this.events = [] 36 this.events = []
42 } 37 }
43 38
44 - getDefaultCommonStyle () {  
45 - return { ...defaultProps }  
46 - }  
47 -  
48 getDefaultPluginProps (editorConfig) { 39 getDefaultPluginProps (editorConfig) {
49 // init prop of plugin 40 // init prop of plugin
50 const propConf = editorConfig.propsConfig 41 const propConf = editorConfig.propsConfig
@@ -72,6 +63,7 @@ class Element { @@ -72,6 +63,7 @@ class Element {
72 color: pluginProps.color || commonStyle.color, 63 color: pluginProps.color || commonStyle.color,
73 // backgroundColor: pluginProps.backgroundColor || commonStyle.backgroundColor, 64 // backgroundColor: pluginProps.backgroundColor || commonStyle.backgroundColor,
74 textAlign: pluginProps.textAlign || commonStyle.textAlign, 65 textAlign: pluginProps.textAlign || commonStyle.textAlign,
  66 + 'z-index': commonStyle.zindex,
75 position 67 position
76 } 68 }
77 return style 69 return style