WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

Enable JavascriptAccessClipboard and JavascriptDomPaste in WPF

Open skl-hyf opened this issue 4 years ago • 2 comments

Currently my project uses CefSharp. Now I want to use webview2 instead.

How can I achieve the effect "JavascriptAccessClipboard" and "JavascriptDomPaste" in webview2 like CefSharp ? This is the description in CefSharp.

    //    Controls whether JavaScript can access the clipboard. Also configurable using
    //    the "disable-javascript-access-clipboard" command-line switch.
    CefState JavascriptAccessClipboard
    {
        get;
        set;
    }

    //     Controls whether DOM pasting is supported in the editor via execCommand("paste").
    //     The |javascript_access_clipboard| setting must also be enabled. Also configurable
    //     using the "disable-javascript-dom-paste" command-line switch.
    CefState JavascriptDomPaste
    {
        get;
        set;
    }

Thanks!

AB#30995003

skl-hyf avatar Nov 08 '21 07:11 skl-hyf

Hey @skl-hyf - We don't currently have support for this, although it has come up as an ask in the past during discussion in #419. We already have a scenario on our backlog tracking this, but I'll link this item to it as well. Thanks!

champnic avatar Nov 12 '21 00:11 champnic

In the meantime, you should be able to disable some parts of this using JS and ExecuteScriptAsync function: https://www.w3docs.com/snippets/javascript/how-to-disable-text-selection-copy-cut-paste-and-right-click-on-a-web-page.html#example-17

champnic avatar Nov 12 '21 00:11 champnic