1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

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
This commit is contained in:
Rokt33r
2016-01-22 03:01:13 +09:00
9 changed files with 56 additions and 34 deletions

View File

@@ -35,6 +35,41 @@ export default class CodeEditor extends React.Component {
if (this.props.onBlur) this.props.onBlur(e)
}
this.killedBuffer = ''
this.execHandler = (e) => {
console.log(e.command.name)
switch (e.command.name) {
case 'gotolineend':
e.preventDefault()
let position = this.editor.getCursorPosition()
this.editor.navigateTo(position.row, this.editor.getSession().getLine(position.row).length)
break
case 'removetolineend':
e.preventDefault()
let range = this.editor.getSelectionRange()
let session = this.editor.getSession()
if (range.isEmpty()) {
range.setEnd(range.start.row, session.getLine(range.start.row).length)
this.killedBuffer = session.getTextRange(range)
if (this.killedBuffer.length > 0) {
console.log('remove to lineend')
session.remove(range)
} else {
if (session.getLength() === range.start.row) {
return
}
range.setStart(range.start.row, range.end.col)
range.setEnd(range.start.row + 1, 0)
this.killedBuffer = '\n'
session.remove(range)
}
} else {
this.killedBuffer = session.getTextRange(range)
session.remove(range)
}
}
}
this.afterExecHandler = (e) => {
switch (e.command.name) {
case 'find':
@@ -42,6 +77,7 @@ export default class CodeEditor extends React.Component {
el.removeEventListener('blur', this.blurHandler)
el.addEventListener('blur', this.blurHandler)
})
break
}
}
@@ -83,6 +119,14 @@ export default class CodeEditor extends React.Component {
},
readOnly: true
})
editor.commands.addCommand({
name: 'Emacs cursor up',
bindKey: {mac: 'Ctrl-Y'},
exec: function (editor) {
editor.insert(this.killedBuffer)
}.bind(this),
readOnly: true
})
editor.commands.addCommand({
name: 'Focus title',
bindKey: {win: 'Esc', mac: 'Esc'},
@@ -96,6 +140,7 @@ export default class CodeEditor extends React.Component {
readOnly: true
})
editor.commands.on('exec', this.execHandler)
editor.commands.on('afterExec', this.afterExecHandler)
var session = editor.getSession()
@@ -120,6 +165,7 @@ export default class CodeEditor extends React.Component {
ipc.removeListener('config-apply', this.configApplyHandler)
this.editor.getSession().removeListener('change', this.changeHandler)
this.editor.removeListener('blur', this.blurHandler)
this.editor.commands.removeListener('exec', this.execHandler)
this.editor.commands.removeListener('afterExec', this.afterExecHandler)
}

View File

@@ -108,7 +108,7 @@ export function emit (type, data = {}) {
}
// Count ARTICLE_CREATE and ARTICLE_UPDATE again by syntax
if ((type === 'ARTICLE_CREATE' || type === 'ARTICLE_UPDATE') && data.mode != null) {
if (type === 'ARTICLE_UPDATE' && data.mode != null) {
let recordKey = type + '_BY_SYNTAX'
if (todayRecord[recordKey] == null) todayRecord[recordKey] = {}

View File

@@ -14,7 +14,7 @@ var md = markdownit({
return hljs.highlight(lang, str).value
} catch (e) {}
}
return str
return str.replace(/\&/g, '&amp;').replace(/\</g, '&lt;').replace(/\>/g, '&gt;').replace(/\"/g, '&quot;')
}
})
md.use(emoji, {

View File

@@ -32,7 +32,6 @@ export default class ArticleEditor extends React.Component {
}
componentDidMount () {
console.log(this.state.switchPreview)
ipc.on('config-apply', this.configApplyHandler)
}

View File

@@ -4,10 +4,7 @@ import moment from 'moment'
import _ from 'lodash'
import {
switchFolder,
updateArticle,
// cacheArticle,
// saveArticle,
// uncacheArticle
updateArticle
} from '../../actions'
import linkState from 'browser/lib/linkState'
import TagSelect from 'browser/components/TagSelect'
@@ -19,22 +16,6 @@ import ArticleEditor from './ArticleEditor'
const electron = require('electron')
const ipc = electron.ipcRenderer
// const remote = electron.remote
// const { Menu, MenuItem } = remote
// const othersMenu = new Menu()
// othersMenu.append(new MenuItem({
// label: 'Delete Post',
// click: function () {
// remote.getCurrentWebContents().send('detail-delete')
// }
// }))
// othersMenu.append(new MenuItem({
// label: 'Discard Change',
// click: function (item) {
// remote.getCurrentWebContents().send('detail-uncache')
// }
// }))
const BRAND_COLOR = '#18AF90'
const OSX = global.process.platform === 'darwin'
@@ -80,10 +61,6 @@ export default class ArticleDetail extends React.Component {
constructor (props) {
super(props)
this.saveHandler = e => {
if (isModalOpen()) return true
this.handleSaveButtonClick()
}
this.deleteHandler = e => {
if (isModalOpen()) return true
this.handleDeleteButtonClick()
@@ -119,7 +96,6 @@ export default class ArticleDetail extends React.Component {
e.stopPropagation()
}
// ipc.on('detail-save', this.saveHandler)
ipc.on('detail-delete', this.deleteHandler)
ipc.on('detail-uncache', this.uncacheHandler)
ipc.on('detail-title', this.titleHandler)
@@ -130,7 +106,6 @@ export default class ArticleDetail extends React.Component {
componentWillUnmount () {
clearInterval(this.refreshTimer)
// ipc.removeListener('detail-save', this.saveHandler)
ipc.removeListener('detail-delete', this.deleteHandler)
ipc.removeListener('detail-uncache', this.uncacheHandler)
ipc.removeListener('detail-title', this.titleHandler)

View File

@@ -4,6 +4,7 @@ import ExternalLink from 'browser/components/ExternalLink'
import { setSearchFilter, clearSearch, toggleTutorial, saveArticle, switchFolder } from '../actions'
import { isModalOpen } from 'browser/lib/modal'
import keygen from 'browser/lib/keygen'
import activityRecord from 'browser/lib/activityRecord'
const electron = require('electron')
const remote = electron.remote
@@ -167,6 +168,7 @@ export default class ArticleTopBar extends React.Component {
dispatch(saveArticle(newArticle.key, newArticle, true))
if (isFolderFilterApplied) dispatch(switchFolder(targetFolders[0].name))
remote.getCurrentWebContents().send('detail-title')
activityRecord.emit('ARTICLE_CREATE')
}
handleTutorialButtonClick (e) {

View File

@@ -48,12 +48,12 @@ marked()
*:not(a.lineAnchor) + h1, *:not(a.lineAnchor) + h2, *:not(a.lineAnchor) + h3, *:not(a.lineAnchor) + h4, *:not(a.lineAnchor) + h5, *:not(a.lineAnchor) + h6
margin-top 25px
h1
font-size 2em
font-size 1.8em
border-bottom solid 2px borderColor
line-height 2.333em
line-height 2em
h2
font-size 1.66em
line-height 2.07em
line-height 1.8em
h3
font-size 1.33em
line-height 1.6625em

View File

@@ -1,6 +1,6 @@
{
"name": "boost",
"version": "0.5.3",
"version": "0.5.4",
"description": "Boostnote",
"main": "index.js",
"scripts": {