Skip to content

Commit 0208a79

Browse files
committed
fix: set z-index for element
1 parent 73ff900 commit 0208a79

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

front-end/h5/src/components/core/models/element.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { parsePx } from '../../../utils/element.js'
44
const disabledPluginsForEditMode = ['lbp-form-input', 'lbp-form-button']
55
const clone = (value) => JSON.parse(JSON.stringify(value))
66

7-
const defaultProps = {
7+
const defaultStyle = {
88
top: 100,
99
left: 100,
1010
width: 100,
@@ -19,7 +19,7 @@ const defaultProps = {
1919
class Element {
2020
constructor (ele) {
2121
this.name = ele.name
22-
this.uuid = +new Date()
22+
this.uuid = ele.uuid || +new Date()
2323
/**
2424
* #!zh:
2525
* 之前版本代码:https://github.com/ly525/luban-h5/blob/a7875cbc73c0d18bc2459985ca3ce1d4dc44f141/front-end/h5/src/components/core/models/element.js#L21
@@ -32,19 +32,10 @@ class Element {
3232
* element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误
3333
*/
3434
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 }
4136
this.events = []
4237
}
4338

44-
getDefaultCommonStyle () {
45-
return { ...defaultProps }
46-
}
47-
4839
getDefaultPluginProps (editorConfig) {
4940
// init prop of plugin
5041
const propConf = editorConfig.propsConfig
@@ -72,6 +63,7 @@ class Element {
7263
color: pluginProps.color || commonStyle.color,
7364
// backgroundColor: pluginProps.backgroundColor || commonStyle.backgroundColor,
7465
textAlign: pluginProps.textAlign || commonStyle.textAlign,
66+
'z-index': commonStyle.zindex,
7567
position
7668
}
7769
return style

0 commit comments

Comments
 (0)