editorjs-hyperlink icon indicating copy to clipboard operation
editorjs-hyperlink copied to clipboard

hyperlink not changing

Open vishal-kushwaha-itorix opened this issue 4 years ago • 7 comments

hyper link not changing only rel and target updating https://user-images.githubusercontent.com/85753351/131978528-e60b210f-a79a-4297-a86e-c5d5cfd2a8ba.mov

vishal-kushwaha-itorix avatar Sep 03 '21 08:09 vishal-kushwaha-itorix

Having the same issue and confirmed it is present in 1.0.5 and 1.0.6 @trinhtam are you able to address this?

Aerofusical avatar Oct 05 '21 10:10 Aerofusical

I have the same issue. Please fix it asap it's affecting our production

khanakia avatar Oct 25 '22 14:10 khanakia

Hi there 👋🏻 Also having the same issue. I'm testing through it today and will post any findings I have.

mattmilburn avatar Dec 16 '22 19:12 mattmilburn

@vishal-kushwaha-itorix @Aerofusical @khanakia I do have a fix if you're still interested in forking the repo in your own project.

@trinhtam This is a one-liner fix in case you are interested in having me submit a pull request 👍🏻

There is an insertLink method in src/Hyperlink.js. I modified one line of code in this method to set the href value based on the input value and the issue seems to fix the issue where the link URL will not update once the link is created.

insertLink(link, target='', rel='') {
  let anchorTag = this.selection.findParentTag('A');
  if (anchorTag) {
    this.selection.expandToTag(anchorTag);
  }else{
    document.execCommand(this.commandLink, false, link);
    anchorTag = this.selection.findParentTag('A');
  }
  if(anchorTag) {
+   anchorTag['href'] = link;
+
    if(!!target) {
    anchorTag['target'] = target;
    }else{
    anchorTag.removeAttribute('target');
    }
    if(!!rel) {
      anchorTag['rel'] = rel;
    }else{
      anchorTag.removeAttribute('rel');
    }
  }
}

mattmilburn avatar Dec 26 '22 22:12 mattmilburn

+1 please support this fix asap

maykel-esser avatar Feb 12 '23 14:02 maykel-esser

Based on @mattmilburn fix, I have uploaded to a repo with the bundle.js: https://github.com/joancifo/editorjs-hyperlink

You can install and use it until @trinhtam merges the PR:

npm i https://github.com/joancifo/editorjs-hyperlink.git

joancifo avatar Jun 18 '24 20:06 joancifo