Merge pull request #218 from NicolasConstant/topic_copy-paste-image

support pasting image from clipboard
This commit is contained in:
Nicolas Constant 2020-02-19 20:11:28 -05:00 committed by GitHub
commit 5e67c8bdd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 19 deletions

View File

@ -206,25 +206,16 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.accountSub.unsubscribe();
}
onPaste(e: ClipboardEvent ) {
console.log(e);
// e.stopPropagation();
// e.preventDefault();
// console.warn(e);
// console.warn(ev.clipboardData.getData('image'));
// console.warn(ev.clipboardData.getData());
// navigator['clipboard'].readText().then(clipText => {
// console.log(clipText);
// });
// var items = (ev.clipboardData || ev.originalEvent.clipboardData).items;
// console.error(items);
onPaste(e: any) {
const items = (e.clipboardData || e.originalEvent.clipboardData).items;
let blobs: File[] = [];
for (const item of items) {
if (item.type.indexOf('image') === 0) {
let blob = item.getAsFile();
blobs.push(blob);
}
}
this.handleFileInput(blobs);
}
changePrivacy(value: string): boolean {