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

Merge pull request #978 from aquibm/master

Fix URIs decoded with mdurl
This commit is contained in:
SuenagaRyota
2017-10-21 13:40:36 +09:00
committed by GitHub
3 changed files with 275 additions and 263 deletions

View File

@@ -10,6 +10,7 @@ import eventEmitter from 'browser/main/lib/eventEmitter'
import fs from 'fs'
import htmlTextHelper from 'browser/lib/htmlTextHelper'
import copy from 'copy-to-clipboard'
import mdurl from 'mdurl'
const { remote } = require('electron')
const { app } = remote
@@ -183,6 +184,14 @@ export default class MarkdownPreview extends React.Component {
})
}
fixDecodedURI (node) {
const { innerText, href } = node
node.innerText = mdurl.decode(href) === innerText
? href
: innerText
}
componentDidMount () {
this.refs.root.setAttribute('sandbox', 'allow-scripts')
this.refs.root.contentWindow.document.body.addEventListener('contextmenu', this.contextMenuHandler)
@@ -279,6 +288,7 @@ export default class MarkdownPreview extends React.Component {
})
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
this.fixDecodedURI(el)
el.addEventListener('click', this.anchorClickHandler)
})

View File

@@ -70,6 +70,7 @@
"markdown-it-multimd-table": "^2.0.1",
"markdown-it-named-headers": "^0.0.4",
"md5": "^2.0.0",
"mdurl": "^1.0.1",
"mixpanel": "^0.4.1",
"moment": "^2.10.3",
"node-ipc": "^8.1.0",

527
yarn.lock

File diff suppressed because it is too large Load Diff