Skip to content

Commit ec49c81

Browse files
committed
Handle fixed potion, handle body and html, handle resize, handle editor refocus to same line
1 parent f749cd5 commit ec49c81

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/actions/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const editorFocusedRequestedLine = createAction(
1414

1515
export const editorFocused = createAction(
1616
'EDITOR_FOCUSED',
17-
language => ({language}),
17+
(source, cursor, language) => ({source, cursor, language}),
1818
);
1919

2020
export const editorBlurred = createAction(

src/components/Editor.jsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ class Editor extends React.Component {
100100
this._startNewSession(this.props.source);
101101
this._resizeEditor();
102102
this._editor.on('focus', this._resizeEditor);
103-
this._editor.on('blur', () => {
104-
this.props.onEditorBlurred();
105-
});
106-
this._editor.on('focus', () => {
107-
this.props.onEditorFocused(this.props.language);
108-
});
109103
this._editor.setOptions({
110104
fontFamily: 'Inconsolata',
111105
fontSize: '14px',
@@ -125,17 +119,27 @@ class Editor extends React.Component {
125119

126120
_startNewSession(source) {
127121
const session = createAceSessionWithoutWorker(this.props.language, source);
122+
const cursor = session.selection.lead;
128123
session.on('change', () => {
129124
this.props.onInput(this._editor.getValue());
130125
});
131126
session.selection.on('changeCursor', () => {
132-
const cursor = session.selection.lead;
133127
this.props.onCursorChange(
134128
this._editor.getValue(),
135129
cursor,
136130
this.props.language,
137131
);
138132
});
133+
this._editor.on('blur', () => {
134+
this.props.onEditorBlurred();
135+
});
136+
this._editor.on('focus', () => {
137+
this.props.onEditorFocused(
138+
this._editor.getValue(),
139+
cursor,
140+
this.props.language,
141+
);
142+
});
139143
session.setAnnotations(this.props.errors);
140144
this._editor.setSession(session);
141145
this._editor.moveCursorTo(0, 0);

src/components/Workspace.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ class Workspace extends React.Component {
142142
this.props.dispatch(focusLine(language, line, column));
143143
}
144144

145-
_handleEditorFocused(language) {
146-
this.props.dispatch(editorFocused(language));
145+
_handleEditorFocused(source, cursor, language) {
146+
this.props.dispatch(editorFocused(source, cursor, language));
147147
}
148148

149149
_handleEditorBlurred() {

src/sagas/ui.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default function* () {
6565
debounceFor('UPDATE_PROJECT_SOURCE', userDoneTyping, 1000),
6666
takeEvery('POP_OUT_PROJECT', popOutProject),
6767
takeEvery('CURRENT_CURSOR_CHANGED', updateFocusedSelector),
68+
takeEvery('EDITOR_FOCUSED', updateFocusedSelector),
6869
takeEvery('EXPORT_PROJECT', exportProject),
6970
]);
7071
}

0 commit comments

Comments
 (0)