Bug 212829 - [StyledText] Add HTML Support to StyledText
Summary: [StyledText] Add HTML Support to StyledText
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
: 98904 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-12-12 18:39 EST by Ozzie CLA
Modified: 2017-07-12 11:35 EDT (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ozzie CLA 2007-12-12 18:39:23 EST
One thing clearly missing from SWT is a WYSIWYG HTML Editor.  The need for HTML editing is very common, you just need to take a look at how many of these editors are available for other technologies.  A quick search of the internet shows that I am not alone this need.

This request is not new and has been been discussed earlier on BugID's 54426, 98904 but has never been implemented.

I realise that writing a HTML WYSIWYG widget in an enourmous task but why not start small and add HTML support to the existing StyledText widget for the existing styles eg: Bold, Italic etc.  The StyledText widget supports an RTFWriter but it really needs a HTMLReader/HTMLWriter.

Even better scrap the reader/writer concept and add an extensible StyleConverter and provide default RTF and HTML implementations.  The converter would need to be extensible so people can add support for styles as they need them.  Also people could add custom converters (eg: custom XML).

Developers could then use examples such as this http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWTTextEditorDemo.htm to write an editor that supports HTML and RTF.

Let's bring SWT in to world of Web2.0 and support HTML editing.
Comment 1 Steve Northover CLA 2007-12-17 14:32:24 EST
*** Bug 98904 has been marked as a duplicate of this bug. ***
Comment 2 Steve Northover CLA 2007-12-17 14:35:04 EST
Why not use the Browser to render HTML?  Browsers can also be flipped into HTLM editor mode.  We should consider this instead of implemeting an HTML renderer for StyledText.
Comment 3 Ozzie CLA 2007-12-20 16:46:20 EST
(In reply to comment #2)

I don't know of any way of making the SWT Browser "flip into editor mode".  I know that on windows SWT embeds the WebBrowser COM control which does not have any editting capabilities.  I know of a couple of OpenSource projects that have attempted to resolve this problem by embedding the Windows DHTMLEDIT COM control but this is very platform specific.
Comment 4 Steve Northover CLA 2008-01-08 18:31:33 EST
Grant, you had code around that turned on HTML editor mode, at least for Mozillam, right?
Comment 5 Grant Gayed CLA 2008-01-09 09:55:44 EST
> Grant, you had code around that turned on HTML editor mode

yes, see http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet267.java
Comment 6 Ozzie CLA 2008-01-16 01:25:40 EST
(In reply to comment #5)
Thanks Grant, this offers a great workaround.  I cannot use this unfortunately since I cannot be sure that my users will have Mozilla installed on their desktop.

I would still very much like to see a fully integrated WYSIWYG HTML editor in SWT.

Comment 7 Steve Northover CLA 2008-01-16 10:13:34 EST
Grant, is it true that all the browsers we support have a WYSIWYG mode?
Comment 8 Grant Gayed CLA 2008-01-16 10:38:24 EST
IE has a WYSISYG mode, though I don't think there's currently a way for a Browser client to turn it on.  I don't know about Safari.

> I cannot be sure that my users will have Mozilla installed on their
> desktop

If this is the only problem with this approach then you can ship the xulrunner plug-in with your app and point the Browser at it by setting the org.eclipse.swt.browser.XULRunnerPath system property.  Not everyone wants to do this since the plug-in will grow your app by 6M (on win32) to 17M (on OSX), but it seemed work mentioning.  If you want to pursue this there's lots of xulrunner-related info at http://www.eclipse.org/swt/faq.php .
Comment 9 Ozzie CLA 2008-01-20 01:43:42 EST
I suspect we are getting off track.  There are several different workarounds to this missing feature.  I found 3 projects on sourceforge and at least one commercial solution.

My intent with this is to request that the Eclipse SWT team consider a formal multi-platform api to support HTML WYSIWYG, since I firmly believe that HTML editing will (if not already) be an important part of any widget library.
Comment 10 Carolyn MacLeod CLA 2008-02-20 10:37:05 EST
I think the WTP project already has html editors.
http://www.eclipse.org/webtools/
Comment 11 Ozzie CLA 2008-02-22 21:51:47 EST
(In reply to comment #10)
> I think the WTP project already has html editors.
> http://www.eclipse.org/webtools/

Yes I think you are correct.  The Web Tools Project does have a HTML editor plug-in which is great for users of Eclipse but of little use to SWT developers.
Comment 12 Heath Borders CLA 2008-08-15 14:58:24 EDT
I'd rather not see an already huge StyledText API grow to encompass HTML editing.  This seems like a perfect reason to migrate your app from swt to rcp, and reap the benefits of WTP's work.
Comment 13 Ozzie CLA 2008-12-13 17:07:50 EST
(In reply to comment #12)

I don't think this will complicate the StyleText api.  I would imagine that it's a separate classes perhaps called StyledTextHTMLWriter/HTMLReader similar to the existing RTFWriter, except not an inner class, perhaps optionally used in place of RTFWriter for clipboard transfers.

I was dissapointed to see that this was not included in the SWT 3.5 StyledText enhancements. 

Lots of people are trying to solve this problem.  Here are a few links;

http://www.richclient2.eu/richhtml4eclipse/ 
This idea is to embed a html WYSIWYG editor using the browser.  Great idea but doesn't work on some platforms, in partiuclar Ubuntu.

http://www.dugaldmorrow.com/index.php?option=com_content&task=blogcategory&id=24&Itemid=44
This product is almost exactly what I am proposing.  It has a few missing features (eg: justification) and is not open source so we can't add them.

http://sourceforge.net/projects/swt-composer/
http://sourceforge.net/projects/swteditor/
A couple of other open source projects that attempt different ways to solve this problem.
Comment 14 Felipe Heidrich CLA 2008-12-15 11:01:07 EST
(In reply to comment #13)
> I don't think this will complicate the StyleText api.  I would imagine that
> it's a separate classes perhaps called StyledTextHTMLWriter/HTMLReader similar
> to the existing RTFWriter, except not an inner class, perhaps optionally used
> in place of RTFWriter for clipboard transfers.

StyledText doesn't support tables, HTML without tables won't be very interesting.

Adding table support to StyledText would be a major effort.
Comment 15 Felipe Heidrich CLA 2009-08-14 08:56:12 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 16 Christian Sell CLA 2010-10-04 15:20:05 EDT
the TextEditor example demonstrates ways to enhance/use StyledText in such a way that even embedded pictures are possible. That could be a way to add tables as well - although it would be much nicer if this was possible through a plugin architecture in StyledText proper rather than in a wrapper class.

However, such attempts are often rendered void as long as major parts of StyledText remain (package-)private, and thus cannot be used/overridden by user code.

I for my part was considering to add advanced RTF styling capabilities. But since I cannot get at the RTFWriter during copy/paste (and the default RTFWiter is very weak), I am stuck right here.
Comment 17 Felipe Heidrich CLA 2010-10-12 15:08:53 EDT
HTML support for StyledText is in the plan for 3.7, sorry.

Can you use the Browser widget + some free html editor for the web ?


StyledText's RTFWriter can only implement RTF styling capabilities that are available in StyledText. I don't understand how you can add an advanced RTF styling without extending StyledText first.
Comment 18 Felipe Heidrich CLA 2010-10-12 15:29:12 EDT
(In reply to comment #17)
> HTML support for StyledText is in the plan for 3.7, sorry.

I meant to say, it is *not* in the plan. Sorry.
Comment 19 Gerald Rosenberg CLA 2010-10-12 16:17:54 EDT
(In reply to comment #18)
> (In reply to comment #17)
> > HTML support for StyledText is in the plan for 3.7, sorry.
> 
> I meant to say, it is *not* in the plan. Sorry.

So, who should I contact to discuss contributing an HTML editor and CSS query engine?  These components have been used for some time in my JDocEditor plugin.

The editor extends StyledText directly to add markup recognition inline.  Included CSS markup is evaluated against standard stylesheets.
Comment 20 Felipe Heidrich CLA 2010-10-12 16:30:41 EDT
> So, who should I contact to discuss contributing an HTML editor and CSS query
> engine?  

http://www.eclipse.org/nebula/
Comment 21 Christian Sell CLA 2010-10-20 05:03:21 EDT
(In reply to comment #19)
> The editor extends StyledText directly to add markup recognition inline. 

Extending StyledText as it currently exists is bound to lead to severe restrictions IMO. E.g, you wont be able to override Copy/Paste behavior, since the related code is private. And the default implementation for copy/paste of styled text is based on a very limited set of RTF attributes
Comment 22 Gerald Rosenberg CLA 2010-10-20 12:59:04 EDT
(In reply to comment #21)
> (In reply to comment #19)
> > The editor extends StyledText directly to add markup recognition inline. 
> 
> Extending StyledText as it currently exists is bound to lead to severe
> restrictions IMO. E.g, you wont be able to override Copy/Paste behavior, since
> the related code is private. And the default implementation for copy/paste of
> styled text is based on a very limited set of RTF attributes

Yes, StyledText does impose limitations.  The most significant is: no internal DIVs.  As is, a single StyledHtml instance is essentially a WYSIWYG text area.  DIVs might be possible by embedding one or more StyledHtmls in another - have not tried yet.  

Copy/paste of HTML marked up text works quite well.  The copy/paste handlers could be adapted to support RTF->HTML and HTML->RTF conversion.

To be clear, StyledHtml embeds zero-width, non-breaking spaces into the StyledText contents.  They are used as pointers into a table of unreduced HTML markup tags extracted from the HTML-in.  So, all stylesheet and HTML markup is preserved and interpreted on-the-fly using CSSQuery to determine the StyledText presentation.  HTML-out preserves the HTML-in markup subject to edits made.

Is this an adequate/appropriate approach to adding HTML support to be worth contributing?  Thanks...