mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: # doesn't work #937
This commit is contained in:
parent
0f334962ce
commit
8afa48ca16
@ -38,7 +38,6 @@ class HeadingTextNodeWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// customize
|
// customize
|
||||||
|
|
||||||
class _HeadingTextNodeWidgetState extends State<HeadingTextNodeWidget>
|
class _HeadingTextNodeWidgetState extends State<HeadingTextNodeWidget>
|
||||||
with Selectable, DefaultSelectable {
|
with Selectable, DefaultSelectable {
|
||||||
@override
|
@override
|
||||||
|
@ -79,7 +79,10 @@ Map<String, double> headingToFontSize = {
|
|||||||
|
|
||||||
extension NodeAttributesExtensions on Attributes {
|
extension NodeAttributesExtensions on Attributes {
|
||||||
String? get heading {
|
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 this[StyleKey.heading];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:appflowy_editor/src/render/rich_text/rich_text_style.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
@ -29,7 +30,8 @@ KeyEventResult _handleBackspace(EditorState editorState, RawKeyEvent event) {
|
|||||||
if (textNode.subtype != null) {
|
if (textNode.subtype != null) {
|
||||||
transactionBuilder
|
transactionBuilder
|
||||||
..updateNode(textNode, {
|
..updateNode(textNode, {
|
||||||
'subtype': null,
|
StyleKey.subtype: null,
|
||||||
|
textNode.subtype!: null,
|
||||||
})
|
})
|
||||||
..afterSelection = Selection.collapsed(
|
..afterSelection = Selection.collapsed(
|
||||||
Position(
|
Position(
|
||||||
|
@ -234,6 +234,38 @@ void main() async {
|
|||||||
(tester) async {
|
(tester) async {
|
||||||
await _deleteLastImage(tester, false);
|
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 {
|
Future<void> _deleteFirstImage(WidgetTester tester, bool isBackward) async {
|
||||||
|
Loading…
Reference in New Issue
Block a user