# Support for Embedded Images, Text Highlights, Wavy Underlines

## Summary

This PR adds new attributes to support embedded images, text highlights, and 
wavy underlines.

The `RichEditorDemoApp` gains new context menus and enables drag and drop to 
showcase the new functionality.

<img width="768" height="703" alt="Screenshot 2026-06-18 at 12 40 28" 
src="https://github.com/user-attachments/assets/678bdbac-6582-46ee-bd41-ea938df930bb";
 />



## Problem

Among the feedback received after publishing the RichTextArea incubating 
module, a number of users complained about the need to support embedded images. 
 Other users complained about difficulty to get the text highlighted or wavy 
underlined, and having these decorations controlled via CSS.


## Solution

Support for images was intentionally missing in the initial release; this PR 
adds the feature.

Adding highlights and underlines is a bit more complicated, for several 
reasons.  One reason is that the existing highlighting mechanism supports 
mixing of arbitrary number of translucent colors - something that is pretty 
much impossible to do with CSS alone.

A useful compromise is to offer a limited number of standard attributes that 
can be controlled via CSS: 5 highlights and 3 wavy underlines.


## Specification


### StyleAttributeMap Attributes

New attributes:
- EMBEDDED_IMAGE
- TEXT_HIGHLIGHT_1 ... TEXT_HIGHLIGHT_5
- UNDERLINE_WAVY_1 ... UNDERLINE_WAVY_3

### CSS Styling

The styling of highlights and wavy underlines is determined by the stylesheet 
and can be changed by the user.

The style selectors are:

`.rich-text-area .text-highlight-1` ... `.rich-text-area .text-highlight-5`
`.rich-text-area .underline-wavy-1` ... `.rich-text-area .underline-wavy-3`


### New Public APIs

`EmbeddedImage`
`FileListFormatHandler`
`StyleAttribute.inlineNode()`
`StyleAttribute.isInlineNode()`
`StyledSegment.ofInlineNode()`
`CellContext.RunDecor`
`CellContext.decorateRun()`
`RichTextArea.dropTargetProperty`
`RichTextArea.clearDropTarget()`
`RichTextArea.getStyleAttributeMap()`


### File Format Changes

The data transfer format (also used by the demo app to save the .rich files) 
version string is changed, making the old files unreadable.

Perhaps it should remain unchanged for the duration of the incubation period.  
See also [2]


### Breaking API Changes

`DataFormatHandler.createStyledInput()`
`StyledTextModel.getStyleAttributeMap()`


## Testing

In addition to the `RichEditorDemoApp`, the standalone Monkey Tester [1] 
provides additional options via context menu in the `RichTextArea` page.




## References

[0] [RichTextArea DataFormat 
(Incubator)](https://github.com/andy-goryachev-oracle/jfx/blob/8366198.new.attributes/doc-files/controls/RichTextArea/RichTextArea_DataFormat_Incubator.md)

[1] [Monkey Tester with added support for the new 
attributes](https://github.com/andy-goryachev-oracle/MonkeyTest/tree/8366198.attributes)

[2] [JDK-8386850 [StyledTextModel] rethink marshalling 
mechanism](https://bugs.openjdk.org/browse/JDK-8386850)

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - cleanup
 - embedded images, text highlights, wavy underlines

Changes: https://git.openjdk.org/jfx/pull/2196/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=2196&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8366198
  Stats: 2303 lines in 51 files changed: 2015 ins; 103 del; 185 mod
  Patch: https://git.openjdk.org/jfx/pull/2196.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/2196/head:pull/2196

PR: https://git.openjdk.org/jfx/pull/2196

Reply via email to