diff --git a/src/browser/js/app/editor/context-menu.js b/src/browser/js/app/editor/context-menu.js
index 6e870dae..4e65f0a9 100644
--- a/src/browser/js/app/editor/context-menu.js
+++ b/src/browser/js/app/editor/context-menu.js
@@ -183,11 +183,22 @@ var handleClick = function(event) {
if (type === 'widget') {
actions[' Copy'] = ()=>{
- CLIPBOARD = JSON.stringify(data)
+ editor.clipboard = JSON.stringify(data)
+ if (data.length == 1) {
+ editor.idClipboard = editor.selectedWidgets[0].getProp('id')
+ } else {
+ editor.idClipboard =null
+ }
}
actions[' Cut'] = ()=>{
- CLIPBOARD = JSON.stringify(data)
+ editor.clipboard = JSON.stringify(data)
+ if (data.length == 1) {
+ editor.idClipboard = editor.selectedWidgets[0].getProp('id')
+ } else {
+ editor.idClipboard =null
+ }
+
for (var i of index) {
parent.props.widgets.splice(i,1)
}
@@ -229,11 +240,11 @@ var handleClick = function(event) {
if (data.length == 1 && (!data[0].tabs || !data[0].tabs.length) && (data[0].widgets)) {
- if (CLIPBOARD !== null) {
+ if (editor.clipboard !== null) {
function paste(increment) {
- var pastedData = JSON.parse(CLIPBOARD),
+ var pastedData = JSON.parse(editor.clipboard),
minTop = Infinity,
minLeft = Infinity
@@ -265,11 +276,32 @@ var handleClick = function(event) {
}
actions[' Paste'] = {
- ' ID + 1': ()=>{
- paste(true)
- },
- ' Clone': ()=>{
+ ' Paste': ()=>{
paste()
+ },
+ ' ID + 1': ()=>{
+ paste(true)
+ }
+ }
+
+ if (editor.idClipboard && widgetManager.getWidgetById(editor.idClipboard).length) {
+ actions[' Paste'][' Clone'] = ()=>{
+ var clone = {type: 'clone', widgetId: editor.idClipboard},
+ pastedData = JSON.parse(editor.clipboard)
+
+ clone.width = pastedData.width
+ clone.height = pastedData.width
+ clone.css = pastedData.css
+
+ if (!eventData.target.classList.contains('tablink')) {
+ clone.top = clickY
+ clone.left = clickX
+ }
+
+ data[0].widgets = data[0].widgets || []
+ data[0].widgets.push(clone)
+
+ updateWidget(editor.selectedWidgets[0])
}
}
diff --git a/src/browser/js/app/editor/index.js b/src/browser/js/app/editor/index.js
index e90ff27a..2e81858d 100644
--- a/src/browser/js/app/editor/index.js
+++ b/src/browser/js/app/editor/index.js
@@ -24,6 +24,10 @@ var Editor = class Editor {
this.selectedWidgets = []
+ this.clipboard = null
+ this.idClipboard = null
+
+
this.enabledOnce = false
window.onbeforeunload = ()=>{
if (this.enabledOnce) return true