问题
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 WebView
component, 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:
- Run the Test App, the ckeditor will display.
- Type come text in an external editor such as notepad and copy the text.
- 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