Commit 0208a797483daebcb36c131dcdc3f8f5df092342
1 parent
73ff900d
fix: set z-index for element
Showing
1 changed file
with
4 additions
and
12 deletions
front-end/h5/src/components/core/models/element.js
| ... | ... | @@ -4,7 +4,7 @@ import { parsePx } from '../../../utils/element.js' |
| 4 | 4 | const disabledPluginsForEditMode = ['lbp-form-input', 'lbp-form-button'] |
| 5 | 5 | const clone = (value) => JSON.parse(JSON.stringify(value)) |
| 6 | 6 | |
| 7 | -const defaultProps = { | |
| 7 | +const defaultStyle = { | |
| 8 | 8 | top: 100, |
| 9 | 9 | left: 100, |
| 10 | 10 | width: 100, |
| ... | ... | @@ -19,7 +19,7 @@ const defaultProps = { |
| 19 | 19 | class Element { |
| 20 | 20 | constructor (ele) { |
| 21 | 21 | this.name = ele.name |
| 22 | - this.uuid = +new Date() | |
| 22 | + this.uuid = ele.uuid || +new Date() | |
| 23 | 23 | /** |
| 24 | 24 | * #!zh: |
| 25 | 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 | 32 | * element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误 |
| 33 | 33 | */ |
| 34 | 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 | 36 | this.events = [] |
| 42 | 37 | } |
| 43 | 38 | |
| 44 | - getDefaultCommonStyle () { | |
| 45 | - return { ...defaultProps } | |
| 46 | - } | |
| 47 | - | |
| 48 | 39 | getDefaultPluginProps (editorConfig) { |
| 49 | 40 | // init prop of plugin |
| 50 | 41 | const propConf = editorConfig.propsConfig |
| ... | ... | @@ -72,6 +63,7 @@ class Element { |
| 72 | 63 | color: pluginProps.color || commonStyle.color, |
| 73 | 64 | // backgroundColor: pluginProps.backgroundColor || commonStyle.backgroundColor, |
| 74 | 65 | textAlign: pluginProps.textAlign || commonStyle.textAlign, |
| 66 | + 'z-index': commonStyle.zindex, | |
| 75 | 67 | position |
| 76 | 68 | } |
| 77 | 69 | return style | ... | ... |