mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
fix: Lint issues.
This commit is contained in:
@@ -21,7 +21,6 @@ const buildEditorContextMenu = require('browser/lib/contextMenuBuilder')
|
|||||||
import { createTurndownService } from '../lib/turndown'
|
import { createTurndownService } from '../lib/turndown'
|
||||||
import { languageMaps } from '../lib/CMLanguageList'
|
import { languageMaps } from '../lib/CMLanguageList'
|
||||||
import snippetManager from '../lib/SnippetManager'
|
import snippetManager from '../lib/SnippetManager'
|
||||||
import { gfm } from 'turndown-plugin-gfm'
|
|
||||||
import { findStorage } from 'browser/lib/findStorage'
|
import { findStorage } from 'browser/lib/findStorage'
|
||||||
import { sendWakatimeHeartBeat } from 'browser/lib/wakatime-plugin'
|
import { sendWakatimeHeartBeat } from 'browser/lib/wakatime-plugin'
|
||||||
import {
|
import {
|
||||||
@@ -120,8 +119,15 @@ export default class CodeEditor extends React.Component {
|
|||||||
// wakatime
|
// wakatime
|
||||||
const { storageKey, noteKey } = this.props
|
const { storageKey, noteKey } = this.props
|
||||||
const storage = findStorage(storageKey)
|
const storage = findStorage(storageKey)
|
||||||
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, false, false, true)
|
if (storage)
|
||||||
|
sendWakatimeHeartBeat(
|
||||||
|
storage.path,
|
||||||
|
noteKey,
|
||||||
|
storage.name,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSearch(msg) {
|
handleSearch(msg) {
|
||||||
@@ -807,9 +813,25 @@ export default class CodeEditor extends React.Component {
|
|||||||
const storage = findStorage(storageKey)
|
const storage = findStorage(storageKey)
|
||||||
if (this.props.onChange) {
|
if (this.props.onChange) {
|
||||||
this.props.onChange(editor)
|
this.props.onChange(editor)
|
||||||
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, true, true, false)
|
if (storage)
|
||||||
|
sendWakatimeHeartBeat(
|
||||||
|
storage.path,
|
||||||
|
noteKey,
|
||||||
|
storage.name,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, false, false, false)
|
if (storage)
|
||||||
|
sendWakatimeHeartBeat(
|
||||||
|
storage.path,
|
||||||
|
noteKey,
|
||||||
|
storage.name,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -942,7 +964,15 @@ export default class CodeEditor extends React.Component {
|
|||||||
// wakatime
|
// wakatime
|
||||||
const { storageKey, noteKey } = this.props
|
const { storageKey, noteKey } = this.props
|
||||||
const storage = findStorage(storageKey)
|
const storage = findStorage(storageKey)
|
||||||
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, false, false, true)
|
if (storage)
|
||||||
|
sendWakatimeHeartBeat(
|
||||||
|
storage.path,
|
||||||
|
noteKey,
|
||||||
|
storage.name,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(value) {
|
setValue(value) {
|
||||||
|
|||||||
@@ -1299,9 +1299,4 @@ MarkdownPreview.propTypes = {
|
|||||||
breaks: PropTypes.bool
|
breaks: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, null, null, { forwardRef: true })(MarkdownPreview)
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
{ forwardRef: true }
|
|
||||||
)(MarkdownPreview)
|
|
||||||
|
|||||||
@@ -278,9 +278,7 @@ class Markdown {
|
|||||||
flowchart: token => {
|
flowchart: token => {
|
||||||
return `<pre class="fence" data-line="${token.map[0]}">
|
return `<pre class="fence" data-line="${token.map[0]}">
|
||||||
<span class="filename">${token.fileName}</span>
|
<span class="filename">${token.fileName}</span>
|
||||||
<div class="flowchart" data-height="${token.parameters.height}">${
|
<div class="flowchart" data-height="${token.parameters.height}">${token.content}</div>
|
||||||
token.content
|
|
||||||
}</div>
|
|
||||||
</pre>`
|
</pre>`
|
||||||
},
|
},
|
||||||
gallery: token => {
|
gallery: token => {
|
||||||
@@ -299,25 +297,19 @@ class Markdown {
|
|||||||
|
|
||||||
return `<pre class="fence" data-line="${token.map[0]}">
|
return `<pre class="fence" data-line="${token.map[0]}">
|
||||||
<span class="filename">${token.fileName}</span>
|
<span class="filename">${token.fileName}</span>
|
||||||
<div class="gallery" data-autoplay="${
|
<div class="gallery" data-autoplay="${token.parameters.autoplay}" data-height="${token.parameters.height}">${content}</div>
|
||||||
token.parameters.autoplay
|
|
||||||
}" data-height="${token.parameters.height}">${content}</div>
|
|
||||||
</pre>`
|
</pre>`
|
||||||
},
|
},
|
||||||
mermaid: token => {
|
mermaid: token => {
|
||||||
return `<pre class="fence" data-line="${token.map[0]}">
|
return `<pre class="fence" data-line="${token.map[0]}">
|
||||||
<span class="filename">${token.fileName}</span>
|
<span class="filename">${token.fileName}</span>
|
||||||
<div class="mermaid" data-height="${token.parameters.height}">${
|
<div class="mermaid" data-height="${token.parameters.height}">${token.content}</div>
|
||||||
token.content
|
|
||||||
}</div>
|
|
||||||
</pre>`
|
</pre>`
|
||||||
},
|
},
|
||||||
sequence: token => {
|
sequence: token => {
|
||||||
return `<pre class="fence" data-line="${token.map[0]}">
|
return `<pre class="fence" data-line="${token.map[0]}">
|
||||||
<span class="filename">${token.fileName}</span>
|
<span class="filename">${token.fileName}</span>
|
||||||
<div class="sequence" data-height="${token.parameters.height}">${
|
<div class="sequence" data-height="${token.parameters.height}">${token.content}</div>
|
||||||
token.content
|
|
||||||
}</div>
|
|
||||||
</pre>`
|
</pre>`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ const exec = require('child_process').exec
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
let lastHeartbeat = 0
|
let lastHeartbeat = 0
|
||||||
|
|
||||||
function sendWakatimeHeartBeat (storagePath, noteKey, storageName, isWrite, hasFileChanges, isFileChange) {
|
function sendWakatimeHeartBeat(
|
||||||
|
storagePath,
|
||||||
|
noteKey,
|
||||||
|
storageName,
|
||||||
|
isWrite,
|
||||||
|
hasFileChanges,
|
||||||
|
isFileChange
|
||||||
|
) {
|
||||||
if (new Date().getTime() - lastHeartbeat > 120000 || isFileChange) {
|
if (new Date().getTime() - lastHeartbeat > 120000 || isFileChange) {
|
||||||
const notePath = path.join(storagePath, 'notes', noteKey + '.cson')
|
const notePath = path.join(storagePath, 'notes', noteKey + '.cson')
|
||||||
|
|
||||||
@@ -14,14 +21,25 @@ function sendWakatimeHeartBeat (storagePath, noteKey, storageName, isWrite, hasF
|
|||||||
lastHeartbeat = new Date()
|
lastHeartbeat = new Date()
|
||||||
const wakatimeKey = config.get().wakatime.key
|
const wakatimeKey = config.get().wakatime.key
|
||||||
if (wakatimeKey) {
|
if (wakatimeKey) {
|
||||||
exec(`wakatime --file ${notePath} --project '${storageName}' --key ${wakatimeKey} --plugin Boostnote-wakatime`, (error, stdOut, stdErr) => {
|
exec(
|
||||||
|
`wakatime --file ${notePath} --project '${storageName}' --key ${wakatimeKey} --plugin Boostnote-wakatime`,
|
||||||
|
(error, stdOut, stdErr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
lastHeartbeat = 0
|
lastHeartbeat = 0
|
||||||
} else {
|
} else {
|
||||||
console.log('wakatime', 'isWrite', isWrite, 'hasChanges', hasFileChanges, 'isFileChange', isFileChange)
|
console.log(
|
||||||
|
'wakatime',
|
||||||
|
'isWrite',
|
||||||
|
isWrite,
|
||||||
|
'hasChanges',
|
||||||
|
hasFileChanges,
|
||||||
|
'isFileChange',
|
||||||
|
isFileChange
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,25 +21,32 @@ class PluginsTab extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.handleSettingDone = () => {
|
this.handleSettingDone = () => {
|
||||||
this.setState({pluginsAlert: {
|
this.setState({
|
||||||
|
pluginsAlert: {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: i18n.__('Successfully applied!')
|
message: i18n.__('Successfully applied!')
|
||||||
}})
|
|
||||||
}
|
}
|
||||||
this.handleSettingError = (err) => {
|
})
|
||||||
|
}
|
||||||
|
this.handleSettingError = err => {
|
||||||
if (
|
if (
|
||||||
this.state.config.wakatime.key === '' ||
|
this.state.config.wakatime.key === '' ||
|
||||||
this.state.config.wakatime.key === null
|
this.state.config.wakatime.key === null
|
||||||
) {
|
) {
|
||||||
this.setState({pluginsAlert: {
|
this.setState({
|
||||||
|
pluginsAlert: {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: i18n.__('Successfully applied!')
|
message: i18n.__('Successfully applied!')
|
||||||
}})
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.setState({pluginsAlert: {
|
this.setState({
|
||||||
|
pluginsAlert: {
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: err.message != null ? err.message : i18n.__('An error occurred!')
|
message:
|
||||||
}})
|
err.message != null ? err.message : i18n.__('An error occurred!')
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.oldWakatimekey = this.state.config.wakatime
|
this.oldWakatimekey = this.state.config.wakatime
|
||||||
@@ -94,11 +101,10 @@ class PluginsTab extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const pluginsAlert = this.state.pluginsAlert
|
const pluginsAlert = this.state.pluginsAlert
|
||||||
const pluginsAlertElement = pluginsAlert != null
|
const pluginsAlertElement =
|
||||||
? <p className={`alert ${pluginsAlert.type}`}>
|
pluginsAlert != null ? (
|
||||||
{pluginsAlert.message}
|
<p className={`alert ${pluginsAlert.type}`}>{pluginsAlert.message}</p>
|
||||||
</p>
|
) : null
|
||||||
: null
|
|
||||||
const { config } = this.state
|
const { config } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -108,8 +114,9 @@ class PluginsTab extends React.Component {
|
|||||||
<div styleName='group-section'>
|
<div styleName='group-section'>
|
||||||
<div styleName='group-section-label'>{i18n.__('Wakatime key')}</div>
|
<div styleName='group-section-label'>{i18n.__('Wakatime key')}</div>
|
||||||
<div styleName='group-section-control'>
|
<div styleName='group-section-control'>
|
||||||
<input styleName='group-section-control-input'
|
<input
|
||||||
onChange={(e) => this.handleWakatimeKeyChange(e)}
|
styleName='group-section-control-input'
|
||||||
|
onChange={e => this.handleWakatimeKeyChange(e)}
|
||||||
ref='key'
|
ref='key'
|
||||||
value={config.wakatime.key}
|
value={config.wakatime.key}
|
||||||
type='text'
|
type='text'
|
||||||
@@ -117,8 +124,11 @@ class PluginsTab extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div styleName='group-control'>
|
<div styleName='group-control'>
|
||||||
<button styleName='group-control-rightButton'
|
<button
|
||||||
onClick={(e) => this.handleSaveButtonClick(e)}>{i18n.__('Save')}
|
styleName='group-control-rightButton'
|
||||||
|
onClick={e => this.handleSaveButtonClick(e)}
|
||||||
|
>
|
||||||
|
{i18n.__('Save')}
|
||||||
</button>
|
</button>
|
||||||
{pluginsAlertElement}
|
{pluginsAlertElement}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -82,13 +82,7 @@ class Preferences extends React.Component {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case 'SNIPPET':
|
case 'SNIPPET':
|
||||||
return (
|
return <SnippetTab dispatch={dispatch} config={config} data={data} />
|
||||||
<SnippetTab
|
|
||||||
dispatch={dispatch}
|
|
||||||
config={config}
|
|
||||||
data={data}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
case 'PLUGINS':
|
case 'PLUGINS':
|
||||||
return (
|
return (
|
||||||
<PluginsTab
|
<PluginsTab
|
||||||
|
|||||||
@@ -480,10 +480,7 @@ const store = createStore(
|
|||||||
reducer,
|
reducer,
|
||||||
undefined,
|
undefined,
|
||||||
process.env.NODE_ENV === 'development'
|
process.env.NODE_ENV === 'development'
|
||||||
? compose(
|
? compose(applyMiddleware(routerMiddleware(history)), DevTools.instrument())
|
||||||
applyMiddleware(routerMiddleware(history)),
|
|
||||||
DevTools.instrument()
|
|
||||||
)
|
|
||||||
: applyMiddleware(routerMiddleware(history))
|
: applyMiddleware(routerMiddleware(history))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user