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

[Mobile] customRecognizerBuilder not triggered for links in bullet list

Open tsafundzic opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

Flutter Quill version

9.4.2

Steps to reproduce

Add customRecognizerBuilder to the QuillEditor:

                         customRecognizerBuilder: (Attribute attribute, Leaf leaf) {
                            // We are not using default long press context menu for handling the links
                            return TapGestureRecognizer()
                              ..onTap = () {
                                if (attribute.key == Attribute.link.key) {
                                  launchUrlFromQuill(context, attribute.value.toString());
                                }
                              };
                          },

This is text used to test:

[
  {
    "insert": "Google",
    "attributes": {
      "link": "https://www.google.com/"
    }
  },
  {
    "insert": "\n",
    "attributes": {
      "list": "bullet"
    }
  },
  {
    "insert": "\n\nAnd this link works: "
  },
  {
    "insert": "Google",
    "attributes": {
      "link": "https://www.google.com/"
    }
  }
]

Expected results

Every link should trigger TapGestureRecognizer defined in customRecognizerBuilder. In bullets it does't trigger it - only long press works in that case.

Actual results

TapGestureRecognizer defined as customRecognizerBuilder is not being triggered when it is in bullet list - in that case only long press on link works.

Code sample

Code sample
                     QuillEditor(
                        focusNode: FocusNode(canRequestFocus: false),
                        scrollController: ScrollController(),
                        configurations: QuillEditorConfigurations(
                          controller: _quillController,
                          scrollable: true,
                          padding: EdgeInsets.zero,
                          autoFocus: false,
                          checkBoxReadOnly: true,
                          showCursor: false,
                          expands: false,
                          customRecognizerBuilder: (Attribute attribute, Leaf leaf) {
                            // We are not using default long press context menu for handling the links
                            return TapGestureRecognizer()
                              ..onTap = () {
                                if (attribute.key == Attribute.link.key) {
                                  launchUrlFromQuill(context, attribute.value.toString());
                                }
                              };
                          },
                          onLaunchUrl: (link) => launchUrlFromQuill(context, link),
                        ),
                      ),

Screenshots or Video

No response

Logs

No response

tsafundzic avatar Jun 19 '24 06:06 tsafundzic

Can you provide what launchUrlFromQuill() does?

CatHood0 avatar Jun 26 '24 08:06 CatHood0

It opens url in external app with url_launcher:

   launcher.launchUrl(
      Uri.parse(url),
      mode: launcher.LaunchMode.externalApplication,
    );

tsafundzic avatar Jul 02 '24 07:07 tsafundzic

Does this issue still persists? If does, please reopen this. I think this was fixed on some of the lastest versions (i could be wrong).

CatHood0 avatar Sep 21 '24 03:09 CatHood0

@tsafundzic Can you confirm if this still an issue?

EchoEllet avatar Sep 21 '24 13:09 EchoEllet

I think this was fixed since EditableTextBlock needs customRecognizerBuilder at pass this into TextLine. So, probably was an issue from the version.

CatHood0 avatar Sep 21 '24 15:09 CatHood0