editor: add mod+d and mod+shift+d for duplicating widgets; use a temporary clipboard when duplicating widgets
This commit is contained in:
parent
68fbe2c56f
commit
1a7b824e73
3 changed files with 46 additions and 11 deletions
|
|
@ -1,12 +1,19 @@
|
|||
# Changelog
|
||||
|
||||
## 1.8.14
|
||||
|
||||
- editor
|
||||
- add `mod+d` and `mod+shift+d` for duplicating widgets
|
||||
- use a temporary clipboard when duplicating widgets
|
||||
|
||||
|
||||
## 1.8.13
|
||||
|
||||
- widgets
|
||||
- file: show save icon when mode is set to save
|
||||
- file: center icon when hidePath is set to true
|
||||
- sliders/pads: apply `spring` property dynamically
|
||||
|
||||
|
||||
- ui
|
||||
- add `alt`+`wheel` for local zoom centered on cursor
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ Multiple widgets can be edited at once.
|
|||
| ++ctrl+x++ | Cut selected widgets |
|
||||
| ++ctrl+v++ | Paste clipboard in selected widget |
|
||||
| ++ctrl+shift+v++ | Paste and increment id |
|
||||
| ++ctrl+d++ | Duplicate selected widget |
|
||||
| ++ctrl+shift+d++ | Duplicate selected widget and increment id |
|
||||
| ++alt+c+"Drag"++ | Paste selection to position |
|
||||
| ++alt+c+shift+"Drag"++ | Paste selection to dragged position and increment id |
|
||||
| ++up++ <br/>++down++ <br/>++left++ <br/>++right++ | Move selected widgets (1 grid unit, hold ++shift++ for 5 grid units) |
|
||||
|
|
@ -113,6 +115,8 @@ Multiple widgets can be edited at once.
|
|||
| ++cmd+x++ | Cut selected widgets |
|
||||
| ++cmd+v++ | Paste clipboard in selected widget |
|
||||
| ++cmd+shift+v++ | Paste and increment id |
|
||||
| ++cmd+d++ | Duplicate selected widget |
|
||||
| ++cmd+shift+d++ | Duplicate selected widget and increment id |
|
||||
| ++alt+c+"Drag"++ | Paste selection to position |
|
||||
| ++alt+c+shift+"Drag"++ | Paste selection to dragged position and increment id |
|
||||
| ++up++ <br/>++down++ <br/>++left++ <br/>++right++ | Move selected widgets (1 grid unit, hold ++shift++ for 5 grid units) |
|
||||
|
|
|
|||
|
|
@ -111,10 +111,7 @@ class Editor {
|
|||
top = Math.round(e.top / GRIDWIDTH) * GRIDWIDTH
|
||||
|
||||
if (e.copying) {
|
||||
this.copyWidget()
|
||||
var index = Math.max(...this.selectedWidgets.map(w=>w.parent.children.indexOf(w)))
|
||||
this.select(this.selectedWidgets[0].parent)
|
||||
this.pasteWidget(left, top, e.shiftKey, index + 1)
|
||||
this.duplicateWidget(left, top, e.shiftKey)
|
||||
} else {
|
||||
var dX = left - e.initLeft,
|
||||
dY = top - e.initTop
|
||||
|
|
@ -132,6 +129,7 @@ class Editor {
|
|||
this.selectedWidgets = []
|
||||
|
||||
this.clipboard = null
|
||||
this.tmpClipboard = null
|
||||
this.idClipboard = null
|
||||
ipc.on('clipboard', (data)=>{
|
||||
this.clipboard = data.clipboard
|
||||
|
|
@ -166,6 +164,8 @@ class Editor {
|
|||
'mod + x',
|
||||
'mod + v',
|
||||
'mod + shift + v',
|
||||
'mod + d',
|
||||
'mod + shift + d',
|
||||
macOs ? 'backspace' : 'delete',
|
||||
'alt + up',
|
||||
'alt + down',
|
||||
|
|
@ -245,6 +245,14 @@ class Editor {
|
|||
this.pasteWidget(this.mousePosition.x, this.mousePosition.y, true)
|
||||
break
|
||||
|
||||
case 'mod + d':
|
||||
this.duplicateWidget(this.mousePosition.x, this.mousePosition.y, false)
|
||||
break
|
||||
|
||||
case 'mod + shift + d':
|
||||
this.duplicateWidget(this.mousePosition.x, this.mousePosition.y, true)
|
||||
break
|
||||
|
||||
case 'backspace':
|
||||
case 'delete':
|
||||
this.deleteWidget()
|
||||
|
|
@ -544,7 +552,7 @@ class Editor {
|
|||
|
||||
}
|
||||
|
||||
copyWidget() {
|
||||
copyWidget(tmp) {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
if (this.selectedWidgets[0].getProp('type') === 'root') return
|
||||
|
|
@ -559,6 +567,19 @@ class Editor {
|
|||
|
||||
}
|
||||
|
||||
duplicateWidget(x, y, increment) {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
if (this.selectedWidgets[0].getProp('type') === 'root') return
|
||||
|
||||
this.tmpClipboard = deepCopy(this.selectedWidgets.map((w)=>w.props))
|
||||
var index = Math.max(...this.selectedWidgets.map(w=>w.parent.children.indexOf(w)))
|
||||
this.select(this.selectedWidgets[0].parent)
|
||||
this.pasteWidget(x, y, increment, index + 1, true)
|
||||
this.select(this.selectedWidgets[0].children[index + 1])
|
||||
|
||||
}
|
||||
|
||||
cutWidget() {
|
||||
|
||||
this.copyWidget()
|
||||
|
|
@ -566,16 +587,19 @@ class Editor {
|
|||
|
||||
}
|
||||
|
||||
pasteWidget(x, y, increment, index) {
|
||||
pasteWidget(x, y, increment, index, tmp) {
|
||||
|
||||
if (!this.selectedWidgets.length || this.clipboard === null) return
|
||||
|
||||
var clipboard = tmp ? this.tmpClipboard : this.clipboard
|
||||
|
||||
if (
|
||||
this.selectedWidgets[0].childrenType === undefined ||
|
||||
this.clipboard[0].type === 'tab' && this.selectedWidgets[0].childrenType === 'widget' ||
|
||||
this.clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
|
||||
clipboard[0].type === 'tab' && this.selectedWidgets[0].childrenType === 'widget' ||
|
||||
clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
|
||||
) return
|
||||
|
||||
var pastedData = deepCopy(this.clipboard),
|
||||
var pastedData = deepCopy(clipboard),
|
||||
minTop = Infinity,
|
||||
minLeft = Infinity
|
||||
|
||||
|
|
@ -630,7 +654,7 @@ class Editor {
|
|||
|
||||
// paste data
|
||||
|
||||
var store = this.clipboard[0].type === 'tab' ? 'tabs' : 'widgets'
|
||||
var store = clipboard[0].type === 'tab' ? 'tabs' : 'widgets'
|
||||
|
||||
this.selectedWidgets[0].props[store] = this.selectedWidgets[0].props[store] || []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue