1
1
import PropTypes from 'prop-types'
2
2
import React from 'react'
3
+ import { connect } from 'react-redux'
3
4
import Markdown from 'browser/lib/markdown'
4
5
import _ from 'lodash'
5
6
import CodeMirror from 'codemirror'
@@ -23,7 +24,7 @@ import i18n from 'browser/lib/i18n'
23
24
import fs from 'fs'
24
25
import { render } from 'react-dom'
25
26
import Carousel from 'react-image-carousel'
26
- import { hashHistory } from 'react-router'
27
+ import { push } from 'connected- react-router'
27
28
import ConfigManager from '../main/lib/ConfigManager'
28
29
29
30
const { remote, shell } = require ( 'electron' )
@@ -206,7 +207,7 @@ function getSourceLineNumberByElement (element) {
206
207
return parent . dataset . line !== undefined ? parseInt ( parent . dataset . line ) : - 1
207
208
}
208
209
209
- export default class MarkdownPreview extends React . Component {
210
+ class MarkdownPreview extends React . Component {
210
211
constructor ( props ) {
211
212
super ( props )
212
213
@@ -1021,6 +1022,7 @@ export default class MarkdownPreview extends React.Component {
1021
1022
parser . href = e . target . getAttribute ( 'href' )
1022
1023
const { href, hash } = parser
1023
1024
const linkHash = hash === '' ? rawHref : hash // needed because we're having special link formats that are removed by parser e.g. :line:10
1025
+ const { dispatch } = this . props
1024
1026
1025
1027
if ( ! rawHref ) return // not checked href because parser will create file://... string for [empty link]()
1026
1028
@@ -1069,7 +1071,7 @@ export default class MarkdownPreview extends React.Component {
1069
1071
const regexIsTagLink = / ^ : t a g : # ( [ \w ] + ) $ /
1070
1072
if ( regexIsTagLink . test ( rawHref ) ) {
1071
1073
const tag = rawHref . match ( regexIsTagLink ) [ 1 ]
1072
- hashHistory . push ( `/tags/${ encodeURIComponent ( tag ) } ` )
1074
+ dispatch ( push ( `/tags/${ encodeURIComponent ( tag ) } ` ) )
1073
1075
return
1074
1076
}
1075
1077
@@ -1106,3 +1108,5 @@ MarkdownPreview.propTypes = {
1106
1108
smartArrows : PropTypes . bool ,
1107
1109
breaks : PropTypes . bool
1108
1110
}
1111
+
1112
+ export default connect ( ) ( MarkdownPreview )
0 commit comments