mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: prevent to copy the style in some cases when pressing the enter key in the front of the text
This commit is contained in:
@ -117,12 +117,17 @@ ShortcutEventHandler enterWithoutShiftInTextNodesHandler =
|
|||||||
makeFollowingNodesIncremental(editorState, insertPath, afterSelection,
|
makeFollowingNodesIncremental(editorState, insertPath, afterSelection,
|
||||||
beginNum: prevNumber);
|
beginNum: prevNumber);
|
||||||
} else {
|
} else {
|
||||||
|
bool needCopyAttributes = ![
|
||||||
|
BuiltInAttributeKey.heading,
|
||||||
|
BuiltInAttributeKey.quote,
|
||||||
|
].contains(subtype);
|
||||||
TransactionBuilder(editorState)
|
TransactionBuilder(editorState)
|
||||||
..insertNode(
|
..insertNode(
|
||||||
textNode.path,
|
textNode.path,
|
||||||
textNode.copyWith(
|
textNode.copyWith(
|
||||||
children: LinkedList(),
|
children: LinkedList(),
|
||||||
delta: Delta(),
|
delta: Delta(),
|
||||||
|
attributes: needCopyAttributes ? null : {},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
..afterSelection = afterSelection
|
..afterSelection = afterSelection
|
||||||
@ -173,7 +178,9 @@ ShortcutEventHandler enterWithoutShiftInTextNodesHandler =
|
|||||||
Attributes _attributesFromPreviousLine(TextNode textNode) {
|
Attributes _attributesFromPreviousLine(TextNode textNode) {
|
||||||
final prevAttributes = textNode.attributes;
|
final prevAttributes = textNode.attributes;
|
||||||
final subType = textNode.subtype;
|
final subType = textNode.subtype;
|
||||||
if (subType == null || subType == BuiltInAttributeKey.heading) {
|
if (subType == null ||
|
||||||
|
subType == BuiltInAttributeKey.heading ||
|
||||||
|
subType == BuiltInAttributeKey.quote) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,8 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
|
|||||||
final result = shortcutEvent.handler(widget.editorState, event);
|
final result = shortcutEvent.handler(widget.editorState, event);
|
||||||
if (result == KeyEventResult.handled) {
|
if (result == KeyEventResult.handled) {
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
|
} else if (result == KeyEventResult.skipRemainingHandlers) {
|
||||||
|
return KeyEventResult.skipRemainingHandlers;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user