Commit 4228dbb79adb614fff068c4a092a17d8af857c1a
1 parent
3dbef87b
fix: use element.uuid to get editingElement
Showing
3 changed files
with
16 additions
and
3 deletions
front-end/h5/src/components/core/editor/canvas/edit.js
| ... | ... | @@ -193,6 +193,7 @@ export default { |
| 193 | 193 | props: element.getProps() |
| 194 | 194 | }) |
| 195 | 195 | } |
| 196 | + const isEditingElement = this.editingElement && this.editingElement.uuid === element.uuid | |
| 196 | 197 | const data = { |
| 197 | 198 | style: { |
| 198 | 199 | width: '100%', |
| ... | ... | @@ -203,7 +204,8 @@ export default { |
| 203 | 204 | class: 'element-on-edit-canvas', |
| 204 | 205 | props: { |
| 205 | 206 | ...element.getProps(), // #6 #3, |
| 206 | - editorMode: 'edit' | |
| 207 | + editorMode: 'edit', | |
| 208 | + isEditingElement | |
| 207 | 209 | }, |
| 208 | 210 | // nativeOn: { |
| 209 | 211 | // contextmenu: e => { | ... | ... |
front-end/h5/src/components/core/models/element.js
| ... | ... | @@ -4,6 +4,12 @@ import { parsePx } from '@/utils/element.js' |
| 4 | 4 | const disabledPluginsForEditMode = ['lbp-form-input', 'lbp-form-button', 'lbp-video'] |
| 5 | 5 | const cloneObj = (value) => JSON.parse(JSON.stringify(value)) |
| 6 | 6 | |
| 7 | +var seed = 0 | |
| 8 | +var now = Date.now() | |
| 9 | + | |
| 10 | +function getUuid (ele) { | |
| 11 | + return `element_${ele.name}_${now}_${seed++}` | |
| 12 | +} | |
| 7 | 13 | const defaultStyle = { |
| 8 | 14 | top: 100, |
| 9 | 15 | left: 100, |
| ... | ... | @@ -19,7 +25,7 @@ const defaultStyle = { |
| 19 | 25 | class Element { |
| 20 | 26 | constructor (ele) { |
| 21 | 27 | this.name = ele.name |
| 22 | - this.uuid = ele.uuid || +new Date() | |
| 28 | + this.uuid = ele.uuid || getUuid(ele) | |
| 23 | 29 | /** |
| 24 | 30 | * #!zh: |
| 25 | 31 | * 之前版本代码:https://github.com/ly525/luban-h5/blob/a7875cbc73c0d18bc2459985ca3ce1d4dc44f141/front-end/h5/src/components/core/models/element.js#L21 | ... | ... |
front-end/h5/src/components/core/plugins/lbp-text.js
| ... | ... | @@ -22,7 +22,7 @@ export default { |
| 22 | 22 | clickOutside: vClickOutside.directive |
| 23 | 23 | }, |
| 24 | 24 | render (h) { |
| 25 | - const canEdit = this.canEdit && this.editorMode === 'edit' | |
| 25 | + const canEdit = this.canEdit && this.editorMode === 'edit' && this.isEditingElement | |
| 26 | 26 | const style = { |
| 27 | 27 | position: 'relative', |
| 28 | 28 | color: `${this.color} !important`, |
| ... | ... | @@ -109,6 +109,11 @@ export default { |
| 109 | 109 | defaultValue: 'preview', // 可选值: preview/edit |
| 110 | 110 | label: '模式', |
| 111 | 111 | visible: false |
| 112 | + }), | |
| 113 | + isEditingElement: PropTypes.boolean({ | |
| 114 | + defaultValue: false, // 可选值: preview/edit | |
| 115 | + label: '是否当前元素', | |
| 116 | + visible: false | |
| 112 | 117 | }) |
| 113 | 118 | }, |
| 114 | 119 | editorConfig: { | ... | ... |