Skip to content

Commit eecf064

Browse files
committed
changes
1 parent eb8d3c2 commit eecf064

File tree

14 files changed

+89
-217
lines changed

14 files changed

+89
-217
lines changed

src/actions/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import {
2727
editorBlurred,
2828
editorFocused,
2929
editorFocusedRequestedLine,
30+
<<<<<<< HEAD
31+
=======
32+
editorResized,
33+
dragRowDivider,
34+
dragColumnDivider,
35+
>>>>>>> 66eba11... changes
3036
startDragColumnDivider,
3137
stopDragColumnDivider,
3238
notificationTriggered,
@@ -105,8 +111,14 @@ export {
105111
editorBlurred,
106112
editorFocused,
107113
editorFocusedRequestedLine,
114+
<<<<<<< HEAD
108115
previousConsoleHistory,
109116
nextConsoleHistory,
117+
=======
118+
editorResized,
119+
dragRowDivider,
120+
dragColumnDivider,
121+
>>>>>>> 66eba11... changes
110122
startDragColumnDivider,
111123
stopDragColumnDivider,
112124
notificationTriggered,

src/actions/ui.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ export const editorFocusedRequestedLine = createAction(
1212
'EDITOR_FOCUSED_REQUESTED_LINE',
1313
);
1414

15+
export const editorFocused = createAction(
16+
'EDITOR_FOCUSED',
17+
language => ({language}),
18+
);
19+
20+
export const editorBlurred = createAction(
21+
'EDITOR_BLURRED',
22+
);
23+
24+
export const editorResized = createAction(
25+
'EDITOR_RESIZED',
26+
);
27+
1528
export const startDragColumnDivider = createAction(
1629
'START_DRAG_COLUMN_DIVIDER',
1730
);

src/components/Editor.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Editor extends React.Component {
3535
this._handleWindowResize = throttle(() => {
3636
if (this._editor) {
3737
this._resizeEditor();
38+
this.props.onEditorResized();
3839
}
3940
}, RESIZE_THROTTLE);
4041

@@ -126,7 +127,7 @@ class Editor extends React.Component {
126127
<<<<<<< HEAD
127128
=======
128129
this._editor.on('blur', () => {
129-
this.props.onEditorBlurred(this.props.language);
130+
this.props.onEditorBlurred();
130131
});
131132
this._editor.on('focus', () => {
132133
this.props.onEditorFocused(this.props.language);
@@ -189,6 +190,7 @@ Editor.propTypes = {
189190
onCursorChange: PropTypes.func.isRequired,
190191
onEditorBlurred: PropTypes.func.isRequired,
191192
onEditorFocused: PropTypes.func.isRequired,
193+
onEditorResized: PropTypes.func.isRequired,
192194
onInput: PropTypes.func.isRequired,
193195
onRequestedLineFocused: PropTypes.func.isRequired,
194196
};

src/components/EditorsColumn.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ export default function EditorsColumn({
6767
source={currentProject.sources[language]}
6868
textSizeIsLarge={isTextSizeLarge}
6969
onCursorChange={onEditorCursorChange}
70+
onEditorBlurred={onEditorBlurred}
71+
onEditorFocused={onEditorFocused}
72+
onEditorResized={onEditorResized}
7073
onInput={partial(
7174
onEditorInput,
7275
currentProject.projectKey,
@@ -138,6 +141,7 @@ EditorsColumn.propTypes = {
138141
onEditorCursorChange: PropTypes.func.isRequired,
139142
onEditorFocused: PropTypes.func.isRequired,
140143
onEditorInput: PropTypes.func.isRequired,
144+
onEditorResized: PropTypes.func.isRequired,
141145
onRef: PropTypes.func.isRequired,
142146
onRequestedLineFocused: PropTypes.func.isRequired,
143147
onResizableFlexDividerDrag: PropTypes.func.isRequired,

src/components/Preview.jsx

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,18 @@
11
import get from 'lodash-es/get';
22
import PropTypes from 'prop-types';
3-
<<<<<<< HEAD
43
import ImmutablePropTypes from 'react-immutable-proptypes';
54
import React from 'react';
6-
=======
7-
import isNil from 'lodash/isNil';
8-
import partial from 'lodash/partial';
9-
import classnames from 'classnames';
10-
import generatePreview, {generateTextPreview} from '../util/previewFrame';
11-
import PreviewFrame from './PreviewFrame';
12-
13-
function generateFrameSrc(
14-
project,
15-
isSyntacticallyValid,
16-
lastRefreshTimestamp,
17-
) {
18-
if (isNil(project) || !isSyntacticallyValid) {
19-
return '';
20-
}
21-
>>>>>>> 23eb7f2... Updates to element highlighter
225

236
import PreviewFrame from './PreviewFrame';
247

258
export default function Preview({
26-
<<<<<<< HEAD
27-
<<<<<<< HEAD
28-
=======
29-
focusedEditors,
30-
focusedSelector,
31-
>>>>>>> 3cc1d22... Update selector at cursor and handle unfocused editor
329
compiledProjects,
3310
consoleEntries,
3411
highlighterSelector,
3512
showingErrors,
3613
onConsoleError,
3714
onConsoleLog,
3815
onConsoleValue,
39-
=======
40-
focusedEditors,
41-
focusedSelector,
42-
isSyntacticallyValid,
43-
lastRefreshTimestamp,
44-
project,
45-
>>>>>>> 23eb7f2... Updates to element highlighter
4616
onPopOutProject,
4717
onRefreshClick,
4818
onRuntimeError,
@@ -55,8 +25,6 @@ export default function Preview({
5525
<PreviewFrame
5626
compiledProject={compiledProject}
5727
consoleEntries={consoleEntries}
58-
focusedEditors={focusedEditors}
59-
focusedSelector={focusedSelector}
6028
isActive={key === compiledProjects.keySeq().last()}
6129
key={compiledProject.compiledProjectKey}
6230
onConsoleError={onConsoleError}
@@ -82,69 +50,25 @@ export default function Preview({
8250
onClick={onRefreshClick}
8351
>&#xf021;</span>
8452
</div>
85-
<<<<<<< HEAD
8653
{projectFrames}
8754
// focusedSelector={focusedSelector}
88-
=======
89-
<PreviewFrame
90-
focusedEditors={focusedEditors}
91-
focusedSelector={focusedSelector}
92-
src={
93-
generateFrameSrc(project, isSyntacticallyValid, lastRefreshTimestamp)
94-
}
95-
onRuntimeError={onRuntimeError}
96-
/>
97-
>>>>>>> 23eb7f2... Updates to element highlighter
9855
</div>
9956
);
10057
}
10158

10259
Preview.propTypes = {
103-
<<<<<<< HEAD
104-
<<<<<<< HEAD
105-
<<<<<<< HEAD
10660
compiledProjects: ImmutablePropTypes.iterable.isRequired,
10761
consoleEntries: ImmutablePropTypes.iterable.isRequired,
108-
=======
109-
compiledProjects: ImmutablePropTypes.iterable.isRequired,
110-
consoleEntries: ImmutablePropTypes.iterable.isRequired,
111-
focusedEditors: PropTypes.array.isRequired,
112-
>>>>>>> 3cc1d22... Update selector at cursor and handle unfocused editor
11362
focusedSelector: PropTypes.string,
11463
showingErrors: PropTypes.bool.isRequired,
11564
onConsoleError: PropTypes.func.isRequired,
11665
onConsoleLog: PropTypes.func.isRequired,
11766
onConsoleValue: PropTypes.func.isRequired,
118-
=======
119-
=======
120-
focusedEditors: PropTypes.array.isRequired,
121-
>>>>>>> 23eb7f2... Updates to element highlighter
122-
focusedSelector: PropTypes.string,
123-
isSyntacticallyValid: PropTypes.bool.isRequired,
124-
lastRefreshTimestamp: PropTypes.number,
125-
project: PropTypes.shape({
126-
sources: PropTypes.shape({
127-
html: PropTypes.string.isRequired,
128-
css: PropTypes.string.isRequired,
129-
javascript: PropTypes.string.isRequired,
130-
}).isRequired,
131-
enabledLibraries: PropTypes.arrayOf(PropTypes.string).isRequired,
132-
}).isRequired,
133-
>>>>>>> 621d5f6... Add saga, add ref to iframe element
13467
onPopOutProject: PropTypes.func.isRequired,
13568
onRefreshClick: PropTypes.func.isRequired,
13669
onRuntimeError: PropTypes.func.isRequired,
13770
};
13871

13972
Preview.defaultProps = {
140-
<<<<<<< HEAD
141-
<<<<<<< HEAD
142-
highlighterSelector: '',
143-
=======
144-
focusedSelector: null,
145-
lastRefreshTimestamp: null,
146-
>>>>>>> 621d5f6... Add saga, add ref to iframe element
147-
=======
14873
focusedSelector: null,
149-
>>>>>>> 3cc1d22... Update selector at cursor and handle unfocused editor
15074
};

src/components/PreviewFrame.jsx

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ import React from 'react';
33
import PropTypes from 'prop-types';
44
import ImmutablePropTypes from 'react-immutable-proptypes';
55
import Bowser from 'bowser';
6-
<<<<<<< HEAD
76
import bindAll from 'lodash-es/bindAll';
87
import constant from 'lodash-es/constant';
9-
=======
10-
import bindAll from 'lodash/bindAll';
11-
import includes from 'lodash/includes';
12-
>>>>>>> 23eb7f2... Updates to element highlighter
138
import {t} from 'i18next';
149

1510
import 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

2824
let nextId = 1;
2925

3026
class 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-
>>>>>>> 8ca6c3c... 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-
>>>>>>> 3cc1d22... 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-
>>>>>>> 8ca6c3c... update to js channel
86-
const {consoleEntries: previousConsoleEntries, isActive} = this.props;
87-
>>>>>>> 3cc1d22... 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-
>>>>>>> 8ca6c3c... 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-
>>>>>>> 23eb7f2... Updates to element highlighter
252176
}
253177

254178
this._channel = Channel.build({
@@ -273,31 +197,17 @@ class PreviewFrame extends React.Component {
273197
}
274198

275199
PreviewFrame.propTypes = {
276-
<<<<<<< HEAD
277-
<<<<<<< HEAD
278-
<<<<<<< HEAD
279200
compiledProject: PropTypes.instanceOf(CompiledProjectRecord).isRequired,
280201
consoleEntries: ImmutablePropTypes.iterable.isRequired,
281-
=======
282-
focusedEditors: PropTypes.array,
283-
>>>>>>> 23eb7f2... Updates to element highlighter
284-
=======
285-
consoleEntries: ImmutablePropTypes.iterable.isRequired,
286-
focusedEditors: PropTypes.array,
287-
>>>>>>> 3cc1d22... 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-
>>>>>>> 621d5f6... Add saga, add ref to iframe element
296207
onRuntimeError: PropTypes.func.isRequired,
297208
};
298209

299210
PreviewFrame.defaultProps = {
300-
focusedEditors: null,
301211
focusedSelector: null,
302212
};
303213

0 commit comments

Comments
 (0)