Skip to content

Commit

Permalink
feat: new context menu logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangChiTW committed Mar 20, 2023
1 parent f2b9985 commit 6a7d3ad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/components/editor/common/ContextMenu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export default {
},
zoom: {
type: Number
},
clipboardLength: {
type: Number
},
selectedElementsLength: {
type: Number
}
},
data: function () {
Expand Down Expand Up @@ -67,9 +73,18 @@ export default {
menu () {
if (this.specialState) {
return [ { name: 'select', action: 'select' } ]
} else if (this.selectedElementsLength === 0) {
if (this.clipboardLength > 0) {
return [
{ name: 'draw', action: 'draw' },
{ name: 'paste', action: 'paste' }
]
}
return [
{ name: 'draw', action: 'draw' }
]
}
return [
{ name: 'select', action: 'select' },
{ name: 'copy', action: 'copy' },
{ name: 'paste', action: 'paste' },
{ name: 'cut', action: 'cut' },
Expand All @@ -85,6 +100,9 @@ export default {
case 'select':
this.$emit('clearState')
break
case 'draw':
this.$emit('draw')
break
case 'copy':
this.$emit('copy')
break
Expand Down
8 changes: 8 additions & 0 deletions src/components/editor/main/Stage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
:axis="rightClickPoint"
:zoom="zoom"
:specialState="paint || moveStage"
:clipboardLength="clipboard.length"
:selectedElementsLength="selectedElements.length"
@clearState="clearState"
@draw="drawState"
@delete="deleteHandler"
@copy="copyHandler"
@cut="cutHandler"
Expand Down Expand Up @@ -157,6 +160,11 @@ export default {
this.moveStage = false
},
drawState () {
this.paint = true
this.moveStage = false
},
checkCollision (selectedEls) {
if (selectedEls.length > 0) {
const unit = this.gridUnit.current / 10
Expand Down

0 comments on commit 6a7d3ad

Please sign in to comment.