Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyperlink cannot be triggered in non edit state. #41

Open
hetian9288 opened this issue Nov 1, 2018 · 12 comments
Open

Hyperlink cannot be triggered in non edit state. #41

hetian9288 opened this issue Nov 1, 2018 · 12 comments
Labels
bug Something isn't working

Comments

@hetian9288
Copy link

1、Hyperlink cannot be triggered in non edit state.
2、EditableBox will terminate the GestureDetector event of custom widgets.

@pulyaevskiy pulyaevskiy added the bug Something isn't working label Nov 2, 2018
@pulyaevskiy
Copy link
Contributor

Thanks for submitting this issue! This is definitely something I'll be looking to fix.

@abinmittu
Copy link

Is this fixed?

@pulyaevskiy
Copy link
Contributor

I’m planning to address this in the next couple of weeks, so stay tuned!

@kdcyberdude
Copy link

Any updates on this??

@cgestes
Copy link
Collaborator

cgestes commented Nov 28, 2019

I'll have a look next week. I also have the issue.

@cgestes
Copy link
Collaborator

cgestes commented Nov 28, 2019

a solution here: #211

:)

@raj457036
Copy link

You can listen to controller and then get the style attribute of the clicked element if thats notusattribte.Link. you got the url just open it with url_launcher

@raj457036
Copy link

raj457036 commented Mar 18, 2020

1、Hyperlink cannot be triggered in non edit state.
2、EditableBox will terminate the GestureDetector event of custom widgets.

You can use TextSelectionGestureDetector but there is a better way to handle ur need. Check my above comment

@jagjot26
Copy link

You can listen to controller and then get the style attribute of the clicked element if thats notusattribte.Link. you got the url just open it with url_launcher

Can you please write some code to explain this a bit? How can I get the text on which the user tapped for checking if it is a link? I'm a little new to Flutter, so it'd be great if you could help.

@Jackilion
Copy link

This is probably not relevant to you guys anymore, but the links still didn't work for me in a non-edit state, so I found this solution based on raj457036 comment:

First, add a listener to the controller via controller.addListener(handleLinkClicked);
This listener will get triggered everytime a user clicks inside the editor, even if it is on mode.view.
You can check whether the clicked item is a link via:

void handleLinkClicked() {
  var styles = _controller.getSelectionStyle();
  for (var atr in styles.values) {
  if (atr.key == "a") print("here's the clicked link: " + atr.value);
  }
}

@raj457036
Copy link

raj457036 commented Aug 16, 2020

You can listen to controller and then get the style attribute of the clicked element if thats notusattribte.Link. you got the url just open it with url_launcher

Can you please write some code to explain this a bit? How can I get the text on which the user tapped for checking if it is a link? I'm a little new to Flutter, so it'd be great if you could help.

first of all, apologies I was very busy with work

@Jackilion your solution might also work well.

So here is what I used in my project

...
// define controller and listen to controller
_controller = ZefyrController(
    NotusDocument.fromDelta(delta)
)..addListener(linkListener);

...

linkListener() {
    // check if any link is clicked
    final _url = _controller.getSelectionStyle().get(NotusAttribute.link)?.value;
   
    // if url found launch it
    if (_url != null) {
        launchURL(_url);
    }
}

@cgestes
Copy link
Collaborator

cgestes commented Oct 20, 2021

Please see #543

  • hittestchildren implementation allows child widget of Zefyr to implement their GestureDetector if they want
  • one of the patch allows clicking links no matter the mode of edition

I believe the current issue without #543 is reversed: cannot trigger links while editing :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants