Skip to content

Commit b74e1ae

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

File tree

3 files changed

+18
-65
lines changed

3 files changed

+18
-65
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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ class Editor extends React.Component {
125125
this._resizeEditor();
126126
this._editor.on('focus', this._resizeEditor);
127127
<<<<<<< HEAD
128+
<<<<<<< HEAD
128129
=======
129130
this._editor.on('blur', () => {
130131
this.props.onEditorBlurred();
131132
});
132133
this._editor.on('focus', () => {
133134
this.props.onEditorFocused(this.props.language);
134135
});
136+
=======
137+
>>>>>>> ec49c81... Handle fixed potion, handle body and html, handle resize, handle editor refocus to same line
135138
this._editor.setOptions({
136139
fontFamily: 'Inconsolata',
137140
fontSize: '14px',
@@ -152,17 +155,27 @@ class Editor extends React.Component {
152155

153156
_startNewSession(source) {
154157
const session = createAceSessionWithoutWorker(this.props.language, source);
158+
const cursor = session.selection.lead;
155159
session.on('change', () => {
156160
this.props.onInput(this._editor.getValue());
157161
});
158162
session.selection.on('changeCursor', () => {
159-
const cursor = session.selection.lead;
160163
this.props.onCursorChange(
161164
this._editor.getValue(),
162165
cursor,
163166
this.props.language,
164167
);
165168
});
169+
this._editor.on('blur', () => {
170+
this.props.onEditorBlurred();
171+
});
172+
this._editor.on('focus', () => {
173+
this.props.onEditorFocused(
174+
this._editor.getValue(),
175+
cursor,
176+
this.props.language,
177+
);
178+
});
166179
session.setAnnotations(this.props.errors);
167180
this._editor.setSession(session);
168181
this._editor.moveCursorTo(0, 0);

src/reducers/ui.js

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
1-
<<<<<<< HEAD
21
import {Map} from 'immutable';
32

43
import {EditorLocation, Notification, UiState} from '../records';
54

65
const defaultState = new UiState();
76

87
function addNotification(state, type, severity, metadata = {}) {
9-
=======
10-
import Immutable from 'immutable';
11-
import {
12-
updateEditorColumnFlex,
13-
updateWorkspaceRowFlex,
14-
} from '../util/resize';
15-
16-
17-
const DEFAULT_COLUMN_FLEX = new Immutable.List(['1', '1', '1']);
18-
const DEFAULT_ROW_FLEX = new Immutable.List(['1', '1']);
19-
export const DEFAULT_WORKSPACE = new Immutable.Map({
20-
columnFlex: DEFAULT_COLUMN_FLEX,
21-
rowFlex: DEFAULT_ROW_FLEX,
22-
isDraggingColumnDivider: false,
23-
});
24-
25-
const defaultState = new Immutable.Map().
26-
set('editors', new Immutable.Map({
27-
typing: false,
28-
requestedFocusedLine: null,
29-
textSizeIsLarge: false,
30-
focusedSelector: null,
31-
focusedEditor: null,
32-
})).
33-
set('workspace', DEFAULT_WORKSPACE).
34-
set('notifications', new Immutable.Map()).
35-
set('topBar', new Immutable.Map({openMenu: null})).
36-
set('lastRefreshTimestamp', null);
37-
38-
function addNotification(state, type, severity, payload = {}) {
39-
>>>>>>> 54c9f3a... Update Element Highlighter
408
return state.setIn(
419
['notifications', type],
4210
new Notification({type, severity, metadata: new Map(metadata)}),
@@ -72,9 +40,10 @@ export default function ui(stateIn, action) {
7240
case 'UPDATE_PROJECT_SOURCE':
7341
return state.set('isTyping', true);
7442

75-
case 'CURRENT_FOCUSED_SELECTOR_CHANGED':
43+
case 'UPDATE_HIGHLIGHTER_SELECTOR':
7644
return state.setIn(
77-
['editors', 'focusedSelector'], action.payload,
45+
['editors', 'highlighterSelector'],
46+
action.payload.selector,
7847
);
7948

8049
case 'USER_DONE_TYPING':
@@ -90,7 +59,6 @@ export default function ui(stateIn, action) {
9059
}),
9160
);
9261

93-
<<<<<<< HEAD
9462
case 'CLEAR_CONSOLE_ENTRIES':
9563
return state.set(
9664
'requestedFocusedLine',
@@ -100,34 +68,6 @@ export default function ui(stateIn, action) {
10068
column: 0,
10169
}),
10270
);
103-
=======
104-
case 'EDITOR_FOCUSED_REQUESTED_LINE':
105-
return state.setIn(['editors', 'requestedFocusedLine'], null);
106-
107-
case 'EDITOR_FOCUSED':
108-
return state.setIn(
109-
['editors', 'focusedEditor'],
110-
action.payload.language,
111-
);
112-
113-
case 'EDITOR_BLURRED':
114-
return state.setIn(
115-
['editors', 'focusedEditor'],
116-
null,
117-
);
118-
119-
case 'EDITOR_RESIZED':
120-
return state.setIn(
121-
['editors', 'focusedSelector'],
122-
null,
123-
);
124-
125-
case 'DRAG_ROW_DIVIDER':
126-
return state.updateIn(['workspace', 'columnFlex'], (prevFlex) => {
127-
const newFlex = updateEditorColumnFlex(action.payload);
128-
return newFlex ? Immutable.fromJS(newFlex) : prevFlex;
129-
});
130-
>>>>>>> 23eb7f2... Updates to element highlighter
13171

13272
case 'EDITOR_FOCUSED_REQUESTED_LINE':
13373
return state.set('requestedFocusedLine', null);

0 commit comments

Comments
 (0)