RichTextFX icon indicating copy to clipboard operation
RichTextFX copied to clipboard

Support for numbered and unnumbered Lists

Open afester opened this issue 8 years ago • 10 comments

It should be possible to define numbered and unnumbered, nested lists. Each paragraph in the list would serve as a list item, the paragraph would be indented according to its level inside the nested list, and optionally prepended either with a level specific bullet (ideally defineable by CSS) or a numeric value, either as single numbers or as combined numbers (like 1., 1.1, 1.2, 1.2,1 etc).

This requires enhancements in the data model (optionally allowing to add each paragraph to a List) and in the rendering layer (indenting ParagraphText and adding the bullet node). It also requires some adjustments in the behaviour of the component: When pressing enter inside a paragraph which is part of a List, the new Paragraph will become a list item of the same List.

afester avatar Oct 18 '16 19:10 afester

How should this be implemented?

Would we be generifying the Paragraph similarly to how we generified the Segment? In which case, rather than a list of Paragraphs, we would have a list of generic lines. A line could be a List that could contain another List (for nested lists) or a Paragraph (for the actual item itself). For example

public class StyledTextArea<Line, LS, Seg, S> {
    // rather than "getParagraphs()" this would now be
    public List<Line> getLines();
}

// thus generifying the Paragraph to be
StyledTextArea<
    // paragraph is now lines
    Either<NestedList, Paragraph<String>>, String, 
    // your custom object support
    Either<StyledText<String>, Image>, String>
> area = //;

JordanMartinez avatar Oct 19 '16 00:10 JordanMartinez

Would we be generifying the Paragraph similarly to how we generified the Segment?

Ah no, I am still busy with unscrambling the knots in my head, caused by all those generic types from the Segment implementation :joy:

My current thinking is that a Paragraph must not be as generic as a Segment - and a Paragraph's list structure is more tied to the Paragraph's style than to its type. The current approach is to add an Optional<ListItem> to a Paragraph, which can be passed around when creating new derived Paragraphs (when splitting, joining etc.). The ListItem can then further reference to some List object which further defines the structure of the List (this is especially required for hierarchically numbered Lists). But, let's discuss any other reasonable approach ...

My playground for this enhancement is https://github.com/afester/RichTextFX/tree/paragraphBullets. It already implements indentation of single paragraphs and rendering for level dependent bullets:

image

Its still a draft only, with many hard coded pieces, just to get an idea where to implement the various bits&pieces.

afester avatar Oct 24 '16 10:10 afester

Does a simple example exist yet for doing this?

stevedefazio avatar Sep 01 '17 12:09 stevedefazio

Unfortunately, no. afester's playground is probably the best place to start.

JordanMartinez avatar Sep 01 '17 16:09 JordanMartinez

I also urgently need this feature. afester's example must have been deleted.

dlemmermann avatar Oct 20 '17 14:10 dlemmermann

afester's example must have been deleted

Seems to be still there in the paragraphBullets branch in his repo: https://github.com/afester/RichTextFX/tree/paragraphBullets

JFormDesigner avatar Oct 20 '17 14:10 JFormDesigner

I do not see it …. any class inside this branch I should look at?

On 20 Oct 2017, at 16:40, JFormDesigner [email protected] wrote:

afester's example must have been deleted

Seems to be still there in the paragraphBullets branch in his repo: https://github.com/afester/RichTextFX/tree/paragraphBullets https://github.com/afester/RichTextFX/tree/paragraphBullets — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/FXMisc/RichTextFX/issues/384#issuecomment-338226013, or mute the thread https://github.com/notifications/unsubscribe-auth/AJF7XVeI01ZL9eVX8QPXZxazaGUf_4iLks5suLDNgaJpZM4KaNyb.

dlemmermann avatar Oct 20 '17 14:10 dlemmermann

Sorry, don't know... never used it

JFormDesigner avatar Oct 20 '17 14:10 JFormDesigner

I'd check out a local branch of the build, and see where ListItem is used throughout it. That's the only class that doesn't appear normally in the code, so he must have added it. That will probably lead you to other classes where he's made some changes.

JordanMartinez avatar Oct 20 '17 15:10 JordanMartinez

Note: The RichTextDemo meanwhile supports bullets (see #850). Probably this is sufficient for this enhancement request - I would like to check if this can be extended to numbered lists though.

afester avatar Sep 18 '21 20:09 afester