diff --git a/lib/pages/dynamics/widgets/content_panel.dart b/lib/pages/dynamics/widgets/content_panel.dart index 52493ff19..dcd52996d 100644 --- a/lib/pages/dynamics/widgets/content_panel.dart +++ b/lib/pages/dynamics/widgets/content_panel.dart @@ -78,6 +78,8 @@ Widget content( style: isSave ? const TextStyle(fontSize: 15) : const TextStyle(fontSize: 16), + contextMenuBuilder: (_, state) => + _contextMenuBuilder(state, moduleDynamic), ) : custom_text.Text.rich( style: floor == 1 @@ -107,3 +109,37 @@ Widget content( ), ); } + +Widget _contextMenuBuilder( + EditableTextState state, + ModuleDynamicModel? moduleDynamic, +) { + return AdaptiveTextSelectionToolbar.buttonItems( + buttonItems: state.contextMenuButtonItems + ..add( + ContextMenuButtonItem( + label: '文本', + onPressed: () => _onCopyText(moduleDynamic), + ), + ), + anchors: state.contextMenuAnchors, + ); +} + +void _onCopyText(ModuleDynamicModel? moduleDynamic) { + final text = + moduleDynamic?.desc?.text ?? moduleDynamic?.major?.opus?.summary?.text; + if (text == null || text.isEmpty) return; + showDialog( + context: Get.context!, + builder: (context) => Dialog( + child: Padding( + padding: const .symmetric(horizontal: 20, vertical: 16), + child: SelectableText( + text, + style: const TextStyle(fontSize: 15, height: 1.7), + ), + ), + ), + ); +}