Code Monkey home page Code Monkey logo

Comments (5)

martinbroos avatar martinbroos commented on June 18, 2024 1

To use the new api but still support older browsers i'm using this implementation. But might be good to add this to copy-to-clipboard.

async onClick() {
        try {
            await navigator.clipboard.writeText(shareUrl);
        } catch {
            // Otherwise we use copy-to-clipboard library that tries to use execCommand which is deprecated in modern browsers
            // when browser does not allow clipboard copy it will show a modal with the link in it
            copy(shareUrl);
        }
}

from copy-to-clipboard.

mlsad3 avatar mlsad3 commented on June 18, 2024

I think a downside of this is it looks like you can only copy text, and can't specify the format. Am I incorrect here?

from copy-to-clipboard.

silverwind avatar silverwind commented on June 18, 2024

writeText is only for text. For other formats, there is write.

from copy-to-clipboard.

silverwind avatar silverwind commented on June 18, 2024

I guess with this API available, this module is pretty much obsolete, so one option could be to not support it, letting this module exist only as a "legacy solution".

from copy-to-clipboard.

Reverier-Xu avatar Reverier-Xu commented on June 18, 2024

I guess with this API available, this module is pretty much obsolete, so one option could be to not support it, letting this module exist only as a "legacy solution".

the new clipboard API just works on HTTPS or localhost. In some usage scenarios, such as intranet environments without domain name resolution and custom certificates, the new API is not available.

from copy-to-clipboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.