-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SuperEditor] Add list item customization via stylesheet (Resolves #1912) #2017
Conversation
@@ -189,6 +194,10 @@ class ListItemComponentViewModel extends SingleColumnLayoutComponentViewModel wi | |||
required this.type, | |||
this.ordinalValue, | |||
required this.indent, | |||
this.dotColor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm noticing that these properties are the first situation where this view model doesn't apply equally to both types of list items. Looks like we should split this view model into two - one for ordered list items and one for unordered list items.
It might make sense to create a shared superclass that has everything but those dot and numeral styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
if (node.type == ListItemType.unordered) { | ||
return UnorderedListItemComponentViewModel( | ||
nodeId: node.id, | ||
indent: node.indent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be initializing these with default dot and numeral choices?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor already have default values for that, so I think we could omit them.
@@ -385,6 +534,10 @@ Widget _defaultUnorderedListItemDotBuilder(BuildContext context, UnorderedListIt | |||
final attributions = component.text.getAllAttributionsAt(0).toSet(); | |||
final textStyle = component.styleBuilder(attributions); | |||
|
|||
final dotColor = component.dotStyle?.color ?? textStyle.color; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason that these values aren't set inline within the widget tree? Do we need variables for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the dot size I think it makes sense because we need access both width and height. I removed the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[SuperEditor] Add list item customization via stylesheet. Resolves #1912
This PR adds the ability to customize list items using stylesheets.
Customization for unordered list items:
Customization for ordered list items:
For roman numbers, we support until 3999 and them switch to arabic. I tried the w3 playground in https://www.w3schools.com/css/tryit.asp?filename=trycss_list-style-type_ex and it seems that html lists also work like that.
CSS list style references: https://www.w3schools.com/css/css_list.asp