How to allow CKEditor within WebView to access the clipboard?

女生的网名这么多〃 提交于 2019-12-11 01:13:45

问题


I'm using a CKEditor 4.1.1 instance within my JavaFX apps' WebView. When i hit the paste-button of the editor, a window opens that tells me that the security settings of the browser prevent clipboard access.

As the browser in this case is the WebViewcomponent, how can i alter the according settings to enable clipboard access?

Test App:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class SimpleWebView extends Application {
  public static void main(String[] args) { launch(args); }
  @Override public void start(Stage stage) {
    WebView webView = new WebView();
    webView.getEngine().load("http://ckeditor.com/demo");

    final Scene scene = new Scene(webView);
    stage.setScene(scene);
    stage.show();
  }
}

To reproduce:

  1. Run the Test App, the ckeditor will display.
  2. Type come text in an external editor such as notepad and copy the text.
  3. Press the 3rd button to the right in the ckeditor toolbar.

回答1:


It seems that this is a general issue with javascript text editors running in a browser, not something WebView specific.

Default security settings for browser runtimes don't allow copy and paste via JavaScript. As the pop-up shown in the screenshot in question shows, the user can still manually paste data into the editor via keyboard shortcuts, it's just that the paste button won't automatically paste data.

In Firefox and Chrome, I got exactly the same behaviour as WebView. In IE, I got a prompt asking if I wanted to allow the web page to access the clipboard and was able to have the data pasted on clicking "Allow Access" to the prompt.

You could file a tweak request against the JavaFX issue tracker runtime project. Note that the block is intentionally implemented as a security related feature, so such a feature request may be rejected.



来源:https://stackoverflow.com/questions/16359956/how-to-allow-ckeditor-within-webview-to-access-the-clipboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!