diff options
Diffstat (limited to 'js')
81 files changed, 5041 insertions, 5602 deletions
diff --git a/js/clipboard/external-apps-clipboard-agent.js b/js/clipboard/external-apps-clipboard-agent.js index 6b9d8090..b82784d3 100644 --- a/js/clipboard/external-apps-clipboard-agent.js +++ b/js/clipboard/external-apps-clipboard-agent.js | |||
@@ -38,40 +38,52 @@ var Montage = require("montage/core/core").Montage, | |||
38 | 38 | ||
39 | var ExternalAppsClipboardAgent = exports.ExternalAppsClipboardAgent = Montage.create(Component, { | 39 | var ExternalAppsClipboardAgent = exports.ExternalAppsClipboardAgent = Montage.create(Component, { |
40 | 40 | ||
41 | //count how many times pasted | ||
42 | //used to move multiple pastes of same copy | ||
43 | pasteCounter:{ | ||
44 | value: 0 | ||
45 | }, | ||
46 | |||
41 | paste:{ | 47 | paste:{ |
42 | value: function(clipboardEvent){ | 48 | value: function(clipboardEvent){ |
43 | var clipboardData = clipboardEvent.clipboardData, | 49 | var clipboardData = clipboardEvent.clipboardData, |
44 | htmlData = clipboardData.getData("text/html"), | 50 | htmlData = clipboardData.getData("text/html"), |
45 | textData = clipboardData.getData("text/plain"), | 51 | textData = clipboardData.getData("text/plain"), |
46 | i=0, | 52 | i=0, |
47 | imageMime, imageData, imageElement; | 53 | imageMime, imageData, imageElement, isImage = false, imageItem; |
48 | 54 | ||
49 | //handle image blobs | 55 | if(clipboardData.items && (clipboardData.items.length > 0)){//handle image blobs |
50 | if(clipboardData.items && (clipboardData.items.length > 0)){ | ||
51 | for(i=0; i < clipboardData.items.length; i++ ){ | 56 | for(i=0; i < clipboardData.items.length; i++ ){ |
52 | if((clipboardData.items[i].kind === "file") && (clipboardData.items[i].type.indexOf("image") === 0)){//example type -> "image/png" | 57 | if((clipboardData.items[i].kind === "file") && (clipboardData.items[i].type.indexOf("image") === 0)){//example type -> "image/png" |
53 | imageMime = clipboardData.items[i].type; | 58 | isImage = true; |
54 | imageData = clipboardData.items[i].getAsFile(); | 59 | if(clipboardData.items[i].type === "image/png"){ |
55 | try{ | 60 | imageItem = clipboardData.items[i];//grab the png image from clipboard |
56 | imageElement = this.pasteImageBinary(imageData); | 61 | } |
57 | }catch(e){ | 62 | else if(i===0){ |
58 | console.log(""+e.stack); | 63 | imageItem = clipboardData.items[i]; |
59 | } | 64 | } |
60 | this.application.ninja.selectionController.selectElements(imageElement); | ||
61 | this.application.ninja.currentDocument.model.needsSave = true; | ||
62 | |||
63 | } | 65 | } |
64 | } | 66 | } |
65 | } | 67 | } |
66 | 68 | ||
67 | try{ | 69 | if(isImage && imageItem){ |
68 | if(!!htmlData || !!textData){ | 70 | imageMime = imageItem.type; |
69 | this.pasteHtml(htmlData, textData); | 71 | imageData = imageItem.getAsFile(); |
72 | try{ | ||
73 | imageElement = this.pasteImageBinary(imageData); | ||
74 | }catch(e){ | ||
75 | console.log(""+e.stack); | ||
70 | } | 76 | } |
71 | }catch(e){ | 77 | this.application.ninja.currentDocument.model.needsSave = true; |
72 | console.log(""+e.stack); | ||
73 | } | 78 | } |
74 | 79 | ||