From 99754857aa78fe044393bd9ffca9b7d6a0938659 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 25 Jan 2024 15:06:28 +0100 Subject: [PATCH] Fixes #4492 - Keyboard combination Ctrl+Shift+... doesnt work in Firefox Co-authored-by: Rolf Schmidt --- .../_plugin/keyboard_shortcuts.coffee | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee b/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee index bf4a6a311663..b7d27b305edf 100644 --- a/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee @@ -290,19 +290,26 @@ App.Config.set( url = window.location.toString() if lastKey && lastKey.count is 3 - item = new window.ClipboardItem( - { - 'text/plain': new Blob( - ["#{text}: #{title}\n#{url}"], - { type: 'text/plain' } - ), - 'text/html': new Blob( - ["#{text}: #{title}"], - { type: 'text/html' } - ), - } - ) - clipboard.write([item]) + + # in firefox `new window.ClipboardItem` may not work + # https://github.com/zammad/zammad/issues/4492 + try + item = new window.ClipboardItem( + { + 'text/plain': new Blob( + ["#{text}: #{title}\n#{url}"], + { type: 'text/plain' } + ), + 'text/html': new Blob( + ["#{text}: #{title}"], + { type: 'text/html' } + ), + } + ) + clipboard.write([item]) + catch e + text = "#{text}: #{title}\n#{url}" + clipboard.writeText(text) } { keyPrefix: '2x'