@@ -3,13 +3,8 @@ import React from 'react';
33import PropTypes from 'prop-types' ;
44import ImmutablePropTypes from 'react-immutable-proptypes' ;
55import Bowser from 'bowser' ;
6- < << << << HEAD
76import bindAll from 'lodash-es/bindAll' ;
87import constant from 'lodash-es/constant' ;
9- = === ===
10- import bindAll from 'lodash/bindAll' ;
11- import includes from 'lodash/includes' ;
12- > >>> >>> 23 eb7f2 ... Updates to element highlighter
138import { t } from 'i18next' ;
149
1510import normalizeError from '../util/normalizeError' ;
@@ -23,49 +18,18 @@ const sandboxOptions = [
2318 'allow-popups-to-escape-sandbox' ,
2419 'allow-scripts' ,
2520 'allow-top-navigation' ,
21+ 'allow-same-origin' ,
2622] . join ( ' ' ) ;
2723
2824let nextId = 1 ;
2925
3026class PreviewFrame extends React . Component {
31- < << << << HEAD
3227 constructor ( props ) {
3328 super ( props ) ;
3429
3530 const { compiledProject : { source} } = props ;
36- = === ===
37- constructor ( ) {
38- super ( ) ;
39- this . _frameName = `preview-frame-${ nextId ++ } ` ;
40- bindAll ( this , '_attachToFrame' , '_handleInfiniteLoop' ) ;
41- }
42-
43- componentDidMount ( ) {
44- this . _postFocusedSelectorToFrame ( this . props . focusedSelector ) ;
45- }
46- >>> >>> > 8 ca6c3c ... update to js channel
4731
48- << << << < HEAD
49- < << << << HEAD
5032 bindAll ( this , '_attachToFrame' , '_handleInfiniteLoop' ) ;
51- === = ===
52- componentWillReceiveProps ( nextProps ) {
53- if ( ! includes ( nextProps . focusedEditors , 'css' ) ) {
54- = === ===
55- componentWillReceiveProps ( newProps ) {
56- if ( includes ( this . props . focusedEditors , 'css' ) &&
57- ! includes ( newProps . focusedEditors , 'css' ) ) {
58- >>> >>> > 3 cc1d22 ... Update selector at cursor and handle unfocused editor
59- this . _postRemoveHighlightToFrame ( ) ;
60- }
61- if ( newProps . focusedSelector !== this . props . focusedSelector ||
62- includes ( newProps . focusedEditors , 'css' ) ) {
63- this . _postFocusedSelectorToFrame ( newProps . focusedSelector ) ;
64- }
65- < << << << HEAD
66- << << << < HEAD
67- }
68- >>> >>> > 23eb7f2... Updates to element highlighter
6933
7034 this . render = constant (
7135 < div className = "preview__frame-container" >
@@ -79,12 +43,6 @@ class PreviewFrame extends React.Component {
7943 </ div > ,
8044 ) ;
8145 }
82- === === =
83-
84- === === =
85- >>> >>> > 8 ca6c3c ... update to js channel
86- const { consoleEntries : previousConsoleEntries , isActive } = this.props;
87- >>> >>> > 3 cc1d22 ... Update selector at cursor and handle unfocused editor
8846
8947 // componentWillReceiveProps(nextProps) {
9048 // if (nextProps.highlighterSelector !== this.props.highlighterSelector) {
@@ -189,7 +147,6 @@ class PreviewFrame extends React.Component {
189147 } ) ;
190148 }
191149
192- < << << << HEAD
193150 _handleConsoleLog ( printedValue ) {
194151 const { compiledProjectKey} = this . props . compiledProject ;
195152 this . props . onConsoleLog ( printedValue , compiledProjectKey ) ;
@@ -200,19 +157,6 @@ class PreviewFrame extends React.Component {
200157 type : 'highlightElement' ,
201158 selector : { selector} ,
202159 } ) , '*' ) ;
203- = === ===
204- _postFocusedSelectorToFrame ( selector ) {
205- this . _channel . notify ( {
206- method : 'highlightElement' ,
207- params : selector ,
208- } ) ;
209- }
210-
211- _postRemoveHighlightToFrame ( ) {
212- this . _channel . notify ( {
213- method : 'removeHighlight' ,
214- } ) ;
215- > >>> >>> 8 ca6c3c ... update to js channel
216160 }
217161
218162 _postFocusedSelectorToFrame ( selector ) {
@@ -222,33 +166,13 @@ class PreviewFrame extends React.Component {
222166 } ) , '*' ) ;
223167 }
224168
225- < << << << HEAD
226169 _attachToFrame ( frame ) {
227170 if ( ! frame ) {
228171 if ( this . _channel ) {
229172 this . _channel . destroy ( ) ;
230173 Reflect . deleteProperty ( this , '_channel' ) ;
231174 }
232175 return ;
233- = === ===
234- _postRemoveHighlightToFrame ( ) {
235- this . _frame_element . contentWindow . postMessage ( JSON . stringify ( {
236- type : 'org.popcode.removeHighlight' ,
237- } ) , '*' ) ;
238- }
239-
240- _setFrameElement ( frame ) {
241- this . _frame_element = frame ;
242- }
243-
244- render ( ) {
245- let srcProps ;
246-
247- if ( this . props . src ) {
248- srcProps = { srcDoc : this . props . src } ;
249- } else {
250- srcProps = { src : 'about:blank' } ;
251- > >>> >>> 23 eb7f2 ... Updates to element highlighter
252176 }
253177
254178 this . _channel = Channel . build ( {
@@ -273,31 +197,17 @@ class PreviewFrame extends React.Component {
273197}
274198
275199PreviewFrame . propTypes = {
276- < << < << < HEAD
277- << << < << HEAD
278- << < << << HEAD
279200 compiledProject : PropTypes . instanceOf ( CompiledProjectRecord ) . isRequired ,
280201 consoleEntries : ImmutablePropTypes . iterable . isRequired ,
281- = === ===
282- focusedEditors : PropTypes . array ,
283- > >>> >>> 23 eb7f2 ... Updates to element highlighter
284- === = ===
285- consoleEntries : ImmutablePropTypes . iterable . isRequired ,
286- focusedEditors : PropTypes . array ,
287- > >>> >>> 3 cc1d22 ... Update selector at cursor and handle unfocused editor
288202 focusedSelector : PropTypes . string ,
289203 isActive : PropTypes . bool . isRequired ,
290204 onConsoleError : PropTypes . func . isRequired ,
291205 onConsoleLog : PropTypes . func . isRequired ,
292206 onConsoleValue : PropTypes . func . isRequired ,
293- = === ===
294- src : PropTypes . string . isRequired ,
295- > >>> >>> 621 d5f6 ... Add saga , add ref to iframe element
296207 onRuntimeError : PropTypes . func . isRequired ,
297208} ;
298209
299210PreviewFrame . defaultProps = {
300- focusedEditors : null ,
301211 focusedSelector : null ,
302212} ;
303213
0 commit comments