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

Adding a hyperlink always adds extra space #59

Open
DomRosenberger opened this issue Jan 23, 2019 · 2 comments
Open

Adding a hyperlink always adds extra space #59

DomRosenberger opened this issue Jan 23, 2019 · 2 comments

Comments

@DomRosenberger
Copy link

When using the toolbar button for adding an hyperlink it always includes an extra whitespace directly after the hyperlink.

Attaching 2 screenshots which show the issue.

text_before_applying_hyperlink
extra_space_after_hyperlink

@agusmakmun
Copy link
Owner

agusmakmun commented Jan 25, 2019

Yes, I'm not indentify the next column is a character or white space. Did you have any solution for this?
For the source can be found here..

editor.session.replace(range, '['+text+'](http://) ');

@some1ataplace
Copy link

some1ataplace commented Apr 5, 2023

Maybe try this. Did not test this.

  1. Add a custom JavaScript function to trim the link:
function trimLink(link) {
  return link.trim();
}
  1. Modify the "insertLink" function in the Markdown Editor to call the "trimLink" function:
function insertLink() {
  var link = prompt("Enter the link URL:");
  if (link) {
    link = trimLink(link);
    var text = prompt("Enter the link text:");
    if (text) {
      text = trimLink(text);
      var selection = getSelection();
      var range = selection.getRangeAt(0);
      var node = document.createElement("a");
      node.setAttribute("href", link);
      node.textContent = text;
      range.insertNode(node);
    }
  }
}

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

3 participants