Merge pull request #1001 from jungeonkim/paste_image
Make image uploadable by paste from clipboard
This commit is contained in:
commit
63e0d314dc
2 changed files with 19 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
<form class="form form-horizontal" id="inputform" ng-submit="sendMessage()" imgur-drop>
|
||||
<div class="input-group">
|
||||
<textarea id="{{inputId}}" class="form-control favorite-font" ng-trim="false" rows="1" ng-change="inputChanged()" autocomplete="on" ng-model="command" ng-focus="hideSidebar()">
|
||||
<textarea id="{{inputId}}" class="form-control favorite-font" ng-trim="false" rows="1" ng-change="inputChanged()" autocomplete="on" ng-model="command" ng-focus="hideSidebar()" ng-paste="inputPasted($event)">
|
||||
</textarea>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-complete-nick unselectable mobile" title="Complete nick" ng-click="handleCompleteNickButton($event)"><i class="glyphicon glyphicon-bullhorn"></i></button>
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue