mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
use _.forEach instead of Array.prototype.forEach.call
This commit is contained in:
@@ -20,6 +20,7 @@ function decodeHTMLEntities (text) {
|
|||||||
|
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
const { remote } = require('electron')
|
const { remote } = require('electron')
|
||||||
const { app } = remote
|
const { app } = remote
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
@@ -175,10 +176,10 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rewriteIframe () {
|
rewriteIframe () {
|
||||||
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
||||||
el.removeEventListener('click', this.anchorClickHandler)
|
el.removeEventListener('click', this.anchorClickHandler)
|
||||||
})
|
})
|
||||||
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => {
|
||||||
el.removeEventListener('click', this.checkboxClickHandler)
|
el.removeEventListener('click', this.checkboxClickHandler)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -187,11 +188,11 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)
|
this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)
|
||||||
this.refs.root.contentWindow.document.body.innerHTML = markdown.render(value)
|
this.refs.root.contentWindow.document.body.innerHTML = markdown.render(value)
|
||||||
|
|
||||||
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
||||||
el.addEventListener('click', this.anchorClickHandler)
|
el.addEventListener('click', this.anchorClickHandler)
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => {
|
||||||
el.addEventListener('click', this.checkboxClickHandler)
|
el.addEventListener('click', this.checkboxClickHandler)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -199,19 +200,18 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
? codeBlockTheme
|
? codeBlockTheme
|
||||||
: 'default'
|
: 'default'
|
||||||
|
|
||||||
Array.prototype.forEach
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.code code'), (el) => {
|
||||||
.call(this.refs.root.contentWindow.document.querySelectorAll('.code code'), (el) => {
|
let syntax = CodeMirror.findModeByName(el.className)
|
||||||
let syntax = CodeMirror.findModeByName(el.className)
|
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
|
||||||
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
|
CodeMirror.requireMode(syntax.mode, () => {
|
||||||
CodeMirror.requireMode(syntax.mode, () => {
|
let content = el.innerHTML
|
||||||
let content = el.innerHTML
|
el.innerHTML = ''
|
||||||
el.innerHTML = ''
|
el.parentNode.className += ` cm-s-${codeBlockTheme} CodeMirror`
|
||||||
el.parentNode.className += ` cm-s-${codeBlockTheme} CodeMirror`
|
CodeMirror.runMode(content, syntax.mime, el, {
|
||||||
CodeMirror.runMode(content, syntax.mime, el, {
|
tabSize: indentSize
|
||||||
tabSize: indentSize
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
let opts = {}
|
let opts = {}
|
||||||
if (this.props.theme === 'dark') {
|
if (this.props.theme === 'dark') {
|
||||||
opts['font-color'] = '#DDD'
|
opts['font-color'] = '#DDD'
|
||||||
@@ -219,20 +219,19 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
opts['element-color'] = '#DDD'
|
opts['element-color'] = '#DDD'
|
||||||
opts['fill'] = '#3A404C'
|
opts['fill'] = '#3A404C'
|
||||||
}
|
}
|
||||||
Array.prototype.forEach
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.flowchart'), (el) => {
|
||||||
.call(this.refs.root.contentWindow.document.querySelectorAll('.flowchart'), (el) => {
|
Raphael.setWindow(this.getWindow())
|
||||||
Raphael.setWindow(this.getWindow())
|
try {
|
||||||
try {
|
let diagram = flowchart.parse(decodeHTMLEntities(el.innerHTML))
|
||||||
let diagram = flowchart.parse(decodeHTMLEntities(el.innerHTML))
|
el.innerHTML = ''
|
||||||
el.innerHTML = ''
|
diagram.drawSVG(el, opts)
|
||||||
diagram.drawSVG(el, opts)
|
_.forEach(el.querySelectorAll('a'), (el) => {
|
||||||
Array.prototype.forEach.call(el.querySelectorAll('a'), (el) => {
|
el.addEventListener('click', this.anchorClickHandler)
|
||||||
el.addEventListener('click', this.anchorClickHandler)
|
})
|
||||||
})
|
} catch (e) {
|
||||||
} catch (e) {
|
console.error(e)
|
||||||
console.error(e)
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
focus () {
|
focus () {
|
||||||
|
|||||||
Reference in New Issue
Block a user