78 | | .each( function ( i, element ) { |
79 | | var contentWrap = $( element ).find( '.wpview-content' ), |
80 | | wrap = element; |
81 | | |
82 | | if ( contentWrap.length && option !== 'wrap' ) { |
83 | | element = contentWrap = contentWrap[0]; |
84 | | } |
85 | | |
86 | | if ( _.isString( html ) ) { |
87 | | if ( option === 'replace' ) { |
88 | | element = editor.dom.replace( editor.dom.createFragment( html ), wrap ); |
89 | | } else { |
90 | | editor.dom.setHTML( element, html ); |
91 | | } |
92 | | } else { |
93 | | if ( option === 'replace' ) { |
94 | | element = editor.dom.replace( html, wrap ); |
95 | | } else { |
96 | | $( element ).empty().append( html ); |
97 | | } |
| 79 | .each( function ( i, node ) { |
| 80 | if ( callback ) { |
| 81 | callback( editor, node ); |
108 | | /* jshint scripturl: true */ |
109 | | createIframe: function ( content ) { |
110 | | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, |
111 | | iframe, iframeDoc, i, resize, |
112 | | dom = tinymce.DOM; |
| 94 | this.getNodes( function ( editor, element ) { |
| 95 | var contentWrap = $( element ).find( '.wpview-content' ), |
| 96 | wrap = element; |
126 | | this.setContent( iframe ); |
127 | | iframeDoc = iframe.contentWindow.document; |
| 102 | if ( _.isString( html ) ) { |
| 103 | if ( option === 'replace' ) { |
| 104 | element = editor.dom.replace( editor.dom.createFragment( html ), wrap ); |
| 105 | } else { |
| 106 | editor.dom.setHTML( element, html ); |
| 107 | } |
| 108 | } else { |
| 109 | if ( option === 'replace' ) { |
| 110 | element = editor.dom.replace( html, wrap ); |
| 111 | } else { |
| 112 | $( element ).empty().append( html ); |
| 113 | } |
| 114 | } |
147 | | if ( MutationObserver ) { |
148 | | new MutationObserver( _.debounce( function() { |
149 | | resize(); |
150 | | }, 100 ) ) |
151 | | .observe( iframeDoc.body, { |
152 | | attributes: true, |
153 | | childList: true, |
154 | | subtree: true |
| 126 | if ( content.indexOf( '<script' ) !== -1 ) { |
| 127 | this.getNodes( function ( editor, node ) { |
| 128 | var dom = editor.dom, |
| 129 | iframe, iframeDoc, i, resize; |
| 130 | |
| 131 | node = $( node ).find( '.wpview-content' )[0]; |
| 132 | |
| 133 | node.innerHTML = ''; |
| 134 | |
| 135 | iframe = dom.add( node, 'iframe', { |
| 136 | src: tinymce.Env.ie ? 'javascript:""' : '', |
| 137 | frameBorder: '0', |
| 138 | allowTransparency: 'true', |
| 139 | scrolling: 'no', |
| 140 | style: { |
| 141 | width: '100%', |
| 142 | display: 'block' |
| 143 | } |
156 | | } else { |
157 | | for ( i = 1; i < 6; i++ ) { |
158 | | setTimeout( resize, i * 700 ); |
| 145 | |
| 146 | iframeDoc = iframe.contentWindow.document; |
| 147 | |
| 148 | iframeDoc.open(); |
| 149 | iframeDoc.write( |
| 150 | '<!DOCTYPE html>' + |
| 151 | '<html>' + |
| 152 | '<head>' + |
| 153 | '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' + |
| 154 | '</head>' + |
| 155 | '<body style="padding: 0; margin: 0;" class="' + /* editor.getBody().className + */ '">' + |
| 156 | content + |
| 157 | '</body>' + |
| 158 | '</html>' |
| 159 | ); |
| 160 | iframeDoc.close(); |
| 161 | |
| 162 | resize = function() { |
| 163 | $( iframe ).height( $( iframeDoc.body ).height() ); |
| 164 | }; |
| 165 | |
| 166 | if ( MutationObserver ) { |
| 167 | new MutationObserver( _.debounce( function() { |
| 168 | resize(); |
| 169 | }, 100 ) ) |
| 170 | .observe( iframeDoc.body, { |
| 171 | attributes: true, |
| 172 | childList: true, |
| 173 | subtree: true |
| 174 | } ); |
| 175 | } else { |
| 176 | for ( i = 1; i < 6; i++ ) { |
| 177 | setTimeout( resize, i * 700 ); |
| 178 | } |