MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
424 stars 51 forks source link

Enable JavascriptAccessClipboard and JavascriptDomPaste in WPF #1913

Open skl-hyf opened 2 years ago

skl-hyf commented 2 years ago

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

champnic commented 2 years ago

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 commented 2 years ago

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