Commit feeff6e0bbe25cd35f844536e5fda533603aea03

Authored by ly525
1 parent 003f7fb5

fix(element) set zindex max if add element to canvas

front-end/h5/src/components/core/editor/index.js
@@ -138,11 +138,11 @@ export default { @@ -138,11 +138,11 @@ export default {
138 * pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo 138 * pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo
139 */ 139 */
140 clone ({ name }) { 140 clone ({ name }) {
141 - const zindex = this.elements.length + 1 141 + // const zindex = this.elements.length + 1
142 const editorConfig = getEditorConfigForEditingElement(name) 142 const editorConfig = getEditorConfigForEditingElement(name)
143 this.elementManager({ 143 this.elementManager({
144 type: 'add', 144 type: 'add',
145 - value: { name, zindex, editorConfig } 145 + value: { name, editorConfig }
146 }) 146 })
147 }, 147 },
148 _renderMenuContent () { 148 _renderMenuContent () {
front-end/h5/src/components/core/models/element.js
@@ -2,7 +2,7 @@ import { parsePx } from '../../../utils/element.js' @@ -2,7 +2,7 @@ import { parsePx } from '../../../utils/element.js'
2 2
3 // #! 编辑状态,不可以点击的按钮,因为点击按钮会触发一些默认行为,比如表单提交等 3 // #! 编辑状态,不可以点击的按钮,因为点击按钮会触发一些默认行为,比如表单提交等
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 cloneObj = (value) => JSON.parse(JSON.stringify(value))
6 6
7 const defaultStyle = { 7 const defaultStyle = {
8 top: 100, 8 top: 100,
@@ -31,8 +31,8 @@ class Element { @@ -31,8 +31,8 @@ class Element {
31 * 3. 为何需要 clone,因为会有 element.clone() 以及 page.clone(), 31 * 3. 为何需要 clone,因为会有 element.clone() 以及 page.clone(),
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 || {})  
35 - this.commonStyle = (typeof ele.commonStyle === 'object' && clone(ele.commonStyle)) || { ...defaultStyle } 34 + this.pluginProps = (typeof ele.pluginProps === 'object' && cloneObj(ele.pluginProps)) || this.getDefaultPluginProps(ele.editorConfig || {})
  35 + this.commonStyle = (typeof ele.commonStyle === 'object' && cloneObj(ele.commonStyle)) || { ...defaultStyle, zindex: ele.zindex }
36 this.events = [] 36 this.events = []
37 this.animations = ele.animations || [] 37 this.animations = ele.animations || []
38 } 38 }