JavaFX WebView & JavaFX HTMLEditor: A Tale of Two Cities
By Geertjan-Oracle on Jun 11, 2013
Tough times in the world of Fosfor, the EPUB Open Toolbox. Turns out that while the JavaFX WebView has perfect rendering but no editing capabilities, the JavaFX HTMLEditor has perfect editing capabilities but crap rendering.
Exhibit one is right here, with the JavaFX HTMLEditor on the left and the JavaFX WebView on the right, rendering the same XHTML file:
As can be seen, the images, CSS, and entities defined in the XHTML file above are perfectly rendered in WebView, but not at all in the HTMLEditor. It seems to me that the HTMLEditor is meant for rendering text only, nothing else.
I then hacked my own HTMLEditor on top of the JavaFX HTMLEditor, which searches through all the text prior to rendering and uses the file protocol to locally locate images and CSS:
The result is as follows, i.e., I've fixed the images and CSS problem, but not the entities, yet:
In short, I'm going to try and create a set of service providers for a "fixHTMLEditorRendering" service which will pre-process images, CSS, and HTML entities prior to them being rendered in the JavaFX HTMLEditor. Then, when saving the file back to EPUB, I'm going to have to reverse the process.
Not ideal, but I think it's workable.