copy to clipboard-button

Issue #15 resolved
kreisel created an issue

so it would be more like the look and feel of the native keepass apps

Comments (8)

  1. Nam Nguyen repo owner

    There will be NO copy to clipboard function. This requires an active object (such as Flash, or Java applet) and I am not willing to use them.

    I will consider an auto-selected text so that the use only needs to Ctrl-C (or Cmd-C).

  2. Nam Nguyen repo owner

    Good news. Some Chrome developer has spent time working on official support for ClipboardEvent constructor a few days ago.

    https://code.google.com/p/chromium/issues/detail?id=496394

    As far as I know, Firefox has this constructor but the default security policy is too strict for it to be useful.

    Sample code:

    <html>
    <body>
        <script type="text/javascript">
            function getText() {
                return document.getElementById("copyme").value;
            }
            function copyHandler(evt) {
                evt.clipboardData.setData('text', getText());
                evt.preventDefault();
            }
            document.body.addEventListener('copy', copyHandler);
            function copyCreate() {
                var evt = new ClipboardEvent('copy', {dataType: 'text', data: getText()});
                evt.preventDefault();
                document.dispatchEvent(evt);
            }
        </script>
        <textarea id="copyme"></textarea>
        <button onclick="document.execCommand('copy');">Exec Copy</button>
        <button onclick="copyCreate();">Create Copy</button>
    </body>
    </html>
    

    If you use recent Chrome, the "Exec Copy" should copy the content from the text area into clipboard. Once the bug I mentioned above is committed, the "Create Copy" will also work.

    In Firefox, however, neither button works. The first one generates an NS_ERROR_FAILURE. This is because the document is not in "design mode", or that "content editable" is false. Changed to design mode progressed a little further to SecurityError: The operation is insecure. This is because of default security policy. Users will have to edit user.js file for it to work.

    In short, there is not yet a cross browser method to work with system clipboard. And I am sorry that there will be no support for this (much wanted) feature in BrowsePass in a foreseeable future across many browsers. I do not intend to support third party plugins (such as ffclipboard, as you suggested).

    Perhaps I'll incorporate copy-to-clipboard to Chrome first and we'll see how it goes.

  3. Nam Nguyen repo owner

    @kreisel @jean_yves_toumit Version 0.7.3 supports copy to clipboard.

    However, I must note that there is NO clearing of clipboard. The reason is that any action involving the clipboard MUST originate from the users (such as by clicking a button, typing a hot key). The web app cannot automatically affect the system clipboard.

  4. Log in to comment