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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: # doesn't work #937
Lucas.Xu8afa48ca1620
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dartindex fff25dd2d5..93defaae8e 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dart@@ -38,7 +38,6 @@ class HeadingTextNodeWidget extends StatefulWidget {}// customize-class _HeadingTextNodeWidgetState extends State<HeadingTextNodeWidget>with Selectable, DefaultSelectable {@overridediff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dartindex 93d088d66f..2cd03fe389 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dart@@ -79,7 +79,10 @@ Map<String, double> headingToFontSize = {extension NodeAttributesExtensions on Attributes {String? get heading {- if (containsKey(StyleKey.heading) && this[StyleKey.heading] is String) {+ if (containsKey(StyleKey.subtype) &&+ containsKey(StyleKey.heading) &&+ this[StyleKey.subtype] == StyleKey.heading &&+ this[StyleKey.heading] is String) {return this[StyleKey.heading];}return null;diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dartindex 0eeaf654de..675ee5b446 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dart@@ -1,3 +1,4 @@+import 'package:appflowy_editor/src/render/rich_text/rich_text_style.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';@@ -29,7 +30,8 @@ KeyEventResult _handleBackspace(EditorState editorState, RawKeyEvent event) {if (textNode.subtype != null) {transactionBuilder..updateNode(textNode, {- 'subtype': null,+ StyleKey.subtype: null,+ textNode.subtype!: null,})..afterSelection = Selection.collapsed(Position(diff --git a/frontend/app_flowy/packages/appflowy_editor/test/service/internal_key_event_handlers/backspace_handler_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/service/internal_key_event_handlers/backspace_handler_test.dartindex 1976ec3250..da5d22a786 100644--- a/frontend/app_flowy/packages/appflowy_editor/test/service/internal_key_event_handlers/backspace_handler_test.dart+++ b/frontend/app_flowy/packages/appflowy_editor/test/service/internal_key_event_handlers/backspace_handler_test.dart@@ -234,6 +234,38 @@ void main() async {(tester) async {await _deleteLastImage(tester, false);});++ testWidgets('Removes the style of heading text and revert', (tester) async {+ const text = 'Welcome to Appflowy 😁';+ final editor = tester.editor..insertTextNode(text);+ await editor.startTesting();++ await editor.updateSelection(+ Selection.single(path: [0], startOffset: 0),+ );++ final textNode = editor.nodeAtPath([0]) as TextNode;++ await editor.insertText(textNode, '#', 0);+ await editor.pressLogicKey(LogicalKeyboardKey.space);+ expect(+ (editor.nodeAtPath([0]) as TextNode).attributes.heading,+ StyleKey.h1,+ );++ await editor.pressLogicKey(LogicalKeyboardKey.backspace);+ expect(+ textNode.attributes.heading,+ null,+ );++ await editor.insertText(textNode, '#', 0);+ await editor.pressLogicKey(LogicalKeyboardKey.space);+ expect(+ (editor.nodeAtPath([0]) as TextNode).attributes.heading,+ StyleKey.h1,+ );+ });}Future<void> _deleteFirstImage(WidgetTester tester, bool isBackward) async {