stevengharris/MarkupEditor

Issue with MarkupEditorView when text starts with a link

Closed this issue · 3 comments

Hi there,

I wanted to start by thanking you for the great work you've done with the MarkupEditor, it's been a total game changer for my SwiftUI app. However, I'm currently experiencing an interesting issue that I hope you can help me with.

I've noticed that when the html text starts with a link, the MarkupEditorView is triggering markupLinkSelected() whenever the user taps anywhere within the view. This means that the text cannot be edited as it automatically opens the link, even if the user didn't intend to click it. However, if there's no link at the beginning of the html text, the MarkupEditorView and link taps work perfectly.

Do you have any ideas on how to solve this issue? I would greatly appreciate any help you can provide.

Thank you in advance!

Thanks for letting me know. I will take a look.

I think this is as simple as removing the code on the JavaScript side where I do the _callback('click'); for the touchstart event. TBH, I am not sure why I had that there, because we still receive a markupClicked on the Swift side when you actually select a link. Here it is commented-out below:

/**
 * Mute selectionChange notifications when touch starts.
 */
MU.editor.addEventListener('touchstart', function() {
    //_callback('click');
    muteChanges();
});

I've checked this on my end, but if you could try this change and confirm it both works and doesn't have any other side-effects for you, I'll merge-in the fix. I'm not using the MarkupEditor on iOS much, so it would be good to have confirmation.

I have tested this on my application and it's working perfectly!🔥
I will wait for the merge. Thank you for your efforts!