Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 1668a22

Browse files
committed
Do not remove plugin on cleaning empty placeholder
This should fix #98 The embed plugin insert a div before the placeholder: ``` add : function ($placeholder) { var formHtml = '<div class="medium-editor-toolbar... $(formHtml).appendTo($placeholder.prev()); ``` The fix for Firefox that cleanup empty placeholder (related to #28) has to check if this div exist before removing it. I've made it kind of generic by checking for a div element instead of a class.
1 parent 0ca2a44 commit 1668a22

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/js/medium-editor-insert-plugin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,13 @@
334334
// by removing all empty placeholders
335335
if (that.isFirefox){
336336
$('.mediumInsert .mediumInsert-placeholder:empty', $el).each(function () {
337-
$(this).parent().remove();
337+
var parent = $(this).parent();
338+
339+
// if the parent has at least one div child it means it can be a plugin, so we don't remove it
340+
// for example, embed works like that (Fix #98)
341+
if (0 === parent.find('.mediumInsert-buttons div').length) {
342+
parent.remove();
343+
}
338344
});
339345
}
340346

0 commit comments

Comments
 (0)