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

Wrong 'saveSelection' #144

Open
dbudde opened this issue Aug 13, 2018 · 3 comments
Open

Wrong 'saveSelection' #144

dbudde opened this issue Aug 13, 2018 · 3 comments

Comments

@dbudde
Copy link

dbudde commented Aug 13, 2018

I have found an instance of when 'saveSelection' is called, that it incorrectly saves a selection outside of the editor. You can reproduce the issue by going to (https://mindmup.github.io/bootstrap-wysiwyg/) and following these instructions.

  1. Highlight/select the text 'Go ahead'.
  2. Click on the Create Hyperlink/Anchor button.
  3. Click into the 'URL' input box placing focus on the box.
  4. Hover over the editor area, and then take the mouse cursor outside the editor onto the page.
  5. Click on the page to make the 'URL' input box lose focus and the dropdown to close.

You should see the temporary highlight stick around rather than have the selection return properly. Here is my suggested fix.

Wysiwyg.prototype.saveSelection = function() {
     var currentRange = this.getCurrentRange();
     if (typeof currentRange !== "undefined" && $.contains(this.editor[0], $(currentRange.commonAncestorContainer).parent()[0]))
     {
          this.selectedRange = this.getCurrentRange();
     }
};

@dbudde
Copy link
Author

dbudde commented Aug 13, 2018

Well, this creates a new issue. If I click in the URL input box and then just click back into the editor, the highlight sticks around this way too. So, I guess I don't really know the fix, just see a problem that you can reproduce with the instructions I first gave.

@PallasDoesCode
Copy link
Contributor

Hi @dbudde the Mindmup repo is no longer maintained and hasn't been updated in quite a while. Can you try this out on our demo page http://steveathon.github.io/bootstrap-wysiwyg/ and let us know if this is still an issue?

@dbudde
Copy link
Author

dbudde commented Aug 13, 2018

Yes, I just tested it at this link (thank you for that by the way) and the problem still occurs. The way I have fixed it for the moment was to update the 'saveSelection' with the code I showed above and then I call the 'markSelection' method by hooking into the 'blur' event on the URL input field. I am not putting the 'data-edit="createLink"' on the URL input directly like the example has it done. Instead I use the add button to kick that off, just so you know. Part of the reason for my changes was I am integrating Bootstrap 4.1 with Font Awesome 5. I'm attaching an image so you can see what the GUI looks like (not that it addresses this issue).

wysiwyg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants