Skip to content

Commit 8e96307

Browse files
committed
create editor actions reducer
1 parent 59d4389 commit 8e96307

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+154
-88
lines changed

lib/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ exports.alertClose = actions_1.alertClose;
55
exports.alertReplay = actions_1.alertReplay;
66
var actions_2 = require('./modules/editor/actions');
77
exports.editorDevToolsToggle = actions_2.editorDevToolsToggle;
8+
exports.editorOpen = actions_2.editorOpen;
9+
exports.editorInsert = actions_2.editorInsert;
10+
exports.editorSave = actions_2.editorSave;
11+
exports.editorSet = actions_2.editorSet;
812
var actions_3 = require('./modules/hints/actions');
913
exports.hintPositionSet = actions_3.hintPositionSet;
1014
var actions_4 = require('./modules/page/actions');

lib/components/Page/PageToolbar/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
var React = require('react');
33
var Toolbar_1 = require('material-ui/Toolbar');
44
var index_1 = require('../../index');
5-
var Continue_1 = require('./Continue');
65
var styles = {
76
zIndex: '5',
87
position: 'relative',
@@ -15,7 +14,7 @@ var styles = {
1514
exports.PageToolbar = function (_a) {
1615
var tasks = _a.tasks, taskPosition = _a.taskPosition, children = _a.children;
1716
return (React.createElement("section", {styles: styles}, children, React.createElement(Toolbar_1.Toolbar, null, React.createElement(Toolbar_1.ToolbarGroup, {float: 'left'}, React.createElement(index_1.ToggleDevTools, null)), React.createElement(Toolbar_1.ToolbarGroup, {float: 'right'}, taskPosition >= tasks.length ?
18-
React.createElement(Continue_1.default, null) : React.createElement(index_1.Save, null)))));
17+
React.createElement(index_1.Continue, null) : React.createElement(index_1.Save, null)))));
1918
};
2019
Object.defineProperty(exports, "__esModule", { value: true });
2120
exports.default = exports.PageToolbar;

lib/components/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ var tutorials_1 = require('../modules/tutorials');
2525
exports.Tutorials = tutorials_1.Tutorials;
2626
var editor_1 = require('../modules/editor');
2727
exports.ToggleDevTools = editor_1.ToggleDevTools;
28-
var editor_2 = require('../modules/editor');
29-
exports.Save = editor_2.Save;
28+
exports.Save = editor_1.Save;
29+
var page_1 = require('../modules/page');
30+
exports.Continue = page_1.Continue;

lib/modules/editor/actions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ function editorDevToolsToggle() {
44
return { type: types_1.EDITOR_DEVTOOLS_TOGGLE };
55
}
66
exports.editorDevToolsToggle = editorDevToolsToggle;
7+
function editorInsert(content) {
8+
return { type: types_1.EDITOR_INSERT, payload: { content: content } };
9+
}
10+
exports.editorInsert = editorInsert;
11+
function editorOpen(file, options) {
12+
return { type: types_1.EDITOR_OPEN, payload: { file: file, options: options } };
13+
}
14+
exports.editorOpen = editorOpen;
715
function editorSave() {
816
return { type: types_1.EDITOR_SAVE };
917
}
1018
exports.editorSave = editorSave;
19+
function editorSet(content) {
20+
return { type: types_1.EDITOR_SET, payload: { content: content } };
21+
}
22+
exports.editorSet = editorSet;

lib/modules/editor/actions/file.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
var fs_1 = require('fs');
33
var node_file_exists_1 = require('node-file-exists');
44
var editor_1 = require('./editor');
5-
var openTimeout = 200;
65
function openFolder() {
76
atom.open();
87
}
@@ -11,13 +10,14 @@ function save() {
1110
editor_1.getEditor().then(function (editor) { return editor.save(); });
1211
}
1312
exports.save = save;
14-
function open(filePath, options) {
13+
function open(file, options) {
1514
if (options === void 0) { options = {}; }
1615
return new Promise(function (resolve, reject) {
17-
if (node_file_exists_1.default(filePath)) {
18-
fs_1.unlink(filePath);
16+
if (node_file_exists_1.default(file)) {
17+
fs_1.unlink(file);
1918
}
20-
atom.workspace.open(filePath, options);
19+
var openTimeout = 200;
20+
atom.workspace.open(file, options);
2121
setTimeout(function () { return resolve(); }, openTimeout);
2222
});
2323
}

lib/modules/editor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
var reducer_1 = require('./reducer');
3-
exports.reducer = reducer_1.default;
3+
exports.editor = reducer_1.default;
44
var dir_1 = require('./dir');
55
exports.dir = dir_1.default;
66
var ToggleDevTools_1 = require('./ToggleDevTools');

lib/modules/editor/reducer.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ function editor(editor, action) {
1010
case types_1.EDITOR_SAVE:
1111
index_1.save();
1212
return editor;
13+
case types_1.EDITOR_OPEN:
14+
var _a = action.payload, file = _a.file, options = _a.options;
15+
index_1.open(file, options);
16+
return editor;
17+
case types_1.EDITOR_INSERT:
18+
index_1.insert(action.payload.content);
19+
return editor;
20+
case types_1.EDITOR_SET:
21+
index_1.set(action.payload.content);
22+
return editor;
1323
default:
1424
return editor;
1525
}

lib/modules/editor/types.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
"use strict";
22
exports.EDITOR_DEVTOOLS_TOGGLE = 'EDITOR_DEVTOOLS_TOGGLE';
3+
exports.EDITOR_INSERT = 'EDITOR_INSERT';
4+
exports.EDITOR_OPEN = 'EDITOR_OPEN';
35
exports.EDITOR_SAVE = 'EDITOR_SAVE';
6+
exports.EDITOR_SET = 'EDITOR_SET';

lib/components/Page/PageToolbar/Continue/index.js renamed to lib/modules/page/Continue/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
1616
var React = require('react');
1717
var react_redux_1 = require('react-redux');
1818
var RaisedButton_1 = require('material-ui/RaisedButton');
19-
var actions_1 = require('../../../../actions');
19+
var actions_1 = require('../actions');
2020
var styles = {
2121
zIndex: '10000',
2222
border: '0px',

lib/modules/page/actions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
"use strict";
22
var types_1 = require('./types');
33
var actions_1 = require('../../actions');
4+
var actions_2 = require('../../actions');
5+
exports.editorOpen = actions_2.editorOpen;
6+
exports.editorSave = actions_2.editorSave;
7+
exports.editorSet = actions_2.editorSet;
8+
exports.editorInsert = actions_2.editorInsert;
49
function pageNext() {
510
return function (dispatch, getState) {
611
var pagePosition = getState().pagePosition;

0 commit comments

Comments
 (0)