diff --git a/package.json b/package.json index 25e0673..ee81d06 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@angular/platform-browser-dynamic": "~7.2.15", "@angular/router": "~7.2.15", "core-js": "^2.5.4", - "ngx-clipboard": "12.1.2", + "ngx-clipboard": "12.2.2", "ngx-window-token": "2.0.1", "rxjs": "~6.5.2", "tslib": "^1.9.0", diff --git a/projects/ngx-clipboard/package.json b/projects/ngx-clipboard/package.json index f4f3e65..9a73241 100644 --- a/projects/ngx-clipboard/package.json +++ b/projects/ngx-clipboard/package.json @@ -1,7 +1,7 @@ { "name": "ngx-clipboard", "description": "angular 2 clipboard", - "version": "12.2.1", + "version": "12.3.0", "author": { "name": "Sam Lin", "email": "maxisam@gmail.com" diff --git a/projects/ngx-clipboard/src/lib/ngx-clipboard.service.ts b/projects/ngx-clipboard/src/lib/ngx-clipboard.service.ts index b16d795..0a1cf38 100644 --- a/projects/ngx-clipboard/src/lib/ngx-clipboard.service.ts +++ b/projects/ngx-clipboard/src/lib/ngx-clipboard.service.ts @@ -49,11 +49,11 @@ export class ClipboardService { /** * Attempts to copy from an input `targetElm` */ - public copyFromInputElement(targetElm: HTMLInputElement | HTMLTextAreaElement): boolean { + public copyFromInputElement(targetElm: HTMLInputElement | HTMLTextAreaElement, isFocus = true): boolean { try { this.selectTarget(targetElm); const re = this.copyText(); - this.clearSelection(targetElm, this.window); + this.clearSelection(isFocus ? targetElm : undefined, this.window); return re && this.isCopySuccessInIE11(); } catch (error) { return false; @@ -94,7 +94,7 @@ export class ClipboardService { } this.tempTextArea.value = content; - const toReturn = this.copyFromInputElement(this.tempTextArea); + const toReturn = this.copyFromInputElement(this.tempTextArea, false); if (this.config.cleanUpAfterCopy) { this.destroy(this.tempTextArea.parentElement); } @@ -129,7 +129,6 @@ export class ClipboardService { * Moves focus away from `target` and back to the trigger, removes current selection. */ private clearSelection(inputElement: HTMLInputElement | HTMLTextAreaElement, window: Window): void { - // tslint:disable-next-line:no-unused-expression inputElement && inputElement.focus(); window.getSelection().removeAllRanges(); } @@ -164,4 +163,11 @@ export class ClipboardService { public pushCopyResponse(response: IClipboardResponse): void { this.copySubject.next(response); } + + /** + * @deprecated use pushCopyResponse instead. + */ + public pushCopyReponse(response: IClipboardResponse): void { + this.pushCopyResponse(response); + } } diff --git a/yarn.lock b/yarn.lock index 11c173a..a1caa13 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5534,10 +5534,10 @@ ng-packagr@^4.2.0: uglify-js "^3.0.7" update-notifier "^2.3.0" -ngx-clipboard@12.1.2: - version "12.1.2" - resolved "https://registry.yarnpkg.com/ngx-clipboard/-/ngx-clipboard-12.1.2.tgz#69077d928a20b061ef22b51bd871633bb4d6af0a" - integrity sha512-tctOooh9WWvK7tVKV+CAGN5nNAhnL7oqEoJmJO4TmkHHwVbL0QQFWdWB5yiMYTRQ/ZXV3bCpufiVM8F4clXthw== +ngx-clipboard@12.2.2: + version "12.2.2" + resolved "https://registry.yarnpkg.com/ngx-clipboard/-/ngx-clipboard-12.2.2.tgz#84de257d6a1cfbae1f17db25080ffdf0fe9b51aa" + integrity sha512-YCeAGJGt7DYXIgfnItud+oM2S1ze1JVUH+3wXTyJpjei+17RLv9OvqshntKfsMkDFskXEe/fpCAlth08JInIzw== dependencies: ngx-window-token "^2.0.0" tslib "^1.9.0"