fix: empty items disable context menu (#793)
This commit is contained in:
parent
b827d089b6
commit
1ceed9b4d2
4 changed files with 22 additions and 8 deletions
|
|
@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||||
# https://github.com/flutter/flutter/issues/57146.
|
# https://github.com/flutter/flutter/issues/57146.
|
||||||
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
|
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
|
||||||
|
|
||||||
|
# Set fallback configurations for older versions of the flutter tool.
|
||||||
|
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
|
||||||
|
set(FLUTTER_TARGET_PLATFORM "windows-x64")
|
||||||
|
endif()
|
||||||
|
|
||||||
# === Flutter Library ===
|
# === Flutter Library ===
|
||||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
|
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
|
||||||
|
|
||||||
|
|
@ -92,7 +97,7 @@ add_custom_command(
|
||||||
COMMAND ${CMAKE_COMMAND} -E env
|
COMMAND ${CMAKE_COMMAND} -E env
|
||||||
${FLUTTER_TOOL_ENVIRONMENT}
|
${FLUTTER_TOOL_ENVIRONMENT}
|
||||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
|
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
|
||||||
windows-x64 $<CONFIG>
|
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
add_custom_target(flutter_assemble DEPENDS
|
add_custom_target(flutter_assemble DEPENDS
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,13 @@ class AppFlowyEditor extends StatefulWidget {
|
||||||
/// The context menu items.
|
/// The context menu items.
|
||||||
///
|
///
|
||||||
/// They will be shown when the user right click on the editor.
|
/// They will be shown when the user right click on the editor.
|
||||||
|
/// Each item will be separated by a divider.
|
||||||
///
|
///
|
||||||
/// A divider will be added between each list.
|
/// Defaults to [standardContextMenuItems].
|
||||||
final List<List<ContextMenuItem>> contextMenuItems;
|
///
|
||||||
|
/// If empty the context menu won't appear.
|
||||||
|
///
|
||||||
|
final List<List<ContextMenuItem>>? contextMenuItems;
|
||||||
|
|
||||||
/// Provide a editorScrollController to control the scroll behavior
|
/// Provide a editorScrollController to control the scroll behavior
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ class DesktopSelectionServiceWidget extends StatefulWidget {
|
||||||
super.key,
|
super.key,
|
||||||
this.cursorColor = const Color(0xFF00BCF0),
|
this.cursorColor = const Color(0xFF00BCF0),
|
||||||
this.selectionColor = const Color(0xFF00BCF0),
|
this.selectionColor = const Color(0xFF00BCF0),
|
||||||
required this.contextMenuItems,
|
this.contextMenuItems,
|
||||||
required this.child,
|
required this.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final Color cursorColor;
|
final Color cursorColor;
|
||||||
final Color selectionColor;
|
final Color selectionColor;
|
||||||
final List<List<ContextMenuItem>> contextMenuItems;
|
final List<List<ContextMenuItem>>? contextMenuItems;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DesktopSelectionServiceWidget> createState() =>
|
State<DesktopSelectionServiceWidget> createState() =>
|
||||||
|
|
@ -363,6 +363,11 @@ class _DesktopSelectionServiceWidgetState
|
||||||
void _showContextMenu(TapDownDetails details) {
|
void _showContextMenu(TapDownDetails details) {
|
||||||
_clearContextMenu();
|
_clearContextMenu();
|
||||||
|
|
||||||
|
// Don't trigger the context menu if there are no items
|
||||||
|
if (widget.contextMenuItems == null || widget.contextMenuItems!.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// only shows around the selection area.
|
// only shows around the selection area.
|
||||||
if (selectionRects.isEmpty) {
|
if (selectionRects.isEmpty) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -394,7 +399,7 @@ class _DesktopSelectionServiceWidgetState
|
||||||
builder: (context) => ContextMenu(
|
builder: (context) => ContextMenu(
|
||||||
position: offset,
|
position: offset,
|
||||||
editorState: editorState,
|
editorState: editorState,
|
||||||
items: widget.contextMenuItems,
|
items: widget.contextMenuItems!,
|
||||||
onPressed: () => _clearContextMenu(),
|
onPressed: () => _clearContextMenu(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ class SelectionServiceWidget extends StatefulWidget {
|
||||||
this.cursorColor = const Color(0xFF00BCF0),
|
this.cursorColor = const Color(0xFF00BCF0),
|
||||||
this.selectionColor = const Color.fromARGB(53, 111, 201, 231),
|
this.selectionColor = const Color.fromARGB(53, 111, 201, 231),
|
||||||
this.showMagnifier = true,
|
this.showMagnifier = true,
|
||||||
required this.contextMenuItems,
|
this.contextMenuItems,
|
||||||
required this.child,
|
required this.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final Color cursorColor;
|
final Color cursorColor;
|
||||||
final Color selectionColor;
|
final Color selectionColor;
|
||||||
final List<List<ContextMenuItem>> contextMenuItems;
|
final List<List<ContextMenuItem>>? contextMenuItems;
|
||||||
|
|
||||||
/// Show the magnifier or not.
|
/// Show the magnifier or not.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue