mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: implement remove subtype if text node is empty when pressing enter key
This commit is contained in:
parent
a1be60721e
commit
397f43cbe1
@ -29,6 +29,25 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {
|
|||||||
|
|
||||||
final textNode = nodes.first as TextNode;
|
final textNode = nodes.first as TextNode;
|
||||||
if (textNode.selectable!.end() == selection.end) {
|
if (textNode.selectable!.end() == selection.end) {
|
||||||
|
if (textNode.subtype != null && textNode.delta.length == 0) {
|
||||||
|
TransactionBuilder(editorState)
|
||||||
|
..deleteNode(textNode)
|
||||||
|
..insertNode(
|
||||||
|
textNode.path,
|
||||||
|
textNode.copyWith(
|
||||||
|
children: LinkedList(),
|
||||||
|
delta: Delta([TextInsert('')]),
|
||||||
|
attributes: {},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..afterSelection = Selection.collapsed(
|
||||||
|
Position(
|
||||||
|
path: textNode.path,
|
||||||
|
offset: 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..commit();
|
||||||
|
} else {
|
||||||
final needCopyAttributes = StyleKey.globalStyleKeys
|
final needCopyAttributes = StyleKey.globalStyleKeys
|
||||||
.where((key) => key != StyleKey.heading)
|
.where((key) => key != StyleKey.heading)
|
||||||
.contains(textNode.subtype);
|
.contains(textNode.subtype);
|
||||||
@ -48,6 +67,8 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
..commit();
|
..commit();
|
||||||
|
}
|
||||||
|
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
} else if (textNode.selectable!.start() == selection.start) {
|
} else if (textNode.selectable!.start() == selection.start) {
|
||||||
TransactionBuilder(editorState)
|
TransactionBuilder(editorState)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user