Merge pull request #1319 from LucasXu0/image_selection_area

update image node selection style and fix the context menu display problem
This commit is contained in:
Lucas.Xu 2022-11-18 09:35:06 +08:00 committed by GitHub
commit 39254b7f17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -34,6 +34,8 @@ class ImageNodeWidget extends StatefulWidget {
class _ImageNodeWidgetState extends State<ImageNodeWidget>
with SelectableMixin {
RenderBox get _renderBox => context.findRenderObject() as RenderBox;
final _imageKey = GlobalKey();
double? _imageWidth;
@ -76,6 +78,12 @@ class _ImageNodeWidgetState extends State<ImageNodeWidget>
);
}
@override
bool get shouldCursorBlink => false;
@override
CursorStyle get cursorStyle => CursorStyle.borderLine;
@override
Position start() {
return Position(path: widget.node.path, offset: 0);
@ -93,7 +101,8 @@ class _ImageNodeWidgetState extends State<ImageNodeWidget>
@override
Rect? getCursorRectInPosition(Position position) {
return null;
final size = _renderBox.size;
return Rect.fromLTWH(-size.width / 2.0, 0, size.width, size.height);
}
@override

View File

@ -508,6 +508,11 @@ class _AppFlowySelectionState extends State<AppFlowySelection>
void _showContextMenu(TapDownDetails details) {
_clearContextMenu();
// For now, only support the text node.
if (!currentSelectedNodes.every((element) => element is TextNode)) {
return;
}
final baseOffset =
editorState.renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
final offset = details.globalPosition + const Offset(10, 10) - baseOffset;