mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Merge branch 'master' into master
This commit is contained in:
@@ -3,12 +3,10 @@ import React from 'react'
|
||||
import _ from 'lodash'
|
||||
import CodeMirror from 'codemirror'
|
||||
import 'codemirror-mode-elixir'
|
||||
import path from 'path'
|
||||
import copyImage from 'browser/main/lib/dataApi/copyImage'
|
||||
import { findStorage } from 'browser/lib/findStorage'
|
||||
import fs from 'fs'
|
||||
import attachmentManagement from 'browser/main/lib/dataApi/attachmentManagement'
|
||||
import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||
import iconv from 'iconv-lite'
|
||||
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js'
|
||||
@@ -275,23 +273,13 @@ export default class CodeEditor extends React.Component {
|
||||
this.editor.setCursor(cursor)
|
||||
}
|
||||
|
||||
handleDropImage (e) {
|
||||
e.preventDefault()
|
||||
const ValidImageTypes = ['image/gif', 'image/jpeg', 'image/png']
|
||||
|
||||
const file = e.dataTransfer.files[0]
|
||||
const filePath = file.path
|
||||
const filename = path.basename(filePath)
|
||||
const fileType = file['type']
|
||||
|
||||
copyImage(filePath, this.props.storageKey).then((imagePath) => {
|
||||
var showPreview = ValidImageTypes.indexOf(fileType) > 0
|
||||
const imageMd = `${showPreview ? '!' : ''}[${filename}](${path.join('/:storage', imagePath)})`
|
||||
this.insertImageMd(imageMd)
|
||||
})
|
||||
handleDropImage (dropEvent) {
|
||||
dropEvent.preventDefault()
|
||||
const {storageKey, noteKey} = this.props
|
||||
attachmentManagement.handleAttachmentDrop(this, storageKey, noteKey, dropEvent)
|
||||
}
|
||||
|
||||
insertImageMd (imageMd) {
|
||||
insertAttachmentMd (imageMd) {
|
||||
this.editor.replaceSelection(imageMd)
|
||||
}
|
||||
|
||||
@@ -317,24 +305,8 @@ export default class CodeEditor extends React.Component {
|
||||
return prevChar === '](' && nextChar === ')'
|
||||
}
|
||||
if (dataTransferItem.type.match('image')) {
|
||||
const blob = dataTransferItem.getAsFile()
|
||||
const reader = new FileReader()
|
||||
let base64data
|
||||
|
||||
reader.readAsDataURL(blob)
|
||||
reader.onloadend = () => {
|
||||
base64data = reader.result.replace(/^data:image\/png;base64,/, '')
|
||||
base64data += base64data.replace('+', ' ')
|
||||
const binaryData = new Buffer(base64data, 'base64').toString('binary')
|
||||
const imageName = Math.random().toString(36).slice(-16)
|
||||
const storagePath = findStorage(this.props.storageKey).path
|
||||
const imageDir = path.join(storagePath, 'images')
|
||||
if (!fs.existsSync(imageDir)) fs.mkdirSync(imageDir)
|
||||
const imagePath = path.join(imageDir, `${imageName}.png`)
|
||||
fs.writeFile(imagePath, binaryData, 'binary')
|
||||
const imageMd = `})`
|
||||
this.insertImageMd(imageMd)
|
||||
}
|
||||
const {storageKey, noteKey} = this.props
|
||||
attachmentManagement.handlePastImageEvent(this, storageKey, noteKey, dataTransferItem)
|
||||
} else if (this.props.fetchUrlTitle && isURL(pastedTxt) && !isInLinkTag(editor)) {
|
||||
this.handlePasteUrl(e, editor, pastedTxt)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import styles from './MarkdownEditor.styl'
|
||||
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'
|
||||
import { findStorage } from 'browser/lib/findStorage'
|
||||
|
||||
class MarkdownEditor extends React.Component {
|
||||
constructor (props) {
|
||||
@@ -223,7 +223,7 @@ class MarkdownEditor extends React.Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { className, value, config, storageKey } = this.props
|
||||
const {className, value, config, storageKey, noteKey} = this.props
|
||||
|
||||
let editorFontSize = parseInt(config.editor.fontSize, 10)
|
||||
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
|
||||
@@ -263,6 +263,7 @@ class MarkdownEditor extends React.Component {
|
||||
displayLineNumbers={config.editor.displayLineNumbers}
|
||||
scrollPastEnd={config.editor.scrollPastEnd}
|
||||
storageKey={storageKey}
|
||||
noteKey={noteKey}
|
||||
fetchUrlTitle={config.editor.fetchUrlTitle}
|
||||
onChange={(e) => this.handleChange(e)}
|
||||
onBlur={(e) => this.handleBlur(e)}
|
||||
@@ -293,6 +294,7 @@ class MarkdownEditor extends React.Component {
|
||||
onCheckboxClick={(e) => this.handleCheckboxClick(e)}
|
||||
showCopyNotification={config.ui.showCopyNotification}
|
||||
storagePath={storage.path}
|
||||
noteKey={noteKey}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -13,9 +13,11 @@ import htmlTextHelper from 'browser/lib/htmlTextHelper'
|
||||
import copy from 'copy-to-clipboard'
|
||||
import mdurl from 'mdurl'
|
||||
import exportNote from 'browser/main/lib/dataApi/exportNote'
|
||||
import {escapeHtmlCharacters} from 'browser/lib/utils'
|
||||
import { escapeHtmlCharacters } from 'browser/lib/utils'
|
||||
|
||||
const { remote } = require('electron')
|
||||
const attachmentManagement = require('../main/lib/dataApi/attachmentManagement')
|
||||
|
||||
const { app } = remote
|
||||
const path = require('path')
|
||||
const dialog = remote.dialog
|
||||
@@ -216,8 +218,10 @@ export default class MarkdownPreview extends React.Component {
|
||||
const {fontFamily, fontSize, codeBlockFontFamily, lineNumber, codeBlockTheme, scrollPastEnd, theme} = this.getStyleParams()
|
||||
|
||||
const inlineStyles = buildStyle(fontFamily, fontSize, codeBlockFontFamily, lineNumber, scrollPastEnd, theme)
|
||||
const body = this.markdown.render(escapeHtmlCharacters(noteContent))
|
||||
let body = this.markdown.render(escapeHtmlCharacters(noteContent))
|
||||
|
||||
const files = [this.GetCodeThemeLink(codeBlockTheme), ...CSS_FILES]
|
||||
const attachmentsAbsolutePaths = attachmentManagement.getAbsolutePathsOfAttachmentsInContent(noteContent, this.props.storagePath)
|
||||
|
||||
files.forEach((file) => {
|
||||
file = file.replace('file://', '')
|
||||
@@ -226,6 +230,13 @@ export default class MarkdownPreview extends React.Component {
|
||||
dst: 'css'
|
||||
})
|
||||
})
|
||||
attachmentsAbsolutePaths.forEach((attachment) => {
|
||||
exportTasks.push({
|
||||
src: attachment,
|
||||
dst: attachmentManagement.DESTINATION_FOLDER
|
||||
})
|
||||
})
|
||||
body = attachmentManagement.removeStorageAndNoteReferences(body, this.props.noteKey)
|
||||
|
||||
let styles = ''
|
||||
files.forEach((file) => {
|
||||
@@ -398,13 +409,11 @@ export default class MarkdownPreview extends React.Component {
|
||||
value = value.replace(codeBlock, htmlTextHelper.encodeEntities(codeBlock))
|
||||
})
|
||||
}
|
||||
this.refs.root.contentWindow.document.body.innerHTML = this.markdown.render(value)
|
||||
let renderedHTML = this.markdown.render(value)
|
||||
this.refs.root.contentWindow.document.body.innerHTML = attachmentManagement.fixLocalURLS(renderedHTML, storagePath)
|
||||
|
||||
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
||||
this.fixDecodedURI(el)
|
||||
el.href = this.markdown.normalizeLinkText(el.href)
|
||||
if (!/\/:storage/.test(el.href)) return
|
||||
el.href = `file:///${this.markdown.normalizeLinkText(path.join(storagePath, 'images', path.basename(el.href)))}`
|
||||
el.addEventListener('click', this.anchorClickHandler)
|
||||
})
|
||||
|
||||
@@ -416,12 +425,6 @@ export default class MarkdownPreview extends React.Component {
|
||||
el.addEventListener('click', this.linkClickHandler)
|
||||
})
|
||||
|
||||
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('img'), (el) => {
|
||||
el.src = this.markdown.normalizeLinkText(el.src)
|
||||
if (!/\/:storage/.test(el.src)) return
|
||||
el.src = `file:///${this.markdown.normalizeLinkText(path.join(storagePath, 'images', path.basename(el.src)))}`
|
||||
})
|
||||
|
||||
codeBlockTheme = consts.THEMES.some((_theme) => _theme === codeBlockTheme)
|
||||
? codeBlockTheme
|
||||
: 'default'
|
||||
|
||||
@@ -88,7 +88,7 @@ class MarkdownSplitEditor extends React.Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { config, value, storageKey } = this.props
|
||||
const {config, value, storageKey, noteKey} = this.props
|
||||
const storage = findStorage(storageKey)
|
||||
let editorFontSize = parseInt(config.editor.fontSize, 10)
|
||||
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
|
||||
@@ -115,6 +115,7 @@ class MarkdownSplitEditor extends React.Component {
|
||||
scrollPastEnd={config.editor.scrollPastEnd}
|
||||
fetchUrlTitle={config.editor.fetchUrlTitle}
|
||||
storageKey={storageKey}
|
||||
noteKey={noteKey}
|
||||
onChange={this.handleOnChange.bind(this)}
|
||||
onScroll={this.handleScroll.bind(this)}
|
||||
/>
|
||||
@@ -138,6 +139,7 @@ class MarkdownSplitEditor extends React.Component {
|
||||
onScroll={this.handleScroll.bind(this)}
|
||||
showCopyNotification={config.ui.showCopyNotification}
|
||||
storagePath={storage.path}
|
||||
noteKey={noteKey}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -321,3 +321,76 @@ body[data-theme="solarized-dark"]
|
||||
.item-bottom-tagList-empty
|
||||
color $ui-inactive-text-color
|
||||
vertical-align middle
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.item
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
&:hover
|
||||
transition 0.15s
|
||||
// background-color alpha($ui-monokai-noteList-backgroundColor, 20%)
|
||||
color $ui-monokai-text-color
|
||||
.item-title
|
||||
.item-title-icon
|
||||
.item-bottom-time
|
||||
transition 0.15s
|
||||
color $ui-monokai-text-color
|
||||
.item-bottom-tagList-item
|
||||
transition 0.15s
|
||||
background-color alpha($ui-monokai-noteList-backgroundColor, 20%)
|
||||
color $ui-monokai-text-color
|
||||
&:active
|
||||
transition 0.15s
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
.item-title
|
||||
.item-title-icon
|
||||
.item-bottom-time
|
||||
transition 0.15s
|
||||
color $ui-monokai-text-color
|
||||
.item-bottom-tagList-item
|
||||
transition 0.15s
|
||||
background-color alpha($ui-monokai-noteList-backgroundColor, 10%)
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.item-wrapper
|
||||
border-color alpha($ui-monokai-button-backgroundColor, 60%)
|
||||
|
||||
.item--active
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
.item-wrapper
|
||||
border-color transparent
|
||||
.item-title
|
||||
.item-title-icon
|
||||
.item-bottom-time
|
||||
color $ui-monokai-text-color
|
||||
.item-bottom-tagList-item
|
||||
background-color alpha(white, 10%)
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
// background-color alpha($ui-monokai-button--active-backgroundColor, 60%)
|
||||
color #c0392b
|
||||
.item-bottom-tagList-item
|
||||
background-color alpha(#fff, 20%)
|
||||
|
||||
.item-title
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.item-title-icon
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.item-title-empty
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.item-bottom-tagList-item
|
||||
background-color alpha($ui-dark-button--active-backgroundColor, 40%)
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.item-bottom-tagList-empty
|
||||
color $ui-inactive-text-color
|
||||
vertical-align middle
|
||||
|
||||
@@ -212,3 +212,61 @@ body[data-theme="solarized-dark"]
|
||||
.item-simple-right-storageName
|
||||
padding-left 4px
|
||||
opacity 0.4
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.item-simple
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
&:hover
|
||||
transition 0.15s
|
||||
// background-color alpha($ui-dark-button--active-backgroundColor, 20%)
|
||||
color $ui-monokai-text-color
|
||||
.item-simple-title
|
||||
.item-simple-title-icon
|
||||
.item-simple-bottom-time
|
||||
transition 0.15s
|
||||
color $ui-monokai-text-color
|
||||
.item-simple-bottom-tagList-item
|
||||
transition 0.15s
|
||||
background-color alpha(#fff, 20%)
|
||||
color $ui-monokai-text-color
|
||||
&:active
|
||||
transition 0.15s
|
||||
background-color $ui-monokai-button--active-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
.item-simple-title
|
||||
.item-simple-title-icon
|
||||
.item-simple-bottom-time
|
||||
transition 0.15s
|
||||
color $ui-monokai-text-color
|
||||
.item-simple-bottom-tagList-item
|
||||
transition 0.15s
|
||||
background-color alpha(white, 10%)
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.item-simple--active
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-button--active-backgroundColor
|
||||
.item-simple-wrapper
|
||||
border-color transparent
|
||||
.item-simple-title
|
||||
.item-simple-title-icon
|
||||
.item-simple-bottom-time
|
||||
color $ui-monokai-text-color
|
||||
.item-simple-bottom-tagList-item
|
||||
background-color alpha(white, 10%)
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
// background-color alpha($ui-dark-button--active-backgroundColor, 60%)
|
||||
color #c0392b
|
||||
.item-simple-bottom-tagList-item
|
||||
background-color alpha(#fff, 20%)
|
||||
.item-simple-right
|
||||
float right
|
||||
.item-simple-right-storageName
|
||||
padding-left 4px
|
||||
opacity 0.4
|
||||
|
||||
@@ -41,3 +41,14 @@ body[data-theme="solarized-dark"]
|
||||
background-color $ui-solarized-dark-button-backgroundColor
|
||||
&:hover
|
||||
color #5CB85C
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.notification-area
|
||||
background-color none
|
||||
|
||||
.notification-link
|
||||
color $ui-monokai-text-color
|
||||
border none
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
&:hover
|
||||
color #5CB85C
|
||||
@@ -51,7 +51,7 @@ const SideNavFilter = ({
|
||||
</button>
|
||||
|
||||
<button styleName={isTrashedActive ? 'menu-button-trash--active' : 'menu-button'}
|
||||
onClick={handleTrashedButtonClick}
|
||||
onClick={handleTrashedButtonClick} onContextMenu={handleFilterButtonContextMenu}
|
||||
>
|
||||
<div styleName='iconWrap'>
|
||||
<img src={isTrashedActive
|
||||
@@ -60,7 +60,7 @@ const SideNavFilter = ({
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<span onContextMenu={handleFilterButtonContextMenu} styleName='menu-button-label'>{i18n.__('Trash')}</span>
|
||||
<span styleName='menu-button-label'>{i18n.__('Trash')}</span>
|
||||
<span styleName='counters'>{counterDelNote}</span>
|
||||
</button>
|
||||
|
||||
|
||||
@@ -222,4 +222,46 @@ body[data-theme="solarized-dark"]
|
||||
background-color $ui-solarized-dark-button-backgroundColor
|
||||
color $ui-solarized-dark-text-color
|
||||
.menu-button-label
|
||||
color $ui-solarized-dark-text-color
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.menu-button
|
||||
&:active
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.menu-button--active
|
||||
color $ui-monokai-text-color
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
.menu-button-label
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
.menu-button-label
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.menu-button-star--active
|
||||
color $ui-monokai-text-color
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
.menu-button-label
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
.menu-button-label
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.menu-button-trash--active
|
||||
color $ui-monokai-text-color
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
.menu-button-label
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
.menu-button-label
|
||||
color $ui-monokai-text-color
|
||||
@@ -138,3 +138,22 @@ body[data-theme="solarized-dark"]
|
||||
&:hover
|
||||
color $ui-solarized-dark-text-color
|
||||
background-color $ui-solarized-dark-button-backgroundColor
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.folderList-item
|
||||
&:hover
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
&:active
|
||||
color $ui-monokai-text-color
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
|
||||
.folderList-item--active
|
||||
@extend .folderList-item
|
||||
color $ui-monokai-text-color
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
&:active
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
&:hover
|
||||
color $ui-monokai-text-color
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
@@ -9,16 +9,26 @@ import CSSModules from 'browser/lib/CSSModules'
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Function} handleClickTagListItem
|
||||
* @param {Function} handleClickNarrowToTag
|
||||
* @param {bool} isActive
|
||||
* @param {bool} isRelated
|
||||
*/
|
||||
|
||||
const TagListItem = ({name, handleClickTagListItem, isActive, count}) => (
|
||||
<button styleName={isActive ? 'tagList-item-active' : 'tagList-item'} onClick={() => handleClickTagListItem(name)}>
|
||||
<span styleName='tagList-item-name'>
|
||||
{`# ${name}`}
|
||||
<span styleName='tagList-item-count'> {count}</span>
|
||||
</span>
|
||||
</button>
|
||||
const TagListItem = ({name, handleClickTagListItem, handleClickNarrowToTag, isActive, isRelated, count}) => (
|
||||
<div styleName='tagList-itemContainer'>
|
||||
{isRelated
|
||||
? <button styleName={isActive ? 'tagList-itemNarrow-active' : 'tagList-itemNarrow'} onClick={() => handleClickNarrowToTag(name)}>
|
||||
<i className={isActive ? 'fa fa-minus-circle' : 'fa fa-plus-circle'} />
|
||||
</button>
|
||||
: <div styleName={isActive ? 'tagList-itemNarrow-active' : 'tagList-itemNarrow'} />
|
||||
}
|
||||
<button styleName={isActive ? 'tagList-item-active' : 'tagList-item'} onClick={() => handleClickTagListItem(name)}>
|
||||
<span styleName='tagList-item-name'>
|
||||
{`# ${name}`}
|
||||
<span styleName='tagList-item-count'>{count}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
|
||||
TagListItem.propTypes = {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
.tagList-itemContainer
|
||||
display flex
|
||||
|
||||
.tagList-item
|
||||
display flex
|
||||
flex 1
|
||||
width 100%
|
||||
height 26px
|
||||
background-color transparent
|
||||
@@ -20,9 +24,16 @@
|
||||
color $ui-button-default-color
|
||||
background-color $ui-button-default--active-backgroundColor
|
||||
|
||||
.tagList-itemNarrow
|
||||
composes tagList-item
|
||||
flex none
|
||||
width 20px
|
||||
padding 0 4px
|
||||
|
||||
.tagList-item-active
|
||||
background-color $ui-button-default--active-backgroundColor
|
||||
display flex
|
||||
flex 1
|
||||
width 100%
|
||||
height 26px
|
||||
padding 0
|
||||
@@ -36,10 +47,16 @@
|
||||
background-color alpha($ui-button-default--active-backgroundColor, 60%)
|
||||
transition 0.2s
|
||||
|
||||
.tagList-itemNarrow-active
|
||||
composes tagList-item-active
|
||||
flex none
|
||||
width 20px
|
||||
padding 0 4px
|
||||
|
||||
.tagList-item-name
|
||||
display block
|
||||
flex 1
|
||||
padding 0 15px
|
||||
padding 0 8px 0 4px
|
||||
height 26px
|
||||
line-height 26px
|
||||
border-width 0 0 0 2px
|
||||
@@ -49,7 +66,10 @@
|
||||
text-overflow ellipsis
|
||||
|
||||
.tagList-item-count
|
||||
padding 0 3px
|
||||
float right
|
||||
line-height 26px
|
||||
padding-right 15px
|
||||
font-size 13px
|
||||
|
||||
body[data-theme="white"]
|
||||
.tagList-item
|
||||
|
||||
@@ -47,5 +47,15 @@ body[data-theme="solarized-dark"]
|
||||
.progressBar
|
||||
background-color: #2aa198
|
||||
|
||||
.percentageText
|
||||
color #fdf6e3
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.percentageBar
|
||||
background-color #f92672
|
||||
|
||||
.progressBar
|
||||
background-color: #373831
|
||||
|
||||
.percentageText
|
||||
color #fdf6e3
|
||||
@@ -371,3 +371,30 @@ body[data-theme="solarized-dark"]
|
||||
border-color themeSolarizedDarkTableBorder
|
||||
&:last-child
|
||||
border-right solid 1px themeSolarizedDarkTableBorder
|
||||
|
||||
themeMonokaiTableOdd = $ui-monokai-noteDetail-backgroundColor
|
||||
themeMonokaiTableEven = darken($ui-monokai-noteDetail-backgroundColor, 10%)
|
||||
themeMonokaiTableHead = themeMonokaiTableEven
|
||||
themeMonokaiTableBorder = themeDarkBorder
|
||||
|
||||
body[data-theme="monokai"]
|
||||
color $ui-monokai-text-color
|
||||
border-color themeDarkBorder
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
table
|
||||
thead
|
||||
tr
|
||||
background-color themeMonokaiTableHead
|
||||
th
|
||||
border-color themeMonokaiTableBorder
|
||||
&:last-child
|
||||
border-right solid 1px themeMonokaiTableBorder
|
||||
tbody
|
||||
tr:nth-child(2n + 1)
|
||||
background-color themeMonokaiTableOdd
|
||||
tr:nth-child(2n)
|
||||
background-color themeMonokaiTableEven
|
||||
td
|
||||
border-color themeMonokaiTableBorder
|
||||
&:last-child
|
||||
border-right solid 1px themeMonokaiTableBorder
|
||||
75
browser/lib/Languages.js
Normal file
75
browser/lib/Languages.js
Normal file
@@ -0,0 +1,75 @@
|
||||
const languages = [
|
||||
{
|
||||
name: 'Albanian',
|
||||
locale: 'sq'
|
||||
},
|
||||
{
|
||||
name: 'Chinese (zh-CN)',
|
||||
locale: 'zh-CN'
|
||||
},
|
||||
{
|
||||
name: 'Chinese (zh-TW)',
|
||||
locale: 'zh-TW'
|
||||
},
|
||||
{
|
||||
name: 'Danish',
|
||||
locale: 'da'
|
||||
},
|
||||
{
|
||||
name: 'English',
|
||||
locale: 'en'
|
||||
},
|
||||
{
|
||||
name: 'French',
|
||||
locale: 'fr'
|
||||
},
|
||||
{
|
||||
name: 'German',
|
||||
locale: 'de'
|
||||
},
|
||||
{
|
||||
name: 'Hungarian',
|
||||
locale: 'hu'
|
||||
},
|
||||
{
|
||||
name: 'Japanese',
|
||||
locale: 'ja'
|
||||
},
|
||||
{
|
||||
name: 'Korean',
|
||||
locale: 'ko'
|
||||
},
|
||||
{
|
||||
name: 'Norwegian',
|
||||
locale: 'no'
|
||||
},
|
||||
{
|
||||
name: 'Polish',
|
||||
locale: 'pl'
|
||||
},
|
||||
{
|
||||
name: 'Portuguese',
|
||||
locale: 'pt'
|
||||
},
|
||||
{
|
||||
name: 'Russian',
|
||||
locale: 'ru'
|
||||
},
|
||||
{
|
||||
name: 'Spanish',
|
||||
locale: 'es-ES'
|
||||
}
|
||||
]
|
||||
|
||||
module.exports = {
|
||||
getLocales () {
|
||||
return languages.reduce(function (localeList, locale) {
|
||||
localeList.push(locale.locale)
|
||||
return localeList
|
||||
}, [])
|
||||
},
|
||||
getLanguages () {
|
||||
return languages
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
const path = require('path')
|
||||
const { remote } = require('electron')
|
||||
const { app } = remote
|
||||
const { getLocales } = require('./Languages.js')
|
||||
|
||||
// load package for localization
|
||||
const i18n = new (require('i18n-2'))({
|
||||
// setup some locales - other locales default to the first locale
|
||||
locales: [ 'da', 'de', 'en', 'es-ES', 'fr', 'hu', 'ja', 'ko', 'pl', 'pt-BR', 'pt-PT', 'ru', 'sq', 'zh-CN', 'zh-TW' ],
|
||||
locales: getLocales(),
|
||||
extension: '.json',
|
||||
directory: process.env.NODE_ENV === 'production'
|
||||
? path.join(app.getAppPath(), './locales')
|
||||
|
||||
@@ -5,7 +5,7 @@ import math from '@rokt33r/markdown-it-math'
|
||||
import _ from 'lodash'
|
||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||
import katex from 'katex'
|
||||
import {lastFindInArray} from './utils'
|
||||
import { lastFindInArray } from './utils'
|
||||
|
||||
function createGutter (str, firstLineNumber) {
|
||||
if (Number.isNaN(firstLineNumber)) firstLineNumber = 1
|
||||
@@ -234,10 +234,6 @@ class Markdown {
|
||||
if (!_.isString(content)) content = ''
|
||||
return this.md.render(content)
|
||||
}
|
||||
|
||||
normalizeLinkText (linkText) {
|
||||
return this.md.normalizeLinkText(linkText)
|
||||
}
|
||||
}
|
||||
|
||||
export default Markdown
|
||||
|
||||
@@ -30,3 +30,10 @@ body[data-theme="solarized-dark"]
|
||||
border-left 1px solid $ui-solarized-dark-borderColor
|
||||
.empty-message
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
border-left 1px solid $ui-monokai-borderColor
|
||||
.empty-message
|
||||
color $ui-monokai-text-color
|
||||
|
||||
@@ -133,3 +133,29 @@ body[data-theme="dark"]
|
||||
color $ui-dark-button--active-color
|
||||
.search-optionList-item-name-surfix
|
||||
color $ui-dark-inactive-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
color $ui-dark-text-color
|
||||
&:hover
|
||||
color white
|
||||
background-color $ui-monokai-button--hover-backgroundColor
|
||||
border-color $ui-monokai-borderColor
|
||||
|
||||
.search-optionList
|
||||
color white
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
|
||||
.search-optionList-item
|
||||
&:hover
|
||||
background-color lighten($ui-monokai-button--hover-backgroundColor, 15%)
|
||||
|
||||
.search-optionList-item--active
|
||||
background-color $ui-monokai-button--active-backgroundColor
|
||||
color $ui-monokai-button--active-color
|
||||
&:hover
|
||||
background-color $ui-monokai-button--active-backgroundColor
|
||||
color $ui-monokai-button--active-color
|
||||
.search-optionList-item-name-surfix
|
||||
color $ui-monokai-inactive-text-color
|
||||
|
||||
@@ -215,3 +215,43 @@ body[data-theme="solarized-dark"]
|
||||
color $ui-dark-inactive-text-color
|
||||
&:hover
|
||||
color $ui-solarized-ark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.control-infoButton-panel
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.control-infoButton-panel-trash
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.modification-date
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.modification-date-desc
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.infoPanel-defaul-count
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.infoPanel-sub-count
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.infoPanel-default
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.infoPanel-sub
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.infoPanel-noteLink
|
||||
background-color alpha($ui-monokai-borderColor, 20%)
|
||||
color $ui-monokai-text-color
|
||||
|
||||
[id=export-wrap]
|
||||
button
|
||||
color $ui-dark-inactive-text-color
|
||||
&:hover
|
||||
background-color alpha($ui-monokai-borderColor, 20%)
|
||||
color $ui-monokai-text-color
|
||||
p
|
||||
color $ui-dark-inactive-text-color
|
||||
&:hover
|
||||
color $ui-monokai-text-color
|
||||
|
||||
@@ -289,6 +289,7 @@ class MarkdownNoteDetail extends React.Component {
|
||||
config={config}
|
||||
value={note.content}
|
||||
storageKey={note.storage}
|
||||
noteKey={note.key}
|
||||
onChange={this.handleUpdateContent.bind(this)}
|
||||
ignorePreviewPointerEvents={ignorePreviewPointerEvents}
|
||||
/>
|
||||
@@ -298,6 +299,7 @@ class MarkdownNoteDetail extends React.Component {
|
||||
config={config}
|
||||
value={note.content}
|
||||
storageKey={note.storage}
|
||||
noteKey={note.key}
|
||||
onChange={this.handleUpdateContent.bind(this)}
|
||||
ignorePreviewPointerEvents={ignorePreviewPointerEvents}
|
||||
/>
|
||||
|
||||
@@ -71,3 +71,8 @@ body[data-theme="solarized-dark"]
|
||||
.root
|
||||
border-left 1px solid $ui-solarized-dark-borderColor
|
||||
background-color $ui-solarized-dark-noteDetail-backgroundColor
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
border-left 1px solid $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
|
||||
@@ -98,3 +98,7 @@ body[data-theme="solarized-dark"]
|
||||
border-color $ui-solarized-dark-borderColor
|
||||
background-color $ui-solarized-dark-noteDetail-backgroundColor
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.info
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
@@ -152,4 +152,21 @@ body[data-theme="solarized-dark"]
|
||||
|
||||
.tabList
|
||||
background-color $ui-solarized-dark-noteDetail-backgroundColor
|
||||
color $ui-solarized-dark-text-color
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
border-left 1px solid $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
|
||||
.body
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
|
||||
.body .description textarea
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
border 1px solid $ui-monokai-borderColor
|
||||
|
||||
.tabList
|
||||
background-color $ui-monokai-noteDetail-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
@@ -81,4 +81,20 @@ body[data-theme="solarized-dark"]
|
||||
.newTag
|
||||
border-color none
|
||||
background-color transparent
|
||||
color $ui-solarized-dark-text-color
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.tag
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
|
||||
.tag-removeButton
|
||||
border-color $ui-button--focus-borderColor
|
||||
background-color transparent
|
||||
|
||||
.tag-label
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.newTag
|
||||
border-color none
|
||||
background-color transparent
|
||||
color $ui-monokai-text-color
|
||||
|
||||
@@ -56,3 +56,10 @@ body[data-theme="solarized-dark"]
|
||||
.active
|
||||
background-color #1EC38B
|
||||
box-shadow 2px 0px 7px #222222
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.control-toggleModeButton
|
||||
background-color #272822
|
||||
.active
|
||||
background-color #1EC38B
|
||||
box-shadow 2px 0px 7px #222222
|
||||
|
||||
@@ -15,6 +15,7 @@ import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||
import { hashHistory } from 'react-router'
|
||||
import store from 'browser/main/store'
|
||||
import i18n from 'browser/lib/i18n'
|
||||
import { getLocales } from 'browser/lib/Languages'
|
||||
const path = require('path')
|
||||
const electron = require('electron')
|
||||
const { remote } = electron
|
||||
@@ -143,7 +144,8 @@ class Main extends React.Component {
|
||||
const supportedThemes = [
|
||||
'dark',
|
||||
'white',
|
||||
'solarized-dark'
|
||||
'solarized-dark',
|
||||
'monokai'
|
||||
]
|
||||
|
||||
if (supportedThemes.indexOf(config.ui.theme) !== -1) {
|
||||
@@ -152,24 +154,7 @@ class Main extends React.Component {
|
||||
document.body.setAttribute('data-theme', 'default')
|
||||
}
|
||||
|
||||
const supportedLanguages = [
|
||||
'sq',
|
||||
'zh-CN',
|
||||
'zh-TW',
|
||||
'da',
|
||||
'fr',
|
||||
'de',
|
||||
'hu',
|
||||
'ja',
|
||||
'ko',
|
||||
'no',
|
||||
'pl',
|
||||
'pt',
|
||||
'ru',
|
||||
'es-ES'
|
||||
]
|
||||
|
||||
if (supportedLanguages.indexOf(config.ui.language) !== -1) {
|
||||
if (getLocales().indexOf(config.ui.language) !== -1) {
|
||||
i18n.setLocale(config.ui.language)
|
||||
} else {
|
||||
i18n.setLocale('en')
|
||||
|
||||
@@ -74,4 +74,8 @@ body[data-theme="dark"]
|
||||
|
||||
body[data-theme="solarized-dark"]
|
||||
.root, .root--expanded
|
||||
background-color $ui-solarized-dark-noteList-backgroundColor
|
||||
background-color $ui-solarized-dark-noteList-backgroundColor
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root, .root--expanded
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
@@ -113,4 +113,28 @@ body[data-theme="solarized-dark"]
|
||||
.control-button--active
|
||||
color $ui-solarized-dark-text-color
|
||||
&:active
|
||||
color $ui-solarized-dark-text-color
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
border-color $ui-monokai-borderColor
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.control
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
border-color $ui-monokai-borderColor
|
||||
|
||||
.control-sortBy-select
|
||||
&:hover
|
||||
transition 0.2s
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.control-button
|
||||
color $ui-monokai-inactive-text-color
|
||||
&:hover
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.control-button--active
|
||||
color $ui-monokai-text-color
|
||||
&:active
|
||||
color $ui-monokai-text-color
|
||||
|
||||
@@ -343,11 +343,10 @@ class NoteList extends React.Component {
|
||||
}
|
||||
|
||||
if (location.pathname.match(/\/tags/)) {
|
||||
const listOfTags = params.tagname.split(' ')
|
||||
return data.noteMap.map(note => {
|
||||
return note
|
||||
}).filter(note => {
|
||||
return note.tags.includes(params.tagname)
|
||||
})
|
||||
}).filter(note => listOfTags.every(tag => note.tags.includes(tag)))
|
||||
}
|
||||
|
||||
return this.getContextNotes()
|
||||
@@ -456,12 +455,19 @@ class NoteList extends React.Component {
|
||||
}
|
||||
|
||||
handleDragStart (e, note) {
|
||||
const { selectedNoteKeys } = this.state
|
||||
let { selectedNoteKeys } = this.state
|
||||
const noteKey = getNoteKey(note)
|
||||
|
||||
if (!selectedNoteKeys.includes(noteKey)) {
|
||||
selectedNoteKeys = []
|
||||
selectedNoteKeys.push(noteKey)
|
||||
}
|
||||
|
||||
const notes = this.notes.map((note) => Object.assign({}, note))
|
||||
const selectedNotes = findNotesByKeys(notes, selectedNoteKeys)
|
||||
const noteData = JSON.stringify(selectedNotes)
|
||||
e.dataTransfer.setData('note', noteData)
|
||||
this.setState({ selectedNoteKeys: [] })
|
||||
this.selectNextNote()
|
||||
}
|
||||
|
||||
handleNoteContextMenu (e, uniqueKey) {
|
||||
@@ -916,7 +922,7 @@ class NoteList extends React.Component {
|
||||
if (note.isTrashed !== true || location.pathname === '/trashed') return true
|
||||
})
|
||||
|
||||
moment.locale('en', {
|
||||
moment.updateLocale('en', {
|
||||
relativeTime: {
|
||||
future: 'in %s',
|
||||
past: '%s ago',
|
||||
|
||||
@@ -117,3 +117,8 @@ body[data-theme="solarized-dark"]
|
||||
.root, .root--folded
|
||||
background-color $ui-solarized-dark-backgroundColor
|
||||
border-right 1px solid $ui-solarized-dark-borderColor
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root, .root--folded
|
||||
background-color $ui-monokai-backgroundColor
|
||||
border-right 1px solid $ui-monokai-borderColor
|
||||
|
||||
@@ -145,20 +145,27 @@ class SideNav extends React.Component {
|
||||
|
||||
tagListComponent () {
|
||||
const { data, location, config } = this.props
|
||||
const relatedTags = this.getRelatedTags(this.getActiveTags(location.pathname), data.noteMap)
|
||||
let tagList = _.sortBy(data.tagNoteMap.map(
|
||||
(tag, name) => ({name, size: tag.size})),
|
||||
['name']
|
||||
)
|
||||
(tag, name) => ({ name, size: tag.size, related: relatedTags.has(name) })
|
||||
), ['name'])
|
||||
if (config.sortTagsBy === 'COUNTER') {
|
||||
tagList = _.sortBy(tagList, item => (0 - item.size))
|
||||
}
|
||||
if (config.ui.showOnlyRelatedTags && (relatedTags.size > 0)) {
|
||||
tagList = tagList.filter(
|
||||
tag => tag.related
|
||||
)
|
||||
}
|
||||
return (
|
||||
tagList.map(tag => {
|
||||
return (
|
||||
<TagListItem
|
||||
name={tag.name}
|
||||
handleClickTagListItem={this.handleClickTagListItem.bind(this)}
|
||||
handleClickNarrowToTag={this.handleClickNarrowToTag.bind(this)}
|
||||
isActive={this.getTagActive(location.pathname, tag.name)}
|
||||
isRelated={tag.related}
|
||||
key={tag.name}
|
||||
count={tag.size}
|
||||
/>
|
||||
@@ -167,10 +174,30 @@ class SideNav extends React.Component {
|
||||
)
|
||||
}
|
||||
|
||||
getRelatedTags (activeTags, noteMap) {
|
||||
if (activeTags.length === 0) {
|
||||
return new Set()
|
||||
}
|
||||
const relatedNotes = noteMap.map(
|
||||
note => ({key: note.key, tags: note.tags})
|
||||
).filter(
|
||||
note => activeTags.every(tag => note.tags.includes(tag))
|
||||
)
|
||||
let relatedTags = new Set()
|
||||
relatedNotes.forEach(note => note.tags.map(tag => relatedTags.add(tag)))
|
||||
return relatedTags
|
||||
}
|
||||
|
||||
getTagActive (path, tag) {
|
||||
return this.getActiveTags(path).includes(tag)
|
||||
}
|
||||
|
||||
getActiveTags (path) {
|
||||
const pathSegments = path.split('/')
|
||||
const pathTag = pathSegments[pathSegments.length - 1]
|
||||
return pathTag === tag
|
||||
const tags = pathSegments[pathSegments.length - 1]
|
||||
return (tags === 'alltags')
|
||||
? []
|
||||
: tags.split(' ')
|
||||
}
|
||||
|
||||
handleClickTagListItem (name) {
|
||||
@@ -192,6 +219,19 @@ class SideNav extends React.Component {
|
||||
})
|
||||
}
|
||||
|
||||
handleClickNarrowToTag (tag) {
|
||||
const { router } = this.context
|
||||
const { location } = this.props
|
||||
let listOfTags = this.getActiveTags(location.pathname)
|
||||
const indexOfTag = listOfTags.indexOf(tag)
|
||||
if (indexOfTag > -1) {
|
||||
listOfTags.splice(indexOfTag, 1)
|
||||
} else {
|
||||
listOfTags.push(tag)
|
||||
}
|
||||
router.push(`/tags/${listOfTags.join(' ')}`)
|
||||
}
|
||||
|
||||
emptyTrash (entries) {
|
||||
const { dispatch } = this.props
|
||||
const deletionPromises = entries.map((note) => {
|
||||
|
||||
@@ -69,3 +69,14 @@ body[data-theme="dark"]
|
||||
navDarkButtonColor()
|
||||
border-color $ui-dark-borderColor
|
||||
border-left 1px solid $ui-dark-borderColor
|
||||
|
||||
body[data-theme="monokai"]
|
||||
navButtonColor()
|
||||
.zoom
|
||||
border-color $ui-dark-borderColor
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
transition 0.15s
|
||||
color $ui-monokai-active-color
|
||||
&:active
|
||||
color $ui-monokai-active-color
|
||||
|
||||
@@ -234,3 +234,25 @@ body[data-theme="solarized-dark"]
|
||||
input
|
||||
background-color $ui-solarized-dark-noteList-backgroundColor
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root, .root--expanded
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.control
|
||||
border-color $ui-monokai-borderColor
|
||||
.control-search
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.control-search-icon
|
||||
absolute top bottom left
|
||||
line-height 32px
|
||||
width 35px
|
||||
color $ui-monokai-inactive-text-color
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
|
||||
.control-search-input
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
input
|
||||
background-color $ui-monokai-noteList-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
|
||||
@@ -134,4 +134,10 @@ body[data-theme="solarized-dark"]
|
||||
.sortableItemHelper
|
||||
color: $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.ModalBase
|
||||
.modalBack
|
||||
background-color $ui-monokai-backgroundColor
|
||||
.sortableItemHelper
|
||||
color: $ui-monokai-text-color
|
||||
|
||||
|
||||
@@ -135,6 +135,8 @@ function set (updates) {
|
||||
document.body.setAttribute('data-theme', 'white')
|
||||
} else if (newConfig.ui.theme === 'solarized-dark') {
|
||||
document.body.setAttribute('data-theme', 'solarized-dark')
|
||||
} else if (newConfig.ui.theme === 'monokai') {
|
||||
document.body.setAttribute('data-theme', 'monokai')
|
||||
} else {
|
||||
document.body.setAttribute('data-theme', 'default')
|
||||
}
|
||||
|
||||
204
browser/main/lib/dataApi/attachmentManagement.js
Normal file
204
browser/main/lib/dataApi/attachmentManagement.js
Normal file
@@ -0,0 +1,204 @@
|
||||
const uniqueSlug = require('unique-slug')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const findStorage = require('browser/lib/findStorage')
|
||||
const mdurl = require('mdurl')
|
||||
const escapeStringRegexp = require('escape-string-regexp')
|
||||
|
||||
const STORAGE_FOLDER_PLACEHOLDER = ':storage'
|
||||
const DESTINATION_FOLDER = 'attachments'
|
||||
|
||||
/**
|
||||
* @description
|
||||
* Copies a copy of an attachment to the storage folder specified by the given key and return the generated attachment name.
|
||||
* Renames the file to match a unique file name.
|
||||
*
|
||||
* @param {String} sourceFilePath The source path of the attachment to be copied
|
||||
* @param {String} storageKey Storage key of the destination storage
|
||||
* @param {String} noteKey Key of the current note. Will be used as subfolder in :storage
|
||||
* @param {boolean} useRandomName determines whether a random filename for the new file is used. If false the source file name is used
|
||||
* @return {Promise<String>} name (inclusive extension) of the generated file
|
||||
*/
|
||||
function copyAttachment (sourceFilePath, storageKey, noteKey, useRandomName = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!sourceFilePath) {
|
||||
reject('sourceFilePath has to be given')
|
||||
}
|
||||
|
||||
if (!storageKey) {
|
||||
reject('storageKey has to be given')
|
||||
}
|
||||
|
||||
if (!noteKey) {
|
||||
reject('noteKey has to be given')
|
||||
}
|
||||
|
||||
try {
|
||||
if (!fs.existsSync(sourceFilePath)) {
|
||||
reject('source file does not exist')
|
||||
}
|
||||
|
||||
const targetStorage = findStorage.findStorage(storageKey)
|
||||
|
||||
const inputFile = fs.createReadStream(sourceFilePath)
|
||||
let destinationName
|
||||
if (useRandomName) {
|
||||
destinationName = `${uniqueSlug()}${path.extname(sourceFilePath)}`
|
||||
} else {
|
||||
destinationName = path.basename(sourceFilePath)
|
||||
}
|
||||
const destinationDir = path.join(targetStorage.path, DESTINATION_FOLDER, noteKey)
|
||||
createAttachmentDestinationFolder(targetStorage.path, noteKey)
|
||||
const outputFile = fs.createWriteStream(path.join(destinationDir, destinationName))
|
||||
inputFile.pipe(outputFile)
|
||||
resolve(destinationName)
|
||||
} catch (e) {
|
||||
return reject(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function createAttachmentDestinationFolder (destinationStoragePath, noteKey) {
|
||||
let destinationDir = path.join(destinationStoragePath, DESTINATION_FOLDER)
|
||||
if (!fs.existsSync(destinationDir)) {
|
||||
fs.mkdirSync(destinationDir)
|
||||
}
|
||||
destinationDir = path.join(destinationStoragePath, DESTINATION_FOLDER, noteKey)
|
||||
if (!fs.existsSync(destinationDir)) {
|
||||
fs.mkdirSync(destinationDir)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Fixes the URLs embedded in the generated HTML so that they again refer actual local files.
|
||||
* @param {String} renderedHTML HTML in that the links should be fixed
|
||||
* @param {String} storagePath Path of the current storage
|
||||
* @returns {String} postprocessed HTML in which all :storage references are mapped to the actual paths.
|
||||
*/
|
||||
function fixLocalURLS (renderedHTML, storagePath) {
|
||||
return renderedHTML.replace(new RegExp(mdurl.encode(path.sep), 'g'), path.sep).replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER, 'g'), 'file:///' + path.join(storagePath, DESTINATION_FOLDER))
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Generates the markdown code for a given attachment
|
||||
* @param {String} fileName Name of the attachment
|
||||
* @param {String} path Path of the attachment
|
||||
* @param {Boolean} showPreview Indicator whether the generated markdown should show a preview of the image. Note that at the moment only previews for images are supported
|
||||
* @returns {String} Generated markdown code
|
||||
*/
|
||||
function generateAttachmentMarkdown (fileName, path, showPreview) {
|
||||
return `${showPreview ? '!' : ''}[${fileName}](${path})`
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Handles the drop-event of a file. Includes the necessary markdown code and copies the file to the corresponding storage folder.
|
||||
* The method calls {CodeEditor#insertAttachmentMd()} to include the generated markdown at the needed place!
|
||||
* @param {CodeEditor} codeEditor Markdown editor. Its insertAttachmentMd() method will be called to include the markdown code
|
||||
* @param {String} storageKey Key of the current storage
|
||||
* @param {String} noteKey Key of the current note
|
||||
* @param {Event} dropEvent DropEvent
|
||||
*/
|
||||
function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) {
|
||||
const file = dropEvent.dataTransfer.files[0]
|
||||
const filePath = file.path
|
||||
const originalFileName = path.basename(filePath)
|
||||
const fileType = file['type']
|
||||
|
||||
copyAttachment(filePath, storageKey, noteKey).then((fileName) => {
|
||||
const showPreview = fileType.startsWith('image')
|
||||
const imageMd = generateAttachmentMarkdown(originalFileName, path.join(STORAGE_FOLDER_PLACEHOLDER, noteKey, fileName), showPreview)
|
||||
codeEditor.insertAttachmentMd(imageMd)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Creates a new file in the storage folder belonging to the current note and inserts the correct markdown code
|
||||
* @param {CodeEditor} codeEditor Markdown editor. Its insertAttachmentMd() method will be called to include the markdown code
|
||||
* @param {String} storageKey Key of the current storage
|
||||
* @param {String} noteKey Key of the current note
|
||||
* @param {DataTransferItem} dataTransferItem Part of the past-event
|
||||
*/
|
||||
function handlePastImageEvent (codeEditor, storageKey, noteKey, dataTransferItem) {
|
||||
if (!codeEditor) {
|
||||
throw new Error('codeEditor has to be given')
|
||||
}
|
||||
if (!storageKey) {
|
||||
throw new Error('storageKey has to be given')
|
||||
}
|
||||
|
||||
if (!noteKey) {
|
||||
throw new Error('noteKey has to be given')
|
||||
}
|
||||
if (!dataTransferItem) {
|
||||
throw new Error('dataTransferItem has to be given')
|
||||
}
|
||||
|
||||
const blob = dataTransferItem.getAsFile()
|
||||
const reader = new FileReader()
|
||||
let base64data
|
||||
const targetStorage = findStorage.findStorage(storageKey)
|
||||
const destinationDir = path.join(targetStorage.path, DESTINATION_FOLDER, noteKey)
|
||||
createAttachmentDestinationFolder(targetStorage.path, noteKey)
|
||||
|
||||
const imageName = `${uniqueSlug()}.png`
|
||||
const imagePath = path.join(destinationDir, imageName)
|
||||
|
||||
reader.onloadend = function () {
|
||||
base64data = reader.result.replace(/^data:image\/png;base64,/, '')
|
||||
base64data += base64data.replace('+', ' ')
|
||||
const binaryData = new Buffer(base64data, 'base64').toString('binary')
|
||||
fs.writeFile(imagePath, binaryData, 'binary')
|
||||
const imageMd = generateAttachmentMarkdown(imageName, imagePath, true)
|
||||
codeEditor.insertAttachmentMd(imageMd)
|
||||
}
|
||||
reader.readAsDataURL(blob)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns all attachment paths of the given markdown
|
||||
* @param {String} markdownContent content in which the attachment paths should be found
|
||||
* @returns {String[]} Array of the relativ paths (starting with :storage) of the attachments of the given markdown
|
||||
*/
|
||||
function getAttachmentsInContent (markdownContent) {
|
||||
const preparedInput = markdownContent.replace(new RegExp(mdurl.encode(path.sep), 'g'), path.sep)
|
||||
const regexp = new RegExp(STORAGE_FOLDER_PLACEHOLDER + escapeStringRegexp(path.sep) + '([a-zA-Z0-9]|-)+' + escapeStringRegexp(path.sep) + '[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)?', 'g')
|
||||
return preparedInput.match(regexp)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns an array of the absolute paths of the attachments referenced in the given markdown code
|
||||
* @param {String} markdownContent content in which the attachment paths should be found
|
||||
* @param {String} storagePath path of the current storage
|
||||
* @returns {String[]} Absolute paths of the referenced attachments
|
||||
*/
|
||||
function getAbsolutePathsOfAttachmentsInContent (markdownContent, storagePath) {
|
||||
const temp = getAttachmentsInContent(markdownContent)
|
||||
const result = []
|
||||
for (const relativePath of temp) {
|
||||
result.push(relativePath.replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER, 'g'), path.join(storagePath, DESTINATION_FOLDER)))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Deletes all :storage and noteKey references from the given input.
|
||||
* @param input Input in which the references should be deleted
|
||||
* @param noteKey Key of the current note
|
||||
* @returns {String} Input without the references
|
||||
*/
|
||||
function removeStorageAndNoteReferences (input, noteKey) {
|
||||
return input.replace(new RegExp(mdurl.encode(path.sep), 'g'), path.sep).replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER + escapeStringRegexp(path.sep) + noteKey, 'g'), DESTINATION_FOLDER)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
copyAttachment,
|
||||
fixLocalURLS,
|
||||
generateAttachmentMarkdown,
|
||||
handleAttachmentDrop,
|
||||
handlePastImageEvent,
|
||||
getAttachmentsInContent,
|
||||
getAbsolutePathsOfAttachmentsInContent,
|
||||
removeStorageAndNoteReferences,
|
||||
STORAGE_FOLDER_PLACEHOLDER,
|
||||
DESTINATION_FOLDER
|
||||
}
|
||||
@@ -2,6 +2,8 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { findStorage } = require('browser/lib/findStorage')
|
||||
|
||||
// TODO: ehhc: delete this
|
||||
|
||||
/**
|
||||
* @description Copy an image and return the path.
|
||||
* @param {String} filePath
|
||||
@@ -21,8 +23,12 @@ function copyImage (filePath, storageKey, rename = true) {
|
||||
const imageDir = path.join(targetStorage.path, 'images')
|
||||
if (!fs.existsSync(imageDir)) fs.mkdirSync(imageDir)
|
||||
const outputImage = fs.createWriteStream(path.join(imageDir, basename))
|
||||
outputImage.on('error', reject)
|
||||
inputImage.on('error', reject)
|
||||
inputImage.on('end', () => {
|
||||
resolve(basename)
|
||||
})
|
||||
inputImage.pipe(outputImage)
|
||||
resolve(basename)
|
||||
} catch (e) {
|
||||
return reject(e)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import copyFile from 'browser/main/lib/dataApi/copyFile'
|
||||
import {findStorage} from 'browser/lib/findStorage'
|
||||
import filenamify from 'filenamify'
|
||||
import { findStorage } from 'browser/lib/findStorage'
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const LOCAL_STORED_REGEX = /!\[(.*?)]\(\s*?\/:storage\/(.*\.\S*?)\)/gi
|
||||
const IMAGES_FOLDER_NAME = 'images'
|
||||
|
||||
/**
|
||||
* Export note together with images
|
||||
*
|
||||
@@ -28,21 +24,7 @@ function exportNote (storageKey, noteContent, targetPath, outputFormatter) {
|
||||
throw new Error('Storage path is not found')
|
||||
}
|
||||
|
||||
let exportedData = noteContent.replace(LOCAL_STORED_REGEX, (match, dstFilename, srcFilename) => {
|
||||
dstFilename = filenamify(dstFilename, {replacement: '_'})
|
||||
if (!path.extname(dstFilename)) {
|
||||
dstFilename += path.extname(srcFilename)
|
||||
}
|
||||
|
||||
const dstRelativePath = path.join(IMAGES_FOLDER_NAME, dstFilename)
|
||||
|
||||
exportTasks.push({
|
||||
src: path.join(IMAGES_FOLDER_NAME, srcFilename),
|
||||
dst: dstRelativePath
|
||||
})
|
||||
|
||||
return ``
|
||||
})
|
||||
let exportedData = noteContent
|
||||
|
||||
if (outputFormatter) {
|
||||
exportedData = outputFormatter(exportedData, exportTasks)
|
||||
|
||||
@@ -68,6 +68,8 @@ function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
|
||||
return noteData
|
||||
})
|
||||
.then(function moveImages (noteData) {
|
||||
if (oldStorage.path === newStorage.path) return noteData
|
||||
|
||||
const searchImagesRegex = /!\[.*?]\(\s*?\/:storage\/(.*\.\S*?)\)/gi
|
||||
let match = searchImagesRegex.exec(noteData.content)
|
||||
|
||||
@@ -75,6 +77,7 @@ function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
|
||||
while (match != null) {
|
||||
const [, filename] = match
|
||||
const oldPath = path.join(oldStorage.path, 'images', filename)
|
||||
// TODO: ehhc: attachmentManagement
|
||||
moveTasks.push(
|
||||
copyImage(oldPath, noteData.storage, false)
|
||||
.then(() => {
|
||||
|
||||
@@ -102,3 +102,29 @@ body[data-theme="solarized-dark"]
|
||||
|
||||
.control-confirmButton
|
||||
colorSolarizedDarkPrimaryButton()
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
modalMonokai()
|
||||
width 500px
|
||||
height 270px
|
||||
overflow hidden
|
||||
position relative
|
||||
|
||||
.header
|
||||
background-color transparent
|
||||
border-color $ui-dark-borderColor
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.control-folder-label
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.control-folder-input
|
||||
border 1px solid $ui-input--create-folder-modal
|
||||
color white
|
||||
|
||||
.description
|
||||
color $ui-inactive-text-color
|
||||
|
||||
.control-confirmButton
|
||||
colorMonokaiPrimaryButton()
|
||||
|
||||
@@ -81,3 +81,19 @@ body[data-theme="solarized-dark"]
|
||||
.description
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
background-color transparent
|
||||
|
||||
.header
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.control-button
|
||||
border-color $ui-monokai-borderColor
|
||||
color $ui-monokai-text-color
|
||||
background-color transparent
|
||||
&:focus
|
||||
colorDarkPrimaryButton()
|
||||
|
||||
.description
|
||||
color $ui-monokai-text-color
|
||||
|
||||
@@ -133,6 +133,11 @@ colorSolarizedDarkControl()
|
||||
background-color $ui-solarized-dark-button-backgroundColor
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
colorMonokaiControl()
|
||||
border none
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
|
||||
|
||||
body[data-theme="dark"]
|
||||
.root
|
||||
@@ -189,4 +194,29 @@ body[data-theme="solarized-dark"]
|
||||
select, .group-section-control-input
|
||||
colorSolarizedDarkControl()
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.group-header
|
||||
color $ui-monokai-text-color
|
||||
border-color $ui-monokai-borderColor
|
||||
|
||||
.group-header2
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.group-section-control-input
|
||||
border-color $ui-monokai-borderColor
|
||||
|
||||
.group-control
|
||||
border-color $ui-monokai-borderColor
|
||||
.group-control-leftButton
|
||||
colorDarkDefaultButton()
|
||||
border-color $ui-monokai-borderColor
|
||||
.group-control-rightButton
|
||||
colorMonokaiPrimaryButton()
|
||||
.group-hint
|
||||
colorMonokaiControl()
|
||||
.group-section-control
|
||||
select, .group-section-control-input
|
||||
colorMonokaiControl()
|
||||
|
||||
@@ -33,4 +33,10 @@ body[data-theme="solarized-dark"]
|
||||
.root
|
||||
color $ui-solarized-dark-text-color
|
||||
p
|
||||
color $ui-solarized-dark-text-color
|
||||
color $ui-solarized-dark-text-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
color $ui-monokai-text-color
|
||||
p
|
||||
color $ui-monokai-text-color
|
||||
|
||||
@@ -126,3 +126,26 @@ body[data-theme="solarized-dark"]
|
||||
|
||||
.folderItem-right-dangerButton
|
||||
colorSolarizedDarkPrimaryButton()
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.folderItem
|
||||
&:hover
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
|
||||
.folderItem-left-danger
|
||||
color $danger-color
|
||||
|
||||
.folderItem-left-key
|
||||
color $ui-dark-inactive-text-color
|
||||
|
||||
.folderItem-left-colorButton
|
||||
colorMonokaiPrimaryButton()
|
||||
|
||||
.folderItem-right-button
|
||||
colorMonokaiPrimaryButton()
|
||||
|
||||
.folderItem-right-confirmButton
|
||||
colorMonokaiPrimaryButton()
|
||||
|
||||
.folderItem-right-dangerButton
|
||||
colorMonokaiPrimaryButton()
|
||||
|
||||
@@ -68,3 +68,10 @@ body[data-theme="solarized-dark"]
|
||||
.list
|
||||
a
|
||||
color $ui-solarized-dark-active-color
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
color $ui-monokai-text-color
|
||||
.list
|
||||
a
|
||||
color $ui-monokai-active-color
|
||||
|
||||
@@ -116,3 +116,26 @@ body[data-theme="solarized-dark"]
|
||||
&:hover
|
||||
color white
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
background-color transparent
|
||||
.top-bar
|
||||
background-color transparent
|
||||
border-color $ui-monokai-borderColor
|
||||
p
|
||||
color $ui-monokai-text-color
|
||||
.nav
|
||||
background-color transparent
|
||||
border-color $ui-monokai-borderColor
|
||||
.nav-button
|
||||
background-color transparent
|
||||
color $ui-monokai-text-color
|
||||
&:hover
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.nav-button--active
|
||||
@extend .nav-button
|
||||
color $ui-monokai-button--active-color
|
||||
background-color $ui-monokai-button--active-backgroundColor
|
||||
&:hover
|
||||
color white
|
||||
|
||||
@@ -199,3 +199,40 @@ body[data-theme="solarized-dark"]
|
||||
colorDarkDefaultButton()
|
||||
border-color $ui-solarized-dark-borderColor
|
||||
|
||||
body[data-theme="monokai"]
|
||||
.root
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.folderList-item
|
||||
border-bottom $ui-monokai-borderColor
|
||||
|
||||
.folderList-empty
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.list-empty
|
||||
color $ui-monokai-text-color
|
||||
.list-control-addStorageButton
|
||||
border-color $ui-monokai-button-backgroundColor
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.addStorage-header
|
||||
color $ui-monokai-text-color
|
||||
border-color $ui-monokai-borderColor
|
||||
|
||||
.addStorage-body-section-name-input
|
||||
border-color $$ui-monokai-borderColor
|
||||
|
||||
.addStorage-body-section-type-description
|
||||
color $ui-monokai-text-color
|
||||
|
||||
.addStorage-body-section-path-button
|
||||
colorPrimaryButton()
|
||||
.addStorage-body-control
|
||||
border-color $ui-monokai-borderColor
|
||||
|
||||
.addStorage-body-control-createButton
|
||||
colorDarkPrimaryButton()
|
||||
.addStorage-body-control-cancelButton
|
||||
colorDarkDefaultButton()
|
||||
border-color $ui-monokai-borderColor
|
||||
|
||||
@@ -10,6 +10,7 @@ import CodeMirror from 'codemirror'
|
||||
import 'codemirror-mode-elixir'
|
||||
import _ from 'lodash'
|
||||
import i18n from 'browser/lib/i18n'
|
||||
import { getLanguages } from 'browser/lib/Languages'
|
||||
|
||||
const OSX = global.process.platform === 'darwin'
|
||||
|
||||
@@ -65,6 +66,7 @@ class UiTab extends React.Component {
|
||||
language: this.refs.uiLanguage.value,
|
||||
showCopyNotification: this.refs.showCopyNotification.checked,
|
||||
confirmDeletion: this.refs.confirmDeletion.checked,
|
||||
showOnlyRelatedTags: this.refs.showOnlyRelatedTags.checked,
|
||||
disableDirectWrite: this.refs.uiD2w != null
|
||||
? this.refs.uiD2w.checked
|
||||
: false
|
||||
@@ -170,6 +172,7 @@ class UiTab extends React.Component {
|
||||
<option value='default'>{i18n.__('Default')}</option>
|
||||
<option value='white'>{i18n.__('White')}</option>
|
||||
<option value='solarized-dark'>{i18n.__('Solarized Dark')}</option>
|
||||
<option value='monokai'>{i18n.__('Monokai')}</option>
|
||||
<option value='dark'>{i18n.__('Dark')}</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -182,22 +185,9 @@ class UiTab extends React.Component {
|
||||
onChange={(e) => this.handleUIChange(e)}
|
||||
ref='uiLanguage'
|
||||
>
|
||||
<option value='sq'>{i18n.__('Albanian')}</option>
|
||||
<option value='zh-CN'>{i18n.__('Chinese (zh-CN)')}</option>
|
||||
<option value='zh-TW'>{i18n.__('Chinese (zh-TW)')}</option>
|
||||
<option value='da'>{i18n.__('Danish')}</option>
|
||||
<option value='en'>{i18n.__('English')}</option>
|
||||
<option value='fr'>{i18n.__('French')}</option>
|
||||
<option value='de'>{i18n.__('German')}</option>
|
||||
<option value='hu'>{i18n.__('Hungarian')}</option>
|
||||
<option value='ja'>{i18n.__('Japanese')}</option>
|
||||
<option value='ko'>{i18n.__('Korean')}</option>
|
||||
<option value='no'>{i18n.__('Norwegian')}</option>
|
||||
<option value='pl'>{i18n.__('Polish')}</option>
|
||||
<option value='pt-BR'>{i18n.__('Portuguese (Brazil)')}</option>
|
||||
<option value='pt-PT'>{i18n.__('Portuguese (Portugal)')}</option>
|
||||
<option value='ru'>{i18n.__('Russian')}</option>
|
||||
<option value='es-ES'>{i18n.__('Spanish')}</option>
|
||||
{
|
||||
getLanguages().map((language) => <option value={language.locale} key={language.locale}>{i18n.__(language.name)}</option>)
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -222,6 +212,16 @@ class UiTab extends React.Component {
|
||||
{i18n.__('Show a confirmation dialog when deleting notes')}
|
||||
</label>
|
||||
</div>
|
||||
<div styleName='group-checkBoxSection'>
|
||||
<label>
|
||||
<input onChange={(e) => this.handleUIChange(e)}
|
||||
checked={this.state.config.ui.showOnlyRelatedTags}
|
||||
ref='showOnlyRelatedTags'
|
||||
type='checkbox'
|
||||
/>
|
||||
{i18n.__('Show only related tags')}
|
||||
</label>
|
||||
</div>
|
||||
{
|
||||
global.process.platform === 'win32'
|
||||
? <div styleName='group-checkBoxSection'>
|
||||
|
||||
@@ -118,6 +118,16 @@ colorSolarizedDarkPrimaryButton()
|
||||
&:active:hover
|
||||
background-color $dark-primary-button-background--active
|
||||
|
||||
colorMonokaiPrimaryButton()
|
||||
color $ui-monokai-text-color
|
||||
background-color $ui-monokai-button-backgroundColor
|
||||
border none
|
||||
&:hover
|
||||
background-color $dark-primary-button-background--hover
|
||||
&:active
|
||||
&:active:hover
|
||||
background-color $dark-primary-button-background--active
|
||||
|
||||
|
||||
// Danger button(Brand color)
|
||||
$danger-button-background = #c9302c
|
||||
@@ -348,3 +358,29 @@ modalSolarizedDark()
|
||||
background-color $ui-solarized-dark-backgroundColor
|
||||
overflow hidden
|
||||
border-radius $modal-border-radius
|
||||
|
||||
/******* Monokai theme ********/
|
||||
$ui-monokai-backgroundColor = #272822
|
||||
$ui-monokai-noteList-backgroundColor = #272822
|
||||
$ui-monokai-noteDetail-backgroundColor = #272822
|
||||
|
||||
$ui-monokai-text-color = #f8f8f2
|
||||
$ui-monokai-active-color = #f92672
|
||||
|
||||
$ui-monokai-borderColor = #373831
|
||||
|
||||
$ui-monokai-tag-backgroundColor = #f92672
|
||||
|
||||
$ui-monokai-button-backgroundColor = #373831
|
||||
$ui-monokai-button--active-color = white
|
||||
$ui-monokai-button--active-backgroundColor = #f92672
|
||||
$ui-monokai-button--hover-backgroundColor = lighten($ui-dark-backgroundColor, 10%)
|
||||
$ui-monokai-button--focus-borderColor = lighten(#369DCD, 25%)
|
||||
|
||||
modalmonokai()
|
||||
position relative
|
||||
z-index $modal-z-index
|
||||
width 100%
|
||||
background-color $ui-monokai-backgroundColor
|
||||
overflow hidden
|
||||
border-radius $modal-border-radius
|
||||
Reference in New Issue
Block a user