|
9 | 9 | var parser = new DOMParser(), |
10 | 10 | shortcutLabel = ( tinymce.Env.mac ? '\u2303\u2325' : 'Shift+Alt+' ) + 'F'; |
11 | 11 |
|
| 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 | + |
12 | 32 | editor.addButton( 'tinymce-clear-float', { |
13 | 33 | title: editor.getLang( 'tinymce_clear_float.tooltip' ) + ' (' + shortcutLabel + ')', |
14 | 34 | cmd: 'clear_both', |
|
34 | 54 |
|
35 | 55 | for ( var i = elements.length - 1; i >= 0; i-- ) { |
36 | 56 | 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 ] ); |
52 | 58 | } |
53 | 59 | }; |
54 | 60 | event.content = html.body.innerHTML; |
|
73 | 79 |
|
74 | 80 | for ( var i = elements.length - 1; i >= 0; i-- ) { |
75 | 81 | 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 ] ); |
83 | 83 | } |
84 | 84 | }; |
85 | 85 | event.content = html.body.innerHTML; |
|
0 commit comments