Skip to content
Permalink
Browse files

Bind event listener to link form only once

  • Loading branch information...
Anna Dabrowska
Anna Dabrowska committed Aug 15, 2019
1 parent ba7249f commit 1f6c3f1c3d4953b335a97d883f1a6b871d4926fd
Showing with 14 additions and 6 deletions.
  1. +13 −6 script/nodeviews/LinkForm.js
  2. +1 −0 script/nodeviews/LinkView.js
@@ -1,18 +1,25 @@
import CustomForm from './CustomForm';
import MediaForm from './MediaForm';

let lfInstance = null;

class LinkForm extends CustomForm {
constructor() {
super('prosemirror-linkform');

this.name = LANG.plugins.prosemirror.linkConfig;
// prevent repeated initialization
if (!lfInstance) {
this.name = LANG.plugins.prosemirror.linkConfig;

if (jQuery('#prosemirror-linkform').length) {
this.initializeLinkForm();
return;
}
if (jQuery('#prosemirror-linkform').length) {
this.initializeLinkForm();
lfInstance = this;
return;
}

jQuery(this.initializeLinkForm.bind(this));
jQuery(this.initializeLinkForm.bind(this));
lfInstance = this;
}
}

getLinkType() {
@@ -115,6 +115,7 @@ class LinkView extends AbstractNodeView {
newAttrs,
this.node.marks,
));
this.deselectNode();
},
));
}

0 comments on commit 1f6c3f1

Please sign in to comment.
You can’t perform that action at this time.