diff --git a/jslib b/jslib index 1f9fbe43d7..bf9a9c5f9f 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 1f9fbe43d7a78349e6fe994fa70d9b773af5c0f9 +Subproject commit bf9a9c5f9fb5933faeeb07a85f127373ebfe7284 diff --git a/src/app/vault/add-edit.component.ts b/src/app/vault/add-edit.component.ts index 7d8167bffb..c10c178bbe 100644 --- a/src/app/vault/add-edit.component.ts +++ b/src/app/vault/add-edit.component.ts @@ -87,7 +87,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit { } this.analytics.eventTrack.next({ action: 'Copied ' + aType }); - this.platformUtilsService.copyToClipboard(value, { doc: window.document }); + this.platformUtilsService.copyToClipboard(value, { window: window }); this.toasterService.popAsync('info', null, this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); } diff --git a/src/app/vault/ciphers.component.ts b/src/app/vault/ciphers.component.ts index 6f8f536374..f757bf32a4 100644 --- a/src/app/vault/ciphers.component.ts +++ b/src/app/vault/ciphers.component.ts @@ -119,7 +119,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy } this.analytics.eventTrack.next({ action: 'Copied ' + aType.toLowerCase() + ' from listing.' }); - this.platformUtilsService.copyToClipboard(value, { doc: window.document }); + this.platformUtilsService.copyToClipboard(value, { window: window }); this.toasterService.popAsync('info', null, this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); } diff --git a/src/services/webPlatformUtils.service.ts b/src/services/webPlatformUtils.service.ts index 55dae55f35..9ecc0f568b 100644 --- a/src/services/webPlatformUtils.service.ts +++ b/src/services/webPlatformUtils.service.ts @@ -208,10 +208,19 @@ export class WebPlatformUtilsService implements PlatformUtilsService { } copyToClipboard(text: string, options?: any): void { - const doc: Document = options ? options.doc : window.document; - if ((window as any).clipboardData && (window as any).clipboardData.setData) { + let win = window; + let doc = window.document; + if (options && (options.window || options.win)) { + win = options.window || options.win; + doc = win.document; + } else if (options && options.doc) { + doc = options.doc; + } + if ((win as any).navigator.clipboard && (win as any).navigator.clipboard.writeText) { + (win as any).navigator.clipboard.writeText(text); + } else if ((win as any).clipboardData && (win as any).clipboardData.setData) { // IE specific code path to prevent textarea being shown while dialog is visible. - (window as any).clipboardData.setData('Text', text); + (win as any).clipboardData.setData('Text', text); } else if (doc.queryCommandSupported && doc.queryCommandSupported('copy')) { const textarea = doc.createElement('textarea'); textarea.textContent = text;