Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard cannot set or getData #25

Open
liuchonghui opened this issue Sep 23, 2015 · 1 comment
Open

Clipboard cannot set or getData #25

liuchonghui opened this issue Sep 23, 2015 · 1 comment

Comments

@liuchonghui
Copy link

RE.editor.addEventListener("paste", function(evt) {
evt.preventDefault();
var pasteData = evt.clipboardData;
// pasteData getData.length = 0
}
How to fix it..I want to remove css style from pasted contents.

@liuchonghui liuchonghui changed the title Clipbroad cannot set or getData Clipboard cannot set or getData Sep 23, 2015
@liuchonghui
Copy link
Author

Fixed.I tried this way:
js add:
RE.editor.addEventListener("paste", function(evt) {
evt.preventDefault();
var plain = ClipboardReader.getClipboardDataAsText();
RE.insertHTML(plain);
});
RichEditor.java add:
private class ClipboardReader {
public String getClipboardDataAsText() {
String plainText = "";
ClipboardManager cm = (ClipboardManager) getContext()
.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData cd = cm.getPrimaryClip();
if (cd != null && cd.getItemAt(0) != null) {
Item item = cd.getItemAt(0);
plainText = item.getText().toString();
}
return plainText;
}
}
and regist "ClipboardReader":
addJavascriptInterface(new ClipboardReader(), "ClipboardReader");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant