Author: [email protected]
Date: Wed Jun 24 14:32:41 2009
New Revision: 5631
Modified:
trunk/user/src/com/google/gwt/user/client/ui/RichTextArea.java
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplIE6.java
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplStandard.java
Log:
Adds the ability to insert arbitrary HTML into the RichTextArea.
Patch by: jlabanca
Review by: jgw
Issue: 1433
Modified: trunk/user/src/com/google/gwt/user/client/ui/RichTextArea.java
==============================================================================
--- trunk/user/src/com/google/gwt/user/client/ui/RichTextArea.java
(original)
+++ trunk/user/src/com/google/gwt/user/client/ui/RichTextArea.java Wed Jun
24 14:32:41 2009
@@ -186,6 +186,13 @@
void insertHorizontalRule();
/**
+ * Inserts generic html.
+ *
+ * @param html the HTML to insert
+ */
+ void insertHTML(String html);
+
+ /**
* Inserts an image element.
*
* @param url the url of the image to be inserted
Modified:
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplIE6.java
==============================================================================
---
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplIE6.java
(original)
+++
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplIE6.java
Wed Jun 24 14:32:41 2009
@@ -61,6 +61,26 @@
}-*/;
@Override
+ public native void insertHTML(String html) /*-{
+ try {
+ var elem =
[email protected]::elem;
+ var doc = elem.contentWindow.document;
+ doc.body.focus();
+ var tr = doc.selection.createRange();
+ if (tr == null) {
+ return;
+ }
+ if
([email protected]::isOrHasChild(Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/Element;)(doc.body,
tr.parentElement())) {
+ return;
+ }
+ tr.pasteHTML(html);
+ }
+ catch (e) {
+ return;
+ }
+ }-*/;
+
+ @Override
protected native String getTextImpl() /*-{
var elem =
[email protected]::elem;
return elem.contentWindow.document.body.innerText;
Modified:
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplStandard.java
==============================================================================
---
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplStandard.java
(original)
+++
trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplStandard.java
Wed Jun 24 14:32:41 2009
@@ -88,6 +88,10 @@
execCommand("InsertHorizontalRule", null);
}
+ public void insertHTML(String html) {
+ execCommand("InsertHTML", html);
+ }
+
public void insertImage(String url) {
execCommand("InsertImage", url);
}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---