Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@
"react/no-find-dom-node": "warn",
"react/no-render-return-value": "warn",
"react/no-deprecated": "warn"
},
"globals": {
"FileReader": true,
"localStorage": true,
"fetch": true
}
}
11 changes: 6 additions & 5 deletions browser/components/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class CodeEditor extends React.Component {
this.editor.on('change', this.changeHandler)
this.editor.on('paste', this.pasteHandler)

let editorTheme = document.getElementById('editorTheme')
const editorTheme = document.getElementById('editorTheme')
editorTheme.addEventListener('load', this.loadStyleHandler)

CodeMirror.Vim.defineEx('quit', 'q', this.quitEditor)
Expand All @@ -121,7 +121,7 @@ export default class CodeEditor extends React.Component {
this.editor.off('blur', this.blurHandler)
this.editor.off('change', this.changeHandler)
this.editor.off('paste', this.pasteHandler)
let editorTheme = document.getElementById('editorTheme')
const editorTheme = document.getElementById('editorTheme')
editorTheme.removeEventListener('load', this.loadStyleHandler)
}

Expand Down Expand Up @@ -197,7 +197,7 @@ export default class CodeEditor extends React.Component {
}

setValue (value) {
let cursor = this.editor.getCursor()
const cursor = this.editor.getCursor()
this.editor.setValue(value)
this.editor.setCursor(cursor)
}
Expand All @@ -222,7 +222,7 @@ export default class CodeEditor extends React.Component {
if (!dataTransferItem.type.match('image')) return

const blob = dataTransferItem.getAsFile()
let reader = new FileReader()
const reader = new FileReader()
let base64data

reader.readAsDataURL(blob)
Expand All @@ -242,7 +242,8 @@ export default class CodeEditor extends React.Component {
}

render () {
let { className, fontFamily, fontSize } = this.props
const { className, fontSize } = this.props
let fontFamily = this.props.className
fontFamily = _.isString(fontFamily) && fontFamily.length > 0
? [fontFamily].concat(defaultEditorFontFamily)
: defaultEditorFontFamily
Expand Down
31 changes: 15 additions & 16 deletions browser/components/MarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import CodeEditor from 'browser/components/CodeEditor'
import MarkdownPreview from 'browser/components/MarkdownPreview'
import eventEmitter from 'browser/main/lib/eventEmitter'
import { findStorage } from 'browser/lib/findStorage'
const _ = require('lodash')

class MarkdownEditor extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -70,9 +69,9 @@ class MarkdownEditor extends React.Component {
}

handleContextMenu (e) {
let { config } = this.props
const { config } = this.props
if (config.editor.switchPreview === 'RIGHTCLICK') {
let newStatus = this.state.status === 'PREVIEW'
const newStatus = this.state.status === 'PREVIEW'
? 'CODE'
: 'PREVIEW'
this.setState({
Expand All @@ -91,9 +90,9 @@ class MarkdownEditor extends React.Component {
handleBlur (e) {
if (this.state.isLocked) return
this.setState({ keyPressed: new Set() })
let { config } = this.props
const { config } = this.props
if (config.editor.switchPreview === 'BLUR') {
let cursorPosition = this.refs.code.editor.getCursor()
const cursorPosition = this.refs.code.editor.getCursor()
this.setState({
status: 'PREVIEW'
}, () => {
Expand All @@ -109,7 +108,7 @@ class MarkdownEditor extends React.Component {
}

handlePreviewMouseUp (e) {
let { config } = this.props
const { config } = this.props
if (config.editor.switchPreview === 'BLUR' && new Date() - this.previewMouseDownedAt < 200) {
this.setState({
status: 'CODE'
Expand All @@ -123,15 +122,15 @@ class MarkdownEditor extends React.Component {
handleCheckboxClick (e) {
e.preventDefault()
e.stopPropagation()
let idMatch = /checkbox-([0-9]+)/
let checkedMatch = /\[x\]/i
let uncheckedMatch = /\[ \]/
const idMatch = /checkbox-([0-9]+)/
const checkedMatch = /\[x\]/i
const uncheckedMatch = /\[ \]/
if (idMatch.test(e.target.getAttribute('id'))) {
let lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
let lines = this.refs.code.value
const lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
const lines = this.refs.code.value
.split('\n')

let targetLine = lines[lineIndex]
const targetLine = lines[lineIndex]

if (targetLine.match(checkedMatch)) {
lines[lineIndex] = targetLine.replace(checkedMatch, '[ ]')
Expand Down Expand Up @@ -163,12 +162,12 @@ class MarkdownEditor extends React.Component {
}

handleKeyDown (e) {
let { config } = this.props
const { config } = this.props
if (this.state.status !== 'CODE') return false
const keyPressed = this.state.keyPressed
keyPressed.add(e.keyCode)
this.setState({ keyPressed })
let isNoteHandlerKey = (el) => { return keyPressed.has(el) }
const isNoteHandlerKey = (el) => { return keyPressed.has(el) }
// These conditions are for ctrl-e and ctrl-w
if (keyPressed.size === this.escapeFromEditor.length &&
!this.state.isLocked && this.state.status === 'CODE' &&
Expand Down Expand Up @@ -207,14 +206,14 @@ class MarkdownEditor extends React.Component {
}

render () {
let { className, value, config, storageKey } = this.props
const { className, value, config, storageKey } = this.props

let editorFontSize = parseInt(config.editor.fontSize, 10)
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
let editorIndentSize = parseInt(config.editor.indentSize, 10)
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4

let previewStyle = {}
const previewStyle = {}
if (this.props.ignorePreviewPointerEvents) previewStyle.pointerEvents = 'none'

const storage = findStorage(storageKey)
Expand Down
26 changes: 14 additions & 12 deletions browser/components/MarkdownPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ export default class MarkdownPreview extends React.Component {
e.preventDefault()
e.stopPropagation()

let anchor = e.target.closest('a')
let href = anchor.getAttribute('href')
const anchor = e.target.closest('a')
const href = anchor.getAttribute('href')
if (_.isString(href) && href.match(/^#/)) {
let targetElement = this.refs.root.contentWindow.document.getElementById(href.substring(1, href.length))
const targetElement = this.refs.root.contentWindow.document.getElementById(href.substring(1, href.length))
if (targetElement != null) {
this.getWindow().scrollTo(0, targetElement.offsetTop)
}
Expand Down Expand Up @@ -251,7 +251,8 @@ export default class MarkdownPreview extends React.Component {
}

applyStyle () {
let { fontFamily, fontSize, codeBlockFontFamily, lineNumber, codeBlockTheme } = this.props
const { fontSize, lineNumber, codeBlockTheme } = this.props
let { fontFamily, codeBlockFontFamily } = this.props
fontFamily = _.isString(fontFamily) && fontFamily.trim().length > 0
? [fontFamily].concat(defaultFontFamily)
: defaultFontFamily
Expand Down Expand Up @@ -284,7 +285,8 @@ export default class MarkdownPreview extends React.Component {
el.removeEventListener('click', this.linkClickHandler)
})

let { value, theme, indentSize, codeBlockTheme, showCopyNotification, storagePath } = this.props
const { theme, indentSize, showCopyNotification, storagePath } = this.props
let { value, codeBlockTheme } = this.props

this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)

Expand Down Expand Up @@ -327,7 +329,7 @@ export default class MarkdownPreview extends React.Component {
let syntax = CodeMirror.findModeByName(el.className)
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
CodeMirror.requireMode(syntax.mode, () => {
let content = htmlTextHelper.decodeEntities(el.innerHTML)
const content = htmlTextHelper.decodeEntities(el.innerHTML)
const copyIcon = document.createElement('i')
copyIcon.innerHTML = '<button class="clipboardButton"><svg width="13" height="13" viewBox="0 0 1792 1792" ><path d="M768 1664h896v-640h-416q-40 0-68-28t-28-68v-416h-384v1152zm256-1440v-64q0-13-9.5-22.5t-22.5-9.5h-704q-13 0-22.5 9.5t-9.5 22.5v64q0 13 9.5 22.5t22.5 9.5h704q13 0 22.5-9.5t9.5-22.5zm256 672h299l-299-299v299zm512 128v672q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-160h-544q-40 0-68-28t-28-68v-1344q0-40 28-68t68-28h1088q40 0 68 28t28 68v328q21 13 36 28l408 408q28 28 48 76t20 88z"/></svg></button>'
copyIcon.onclick = (e) => {
Expand All @@ -352,7 +354,7 @@ export default class MarkdownPreview extends React.Component {
})
})
})
let opts = {}
const opts = {}
// if (this.props.theme === 'dark') {
// opts['font-color'] = '#DDD'
// opts['line-color'] = '#DDD'
Expand All @@ -362,7 +364,7 @@ export default class MarkdownPreview extends React.Component {
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.flowchart'), (el) => {
Raphael.setWindow(this.getWindow())
try {
let diagram = flowchart.parse(htmlTextHelper.decodeEntities(el.innerHTML))
const diagram = flowchart.parse(htmlTextHelper.decodeEntities(el.innerHTML))
el.innerHTML = ''
diagram.drawSVG(el, opts)
_.forEach(el.querySelectorAll('a'), (el) => {
Expand All @@ -378,7 +380,7 @@ export default class MarkdownPreview extends React.Component {
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.sequence'), (el) => {
Raphael.setWindow(this.getWindow())
try {
let diagram = SequenceDiagram.parse(htmlTextHelper.decodeEntities(el.innerHTML))
const diagram = SequenceDiagram.parse(htmlTextHelper.decodeEntities(el.innerHTML))
el.innerHTML = ''
diagram.drawSVG(el, {theme: 'simple'})
_.forEach(el.querySelectorAll('a'), (el) => {
Expand All @@ -401,11 +403,11 @@ export default class MarkdownPreview extends React.Component {
}

scrollTo (targetRow) {
let blocks = this.getWindow().document.querySelectorAll('body>[data-line]')
const blocks = this.getWindow().document.querySelectorAll('body>[data-line]')

for (let index = 0; index < blocks.length; index++) {
let block = blocks[index]
let row = parseInt(block.getAttribute('data-line'))
const row = parseInt(block.getAttribute('data-line'))
if (row > targetRow || index === blocks.length - 1) {
block = blocks[index - 1]
block != null && this.getWindow().scrollTo(0, block.offsetTop)
Expand Down Expand Up @@ -435,7 +437,7 @@ export default class MarkdownPreview extends React.Component {
}

render () {
let { className, style, tabIndex } = this.props
const { className, style, tabIndex } = this.props
return (
<iframe className={className != null
? 'MarkdownPreview ' + className
Expand Down
2 changes: 1 addition & 1 deletion browser/components/RealtimeNotification.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropTypes } from 'react'
import React from 'react'
import CSSModules from 'browser/lib/CSSModules'
import styles from './RealtimeNotification.styl'

Expand Down
2 changes: 1 addition & 1 deletion browser/components/SnippetTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SnippetTab extends React.Component {
}

render () {
let { isActive, snippet, isDeletable } = this.props
const { isActive, snippet, isDeletable } = this.props
return (
<div styleName={isActive
? 'root--active'
Expand Down
16 changes: 8 additions & 8 deletions browser/finder/NoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NoteDetail extends React.Component {
}

selectPriorSnippet () {
let { note } = this.props
const { note } = this.props
if (note.type === 'SNIPPET_NOTE' && note.snippets.length > 1) {
this.setState({
snippetIndex: (this.state.snippetIndex + note.snippets.length - 1) % note.snippets.length
Expand All @@ -65,7 +65,7 @@ class NoteDetail extends React.Component {
}

selectNextSnippet () {
let { note } = this.props
const { note } = this.props
if (note.type === 'SNIPPET_NOTE' && note.snippets.length > 1) {
this.setState({
snippetIndex: (this.state.snippetIndex + 1) % note.snippets.length
Expand All @@ -74,7 +74,7 @@ class NoteDetail extends React.Component {
}

saveToClipboard () {
let { note } = this.props
const { note } = this.props

if (note.type === 'MARKDOWN_NOTE') {
clipboard.writeText(note.content)
Expand All @@ -95,7 +95,7 @@ class NoteDetail extends React.Component {
}

render () {
let { note, config } = this.props
const { note, config } = this.props
if (note == null) {
return (
<div styleName='root' />
Expand All @@ -110,8 +110,8 @@ class NoteDetail extends React.Component {
const storage = findStorage(note.storage)

if (note.type === 'SNIPPET_NOTE') {
let tabList = note.snippets.map((snippet, index) => {
let isActive = this.state.snippetIndex === index
const tabList = note.snippets.map((snippet, index) => {
const isActive = this.state.snippetIndex === index
return <div styleName={isActive
? 'tabList-item--active'
: 'tabList-item'
Expand All @@ -131,8 +131,8 @@ class NoteDetail extends React.Component {
</div>
})

let viewList = note.snippets.map((snippet, index) => {
let isActive = this.state.snippetIndex === index
const viewList = note.snippets.map((snippet, index) => {
const isActive = this.state.snippetIndex === index

let syntax = CodeMirror.findModeByName(pass(snippet.mode))
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
Expand Down
16 changes: 8 additions & 8 deletions browser/finder/NoteList.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class NoteList extends React.Component {
}

componentDidUpdate () {
let { index } = this.props
const { index } = this.props

if (index > -1) {
let list = this.refs.root
let item = list.childNodes[index]
const list = this.refs.root
const item = list.childNodes[index]
if (item == null) return null

let overflowBelow = item.offsetTop + item.clientHeight - list.clientHeight - list.scrollTop > 0
const overflowBelow = item.offsetTop + item.clientHeight - list.clientHeight - list.scrollTop > 0
if (overflowBelow) {
list.scrollTop = item.offsetTop + item.clientHeight - list.clientHeight
}
let overflowAbove = list.scrollTop > item.offsetTop
const overflowAbove = list.scrollTop > item.offsetTop
if (overflowAbove) {
list.scrollTop = item.offsetTop
}
Expand All @@ -44,7 +44,7 @@ class NoteList extends React.Component {
}

handleScroll (e) {
let { notes } = this.props
const { notes } = this.props

if (e.target.offsetHeight + e.target.scrollTop > e.target.scrollHeight - 100 && notes.length > this.state.range * 10 + 10) {
this.setState({
Expand All @@ -54,9 +54,9 @@ class NoteList extends React.Component {
}

render () {
let { notes, index } = this.props
const { notes, index } = this.props

let notesList = notes
const notesList = notes
.slice(0, 10 + 10 * this.state.range)
.map((note, _index) => {
const isActive = (index === _index)
Expand Down
8 changes: 4 additions & 4 deletions browser/finder/StorageSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class StorageSection extends React.Component {
}

handleHeaderClick (e) {
let { storage } = this.props
const { storage } = this.props
this.props.handleStorageButtonClick(e, storage.key)
}

handleFolderClick (e, folder) {
let { storage } = this.props
const { storage } = this.props
this.props.handleFolderButtonClick(e, storage.key, folder.key)
}

render () {
let { storage, filter } = this.props
let folderList = storage.folders
const { storage, filter } = this.props
const folderList = storage.folders
.map(folder => (
<StorageItem
key={folder.key}
Expand Down
Loading