flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Native Text processing context menu

Open theachoem opened this issue 8 months ago • 3 comments

Have you checked for an existing issue?

Use case

Have access to native context menus like Translate, Search, etc.

Proposal


Changes in raw_editor_state.dart: If we check in the Flutter text field, we can access those native context menus. What we need to do is load it in raw_editor_state.dart, then add them to the contextMenuButtonItems.

  @protected
  @override
  void initState() {
    super.initState();
    ....
    _initProcessTextActions();
  }

  /// Query the engine to initialize the list of text processing actions to show
  /// in the text selection toolbar.
  Future<void> _initProcessTextActions() async {
    _processTextActions.clear();
    _processTextActions.addAll(await _processTextService.queryTextActions());
  }

 List<ContextMenuButtonItem> get contextMenuButtonItems {
    return buttonItemsForToolbarOptions() ??
          EditableText.getEditableButtonItems(
            ...
          )
      ..addAll(_textProcessingActionButtonItems); <--- add them here.
  }

Reference

  • package:flutter/src/widgets/editable_text.dart:2946

I already added them to my app but it will be great to have them directly in Flutter Quill so I don't have to customize & will also benefit all Quill users.

theachoem avatar Mar 17 '25 18:03 theachoem

I'll pay attention to this as soon as I have the time. Let us finish the fixes we're working on first, and we'll likely add this (at least I'll take it into consideration for future PRs).

CatHood0 avatar Mar 17 '25 19:03 CatHood0

@EchoEllet thanks for you PR for Android, but there is similar feature on iOS too. It will be better to support both Android and iOS.

Flutter supports for an iOS 16+ system context menu: https://api.flutter.dev/flutter/widgets/SystemContextMenu-class.html

ibrahimdevs avatar Jun 11 '25 21:06 ibrahimdevs

I think it also unlock the secure paste feature for iOS. https://github.com/flutter/flutter/issues/103163 Now: on iOS, user copy from any other app, and open our app, tries to paste quill editor. iOS shows a popup:

"Acme" would like to paste from "Safari" Do you want to allow this?

So we can get rid of this question and directly paste content too.

ibrahimdevs avatar Jun 11 '25 22:06 ibrahimdevs