RFR: 8301121: RichTextArea Control (Incubator) [v19]
Kevin Rushforth
kcr at openjdk.org
Fri Oct 4 18:26:41 UTC 2024
On Fri, 4 Oct 2024 18:23:29 GMT, Andy Goryachev <angorya 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**.
>>
>> Because it's an incubating module, please focus on the public APIs rather than implementation. There **will be** changes to the implementation once/if the module is promoted to the core by popular demand. The goal of the incubator is to let the app developers try the new feature out.
>>
>> **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
>
> Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
>
> ensure cell is in the arrangement
Following up on the earlier question I asked about how to create a StyleAttributeMap from a CSS style:
> CSS styles in StyleAttributeMap are a special case, the attribute itself is not public (`com.sun.jfx.incubator.scene.control.richtext.CssStyles.CSS`). I've added additional explanations to the `StyledTextModel` class:
>
> ```
> * <h2>Creating a Paragraph</h2>
> ...
> ```
Thanks for the explanation. I can see why it would make sense to not expose CSS in the `StyleAttributeMap` class, but instead have the view-only model do it.
As a consequence of this, the following example from the `RichTextArea` class docs (also found in the JEP) using a `SimpleViewOnlyStyledModel` with inline CSS styles is no longer possible:
SimpleViewOnlyStyledModel m = new SimpleViewOnlyStyledModel();
// add text segment using CSS style name (requires a style sheet)
m.addSegment("RichTextArea ", null, "HEADER");
// add text segment using direct style
m.addSegment("Demo", "-fx-font-size:200%;", null);
// newline
m.nl();
RichTextArea textArea = new RichTextArea(m);
You will either need additional methods in `SimpleViewOnlyStyledModel` to restore this functionality or rework the demo in the RTA docs (and JEP) to not use CSS. I recommend the former unless there is a good reason you can't.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1524#issuecomment-2394331862
More information about the openjfx-dev
mailing list