如何允许WebView中的CKEditor访问剪贴板? [英] How to allow CKEditor within WebView to access the clipboard?

查看:299
本文介绍了如何允许WebView中的CKEditor访问剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在JavaFX应用程序的 WebView 中使用CKEditor 4.1.1实例。当我按下编辑器的粘贴按钮时,将打开一个窗口,告诉我浏览器的安全设置阻止剪贴板访问。

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.

在这种情况下,浏览器是 WebView 组件,如何更改相应设置以启用剪贴板访问权限?

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

测试应用程序:

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();
  }
}

要重现:


  1. 运行测试应用程序,将显示ckeditor。

  2. 在外部编辑器(如记事本)中键入come text并复制文本。

  3. 按ckeditor工具栏右侧的第3个按钮。


推荐答案

这似乎是浏览器中运行的javascript文本编辑器的普遍问题,而不是WebView特定的问题。

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

浏览器运行时的默认安全设置don不允许通过JavaScript复制和粘贴。如相关屏幕快照中所示的弹出窗口所示,用户仍然可以通过键盘快捷键将数据手动粘贴到编辑器中,只是粘贴按钮不会自动粘贴数据。

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.

在Firefox和Chrome中,我的行为与WebView完全相同。在IE中,我收到提示,询问是否要允许网页访问剪贴板,并能够通过单击提示的允许访问来粘贴数据。

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.

您可以针对 JavaFX问题跟踪器运行时项目提交调整请求。注意,该块是有意实现为与安全相关的功能,因此可能会拒绝此类功能请求。

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.

这篇关于如何允许WebView中的CKEditor访问剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆