Skip to content

Instantly share code, notes, and snippets.

@redgeoff
Last active September 23, 2016 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redgeoff/3331e810c5d391f568611d86e15876f9 to your computer and use it in GitHub Desktop.
Save redgeoff/3331e810c5d391f568611d86e15876f9 to your computer and use it in GitHub Desktop.
Ionic Paste Image
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Todo</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.1/css/ionic.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.1/js/ionic.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/paste-image/0.0.3/paste-image.js"></script>
<script>
angular.module('todo', ['ionic']);
</script>
</head>
<body ng-app="todo">
<ion-side-menus>
<!-- Center content -->
<ion-side-menu-content>
<ion-header-bar class="bar-dark">
<h1 class="title">Todo</h1>
</ion-header-bar>
<ion-content>
<script>
// The current image
var img = null;
pasteImage.on('pasting-image', function () {
console.log('pasting image...');
});
pasteImage.on('paste-image', function (image) {
// Does an image already exist? If so, remove it so that we can make space for our new image
if (img) {
document.getElementById('my-img-container').removeChild(img);
}
// Save a reference to the image so that we have the option to remove it later
img = image;
// Display the new image
document.getElementById('my-img-container').appendChild(image);
console.log('image pasted');
});
</script>
<h1>
Copy an image and then press Command+V (Mac) or Ctrl+V (Windows) anywhere in this window.
</h1>
<div id="my-img-container">
</div>
</ion-content>
</ion-side-menu-content>
<!-- Left menu -->
<ion-side-menu side="left">
<ion-header-bar class="bar-dark">
<h1 class="title">Projects</h1>
</ion-header-bar>
</ion-side-menu>
</ion-side-menus>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment