CodeArea (almost) ready to support a rich-text editor
tomas.mikula at gmail.com
Wed Jan 29 07:25:35 PST 2014
I put together a prototype of a rich-text editor based on CodeAreaFX:
On Thu, Dec 19, 2013 at 7:47 PM, Tomas Mikula <tomas.mikula at gmail.com>wrote:
> I made a bunch of improvements to CodeArea , most notably two:
> 1. line wrapping
> 2. arbitrary (generic) style information (instead of just style classes
> before). Your style information can be anything, as long as you provide a
> way (read lambda function) to either
> a) convert it to a CSS string; or
> b) apply it directly to a Text node.
> This means that CodeArea can now support a rich-text editor.
> What you might be missing is paragraph-level styles (for e.g. headings,
> text alignment) and that Undo now works on plain text, so if you undo an
> redo, you lose your style information. These will be coming in the next
> year, so you can start hacking your rich-text editor now.
>  https://github.com/TomasMikula/CodeAreaFX
> On Wed, Oct 9, 2013 at 1:39 AM, Tomas Mikula <tomas.mikula at gmail.com>wrote:
>> Thanks, Jonathan.
>> On Tue, Oct 8, 2013 at 9:08 PM, Jonathan Giles
>> <jonathan.giles at oracle.com> wrote:
>> > Tomas,
>> > Very nice work! :-)
>> > The first step in the process to contribute features / bug fixes back
>> > into OpenJFX is to create a Jira issue (or find one that covers the
>> > topic). In the case of styled text ranges I don't believe a Jira issue
>> > exists, so feel free to open a new issue. This will be the way we can
>> > see what is popular and still outstanding in JavaFX, and of course
>> > discuss details.
>> > I'm not clear on how closely your approach is related to Tom's, but
>> > perhaps there is sufficient overlap there that you can collaborate.
>> I think the main differences are:
>> 1. Tom's StyledTextArea assigns styles, while my CodeArea assigns
>> style classes. I think my approach is easier to work with, but less
>> powerful (you can only use styles pre-defined in a stylesheet, thus
>> you can't implement a rich text editor on top of CodeArea).
>> 2. StyledTextArea's API assigns styles for the whole content at once,
>> CodeArea assigns one range at a time. I think both approaches have
>> their use and I plan to add support for batch assignment for
>> performance reasons.
>> 3. AFAIK, StyledTextArea does not support text selection.
>> 4. Compared to TextArea, CodeArea supports detailed change events
>> (which part of text was replaced) via TextChangeListener
>> Not sure about StyledTextArea.
>> > This
>> > may help to improve your API and implementation prior to it being
>> > considered for integration into OpenJFX, and will of course help to
>> > prevent duplication of effort.
>> I don't consider the API to be final, quite opposite, I expect changes
>> arising from the community and from my own needs. I'm open to feedback
>> and suggestions.
>> > Keep up the great work and be sure to keep me in the loop of your
>> > progress :-)
>> > -- Jonathan
>> > On 8/10/2013 2:48 a.m., Tomas Mikula wrote:
>> >> Hi all,
>> >> I implemented a text control that supports assigning style classes to
>> >> portions of text. It is meant to be used for syntax highlighting.
>> >> https://github.com/TomasMikula/CodeAreaFX
>> >> The code is based on the original TextArea code. This implies the
>> >> license to be GPLv2 with the Classpath Exception. I would be happy to
>> >> contribute it back to the OpenJFX project.
>> >> The idea of using a ListView of TextFlows is borrowed from Tom
>> >> Schindl's StyledTextArea
>> >> (http://fxexperience.com/2013/02/interview-with-tom-schindl-2/).
>> >> Check out the demos and the APIs. Feedback really appreciated. Any
>> >> help with the issues
>> >> (https://github.com/TomasMikula/CodeAreaFX/wiki/Known-Issues) would be
>> >> awesome.
>> >> Best,
>> >> Tomas
More information about the openjfx-dev