Trumbowyg: 2.11.1 insertImage doesn't insert link

Created on 5 Oct 2018  路  7Comments  路  Source: Alex-D/Trumbowyg

Somewhere between 2.10 and 2.11.1 a change on line 1425 breaks link insertion for insertImage.
Either the modal box disappears and nothing is added in the editor or a new insertImage modal box appears on top of the previous one.

 // Build out of ModalBox, it's the mask for animations
var $modal = $('<div/>', {
                class: prefix + 'modal ' + prefix + 'fixed-top'
 }).css({
                top: t.$box.offset().top + t.$btnPane.height(),
                zIndex: 99999
}).appendTo($(document.body)); 

Line 1425 in 2.11.1 is '}).appendTo($(document.body));'
Line 1425 in 2.10 is '}).appendTo(t.$box);'

Changing 'only' that single line in 2.11.1 code makes the insertImage work again.

Browser version: Safari 12, Firefox 62.0.3
OS: Mac

core

Most helpful comment

@JackTR-M

I managed to fix this temporarily without changing source code by adding this:

success: function(data, trumbowyg, _$modal, values) {
  trumbowyg.doc.execCommand("insertHTML", false, "<img src='" + data.url + "' alt='" +  values.alt + "'>")
  trumbowyg.closeModal();
}

All 7 comments

@JackTR-M

I managed to fix this temporarily without changing source code by adding this:

success: function(data, trumbowyg, _$modal, values) {
  trumbowyg.doc.execCommand("insertHTML", false, "<img src='" + data.url + "' alt='" +  values.alt + "'>")
  trumbowyg.closeModal();
}

Hello,
I have this problem.

Did you try t.doc.body instead of t.$box?

Just tried and it doesn't work

I would just add to what @causztic has said that it seems like (at least for me) that there needs to be after modal closing line also added following: trumbowyg.syncCode(); Without it, the returned HTML code in textarea doesn't get updated until you change some other content after.

@JackTR-M

I managed to fix this temporarily without changing source code by adding this:

success: function(data, trumbowyg, _$modal, values) {
  trumbowyg.doc.execCommand("insertHTML", false, "<img src='" + data.url + "' alt='" +  values.alt + "'>")
  trumbowyg.closeModal();
}

@causztic so after lot of surfing I found that I fall in love with your solution, thanks alot buddy you made my day!!!

Was this page helpful?
0 / 5 - 0 ratings