Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: remove attribute if it already exists on the node

Alexandre Moreau5d2ff8e07c1d
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart
index 0229d2270f..93ef3ebea9 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart
@@ -108,7 +108,16 @@ bool formatTextNodes(EditorState editorState, Attributes attributes) {
newAttributes[globalStyleKey] = null;
}
}
- newAttributes.addAll(attributes);
+
+ // if an attribute already exists in the node, it should be removed instead
+ for (final entry in attributes.entries) {
+ if (textNode.attributes.containsKey(entry.key) &&
+ textNode.attributes[entry.key] == entry.value) {
+ // attribute is not added to the node new attributes
+ } else {
+ newAttributes.addEntries([entry]);
+ }
+ }
transaction
..updateNode(
textNode,