ngx-clipboard
Advanced tools
Comparing version 6.0.0-beta0 to 6.0.0-beta1
@@ -42,6 +42,6 @@ (function (global, factory) { | ||
if (this.targetElm) { | ||
this.selectedText = this.targetElm.nativeElement.value; | ||
this.selectTarget(this.targetElm.nativeElement); | ||
this.selectedText = this.targetElm.value; | ||
this.selectTarget(this.targetElm); | ||
this.handleResult(this.copyText()); | ||
this.clearSelection(this.targetElm.nativeElement, window); | ||
this.clearSelection(this.targetElm, window); | ||
} | ||
@@ -48,0 +48,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core")):typeof define==="function"&&define.amd?define(["exports","@angular/core"],factory):factory((global.ngx=global.ngx||{},global.ngx.clipboard=global.ngx.clipboard||{}),global.ng.core)})(this,function(exports,_angular_core){"use strict";var ClipboardDirective=function(){function ClipboardDirective(elmRef,renderer){this.elmRef=elmRef;this.renderer=renderer;this.cbOnSuccess=new _angular_core.EventEmitter;this.cbOnError=new _angular_core.EventEmitter}ClipboardDirective.prototype.ngOnInit=function(){};ClipboardDirective.prototype.ngOnDestroy=function(){};ClipboardDirective.prototype.onClick=function(button){if(this.targetElm){this.selectedText=this.targetElm.nativeElement.value;this.selectTarget(this.targetElm.nativeElement);this.handleResult(this.copyText());this.clearSelection(this.targetElm.nativeElement,window)}};ClipboardDirective.prototype.selectTarget=function(nativeElement){if(nativeElement.nodeName==="INPUT"||nativeElement.nodeName==="TEXTAREA"){this.renderer.invokeElementMethod(nativeElement,"select");this.renderer.invokeElementMethod(nativeElement,"setSelectionRange",[0,nativeElement.value.length])}};ClipboardDirective.prototype.copyText=function(){try{return document.execCommand("copy")}catch(err){throw new Error("fail to perform copy")}};ClipboardDirective.prototype.handleResult=function(succeeded){if(succeeded){this.cbOnSuccess.emit({isSuccess:true,content:this.selectedText})}else{this.cbOnError.emit({isSuccess:false})}};ClipboardDirective.prototype.clearSelection=function(nativeElement,window){nativeElement&&nativeElement.blur();window.getSelection().removeAllRanges()};return ClipboardDirective}();ClipboardDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[ngxClipboard]"}]}];ClipboardDirective.ctorParameters=function(){return[{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};ClipboardDirective.propDecorators={targetElm:[{type:_angular_core.Input,args:["ngxClipboard"]}],cbContent:[{type:_angular_core.Input}],cbOnSuccess:[{type:_angular_core.Output}],cbOnError:[{type:_angular_core.Output}],onClick:[{type:_angular_core.HostListener,args:["click",["$event.target"]]}]};var ClipboardModule=function(){function ClipboardModule(){}return ClipboardModule}();ClipboardModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[ClipboardDirective],exports:[ClipboardDirective]}]}];ClipboardModule.ctorParameters=function(){return[]};exports.ClipboardModule=ClipboardModule;exports.ClipboardDirective=ClipboardDirective;Object.defineProperty(exports,"__esModule",{value:true})}); | ||
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core")):typeof define==="function"&&define.amd?define(["exports","@angular/core"],factory):factory((global.ngx=global.ngx||{},global.ngx.clipboard=global.ngx.clipboard||{}),global.ng.core)})(this,function(exports,_angular_core){"use strict";var ClipboardDirective=function(){function ClipboardDirective(elmRef,renderer){this.elmRef=elmRef;this.renderer=renderer;this.cbOnSuccess=new _angular_core.EventEmitter;this.cbOnError=new _angular_core.EventEmitter}ClipboardDirective.prototype.ngOnInit=function(){};ClipboardDirective.prototype.ngOnDestroy=function(){};ClipboardDirective.prototype.onClick=function(button){if(this.targetElm){this.selectedText=this.targetElm.value;this.selectTarget(this.targetElm);this.handleResult(this.copyText());this.clearSelection(this.targetElm,window)}};ClipboardDirective.prototype.selectTarget=function(nativeElement){if(nativeElement.nodeName==="INPUT"||nativeElement.nodeName==="TEXTAREA"){this.renderer.invokeElementMethod(nativeElement,"select");this.renderer.invokeElementMethod(nativeElement,"setSelectionRange",[0,nativeElement.value.length])}};ClipboardDirective.prototype.copyText=function(){try{return document.execCommand("copy")}catch(err){throw new Error("fail to perform copy")}};ClipboardDirective.prototype.handleResult=function(succeeded){if(succeeded){this.cbOnSuccess.emit({isSuccess:true,content:this.selectedText})}else{this.cbOnError.emit({isSuccess:false})}};ClipboardDirective.prototype.clearSelection=function(nativeElement,window){nativeElement&&nativeElement.blur();window.getSelection().removeAllRanges()};return ClipboardDirective}();ClipboardDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[ngxClipboard]"}]}];ClipboardDirective.ctorParameters=function(){return[{type:_angular_core.ElementRef},{type:_angular_core.Renderer}]};ClipboardDirective.propDecorators={targetElm:[{type:_angular_core.Input,args:["ngxClipboard"]}],cbContent:[{type:_angular_core.Input}],cbOnSuccess:[{type:_angular_core.Output}],cbOnError:[{type:_angular_core.Output}],onClick:[{type:_angular_core.HostListener,args:["click",["$event.target"]]}]};var ClipboardModule=function(){function ClipboardModule(){}return ClipboardModule}();ClipboardModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[ClipboardDirective],exports:[ClipboardDirective]}]}];ClipboardModule.ctorParameters=function(){return[]};exports.ClipboardModule=ClipboardModule;exports.ClipboardDirective=ClipboardDirective;Object.defineProperty(exports,"__esModule",{value:true})}); |
@@ -5,3 +5,3 @@ import { ElementRef, EventEmitter, OnInit, OnDestroy, Renderer } from '@angular/core'; | ||
private renderer; | ||
targetElm: ElementRef; | ||
targetElm: HTMLInputElement; | ||
cbContent: string; | ||
@@ -8,0 +8,0 @@ cbOnSuccess: EventEmitter<any>; |
@@ -37,6 +37,6 @@ import { HostListener, Directive, ElementRef, Input, Output, EventEmitter, Renderer } from '@angular/core'; | ||
if (this.targetElm) { | ||
this.selectedText = this.targetElm.nativeElement.value; | ||
this.selectTarget(this.targetElm.nativeElement); | ||
this.selectedText = this.targetElm.value; | ||
this.selectTarget(this.targetElm); | ||
this.handleResult(this.copyText()); | ||
this.clearSelection(this.targetElm.nativeElement, window); | ||
this.clearSelection(this.targetElm, window); | ||
} | ||
@@ -43,0 +43,0 @@ }; |
@@ -6,3 +6,3 @@ { | ||
"module": "./dist/index.js", | ||
"version": "6.0.0-beta0", | ||
"version": "6.0.0-beta1", | ||
"author": { | ||
@@ -9,0 +9,0 @@ "name": "Sam Lin", |
@@ -8,3 +8,3 @@ import { HostListener, Directive, ElementRef, Input, Output, EventEmitter, OnInit, OnDestroy, Renderer } from '@angular/core'; | ||
@Input('ngxClipboard') public targetElm: ElementRef; | ||
@Input('ngxClipboard') public targetElm: HTMLInputElement; | ||
@@ -38,10 +38,9 @@ @Input() public cbContent: string; | ||
if (this.targetElm) { | ||
this.selectedText = this.targetElm.nativeElement.value; | ||
this.selectTarget(this.targetElm.nativeElement); | ||
this.selectedText = this.targetElm.value; | ||
this.selectTarget(this.targetElm); | ||
this.handleResult(this.copyText()); | ||
this.clearSelection(this.targetElm.nativeElement, window); | ||
this.clearSelection(this.targetElm, window); | ||
} | ||
} | ||
// select the native element | ||
@@ -48,0 +47,0 @@ private selectTarget(nativeElement: any) { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
32373