home.social

#clipboardapi — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #clipboardapi, aggregated by home.social.

  1. #TIL

    > The async #ClipboardAPI introduced in 2017 restricts which data types can be written to and read from the clipboard. However, it can read from and write to the clipboard at any time.

    > The older #Clipboard #Events #API has no real restrictions on which data types can be written to and read from the clipboard. However, it can only be triggered by the user agent.

    alexharri.com/blog/undefined/b

    #webDev #javaScript #web #development

  2. Here’s a niche gotcha with the clipboard API’s `navigator.clipboard.writeText()` method that’s unique to Safari:

    If you access a function from a module within your gesture handler (e.g., click handler), you will get a permission error.

    The (sadly hacky and not as robust) workaround is to set a global variable from your module instead.

    Full gist:

    codeberg.org/aral/gists/src/br

    #Safari #clipboardAPI #JavaScript #ESModules #web #dev #gist