editor: prevent actions on empty selection
This commit is contained in:
parent
2df4661651
commit
d51531a305
1 changed files with 16 additions and 4 deletions
|
|
@ -373,6 +373,8 @@ var Editor = class Editor {
|
|||
|
||||
copyWidget() {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
var data = this.selectedWidgets.map((w)=>w.props),
|
||||
type = this.selectedWidgets[0].props.type == 'tab' ? 'tab' : 'widget'
|
||||
|
||||
|
|
@ -391,6 +393,8 @@ var Editor = class Editor {
|
|||
|
||||
cutWidget() {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
var index = this.selectedWidgets.map((w)=>DOM.index(w.container)).sort((a,b)=>{return b-a}),
|
||||
data = this.selectedWidgets.map((w)=>w.props),
|
||||
type = this.selectedWidgets[0].props.type == 'tab' ? 'tab' : 'widget',
|
||||
|
|
@ -417,7 +421,7 @@ var Editor = class Editor {
|
|||
|
||||
pasteWidget(x, y, increment) {
|
||||
|
||||
if (this.clipboard === null) return
|
||||
if (!this.selectedWidgets.length || this.clipboard === null) return
|
||||
|
||||
var data = this.selectedWidgets.map((w)=>w.props)
|
||||
|
||||
|
|
@ -452,6 +456,8 @@ var Editor = class Editor {
|
|||
|
||||
pasteWidgetAsClone(x, y) {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
if (this.clipboard === null || !(this.idClipboard && widgetManager.getWidgetById(this.idClipboard).length)) return
|
||||
|
||||
var data = this.selectedWidgets.map((w)=>w.props)
|
||||
|
|
@ -478,14 +484,16 @@ var Editor = class Editor {
|
|||
|
||||
deleteWidget() {
|
||||
|
||||
if (this.deleting) return
|
||||
|
||||
this.deleting = true
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
var index = this.selectedWidgets.map((w)=>DOM.index(w.container)).sort((a,b)=>{return b-a}),
|
||||
type = this.selectedWidgets[0].props.type == 'tab' ? 'tab' : 'widget',
|
||||
parent = this.selectedWidgets[0].parent
|
||||
|
||||
if (this.deleting || this.selectedWidgets[0].getProp('id') === 'root') return
|
||||
|
||||
this.deleting = true
|
||||
|
||||
var popup = new Popup({
|
||||
title: locales('editor_delete_prompt'),
|
||||
content:`
|
||||
|
|
@ -528,6 +536,8 @@ var Editor = class Editor {
|
|||
|
||||
resizeWidget(deltaW, deltaH, ui) {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
var newWidgets = []
|
||||
|
||||
for (var i = 0; i < this.selectedWidgets.length; i++) {
|
||||
|
|
@ -574,6 +584,8 @@ var Editor = class Editor {
|
|||
|
||||
moveWidget(deltaX, deltaY) {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
var newWidgets = []
|
||||
|
||||
for (var w of this.selectedWidgets) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue