Skip to content

Commit 7bbe69c

Browse files
committed
Merge branch 'v0.5.4'
* v0.5.4: bump up version to v0.5.4 emit ARTICLE_CREATE when new post clicked update h1 style of markdown fix go to line end clean old code fix sanitizing bug in Code block done but bugged Conflicts: package.json
2 parents ba76df8 + e921e30 commit 7bbe69c

9 files changed

Lines changed: 56 additions & 34 deletions

File tree

browser/components/CodeEditor.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,49 @@ export default class CodeEditor extends React.Component {
3535

3636
if (this.props.onBlur) this.props.onBlur(e)
3737
}
38+
39+
this.killedBuffer = ''
40+
this.execHandler = (e) => {
41+
console.log(e.command.name)
42+
switch (e.command.name) {
43+
case 'gotolineend':
44+
e.preventDefault()
45+
let position = this.editor.getCursorPosition()
46+
this.editor.navigateTo(position.row, this.editor.getSession().getLine(position.row).length)
47+
break
48+
case 'removetolineend':
49+
e.preventDefault()
50+
let range = this.editor.getSelectionRange()
51+
let session = this.editor.getSession()
52+
if (range.isEmpty()) {
53+
range.setEnd(range.start.row, session.getLine(range.start.row).length)
54+
this.killedBuffer = session.getTextRange(range)
55+
if (this.killedBuffer.length > 0) {
56+
console.log('remove to lineend')
57+
session.remove(range)
58+
} else {
59+
if (session.getLength() === range.start.row) {
60+
return
61+
}
62+
range.setStart(range.start.row, range.end.col)
63+
range.setEnd(range.start.row + 1, 0)
64+
this.killedBuffer = '\n'
65+
session.remove(range)
66+
}
67+
} else {
68+
this.killedBuffer = session.getTextRange(range)
69+
session.remove(range)
70+
}
71+
}
72+
}
3873
this.afterExecHandler = (e) => {
3974
switch (e.command.name) {
4075
case 'find':
4176
Array.prototype.forEach.call(ReactDOM.findDOMNode(this).querySelectorAll('.ace_search_field, .ace_searchbtn, .ace_replacebtn, .ace_searchbtn_close'), el => {
4277
el.removeEventListener('blur', this.blurHandler)
4378
el.addEventListener('blur', this.blurHandler)
4479
})
80+
break
4581
}
4682
}
4783

@@ -83,6 +119,14 @@ export default class CodeEditor extends React.Component {
83119
},
84120
readOnly: true
85121
})
122+
editor.commands.addCommand({
123+
name: 'Emacs cursor up',
124+
bindKey: {mac: 'Ctrl-Y'},
125+
exec: function (editor) {
126+
editor.insert(this.killedBuffer)
127+
}.bind(this),
128+
readOnly: true
129+
})
86130
editor.commands.addCommand({
87131
name: 'Focus title',
88132
bindKey: {win: 'Esc', mac: 'Esc'},
@@ -96,6 +140,7 @@ export default class CodeEditor extends React.Component {
96140
readOnly: true
97141
})
98142

143+
editor.commands.on('exec', this.execHandler)
99144
editor.commands.on('afterExec', this.afterExecHandler)
100145

101146
var session = editor.getSession()
@@ -120,6 +165,7 @@ export default class CodeEditor extends React.Component {
120165
ipc.removeListener('config-apply', this.configApplyHandler)
121166
this.editor.getSession().removeListener('change', this.changeHandler)
122167
this.editor.removeListener('blur', this.blurHandler)
168+
this.editor.commands.removeListener('exec', this.execHandler)
123169
this.editor.commands.removeListener('afterExec', this.afterExecHandler)
124170
}
125171

browser/lib/activityRecord.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function emit (type, data = {}) {
108108
}
109109

110110
// Count ARTICLE_CREATE and ARTICLE_UPDATE again by syntax
111-
if ((type === 'ARTICLE_CREATE' || type === 'ARTICLE_UPDATE') && data.mode != null) {
111+
if (type === 'ARTICLE_UPDATE' && data.mode != null) {
112112
let recordKey = type + '_BY_SYNTAX'
113113
if (todayRecord[recordKey] == null) todayRecord[recordKey] = {}
114114

browser/lib/markdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var md = markdownit({
1414
return hljs.highlight(lang, str).value
1515
} catch (e) {}
1616
}
17-
return str
17+
return str.replace(/\&/g, '&amp;').replace(/\</g, '&lt;').replace(/\>/g, '&gt;').replace(/\"/g, '&quot;')
1818
}
1919
})
2020
md.use(emoji, {

browser/main/HomePage/ArticleDetail/ArticleEditor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export default class ArticleEditor extends React.Component {
3232
}
3333

3434
componentDidMount () {
35-
console.log(this.state.switchPreview)
3635
ipc.on('config-apply', this.configApplyHandler)
3736
}
3837

browser/main/HomePage/ArticleDetail/index.js

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import moment from 'moment'
44
import _ from 'lodash'
55
import {
66
switchFolder,
7-
updateArticle,
8-
// cacheArticle,
9-
// saveArticle,
10-
// uncacheArticle
7+
updateArticle
118
} from '../../actions'
129
import linkState from 'browser/lib/linkState'
1310
import TagSelect from 'browser/components/TagSelect'
@@ -19,22 +16,6 @@ import ArticleEditor from './ArticleEditor'
1916
const electron = require('electron')
2017
const ipc = electron.ipcRenderer
2118

22-
// const remote = electron.remote
23-
// const { Menu, MenuItem } = remote
24-
// const othersMenu = new Menu()
25-
// othersMenu.append(new MenuItem({
26-
// label: 'Delete Post',
27-
// click: function () {
28-
// remote.getCurrentWebContents().send('detail-delete')
29-
// }
30-
// }))
31-
// othersMenu.append(new MenuItem({
32-
// label: 'Discard Change',
33-
// click: function (item) {
34-
// remote.getCurrentWebContents().send('detail-uncache')
35-
// }
36-
// }))
37-
3819
const BRAND_COLOR = '#18AF90'
3920
const OSX = global.process.platform === 'darwin'
4021

@@ -80,10 +61,6 @@ export default class ArticleDetail extends React.Component {
8061
constructor (props) {
8162
super(props)
8263

83-
this.saveHandler = e => {
84-
if (isModalOpen()) return true
85-
this.handleSaveButtonClick()
86-
}
8764
this.deleteHandler = e => {
8865
if (isModalOpen()) return true
8966
this.handleDeleteButtonClick()
@@ -119,7 +96,6 @@ export default class ArticleDetail extends React.Component {
11996
e.stopPropagation()
12097
}
12198

122-
// ipc.on('detail-save', this.saveHandler)
12399
ipc.on('detail-delete', this.deleteHandler)
124100
ipc.on('detail-uncache', this.uncacheHandler)
125101
ipc.on('detail-title', this.titleHandler)
@@ -130,7 +106,6 @@ export default class ArticleDetail extends React.Component {
130106
componentWillUnmount () {
131107
clearInterval(this.refreshTimer)
132108

133-
// ipc.removeListener('detail-save', this.saveHandler)
134109
ipc.removeListener('detail-delete', this.deleteHandler)
135110
ipc.removeListener('detail-uncache', this.uncacheHandler)
136111
ipc.removeListener('detail-title', this.titleHandler)

browser/main/HomePage/ArticleTopBar.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ExternalLink from 'browser/components/ExternalLink'
44
import { setSearchFilter, clearSearch, toggleTutorial, saveArticle, switchFolder } from '../actions'
55
import { isModalOpen } from 'browser/lib/modal'
66
import keygen from 'browser/lib/keygen'
7+
import activityRecord from 'browser/lib/activityRecord'
78

89
const electron = require('electron')
910
const remote = electron.remote
@@ -167,6 +168,7 @@ export default class ArticleTopBar extends React.Component {
167168
dispatch(saveArticle(newArticle.key, newArticle, true))
168169
if (isFolderFilterApplied) dispatch(switchFolder(targetFolders[0].name))
169170
remote.getCurrentWebContents().send('detail-title')
171+
activityRecord.emit('ARTICLE_CREATE')
170172
}
171173

172174
handleTutorialButtonClick (e) {

browser/styles/mixins/marked.styl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ marked()
4848
*:not(a.lineAnchor) + h1, *:not(a.lineAnchor) + h2, *:not(a.lineAnchor) + h3, *:not(a.lineAnchor) + h4, *:not(a.lineAnchor) + h5, *:not(a.lineAnchor) + h6
4949
margin-top 25px
5050
h1
51-
font-size 2em
51+
font-size 1.8em
5252
border-bottom solid 2px borderColor
53-
line-height 2.333em
53+
line-height 2em
5454
h2
5555
font-size 1.66em
56-
line-height 2.07em
56+
line-height 1.8em
5757
h3
5858
font-size 1.33em
5959
line-height 1.6625em

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "boost",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"description": "Boostnote",
55
"main": "index.js",
66
"scripts": {

submodules/ace

Submodule ace updated 334 files

0 commit comments

Comments
 (0)