[Sprint/HipsterHedgehog] (feat): ability to copy and paste images into posts and comments
closes minds#553
0/3 discussions resolved
6 7 private focused: boolean = false; 8 9 10 @HostListener('focus') onFocus() { 11 this.focused = true; 12 } 13 14 @HostListener('focusout') onFocusOut() { 15 this.focused = false; 16 } 17 18 @HostListener('window:paste', ['$event']) onPaste(event: ClipboardEvent) { 19 if (this.focused) { 20 for (let index in event.clipboardData.items) { 21 const item: DataTransferItem = event.clipboardData.items[index]; - Maintainer
This just works from the raw clipboard? We don't need to do any encoding? Sounds both awesome and terrifying.
134 146 this.triedToPost = false; 135 file.value = null; 136 147 this.detectChanges(); 137 148 }) 138 149 .catch(e => { 139 150 console.error(e); 140 151 this.canPost = true; 141 152 this.triedToPost = false; 142 file.value = null; 143 153 this.detectChanges(); 144 154 }); 145 146 this.detectChanges(); 147 155 } 148 156 149 157 removeAttachment(file: HTMLInputElement) { - Maintainer
Can we name this something more specific like ```fileElement``? My dumb brain keeps reading that as an input stream
1 import { Directive, EventEmitter, HostListener, Output } from '@angular/core'; 2 3 @Directive({ selector: '[m-attachment-paste]' }) 4 export class AttachmentPasteDirective { 5 @Output('onFilePaste') onFilePaste: EventEmitter<File> = new EventEmitter<File>(); 6 7 private focused: boolean = false; 8 9 10 @HostListener('focus') onFocus() { 11 this.focused = true; 12 } 13 - Maintainer
This feels like it should be unit tested and also a total pain in the ass to test.