Skip to content

Commit cae6fd4

Browse files
committed
Merge branch 'master' into tags
2 parents 4e80e1d + 2ccd00a commit cae6fd4

Some content is hidden

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

47 files changed

+431
-238
lines changed

browser/components/CodeEditor.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ export default class CodeEditor extends React.Component {
292292
this.editor.on('cursorActivity', this.editorActivityHandler)
293293
this.editor.on('changes', this.editorActivityHandler)
294294
}
295+
296+
this.setState({
297+
clientWidth: this.refs.root.clientWidth
298+
})
295299
}
296300

297301
expandSnippet (line, cursor, cm, snippets) {
@@ -441,6 +445,14 @@ export default class CodeEditor extends React.Component {
441445
this.editor.setOption('extraKeys', this.defaultKeyMap)
442446
}
443447

448+
if (this.state.clientWidth !== this.refs.root.clientWidth) {
449+
this.setState({
450+
clientWidth: this.refs.root.clientWidth
451+
})
452+
453+
needRefresh = true
454+
}
455+
444456
if (needRefresh) {
445457
this.editor.refresh()
446458
}

browser/components/MarkdownPreview.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ import copy from 'copy-to-clipboard'
1717
import mdurl from 'mdurl'
1818
import exportNote from 'browser/main/lib/dataApi/exportNote'
1919
import { escapeHtmlCharacters } from 'browser/lib/utils'
20+
import context from 'browser/lib/context'
21+
import i18n from 'browser/lib/i18n'
22+
import fs from 'fs'
2023

21-
const { remote } = require('electron')
24+
const { remote, shell } = require('electron')
2225
const attachmentManagement = require('../main/lib/dataApi/attachmentManagement')
2326

2427
const { app } = remote
@@ -27,6 +30,8 @@ const fileUrl = require('file-url')
2730

2831
const dialog = remote.dialog
2932

33+
const uri2path = require('file-uri-to-path')
34+
3035
const markdownStyle = require('!!css!stylus?sourceMap!./markdown.styl')[0][1]
3136
const appPath = fileUrl(
3237
process.env.NODE_ENV === 'production' ? app.getAppPath() : path.resolve()
@@ -161,7 +166,6 @@ const scrollBarDarkStyle = `
161166
}
162167
`
163168

164-
const { shell } = require('electron')
165169
const OSX = global.process.platform === 'darwin'
166170

167171
const defaultFontFamily = ['helvetica', 'arial', 'sans-serif']
@@ -219,8 +223,32 @@ export default class MarkdownPreview extends React.Component {
219223
}
220224
}
221225

222-
handleContextMenu (e) {
223-
this.props.onContextMenu(e)
226+
handleContextMenu (event) {
227+
// If a contextMenu handler was passed to us, use it instead of the self-defined one -> return
228+
if (_.isFunction(this.props.onContextMenu)) {
229+
this.props.onContextMenu(event)
230+
return
231+
}
232+
// No contextMenu was passed to us -> execute our own link-opener
233+
if (event.target.tagName.toLowerCase() === 'a') {
234+
const href = event.target.href
235+
const isLocalFile = href.startsWith('file:')
236+
if (isLocalFile) {
237+
const absPath = uri2path(href)
238+
try {
239+
if (fs.lstatSync(absPath).isFile()) {
240+
context.popup([
241+
{
242+
label: i18n.__('Show in explorer'),
243+
click: (e) => shell.showItemInFolder(absPath)
244+
}
245+
])
246+
}
247+
} catch (e) {
248+
console.log('Error while evaluating if the file is locally available', e)
249+
}
250+
}
251+
}
224252
}
225253

226254
handleDoubleClick (e) {

browser/components/NoteItem.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,22 @@ const NoteItem = ({
7878
? note.title
7979
: <span styleName='item-title-empty'>{i18n.__('Empty note')}</span>}
8080
</div>
81-
{['ALL', 'STORAGE'].includes(viewType) &&
82-
<div styleName='item-middle'>
83-
<div styleName='item-middle-time'>{dateDisplay}</div>
84-
<div styleName='item-middle-app-meta'>
85-
<div
86-
title={
87-
viewType === 'ALL'
88-
? storageName
89-
: viewType === 'STORAGE' ? folderName : null
90-
}
91-
styleName='item-middle-app-meta-label'
92-
>
93-
{viewType === 'ALL' && storageName}
94-
{viewType === 'STORAGE' && folderName}
95-
</div>
81+
<div styleName='item-middle'>
82+
<div styleName='item-middle-time'>{dateDisplay}</div>
83+
<div styleName='item-middle-app-meta'>
84+
<div
85+
title={
86+
viewType === 'ALL'
87+
? storageName
88+
: viewType === 'STORAGE' ? folderName : null
89+
}
90+
styleName='item-middle-app-meta-label'
91+
>
92+
{viewType === 'ALL' && storageName}
93+
{viewType === 'STORAGE' && folderName}
9694
</div>
97-
</div>}
98-
95+
</div>
96+
</div>
9997
<div styleName='item-bottom'>
10098
<div styleName='item-bottom-tagList'>
10199
{note.tags.length > 0

browser/components/NoteItem.styl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,13 @@ body[data-theme="monokai"]
368368
.item-title
369369
.item-title-icon
370370
.item-bottom-time
371-
color $ui-monokai-text-color
371+
color $ui-monokai-active-color
372372
.item-bottom-tagList-item
373373
background-color alpha(white, 10%)
374374
color $ui-monokai-text-color
375375
&:hover
376376
// background-color alpha($ui-monokai-button--active-backgroundColor, 60%)
377-
color #c0392b
377+
color #f92672
378378
.item-bottom-tagList-item
379379
background-color alpha(#fff, 20%)
380380

browser/components/NoteItemSimple.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ body[data-theme="monokai"]
240240
.item-simple-title-icon
241241
.item-simple-bottom-time
242242
transition 0.15s
243-
color $ui-solarized-dark-text-color
243+
color $ui-monokai-text-color
244244
.item-simple-bottom-tagList-item
245245
transition 0.15s
246246
background-color alpha(#fff, 20%)

browser/components/TodoListPercentage.styl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ body[data-theme="dark"]
3939

4040
.percentageText
4141
color $ui-dark-text-color
42-
42+
4343
body[data-theme="solarized-dark"]
4444
.percentageBar
4545
background-color #002b36
@@ -52,10 +52,10 @@ body[data-theme="solarized-dark"]
5252

5353
body[data-theme="monokai"]
5454
.percentageBar
55-
background-color #f92672
55+
background-color: $ui-monokai-borderColor
5656

5757
.progressBar
58-
background-color: #373831
58+
background-color $ui-monokai-active-color
5959

6060
.percentageText
61-
color #fdf6e3
61+
color $ui-monokai-text-color

browser/lib/markdown.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ class Markdown {
148148
}
149149
})
150150
this.md.use(require('markdown-it-kbd'))
151-
this.md.use(require('markdown-it-admonition'))
151+
152+
this.md.use(require('markdown-it-admonition'), {types: ['note', 'hint', 'attention', 'caution', 'danger', 'error']})
152153
this.md.use(require('./markdown-it-frontmatter'))
153154

154155
const deflate = require('markdown-it-plantuml/lib/deflate')

browser/main/Detail/SnippetNoteDetail.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ class SnippetNoteDetail extends React.Component {
761761
value={this.state.note.tags}
762762
saveTagsAlphabetically={config.ui.saveTagsAlphabetically}
763763
showTagsAlphabetically={config.ui.showTagsAlphabetically}
764+
data={data}
764765
onChange={(e) => this.handleChange(e)}
765766
/>
766767
</div>

browser/main/Detail/TagSelect.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ class TagSelect extends React.Component {
8888
this.refs.newTag.input.focus()
8989
}
9090

91+
handleTagLabelClick (tag) {
92+
const { router } = this.context
93+
router.push(`/tags/${tag}`)
94+
}
95+
9196
handleTagRemoveButtonClick (tag) {
9297
this.removeTagByCallback((value, tag) => {
9398
value.splice(value.indexOf(tag), 1)
@@ -182,7 +187,7 @@ class TagSelect extends React.Component {
182187
<span styleName='tag'
183188
key={tag}
184189
>
185-
<span styleName='tag-label'>#{tag}</span>
190+
<span styleName='tag-label' onClick={(e) => this.handleTagLabelClick(tag)}>#{tag}</span>
186191
<button styleName='tag-removeButton'
187192
onClick={(e) => this.handleTagRemoveButtonClick(tag)}
188193
>
@@ -228,6 +233,10 @@ class TagSelect extends React.Component {
228233
}
229234
}
230235

236+
TagSelect.contextTypes = {
237+
router: PropTypes.shape({})
238+
}
239+
231240
TagSelect.propTypes = {
232241
className: PropTypes.string,
233242
value: PropTypes.arrayOf(PropTypes.string),

browser/main/Detail/TagSelect.styl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939

4040
.tag-label
4141
font-size 13px
42-
color: $ui-text-color
42+
color $ui-text-color
4343
padding 4px 16px 4px 8px
44+
cursor pointer
4445

4546
body[data-theme="dark"]
4647
.tag
@@ -67,11 +68,11 @@ body[data-theme="solarized-dark"]
6768

6869
body[data-theme="monokai"]
6970
.tag
70-
background-color $ui-monokai-button-backgroundColor
71+
background-color $ui-monokai-tag-backgroundColor
7172

7273
.tag-removeButton
7374
border-color $ui-button--focus-borderColor
7475
background-color transparent
7576

7677
.tag-label
77-
color $ui-monokai-text-color
78+
color $ui-monokai-text-color

0 commit comments

Comments
 (0)