mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: pressing enter key in the edge of node doesn't work good.
This commit is contained in:
parent
5fdcdbd357
commit
a1be60721e
@ -116,13 +116,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
_editorState = EditorState(
|
_editorState = EditorState(
|
||||||
document: document,
|
document: document,
|
||||||
);
|
);
|
||||||
return FlowyEditor(
|
return Container(
|
||||||
|
padding: const EdgeInsets.only(left: 20, right: 20),
|
||||||
|
child: FlowyEditor(
|
||||||
key: editorKey,
|
key: editorKey,
|
||||||
editorState: _editorState,
|
editorState: _editorState,
|
||||||
keyEventHandlers: const [],
|
keyEventHandlers: const [],
|
||||||
customBuilders: {
|
customBuilders: {
|
||||||
'image': ImageNodeBuilder(),
|
'image': ImageNodeBuilder(),
|
||||||
},
|
},
|
||||||
|
),
|
||||||
// shortcuts: [
|
// shortcuts: [
|
||||||
// // TODO: this won't work, just a example for now.
|
// // TODO: this won't work, just a example for now.
|
||||||
// {
|
// {
|
||||||
|
@ -74,7 +74,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {
|
|||||||
_renderParagraph.getOffsetForCaret(textPosition, Rect.zero);
|
_renderParagraph.getOffsetForCaret(textPosition, Rect.zero);
|
||||||
final cursorHeight = widget.cursorHeight ??
|
final cursorHeight = widget.cursorHeight ??
|
||||||
_renderParagraph.getFullHeightForCaret(textPosition) ??
|
_renderParagraph.getFullHeightForCaret(textPosition) ??
|
||||||
5.0; // default height
|
18.0; // default height
|
||||||
return Rect.fromLTWH(
|
return Rect.fromLTWH(
|
||||||
cursorOffset.dx - (widget.cursorWidth / 2),
|
cursorOffset.dx - (widget.cursorWidth / 2),
|
||||||
cursorOffset.dy,
|
cursorOffset.dy,
|
||||||
|
@ -51,6 +51,7 @@ class StyleKey {
|
|||||||
|
|
||||||
static List<String> globalStyleKeys = [
|
static List<String> globalStyleKeys = [
|
||||||
StyleKey.heading,
|
StyleKey.heading,
|
||||||
|
StyleKey.checkbox,
|
||||||
StyleKey.bulletedList,
|
StyleKey.bulletedList,
|
||||||
StyleKey.numberList,
|
StyleKey.numberList,
|
||||||
StyleKey.quote,
|
StyleKey.quote,
|
||||||
|
@ -37,9 +37,8 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {
|
|||||||
textNode.path.next,
|
textNode.path.next,
|
||||||
textNode.copyWith(
|
textNode.copyWith(
|
||||||
children: LinkedList(),
|
children: LinkedList(),
|
||||||
delta: Delta([TextInsert(' ')]),
|
delta: Delta([TextInsert('')]),
|
||||||
attributes:
|
attributes: needCopyAttributes ? textNode.attributes : {},
|
||||||
needCopyAttributes ? {StyleKey.subtype: textNode.subtype} : {},
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
..afterSelection = Selection.collapsed(
|
..afterSelection = Selection.collapsed(
|
||||||
@ -56,7 +55,7 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {
|
|||||||
textNode.path,
|
textNode.path,
|
||||||
textNode.copyWith(
|
textNode.copyWith(
|
||||||
children: LinkedList(),
|
children: LinkedList(),
|
||||||
delta: Delta([TextInsert(' ')]),
|
delta: Delta([TextInsert('')]),
|
||||||
attributes: {},
|
attributes: {},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -233,6 +233,9 @@ class _FlowySelectionState extends State<FlowySelection>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
clearSelection();
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +458,7 @@ class _FlowySelectionState extends State<FlowySelection>
|
|||||||
..forEach((overlay) => overlay.remove())
|
..forEach((overlay) => overlay.remove())
|
||||||
..clear();
|
..clear();
|
||||||
// clear toolbar
|
// clear toolbar
|
||||||
editorState.service.toolbarService.hide();
|
editorState.service.toolbarService?.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateSelection(Selection selection) {
|
void _updateSelection(Selection selection) {
|
||||||
@ -526,7 +529,7 @@ class _FlowySelectionState extends State<FlowySelection>
|
|||||||
|
|
||||||
if (topmostRect != null && layerLink != null) {
|
if (topmostRect != null && layerLink != null) {
|
||||||
editorState.service.toolbarService
|
editorState.service.toolbarService
|
||||||
.showInOffset(topmostRect.topLeft, layerLink);
|
?.showInOffset(topmostRect.topLeft, layerLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,11 @@ class FlowyService {
|
|||||||
|
|
||||||
// toolbar service
|
// toolbar service
|
||||||
final toolbarServiceKey = GlobalKey(debugLabel: 'flowy_toolbar_service');
|
final toolbarServiceKey = GlobalKey(debugLabel: 'flowy_toolbar_service');
|
||||||
ToolbarService get toolbarService {
|
ToolbarService? get toolbarService {
|
||||||
assert(toolbarServiceKey.currentState != null &&
|
if (toolbarServiceKey.currentState != null &&
|
||||||
toolbarServiceKey.currentState is ToolbarService);
|
toolbarServiceKey.currentState is ToolbarService) {
|
||||||
return toolbarServiceKey.currentState! as ToolbarService;
|
return toolbarServiceKey.currentState! as ToolbarService;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user