You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function below always works on Chrome, but never on Firefox. My guess is that Firefox is stricter in its definition of a user-driven event, which is necessary to execute the copy command, and something is getting interleaved by the ghcjs runtime that violates it. It's possible that this is a ghcjs bug, but putting here for now until we've got an example that can prove it.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
importData.Text (Text)
importqualifiedGHCJS.DOMasDOMimportqualifiedGHCJS.DOM.DocumentasDocumentimportqualifiedGHCJS.DOM.HTMLTextAreaElementasTextAreaimportqualifiedGHCJS.DOM.NodeasNodeimportqualifiedGHCJS.DOM.TypesasDOMimportLanguage.Javascript.JSaddle (MonadJSM)
importReflex.Dom.Core--| Copy the given text to the clipboard
performCopyToClipboard
:: (MonadJSM (Performablem), PerformEventtm)
=>EventtText--^ Text to copy to clipboard. Event must come directly from user-- interaction (e.g. domEvent Click), or the copy will not take place.->m (EventtBool)
--^ Did the copy take place successfully?
performCopyToClipboard copyEvent = performEvent $
ffor copyEvent $\copyText ->do
doc <-DOM.currentDocumentUnchecked
ta <-DOM.uncheckedCastTo TextArea.HTMLTextAreaElement<$>Document.createElement doc ("textarea"::Text)
TextArea.setValue ta copyText
body <-Document.getBodyUnchecked doc
_ <-Node.appendChild body ta
TextArea.select ta
result <-Document.execCommand doc ("copy"::Text) False (Nothing::MaybeText)
_ <-Node.removeChild body ta
return result
The text was updated successfully, but these errors were encountered:
The function below always works on Chrome, but never on Firefox. My guess is that Firefox is stricter in its definition of a user-driven event, which is necessary to execute the copy command, and something is getting interleaved by the ghcjs runtime that violates it. It's possible that this is a ghcjs bug, but putting here for now until we've got an example that can prove it.
The text was updated successfully, but these errors were encountered: