Skip to content

Commit

Permalink
fix: paste electrode left click disappear error
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangChiTW committed Feb 8, 2023
1 parent b21d1c0 commit df2cdc7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
36 changes: 30 additions & 6 deletions src/components/editor/main/Stage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,17 @@ export default {
}
},
pasteHandler (e) {
async pasteHandler (e) {
if (this.clipboard.length > 0) {
const unit = this.gridUnit.origin / 10
const unitX = parseInt((e.x / this.zoom) / unit)
const unitY = parseInt((e.y / this.zoom) / unit)
const top = unit * unitY
const left = unit * unitX
const cornerSize = this.cornerSize
const gapSize = this.gapSize
const posX = e.x
const posY = e.y
let canAdd = true
const pasteTop = this.clipboard[0].top
Expand All @@ -355,14 +359,34 @@ export default {
})
if (canAdd) {
this.clipboard.map(el => {
this.clipboard.map(async el => {
el.top = top + el.top - pasteTop
el.left = left + el.left - pasteLeft
this.registerElement({pageId: this.page.id, el, global: el.global})
this._updateChipMatrix({
egglement: el,
add: true
let element = newElectrodeUnit(el.name, unit, cornerSize, gapSize, el.top, el.left)
const fixedElement = {
top: el.top,
left: el.left,
height: el.height,
width: el.width
}
element = {...element, ...fixedElement}
element = await this.registerElement({pageId: this.page.id, el: element, global: el.global})
this.currentRelPosPoint.x = posX
this.currentRelPosPoint.y = posY
if (element.name !== 'base') {
this.updateElement({
egglement: element,
name: element.id.split('.')[1],
path: el.children[0].attrs.d,
classes: {
'matrix': el.classes.matrix
}
})
this._updateChipMatrix({
egglement: element,
add: true
})
}
})
} else {
this.$toasted.show(
Expand Down
2 changes: 1 addition & 1 deletion src/store/actions/elementAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const elementActions = {
commit(types._updateComponentRef, {compIndex, newCount})
}
} else if (el.external) {
// In case the componegg is from a external library...
// In case the componegg is from a external library...
if (!getters.componentExist(el.name)) {
let componentRef = componentFactory.compRef(payload.el)
commit(types._saveComponentRef, setElId(componentRef))
Expand Down

0 comments on commit df2cdc7

Please sign in to comment.