super_editor
super_editor copied to clipboard
[BUG] - Bold formatting not applied in normal paragraphs
Package Version
super_editor: 0.3.0-dev.13
super_editor_markdown: ^0.1.7
User Info
Using SuperEditor inside a mobile app to let users edit AI-generated summaries of transcribed audio recordings.
To Reproduce
- Load a
SuperEditorwith aMutableDocumentandMutableDocumentComposer. - Place the selection inside a normal paragraph (not a list item or blockquote).
- Click the bold button from a toolbar — it doesn’t matter whether the text is selected or the cursor is collapsed.
- Type or inspect the selected text.
📝 Note:
- This issue only affects normal paragraphs.
- Bold works fine in list items, blockquotes, and other block types.
- Italic and strikethrough work perfectly in all contexts, including paragraphs.
Minimal Reproduction Code
Minimal, Runnable Code Sample
final _document = MutableDocument(nodes: []);
final _composer = MutableDocumentComposer();
final _docEditor = createDefaultDocumentEditor(
document: _document,
composer: _composer,
isHistoryEnabled: true,
);
final _commonOps = CommonEditorOperations(
document: _document,
editor: _docEditor,
composer: _composer,
documentLayoutResolver: () => _layoutKey.currentState! as DocumentLayout,
);
void toggleBold() {
final selection = _composer.selection;
final attributions = {boldAttribution};
if (selection == null) return;
if (selection.isCollapsed) {
_commonOps.toggleComposerAttributions(attributions);
} else {
_commonOps.toggleAttributionsOnSelection(attributions);
}
}
Stylesheet customStyleSheet(AppTheme theme) => defaultStylesheet.copyWith(
inlineTextStyler: (attributions, baseStyle) {
var style = baseStyle;
if (attributions.contains(boldAttribution)) {
style = style.merge(const TextStyle(fontWeight: FontWeight.bold));
}
if (attributions.contains(italicsAttribution)) {
style = style.merge(const TextStyle(fontStyle: FontStyle.italic));
}
if (attributions.contains(strikethroughAttribution)) {
style = style.merge(const TextStyle(decoration: TextDecoration.lineThrough));
}
return style;
},
);
Actual Behavior
When the bold button is toggled inside a normal paragraph, bold formatting does not get applied — regardless of whether text is selected or the cursor is collapsed. Typed text appears in normal weight, and selected text doesn’t change visually.
Expected Behavior
Bold formatting should work the same as italic and strikethrough:
- If text is selected, it should apply to the selected text.
- If the cursor is collapsed, all newly typed text should retain the bold attribution until toggled off.
Platform
Tested on:
- iOS (real device: iPhone 13, iOS 18.5)
Flutter Version
Flutter 3.29.0 • channel stable
Framework • revision 35c388afb5 • 2025-02-10
Engine • revision f73bfc4522
Dart 3.7.0
Additional Context
- This happens consistently in normal paragraphs.
- The composer and editor are initialized using the recommended
createDefaultDocumentEditorandMutableDocumentComposer. - Attributions are correctly applied to
composer.preferences.currentAttributions. - The style is defined in
inlineTextStylerand is applied correctly for other attributions like italics and strikethrough.
@yagoquesadafloriach Is this reproducible in the example app?