Skip to content

Commit 25d055e

Browse files
committed
Merge branch 'master' into fix-search-issue-unicode
# Conflicts: # browser/main/TopBar/index.js # yarn.lock
2 parents 9794149 + 052fb3d commit 25d055e

35 files changed

+854
-276
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": {
88
"presets": ["env" ,"react", "es2015"],
99
"plugins": [
10-
[ "babel-plugin-webpack-alias", { "config": "${PWD}/webpack.config.js" } ]
10+
[ "babel-plugin-webpack-alias", { "config": "<rootDir>/webpack.config.js" } ]
1111
]
1212
}
1313
}

browser/components/MarkdownPreview.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,15 +1015,19 @@ export default class MarkdownPreview extends React.Component {
10151015
e.preventDefault()
10161016
e.stopPropagation()
10171017

1018-
const href = e.target.getAttribute('href')
1019-
const linkHash = href.split('/').pop()
1018+
const rawHref = e.target.getAttribute('href')
1019+
const parser = document.createElement('a')
1020+
parser.href = e.target.getAttribute('href')
1021+
const { href, hash } = parser
1022+
const linkHash = hash === '' ? rawHref : hash // needed because we're having special link formats that are removed by parser e.g. :line:10
10201023

1021-
if (!href) return
1024+
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
10221025

1023-
const regexNoteInternalLink = /main.html#(.+)/
1024-
if (regexNoteInternalLink.test(linkHash)) {
1025-
const targetId = mdurl.encode(linkHash.match(regexNoteInternalLink)[1])
1026-
const targetElement = this.refs.root.contentWindow.document.getElementById(
1026+
const regexNoteInternalLink = /.*[main.\w]*.html#/
1027+
1028+
if (regexNoteInternalLink.test(href)) {
1029+
const targetId = mdurl.encode(linkHash)
1030+
const targetElement = this.refs.root.contentWindow.document.querySelector(
10271031
targetId
10281032
)
10291033

browser/lib/CSSModules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import CSSModules from 'react-css-modules'
22

33
export default function (component, styles) {
4-
return CSSModules(component, styles, {errorWhenNotFound: false})
4+
return CSSModules(component, styles, {handleNotFoundStyleName: 'log'})
55
}

browser/lib/newNote.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { hashHistory } from 'react-router'
21
import dataApi from 'browser/main/lib/dataApi'
32
import ee from 'browser/main/lib/eventEmitter'
43
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
4+
import queryString from 'query-string'
5+
import { push } from 'connected-react-router'
56

67
export function createMarkdownNote (storage, folder, dispatch, location, params, config) {
78
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
@@ -28,10 +29,10 @@ export function createMarkdownNote (storage, folder, dispatch, location, params,
2829
note: note
2930
})
3031

31-
hashHistory.push({
32+
dispatch(push({
3233
pathname: location.pathname,
33-
query: { key: noteHash }
34-
})
34+
search: queryString.stringify({ key: noteHash })
35+
}))
3536
ee.emit('list:jump', noteHash)
3637
ee.emit('detail:focus')
3738
})
@@ -70,10 +71,10 @@ export function createSnippetNote (storage, folder, dispatch, location, params,
7071
type: 'UPDATE_NOTE',
7172
note: note
7273
})
73-
hashHistory.push({
74+
dispatch(push({
7475
pathname: location.pathname,
75-
query: { key: noteHash }
76-
})
76+
search: queryString.stringify({ key: noteHash })
77+
}))
7778
ee.emit('list:jump', noteHash)
7879
ee.emit('detail:focus')
7980
})

browser/main/Detail/MarkdownNoteDetail.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import StarButton from './StarButton'
99
import TagSelect from './TagSelect'
1010
import FolderSelect from './FolderSelect'
1111
import dataApi from 'browser/main/lib/dataApi'
12-
import { hashHistory } from 'react-router'
1312
import ee from 'browser/main/lib/eventEmitter'
1413
import markdown from 'browser/lib/markdownTextHelper'
1514
import StatusBar from '../StatusBar'
@@ -30,6 +29,8 @@ import { getTodoPercentageOfCompleted } from 'browser/lib/getTodoStatus'
3029
import striptags from 'striptags'
3130
import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
3231
import markdownToc from 'browser/lib/markdown-toc-generator'
32+
import queryString from 'query-string'
33+
import { replace } from 'connected-react-router'
3334

3435
class MarkdownNoteDetail extends React.Component {
3536
constructor (props) {
@@ -147,6 +148,7 @@ class MarkdownNoteDetail extends React.Component {
147148
}
148149

149150
handleFolderChange (e) {
151+
const { dispatch } = this.props
150152
const { note } = this.state
151153
const value = this.refs.folder.value
152154
const splitted = value.split('-')
@@ -166,12 +168,12 @@ class MarkdownNoteDetail extends React.Component {
166168
originNote: note,
167169
note: newNote
168170
})
169-
hashHistory.replace({
171+
dispatch(replace({
170172
pathname: location.pathname,
171-
query: {
173+
search: queryString.stringify({
172174
key: newNote.key
173-
}
174-
})
175+
})
176+
}))
175177
this.setState({
176178
isMovingNote: false
177179
})
@@ -498,7 +500,7 @@ class MarkdownNoteDetail extends React.Component {
498500
<InfoPanel
499501
storageName={currentOption.storage.name}
500502
folderName={currentOption.folder.name}
501-
noteLink={`[${note.title}](:note:${location.query.key})`}
503+
noteLink={`[${note.title}](:note:${queryString.parse(location.search).key})`}
502504
updatedAt={formatDate(note.updatedAt)}
503505
createdAt={formatDate(note.createdAt)}
504506
exportAsMd={this.exportAsMd}

browser/main/Detail/MarkdownNoteDetail.styl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,12 @@ body[data-theme="monokai"]
8080
body[data-theme="dracula"]
8181
.root
8282
border-left 1px solid $ui-dracula-borderColor
83-
background-color $ui-dracula-noteDetail-backgroundColor
83+
background-color $ui-dracula-noteDetail-backgroundColor
84+
85+
div
86+
> button, div
87+
-webkit-user-drag none
88+
user-select none
89+
> img, span
90+
-webkit-user-drag none
91+
user-select none

browser/main/Detail/SnippetNoteDetail.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import StarButton from './StarButton'
88
import TagSelect from './TagSelect'
99
import FolderSelect from './FolderSelect'
1010
import dataApi from 'browser/main/lib/dataApi'
11-
import {hashHistory} from 'react-router'
1211
import ee from 'browser/main/lib/eventEmitter'
1312
import CodeMirror from 'codemirror'
1413
import 'codemirror-mode-elixir'
@@ -18,7 +17,6 @@ import context from 'browser/lib/context'
1817
import ConfigManager from 'browser/main/lib/ConfigManager'
1918
import _ from 'lodash'
2019
import {findNoteTitle} from 'browser/lib/findNoteTitle'
21-
import convertModeName from 'browser/lib/convertModeName'
2220
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
2321
import FullscreenButton from './FullscreenButton'
2422
import TrashButton from './TrashButton'
@@ -31,6 +29,8 @@ import { formatDate } from 'browser/lib/date-formatter'
3129
import i18n from 'browser/lib/i18n'
3230
import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
3331
import markdownToc from 'browser/lib/markdown-toc-generator'
32+
import queryString from 'query-string'
33+
import { replace } from 'connected-react-router'
3434

3535
const electron = require('electron')
3636
const { remote } = electron
@@ -166,12 +166,12 @@ class SnippetNoteDetail extends React.Component {
166166
originNote: note,
167167
note: newNote
168168
})
169-
hashHistory.replace({
169+
dispatch(replace({
170170
pathname: location.pathname,
171-
query: {
171+
search: queryString.stringify({
172172
key: newNote.key
173-
}
174-
})
173+
})
174+
}))
175175
this.setState({
176176
isMovingNote: false
177177
})
@@ -814,7 +814,7 @@ class SnippetNoteDetail extends React.Component {
814814
<InfoPanel
815815
storageName={currentOption.storage.name}
816816
folderName={currentOption.folder.name}
817-
noteLink={`[${note.title}](:note:${location.query.key})`}
817+
noteLink={`[${note.title}](:note:${queryString.parse(location.search).key})`}
818818
updatedAt={formatDate(note.updatedAt)}
819819
createdAt={formatDate(note.createdAt)}
820820
exportAsMd={this.showWarning}

browser/main/Detail/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import StatusBar from '../StatusBar'
1010
import i18n from 'browser/lib/i18n'
1111
import debounceRender from 'react-debounce-render'
1212
import searchFromNotes from 'browser/lib/search'
13+
import queryString from 'query-string'
1314

1415
const OSX = global.process.platform === 'darwin'
1516

@@ -36,11 +37,11 @@ class Detail extends React.Component {
3637
}
3738

3839
render () {
39-
const { location, data, params, config } = this.props
40+
const { location, data, match: { params }, config } = this.props
41+
const noteKey = location.search !== '' && queryString.parse(location.search).key
4042
let note = null
4143

42-
if (location.query.key != null) {
43-
const noteKey = location.query.key
44+
if (location.search !== '') {
4445
const allNotes = data.noteMap.map(note => note)
4546
const trashedNotes = data.trashedSet.toJS().map(uniqueKey => data.noteMap.get(uniqueKey))
4647
let displayedNotes = allNotes

browser/main/DevTools/index.dev.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react'
2+
import { createDevTools } from 'redux-devtools'
3+
import LogMonitor from 'redux-devtools-log-monitor'
4+
import DockMonitor from 'redux-devtools-dock-monitor'
5+
6+
const DevTools = createDevTools(
7+
<DockMonitor
8+
toggleVisibilityKey='ctrl-h'
9+
changePositionKey='ctrl-q'
10+
defaultIsVisible={false}
11+
>
12+
<LogMonitor theme='tomorrow' />
13+
</DockMonitor>
14+
)
15+
16+
export default DevTools

browser/main/DevTools/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* eslint-disable no-undef */
2+
if (process.env.NODE_ENV === 'production') {
3+
// eslint-disable-next-line global-require
4+
module.exports = require('./index.prod').default
5+
} else {
6+
// eslint-disable-next-line global-require
7+
module.exports = require('./index.dev').default
8+
}

0 commit comments

Comments
 (0)