1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-20 13:11:44 +00:00

Merge branch 'master' into export-yfm

This commit is contained in:
Baptiste Augrain
2020-07-20 14:05:21 +02:00
23 changed files with 1219 additions and 330 deletions

View File

@@ -747,17 +747,18 @@ class MarkdownPreview extends React.Component {
/**
* @public
* @param {Number} targetRow
* @param {Number} targetLine
*/
scrollToRow(targetRow) {
scrollToLine(targetLine) {
const blocks = this.getWindow().document.querySelectorAll(
'body>[data-line]'
'body [data-line]'
)
for (let index = 0; index < blocks.length; index++) {
let block = blocks[index]
const row = parseInt(block.getAttribute('data-line'))
if (row > targetRow || index === blocks.length - 1) {
const line = parseInt(block.getAttribute('data-line'))
if (line > targetLine || index === blocks.length - 1) {
block = blocks[index - 1]
block != null && this.scrollTo(0, block.offsetTop)
break
@@ -794,7 +795,10 @@ class MarkdownPreview extends React.Component {
e.preventDefault()
e.stopPropagation()
const rawHref = e.target.getAttribute('href')
const el = e.target.closest('a[href]')
if (!el) return
const rawHref = el.getAttribute('href')
const { dispatch } = this.props
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()