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: pressing enter key in the edge of node doesn't work good.
Lucas.Xua1be60721e9a
diff --git a/frontend/app_flowy/packages/flowy_editor/example/lib/main.dart b/frontend/app_flowy/packages/flowy_editor/example/lib/main.dartindex 158e33bbb1..1a68f38ead 100644--- a/frontend/app_flowy/packages/flowy_editor/example/lib/main.dart+++ b/frontend/app_flowy/packages/flowy_editor/example/lib/main.dart@@ -116,13 +116,16 @@ class _MyHomePageState extends State<MyHomePage> {_editorState = EditorState(document: document,);- return FlowyEditor(- key: editorKey,- editorState: _editorState,- keyEventHandlers: const [],- customBuilders: {- 'image': ImageNodeBuilder(),- },+ return Container(+ padding: const EdgeInsets.only(left: 20, right: 20),+ child: FlowyEditor(+ key: editorKey,+ editorState: _editorState,+ keyEventHandlers: const [],+ customBuilders: {+ 'image': ImageNodeBuilder(),+ },+ ),// shortcuts: [// // TODO: this won't work, just a example for now.// {diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dartindex 70834184cc..f302fcaba8 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dart@@ -74,7 +74,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {_renderParagraph.getOffsetForCaret(textPosition, Rect.zero);final cursorHeight = widget.cursorHeight ??_renderParagraph.getFullHeightForCaret(textPosition) ??- 5.0; // default height+ 18.0; // default heightreturn Rect.fromLTWH(cursorOffset.dx - (widget.cursorWidth / 2),cursorOffset.dy,diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dartindex 19aa109faf..cc4f6038ac 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/rich_text_style.dart@@ -51,6 +51,7 @@ class StyleKey {static List<String> globalStyleKeys = [StyleKey.heading,+ StyleKey.checkbox,StyleKey.bulletedList,StyleKey.numberList,StyleKey.quote,diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dartindex 525afd9021..5b49907138 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart@@ -37,9 +37,8 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {textNode.path.next,textNode.copyWith(children: LinkedList(),- delta: Delta([TextInsert(' ')]),- attributes:- needCopyAttributes ? {StyleKey.subtype: textNode.subtype} : {},+ delta: Delta([TextInsert('')]),+ attributes: needCopyAttributes ? textNode.attributes : {},),)..afterSelection = Selection.collapsed(@@ -56,7 +55,7 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {textNode.path,textNode.copyWith(children: LinkedList(),- delta: Delta([TextInsert(' ')]),+ delta: Delta([TextInsert('')]),attributes: {},),)diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dartindex 0695dd5e90..59632773e5 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart@@ -233,6 +233,9 @@ class _FlowySelectionState extends State<FlowySelection>@overridevoid dispose() {+ clearSelection();+ WidgetsBinding.instance.removeObserver(this);+super.dispose();}@@ -455,7 +458,7 @@ class _FlowySelectionState extends State<FlowySelection>..forEach((overlay) => overlay.remove())..clear();// clear toolbar- editorState.service.toolbarService.hide();+ editorState.service.toolbarService?.hide();}void _updateSelection(Selection selection) {@@ -526,7 +529,7 @@ class _FlowySelectionState extends State<FlowySelection>if (topmostRect != null && layerLink != null) {editorState.service.toolbarService- .showInOffset(topmostRect.topLeft, layerLink);+ ?.showInOffset(topmostRect.topLeft, layerLink);}}diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/service.dartindex 829ad2bde1..937a16044a 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/service/service.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/service/service.dart@@ -23,9 +23,11 @@ class FlowyService {// toolbar servicefinal toolbarServiceKey = GlobalKey(debugLabel: 'flowy_toolbar_service');- ToolbarService get toolbarService {- assert(toolbarServiceKey.currentState != null &&- toolbarServiceKey.currentState is ToolbarService);- return toolbarServiceKey.currentState! as ToolbarService;+ ToolbarService? get toolbarService {+ if (toolbarServiceKey.currentState != null &&+ toolbarServiceKey.currentState is ToolbarService) {+ return toolbarServiceKey.currentState! as ToolbarService;+ }+ return null;}}