zefyr
zefyr copied to clipboard
Hyperlink cannot be triggered in non edit state.
1、Hyperlink cannot be triggered in non edit state. 2、EditableBox will terminate the GestureDetector event of custom widgets.
Thanks for submitting this issue! This is definitely something I'll be looking to fix.
Is this fixed?
I’m planning to address this in the next couple of weeks, so stay tuned!
Any updates on this??
I'll have a look next week. I also have the issue.
a solution here: https://github.com/memspace/zefyr/pull/211
:)
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
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
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.
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);
}
}
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);
}
}
Please see https://github.com/memspace/zefyr/pull/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