From 5f36adb083b86324923a9a316541a84448475dc0 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 15 Aug 2017 16:41:50 +0100 Subject: FF: Add copy/paste functions to the HUD --- content_scripts/hud.coffee | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'content_scripts') diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index 7c983cfa..928ae5fd 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -9,6 +9,8 @@ HUD = findMode: null abandon: -> @hudUI?.hide false + pasteListener: null # Set by @pasteFromClipboard to handle the value returned by pasteResponse + # This HUD is styled to precisely mimick the chrome HUD on Mac. Use the "has_popup_and_link_hud.html" # test harness to tweak these styles to match Chrome's. One limitation of our HUD display is that # it doesn't sit on top of horizontal scrollbars like Chrome's HUD does. @@ -82,6 +84,20 @@ HUD = @findMode.exit() postExit?() + # These commands manage copying and pasting from the clipboard in the HUD frame. + # NOTE(mrmr1993): We need this to copy and paste on Firefox: + # * an element can't be focused in the background page, so copying/pasting doesn't work + # * we don't want to disrupt the focus in the page, in case the page is listening for focus/blur events. + # * the HUD shouldn't be active for this frame while any of the copy/paste commands are running. + copyToClipboard: (text) -> + @hudUI.postMessage {name: "copyToClipboard", data: text} + + pasteFromClipboard: (@pasteListener) -> + @hudUI.postMessage {name: "pasteFromClipboard"} + + pasteResponse: ({data}) -> + @pasteListener data + class Tween opacity: 0 intervalId: -1 -- cgit v1.2.3