diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 76b73941..ffcf933d 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -47,7 +47,23 @@ export default class CodeEditor extends React.Component { theme: this.props.theme, indentUnit: this.props.indentSize, tabSize: this.props.indentSize, - indentWithTabs: this.props.indentType !== 'space' + indentWithTabs: this.props.indentType !== 'space', + keyMap: 'sublime', + extraKeys: { + Tab: function (cm) { + if (cm.somethingSelected()) cm.indentSelection('add') + else { + if (cm.getOption('indentWithTabs')) { + cm.execCommand('insertTab') + } else { + cm.execCommand('insertSoftTab') + } + } + }, + 'Cmd-T': function (cm) { + // Do nothing + } + } }) this.setMode(this.props.mode) diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index 43b129ec..04d7770d 100644 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -9,6 +9,8 @@ import dataApi from 'browser/main/lib/dataApi' import { hashHistory } from 'react-router' import ee from 'browser/main/lib/eventEmitter' import markdown from 'browser/lib/markdown' +import StatusBar from '../StatusBar' +import _ from 'lodash' const electron = require('electron') const { remote } = electron @@ -253,7 +255,7 @@ class MarkdownNoteDetail extends React.Component { onClick={(e) => this.handleShareButtonClick(e)} disabled > - + Share Note @@ -261,7 +263,7 @@ class MarkdownNoteDetail extends React.Component { + + + + + ) } diff --git a/browser/main/Detail/SnippetNoteDetail.styl b/browser/main/Detail/SnippetNoteDetail.styl index 407475af..3cec053f 100644 --- a/browser/main/Detail/SnippetNoteDetail.styl +++ b/browser/main/Detail/SnippetNoteDetail.styl @@ -59,8 +59,9 @@ $info-height = 75px opacity 0 .body - absolute bottom left right + absolute left right top $info-height + bottom $statusBar-height .body .description absolute top left right @@ -101,6 +102,19 @@ $info-height = 75px .tabView-content absolute top left right bottom +.override + absolute bottom left + height 23px + z-index 1 + button + navButtonColor() + height 24px + border-width 0 1px 0 0 + border-style solid + border-color $ui-borderColor + &:active .update-icon + color white + body[data-theme="dark"] .root border-color $ui-dark-borderColor @@ -151,15 +165,3 @@ body[data-theme="dark"] .tabList .plusButton navDarkButtonColor() - - .tabView-top-mode - border-color $ui-dark-borderColor - background-color $dark-default-button-background - color $ui-dark-inactive-text-color - &:hover - color $ui-dark-text-color - background-color $ui-dark-button--hover-backgroundColor - &:active - background-color $ui-dark-button--active-backgroundColor - &:active:hover - background-color $ui-dark-button--active-backgroundColor diff --git a/browser/main/Detail/index.js b/browser/main/Detail/index.js index 89d1dd56..a1eb249d 100644 --- a/browser/main/Detail/index.js +++ b/browser/main/Detail/index.js @@ -5,6 +5,7 @@ import _ from 'lodash' import MarkdownNoteDetail from './MarkdownNoteDetail' import SnippetNoteDetail from './SnippetNoteDetail' import ee from 'browser/main/lib/eventEmitter' +import StatusBar from '../StatusBar' const OSX = global.process.platform === 'darwin' @@ -48,8 +49,11 @@ class Detail extends React.Component { tabIndex='0' >
-
{OSX ? 'Command(⌘)' : 'Ctrl(^)'} + N
to create a new post
+
{OSX ? 'Command(⌘)' : 'Ctrl(^)'} + N
to create a new post
+ ) } diff --git a/browser/main/Main.js b/browser/main/Main.js index 17128467..e3d40759 100644 --- a/browser/main/Main.js +++ b/browser/main/Main.js @@ -7,7 +7,6 @@ import TopBar from './TopBar' import NoteList from './NoteList' import Detail from './Detail' import dataApi from 'browser/main/lib/dataApi' -import StatusBar from './StatusBar' import _ from 'lodash' import ConfigManager from 'browser/main/lib/ConfigManager' import modal from 'browser/main/lib/modal' @@ -32,6 +31,15 @@ class Main extends React.Component { } } + getChildContext () { + let { status, config } = this.props + + return { + status, + config + } + } + componentDidMount () { let { dispatch, config } = this.props @@ -188,7 +196,7 @@ class Main extends React.Component { onMouseDown={(e) => this.handleRightSlideMouseDown(e)} draggable='false' > -
+
- ) } } +Main.childContextTypes = { + status: PropTypes.shape({ + updateReady: PropTypes.bool.isRequired + }).isRequired, + config: PropTypes.shape({}).isRequired +} + Main.propTypes = { dispatch: PropTypes.func, data: PropTypes.shape({}).isRequired diff --git a/browser/main/Main.styl b/browser/main/Main.styl index 44d08854..51c5e0de 100644 --- a/browser/main/Main.styl +++ b/browser/main/Main.styl @@ -2,8 +2,7 @@ absolute top left bottom right .body - absolute right top - bottom $statusBar-height - 1 + absolute right top bottom left $sideNav-width .body--expanded diff --git a/browser/main/NoteList/NoteList.styl b/browser/main/NoteList/NoteList.styl index a39ec4cd..a20485e4 100644 --- a/browser/main/NoteList/NoteList.styl +++ b/browser/main/NoteList/NoteList.styl @@ -1,7 +1,6 @@ .root absolute left bottom border-top $ui-border - border-bottom $ui-border top $topBar-height - 1 .control diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index f735d197..b6519db8 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -45,7 +45,7 @@ class NoteList extends React.Component { this.refreshTimer = setInterval(() => this.forceUpdate(), 60 * 1000) ee.on('list:next', this.selectNextNoteHandler) ee.on('list:prior', this.selectPriorNoteHandler) - ee.on('lost:focus', this.focusHandler) + ee.on('list:focus', this.focusHandler) } componentWillReceiveProps (nextProps) { @@ -63,7 +63,7 @@ class NoteList extends React.Component { ee.off('list:next', this.selectNextNoteHandler) ee.off('list:prior', this.selectPriorNoteHandler) - ee.off('lost:focus', this.focusHandler) + ee.off('list:focus', this.focusHandler) } componentDidUpdate (prevProps) { diff --git a/browser/main/SideNav/SideNav.styl b/browser/main/SideNav/SideNav.styl index a8d4bbb1..bed9ca56 100644 --- a/browser/main/SideNav/SideNav.styl +++ b/browser/main/SideNav/SideNav.styl @@ -1,9 +1,7 @@ .root - absolute top left - bottom $statusBar-height - 1 + absolute top left bottom width $sideNav-width border-right $ui-border - border-bottom $ui-border background-color $ui-backgroundColor user-select none color $ui-text-color diff --git a/browser/main/StatusBar/StatusBar.styl b/browser/main/StatusBar/StatusBar.styl index e9259949..bbd0ba74 100644 --- a/browser/main/StatusBar/StatusBar.styl +++ b/browser/main/StatusBar/StatusBar.styl @@ -2,30 +2,31 @@ absolute bottom left right height $statusBar-height - 1 background-color $ui-backgroundColor + border-top $ui-border + display flex -.pathname - absolute left +.blank + flex 1 + +.help + navButtonColor() height 24px - overflow ellipsis - right 185px - line-height 24px - font-size 12px - padding 0 15px - color $ui-inactive-text-color + width 24px + border-width 0 0 0 1px + border-style solid + border-color $ui-borderColor + &:active .update-icon + color white .zoom navButtonColor() - absolute right height 24px - width 60px border-width 0 1px border-style solid border-color $ui-borderColor .update navButtonColor() - position absolute - right 60px height 24px border-width 0 0 0 1px border-style solid @@ -40,12 +41,14 @@ body[data-theme="dark"] .root background-color $ui-dark-backgroundColor - .pathname - color $ui-dark-inactive-text-color - .zoom border-color $ui-dark-borderColor + .help + navButtonColor() + border-color $ui-dark-borderColor + border-left 1px solid $ui-dark-borderColor + .update navDarkButtonColor() border-color $ui-dark-borderColor diff --git a/browser/main/StatusBar/index.js b/browser/main/StatusBar/index.js index c63194cb..a1863c1a 100644 --- a/browser/main/StatusBar/index.js +++ b/browser/main/StatusBar/index.js @@ -4,50 +4,12 @@ import styles from './StatusBar.styl' import ZoomManager from 'browser/main/lib/ZoomManager' const electron = require('electron') -const ipc = electron.ipcRenderer -const { remote } = electron +const { remote, ipcRenderer } = electron const { Menu, MenuItem, dialog } = remote const zoomOptions = [0.8, 0.9, 1, 1.1, 1.2, 1.3] -function notify (...args) { - return new window.Notification(...args) -} - class StatusBar extends React.Component { - constructor (props) { - super(props) - - this.state = { - updateReady: false - } - this.updateReadyHandler = (message) => { - this.setState({ - updateReady: true - }, () => { - notify('Update ready!', { - body: 'New Boostnote is ready to be installed.' - }) - this.updateApp() - }) - } - this.updateFoundHandler = (message) => { - notify('Update found!', { - body: 'Preparing to update...' - }) - } - } - - componentDidMount () { - ipc.on('update-ready', this.updateReadyHandler) - ipc.on('update-found', this.updateFoundHandler) - } - - componentWillUnmount () { - ipc.removeListener('update-ready', this.updateReadyHandler) - ipc.removeListener('update-found', this.updateFoundHandler) - } - updateApp () { let index = dialog.showMessageBox(remote.getCurrentWindow(), { type: 'warning', @@ -57,7 +19,7 @@ class StatusBar extends React.Component { }) if (index === 0) { - ipc.send('update-app-confirm') + ipcRenderer.send('update-app-confirm') } } @@ -84,23 +46,26 @@ class StatusBar extends React.Component { } render () { - let { config, location } = this.props + let { config, status } = this.context return (
-
{location.pathname + location.search}
- {this.state.updateReady +
+ {status.updateReady ? : null } +
@@ -108,6 +73,13 @@ class StatusBar extends React.Component { } } +StatusBar.contextTypes = { + status: PropTypes.shape({ + updateReady: PropTypes.bool.isRequired + }).isRequired, + config: PropTypes.shape({}).isRequired +} + StatusBar.propTypes = { config: PropTypes.shape({ zoom: PropTypes.number diff --git a/browser/main/index.js b/browser/main/index.js index 4175b814..5eeb89f9 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -9,12 +9,9 @@ import { syncHistoryWithStore } from 'react-router-redux' require('./lib/ipcClient') const electron = require('electron') -const ipc = electron.ipcRenderer -ipc.send('check-update', 'check-update') -window.addEventListener('online', function () { - ipc.send('check-update', 'check-update') -}) +const { remote, ipcRenderer } = electron +const { dialog } = remote document.addEventListener('drop', function (e) { e.preventDefault() @@ -32,18 +29,35 @@ if (process.env !== 'production') { let el = document.getElementById('content') const history = syncHistoryWithStore(hashHistory, store) +function notify (...args) { + return new window.Notification(...args) +} + +function updateApp () { + let index = dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'warning', + message: 'Update Boostnote', + detail: 'New Boostnote is ready to be installed.', + buttons: ['Restart & Install', 'Not Now'] + }) + + if (index === 0) { + ipcRenderer.send('update-app-confirm') + } +} + ReactDOM.render(( - - - + + + - + - - + + @@ -52,4 +66,25 @@ ReactDOM.render(( ), el, function () { let loadingCover = document.getElementById('loadingCover') loadingCover.parentNode.removeChild(loadingCover) + + ipcRenderer.on('update-ready', function () { + store.dispatch({ + type: 'UPDATE_AVAILABLE' + }) + notify('Update ready!', { + body: 'New Boostnote is ready to be installed.' + }) + updateApp() + }) + + ipcRenderer.on('update-found', function () { + notify('Update found!', { + body: 'Preparing to update...' + }) + }) + + ipcRenderer.send('update-check', 'check-update') + window.addEventListener('online', function () { + ipcRenderer.send('update-check', 'check-update') + }) }) diff --git a/browser/main/store.js b/browser/main/store.js index b38cd114..f90d886e 100644 --- a/browser/main/store.js +++ b/browser/main/store.js @@ -475,9 +475,24 @@ function config (state = defaultConfig, action) { return state } +const defaultStatus = { + updateReady: false +} + +function status (state = defaultStatus, action) { + switch (action.type) { + case 'UPDATE_AVAILABLE': + return Object.assign({}, defaultStatus, { + updateReady: true + }) + } + return state +} + let reducer = combineReducers({ data, config, + status, routing: routerReducer }) diff --git a/lib/main-app.js b/lib/main-app.js index 2a6711f9..12399ee2 100644 --- a/lib/main-app.js +++ b/lib/main-app.js @@ -67,8 +67,15 @@ updater.on('update-downloaded', (info) => { } }) +ipc.on('update-check', function (event, msg) { + if (isUpdateReady) { + mainWindow.webContents.send('update-ready', 'Update available!') + } else { + checkUpdate() + } +}) + ipc.on('update-app-confirm', function (event, msg) { - console.log('confirmed') if (isUpdateReady) { mainWindow.removeAllListeners() updater.install() diff --git a/lib/main.html b/lib/main.html index 17432a37..90a6b95d 100644 --- a/lib/main.html +++ b/lib/main.html @@ -56,6 +56,7 @@ +