Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML Editor with Java and And webkit - SWT Browser
    primarykey
    data
    text
    <p>i want to add WYSIWYG HTML editor to my Java program.<br> my idea is to do Something like <a href="http://arstechnica.com/open-source/guides/2009/07/how-to-build-a-desktop-wysiwyg-editor-with-webkit-and-html-5.ars" rel="noreferrer">this</a> but not with python - with Java.</p> <p>i know about couple of options and their problems : </p> <ul> <li><b>HTMLEditorKit</b> - not sophisticated enough.</li> <li><b>JWebpane</b> - fairy tale.</li> <li><b>QtWebKit</b> - not open source.</li> <li><b>JWebEngine</b> - not open source.</li> <li><b>metaphaseeditor</b> - to simple.</li> <li><b>The Lobo Project</b> - not support the contenteditable attribute.</li> <li><b>JavaXPCOM</b> - I don't Succeed to operate it on my mac OS X 10.6.<br> Anyway, I just prefer not to use it because Gecko is slower then webkit.</li> </ul> <p>That's way I chose to work with <b> <a href="http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/browser/Browser.html" rel="noreferrer"> Browser Object</a></b> from <i>org.eclipse.swt.browser</i> Package.</p> <p>For now, I have the code below:<br> The code, first create a instance of the browser object.<br> After this it's load HTML page with <code>contenteditable='true'</code> attributes on the body tag.<br> If its load a page its supposed to add <code>contenteditable='true'</code> attributes to the body tag, and when its save the page it's supposed remove it.</p> <p>My questions are:</p> <ul> <li>How do I grab the edited HTML code?</li> <li>How do I know were the cursor is step on?</li> <li>How do I know if some text is highlighted?</li> </ul> <p><b>Or, in general :</b></p> <ul> <li> How do I build a word possessor with Browser Object and ontenteditable='true' attributes? </li> <li>is it possible?</li> <li>is this the right way for WYSIWYG HTML editor in Java?</li> <li>Any Examples out there?<br> I already check the SWT <a href="http://www.eclipse.org/swt/snippets/#browser" rel="noreferrer">Snippets</a> - doesn't help much.</li> </ul> <p>Thanks a lot.</p> <pre><code>import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class editor { public static void main(String [] args) { String html = "&lt;html&gt;&lt;title&gt;Editor&lt;/title&gt;" + "&lt;body contenteditable='true'&gt;" + " &lt;h2&gt;All the Page is ditable!!!!!&lt;/h2&gt;" + "&lt;p&gt;Heres a typical paragraph element&lt;/p&gt;" + "&lt;ol&gt;&lt;li&gt;and now a list&lt;/li&gt;" + "&lt;li&gt;with only&lt;/li&gt;" + "&lt;li&gt;three items&lt;/li&gt;" + "&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;"; Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Browser browser; try { browser = new Browser(shell, SWT.BORDER); } catch (SWTError e) { System.out.println(e.getMessage()); display.dispose(); return; } Composite comp = new Composite(shell, SWT.NONE); comp.setLayout(new FillLayout(SWT.ALL)); browser.setText(html); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload