RFR: 8301121: RichTextArea Control (Incubator)
Andy Goryachev
angorya at openjdk.org
Wed Jul 31 15:11:38 UTC 2024
On Wed, 31 Jul 2024 13:01:05 GMT, danielpeintner <duke at openjdk.org> wrote:
>> Incubating a new feature - rich text control, **RichTextArea**, intended to bridge the functional gap with Swing and its StyledEditorKit/JEditorPane. The main design goal is to provide a control that is complete enough to be useful out-of-the box, as well as open to extension by the application developers.
>>
>> This is a complex feature with a large API surface that would be nearly impossible to get right the first time, even after an extensive review. We are, therefore, introducing this in an incubating module, **jfx.incubator.richtext**. This will allow us to evolve the API in future releases without the strict compatibility constraints that other JavaFX modules have.
>>
>> Please check out two manual test applications - one for RichTextArea (**RichTextAreaDemoApp**) and one for the CodeArea (**CodeAreaDemoApp**). Also, a small example provides a standalone rich text editor, see **RichEditorDemoApp**.
>>
>> **References**
>>
>> - Proposal: https://github.com/andy-goryachev-oracle/Test/blob/main/doc/RichTextArea/RichTextArea.md
>> - Discussion points: https://github.com/andy-goryachev-oracle/Test/blob/main/doc/RichTextArea/RichTextAreaDiscussion.md
>> - API specification (javadoc): https://cr.openjdk.org/~angorya/RichTextArea/javadoc
>> - RichTextArea RFE: https://bugs.openjdk.org/browse/JDK-8301121
>> - Behavior doc: https://github.com/andy-goryachev-oracle/jfx/blob/8301121.RichTextArea/doc-files/behavior/RichTextAreaBehavior.md
>> - CSS Reference: https://cr.openjdk.org/~angorya/RichTextArea/javadoc/javafx.graphics/javafx/scene/doc-files/cssref.html
>> - InputMap (v3): https://github.com/andy-goryachev-oracle/Test/blob/main/doc/InputMap/InputMapV3.md
>> - Previous Draft PR: https://github.com/openjdk/jfx/pull/1374
>
> modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/RichTextArea.java line 157:
>
>> 155: * @since 999 TODO
>> 156: */
>> 157: public class RichTextArea extends Control {
>
> The *old* `TextField` and `TextArea` controls extend `TextInputControl`.
>
> I wonder whether there is a a _good_ reason not doing the same for `RichTextArea`?
> Doing so would allow to more easily switch between one or the other.
Thank you for a very good question!
The main reason is that RichTextArea (RTA) can work with a large text model which needs to be represented differently from **TextInputControl**'s simple String **text** property. Other things, like position within the text is also very different, using `{paragraphIndex,charOffset}` instead of a simple `int` offset. The fact that the model is separated from the control also makes it very different.
At the end, there is simply no benefit in dragging the `TextInputControl` into the picture.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1524#discussion_r1698684416
More information about the openjfx-dev
mailing list