Skip to content
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

customStyleBuilder Does Not Accumulate Styles for Multiple Attributes #2425

Open
1 task done
manudicri opened this issue Jan 1, 2025 · 1 comment · May be fixed by #2447
Open
1 task done

customStyleBuilder Does Not Accumulate Styles for Multiple Attributes #2425

manudicri opened this issue Jan 1, 2025 · 1 comment · May be fixed by #2447
Assignees
Labels
minor Minimal impact or cosmetic issue. Can be resolved at a later time without affecting overall function question Further information is requested

Comments

@manudicri
Copy link

Is there an existing issue for this?

The question

The customStyleBuilder in flutter_quill does not accumulate styles when multiple attributes are applied to the same text. Instead, it processes each attribute independently, leading to only the last attribute being applied. This behavior makes it impossible to correctly combine styles like bold, italic, underline, and custom font sizes.

Steps to Reproduce

Create a QuillEditor with a customStyleBuilder to handle custom styles.
Apply multiple styles (e.g., bold, italic, and size) to the same text.
Observe that only one of the styles is applied (the last one processed).

Expected Behavior

All styles (bold, italic, underline, size, etc.) should be combined into a single TextStyle and applied simultaneously to the text.

Actual Behavior

Only one style (the last one processed by customStyleBuilder) is applied, overriding any previously applied styles.

Example Code

configurations: QuillEditorConfigurations(
  customStyleBuilder: (attribute) {
    // basically settings.fontSize is the size factor of a zoom mechanism already implemented, so i can make the text larger or smaller by pinching the screen, without modifying the quill editor document
    TextStyle style = DefaultTextStyle.of(context).style.copyWith(fontSize: settings.fontSize * 20);

    if (attribute.key == "bold" && attribute.value == true) {
      style = style.copyWith(fontWeight: FontWeight.bold);
    }
    if (attribute.key == "italic" && attribute.value == true) {
      style = style.copyWith(fontStyle: FontStyle.italic);
    }
    if (attribute.key == "underline" && attribute.value == true) {
      style = style.copyWith(decoration: TextDecoration.underline);
    }
    // the thing I need the most, specific size attribute 
    if (attribute.key == "size") {
      final size = double.parse(attribute.value.toString());
      style = style.copyWith(fontSize: settings.fontSize * size);
    }

    return style;
  },
)

(read comments)

Can you help me with this? Thank you so much

@manudicri manudicri added the question Further information is requested label Jan 1, 2025
@CatHood0 CatHood0 self-assigned this Jan 10, 2025
@CatHood0 CatHood0 added the minor Minimal impact or cosmetic issue. Can be resolved at a later time without affecting overall function label Jan 10, 2025
@CatHood0
Copy link
Collaborator

CatHood0 commented Jan 10, 2025

I'll take care about this. Thanks for reporting it.

@CatHood0 CatHood0 linked a pull request Jan 19, 2025 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Minimal impact or cosmetic issue. Can be resolved at a later time without affecting overall function question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants