yakovlevga / brickyeditor

WYSIWYG block editor jQuery plugin.
MIT License
115 stars 20 forks source link

Error when trying to change Link from image field #36

Closed digitalManiac closed 4 years ago

digitalManiac commented 5 years ago

Hi, Before anything, I would like to congratulate you for brickyeditor. It is a very promising plugin although I'm still trying to figure out how to use it properly. At the moment I can create elements, store them and modify them. It works great except when trying to modify a link over an image. I get this error: "Uncaught (in promise) TypeError: link.getLinkPromptParams is not a function at ImageField.getPromptParams (jquery.brickyeditor.js:1135)" The popup when clicking on the image doesn't come out anymore once the link has been filled. Could you please help me ?

PS: there is a tiny typo I notice on line 1144 this.$field.css('background-image', "url(" + src +")" ); instead of this.$field.css('background-image', "url(" + src);

digitalManiac commented 5 years ago

Got it working ! I'm not sure it is the most elegant coding style but it makes the job :

Line 1128 replace new BrickyEditor.Prompt.PromptParameter('src', BrickyEditor.EditorStrings.imageFieldLinkTitle, this.data.url, BrickyEditor.EditorStrings.imageFieldLinkPlaceholder), with new BrickyEditor.Prompt.PromptParameter('src', BrickyEditor.EditorStrings.imageFieldLinkTitle, this.data.src, BrickyEditor.EditorStrings.imageFieldLinkPlaceholder),

Line 1133 replace var link = this.data.link ? this.data.link : new BrickyEditor.HtmlLinkParams(); with var link = this.data.link ? new BrickyEditor.HtmlLinkParams(this.data.link.href, this.data.link.title,this.data.link.target).getLinkPromptParams() : new BrickyEditor.HtmlLinkParams('','','').getLinkPromptParams()

Comment out line 1134 //var linkParams = link.getLinkPromptParams();

Line 1135 replace return params.concat(linkParams); with return params.concat(link);

For more clarity, please find attached a copy of the modified version, should you incorporate it to your next release. Hope it helps someone. Cheers !

jquery.brickyeditor.zip

yakovlevga commented 4 years ago

Thanks for pointing this out and sorry for so late response :)