Skip to content

Commit df25c6f

Browse files
committed
Bugfix if no clear element is used
1 parent 002c98b commit df25c6f

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

admin/tinymce/tinymce-clear-float/js/plugin.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@
99
var parser = new DOMParser(),
1010
shortcutLabel = ( tinymce.Env.mac ? '\u2303\u2325' : 'Shift+Alt+' ) + 'F';
1111

12+
/**
13+
* Create placeholder image.
14+
*/
15+
placeholder = document.createElement( 'img' );
16+
placeholder.src = tinymce.Env.transparentSrc;
17+
placeholder.className = 'mce-tinymce-clear-float';
18+
placeholder.title = editor.getLang( 'tinymce_clear_float.img_title' );
19+
/**
20+
* `data-wp-more` is required to apply core CSS to the placeholder element.
21+
*/
22+
placeholder.setAttribute( 'data-wp-more', '' );
23+
placeholder.setAttribute( 'data-mce-resize', false );
24+
placeholder.setAttribute( 'data-mce-placeholder', 1 );
25+
26+
/**
27+
* Create clear element.
28+
*/
29+
element = document.createElement( 'br' );
30+
element.style.clear = 'both';
31+
1232
editor.addButton( 'tinymce-clear-float', {
1333
title: editor.getLang( 'tinymce_clear_float.tooltip' ) + ' (' + shortcutLabel + ')',
1434
cmd: 'clear_both',
@@ -34,21 +54,7 @@
3454

3555
for ( var i = elements.length - 1; i >= 0; i-- ) {
3656
if ( 'both' === elements[ i ].style.clear ) {
37-
/**
38-
* Create the placeholder image.
39-
*/
40-
placeholder = document.createElement( 'img' );
41-
placeholder.src = tinymce.Env.transparentSrc;
42-
placeholder.className = 'mce-tinymce-clear-float';
43-
placeholder.title = editor.getLang( 'tinymce_clear_float.img_title' );
44-
/**
45-
* `data-wp-more` is required to apply core CSS to the placeholder element.
46-
*/
47-
placeholder.setAttribute( 'data-wp-more', '' );
48-
placeholder.setAttribute( 'data-mce-resize', false );
49-
placeholder.setAttribute( 'data-mce-placeholder', 1 );
50-
51-
elements[ i ].parentNode.replaceChild( placeholder, elements[ i ] );
57+
elements[ i ].parentNode.replaceChild( placeholder.cloneNode(), elements[ i ] );
5258
}
5359
};
5460
event.content = html.body.innerHTML;
@@ -73,13 +79,7 @@
7379

7480
for ( var i = elements.length - 1; i >= 0; i-- ) {
7581
if ( 'mce-tinymce-clear-float' === elements[ i ].className ) {
76-
/**
77-
* Create the clear element.
78-
*/
79-
element = document.createElement( 'br' );
80-
element.style.clear = 'both';
81-
82-
elements[ i ].parentNode.replaceChild( element, elements[ i ] );
82+
elements[ i ].parentNode.replaceChild( element.cloneNode(), elements[ i ] );
8383
}
8484
};
8585
event.content = html.body.innerHTML;

admin/tinymce/tinymce-clear-float/js/plugin.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)