From 3d39a3c13874cb2b18d80b01c70780607d8b9587 Mon Sep 17 00:00:00 2001 From: JungEon Kim Date: Fri, 13 Apr 2018 09:47:24 +0900 Subject: [PATCH] Make image uploadable by paste from clipboard --- directives/input.html | 2 +- js/inputbar.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/directives/input.html b/directives/input.html index d5b4d12..0c0c343 100644 --- a/directives/input.html +++ b/directives/input.html @@ -1,6 +1,6 @@
- diff --git a/js/inputbar.js b/js/inputbar.js index 726db97..7b000bd 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -592,6 +592,24 @@ weechat.directive('inputBar', function() { return true; }; + $scope.inputPasted = function(e) { + if (e.clipboardData && e.clipboardData.files && e.clipboardData.files.length) { + e.stopPropagation(); + e.preventDefault(); + + var sendImageUrl = function(imageUrl) { + if(imageUrl !== undefined && imageUrl !== '') { + $rootScope.insertAtCaret(String(imageUrl)); + } + }; + + for (var i = 0; i < e.clipboardData.files.length; i++) { + imgur.process(e.clipboardData.files[i], sendImageUrl); + } + return false; + } + return true; + }; }] }; });