mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 18:26:26 +00:00
Compare commits
102 Commits
v0.15.1
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6315d1c38 | ||
|
|
fae91255f9 | ||
|
|
a82a3efb14 | ||
|
|
9556417447 | ||
|
|
60fbb7db5d | ||
|
|
e504f8e63e | ||
|
|
071ce12a7e | ||
|
|
0decaf187c | ||
|
|
961644747e | ||
|
|
7f3fdedb5d | ||
|
|
3a80706938 | ||
|
|
2cf5f8e966 | ||
|
|
8ede1a4989 | ||
|
|
76da76ae76 | ||
|
|
c02ab033f4 | ||
|
|
1aaba74e24 | ||
|
|
6fe6794796 | ||
|
|
fd3e243855 | ||
|
|
938b075bf6 | ||
|
|
4fbbb4651d | ||
|
|
2ac38e9644 | ||
|
|
98d4fa0603 | ||
|
|
2ea0514bbe | ||
|
|
137aa692bc | ||
|
|
634fec39c0 | ||
|
|
d269f1e8fd | ||
|
|
4b67026bbf | ||
|
|
8b13ec4f0e | ||
|
|
7fef7660e4 | ||
|
|
01d021cc4c | ||
|
|
c355f81525 | ||
|
|
d138a54dfd | ||
|
|
514d4b9059 | ||
|
|
a7ead67c2d | ||
|
|
2f16784a20 | ||
|
|
8ca3ba21ee | ||
|
|
58ae6419f0 | ||
|
|
b56e0b98e3 | ||
|
|
4def32ab13 | ||
|
|
0de78d12ef | ||
|
|
e756534db4 | ||
|
|
2194965dc4 | ||
|
|
f9e54bcbfc | ||
|
|
667fd3a601 | ||
|
|
461e24bf39 | ||
|
|
ac2cfe5169 | ||
|
|
3f320f4337 | ||
|
|
433ee9ed45 | ||
|
|
6ee92588b1 | ||
|
|
0d797ce8a8 | ||
|
|
4915c545d9 | ||
|
|
e1c95fb1f2 | ||
|
|
5f56d3e0de | ||
|
|
d6b86b902c | ||
|
|
3abc0fec38 | ||
|
|
c0619eb746 | ||
|
|
791ababe1e | ||
|
|
d829216c8d | ||
|
|
1cf6f3b1e2 | ||
|
|
4d5939aaf4 | ||
|
|
2695f62f3e | ||
|
|
ccd0355d0b | ||
|
|
6d6e3a51c0 | ||
|
|
48c8164689 | ||
|
|
38ed5b8541 | ||
|
|
8a6df8bf95 | ||
|
|
9c3f34fe04 | ||
|
|
d4123eeccd | ||
|
|
b91a76b3b1 | ||
|
|
fc08d2f8c3 | ||
|
|
59e361cb37 | ||
|
|
1993a6588d | ||
|
|
218fba1aa1 | ||
|
|
4de6c69f5d | ||
|
|
3921655157 | ||
|
|
e4e10d523f | ||
|
|
404dddcb86 | ||
|
|
ffb2603485 | ||
|
|
ba34458feb | ||
|
|
a2fb50a71c | ||
|
|
b15a4007ee | ||
|
|
93f0d3c1cf | ||
|
|
8ec7d19f30 | ||
|
|
a0f5a06c73 | ||
|
|
39a98e795f | ||
|
|
57705cf41b | ||
|
|
052c70bb38 | ||
|
|
6dc88262c9 | ||
|
|
a19ff6762e | ||
|
|
7034e7b620 | ||
|
|
cd53a65c14 | ||
|
|
8b54f5aa69 | ||
|
|
ceed178061 | ||
|
|
33662974bf | ||
|
|
36b97fc6a2 | ||
|
|
0f8c627474 | ||
|
|
f38fef23a0 | ||
|
|
8be0ea64a5 | ||
|
|
1419c71ef5 | ||
|
|
e13742445e | ||
|
|
1d21bb1ea3 | ||
|
|
aa38b1f859 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ node_modules/*
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
config.json
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ 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 { findStorage } from 'browser/lib/findStorage'
|
||||||
|
import { sendWakatimeHeartBeat } from 'browser/lib/wakatime-plugin'
|
||||||
import {
|
import {
|
||||||
generateInEditor,
|
generateInEditor,
|
||||||
tocExistsInEditor
|
tocExistsInEditor
|
||||||
@@ -113,6 +115,16 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.editorActivityHandler = () => this.handleEditorActivity()
|
this.editorActivityHandler = () => this.handleEditorActivity()
|
||||||
|
|
||||||
this.turndownService = createTurndownService()
|
this.turndownService = createTurndownService()
|
||||||
|
|
||||||
|
// wakatime
|
||||||
|
const { storageKey, noteKey } = this.props
|
||||||
|
const storage = findStorage(storageKey)
|
||||||
|
if (storage)
|
||||||
|
sendWakatimeHeartBeat(storage.path, noteKey, storage.name, {
|
||||||
|
isWrite: false,
|
||||||
|
hasFileChanges: false,
|
||||||
|
isFileChange: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSearch(msg) {
|
handleSearch(msg) {
|
||||||
@@ -793,9 +805,23 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.updateHighlight(editor, changeObject)
|
this.updateHighlight(editor, changeObject)
|
||||||
|
|
||||||
this.value = editor.getValue()
|
this.value = editor.getValue()
|
||||||
|
|
||||||
|
const { storageKey, noteKey } = this.props
|
||||||
|
const storage = findStorage(storageKey)
|
||||||
if (this.props.onChange) {
|
if (this.props.onChange) {
|
||||||
this.props.onChange(editor)
|
this.props.onChange(editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isWrite = !!this.props.onChange
|
||||||
|
const hasFileChanges = isWrite
|
||||||
|
|
||||||
|
if (storage) {
|
||||||
|
sendWakatimeHeartBeat(storage.path, noteKey, storage.name, {
|
||||||
|
isWrite,
|
||||||
|
hasFileChanges,
|
||||||
|
isFileChange: false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linePossibleContainsHeadline(currentLine) {
|
linePossibleContainsHeadline(currentLine) {
|
||||||
@@ -923,6 +949,16 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.restartHighlighting()
|
this.restartHighlighting()
|
||||||
this.editor.on('change', this.changeHandler)
|
this.editor.on('change', this.changeHandler)
|
||||||
this.editor.refresh()
|
this.editor.refresh()
|
||||||
|
|
||||||
|
// wakatime
|
||||||
|
const { storageKey, noteKey } = this.props
|
||||||
|
const storage = findStorage(storageKey)
|
||||||
|
if (storage)
|
||||||
|
sendWakatimeHeartBeat(storage.path, noteKey, storage.name, {
|
||||||
|
isWrite: false,
|
||||||
|
hasFileChanges: false,
|
||||||
|
isFileChange: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(value) {
|
setValue(value) {
|
||||||
@@ -1240,18 +1276,19 @@ export default class CodeEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className, fontSize } = this.props
|
const { className, fontSize, fontFamily, width, height } = this.props
|
||||||
const fontFamily = normalizeEditorFontFamily(this.props.fontFamily)
|
const normalisedFontFamily = normalizeEditorFontFamily(fontFamily)
|
||||||
const width = this.props.width
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={className == null ? 'CodeEditor' : `CodeEditor ${className}`}
|
className={className == null ? 'CodeEditor' : `CodeEditor ${className}`}
|
||||||
ref='root'
|
ref='root'
|
||||||
tabIndex='-1'
|
tabIndex='-1'
|
||||||
style={{
|
style={{
|
||||||
fontFamily,
|
fontFamily: normalisedFontFamily,
|
||||||
fontSize: fontSize,
|
fontSize,
|
||||||
width: width
|
width,
|
||||||
|
height
|
||||||
}}
|
}}
|
||||||
onDrop={e => this.handleDropImage(e)}
|
onDrop={e => this.handleDropImage(e)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -130,6 +130,81 @@ code {
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p code,
|
||||||
|
li code,
|
||||||
|
td code
|
||||||
|
{
|
||||||
|
padding: 2px;
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
[data-theme="default"] p code,
|
||||||
|
[data-theme="default"] li code,
|
||||||
|
[data-theme="default"] td code
|
||||||
|
{
|
||||||
|
background-color: #F4F4F4;
|
||||||
|
border-color: #d9d9d9;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
[data-theme="white"] p code,
|
||||||
|
[data-theme="white"] li code,
|
||||||
|
[data-theme="white"] td code
|
||||||
|
{
|
||||||
|
background-color: #F4F4F4;
|
||||||
|
border-color: #d9d9d9;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
[data-theme="dark"] p code,
|
||||||
|
[data-theme="dark"] li code,
|
||||||
|
[data-theme="dark"] td code
|
||||||
|
{
|
||||||
|
background-color: #444444;
|
||||||
|
border-color: #555;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
[data-theme="dracula"] p code,
|
||||||
|
[data-theme="dracula"] li code,
|
||||||
|
[data-theme="dracula"] td code
|
||||||
|
{
|
||||||
|
background-color: #444444;
|
||||||
|
border-color: #555;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
[data-theme="monokai"] p code,
|
||||||
|
[data-theme="monokai"] li code,
|
||||||
|
[data-theme="monokai"] td code
|
||||||
|
{
|
||||||
|
background-color: #444444;
|
||||||
|
border-color: #555;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
[data-theme="nord"] p code,
|
||||||
|
[data-theme="nord"] li code,
|
||||||
|
[data-theme="nord"] td code
|
||||||
|
{
|
||||||
|
background-color: #444444;
|
||||||
|
border-color: #555;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
[data-theme="solarized-dark"] p code,
|
||||||
|
[data-theme="solarized-dark"] li code,
|
||||||
|
[data-theme="solarized-dark"] td code
|
||||||
|
{
|
||||||
|
background-color: #444444;
|
||||||
|
border-color: #555;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
[data-theme="vulcan"] p code,
|
||||||
|
[data-theme="vulcan"] li code,
|
||||||
|
[data-theme="vulcan"] td code
|
||||||
|
{
|
||||||
|
background-color: #444444;
|
||||||
|
border-color: #555;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
.lineNumber {
|
.lineNumber {
|
||||||
${lineNumber && 'display: block !important;'}
|
${lineNumber && 'display: block !important;'}
|
||||||
font-family: '${codeBlockFontFamily.join("','")}';
|
font-family: '${codeBlockFontFamily.join("','")}';
|
||||||
@@ -1117,7 +1192,10 @@ class MarkdownPreview extends React.Component {
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
const rawHref = e.target.getAttribute('href')
|
const el = e.target.closest('a[href]')
|
||||||
|
if (!el) return
|
||||||
|
|
||||||
|
const rawHref = el.getAttribute('href')
|
||||||
const { dispatch } = this.props
|
const { dispatch } = this.props
|
||||||
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
||||||
|
|
||||||
@@ -1126,8 +1204,6 @@ class MarkdownPreview extends React.Component {
|
|||||||
const isStartWithHash = rawHref[0] === '#'
|
const isStartWithHash = rawHref[0] === '#'
|
||||||
const { href, hash } = parser
|
const { href, hash } = parser
|
||||||
|
|
||||||
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
|
||||||
|
|
||||||
const linkHash = hash === '' ? rawHref : hash // needed because we're having special link formats that are removed by parser e.g. :line:10
|
const linkHash = hash === '' ? rawHref : hash // needed because we're having special link formats that are removed by parser e.g. :line:10
|
||||||
|
|
||||||
const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
|
const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
this.userScroll = true
|
this.userScroll = true
|
||||||
this.state = {
|
this.state = {
|
||||||
isSliderFocused: false,
|
isSliderFocused: false,
|
||||||
codeEditorWidthInPercent: 50
|
codeEditorWidthInPercent: 50,
|
||||||
|
codeEditorHeightInPercent: 50
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,22 +115,42 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
handleMouseMove(e) {
|
handleMouseMove(e) {
|
||||||
if (this.state.isSliderFocused) {
|
if (this.state.isSliderFocused) {
|
||||||
const rootRect = this.refs.root.getBoundingClientRect()
|
const rootRect = this.refs.root.getBoundingClientRect()
|
||||||
const rootWidth = rootRect.width
|
if (this.props.isStacking) {
|
||||||
const offset = rootRect.left
|
const rootHeight = rootRect.height
|
||||||
let newCodeEditorWidthInPercent = ((e.pageX - offset) / rootWidth) * 100
|
const offset = rootRect.top
|
||||||
|
let newCodeEditorHeightInPercent =
|
||||||
|
((e.pageY - offset) / rootHeight) * 100
|
||||||
|
|
||||||
// limit minSize to 10%, maxSize to 90%
|
// limit minSize to 10%, maxSize to 90%
|
||||||
if (newCodeEditorWidthInPercent <= 10) {
|
if (newCodeEditorHeightInPercent <= 10) {
|
||||||
newCodeEditorWidthInPercent = 10
|
newCodeEditorHeightInPercent = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newCodeEditorHeightInPercent >= 90) {
|
||||||
|
newCodeEditorHeightInPercent = 90
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
codeEditorHeightInPercent: newCodeEditorHeightInPercent
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const rootWidth = rootRect.width
|
||||||
|
const offset = rootRect.left
|
||||||
|
let newCodeEditorWidthInPercent = ((e.pageX - offset) / rootWidth) * 100
|
||||||
|
|
||||||
|
// limit minSize to 10%, maxSize to 90%
|
||||||
|
if (newCodeEditorWidthInPercent <= 10) {
|
||||||
|
newCodeEditorWidthInPercent = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newCodeEditorWidthInPercent >= 90) {
|
||||||
|
newCodeEditorWidthInPercent = 90
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
codeEditorWidthInPercent: newCodeEditorWidthInPercent
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newCodeEditorWidthInPercent >= 90) {
|
|
||||||
newCodeEditorWidthInPercent = 90
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
codeEditorWidthInPercent: newCodeEditorWidthInPercent
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,17 +175,71 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
storageKey,
|
storageKey,
|
||||||
noteKey,
|
noteKey,
|
||||||
linesHighlighted,
|
linesHighlighted,
|
||||||
|
isStacking,
|
||||||
RTL
|
RTL
|
||||||
} = this.props
|
} = this.props
|
||||||
const storage = findStorage(storageKey)
|
let storage
|
||||||
|
try {
|
||||||
|
storage = findStorage(storageKey)
|
||||||
|
} catch (e) {
|
||||||
|
return <div />
|
||||||
|
}
|
||||||
|
|
||||||
|
let editorStyle = {}
|
||||||
|
let previewStyle = {}
|
||||||
|
let sliderStyle = {}
|
||||||
|
|
||||||
let editorFontSize = parseInt(config.editor.fontSize, 10)
|
let editorFontSize = parseInt(config.editor.fontSize, 10)
|
||||||
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
|
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
|
||||||
|
editorStyle.fontSize = editorFontSize
|
||||||
|
|
||||||
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
||||||
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
|
if (!(editorStyle.fontSize > 0 && editorStyle.fontSize < 132))
|
||||||
const previewStyle = {}
|
editorIndentSize = 4
|
||||||
previewStyle.width = 100 - this.state.codeEditorWidthInPercent + '%'
|
editorStyle.indentSize = editorIndentSize
|
||||||
|
|
||||||
|
editorStyle = Object.assign(
|
||||||
|
editorStyle,
|
||||||
|
isStacking
|
||||||
|
? {
|
||||||
|
width: '100%',
|
||||||
|
height: `${this.state.codeEditorHeightInPercent}%`
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
width: `${this.state.codeEditorWidthInPercent}%`,
|
||||||
|
height: '100%'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
previewStyle = Object.assign(
|
||||||
|
previewStyle,
|
||||||
|
isStacking
|
||||||
|
? {
|
||||||
|
width: '100%',
|
||||||
|
height: `${100 - this.state.codeEditorHeightInPercent}%`
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
width: `${100 - this.state.codeEditorWidthInPercent}%`,
|
||||||
|
height: '100%'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
sliderStyle = Object.assign(
|
||||||
|
sliderStyle,
|
||||||
|
isStacking
|
||||||
|
? {
|
||||||
|
left: 0,
|
||||||
|
top: `${this.state.codeEditorHeightInPercent}%`
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
left: `${this.state.codeEditorWidthInPercent}%`,
|
||||||
|
top: 0
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (this.props.ignorePreviewPointerEvents || this.state.isSliderFocused)
|
if (this.props.ignorePreviewPointerEvents || this.state.isSliderFocused)
|
||||||
previewStyle.pointerEvents = 'none'
|
previewStyle.pointerEvents = 'none'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
styleName='root'
|
styleName='root'
|
||||||
@@ -174,20 +249,21 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
>
|
>
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
ref='code'
|
ref='code'
|
||||||
width={this.state.codeEditorWidthInPercent + '%'}
|
width={editorStyle.width}
|
||||||
|
height={editorStyle.height}
|
||||||
mode='Boost Flavored Markdown'
|
mode='Boost Flavored Markdown'
|
||||||
value={value}
|
value={value}
|
||||||
theme={config.editor.theme}
|
theme={config.editor.theme}
|
||||||
keyMap={config.editor.keyMap}
|
keyMap={config.editor.keyMap}
|
||||||
fontFamily={config.editor.fontFamily}
|
fontFamily={config.editor.fontFamily}
|
||||||
fontSize={editorFontSize}
|
fontSize={editorStyle.fontSize}
|
||||||
displayLineNumbers={config.editor.displayLineNumbers}
|
displayLineNumbers={config.editor.displayLineNumbers}
|
||||||
lineWrapping
|
lineWrapping
|
||||||
matchingPairs={config.editor.matchingPairs}
|
matchingPairs={config.editor.matchingPairs}
|
||||||
matchingTriples={config.editor.matchingTriples}
|
matchingTriples={config.editor.matchingTriples}
|
||||||
explodingPairs={config.editor.explodingPairs}
|
explodingPairs={config.editor.explodingPairs}
|
||||||
indentType={config.editor.indentType}
|
indentType={config.editor.indentType}
|
||||||
indentSize={editorIndentSize}
|
indentSize={editorStyle.indentSize}
|
||||||
enableRulers={config.editor.enableRulers}
|
enableRulers={config.editor.enableRulers}
|
||||||
rulers={config.editor.rulers}
|
rulers={config.editor.rulers}
|
||||||
scrollPastEnd={config.editor.scrollPastEnd}
|
scrollPastEnd={config.editor.scrollPastEnd}
|
||||||
@@ -208,13 +284,14 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
RTL={RTL}
|
RTL={RTL}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
styleName='slider'
|
styleName={isStacking ? 'slider-hoz' : 'slider'}
|
||||||
style={{ left: this.state.codeEditorWidthInPercent + '%' }}
|
style={{ left: sliderStyle.left, top: sliderStyle.top }}
|
||||||
onMouseDown={e => this.handleMouseDown(e)}
|
onMouseDown={e => this.handleMouseDown(e)}
|
||||||
>
|
>
|
||||||
<div styleName='slider-hitbox' />
|
<div styleName='slider-hitbox' />
|
||||||
</div>
|
</div>
|
||||||
<MarkdownPreview
|
<MarkdownPreview
|
||||||
|
ref='preview'
|
||||||
style={previewStyle}
|
style={previewStyle}
|
||||||
theme={config.ui.theme}
|
theme={config.ui.theme}
|
||||||
keyMap={config.editor.keyMap}
|
keyMap={config.editor.keyMap}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
height 100%
|
height 100%
|
||||||
font-size 30px
|
font-size 30px
|
||||||
display flex
|
display flex
|
||||||
|
flex-wrap wrap
|
||||||
.slider
|
.slider
|
||||||
absolute top bottom
|
absolute top bottom
|
||||||
top -2px
|
top -2px
|
||||||
@@ -15,6 +16,14 @@
|
|||||||
left -3px
|
left -3px
|
||||||
z-index 10
|
z-index 10
|
||||||
cursor col-resize
|
cursor col-resize
|
||||||
|
.slider-hoz
|
||||||
|
absolute left right
|
||||||
|
.slider-hitbox
|
||||||
|
absolute left right
|
||||||
|
width: 100%
|
||||||
|
height 7px
|
||||||
|
cursor row-resize
|
||||||
|
|
||||||
|
|
||||||
apply-theme(theme)
|
apply-theme(theme)
|
||||||
body[data-theme={theme}]
|
body[data-theme={theme}]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import mermaidAPI from 'mermaid'
|
import mermaidAPI from 'mermaid/dist/mermaid.min.js'
|
||||||
import uiThemes from 'browser/lib/ui-themes'
|
import uiThemes from 'browser/lib/ui-themes'
|
||||||
|
|
||||||
// fixes bad styling in the mermaid dark theme
|
// fixes bad styling in the mermaid dark theme
|
||||||
@@ -61,7 +61,6 @@ function render(element, content, theme, enableHTMLLabel) {
|
|||||||
|
|
||||||
el.setAttribute('ratio', ratio)
|
el.setAttribute('ratio', ratio)
|
||||||
el.setAttribute('height', el.parentNode.clientWidth / ratio)
|
el.setAttribute('height', el.parentNode.clientWidth / ratio)
|
||||||
console.log(el)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
49
browser/lib/wakatime-plugin.js
Normal file
49
browser/lib/wakatime-plugin.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import config from 'browser/main/lib/ConfigManager'
|
||||||
|
const exec = require('child_process').exec
|
||||||
|
const path = require('path')
|
||||||
|
let lastHeartbeat = 0
|
||||||
|
|
||||||
|
function sendWakatimeHeartBeat(
|
||||||
|
storagePath,
|
||||||
|
noteKey,
|
||||||
|
storageName,
|
||||||
|
{ isWrite, hasFileChanges, isFileChange }
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
config.get().wakatime.isActive &&
|
||||||
|
!!config.get().wakatime.key &&
|
||||||
|
(new Date().getTime() - lastHeartbeat > 120000 || isFileChange)
|
||||||
|
) {
|
||||||
|
const notePath = path.join(storagePath, 'notes', noteKey + '.cson')
|
||||||
|
|
||||||
|
if (!isWrite && !hasFileChanges && !isFileChange) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
lastHeartbeat = new Date()
|
||||||
|
const wakatimeKey = config.get().wakatime.key
|
||||||
|
if (wakatimeKey) {
|
||||||
|
exec(
|
||||||
|
`wakatime --file ${notePath} --project '${storageName}' --key ${wakatimeKey} --plugin Boostnote-wakatime`,
|
||||||
|
(error, stdOut, stdErr) => {
|
||||||
|
if (error) {
|
||||||
|
console.log(error)
|
||||||
|
lastHeartbeat = 0
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
'wakatime',
|
||||||
|
'isWrite',
|
||||||
|
isWrite,
|
||||||
|
'hasChanges',
|
||||||
|
hasFileChanges,
|
||||||
|
'isFileChange',
|
||||||
|
isFileChange
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { sendWakatimeHeartBeat }
|
||||||
@@ -294,7 +294,7 @@ class FolderSelect extends React.Component {
|
|||||||
{optionList}
|
{optionList}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : currentOption ? (
|
||||||
<div styleName='idle' style={{ color: currentOption.folder.color }}>
|
<div styleName='idle' style={{ color: currentOption.folder.color }}>
|
||||||
<div styleName='idle-label'>
|
<div styleName='idle-label'>
|
||||||
<i className='fa fa-folder' />
|
<i className='fa fa-folder' />
|
||||||
@@ -303,7 +303,7 @@ class FolderSelect extends React.Component {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
this.toggleLockButton = this.handleToggleLockButton.bind(this)
|
this.toggleLockButton = this.handleToggleLockButton.bind(this)
|
||||||
this.generateToc = this.handleGenerateToc.bind(this)
|
this.generateToc = this.handleGenerateToc.bind(this)
|
||||||
this.handleUpdateContent = this.handleUpdateContent.bind(this)
|
this.handleUpdateContent = this.handleUpdateContent.bind(this)
|
||||||
|
this.handleSwitchStackDirection = this.handleSwitchStackDirection.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
@@ -67,6 +68,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
ee.on('editor:orientation', this.handleSwitchStackDirection)
|
||||||
ee.on('topbar:togglelockbutton', this.toggleLockButton)
|
ee.on('topbar:togglelockbutton', this.toggleLockButton)
|
||||||
ee.on('topbar:toggledirectionbutton', () => this.handleSwitchDirection())
|
ee.on('topbar:toggledirectionbutton', () => this.handleSwitchDirection())
|
||||||
ee.on('topbar:togglemodebutton', () => {
|
ee.on('topbar:togglemodebutton', () => {
|
||||||
@@ -383,7 +385,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
handleSwitchMode(type) {
|
handleSwitchMode(type) {
|
||||||
// If in split mode, hide the lock button
|
// If in split mode, hide the lock button
|
||||||
this.setState(
|
this.setState(
|
||||||
{ editorType: type, isLockButtonShown: !(type === 'SPLIT') },
|
{ editorType: type, isLockButtonShown: type !== 'SPLIT' },
|
||||||
() => {
|
() => {
|
||||||
this.focus()
|
this.focus()
|
||||||
const newConfig = Object.assign({}, this.props.config)
|
const newConfig = Object.assign({}, this.props.config)
|
||||||
@@ -393,6 +395,18 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSwitchStackDirection() {
|
||||||
|
this.setState(
|
||||||
|
prevState => ({ isStacking: !prevState.isStacking }),
|
||||||
|
() => {
|
||||||
|
this.focus()
|
||||||
|
const newConfig = Object.assign({}, this.props.config)
|
||||||
|
newConfig.ui.isStacking = this.state.isStacking
|
||||||
|
ConfigManager.set(newConfig)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
handleSwitchDirection() {
|
handleSwitchDirection() {
|
||||||
if (!this.props.config.editor.rtlEnabled) {
|
if (!this.props.config.editor.rtlEnabled) {
|
||||||
return
|
return
|
||||||
@@ -429,7 +443,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
|
|
||||||
renderEditor() {
|
renderEditor() {
|
||||||
const { config, ignorePreviewPointerEvents } = this.props
|
const { config, ignorePreviewPointerEvents } = this.props
|
||||||
const { note } = this.state
|
const { note, isStacking } = this.state
|
||||||
|
|
||||||
if (this.state.editorType === 'EDITOR_PREVIEW') {
|
if (this.state.editorType === 'EDITOR_PREVIEW') {
|
||||||
return (
|
return (
|
||||||
@@ -455,6 +469,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
value={note.content}
|
value={note.content}
|
||||||
storageKey={note.storage}
|
storageKey={note.storage}
|
||||||
noteKey={note.key}
|
noteKey={note.key}
|
||||||
|
isStacking={isStacking}
|
||||||
linesHighlighted={note.linesHighlighted}
|
linesHighlighted={note.linesHighlighted}
|
||||||
onChange={this.handleUpdateContent}
|
onChange={this.handleUpdateContent}
|
||||||
ignorePreviewPointerEvents={ignorePreviewPointerEvents}
|
ignorePreviewPointerEvents={ignorePreviewPointerEvents}
|
||||||
@@ -479,10 +494,16 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const currentOption = options.filter(
|
|
||||||
|
const currentOption = _.find(
|
||||||
|
options,
|
||||||
option =>
|
option =>
|
||||||
option.storage.key === storageKey && option.folder.key === folderKey
|
option.storage.key === storageKey && option.folder.key === folderKey
|
||||||
)[0]
|
)
|
||||||
|
|
||||||
|
// currentOption may be undefined
|
||||||
|
const storageName = _.get(currentOption, 'storage.name') || ''
|
||||||
|
const folderName = _.get(currentOption, 'folder.name') || ''
|
||||||
|
|
||||||
const trashTopBar = (
|
const trashTopBar = (
|
||||||
<div styleName='info'>
|
<div styleName='info'>
|
||||||
@@ -495,8 +516,8 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
/>
|
/>
|
||||||
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
||||||
<InfoPanelTrashed
|
<InfoPanelTrashed
|
||||||
storageName={currentOption.storage.name}
|
storageName={storageName}
|
||||||
folderName={currentOption.folder.name}
|
folderName={folderName}
|
||||||
updatedAt={formatDate(note.updatedAt)}
|
updatedAt={formatDate(note.updatedAt)}
|
||||||
createdAt={formatDate(note.createdAt)}
|
createdAt={formatDate(note.createdAt)}
|
||||||
exportAsHtml={this.exportAsHtml}
|
exportAsHtml={this.exportAsHtml}
|
||||||
@@ -579,8 +600,8 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
||||||
|
|
||||||
<InfoPanel
|
<InfoPanel
|
||||||
storageName={currentOption.storage.name}
|
storageName={storageName}
|
||||||
folderName={currentOption.folder.name}
|
folderName={folderName}
|
||||||
noteLink={`[${note.title}](:note:${
|
noteLink={`[${note.title}](:note:${
|
||||||
queryString.parse(location.search).key
|
queryString.parse(location.search).key
|
||||||
})`}
|
})`}
|
||||||
|
|||||||
@@ -870,6 +870,8 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
enableSmartPaste={config.editor.enableSmartPaste}
|
enableSmartPaste={config.editor.enableSmartPaste}
|
||||||
hotkey={config.hotkey}
|
hotkey={config.hotkey}
|
||||||
autoDetect={autoDetect}
|
autoDetect={autoDetect}
|
||||||
|
storageKey={storageKey}
|
||||||
|
noteKey={note.key}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -885,10 +887,16 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const currentOption = options.filter(
|
|
||||||
|
const currentOption = _.find(
|
||||||
|
options,
|
||||||
option =>
|
option =>
|
||||||
option.storage.key === storageKey && option.folder.key === folderKey
|
option.storage.key === storageKey && option.folder.key === folderKey
|
||||||
)[0]
|
)
|
||||||
|
|
||||||
|
// currentOption may be undefined
|
||||||
|
const storageName = _.get(currentOption, 'storage.name') || ''
|
||||||
|
const folderName = _.get(currentOption, 'folder.name') || ''
|
||||||
|
|
||||||
const trashTopBar = (
|
const trashTopBar = (
|
||||||
<div styleName='info'>
|
<div styleName='info'>
|
||||||
@@ -901,8 +909,8 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
/>
|
/>
|
||||||
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
||||||
<InfoPanelTrashed
|
<InfoPanelTrashed
|
||||||
storageName={currentOption.storage.name}
|
storageName={storageName}
|
||||||
folderName={currentOption.folder.name}
|
folderName={folderName}
|
||||||
updatedAt={formatDate(note.updatedAt)}
|
updatedAt={formatDate(note.updatedAt)}
|
||||||
createdAt={formatDate(note.createdAt)}
|
createdAt={formatDate(note.createdAt)}
|
||||||
exportAsMd={this.showWarning}
|
exportAsMd={this.showWarning}
|
||||||
@@ -951,8 +959,8 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
<InfoButton onClick={e => this.handleInfoButtonClick(e)} />
|
||||||
|
|
||||||
<InfoPanel
|
<InfoPanel
|
||||||
storageName={currentOption.storage.name}
|
storageName={storageName}
|
||||||
folderName={currentOption.folder.name}
|
folderName={folderName}
|
||||||
noteLink={`[${note.title}](:note:${
|
noteLink={`[${note.title}](:note:${
|
||||||
queryString.parse(location.search).key
|
queryString.parse(location.search).key
|
||||||
})`}
|
})`}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class TagSelect extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.handleAddTag = this.handleAddTag.bind(this)
|
this.handleAddTag = this.handleAddTag.bind(this)
|
||||||
|
this.handleRenameTag = this.handleRenameTag.bind(this)
|
||||||
this.onInputBlur = this.onInputBlur.bind(this)
|
this.onInputBlur = this.onInputBlur.bind(this)
|
||||||
this.onInputChange = this.onInputChange.bind(this)
|
this.onInputChange = this.onInputChange.bind(this)
|
||||||
this.onInputKeyDown = this.onInputKeyDown.bind(this)
|
this.onInputKeyDown = this.onInputKeyDown.bind(this)
|
||||||
@@ -88,6 +89,7 @@ class TagSelect extends React.Component {
|
|||||||
this.buildSuggestions()
|
this.buildSuggestions()
|
||||||
|
|
||||||
ee.on('editor:add-tag', this.handleAddTag)
|
ee.on('editor:add-tag', this.handleAddTag)
|
||||||
|
ee.on('sidebar:rename-tag', this.handleRenameTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
@@ -96,12 +98,23 @@ class TagSelect extends React.Component {
|
|||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
ee.off('editor:add-tag', this.handleAddTag)
|
ee.off('editor:add-tag', this.handleAddTag)
|
||||||
|
ee.off('sidebar:rename-tag', this.handleRenameTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAddTag() {
|
handleAddTag() {
|
||||||
this.refs.newTag.input.focus()
|
this.refs.newTag.input.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleRenameTag(event, tagChange) {
|
||||||
|
const { value } = this.props
|
||||||
|
const { tag, updatedTag } = tagChange
|
||||||
|
const newTags = value.slice()
|
||||||
|
|
||||||
|
newTags[value.indexOf(tag)] = updatedTag
|
||||||
|
this.value = newTags
|
||||||
|
this.props.onChange()
|
||||||
|
}
|
||||||
|
|
||||||
handleTagLabelClick(tag) {
|
handleTagLabelClick(tag) {
|
||||||
const { dispatch } = this.props
|
const { dispatch } = this.props
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { store } from 'browser/main/store'
|
|||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
import { getLocales } from 'browser/lib/Languages'
|
import { getLocales } from 'browser/lib/Languages'
|
||||||
import applyShortcuts from 'browser/main/lib/shortcutManager'
|
import applyShortcuts from 'browser/main/lib/shortcutManager'
|
||||||
import uiThemes from 'browser/lib/ui-themes'
|
import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager'
|
||||||
import { push } from 'connected-react-router'
|
import { push } from 'connected-react-router'
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
@@ -148,11 +148,13 @@ class Main extends React.Component {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { dispatch, config } = this.props
|
const { dispatch, config } = this.props
|
||||||
|
|
||||||
if (uiThemes.some(theme => theme.name === config.ui.theme)) {
|
this.refreshTheme = setInterval(() => {
|
||||||
document.body.setAttribute('data-theme', config.ui.theme)
|
const conf = ConfigManager.get()
|
||||||
} else {
|
chooseTheme(conf)
|
||||||
document.body.setAttribute('data-theme', 'default')
|
}, 5 * 1000)
|
||||||
}
|
|
||||||
|
chooseTheme(config)
|
||||||
|
applyTheme(config.ui.theme)
|
||||||
|
|
||||||
if (getLocales().indexOf(config.ui.language) !== -1) {
|
if (getLocales().indexOf(config.ui.language) !== -1) {
|
||||||
i18n.setLocale(config.ui.language)
|
i18n.setLocale(config.ui.language)
|
||||||
@@ -181,6 +183,7 @@ class Main extends React.Component {
|
|||||||
'menubar:togglemenubar',
|
'menubar:togglemenubar',
|
||||||
this.toggleMenuBarVisible.bind(this)
|
this.toggleMenuBarVisible.bind(this)
|
||||||
)
|
)
|
||||||
|
eventEmitter.on('dispatch:push', this.changeRoutePush.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@@ -189,6 +192,13 @@ class Main extends React.Component {
|
|||||||
'menubar:togglemenubar',
|
'menubar:togglemenubar',
|
||||||
this.toggleMenuBarVisible.bind(this)
|
this.toggleMenuBarVisible.bind(this)
|
||||||
)
|
)
|
||||||
|
eventEmitter.off('dispatch:push', this.changeRoutePush.bind(this))
|
||||||
|
clearInterval(this.refreshTheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
changeRoutePush(event, destination) {
|
||||||
|
const { dispatch } = this.props
|
||||||
|
dispatch(push(destination))
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleMenuBarVisible() {
|
toggleMenuBarVisible() {
|
||||||
|
|||||||
@@ -1107,10 +1107,10 @@ class NoteList extends React.Component {
|
|||||||
|
|
||||||
getNoteFolder(note) {
|
getNoteFolder(note) {
|
||||||
// note.folder = folder key
|
// note.folder = folder key
|
||||||
return _.find(
|
const storage = this.getNoteStorage(note)
|
||||||
this.getNoteStorage(note).folders,
|
return storage
|
||||||
({ key }) => key === note.folder
|
? _.find(storage.folders, ({ key }) => key === note.folder)
|
||||||
)
|
: []
|
||||||
}
|
}
|
||||||
|
|
||||||
getViewType() {
|
getViewType() {
|
||||||
@@ -1145,9 +1145,14 @@ class NoteList extends React.Component {
|
|||||||
? this.getNotes().sort(sortFunc)
|
? this.getNotes().sort(sortFunc)
|
||||||
: this.sortByPin(this.getNotes().sort(sortFunc))
|
: this.sortByPin(this.getNotes().sort(sortFunc))
|
||||||
this.notes = notes = sortedNotes.filter(note => {
|
this.notes = notes = sortedNotes.filter(note => {
|
||||||
// this is for the trash box
|
if (
|
||||||
if (note.isTrashed !== true || location.pathname === '/trashed')
|
// has matching storage
|
||||||
|
!!this.getNoteStorage(note) &&
|
||||||
|
// this is for the trash box
|
||||||
|
(note.isTrashed !== true || location.pathname === '/trashed')
|
||||||
|
) {
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (sortDir === 'DESCENDING') this.notes.reverse()
|
if (sortDir === 'DESCENDING') this.notes.reverse()
|
||||||
|
|
||||||
@@ -1193,6 +1198,8 @@ class NoteList extends React.Component {
|
|||||||
sortBy === 'CREATED_AT' ? note.createdAt : note.updatedAt
|
sortBy === 'CREATED_AT' ? note.createdAt : note.updatedAt
|
||||||
).fromNow('D')
|
).fromNow('D')
|
||||||
|
|
||||||
|
const storage = this.getNoteStorage(note)
|
||||||
|
|
||||||
if (isDefault) {
|
if (isDefault) {
|
||||||
return (
|
return (
|
||||||
<NoteItem
|
<NoteItem
|
||||||
@@ -1205,7 +1212,7 @@ class NoteList extends React.Component {
|
|||||||
handleDragStart={this.handleDragStart.bind(this)}
|
handleDragStart={this.handleDragStart.bind(this)}
|
||||||
pathname={location.pathname}
|
pathname={location.pathname}
|
||||||
folderName={this.getNoteFolder(note).name}
|
folderName={this.getNoteFolder(note).name}
|
||||||
storageName={this.getNoteStorage(note).name}
|
storageName={storage.name}
|
||||||
viewType={viewType}
|
viewType={viewType}
|
||||||
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
||||||
coloredTags={config.coloredTags}
|
coloredTags={config.coloredTags}
|
||||||
@@ -1223,7 +1230,7 @@ class NoteList extends React.Component {
|
|||||||
handleDragStart={this.handleDragStart.bind(this)}
|
handleDragStart={this.handleDragStart.bind(this)}
|
||||||
pathname={location.pathname}
|
pathname={location.pathname}
|
||||||
folderName={this.getNoteFolder(note).name}
|
folderName={this.getNoteFolder(note).name}
|
||||||
storageName={this.getNoteStorage(note).name}
|
storageName={storage.name}
|
||||||
viewType={viewType}
|
viewType={viewType}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import dataApi from 'browser/main/lib/dataApi'
|
|||||||
import styles from './SideNav.styl'
|
import styles from './SideNav.styl'
|
||||||
import { openModal } from 'browser/main/lib/modal'
|
import { openModal } from 'browser/main/lib/modal'
|
||||||
import PreferencesModal from '../modals/PreferencesModal'
|
import PreferencesModal from '../modals/PreferencesModal'
|
||||||
|
import RenameTagModal from 'browser/main/modals/RenameTagModal'
|
||||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
import StorageItem from './StorageItem'
|
import StorageItem from './StorageItem'
|
||||||
import TagListItem from 'browser/components/TagListItem'
|
import TagListItem from 'browser/components/TagListItem'
|
||||||
@@ -170,6 +171,11 @@ class SideNav extends React.Component {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
menu.push({
|
||||||
|
label: i18n.__('Rename Tag'),
|
||||||
|
click: this.handleRenameTagClick.bind(this, tag)
|
||||||
|
})
|
||||||
|
|
||||||
context.popup(menu)
|
context.popup(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +199,16 @@ class SideNav extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleRenameTagClick(tagName) {
|
||||||
|
const { data, dispatch } = this.props
|
||||||
|
|
||||||
|
openModal(RenameTagModal, {
|
||||||
|
tagName,
|
||||||
|
data,
|
||||||
|
dispatch
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
handleColorPickerConfirm(color) {
|
handleColorPickerConfirm(color) {
|
||||||
const {
|
const {
|
||||||
dispatch,
|
dispatch,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import _ from 'lodash'
|
|||||||
import RcParser from 'browser/lib/RcParser'
|
import RcParser from 'browser/lib/RcParser'
|
||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
import ee from 'browser/main/lib/eventEmitter'
|
import ee from 'browser/main/lib/eventEmitter'
|
||||||
import uiThemes from 'browser/lib/ui-themes'
|
|
||||||
|
|
||||||
const OSX = global.process.platform === 'darwin'
|
const OSX = global.process.platform === 'darwin'
|
||||||
const win = global.process.platform === 'win32'
|
const win = global.process.platform === 'win32'
|
||||||
@@ -17,6 +16,22 @@ const DEFAULT_MARKDOWN_LINT_CONFIG = `{
|
|||||||
"default": true
|
"default": true
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
const DEFAULT_CSS_CONFIG = `
|
||||||
|
/* Drop Your Custom CSS Code Here */
|
||||||
|
[data-theme="default"] p code,
|
||||||
|
[data-theme="default"] li code,
|
||||||
|
[data-theme="default"] td code
|
||||||
|
{
|
||||||
|
padding: 2px;
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #F4F4F4;
|
||||||
|
border-color: #d9d9d9;
|
||||||
|
color: #03C588;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export const DEFAULT_CONFIG = {
|
export const DEFAULT_CONFIG = {
|
||||||
zoom: 1,
|
zoom: 1,
|
||||||
isSideNavFolded: false,
|
isSideNavFolded: false,
|
||||||
@@ -47,11 +62,17 @@ export const DEFAULT_CONFIG = {
|
|||||||
ui: {
|
ui: {
|
||||||
language: 'en',
|
language: 'en',
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
|
defaultTheme: 'default',
|
||||||
|
enableScheduleTheme: false,
|
||||||
|
scheduledTheme: 'monokai',
|
||||||
|
scheduleStart: 1200,
|
||||||
|
scheduleEnd: 360,
|
||||||
showCopyNotification: true,
|
showCopyNotification: true,
|
||||||
disableDirectWrite: false,
|
disableDirectWrite: false,
|
||||||
showScrollBar: true,
|
showScrollBar: true,
|
||||||
defaultNote: 'ALWAYS_ASK', // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
|
defaultNote: 'ALWAYS_ASK', // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
|
||||||
showMenuBar: false
|
showMenuBar: false,
|
||||||
|
isStacking: false
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
theme: 'base16-light',
|
theme: 'base16-light',
|
||||||
@@ -79,7 +100,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
enableSmartPaste: false,
|
enableSmartPaste: false,
|
||||||
enableMarkdownLint: false,
|
enableMarkdownLint: false,
|
||||||
customMarkdownLintConfig: DEFAULT_MARKDOWN_LINT_CONFIG,
|
customMarkdownLintConfig: DEFAULT_MARKDOWN_LINT_CONFIG,
|
||||||
prettierConfig: ` {
|
prettierConfig: `{
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"semi": false,
|
"semi": false,
|
||||||
@@ -104,8 +125,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
breaks: true,
|
breaks: true,
|
||||||
smartArrows: false,
|
smartArrows: false,
|
||||||
allowCustomCSS: false,
|
allowCustomCSS: false,
|
||||||
|
customCSS: DEFAULT_CSS_CONFIG,
|
||||||
customCSS: '/* Drop Your Custom CSS Code Here */',
|
|
||||||
sanitize: 'STRICT', // 'STRICT', 'ALLOW_STYLES', 'NONE'
|
sanitize: 'STRICT', // 'STRICT', 'ALLOW_STYLES', 'NONE'
|
||||||
mermaidHTMLLabel: false,
|
mermaidHTMLLabel: false,
|
||||||
lineThroughCheckbox: true
|
lineThroughCheckbox: true
|
||||||
@@ -118,7 +138,10 @@ export const DEFAULT_CONFIG = {
|
|||||||
username: '',
|
username: '',
|
||||||
password: ''
|
password: ''
|
||||||
},
|
},
|
||||||
coloredTags: {}
|
coloredTags: {},
|
||||||
|
wakatime: {
|
||||||
|
key: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate(config) {
|
function validate(config) {
|
||||||
@@ -200,12 +223,6 @@ function set(updates) {
|
|||||||
if (!validate(newConfig)) throw new Error('INVALID CONFIG')
|
if (!validate(newConfig)) throw new Error('INVALID CONFIG')
|
||||||
_save(newConfig)
|
_save(newConfig)
|
||||||
|
|
||||||
if (uiThemes.some(theme => theme.name === newConfig.ui.theme)) {
|
|
||||||
document.body.setAttribute('data-theme', newConfig.ui.theme)
|
|
||||||
} else {
|
|
||||||
document.body.setAttribute('data-theme', 'default')
|
|
||||||
}
|
|
||||||
|
|
||||||
i18n.setLocale(newConfig.ui.language)
|
i18n.setLocale(newConfig.ui.language)
|
||||||
|
|
||||||
let editorTheme = document.getElementById('editorTheme')
|
let editorTheme = document.getElementById('editorTheme')
|
||||||
@@ -240,6 +257,12 @@ function assignConfigValues(originalConfig, rcConfig) {
|
|||||||
originalConfig.hotkey,
|
originalConfig.hotkey,
|
||||||
rcConfig.hotkey
|
rcConfig.hotkey
|
||||||
)
|
)
|
||||||
|
config.wakatime = Object.assign(
|
||||||
|
{},
|
||||||
|
DEFAULT_CONFIG.wakatime,
|
||||||
|
originalConfig.wakatime,
|
||||||
|
rcConfig.wakatime
|
||||||
|
)
|
||||||
config.blog = Object.assign(
|
config.blog = Object.assign(
|
||||||
{},
|
{},
|
||||||
DEFAULT_CONFIG.blog,
|
DEFAULT_CONFIG.blog,
|
||||||
|
|||||||
59
browser/main/lib/ThemeManager.js
Normal file
59
browser/main/lib/ThemeManager.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
|
import uiThemes from 'browser/lib/ui-themes'
|
||||||
|
|
||||||
|
const saveChanges = newConfig => {
|
||||||
|
ConfigManager.set(newConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
const chooseTheme = config => {
|
||||||
|
const { ui } = config
|
||||||
|
if (!ui.enableScheduleTheme) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const start = parseInt(ui.scheduleStart)
|
||||||
|
const end = parseInt(ui.scheduleEnd)
|
||||||
|
|
||||||
|
const now = new Date()
|
||||||
|
const minutes = now.getHours() * 60 + now.getMinutes()
|
||||||
|
|
||||||
|
const isEndAfterStart = end > start
|
||||||
|
const isBetweenStartAndEnd = minutes >= start && minutes < end
|
||||||
|
const isBetweenEndAndStart = minutes >= start || minutes < end
|
||||||
|
|
||||||
|
if (
|
||||||
|
(isEndAfterStart && isBetweenStartAndEnd) ||
|
||||||
|
(!isEndAfterStart && isBetweenEndAndStart)
|
||||||
|
) {
|
||||||
|
if (ui.theme !== ui.scheduledTheme) {
|
||||||
|
ui.defaultTheme = ui.theme
|
||||||
|
ui.theme = ui.scheduledTheme
|
||||||
|
applyTheme(ui.theme)
|
||||||
|
saveChanges(config)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ui.theme !== ui.defaultTheme) {
|
||||||
|
ui.theme = ui.defaultTheme
|
||||||
|
applyTheme(ui.theme)
|
||||||
|
saveChanges(config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const applyTheme = theme => {
|
||||||
|
if (uiThemes.some(item => item.name === theme)) {
|
||||||
|
document.body.setAttribute('data-theme', theme)
|
||||||
|
if (document.body.querySelector('.MarkdownPreview')) {
|
||||||
|
document.body
|
||||||
|
.querySelector('.MarkdownPreview')
|
||||||
|
.contentDocument.body.setAttribute('data-theme', theme)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
document.body.setAttribute('data-theme', 'default')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
chooseTheme,
|
||||||
|
applyTheme
|
||||||
|
}
|
||||||
@@ -713,24 +713,30 @@ function replaceNoteKeyWithNewNoteKey(noteContent, oldNoteKey, newNoteKey) {
|
|||||||
*/
|
*/
|
||||||
function removeStorageAndNoteReferences(input, noteKey) {
|
function removeStorageAndNoteReferences(input, noteKey) {
|
||||||
return input.replace(
|
return input.replace(
|
||||||
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|])', 'g'),
|
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|\\))', 'g'),
|
||||||
function(match) {
|
function(match) {
|
||||||
const temp = match
|
return match
|
||||||
.replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep)
|
.replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.posix.sep)
|
||||||
.replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.sep)
|
.replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.posix.sep)
|
||||||
.replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.sep)
|
.replace(
|
||||||
.replace(new RegExp(escapeStringRegexp(path.posix.sep), 'g'), path.sep)
|
new RegExp(escapeStringRegexp(path.win32.sep), 'g'),
|
||||||
return temp.replace(
|
path.posix.sep
|
||||||
new RegExp(
|
)
|
||||||
STORAGE_FOLDER_PLACEHOLDER +
|
.replace(
|
||||||
'(' +
|
new RegExp(escapeStringRegexp(path.posix.sep), 'g'),
|
||||||
escapeStringRegexp(path.sep) +
|
path.posix.sep
|
||||||
noteKey +
|
)
|
||||||
')?',
|
.replace(
|
||||||
'g'
|
new RegExp(
|
||||||
),
|
STORAGE_FOLDER_PLACEHOLDER +
|
||||||
DESTINATION_FOLDER
|
'(' +
|
||||||
)
|
escapeStringRegexp(path.sep) +
|
||||||
|
noteKey +
|
||||||
|
')?',
|
||||||
|
'g'
|
||||||
|
),
|
||||||
|
DESTINATION_FOLDER
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -835,7 +841,15 @@ function getAttachmentsPathAndStatus(markdownContent, storageKey, noteKey) {
|
|||||||
if (storageKey == null || noteKey == null || markdownContent == null) {
|
if (storageKey == null || noteKey == null || markdownContent == null) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const targetStorage = findStorage.findStorage(storageKey)
|
let targetStorage = null
|
||||||
|
try {
|
||||||
|
targetStorage = findStorage.findStorage(storageKey)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`No stroage found for: ${storageKey}`)
|
||||||
|
}
|
||||||
|
if (!targetStorage) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
const attachmentFolder = path.join(
|
const attachmentFolder = path.join(
|
||||||
targetStorage.path,
|
targetStorage.path,
|
||||||
DESTINATION_FOLDER,
|
DESTINATION_FOLDER,
|
||||||
|
|||||||
@@ -1,5 +1,109 @@
|
|||||||
@import('./Tab')
|
@import('./Tab')
|
||||||
|
|
||||||
|
.container
|
||||||
|
display flex
|
||||||
|
flex-direction column
|
||||||
|
align-items center
|
||||||
|
justify-content center
|
||||||
|
position relative
|
||||||
|
margin-bottom 2em
|
||||||
|
margin-left 2em
|
||||||
|
|
||||||
|
.box-minmax
|
||||||
|
width 608px
|
||||||
|
height 45px
|
||||||
|
display flex
|
||||||
|
justify-content space-between
|
||||||
|
font-size $tab--button-font-size
|
||||||
|
color $ui-text-color
|
||||||
|
span first-child
|
||||||
|
margin-top 18px
|
||||||
|
padding-right 10px
|
||||||
|
padding-left 10px
|
||||||
|
padding-top 8px
|
||||||
|
position relative
|
||||||
|
border $ui-borderColor
|
||||||
|
border-radius 5px
|
||||||
|
background $ui-backgroundColor
|
||||||
|
|
||||||
|
div[id^="secondRow"]
|
||||||
|
position absolute
|
||||||
|
z-index 2
|
||||||
|
left 0
|
||||||
|
top 0
|
||||||
|
margin-bottom -42px
|
||||||
|
.rs-label
|
||||||
|
margin-left -20px
|
||||||
|
|
||||||
|
div[id^="firstRow"]
|
||||||
|
position absolute
|
||||||
|
z-index 2
|
||||||
|
left 0
|
||||||
|
top 0
|
||||||
|
margin-bottom -25px
|
||||||
|
.rs-range
|
||||||
|
&::-webkit-slider-thumb
|
||||||
|
margin-top 0px
|
||||||
|
transform rotate(180deg)
|
||||||
|
.rs-label
|
||||||
|
margin-bottom -85px
|
||||||
|
margin-top 85px
|
||||||
|
|
||||||
|
|
||||||
|
.rs-range
|
||||||
|
margin-top 29px
|
||||||
|
width 600px
|
||||||
|
-webkit-appearance none
|
||||||
|
&:focus
|
||||||
|
outline black
|
||||||
|
&::-webkit-slider-runnable-track
|
||||||
|
width 100%
|
||||||
|
height 0.1px
|
||||||
|
cursor pointer
|
||||||
|
box-shadow none
|
||||||
|
background $ui-backgroundColor
|
||||||
|
border-radius 0px
|
||||||
|
border 0px solid #010101
|
||||||
|
cursor none
|
||||||
|
|
||||||
|
&::-webkit-slider-thumb
|
||||||
|
box-shadow none
|
||||||
|
border 1px solid $ui-borderColor
|
||||||
|
box-shadow 0px 10px 10px rgba(0, 0, 0, 0.25)
|
||||||
|
height 32px
|
||||||
|
width 32px
|
||||||
|
border-radius 22px
|
||||||
|
background white
|
||||||
|
cursor pointer
|
||||||
|
-webkit-appearance none
|
||||||
|
margin-top -20px
|
||||||
|
border-color $ui-default-button-backgroundColor
|
||||||
|
height 32px
|
||||||
|
border-top-left-radius 10%
|
||||||
|
border-top-right-radius 10%
|
||||||
|
|
||||||
|
.rs-label
|
||||||
|
position relative
|
||||||
|
transform-origin center center
|
||||||
|
display block
|
||||||
|
background transparent
|
||||||
|
border-radius none
|
||||||
|
line-height 30px
|
||||||
|
font-weight normal
|
||||||
|
box-sizing border-box
|
||||||
|
border none
|
||||||
|
margin-bottom -5px
|
||||||
|
margin-top -10px
|
||||||
|
clear both
|
||||||
|
float left
|
||||||
|
height 17px
|
||||||
|
margin-left -25px
|
||||||
|
left attr(value)
|
||||||
|
color $ui-text-color
|
||||||
|
font-style normal
|
||||||
|
font-weight normal
|
||||||
|
line-height normal
|
||||||
|
font-size $tab--button-font-size
|
||||||
.root
|
.root
|
||||||
padding 15px
|
padding 15px
|
||||||
margin-bottom 30px
|
margin-bottom 30px
|
||||||
@@ -175,6 +279,9 @@ body[data-theme="dark"]
|
|||||||
.group-section-control
|
.group-section-control
|
||||||
select, .group-section-control-input
|
select, .group-section-control-input
|
||||||
colorDarkControl()
|
colorDarkControl()
|
||||||
|
.rs-label
|
||||||
|
color $ui-dark-text-color
|
||||||
|
|
||||||
|
|
||||||
apply-theme(theme)
|
apply-theme(theme)
|
||||||
body[data-theme={theme}]
|
body[data-theme={theme}]
|
||||||
@@ -205,6 +312,8 @@ apply-theme(theme)
|
|||||||
.group-section-control
|
.group-section-control
|
||||||
select, .group-section-control-input
|
select, .group-section-control-input
|
||||||
colorThemedControl(theme)
|
colorThemedControl(theme)
|
||||||
|
.rs-label
|
||||||
|
color get-theme-var(theme, 'text-color')
|
||||||
|
|
||||||
for theme in 'solarized-dark' 'dracula'
|
for theme in 'solarized-dark' 'dracula'
|
||||||
apply-theme(theme)
|
apply-theme(theme)
|
||||||
|
|||||||
@@ -145,9 +145,7 @@ class InfoTab extends React.Component {
|
|||||||
height='92'
|
height='92'
|
||||||
/>
|
/>
|
||||||
<div styleName='icon-right'>
|
<div styleName='icon-right'>
|
||||||
<div styleName='appId'>
|
<div styleName='appId'>Boostnote Legacy {appVersion}</div>
|
||||||
{i18n.__('Boostnote')} {appVersion}
|
|
||||||
</div>
|
|
||||||
<div styleName='description'>
|
<div styleName='description'>
|
||||||
{i18n.__(
|
{i18n.__(
|
||||||
'An open source note-taking app made for programmers just like you.'
|
'An open source note-taking app made for programmers just like you.'
|
||||||
|
|||||||
207
browser/main/modals/PreferencesModal/PluginsTab.js
Normal file
207
browser/main/modals/PreferencesModal/PluginsTab.js
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import React from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './ConfigTab.styl'
|
||||||
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
|
import { store } from 'browser/main/store'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import i18n from 'browser/lib/i18n'
|
||||||
|
import { sync as commandExists } from 'command-exists'
|
||||||
|
const electron = require('electron')
|
||||||
|
const ipc = electron.ipcRenderer
|
||||||
|
const { remote } = electron
|
||||||
|
const { dialog } = remote
|
||||||
|
class PluginsTab extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
config: props.config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.handleSettingDone = () => {
|
||||||
|
this.setState({
|
||||||
|
pluginsAlert: {
|
||||||
|
type: 'success',
|
||||||
|
message: i18n.__('Successfully applied!')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.handleSettingError = err => {
|
||||||
|
this.setState({
|
||||||
|
pluginsAlert: {
|
||||||
|
type: 'error',
|
||||||
|
message:
|
||||||
|
err.message != null ? err.message : i18n.__('An error occurred!')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.oldWakatimeConfig = this.state.config.wakatime
|
||||||
|
ipc.addListener('APP_SETTING_DONE', this.handleSettingDone)
|
||||||
|
ipc.addListener('APP_SETTING_ERROR', this.handleSettingError)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
ipc.removeListener('APP_SETTING_DONE', this.handleSettingDone)
|
||||||
|
ipc.removeListener('APP_SETTING_ERROR', this.handleSettingError)
|
||||||
|
}
|
||||||
|
|
||||||
|
checkWakatimePluginRequirement() {
|
||||||
|
const { wakatime } = this.state.config
|
||||||
|
if (wakatime.isActive && !commandExists('wakatime')) {
|
||||||
|
this.setState({
|
||||||
|
wakatimePluginAlert: {
|
||||||
|
type: i18n.__('Warning'),
|
||||||
|
message: i18n.__('Missing wakatime cli')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const alertConfig = {
|
||||||
|
type: 'warning',
|
||||||
|
message: i18n.__('Missing Wakatime CLI'),
|
||||||
|
detail: i18n.__(
|
||||||
|
`Please install Wakatime CLI to use Wakatime tracker feature.`
|
||||||
|
),
|
||||||
|
buttons: [i18n.__('OK')]
|
||||||
|
}
|
||||||
|
dialog.showMessageBox(remote.getCurrentWindow(), alertConfig)
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
wakatimePluginAlert: null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSaveButtonClick(e) {
|
||||||
|
const newConfig = {
|
||||||
|
wakatime: {
|
||||||
|
isActive: this.state.config.wakatime.isActive,
|
||||||
|
key: this.state.config.wakatime.key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigManager.set(newConfig)
|
||||||
|
|
||||||
|
store.dispatch({
|
||||||
|
type: 'SET_CONFIG',
|
||||||
|
config: newConfig
|
||||||
|
})
|
||||||
|
this.clearMessage()
|
||||||
|
this.props.haveToSave()
|
||||||
|
this.checkWakatimePluginRequirement()
|
||||||
|
}
|
||||||
|
|
||||||
|
handleIsWakatimePluginActiveChange(e) {
|
||||||
|
const { config } = this.state
|
||||||
|
config.wakatime.isActive = !config.wakatime.isActive
|
||||||
|
this.setState({
|
||||||
|
config
|
||||||
|
})
|
||||||
|
if (_.isEqual(this.oldWakatimeConfig.isActive, config.wakatime.isActive)) {
|
||||||
|
this.props.haveToSave()
|
||||||
|
} else {
|
||||||
|
this.props.haveToSave({
|
||||||
|
tab: 'Plugins',
|
||||||
|
type: 'warning',
|
||||||
|
message: i18n.__('Unsaved Changes!')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleWakatimeKeyChange(e) {
|
||||||
|
const { config } = this.state
|
||||||
|
config.wakatime = {
|
||||||
|
isActive: true,
|
||||||
|
key: this.refs.wakatimeKey.value
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
config
|
||||||
|
})
|
||||||
|
if (_.isEqual(this.oldWakatimeConfig.key, config.wakatime.key)) {
|
||||||
|
this.props.haveToSave()
|
||||||
|
} else {
|
||||||
|
this.props.haveToSave({
|
||||||
|
tab: 'Plugins',
|
||||||
|
type: 'warning',
|
||||||
|
message: i18n.__('Unsaved Changes!')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearMessage() {
|
||||||
|
_.debounce(() => {
|
||||||
|
this.setState({
|
||||||
|
pluginsAlert: null
|
||||||
|
})
|
||||||
|
}, 2000)()
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const pluginsAlert = this.state.pluginsAlert
|
||||||
|
const pluginsAlertElement =
|
||||||
|
pluginsAlert != null ? (
|
||||||
|
<p className={`alert ${pluginsAlert.type}`}>{pluginsAlert.message}</p>
|
||||||
|
) : null
|
||||||
|
|
||||||
|
const wakatimeAlert = this.state.wakatimePluginAlert
|
||||||
|
const wakatimePluginAlertElement =
|
||||||
|
wakatimeAlert != null ? (
|
||||||
|
<p className={`alert ${wakatimeAlert.type}`}>{wakatimeAlert.message}</p>
|
||||||
|
) : null
|
||||||
|
|
||||||
|
const { config } = this.state
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div styleName='root'>
|
||||||
|
<div styleName='group'>
|
||||||
|
<div styleName='group-header'>{i18n.__('Plugins')}</div>
|
||||||
|
<div styleName='group-header2'>{i18n.__('Wakatime')}</div>
|
||||||
|
<div styleName='group-checkBoxSection'>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
onChange={e => this.handleIsWakatimePluginActiveChange(e)}
|
||||||
|
checked={config.wakatime.isActive}
|
||||||
|
ref='wakatimeIsActive'
|
||||||
|
type='checkbox'
|
||||||
|
/>
|
||||||
|
|
||||||
|
{i18n.__('Enable Wakatime')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>{i18n.__('Wakatime key')}</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
<input
|
||||||
|
styleName='group-section-control-input'
|
||||||
|
onChange={e => this.handleWakatimeKeyChange(e)}
|
||||||
|
disabled={!config.wakatime.isActive}
|
||||||
|
ref='wakatimeKey'
|
||||||
|
value={config.wakatime.key}
|
||||||
|
type='text'
|
||||||
|
/>
|
||||||
|
{wakatimePluginAlertElement}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-control'>
|
||||||
|
<button
|
||||||
|
styleName='group-control-rightButton'
|
||||||
|
onClick={e => this.handleSaveButtonClick(e)}
|
||||||
|
>
|
||||||
|
{i18n.__('Save')}
|
||||||
|
</button>
|
||||||
|
{pluginsAlertElement}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginsTab.propTypes = {
|
||||||
|
dispatch: PropTypes.func,
|
||||||
|
haveToSave: PropTypes.func
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(PluginsTab, styles)
|
||||||
@@ -13,6 +13,7 @@ import i18n from 'browser/lib/i18n'
|
|||||||
import { getLanguages } from 'browser/lib/Languages'
|
import { getLanguages } from 'browser/lib/Languages'
|
||||||
import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily'
|
import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily'
|
||||||
import uiThemes from 'browser/lib/ui-themes'
|
import uiThemes from 'browser/lib/ui-themes'
|
||||||
|
import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager'
|
||||||
|
|
||||||
const OSX = global.process.platform === 'darwin'
|
const OSX = global.process.platform === 'darwin'
|
||||||
|
|
||||||
@@ -84,6 +85,11 @@ class UiTab extends React.Component {
|
|||||||
const newConfig = {
|
const newConfig = {
|
||||||
ui: {
|
ui: {
|
||||||
theme: this.refs.uiTheme.value,
|
theme: this.refs.uiTheme.value,
|
||||||
|
defaultTheme: this.refs.uiTheme.value,
|
||||||
|
enableScheduleTheme: this.refs.enableScheduleTheme.checked,
|
||||||
|
scheduledTheme: this.refs.uiScheduledTheme.value,
|
||||||
|
scheduleStart: this.refs.scheduleStart.value,
|
||||||
|
scheduleEnd: this.refs.scheduleEnd.value,
|
||||||
language: this.refs.uiLanguage.value,
|
language: this.refs.uiLanguage.value,
|
||||||
defaultNote: this.refs.defaultNote.value,
|
defaultNote: this.refs.defaultNote.value,
|
||||||
tagNewNoteWithFilteringTags: this.refs.tagNewNoteWithFilteringTags
|
tagNewNoteWithFilteringTags: this.refs.tagNewNoteWithFilteringTags
|
||||||
@@ -190,6 +196,9 @@ class UiTab extends React.Component {
|
|||||||
preview: this.state.config.preview
|
preview: this.state.config.preview
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chooseTheme(newConfig)
|
||||||
|
applyTheme(newConfig.ui.theme)
|
||||||
|
|
||||||
ConfigManager.set(newConfig)
|
ConfigManager.set(newConfig)
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
@@ -208,6 +217,21 @@ class UiTab extends React.Component {
|
|||||||
}, 2000)()
|
}, 2000)()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formatTime(time) {
|
||||||
|
let hour = Math.floor(time / 60)
|
||||||
|
let minute = time % 60
|
||||||
|
|
||||||
|
if (hour < 10) {
|
||||||
|
hour = '0' + hour
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minute < 10) {
|
||||||
|
minute = '0' + minute
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${hour}:${minute}`
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const UiAlert = this.state.UiAlert
|
const UiAlert = this.state.UiAlert
|
||||||
const UiAlertElement =
|
const UiAlertElement =
|
||||||
@@ -232,7 +256,7 @@ class UiTab extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
<div styleName='group-section-control'>
|
<div styleName='group-section-control'>
|
||||||
<select
|
<select
|
||||||
value={config.ui.theme}
|
value={config.ui.defaultTheme}
|
||||||
onChange={e => this.handleUIChange(e)}
|
onChange={e => this.handleUIChange(e)}
|
||||||
ref='uiTheme'
|
ref='uiTheme'
|
||||||
>
|
>
|
||||||
@@ -263,6 +287,101 @@ class UiTab extends React.Component {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div styleName='group-header2'>{i18n.__('Theme Schedule')}</div>
|
||||||
|
<div styleName='group-checkBoxSection'>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
onChange={e => this.handleUIChange(e)}
|
||||||
|
checked={config.ui.enableScheduleTheme}
|
||||||
|
ref='enableScheduleTheme'
|
||||||
|
type='checkbox'
|
||||||
|
/>
|
||||||
|
|
||||||
|
{i18n.__('Enable Scheduled Themes')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
{i18n.__('Scheduled Theme')}
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
<select
|
||||||
|
disabled={!config.ui.enableScheduleTheme}
|
||||||
|
value={config.ui.scheduledTheme}
|
||||||
|
onChange={e => this.handleUIChange(e)}
|
||||||
|
ref='uiScheduledTheme'
|
||||||
|
>
|
||||||
|
<optgroup label='Light Themes'>
|
||||||
|
{uiThemes
|
||||||
|
.filter(theme => !theme.isDark)
|
||||||
|
.sort((a, b) => a.label.localeCompare(b.label))
|
||||||
|
.map(theme => {
|
||||||
|
return (
|
||||||
|
<option value={theme.name} key={theme.name}>
|
||||||
|
{theme.label}
|
||||||
|
</option>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</optgroup>
|
||||||
|
<optgroup label='Dark Themes'>
|
||||||
|
{uiThemes
|
||||||
|
.filter(theme => theme.isDark)
|
||||||
|
.sort((a, b) => a.label.localeCompare(b.label))
|
||||||
|
.map(theme => {
|
||||||
|
return (
|
||||||
|
<option value={theme.name} key={theme.name}>
|
||||||
|
{theme.label}
|
||||||
|
</option>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</optgroup>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='container'>
|
||||||
|
<div id='firstRow'>
|
||||||
|
<span
|
||||||
|
id='rs-bullet-1'
|
||||||
|
styleName='rs-label'
|
||||||
|
>{`End: ${this.formatTime(config.ui.scheduleEnd)}`}</span>
|
||||||
|
<input
|
||||||
|
disabled={!config.ui.enableScheduleTheme}
|
||||||
|
id='rs-range-line-1'
|
||||||
|
styleName='rs-range'
|
||||||
|
type='range'
|
||||||
|
value={config.ui.scheduleEnd}
|
||||||
|
min='0'
|
||||||
|
max='1440'
|
||||||
|
step='5'
|
||||||
|
ref='scheduleEnd'
|
||||||
|
onChange={e => this.handleUIChange(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div id='secondRow'>
|
||||||
|
<span
|
||||||
|
id='rs-bullet-2'
|
||||||
|
styleName='rs-label'
|
||||||
|
>{`Start: ${this.formatTime(config.ui.scheduleStart)}`}</span>
|
||||||
|
<input
|
||||||
|
disabled={!config.ui.enableScheduleTheme}
|
||||||
|
id='rs-range-line-2'
|
||||||
|
styleName='rs-range'
|
||||||
|
type='range'
|
||||||
|
value={config.ui.scheduleStart}
|
||||||
|
min='0'
|
||||||
|
max='1440'
|
||||||
|
step='5'
|
||||||
|
ref='scheduleStart'
|
||||||
|
onChange={e => this.handleUIChange(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div styleName='box-minmax'>
|
||||||
|
<span>00:00</span>
|
||||||
|
<span>24:00</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div styleName='group-section'>
|
<div styleName='group-section'>
|
||||||
<div styleName='group-section-label'>{i18n.__('Language')}</div>
|
<div styleName='group-section-label'>{i18n.__('Language')}</div>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import InfoTab from './InfoTab'
|
|||||||
import Crowdfunding from './Crowdfunding'
|
import Crowdfunding from './Crowdfunding'
|
||||||
import StoragesTab from './StoragesTab'
|
import StoragesTab from './StoragesTab'
|
||||||
import SnippetTab from './SnippetTab'
|
import SnippetTab from './SnippetTab'
|
||||||
|
import PluginsTab from './PluginsTab'
|
||||||
import Blog from './Blog'
|
import Blog from './Blog'
|
||||||
import ModalEscButton from 'browser/components/ModalEscButton'
|
import ModalEscButton from 'browser/components/ModalEscButton'
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
@@ -82,6 +83,14 @@ class Preferences extends React.Component {
|
|||||||
)
|
)
|
||||||
case 'SNIPPET':
|
case 'SNIPPET':
|
||||||
return <SnippetTab dispatch={dispatch} config={config} data={data} />
|
return <SnippetTab dispatch={dispatch} config={config} data={data} />
|
||||||
|
case 'PLUGINS':
|
||||||
|
return (
|
||||||
|
<PluginsTab
|
||||||
|
dispatch={dispatch}
|
||||||
|
config={config}
|
||||||
|
haveToSave={alert => this.setState({ PluginsAlert: alert })}
|
||||||
|
/>
|
||||||
|
)
|
||||||
case 'STORAGES':
|
case 'STORAGES':
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
@@ -122,7 +131,8 @@ class Preferences extends React.Component {
|
|||||||
{ target: 'INFO', label: i18n.__('About') },
|
{ target: 'INFO', label: i18n.__('About') },
|
||||||
{ target: 'CROWDFUNDING', label: i18n.__('Crowdfunding') },
|
{ target: 'CROWDFUNDING', label: i18n.__('Crowdfunding') },
|
||||||
{ target: 'BLOG', label: i18n.__('Blog'), Blog: this.state.BlogAlert },
|
{ target: 'BLOG', label: i18n.__('Blog'), Blog: this.state.BlogAlert },
|
||||||
{ target: 'SNIPPET', label: i18n.__('Snippets') }
|
{ target: 'SNIPPET', label: i18n.__('Snippets') },
|
||||||
|
{ target: 'PLUGINS', label: i18n.__('Plugins') }
|
||||||
]
|
]
|
||||||
|
|
||||||
const navButtons = tabs.map(tab => {
|
const navButtons = tabs.map(tab => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './RenameFolderModal.styl'
|
import styles from './RenameModal.styl'
|
||||||
import dataApi from 'browser/main/lib/dataApi'
|
import dataApi from 'browser/main/lib/dataApi'
|
||||||
import { store } from 'browser/main/store'
|
import { store } from 'browser/main/store'
|
||||||
import ModalEscButton from 'browser/components/ModalEscButton'
|
import ModalEscButton from 'browser/components/ModalEscButton'
|
||||||
|
|||||||
@@ -46,13 +46,18 @@
|
|||||||
font-size 14px
|
font-size 14px
|
||||||
colorPrimaryButton()
|
colorPrimaryButton()
|
||||||
|
|
||||||
|
.error
|
||||||
|
text-align center
|
||||||
|
color #F44336
|
||||||
|
height 20px
|
||||||
|
|
||||||
apply-theme(theme)
|
apply-theme(theme)
|
||||||
body[data-theme={theme}]
|
body[data-theme={theme}]
|
||||||
.root
|
.root
|
||||||
background-color transparent
|
background-color transparent
|
||||||
|
|
||||||
.header
|
.header
|
||||||
background-color get-theme-var(theme, 'button--hover-backgroundColor')
|
background-color transparent
|
||||||
border-color get-theme-var(theme, 'borderColor')
|
border-color get-theme-var(theme, 'borderColor')
|
||||||
color get-theme-var(theme, 'text-color')
|
color get-theme-var(theme, 'text-color')
|
||||||
|
|
||||||
196
browser/main/modals/RenameTagModal.js
Normal file
196
browser/main/modals/RenameTagModal.js
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import React from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './RenameModal.styl'
|
||||||
|
import dataApi from 'browser/main/lib/dataApi'
|
||||||
|
import ModalEscButton from 'browser/components/ModalEscButton'
|
||||||
|
import i18n from 'browser/lib/i18n'
|
||||||
|
import { replace } from 'connected-react-router'
|
||||||
|
import ee from 'browser/main/lib/eventEmitter'
|
||||||
|
import { isEmpty } from 'lodash'
|
||||||
|
import electron from 'electron'
|
||||||
|
|
||||||
|
const { remote } = electron
|
||||||
|
const { dialog } = remote
|
||||||
|
|
||||||
|
class RenameTagModal extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
this.nameInput = null
|
||||||
|
|
||||||
|
this.handleChange = this.handleChange.bind(this)
|
||||||
|
|
||||||
|
this.setTextInputRef = el => {
|
||||||
|
this.nameInput = el
|
||||||
|
}
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
name: props.tagName,
|
||||||
|
oldName: props.tagName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.nameInput.focus()
|
||||||
|
this.nameInput.select()
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChange(e) {
|
||||||
|
this.setState({
|
||||||
|
name: this.nameInput.value,
|
||||||
|
showerror: false,
|
||||||
|
errormessage: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
handleKeyDown(e) {
|
||||||
|
if (e.keyCode === 27) {
|
||||||
|
this.props.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleInputKeyDown(e) {
|
||||||
|
switch (e.keyCode) {
|
||||||
|
case 13:
|
||||||
|
this.handleConfirm()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleConfirm() {
|
||||||
|
if (this.state.name.trim().length > 0) {
|
||||||
|
const { name, oldName } = this.state
|
||||||
|
this.renameTag(oldName, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
showError(message) {
|
||||||
|
this.setState({
|
||||||
|
showerror: true,
|
||||||
|
errormessage: message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
renameTag(tag, updatedTag) {
|
||||||
|
const { data, dispatch } = this.props
|
||||||
|
|
||||||
|
if (tag === updatedTag) {
|
||||||
|
// confirm with-out any change - just dismiss the modal
|
||||||
|
this.props.close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.noteMap
|
||||||
|
.map(note => note)
|
||||||
|
.some(note => note.tags.indexOf(updatedTag) !== -1)
|
||||||
|
) {
|
||||||
|
const alertConfig = {
|
||||||
|
type: 'warning',
|
||||||
|
message: i18n.__('Confirm tag merge'),
|
||||||
|
detail: i18n.__(
|
||||||
|
`Tag ${tag} will be merged with existing tag ${updatedTag}`
|
||||||
|
),
|
||||||
|
buttons: [i18n.__('Confirm'), i18n.__('Cancel')]
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialogButtonIndex = dialog.showMessageBox(
|
||||||
|
remote.getCurrentWindow(),
|
||||||
|
alertConfig
|
||||||
|
)
|
||||||
|
|
||||||
|
if (dialogButtonIndex === 1) {
|
||||||
|
return // bail early on cancel click
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const notes = data.noteMap
|
||||||
|
.map(note => note)
|
||||||
|
.filter(
|
||||||
|
note => note.tags.indexOf(tag) !== -1 && note.tags.indexOf(updatedTag)
|
||||||
|
)
|
||||||
|
.map(note => {
|
||||||
|
note = Object.assign({}, note)
|
||||||
|
note.tags = note.tags.slice()
|
||||||
|
|
||||||
|
note.tags[note.tags.indexOf(tag)] = updatedTag
|
||||||
|
|
||||||
|
return note
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isEmpty(notes)) {
|
||||||
|
this.showError(i18n.__('Tag exists'))
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Promise.all(
|
||||||
|
notes.map(note => dataApi.updateNote(note.storage, note.key, note))
|
||||||
|
)
|
||||||
|
.then(updatedNotes => {
|
||||||
|
updatedNotes.forEach(note => {
|
||||||
|
dispatch({
|
||||||
|
type: 'UPDATE_NOTE',
|
||||||
|
note
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
if (window.location.hash.includes(tag)) {
|
||||||
|
dispatch(replace(`/tags/${updatedTag}`))
|
||||||
|
}
|
||||||
|
ee.emit('sidebar:rename-tag', { tag, updatedTag })
|
||||||
|
this.props.close()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { close } = this.props
|
||||||
|
const { errormessage } = this.state
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
styleName='root'
|
||||||
|
tabIndex='-1'
|
||||||
|
onKeyDown={e => this.handleKeyDown(e)}
|
||||||
|
>
|
||||||
|
<div styleName='header'>
|
||||||
|
<div styleName='title'>{i18n.__('Rename Tag')}</div>
|
||||||
|
</div>
|
||||||
|
<ModalEscButton handleEscButtonClick={close} />
|
||||||
|
|
||||||
|
<div styleName='control'>
|
||||||
|
<input
|
||||||
|
styleName='control-input'
|
||||||
|
placeholder={i18n.__('Tag Name')}
|
||||||
|
ref={this.setTextInputRef}
|
||||||
|
value={this.state.name}
|
||||||
|
onChange={this.handleChange}
|
||||||
|
onKeyDown={e => this.handleInputKeyDown(e)}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
styleName='control-confirmButton'
|
||||||
|
onClick={() => this.handleConfirm()}
|
||||||
|
>
|
||||||
|
{i18n.__('Confirm')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className='error' styleName='error'>
|
||||||
|
{errormessage}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RenameTagModal.propTypes = {
|
||||||
|
storage: PropTypes.shape({
|
||||||
|
key: PropTypes.string
|
||||||
|
}),
|
||||||
|
folder: PropTypes.shape({
|
||||||
|
key: PropTypes.string,
|
||||||
|
name: PropTypes.string
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(RenameTagModal, styles)
|
||||||
@@ -1,22 +1,31 @@
|
|||||||
(function (mod) {
|
;(function(mod) {
|
||||||
if (typeof exports === 'object' && typeof module === 'object') { // Common JS
|
if (typeof exports === 'object' && typeof module === 'object') {
|
||||||
|
// Common JS
|
||||||
mod(require('../codemirror/lib/codemirror'))
|
mod(require('../codemirror/lib/codemirror'))
|
||||||
} else if (typeof define === 'function' && define.amd) { // AMD
|
} else if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD
|
||||||
define(['../codemirror/lib/codemirror'], mod)
|
define(['../codemirror/lib/codemirror'], mod)
|
||||||
} else { // Plain browser env
|
} else {
|
||||||
|
// Plain browser env
|
||||||
mod(CodeMirror)
|
mod(CodeMirror)
|
||||||
}
|
}
|
||||||
})(function (CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const shell = require('electron').shell
|
const shell = require('electron').shell
|
||||||
|
const remote = require('electron').remote
|
||||||
|
const eventEmitter = {
|
||||||
|
emit: function() {
|
||||||
|
remote.getCurrentWindow().webContents.send.apply(null, arguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
const yOffset = 2
|
const yOffset = 2
|
||||||
|
|
||||||
const macOS = global.process.platform === 'darwin'
|
const macOS = global.process.platform === 'darwin'
|
||||||
const modifier = macOS ? 'metaKey' : 'ctrlKey'
|
const modifier = macOS ? 'metaKey' : 'ctrlKey'
|
||||||
|
|
||||||
class HyperLink {
|
class HyperLink {
|
||||||
constructor (cm) {
|
constructor(cm) {
|
||||||
this.cm = cm
|
this.cm = cm
|
||||||
this.lineDiv = cm.display.lineDiv
|
this.lineDiv = cm.display.lineDiv
|
||||||
|
|
||||||
@@ -28,11 +37,16 @@
|
|||||||
this.tooltip = document.createElement('div')
|
this.tooltip = document.createElement('div')
|
||||||
this.tooltipContent = document.createElement('div')
|
this.tooltipContent = document.createElement('div')
|
||||||
this.tooltipIndicator = document.createElement('div')
|
this.tooltipIndicator = document.createElement('div')
|
||||||
this.tooltip.setAttribute('class', 'CodeMirror-hover CodeMirror-matchingbracket CodeMirror-selected')
|
this.tooltip.setAttribute(
|
||||||
|
'class',
|
||||||
|
'CodeMirror-hover CodeMirror-matchingbracket CodeMirror-selected'
|
||||||
|
)
|
||||||
this.tooltip.setAttribute('cm-ignore-events', 'true')
|
this.tooltip.setAttribute('cm-ignore-events', 'true')
|
||||||
this.tooltip.appendChild(this.tooltipContent)
|
this.tooltip.appendChild(this.tooltipContent)
|
||||||
this.tooltip.appendChild(this.tooltipIndicator)
|
this.tooltip.appendChild(this.tooltipIndicator)
|
||||||
this.tooltipContent.textContent = `${macOS ? 'Cmd(⌘)' : 'Ctrl(^)'} + click to follow link`
|
this.tooltipContent.textContent = `${
|
||||||
|
macOS ? 'Cmd(⌘)' : 'Ctrl(^)'
|
||||||
|
} + click to follow link`
|
||||||
|
|
||||||
this.lineDiv.addEventListener('mousedown', this.onMouseDown)
|
this.lineDiv.addEventListener('mousedown', this.onMouseDown)
|
||||||
this.lineDiv.addEventListener('mouseenter', this.onMouseEnter, {
|
this.lineDiv.addEventListener('mouseenter', this.onMouseEnter, {
|
||||||
@@ -47,11 +61,20 @@
|
|||||||
passive: true
|
passive: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
getUrl (el) {
|
getUrl(el) {
|
||||||
const className = el.className.split(' ')
|
const className = el.className.split(' ')
|
||||||
|
|
||||||
if (className.indexOf('cm-url') !== -1) {
|
if (className.indexOf('cm-url') !== -1) {
|
||||||
const match = /^\((.*)\)|\[(.*)\]|(.*)$/.exec(el.textContent)
|
// multiple cm-url because of search term
|
||||||
|
const cmUrlSpans = Array.from(
|
||||||
|
el.parentNode.getElementsByClassName('cm-url')
|
||||||
|
)
|
||||||
|
const textContent =
|
||||||
|
cmUrlSpans.length > 1
|
||||||
|
? cmUrlSpans.map(span => span.textContent).join('')
|
||||||
|
: el.textContent
|
||||||
|
|
||||||
|
const match = /^\((.*)\)|\[(.*)\]|(.*)$/.exec(textContent)
|
||||||
const url = match[1] || match[2] || match[3]
|
const url = match[1] || match[2] || match[3]
|
||||||
|
|
||||||
// `:storage` is the value of the variable `STORAGE_FOLDER_PLACEHOLDER` defined in `browser/main/lib/dataApi/attachmentManagement`
|
// `:storage` is the value of the variable `STORAGE_FOLDER_PLACEHOLDER` defined in `browser/main/lib/dataApi/attachmentManagement`
|
||||||
@@ -60,26 +83,106 @@
|
|||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
onMouseDown (e) {
|
specialLinkHandler(e, rawHref, linkHash) {
|
||||||
|
const isStartWithHash = rawHref[0] === '#'
|
||||||
|
|
||||||
|
const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
|
||||||
|
const regexNoteInternalLink = new RegExp(`${extractIdRegex.source}(.+)`)
|
||||||
|
if (isStartWithHash || regexNoteInternalLink.test(rawHref)) {
|
||||||
|
const posOfHash = linkHash.indexOf('#')
|
||||||
|
if (posOfHash > -1) {
|
||||||
|
const extractedId = linkHash.slice(posOfHash + 1)
|
||||||
|
const targetId = mdurl.encode(extractedId)
|
||||||
|
const targetElement = document.getElementById(targetId) // this.getWindow().document.getElementById(targetId)
|
||||||
|
|
||||||
|
if (targetElement != null) {
|
||||||
|
this.scrollTo(0, targetElement.offsetTop)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this will match the new uuid v4 hash and the old hash
|
||||||
|
// e.g.
|
||||||
|
// :note:1c211eb7dcb463de6490 and
|
||||||
|
// :note:7dd23275-f2b4-49cb-9e93-3454daf1af9c
|
||||||
|
const regexIsNoteLink = /^:note:([a-zA-Z0-9-]{20,36})$/
|
||||||
|
if (regexIsNoteLink.test(linkHash)) {
|
||||||
|
eventEmitter.emit('list:jump', linkHash.replace(':note:', ''))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const regexIsLine = /^:line:[0-9]/
|
||||||
|
if (regexIsLine.test(linkHash)) {
|
||||||
|
const numberPattern = /\d+/g
|
||||||
|
|
||||||
|
const lineNumber = parseInt(linkHash.match(numberPattern)[0])
|
||||||
|
eventEmitter.emit('line:jump', lineNumber)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// this will match the old link format storage.key-note.key
|
||||||
|
// e.g.
|
||||||
|
// 877f99c3268608328037-1c211eb7dcb463de6490
|
||||||
|
const regexIsLegacyNoteLink = /^(.{20})-(.{20})$/
|
||||||
|
if (regexIsLegacyNoteLink.test(linkHash)) {
|
||||||
|
eventEmitter.emit('list:jump', linkHash.split('-')[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const regexIsTagLink = /^:tag:([\w]+)$/
|
||||||
|
if (regexIsTagLink.test(rawHref)) {
|
||||||
|
const tag = rawHref.match(regexIsTagLink)[1]
|
||||||
|
eventEmitter.emit('dispatch:push', `/tags/${encodeURIComponent(tag)}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onMouseDown(e) {
|
||||||
const { target } = e
|
const { target } = e
|
||||||
if (!e[modifier]) {
|
if (!e[modifier]) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create URL spans array used for special case "search term is hitting a link".
|
||||||
|
const cmUrlSpans = Array.from(
|
||||||
|
e.target.parentNode.getElementsByClassName('cm-url')
|
||||||
|
)
|
||||||
|
|
||||||
|
const innerText =
|
||||||
|
cmUrlSpans.length > 1
|
||||||
|
? cmUrlSpans.map(span => span.textContent).join('')
|
||||||
|
: e.target.innerText
|
||||||
|
const rawHref = innerText.trim().slice(1, -1) // get link text from markdown text
|
||||||
|
|
||||||
|
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
||||||
|
|
||||||
|
const parser = document.createElement('a')
|
||||||
|
parser.href = rawHref
|
||||||
|
const { href, hash } = parser
|
||||||
|
|
||||||
|
const linkHash = hash === '' ? rawHref : hash // needed because we're having special link formats that are removed by parser e.g. :line:10
|
||||||
|
|
||||||
|
this.specialLinkHandler(target, rawHref, linkHash)
|
||||||
|
|
||||||
const url = this.getUrl(target)
|
const url = this.getUrl(target)
|
||||||
|
|
||||||
|
// all special cases handled --> other case
|
||||||
if (url) {
|
if (url) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMouseEnter (e) {
|
onMouseEnter(e) {
|
||||||
const { target } = e
|
const { target } = e
|
||||||
|
|
||||||
const url = this.getUrl(target)
|
const url = this.getUrl(target)
|
||||||
if (url) {
|
if (url) {
|
||||||
if (e[modifier]) {
|
if (e[modifier]) {
|
||||||
target.classList.add('CodeMirror-activeline-background', 'CodeMirror-hyperlink')
|
target.classList.add(
|
||||||
|
'CodeMirror-activeline-background',
|
||||||
|
'CodeMirror-hyperlink'
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
target.classList.add('CodeMirror-activeline-background')
|
target.classList.add('CodeMirror-activeline-background')
|
||||||
}
|
}
|
||||||
@@ -87,14 +190,17 @@
|
|||||||
this.showInfo(target)
|
this.showInfo(target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMouseLeave (e) {
|
onMouseLeave(e) {
|
||||||
if (this.tooltip.parentElement === this.lineDiv) {
|
if (this.tooltip.parentElement === this.lineDiv) {
|
||||||
e.target.classList.remove('CodeMirror-activeline-background', 'CodeMirror-hyperlink')
|
e.target.classList.remove(
|
||||||
|
'CodeMirror-activeline-background',
|
||||||
|
'CodeMirror-hyperlink'
|
||||||
|
)
|
||||||
|
|
||||||
this.lineDiv.removeChild(this.tooltip)
|
this.lineDiv.removeChild(this.tooltip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMouseMove (e) {
|
onMouseMove(e) {
|
||||||
if (this.tooltip.parentElement === this.lineDiv) {
|
if (this.tooltip.parentElement === this.lineDiv) {
|
||||||
if (e[modifier]) {
|
if (e[modifier]) {
|
||||||
e.target.classList.add('CodeMirror-hyperlink')
|
e.target.classList.add('CodeMirror-hyperlink')
|
||||||
@@ -103,25 +209,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showInfo (relatedTo) {
|
showInfo(relatedTo) {
|
||||||
const b1 = relatedTo.getBoundingClientRect()
|
const b1 = relatedTo.getBoundingClientRect()
|
||||||
const b2 = this.lineDiv.getBoundingClientRect()
|
const b2 = this.lineDiv.getBoundingClientRect()
|
||||||
const tdiv = this.tooltip
|
const tdiv = this.tooltip
|
||||||
|
|
||||||
tdiv.style.left = (b1.left - b2.left) + 'px'
|
tdiv.style.left = b1.left - b2.left + 'px'
|
||||||
this.lineDiv.appendChild(tdiv)
|
this.lineDiv.appendChild(tdiv)
|
||||||
|
|
||||||
const b3 = tdiv.getBoundingClientRect()
|
const b3 = tdiv.getBoundingClientRect()
|
||||||
const top = b1.top - b2.top - b3.height - yOffset
|
const top = b1.top - b2.top - b3.height - yOffset
|
||||||
if (top < 0) {
|
if (top < 0) {
|
||||||
tdiv.style.top = (b1.top - b2.top + b1.height + yOffset) + 'px'
|
tdiv.style.top = b1.top - b2.top + b1.height + yOffset + 'px'
|
||||||
} else {
|
} else {
|
||||||
tdiv.style.top = top + 'px'
|
tdiv.style.top = top + 'px'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeMirror.defineOption('hyperlink', true, (cm) => {
|
CodeMirror.defineOption('hyperlink', true, cm => {
|
||||||
const addon = new HyperLink(cm)
|
const addon = new HyperLink(cm)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
353
extra_scripts/codemirror/mode/bfm/bfm.js
vendored
353
extra_scripts/codemirror/mode/bfm/bfm.js
vendored
@@ -1,10 +1,20 @@
|
|||||||
(function(mod) {
|
;(function(mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == 'object' && typeof module == 'object')
|
||||||
mod(require("../codemirror/lib/codemirror"), require("../codemirror/mode/gfm/gfm"), require("../codemirror/mode/yaml-frontmatter/yaml-frontmatter"))
|
// CommonJS
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
mod(
|
||||||
define(["../codemirror/lib/codemirror", "../codemirror/mode/gfm/gfm", "../codemirror/mode/yaml-frontmatter/yaml-frontmatter"], mod)
|
require('../codemirror/lib/codemirror'),
|
||||||
else // Plain browser env
|
require('../codemirror/mode/gfm/gfm'),
|
||||||
mod(CodeMirror)
|
require('../codemirror/mode/yaml-frontmatter/yaml-frontmatter')
|
||||||
|
)
|
||||||
|
else if (typeof define == 'function' && define.amd)
|
||||||
|
// AMD
|
||||||
|
define([
|
||||||
|
'../codemirror/lib/codemirror',
|
||||||
|
'../codemirror/mode/gfm/gfm',
|
||||||
|
'../codemirror/mode/yaml-frontmatter/yaml-frontmatter'
|
||||||
|
], mod)
|
||||||
|
// Plain browser env
|
||||||
|
else mod(CodeMirror)
|
||||||
})(function(CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
@@ -45,189 +55,208 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeMirror.defineMode('bfm', function (config, baseConfig) {
|
CodeMirror.defineMode(
|
||||||
baseConfig.name = 'yaml-frontmatter'
|
'bfm',
|
||||||
const baseMode = CodeMirror.getMode(config, baseConfig)
|
function(config, baseConfig) {
|
||||||
|
baseConfig.name = 'yaml-frontmatter'
|
||||||
|
const baseMode = CodeMirror.getMode(config, baseConfig)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startState: function() {
|
startState: function() {
|
||||||
return {
|
return {
|
||||||
baseState: CodeMirror.startState(baseMode),
|
baseState: CodeMirror.startState(baseMode),
|
||||||
|
|
||||||
basePos: 0,
|
basePos: 0,
|
||||||
baseCur: null,
|
baseCur: null,
|
||||||
overlayPos: 0,
|
overlayPos: 0,
|
||||||
overlayCur: null,
|
overlayCur: null,
|
||||||
streamSeen: null,
|
streamSeen: null,
|
||||||
|
|
||||||
fencedEndRE: null,
|
fencedEndRE: null,
|
||||||
|
|
||||||
inTable: false,
|
inTable: false,
|
||||||
rowIndex: 0
|
rowIndex: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
copyState: function(s) {
|
copyState: function(s) {
|
||||||
return {
|
return {
|
||||||
baseState: CodeMirror.copyState(baseMode, s.baseState),
|
baseState: CodeMirror.copyState(baseMode, s.baseState),
|
||||||
|
|
||||||
basePos: s.basePos,
|
basePos: s.basePos,
|
||||||
baseCur: null,
|
baseCur: null,
|
||||||
overlayPos: s.overlayPos,
|
overlayPos: s.overlayPos,
|
||||||
overlayCur: null,
|
overlayCur: null,
|
||||||
|
|
||||||
fencedMode: s.fencedMode,
|
fencedMode: s.fencedMode,
|
||||||
fencedState: s.fencedMode ? CodeMirror.copyState(s.fencedMode, s.fencedState) : null,
|
fencedState: s.fencedMode
|
||||||
|
? CodeMirror.copyState(s.fencedMode, s.fencedState)
|
||||||
|
: null,
|
||||||
|
|
||||||
fencedEndRE: s.fencedEndRE,
|
fencedEndRE: s.fencedEndRE,
|
||||||
|
|
||||||
inTable: s.inTable,
|
inTable: s.inTable,
|
||||||
rowIndex: s.rowIndex
|
rowIndex: s.rowIndex
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
token: function(stream, state) {
|
token: function(stream, state) {
|
||||||
const initialPos = stream.pos
|
const initialPos = stream.pos
|
||||||
|
|
||||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||||
state.fencedEndRE = null
|
state.fencedEndRE = null
|
||||||
state.fencedMode = null
|
state.fencedMode = null
|
||||||
state.fencedState = null
|
state.fencedState = null
|
||||||
|
|
||||||
stream.pos = initialPos
|
stream.pos = initialPos
|
||||||
}
|
} else {
|
||||||
else {
|
if (state.fencedMode) {
|
||||||
if (state.fencedMode) {
|
return state.fencedMode.token(stream, state.fencedState)
|
||||||
return state.fencedMode.token(stream, state.fencedState)
|
}
|
||||||
|
|
||||||
|
const match = stream.match(fencedCodeRE, true)
|
||||||
|
if (match) {
|
||||||
|
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
||||||
|
|
||||||
|
state.fencedMode = getMode(
|
||||||
|
match[2],
|
||||||
|
match[3],
|
||||||
|
config,
|
||||||
|
stream.lineOracle.doc.cm
|
||||||
|
)
|
||||||
|
if (state.fencedMode) {
|
||||||
|
state.fencedState = CodeMirror.startState(state.fencedMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.pos = initialPos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
stream != state.streamSeen ||
|
||||||
|
Math.min(state.basePos, state.overlayPos) < stream.start
|
||||||
|
) {
|
||||||
|
state.streamSeen = stream
|
||||||
|
state.basePos = state.overlayPos = stream.start
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream.start == state.basePos) {
|
||||||
|
state.baseCur = baseMode.token(stream, state.baseState)
|
||||||
|
state.basePos = stream.pos
|
||||||
|
}
|
||||||
|
if (stream.start == state.overlayPos) {
|
||||||
|
stream.pos = stream.start
|
||||||
|
state.overlayCur = this.overlayToken(stream, state)
|
||||||
|
state.overlayPos = stream.pos
|
||||||
|
}
|
||||||
|
stream.pos = Math.min(state.basePos, state.overlayPos)
|
||||||
|
|
||||||
|
if (state.overlayCur == null) {
|
||||||
|
return state.baseCur
|
||||||
|
} else if (state.baseCur != null && state.combineTokens) {
|
||||||
|
return state.baseCur + ' ' + state.overlayCur
|
||||||
|
} else {
|
||||||
|
return state.overlayCur
|
||||||
|
}
|
||||||
|
},
|
||||||
|
overlayToken: function(stream, state) {
|
||||||
|
state.combineTokens = false
|
||||||
|
|
||||||
|
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||||
|
state.fencedEndRE = null
|
||||||
|
state.localMode = null
|
||||||
|
state.localState = null
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.localMode) {
|
||||||
|
return state.localMode.token(stream, state.localState) || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = stream.match(fencedCodeRE, true)
|
const match = stream.match(fencedCodeRE, true)
|
||||||
if (match) {
|
if (match) {
|
||||||
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
||||||
|
|
||||||
state.fencedMode = getMode(match[2], match[3], config, stream.lineOracle.doc.cm)
|
state.localMode = getMode(
|
||||||
if (state.fencedMode) {
|
match[2],
|
||||||
state.fencedState = CodeMirror.startState(state.fencedMode)
|
match[3],
|
||||||
|
config,
|
||||||
|
stream.lineOracle.doc.cm
|
||||||
|
)
|
||||||
|
if (state.localMode) {
|
||||||
|
state.localState = CodeMirror.startState(state.localMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.pos = initialPos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream != state.streamSeen || Math.min(state.basePos, state.overlayPos) < stream.start) {
|
|
||||||
state.streamSeen = stream
|
|
||||||
state.basePos = state.overlayPos = stream.start
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream.start == state.basePos) {
|
|
||||||
state.baseCur = baseMode.token(stream, state.baseState)
|
|
||||||
state.basePos = stream.pos
|
|
||||||
}
|
|
||||||
if (stream.start == state.overlayPos) {
|
|
||||||
stream.pos = stream.start
|
|
||||||
state.overlayCur = this.overlayToken(stream, state)
|
|
||||||
state.overlayPos = stream.pos
|
|
||||||
}
|
|
||||||
stream.pos = Math.min(state.basePos, state.overlayPos)
|
|
||||||
|
|
||||||
if (state.overlayCur == null) {
|
|
||||||
return state.baseCur
|
|
||||||
}
|
|
||||||
else if (state.baseCur != null && state.combineTokens) {
|
|
||||||
return state.baseCur + ' ' + state.overlayCur
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return state.overlayCur
|
|
||||||
}
|
|
||||||
},
|
|
||||||
overlayToken: function(stream, state) {
|
|
||||||
state.combineTokens = false
|
|
||||||
|
|
||||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
|
||||||
state.fencedEndRE = null
|
|
||||||
state.localMode = null
|
|
||||||
state.localState = null
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.localMode) {
|
|
||||||
return state.localMode.token(stream, state.localState) || ''
|
|
||||||
}
|
|
||||||
|
|
||||||
const match = stream.match(fencedCodeRE, true)
|
|
||||||
if (match) {
|
|
||||||
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
|
||||||
|
|
||||||
state.localMode = getMode(match[2], match[3], config, stream.lineOracle.doc.cm)
|
|
||||||
if (state.localMode) {
|
|
||||||
state.localState = CodeMirror.startState(state.localMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
state.combineTokens = true
|
|
||||||
|
|
||||||
if (state.inTable) {
|
|
||||||
if (stream.match(/^\|/)) {
|
|
||||||
++state.rowIndex
|
|
||||||
|
|
||||||
stream.skipToEnd()
|
|
||||||
|
|
||||||
if (state.rowIndex === 1) {
|
|
||||||
return 'table table-separator'
|
|
||||||
} else if (state.rowIndex % 2 === 0) {
|
|
||||||
return 'table table-row table-row-even'
|
|
||||||
} else {
|
|
||||||
return 'table table-row table-row-odd'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state.inTable = false
|
|
||||||
|
|
||||||
stream.skipToEnd()
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
} else if (stream.match(/^\|/)) {
|
|
||||||
state.inTable = true
|
state.combineTokens = true
|
||||||
state.rowIndex = 0
|
|
||||||
|
if (state.inTable) {
|
||||||
|
if (stream.match(/^\|/)) {
|
||||||
|
++state.rowIndex
|
||||||
|
|
||||||
|
stream.skipToEnd()
|
||||||
|
|
||||||
|
if (state.rowIndex === 1) {
|
||||||
|
return 'table table-separator'
|
||||||
|
} else if (state.rowIndex % 2 === 0) {
|
||||||
|
return 'table table-row table-row-even'
|
||||||
|
} else {
|
||||||
|
return 'table table-row table-row-odd'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.inTable = false
|
||||||
|
|
||||||
|
stream.skipToEnd()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
} else if (stream.match(/^\|/)) {
|
||||||
|
state.inTable = true
|
||||||
|
state.rowIndex = 0
|
||||||
|
|
||||||
|
stream.skipToEnd()
|
||||||
|
return 'table table-header'
|
||||||
|
}
|
||||||
|
|
||||||
stream.skipToEnd()
|
stream.skipToEnd()
|
||||||
return 'table table-header'
|
return null
|
||||||
}
|
},
|
||||||
|
electricChars: baseMode.electricChars,
|
||||||
stream.skipToEnd()
|
innerMode: function(state) {
|
||||||
return null
|
if (state.fencedMode) {
|
||||||
},
|
return {
|
||||||
electricChars: baseMode.electricChars,
|
mode: state.fencedMode,
|
||||||
innerMode: function(state) {
|
state: state.fencedState
|
||||||
if (state.fencedMode) {
|
}
|
||||||
return {
|
} else {
|
||||||
mode: state.fencedMode,
|
return {
|
||||||
state: state.fencedState
|
mode: baseMode,
|
||||||
|
state: state.baseState
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
},
|
||||||
return {
|
blankLine: function(state) {
|
||||||
mode: baseMode,
|
state.inTable = false
|
||||||
state: state.baseState
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
blankLine: function(state) {
|
|
||||||
state.inTable = false
|
|
||||||
|
|
||||||
if (state.fencedMode) {
|
if (state.fencedMode) {
|
||||||
return state.fencedMode.blankLine && state.fencedMode.blankLine(state.fencedState)
|
return (
|
||||||
} else {
|
state.fencedMode.blankLine &&
|
||||||
return baseMode.blankLine(state.baseState)
|
state.fencedMode.blankLine(state.fencedState)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return baseMode.blankLine(state.baseState)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}, 'yaml-frontmatter')
|
'yaml-frontmatter'
|
||||||
|
)
|
||||||
|
|
||||||
CodeMirror.defineMIME('text/x-bfm', 'bfm')
|
CodeMirror.defineMIME('text/x-bfm', 'bfm')
|
||||||
|
|
||||||
CodeMirror.modeInfo.push({
|
CodeMirror.modeInfo.push({
|
||||||
name: "Boost Flavored Markdown",
|
name: 'Boost Flavored Markdown',
|
||||||
mime: "text/x-bfm",
|
mime: 'text/x-bfm',
|
||||||
mode: "bfm"
|
mode: 'bfm'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
157
extra_scripts/codemirror/mode/gfm/gfm.js
vendored
Normal file
157
extra_scripts/codemirror/mode/gfm/gfm.js
vendored
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
|
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||||
|
|
||||||
|
;(function(mod) {
|
||||||
|
if (typeof exports == 'object' && typeof module == 'object')
|
||||||
|
// CommonJS
|
||||||
|
mod(
|
||||||
|
require('../codemirror/lib/codemirror'),
|
||||||
|
require('../codemirror/mode/markdown/markdown'),
|
||||||
|
require('../codemirror/addon/mode/overlay')
|
||||||
|
)
|
||||||
|
else if (typeof define == 'function' && define.amd)
|
||||||
|
// AMD
|
||||||
|
define([
|
||||||
|
'../codemirror/lib/codemirror',
|
||||||
|
'../codemirror/mode/markdown/markdown',
|
||||||
|
'../codemirror/addon/mode/overlay'
|
||||||
|
], mod)
|
||||||
|
// Plain browser env
|
||||||
|
else mod(CodeMirror)
|
||||||
|
})(function(CodeMirror) {
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
|
||||||
|
|
||||||
|
CodeMirror.defineMode(
|
||||||
|
'gfm',
|
||||||
|
function(config, modeConfig) {
|
||||||
|
var codeDepth = 0
|
||||||
|
function blankLine(state) {
|
||||||
|
state.code = false
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
var gfmOverlay = {
|
||||||
|
startState: function() {
|
||||||
|
return {
|
||||||
|
code: false,
|
||||||
|
codeBlock: false,
|
||||||
|
ateSpace: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
copyState: function(s) {
|
||||||
|
return {
|
||||||
|
code: s.code,
|
||||||
|
codeBlock: s.codeBlock,
|
||||||
|
ateSpace: s.ateSpace
|
||||||
|
}
|
||||||
|
},
|
||||||
|
token: function(stream, state) {
|
||||||
|
state.combineTokens = null
|
||||||
|
|
||||||
|
// Hack to prevent formatting override inside code blocks (block and inline)
|
||||||
|
if (state.codeBlock) {
|
||||||
|
if (stream.match(/^```+/)) {
|
||||||
|
state.codeBlock = false
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
stream.skipToEnd()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (stream.sol()) {
|
||||||
|
state.code = false
|
||||||
|
}
|
||||||
|
if (stream.sol() && stream.match(/^```+/)) {
|
||||||
|
stream.skipToEnd()
|
||||||
|
state.codeBlock = true
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
// If this block is changed, it may need to be updated in Markdown mode
|
||||||
|
if (stream.peek() === '`') {
|
||||||
|
stream.next()
|
||||||
|
var before = stream.pos
|
||||||
|
stream.eatWhile('`')
|
||||||
|
var difference = 1 + stream.pos - before
|
||||||
|
if (!state.code) {
|
||||||
|
codeDepth = difference
|
||||||
|
state.code = true
|
||||||
|
} else {
|
||||||
|
if (difference === codeDepth) {
|
||||||
|
// Must be exact
|
||||||
|
state.code = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
} else if (state.code) {
|
||||||
|
stream.next()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
// Check if space. If so, links can be formatted later on
|
||||||
|
if (stream.eatSpace()) {
|
||||||
|
state.ateSpace = true
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (stream.sol() || state.ateSpace) {
|
||||||
|
state.ateSpace = false
|
||||||
|
if (modeConfig.gitHubSpice !== false) {
|
||||||
|
if (
|
||||||
|
stream.match(
|
||||||
|
/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// User/Project@SHA
|
||||||
|
// User@SHA
|
||||||
|
// SHA
|
||||||
|
state.combineTokens = true
|
||||||
|
return 'link'
|
||||||
|
} else if (
|
||||||
|
stream.match(
|
||||||
|
/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// User/Project#Num
|
||||||
|
// User#Num
|
||||||
|
// #Num
|
||||||
|
state.combineTokens = true
|
||||||
|
return 'link'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
stream.match(urlRE) &&
|
||||||
|
stream.string.slice(stream.start - 2, stream.start) != '](' &&
|
||||||
|
(stream.start == 0 ||
|
||||||
|
/\W/.test(stream.string.charAt(stream.start - 1)))
|
||||||
|
) {
|
||||||
|
// URLs
|
||||||
|
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
||||||
|
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
|
||||||
|
// And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
|
||||||
|
state.combineTokens = true
|
||||||
|
return 'link'
|
||||||
|
}
|
||||||
|
stream.next()
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
blankLine: blankLine
|
||||||
|
}
|
||||||
|
|
||||||
|
var markdownConfig = {
|
||||||
|
taskLists: true,
|
||||||
|
strikethrough: true,
|
||||||
|
emoji: true
|
||||||
|
}
|
||||||
|
for (var attr in modeConfig) {
|
||||||
|
markdownConfig[attr] = modeConfig[attr]
|
||||||
|
}
|
||||||
|
markdownConfig.name = 'markdown'
|
||||||
|
return CodeMirror.overlayMode(
|
||||||
|
CodeMirror.getMode(config, markdownConfig),
|
||||||
|
gfmOverlay
|
||||||
|
)
|
||||||
|
},
|
||||||
|
'markdown'
|
||||||
|
)
|
||||||
|
|
||||||
|
CodeMirror.defineMIME('text/x-gfm', 'gfm')
|
||||||
|
})
|
||||||
@@ -314,6 +314,12 @@ const view = {
|
|||||||
mainWindow.webContents.send('editor:fullscreen')
|
mainWindow.webContents.send('editor:fullscreen')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Toggle Editor Orientation',
|
||||||
|
click() {
|
||||||
|
mainWindow.webContents.send('editor:orientation')
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -108,12 +108,12 @@
|
|||||||
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/gfm/gfm.js"></script>
|
|
||||||
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
||||||
|
|
||||||
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
||||||
|
<script src="../extra_scripts/codemirror/mode/gfm/gfm.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
||||||
|
|
||||||
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
||||||
|
|||||||
@@ -104,12 +104,12 @@
|
|||||||
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/gfm/gfm.js"></script>
|
|
||||||
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
||||||
|
|
||||||
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
||||||
|
<script src="../extra_scripts/codemirror/mode/gfm/gfm.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
||||||
|
|
||||||
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"Ctrl(^)": "Ctrl(^)",
|
"Ctrl(^)": "Ctrl(^)",
|
||||||
"to create a new note": "新增筆記",
|
"to create a new note": "新增筆記",
|
||||||
"Toggle Mode": "切換模式",
|
"Toggle Mode": "切換模式",
|
||||||
|
"Add tag...": "新增標籤...",
|
||||||
"Trash": "垃圾桶",
|
"Trash": "垃圾桶",
|
||||||
"Ok": "好",
|
"Ok": "好",
|
||||||
"MODIFICATION DATE": "修改時間",
|
"MODIFICATION DATE": "修改時間",
|
||||||
@@ -22,50 +23,57 @@
|
|||||||
".pdf": ".pdf",
|
".pdf": ".pdf",
|
||||||
"Print": "列印",
|
"Print": "列印",
|
||||||
"Your preferences for Boostnote": "Boostnote 偏好設定",
|
"Your preferences for Boostnote": "Boostnote 偏好設定",
|
||||||
|
"Help": "幫助",
|
||||||
|
"Hide Help": "隱藏幫助",
|
||||||
"Storage Locations": "儲存空間",
|
"Storage Locations": "儲存空間",
|
||||||
"Add Storage Location": "新增儲存位置",
|
"Add Storage Location": "新增儲存位置",
|
||||||
"Add Folder": "新增資料夾",
|
"Add Folder": "新增資料夾",
|
||||||
|
"Select Folder": "選擇資料夾",
|
||||||
"Open Storage folder": "開啟儲存資料夾",
|
"Open Storage folder": "開啟儲存資料夾",
|
||||||
"Unlink": "解除連結",
|
"Unlink": "解除連結",
|
||||||
"Edit": "編輯",
|
"Edit": "編輯",
|
||||||
"Delete": "刪除",
|
"Delete": "刪除",
|
||||||
"Interface": "界面",
|
"Interface": "介面",
|
||||||
"Interface Theme": "主題",
|
"Interface Theme": "介面主題",
|
||||||
"Default": "預設",
|
"Default": "預設",
|
||||||
"White": "White",
|
"White": "White",
|
||||||
"Solarized Dark": "Solarized Dark",
|
"Solarized Dark": "Solarized Dark",
|
||||||
"Dark": "Dark",
|
"Dark": "Dark",
|
||||||
"Show a confirmation dialog when deleting notes": "刪除筆記的時候,顯示確認對話框",
|
"Show a confirmation dialog when deleting notes": "刪除筆記時顯示確認對話框",
|
||||||
|
"Disable Direct Write (It will be applied after restarting)": "停用直接編輯 (重新啟動後生效)",
|
||||||
|
"Show only related tags": "只顯示相關標籤",
|
||||||
"Editor Theme": "編輯器主題",
|
"Editor Theme": "編輯器主題",
|
||||||
"Editor Font Size": "編輯器字型大小",
|
"Editor Font Size": "編輯器字型大小",
|
||||||
"Editor Font Family": "編輯器字體",
|
"Editor Font Family": "編輯器字體",
|
||||||
"Editor Indent Style": "縮排風格",
|
"Editor Indent Style": "縮排風格",
|
||||||
"Spaces": "空格",
|
"Spaces": "空格",
|
||||||
"Tabs": "Tabs",
|
"Tabs": "Tabs",
|
||||||
"Switch to Preview": "切回預覽頁面的時機",
|
"Switch to Preview": "切回預覽頁面",
|
||||||
"When Editor Blurred": "當編輯器失去焦點時",
|
"When Editor Blurred": "當編輯器失去焦點時",
|
||||||
"When Editor Blurred, Edit On Double Click": "當編輯器失去焦點時,雙擊切換到編輯畫面",
|
"When Editor Blurred, Edit On Double Click": "當編輯器失去焦點時,點兩下開始編輯",
|
||||||
"On Right Click": "點選右鍵切換兩個頁面",
|
"On Right Click": "點選右鍵",
|
||||||
"Editor Keymap": "編輯器 Keymap",
|
"Editor Keymap": "編輯器 Keymap",
|
||||||
"default": "預設",
|
"default": "預設",
|
||||||
"vim": "vim",
|
"vim": "vim",
|
||||||
"emacs": "emacs",
|
"emacs": "emacs",
|
||||||
"⚠️ Please restart boostnote after you change the keymap": "⚠️ 修改鍵盤配置請重新開啟 Boostnote ",
|
"⚠️ Please restart boostnote after you change the keymap": "⚠️ 修改鍵盤配置後請重新啟動 Boostnote ",
|
||||||
"Show line numbers in the editor": "在編輯器中顯示行號",
|
"Show line numbers in the editor": "在編輯器中顯示行號",
|
||||||
"Allow editor to scroll past the last line": "允許編輯器捲軸捲動超過最後一行",
|
"Allow editor to scroll past the last line": "允許編輯器捲軸捲動超過最後一行",
|
||||||
"Bring in web page title when pasting URL on editor": "在編輯器貼上網址的時候,自動加上網頁標題",
|
"Enable smart quotes": "啟用智慧引號",
|
||||||
|
"Bring in web page title when pasting URL on editor": "在編輯器貼上網址時自動加上網頁標題",
|
||||||
"Preview": "預覽頁面",
|
"Preview": "預覽頁面",
|
||||||
"Preview Font Size": "預覽頁面字型大小",
|
"Preview Font Size": "預覽頁面字型大小",
|
||||||
"Preview Font Family": "預覽頁面字體",
|
"Preview Font Family": "預覽頁面字體",
|
||||||
"Code Block Theme": "程式碼區塊主題",
|
"Code Block Theme": "程式碼區塊主題",
|
||||||
"Allow preview to scroll past the last line": "允許預覽頁面捲軸捲動超過最後一行",
|
"Allow preview to scroll past the last line": "允許預覽頁面捲軸捲動超過最後一行",
|
||||||
"Show line numbers for preview code blocks": "在預覽頁面的程式碼區塊中顯示行號",
|
"Show line numbers for preview code blocks": "在程式碼區塊預覽中顯示行號",
|
||||||
"LaTeX Inline Open Delimiter": "LaTeX 單行開頭符號",
|
"LaTeX Inline Open Delimiter": "LaTeX 單行開頭符號",
|
||||||
"LaTeX Inline Close Delimiter": "LaTeX 單行結尾符號",
|
"LaTeX Inline Close Delimiter": "LaTeX 單行結尾符號",
|
||||||
"LaTeX Block Open Delimiter": "LaTeX 多行開頭符號",
|
"LaTeX Block Open Delimiter": "LaTeX 多行開頭符號",
|
||||||
"LaTeX Block Close Delimiter": "LaTeX 多行結尾符號",
|
"LaTeX Block Close Delimiter": "LaTeX 多行結尾符號",
|
||||||
|
"PlantUML Server": "PlantUML 伺服器",
|
||||||
"Community": "社群",
|
"Community": "社群",
|
||||||
"Subscribe to Newsletter": "訂閱郵件",
|
"Subscribe to Newsletter": "訂閱電子報",
|
||||||
"GitHub": "GitHub",
|
"GitHub": "GitHub",
|
||||||
"Blog": "部落格",
|
"Blog": "部落格",
|
||||||
"Facebook Group": "Facebook 社團",
|
"Facebook Group": "Facebook 社團",
|
||||||
@@ -73,34 +81,35 @@
|
|||||||
"About": "關於",
|
"About": "關於",
|
||||||
"Boostnote": "Boostnote",
|
"Boostnote": "Boostnote",
|
||||||
"An open source note-taking app made for programmers just like you.": "一款專門為程式設計師朋友量身打造的開源筆記軟體",
|
"An open source note-taking app made for programmers just like you.": "一款專門為程式設計師朋友量身打造的開源筆記軟體",
|
||||||
"Website": "官網",
|
"Website": "官方網站",
|
||||||
"Development": "開發",
|
"Development": "開發",
|
||||||
" : Development configurations for Boostnote.": " : Boostnote 的開發組態",
|
" : Development configurations for Boostnote.": " : Boostnote 的開發設定",
|
||||||
"Copyright (C) 2017 - 2019 BoostIO": "Copyright (C) 2017 - 2019 BoostIO",
|
"Copyright (C) 2017 - 2019 BoostIO": "Copyright (C) 2017 - 2019 BoostIO",
|
||||||
"License: GPL v3": "License: GPL v3",
|
"License: GPL v3": "License: GPL v3",
|
||||||
"Analytics": "分析",
|
"Analytics": "分析",
|
||||||
"Boostnote collects anonymous data for the sole purpose of improving the application, and strictly does not collect any personal information such the contents of your notes.": "Boostnote 收集匿名資料單純只為了提升軟體使用體驗,絕對不收集任何個人資料(包括筆記內容)",
|
"Boostnote collects anonymous data for the sole purpose of improving the application, and strictly does not collect any personal information such the contents of your notes.": "Boostnote 收集匿名資料單純只為了提升軟體使用體驗,絕對不收集任何個人資料(包括筆記內容)",
|
||||||
"You can see how it works on ": "你可以看看它的程式碼是如何運作 ",
|
"You can see how it works on ": "您可以看看它的程式碼是如何運作 ",
|
||||||
"You can choose to enable or disable this option.": "你可以選擇啟用或停用這項功能",
|
"You can choose to enable or disable this option.": "您可以選擇啟用或停用這項功能",
|
||||||
"Enable analytics to help improve Boostnote": "允許數據分析以協助我們改進 Boostnote",
|
"Enable analytics to help improve Boostnote": "啟用數據分析以協助我們改進 Boostnote",
|
||||||
"Crowdfunding": "群眾募資",
|
"Crowdfunding": "群眾募資",
|
||||||
"Dear Boostnote users,": "親愛的用戶:",
|
"Dear Boostnote users,": "親愛的使用者:",
|
||||||
"Thank you for using Boostnote!": "謝謝你使用 Boostnote!",
|
"Thank you for using Boostnote!": "感謝您使用 Boostnote!",
|
||||||
"Boostnote is used in about 200 different countries and regions by an awesome community of developers.": "大約有 200 個不同的國家和地區的優秀開發者們都在使用 Boostnote!",
|
"Boostnote is used in about 200 different countries and regions by an awesome community of developers.": "大約有 200 個不同的國家和地區的優秀開發者們都在使用 Boostnote!",
|
||||||
"To support our growing userbase, and satisfy community expectations,": "為了繼續支持這種發展,和滿足社群的期待,",
|
"To support our growing userbase, and satisfy community expectations,": "為了繼續支持我們的使用者成長與滿足社群期待,",
|
||||||
"we would like to invest more time and resources in this project.": "我們非常願意投入更多的時間和資源到這個專案中。",
|
"we would like to invest more time and resources in this project.": "我們非常願意投入更多的時間和資源到這個專案中。",
|
||||||
"If you use Boostnote and see its potential, help us out by supporting the project on OpenCollective!": "如果你喜歡這款軟體並且看好它的潛力, 請在 OpenCollective 上支持我們!",
|
"If you use Boostnote and see its potential, help us out by supporting the project on OpenCollective!": "如果您喜歡這款軟體並且看好它的潛力, 請在 OpenCollective 上支持我們!",
|
||||||
"Thanks,": "十分感謝!",
|
"Thanks,": "十分感謝!",
|
||||||
"The Boostnote Team": "Boostnote 的維護人員",
|
"The Boostnote Team": "Boostnote 的團隊",
|
||||||
"Support via OpenCollective": "在 OpenCollective 上支持我們",
|
"Support via OpenCollective": "在 OpenCollective 上支持我們",
|
||||||
"Language": "語言",
|
"Language": "語言",
|
||||||
|
"Default New Note": "新筆記預設類型",
|
||||||
"English": "English",
|
"English": "English",
|
||||||
"German": "German",
|
"German": "德文",
|
||||||
"French": "French",
|
"French": "法文",
|
||||||
"Show \"Saved to Clipboard\" notification when copying": "複製的時候,顯示 \"已複製到剪貼簿\" 的通知",
|
"Show \"Saved to Clipboard\" notification when copying": "複製的時候,顯示 \"已複製到剪貼簿\" 的通知",
|
||||||
"All Notes": "所有筆記",
|
"All Notes": "所有筆記",
|
||||||
"Starred": "星號收藏",
|
"Starred": "我的最愛",
|
||||||
"Are you sure to ": "你確定要 ",
|
"Are you sure to ": "您確定要 ",
|
||||||
" delete": " 刪除",
|
" delete": " 刪除",
|
||||||
"this folder?": "這個資料夾嗎?",
|
"this folder?": "這個資料夾嗎?",
|
||||||
"Confirm": "確認",
|
"Confirm": "確認",
|
||||||
@@ -113,13 +122,14 @@
|
|||||||
"Updated": "依更新時間排序",
|
"Updated": "依更新時間排序",
|
||||||
"Created": "依建立時間排序",
|
"Created": "依建立時間排序",
|
||||||
"Alphabetically": "依字母排序",
|
"Alphabetically": "依字母排序",
|
||||||
|
"Counter": "計數器",
|
||||||
"Default View": "預設顯示",
|
"Default View": "預設顯示",
|
||||||
"Compressed View": "緊密顯示",
|
"Compressed View": "緊密顯示",
|
||||||
"Search": "搜尋",
|
"Search": "搜尋",
|
||||||
"Blog Type": "部落格類型",
|
"Blog Type": "部落格類型",
|
||||||
"Blog Address": "部落格網址",
|
"Blog Address": "部落格網址",
|
||||||
"Save": "儲存",
|
"Save": "儲存",
|
||||||
"Auth": "驗證",
|
"Auth": "認證",
|
||||||
"Authentication Method": "認證方法",
|
"Authentication Method": "認證方法",
|
||||||
"JWT": "JWT",
|
"JWT": "JWT",
|
||||||
"USER": "USER",
|
"USER": "USER",
|
||||||
@@ -127,47 +137,61 @@
|
|||||||
"Storage": "儲存空間",
|
"Storage": "儲存空間",
|
||||||
"Hotkeys": "快捷鍵",
|
"Hotkeys": "快捷鍵",
|
||||||
"Show/Hide Boostnote": "顯示/隱藏 Boostnote",
|
"Show/Hide Boostnote": "顯示/隱藏 Boostnote",
|
||||||
|
"Toggle Editor Mode": "切換編輯器模式",
|
||||||
|
"Delete Note": "刪除模式",
|
||||||
"Restore": "還原",
|
"Restore": "還原",
|
||||||
"Permanent Delete": "永久刪除",
|
"Permanent Delete": "永久刪除",
|
||||||
"Confirm note deletion": "確認刪除筆記",
|
"Confirm note deletion": "確認刪除筆記",
|
||||||
"This will permanently remove this note.": "這將會永久地刪除這條筆記",
|
"This will permanently remove this note.": "永久地刪除此筆記",
|
||||||
"Successfully applied!": "設定成功",
|
"Successfully applied!": "設定成功!",
|
||||||
"Albanian": "Albanian",
|
"Albanian": "阿爾巴尼亞語",
|
||||||
"Chinese (zh-CN)": "简体中文",
|
"Chinese (zh-CN)": "简体中文 (zh-CN)",
|
||||||
"Chinese (zh-TW)": "繁體中文",
|
"Chinese (zh-TW)": "繁體中文 (zh-TW)",
|
||||||
"Czech": "捷克文",
|
"Czech": "捷克文",
|
||||||
"Danish": "Danish",
|
"Danish": "丹麥文",
|
||||||
"Japanese": "Japanese",
|
"Japanese": "日文",
|
||||||
"Korean": "Korean",
|
"Korean": "韓文",
|
||||||
"Norwegian": "Norwegian",
|
"Norwegian": "挪威語",
|
||||||
"Polish": "Polish",
|
"Polish": "波蘭文",
|
||||||
"Portuguese": "Portuguese",
|
"Portuguese": "葡萄牙文",
|
||||||
"Spanish": "Spanish",
|
"Spanish": "西班牙文",
|
||||||
"Unsaved Changes!": "你必須儲存一下!",
|
"Unsaved Changes!": "您必須儲存一下!",
|
||||||
"Russian": "Russian",
|
"UserName": "使用者名稱",
|
||||||
|
"Password": "密碼",
|
||||||
|
"Russian": "俄羅斯語",
|
||||||
|
"Hungarian": "匈牙利語",
|
||||||
|
"Thai": "泰文 (ภาษาไทย)",
|
||||||
|
"Command(⌘)": "指令(⌘)",
|
||||||
|
"Add Storage": "新增儲存空間",
|
||||||
|
"Name": "名稱",
|
||||||
|
"Type": "類型",
|
||||||
|
"File System": "檔案系統",
|
||||||
|
"Setting up 3rd-party cloud storage integration:": "第三方雲端儲存空間設定:",
|
||||||
|
"Cloud-Syncing-and-Backup": "雲端同步與備份",
|
||||||
|
"Location": "位置",
|
||||||
|
"Add": "新增",
|
||||||
|
"Unlink Storage": "解除儲存空間連結",
|
||||||
|
"Unlinking removes this linked storage from Boostnote. No data is removed, please manually delete the folder from your hard drive if needed.": "從 Boostnote 移除解此連結. 資料並不會被刪除,如需刪除,請手動從硬碟資料夾中刪除資料。",
|
||||||
"Editor Rulers": "編輯器中顯示垂直尺規",
|
"Editor Rulers": "編輯器中顯示垂直尺規",
|
||||||
"Enable": "啟用",
|
"Enable": "啟用",
|
||||||
"Disable": "停用",
|
"Disable": "停用",
|
||||||
"Sanitization": "過濾 HTML 程式碼",
|
"Sanitization": "過濾 HTML 程式碼",
|
||||||
"Only allow secure html tags (recommended)": "只允許安全的 HTML 標籤 (建議)",
|
"Only allow secure html tags (recommended)": "只允許安全的 HTML 標籤 (建議)",
|
||||||
|
"Render newlines in Markdown paragraphs as <br>": "在 Markdown 段落中使用 <br> 換行",
|
||||||
"Allow styles": "允許樣式",
|
"Allow styles": "允許樣式",
|
||||||
"Allow dangerous html tags": "允許危險的 HTML 標籤",
|
"Allow dangerous html tags": "允許危險的 HTML 標籤",
|
||||||
"Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.": "將文本箭頭轉換為完整符號。 ⚠ 注意這會影響 Markdown 的 HTML 注釋。",
|
"Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.": "將文本箭頭轉換為完整符號。 ⚠ 注意這會影響 Markdown 的 HTML 注釋。",
|
||||||
"Default New Note": "預設新筆記類型",
|
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ 您貼上了一個不存在本筆記儲存空間的附加檔案連結。貼上附加檔案連結功能只支援剪下貼上於相同儲存空間之間。請改以拖拉 Drag&Drop 附加檔案!⚠",
|
||||||
"Show only related tags": "只顯示相關標籤",
|
"Spellcheck disabled": "拼寫檢查已關閉",
|
||||||
"Snippet Default Language": "程式碼片段預設語言",
|
"Save tags of a note in alphabetical order": "依照字母排序儲存標籤",
|
||||||
"Disable Direct Write (It will be applied after restarting)": "停用直接編輯 (重啟後生效)",
|
"Enable live count of notes": "啟用即時統計筆記數量",
|
||||||
"Enable smart table editor": "啟用智能表格編輯器",
|
"Enable smart table editor": "啟用智能表格編輯器",
|
||||||
"Enable smart quotes": "啟用智能引號",
|
"Snippet Default Language": "程式碼片段預設語言",
|
||||||
"Allow line through checkbox": "替標示為完成的選框添加刪除線",
|
"New notes are tagged with the filtering tags": "以過慮標籤標記新筆記",
|
||||||
"Custom CSS": "自定義 CSS",
|
"Show menu bar": "顯示功能列",
|
||||||
"Allow custom CSS for preview": "允許預覽自定義 CSS",
|
"Auto Detect": "自動偵測",
|
||||||
"Render newlines in Markdown paragraphs as <br>": "在 Markdown 段落中使用 <br> 換行",
|
"Filter tags/folders...": "過濾標籤/資料夾...",
|
||||||
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠",
|
"Enable HTML label in mermaid flowcharts": "在 mermaid 流程圖中啟用 HTML 標籤 ⚠ 本選項有潛在的 XSS 安全風險。",
|
||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Wrap line in Snippet Note": "Snippet Note 行尾換行",
|
||||||
"Show menu bar": "Show menu bar",
|
"Enable Auto Update": "Enable Auto Update"
|
||||||
"Auto Detect": "Auto Detect",
|
|
||||||
"Filter tags/folders...": "filter tags/folders...",
|
|
||||||
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "boost",
|
"name": "boost",
|
||||||
"productName": "Boostnote",
|
"productName": "Boostnote",
|
||||||
"version": "0.15.1",
|
"version": "0.15.3",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"description": "Boostnote",
|
"description": "Boostnote",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
"chart.js": "^2.7.2",
|
"chart.js": "^2.7.2",
|
||||||
"codemirror": "^5.40.2",
|
"codemirror": "^5.40.2",
|
||||||
"codemirror-mode-elixir": "^1.1.1",
|
"codemirror-mode-elixir": "^1.1.1",
|
||||||
|
"command-exists": "^1.2.9",
|
||||||
"connected-react-router": "^6.4.0",
|
"connected-react-router": "^6.4.0",
|
||||||
"electron-config": "^1.0.0",
|
"electron-config": "^1.0.0",
|
||||||
"electron-gh-releases": "^2.0.4",
|
"electron-gh-releases": "^2.0.4",
|
||||||
@@ -79,7 +80,7 @@
|
|||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"jsonlint-mod": "^1.7.4",
|
"jsonlint-mod": "^1.7.4",
|
||||||
"katex": "^0.10.1",
|
"katex": "^0.10.1",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.19",
|
||||||
"lodash-move": "^1.1.1",
|
"lodash-move": "^1.1.1",
|
||||||
"markdown-it": "^6.0.1",
|
"markdown-it": "^6.0.1",
|
||||||
"markdown-it-abbr": "^1.0.4",
|
"markdown-it-abbr": "^1.0.4",
|
||||||
@@ -95,7 +96,7 @@
|
|||||||
"markdown-it-sup": "^1.0.0",
|
"markdown-it-sup": "^1.0.0",
|
||||||
"markdown-toc": "^1.2.0",
|
"markdown-toc": "^1.2.0",
|
||||||
"mdurl": "^1.0.1",
|
"mdurl": "^1.0.1",
|
||||||
"mermaid": "^8.4.2",
|
"mermaid": "^8.5.2",
|
||||||
"moment": "^2.10.3",
|
"moment": "^2.10.3",
|
||||||
"mousetrap": "^1.6.2",
|
"mousetrap": "^1.6.2",
|
||||||
"mousetrap-global-bind": "^1.1.0",
|
"mousetrap-global-bind": "^1.1.0",
|
||||||
@@ -185,7 +186,7 @@
|
|||||||
"stylus": "^0.52.4",
|
"stylus": "^0.52.4",
|
||||||
"stylus-loader": "^2.3.1",
|
"stylus-loader": "^2.3.1",
|
||||||
"webpack": "^1.12.2",
|
"webpack": "^1.12.2",
|
||||||
"webpack-dev-server": "^1.12.0"
|
"webpack-dev-server": "^3.1.11"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"grunt-electron-installer-debian": "^0.5.0",
|
"grunt-electron-installer-debian": "^0.5.0",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"trailingComma": "es5",
|
"singleQuote": true,
|
||||||
"tabWidth": 2,
|
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true
|
"jsxSingleQuote": true
|
||||||
}
|
}
|
||||||
26
readme.md
26
readme.md
@@ -1,4 +1,10 @@
|
|||||||
> [We've launched desktop app of the new Boost Note now. We'll release its mobile app too in January 2020.](https://github.com/BoostIO/BoostNote.next)
|
> [We've launched desktop and mobile app of the new Boost Note now.](https://github.com/BoostIO/BoostNote.next)
|
||||||
|
|
||||||
|
> ### [Boost Note for Teams](https://boosthub.io/)
|
||||||
|
>
|
||||||
|
> We've developed a collaborative workspace app called "Boost Hub" for developer teams.
|
||||||
|
>
|
||||||
|
> It's customizable and easy to optimize for your team like rego blocks and even lets you edit documents together in real-time!
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -15,6 +21,10 @@
|
|||||||
|
|
||||||
[Find the latest release of Boostnote here!](https://github.com/BoostIO/boost-releases/releases/)
|
[Find the latest release of Boostnote here!](https://github.com/BoostIO/boost-releases/releases/)
|
||||||
|
|
||||||
|
## Roadmap
|
||||||
|
|
||||||
|
[Boost Note Roadmap 2020](https://medium.com/boostnote/boost-note-roadmap-2020-9f06a642f5f1)
|
||||||
|
|
||||||
## Authors & Maintainers
|
## Authors & Maintainers
|
||||||
|
|
||||||
- [Rokt33r](https://github.com/rokt33r)
|
- [Rokt33r](https://github.com/rokt33r)
|
||||||
@@ -22,11 +32,13 @@
|
|||||||
- [ZeroX-DG](https://github.com/ZeroX-DG)
|
- [ZeroX-DG](https://github.com/ZeroX-DG)
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
Thank you to all the people who have contributed to Boostnote!
|
Thank you to all the people who have contributed to Boostnote!
|
||||||
|
|
||||||
<a href="https://github.com/BoostIO/Boostnote/graphs/contributors"><img src="https://opencollective.com/boostnoteio/contributors.svg?width=890" /></a>
|
<a href="https://github.com/BoostIO/Boostnote/graphs/contributors"><img src="https://opencollective.com/boostnoteio/contributors.svg?width=890" /></a>
|
||||||
|
|
||||||
## Supporting Boostnote
|
## Supporting Boostnote
|
||||||
|
|
||||||
Boostnote is an open source project. It's an independent project with its ongoing development made possible thanks to the support by our amazing backers.
|
Boostnote is an open source project. It's an independent project with its ongoing development made possible thanks to the support by our amazing backers.
|
||||||
|
|
||||||
Issues on Boostnote can be funded by anyone and the money will be distributed to contributors and maintainers. If you use Boostnote please consider becoming a backer:
|
Issues on Boostnote can be funded by anyone and the money will be distributed to contributors and maintainers. If you use Boostnote please consider becoming a backer:
|
||||||
@@ -34,18 +46,22 @@ Issues on Boostnote can be funded by anyone and the money will be distributed to
|
|||||||
[](https://issuehunt.io/repos/53266139)
|
[](https://issuehunt.io/repos/53266139)
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|
||||||
- [Facebook Group](https://www.facebook.com/groups/boostnote/)
|
- [Facebook Group](https://www.facebook.com/groups/boostnote/)
|
||||||
- [Twitter](https://twitter.com/boostnoteapp)
|
- [Twitter](https://twitter.com/boostnoteapp)
|
||||||
- [Slack Group](https://join.slack.com/t/boostnote-group/shared_invite/enQtMzkxOTk4ODkyNzc0LWQxZTQwNjBlMDI4YjkyYjg2MTRiZGJhNzA1YjQ5ODA5M2M0M2NlMjI5YjhiYWQzNzgzYmU0MDMwOTlmZmZmMGE)
|
- [Slack Group](https://join.slack.com/t/boostnote-group/shared_invite/zt-cun7pas3-WwkaezxHBB1lCbUHrwQLXw)
|
||||||
- [Blog](https://medium.com/boostnote)
|
- [Blog](https://medium.com/boostnote)
|
||||||
- [Reddit](https://www.reddit.com/r/Boostnote/)
|
- [Reddit](https://www.reddit.com/r/Boostnote/)
|
||||||
|
|
||||||
|
### Boostnote mobile
|
||||||
|
A community project developing a mobile cross-platform version of boostnote for iOS and Android can be found here: [NoteApp](https://github.com/T0M0F/NoteApp)
|
||||||
|
|
||||||
|
|
||||||
#### More Information
|
#### More Information
|
||||||
* Website: https://boostnote.io
|
|
||||||
* [Development](https://github.com/BoostIO/Boostnote/blob/master/docs/build.md): Development configurations for Boostnote.
|
|
||||||
* Copyright (C) 2016 - 2020 BoostIO, Inc.
|
|
||||||
|
|
||||||
|
- Website: https://boostnote.io
|
||||||
|
- [Development](https://github.com/BoostIO/Boostnote/blob/master/docs/build.md): Development configurations for Boostnote.
|
||||||
|
- Copyright (C) 2016 - 2020 BoostIO, Inc.
|
||||||
|
|
||||||
#### License
|
#### License
|
||||||
|
|
||||||
|
|||||||
@@ -685,19 +685,19 @@ it('should remove the all ":storage" and noteKey references', function() {
|
|||||||
' <p data-line="2">\n' +
|
' <p data-line="2">\n' +
|
||||||
' <img src="' +
|
' <img src="' +
|
||||||
storageFolder +
|
storageFolder +
|
||||||
path.sep +
|
path.posix.sep +
|
||||||
'0.6r4zdgc22xp.png" alt="dummyImage.png" >\n' +
|
'0.6r4zdgc22xp.png" alt="dummyImage.png" >\n' +
|
||||||
' </p>\n' +
|
' </p>\n' +
|
||||||
' <p data-line="4">\n' +
|
' <p data-line="4">\n' +
|
||||||
' <a href="' +
|
' <a href="' +
|
||||||
storageFolder +
|
storageFolder +
|
||||||
path.sep +
|
path.posix.sep +
|
||||||
'0.q2i4iw0fyx.pdf">dummyPDF.pdf</a>\n' +
|
'0.q2i4iw0fyx.pdf">dummyPDF.pdf</a>\n' +
|
||||||
' </p>\n' +
|
' </p>\n' +
|
||||||
' <p data-line="6">\n' +
|
' <p data-line="6">\n' +
|
||||||
' <img src="' +
|
' <img src="' +
|
||||||
storageFolder +
|
storageFolder +
|
||||||
path.sep +
|
path.posix.sep +
|
||||||
'd6c5ee92.jpg" alt="dummyImage2.jpg">\n' +
|
'd6c5ee92.jpg" alt="dummyImage2.jpg">\n' +
|
||||||
' </p>\n' +
|
' </p>\n' +
|
||||||
' </body>\n' +
|
' </body>\n' +
|
||||||
@@ -713,29 +713,29 @@ it('should make sure that "removeStorageAndNoteReferences" works with markdown c
|
|||||||
const noteKey = 'noteKey'
|
const noteKey = 'noteKey'
|
||||||
const testInput =
|
const testInput =
|
||||||
'Test input' +
|
'Test input' +
|
||||||
' \n' +
|
'image.jpg) \n' +
|
||||||
'[' +
|
'[pdf](' +
|
||||||
systemUnderTest.STORAGE_FOLDER_PLACEHOLDER +
|
systemUnderTest.STORAGE_FOLDER_PLACEHOLDER +
|
||||||
path.posix.sep +
|
path.posix.sep +
|
||||||
noteKey +
|
noteKey +
|
||||||
path.posix.sep +
|
path.posix.sep +
|
||||||
'pdf.pdf](pdf})'
|
'pdf.pdf)'
|
||||||
|
|
||||||
const expectedOutput =
|
const expectedOutput =
|
||||||
'Test input' +
|
'Test input' +
|
||||||
' \n' +
|
'image.jpg) \n' +
|
||||||
'[' +
|
'[pdf](' +
|
||||||
systemUnderTest.DESTINATION_FOLDER +
|
systemUnderTest.DESTINATION_FOLDER +
|
||||||
path.sep +
|
path.posix.sep +
|
||||||
'pdf.pdf](pdf})'
|
'pdf.pdf)'
|
||||||
const actual = systemUnderTest.removeStorageAndNoteReferences(
|
const actual = systemUnderTest.removeStorageAndNoteReferences(
|
||||||
testInput,
|
testInput,
|
||||||
noteKey
|
noteKey
|
||||||
@@ -912,6 +912,19 @@ it('should test that getAttachmentsPathAndStatus return null if noteKey, storage
|
|||||||
expect(result).toBeNull()
|
expect(result).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should test that getAttachmentsPathAndStatus return null if no storage found', function() {
|
||||||
|
const noteKey = 'test'
|
||||||
|
const storageKey = 'not_exist'
|
||||||
|
const markdownContent = ''
|
||||||
|
|
||||||
|
const result = systemUnderTest.getAttachmentsPathAndStatus(
|
||||||
|
markdownContent,
|
||||||
|
storageKey,
|
||||||
|
noteKey
|
||||||
|
)
|
||||||
|
expect(result).toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
it('should test that getAttachmentsPathAndStatus return the correct path and status for attachments', async function() {
|
it('should test that getAttachmentsPathAndStatus return the correct path and status for attachments', async function() {
|
||||||
const dummyStorage = { path: 'dummyStoragePath' }
|
const dummyStorage = { path: 'dummyStoragePath' }
|
||||||
const noteKey = 'noteKey'
|
const noteKey = 'noteKey'
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
const test = require('ava')
|
|
||||||
const copyFile = require('browser/main/lib/dataApi/copyFile')
|
const copyFile = require('browser/main/lib/dataApi/copyFile')
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
@@ -13,23 +12,25 @@ const srcPath = path.join(srcFolder, testFile)
|
|||||||
const dstFolder = path.join(__dirname, '😇')
|
const dstFolder = path.join(__dirname, '😇')
|
||||||
const dstPath = path.join(dstFolder, testFile)
|
const dstPath = path.join(dstFolder, testFile)
|
||||||
|
|
||||||
test.before(t => {
|
beforeAll(() => {
|
||||||
if (!fs.existsSync(srcFolder)) fs.mkdirSync(srcFolder)
|
if (!fs.existsSync(srcFolder)) fs.mkdirSync(srcFolder)
|
||||||
|
|
||||||
fs.writeFileSync(srcPath, 'test')
|
fs.writeFileSync(srcPath, 'test')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('`copyFile` should handle encoded URI on src path', t => {
|
it('`copyFile` should handle encoded URI on src path', done => {
|
||||||
return copyFile(encodeURI(srcPath), dstPath)
|
return copyFile(encodeURI(srcPath), dstPath)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
t.true(true)
|
expect(true).toBe(true)
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
t.true(false)
|
expect(false).toBe(true)
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.after(t => {
|
afterAll(() => {
|
||||||
fs.unlinkSync(srcPath)
|
fs.unlinkSync(srcPath)
|
||||||
fs.unlinkSync(dstPath)
|
fs.unlinkSync(dstPath)
|
||||||
execSync(removeDirCommand + '"' + srcFolder + '"')
|
execSync(removeDirCommand + '"' + srcFolder + '"')
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
const test = require('ava')
|
|
||||||
const createFolder = require('browser/main/lib/dataApi/createFolder')
|
const createFolder = require('browser/main/lib/dataApi/createFolder')
|
||||||
|
|
||||||
global.document = require('jsdom').jsdom('<body></body>')
|
global.document = require('jsdom').jsdom('<body></body>')
|
||||||
@@ -19,32 +18,34 @@ const CSON = require('@rokt33r/season')
|
|||||||
|
|
||||||
const storagePath = path.join(os.tmpdir(), 'test/create-folder')
|
const storagePath = path.join(os.tmpdir(), 'test/create-folder')
|
||||||
|
|
||||||
test.beforeEach(t => {
|
let storageContext
|
||||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
|
||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
beforeAll(() => {
|
||||||
|
storageContext = TestDummy.dummyStorage(storagePath)
|
||||||
|
localStorage.setItem('storages', JSON.stringify([storageContext.cache]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a folder', t => {
|
it('Create a folder', done => {
|
||||||
const storageKey = t.context.storage.cache.key
|
const storageKey = storageContext.cache.key
|
||||||
const input = {
|
const input = {
|
||||||
name: 'created',
|
name: 'created',
|
||||||
color: '#ff5555'
|
color: '#ff5555'
|
||||||
}
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest() {
|
.then(() => {
|
||||||
return createFolder(storageKey, input)
|
return createFolder(storageKey, input)
|
||||||
})
|
})
|
||||||
.then(function assert(data) {
|
.then(data => {
|
||||||
t.true(_.find(data.storage.folders, input) != null)
|
expect(_.find(data.storage.folders, input)).not.toBeNull()
|
||||||
const jsonData = CSON.readFileSync(
|
const jsonData = CSON.readFileSync(
|
||||||
path.join(data.storage.path, 'boostnote.json')
|
path.join(data.storage.path, 'boostnote.json')
|
||||||
)
|
)
|
||||||
console.log(path.join(data.storage.path, 'boostnote.json'))
|
expect(_.find(jsonData.folders, input)).not.toBeNull()
|
||||||
t.true(_.find(jsonData.folders, input) != null)
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.after(function after() {
|
afterAll(() => {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
sander.rimrafSync(storagePath)
|
sander.rimrafSync(storagePath)
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
const test = require('ava')
|
|
||||||
const createNote = require('browser/main/lib/dataApi/createNote')
|
const createNote = require('browser/main/lib/dataApi/createNote')
|
||||||
|
|
||||||
global.document = require('jsdom').jsdom('<body></body>')
|
global.document = require('jsdom').jsdom('<body></body>')
|
||||||
@@ -19,14 +18,16 @@ const faker = require('faker')
|
|||||||
|
|
||||||
const storagePath = path.join(os.tmpdir(), 'test/create-note')
|
const storagePath = path.join(os.tmpdir(), 'test/create-note')
|
||||||
|
|
||||||
test.beforeEach(t => {
|
let storageContext
|
||||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
|
||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
beforeEach(() => {
|
||||||
|
storageContext = TestDummy.dummyStorage(storagePath)
|
||||||
|
localStorage.setItem('storages', JSON.stringify([storageContext.cache]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a note', t => {
|
it('Create a note', done => {
|
||||||
const storageKey = t.context.storage.cache.key
|
const storageKey = storageContext.cache.key
|
||||||
const folderKey = t.context.storage.json.folders[0].key
|
const folderKey = storageContext.json.folders[0].key
|
||||||
|
|
||||||
const randLinesHighlightedArray = new Array(10)
|
const randLinesHighlightedArray = new Array(10)
|
||||||
.fill()
|
.fill()
|
||||||
@@ -58,58 +59,58 @@ test.serial('Create a note', t => {
|
|||||||
input2.title = input2.content.split('\n').shift()
|
input2.title = input2.content.split('\n').shift()
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest() {
|
.then(() => {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
createNote(storageKey, input1),
|
createNote(storageKey, input1),
|
||||||
createNote(storageKey, input2)
|
createNote(storageKey, input2)
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
.then(function assert(data) {
|
.then(data => {
|
||||||
const data1 = data[0]
|
const data1 = data[0]
|
||||||
const data2 = data[1]
|
const data2 = data[1]
|
||||||
|
|
||||||
t.is(storageKey, data1.storage)
|
expect(storageKey).toEqual(data1.storage)
|
||||||
const jsonData1 = CSON.readFileSync(
|
const jsonData1 = CSON.readFileSync(
|
||||||
path.join(storagePath, 'notes', data1.key + '.cson')
|
path.join(storagePath, 'notes', data1.key + '.cson')
|
||||||
)
|
)
|
||||||
|
|
||||||
t.is(input1.title, data1.title)
|
expect(input1.title).toEqual(data1.title)
|
||||||
t.is(input1.title, jsonData1.title)
|
expect(input1.title).toEqual(jsonData1.title)
|
||||||
t.is(input1.description, data1.description)
|
expect(input1.description).toEqual(data1.description)
|
||||||
t.is(input1.description, jsonData1.description)
|
expect(input1.description).toEqual(jsonData1.description)
|
||||||
t.is(input1.tags.length, data1.tags.length)
|
expect(input1.tags.length).toEqual(data1.tags.length)
|
||||||
t.is(input1.tags.length, jsonData1.tags.length)
|
expect(input1.tags.length).toEqual(jsonData1.tags.length)
|
||||||
t.is(input1.snippets.length, data1.snippets.length)
|
expect(input1.snippets.length).toEqual(data1.snippets.length)
|
||||||
t.is(input1.snippets.length, jsonData1.snippets.length)
|
expect(input1.snippets.length).toEqual(jsonData1.snippets.length)
|
||||||
t.is(input1.snippets[0].content, data1.snippets[0].content)
|
expect(input1.snippets[0].content).toEqual(data1.snippets[0].content)
|
||||||
t.is(input1.snippets[0].content, jsonData1.snippets[0].content)
|
expect(input1.snippets[0].content).toEqual(jsonData1.snippets[0].content)
|
||||||
t.is(input1.snippets[0].name, data1.snippets[0].name)
|
expect(input1.snippets[0].name).toEqual(data1.snippets[0].name)
|
||||||
t.is(input1.snippets[0].name, jsonData1.snippets[0].name)
|
expect(input1.snippets[0].name).toEqual(jsonData1.snippets[0].name)
|
||||||
t.deepEqual(
|
expect(input1.snippets[0].linesHighlighted).toEqual(
|
||||||
input1.snippets[0].linesHighlighted,
|
|
||||||
data1.snippets[0].linesHighlighted
|
data1.snippets[0].linesHighlighted
|
||||||
)
|
)
|
||||||
t.deepEqual(
|
expect(input1.snippets[0].linesHighlighted).toEqual(
|
||||||
input1.snippets[0].linesHighlighted,
|
|
||||||
jsonData1.snippets[0].linesHighlighted
|
jsonData1.snippets[0].linesHighlighted
|
||||||
)
|
)
|
||||||
|
|
||||||
t.is(storageKey, data2.storage)
|
expect(storageKey).toEqual(data2.storage)
|
||||||
const jsonData2 = CSON.readFileSync(
|
const jsonData2 = CSON.readFileSync(
|
||||||
path.join(storagePath, 'notes', data2.key + '.cson')
|
path.join(storagePath, 'notes', data2.key + '.cson')
|
||||||
)
|
)
|
||||||
t.is(input2.title, data2.title)
|
expect(input2.title).toEqual(data2.title)
|
||||||
t.is(input2.title, jsonData2.title)
|
expect(input2.title).toEqual(jsonData2.title)
|
||||||
t.is(input2.content, data2.content)
|
expect(input2.content).toEqual(data2.content)
|
||||||
t.is(input2.content, jsonData2.content)
|
expect(input2.content).toEqual(jsonData2.content)
|
||||||
t.is(input2.tags.length, data2.tags.length)
|
expect(input2.tags.length).toEqual(data2.tags.length)
|
||||||
t.is(input2.tags.length, jsonData2.tags.length)
|
expect(input2.tags.length).toEqual(jsonData2.tags.length)
|
||||||
t.deepEqual(input2.linesHighlighted, data2.linesHighlighted)
|
expect(input2.linesHighlighted).toEqual(data2.linesHighlighted)
|
||||||
t.deepEqual(input2.linesHighlighted, jsonData2.linesHighlighted)
|
expect(input2.linesHighlighted).toEqual(jsonData2.linesHighlighted)
|
||||||
|
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.after(function after() {
|
afterAll(function after() {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
sander.rimrafSync(storagePath)
|
sander.rimrafSync(storagePath)
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
const test = require('ava')
|
|
||||||
const createNoteFromUrl = require('browser/main/lib/dataApi/createNoteFromUrl')
|
const createNoteFromUrl = require('browser/main/lib/dataApi/createNoteFromUrl')
|
||||||
|
|
||||||
global.document = require('jsdom').jsdom('<body></body>')
|
global.document = require('jsdom').jsdom('<body></body>')
|
||||||
@@ -18,32 +17,34 @@ const CSON = require('@rokt33r/season')
|
|||||||
|
|
||||||
const storagePath = path.join(os.tmpdir(), 'test/create-note-from-url')
|
const storagePath = path.join(os.tmpdir(), 'test/create-note-from-url')
|
||||||
|
|
||||||
test.beforeEach(t => {
|
let storageContext
|
||||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
|
||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
beforeEach(() => {
|
||||||
|
storageContext = TestDummy.dummyStorage(storagePath)
|
||||||
|
localStorage.setItem('storages', JSON.stringify([storageContext.cache]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a note from URL', t => {
|
it('Create a note from URL', () => {
|
||||||
const storageKey = t.context.storage.cache.key
|
const storageKey = storageContext.cache.key
|
||||||
const folderKey = t.context.storage.json.folders[0].key
|
const folderKey = storageContext.json.folders[0].key
|
||||||
|
|
||||||
const url = 'https://shapeshed.com/writing-cross-platform-node/'
|
const url = 'https://shapeshed.com/writing-cross-platform-node/'
|
||||||
|
|
||||||
return createNoteFromUrl(url, storageKey, folderKey).then(function assert({
|
return createNoteFromUrl(url, storageKey, folderKey).then(function assert({
|
||||||
note
|
note
|
||||||
}) {
|
}) {
|
||||||
t.is(storageKey, note.storage)
|
expect(storageKey).toEqual(note.storage)
|
||||||
const jsonData = CSON.readFileSync(
|
const jsonData = CSON.readFileSync(
|
||||||
path.join(storagePath, 'notes', note.key + '.cson')
|
path.join(storagePath, 'notes', note.key + '.cson')
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test if saved content is matching the created in memory note
|
// Test if saved content is matching the created in memory note
|
||||||
t.is(note.content, jsonData.content)
|
expect(note.content).toEqual(jsonData.content)
|
||||||
t.is(note.tags.length, jsonData.tags.length)
|
expect(note.tags.length).toEqual(jsonData.tags.length)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.after(function after() {
|
afterAll(function after() {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
sander.rimrafSync(storagePath)
|
sander.rimrafSync(storagePath)
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
const test = require('ava')
|
|
||||||
const createSnippet = require('browser/main/lib/dataApi/createSnippet')
|
const createSnippet = require('browser/main/lib/dataApi/createSnippet')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
@@ -7,29 +6,27 @@ const path = require('path')
|
|||||||
const snippetFilePath = path.join(os.tmpdir(), 'test', 'create-snippet')
|
const snippetFilePath = path.join(os.tmpdir(), 'test', 'create-snippet')
|
||||||
const snippetFile = path.join(snippetFilePath, 'snippets.json')
|
const snippetFile = path.join(snippetFilePath, 'snippets.json')
|
||||||
|
|
||||||
test.beforeEach(t => {
|
beforeEach(() => {
|
||||||
sander.writeFileSync(snippetFile, '[]')
|
sander.writeFileSync(snippetFile, '[]')
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a snippet', t => {
|
it('Create a snippet', () => {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest() {
|
.then(() => Promise.all([createSnippet(snippetFile)]))
|
||||||
return Promise.all([createSnippet(snippetFile)])
|
|
||||||
})
|
|
||||||
.then(function assert(data) {
|
.then(function assert(data) {
|
||||||
data = data[0]
|
data = data[0]
|
||||||
const snippets = JSON.parse(sander.readFileSync(snippetFile))
|
const snippets = JSON.parse(sander.readFileSync(snippetFile))
|
||||||
const snippet = snippets.find(
|
const snippet = snippets.find(
|
||||||
currentSnippet => currentSnippet.id === data.id
|
currentSnippet => currentSnippet.id === data.id
|
||||||
)
|
)
|
||||||
t.not(snippet, undefined)
|
expect(snippet).not.toBeUndefined()
|
||||||
t.is(snippet.name, data.name)
|
expect(snippet.name).toEqual(data.name)
|
||||||
t.deepEqual(snippet.prefix, data.prefix)
|
expect(snippet.prefix).toEqual(data.prefix)
|
||||||
t.is(snippet.content, data.content)
|
expect(snippet.content).toEqual(data.content)
|
||||||
t.deepEqual(snippet.linesHighlighted, data.linesHighlighted)
|
expect(snippet.linesHighlighted).toEqual(data.linesHighlighted)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.after.always(() => {
|
afterAll(() => {
|
||||||
sander.rimrafSync(snippetFilePath)
|
sander.rimrafSync(snippetFilePath)
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
const test = require('ava')
|
|
||||||
const deleteFolder = require('browser/main/lib/dataApi/deleteFolder')
|
const deleteFolder = require('browser/main/lib/dataApi/deleteFolder')
|
||||||
const attachmentManagement = require('browser/main/lib/dataApi/attachmentManagement')
|
const attachmentManagement = require('browser/main/lib/dataApi/attachmentManagement')
|
||||||
const createNote = require('browser/main/lib/dataApi/createNote')
|
const createNote = require('browser/main/lib/dataApi/createNote')
|
||||||
@@ -23,14 +22,16 @@ const CSON = require('@rokt33r/season')
|
|||||||
|
|
||||||
const storagePath = path.join(os.tmpdir(), 'test/delete-folder')
|
const storagePath = path.join(os.tmpdir(), 'test/delete-folder')
|
||||||
|
|
||||||
test.beforeEach(t => {
|
let storageContext
|
||||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
|
||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
beforeEach(() => {
|
||||||
|
storageContext = TestDummy.dummyStorage(storagePath)
|
||||||
|
localStorage.setItem('storages', JSON.stringify([storageContext.cache]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Delete a folder', t => {
|
it('Delete a folder', () => {
|
||||||
const storageKey = t.context.storage.cache.key
|
const storageKey = storageContext.cache.key
|
||||||
const folderKey = t.context.storage.json.folders[0].key
|
const folderKey = storageContext.json.folders[0].key
|
||||||
let noteKey
|
let noteKey
|
||||||
|
|
||||||
const input1 = {
|
const input1 = {
|
||||||
@@ -72,16 +73,15 @@ test.serial('Delete a folder', t => {
|
|||||||
return deleteFolder(storageKey, folderKey)
|
return deleteFolder(storageKey, folderKey)
|
||||||
})
|
})
|
||||||
.then(function assert(data) {
|
.then(function assert(data) {
|
||||||
t.true(_.find(data.storage.folders, { key: folderKey }) == null)
|
expect(_.find(data.storage.folders, { key: folderKey })).toBeUndefined()
|
||||||
const jsonData = CSON.readFileSync(
|
const jsonData = CSON.readFileSync(
|
||||||
path.join(data.storage.path, 'boostnote.json')
|
path.join(data.storage.path, 'boostnote.json')
|
||||||
)
|
)
|
||||||
|
|
||||||
t.true(_.find(jsonData.folders, { key: folderKey }) == null)
|
expect(_.find(jsonData.folders, { key: folderKey })).toBeUndefined()
|
||||||
const notePaths = sander.readdirSync(data.storage.path, 'notes')
|
const notePaths = sander.readdirSync(data.storage.path, 'notes')
|
||||||
t.is(
|
expect(notePaths.length).toBe(
|
||||||
notePaths.length,
|
storageContext.notes.filter(note => note.folder !== folderKey).length
|
||||||
t.context.storage.notes.filter(note => note.folder !== folderKey).length
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const attachmentFolderPath = path.join(
|
const attachmentFolderPath = path.join(
|
||||||
@@ -89,11 +89,11 @@ test.serial('Delete a folder', t => {
|
|||||||
attachmentManagement.DESTINATION_FOLDER,
|
attachmentManagement.DESTINATION_FOLDER,
|
||||||
noteKey
|
noteKey
|
||||||
)
|
)
|
||||||
t.false(fs.existsSync(attachmentFolderPath))
|
expect(fs.existsSync(attachmentFolderPath)).toBe(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.after.always(function after() {
|
afterAll(() => {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
sander.rimrafSync(storagePath)
|
sander.rimrafSync(storagePath)
|
||||||
})
|
})
|
||||||
189
tests/lib/__snapshots__/markdown.test.js.snap
Normal file
189
tests/lib/__snapshots__/markdown.test.js.snap
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render PlantUML Ditaa correctly 1`] = `
|
||||||
|
"<img src=\\"http://www.plantuml.com/plantuml/png/SoWkIImgISaiIKpaqjQ50cq51GLj93Q2mrMZ00NQO3cmHX3RJW4cKmDI4v9QKQ805a8nfyObCp6zA34NgCObFxiqDpMl1AIcHj4tCJqpLH5i18evG52TKbk3B8og1kmC0cvMKB1Im0NYkA2ckMRcANWabgQbvYau5YMbPfP0p4UOWmcqkHnIyrB0GG00\\" alt=\\"uml diagram\\" />
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render PlantUML Gantt correctly 1`] = `
|
||||||
|
"<img src=\\"http://www.plantuml.com/plantuml/svg/SoWkIImgIK_CAodXYWueoY_9BwaiI5L8IItEJC-BLSX9B2ufLZ0qLKX9h2pcYWv9BIvHA82fWaiRu906crsia5YYW6cqUh52QbuAbmEG0DiE0000\\" alt=\\"uml diagram\\" />
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render PlantUML MindMaps correctly 1`] = `
|
||||||
|
"<img src=\\"http://www.plantuml.com/plantuml/svg/JOzD3e8m44Rtd6BMtNW192IM5I29HEDsAbKdeLD2MvNRIsjCMCsRlFd9LpgFipV4Wy4f4o2r8kHC23Yhm3wi9A0X3XzeYNrgwx1H6wvb1KTjqtRJoYhMtexBSAqJUescwoEUq4tn3xp9Fm7XfUS5HiiFO3Gw7SjT4QUCkkKxLy2-WAvl3rkrtEclBdOCXcnMwZN7ByiN\\" alt=\\"uml diagram\\" />
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render PlantUML Umls correctly 1`] = `
|
||||||
|
"<img src=\\"http://www.plantuml.com/plantuml/svg/LOzD2eCm44RtESMtj0jx01V5E_G4Gvngo2_912gbTsz4LBfylCV7p5Y4ibJlbEENG2AocHV1P39hCJ6eOar8bCaZaROqyrDMnzWqXTcn8YqnGzSYqNC-q76sweoW5zOsLi57uMpHz-WESslY0jmVw1AjdaE30IPeLoVUceLTslrL3-2tS9ZA_qZRtm_vgh7PzkOF\\" alt=\\"uml diagram\\" />
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render PlantUML WBS correctly 1`] = `
|
||||||
|
"<img src=\\"http://www.plantuml.com/plantuml/svg/ZP2_JiD03CRtFeNdRF04fR140gdGeREv-z8plVYYimFYxSabKbaxsR9-ylTdRyxLVpvjrz5XDb6OqR6MqEPRYSXPz4BdmsdNTVJAiuP4da1JBLy8lbmxUYxZbE6Wa_CLgUI8IXymS0rf9NeL5yxKDt24EhiKfMDcRNzVO79HcX8RLdvLfZBGa_KtFx2RKcpK7TZ3dTpZfWgskMAZ9jIXr94rW4PubM1RbBZOb-6NtcS9LpgBjlj_1w9QldbPjZHxQ5pg_GC0\\" alt=\\"uml diagram\\" />
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render footnote correctly 1`] = `
|
||||||
|
"<p data-line=\\"1\\"><sup class=\\"footnote-ref\\"><a href=\\"#fn1\\" id=\\"fnref1\\">[1]</a></sup><br />
|
||||||
|
hello-world: <a href=\\"https://github.com/BoostIO/Boostnote/\\">https://github.com/BoostIO/Boostnote/</a></p>
|
||||||
|
<hr class=\\"footnotes-sep\\" />
|
||||||
|
<section class=\\"footnotes\\">
|
||||||
|
<ol class=\\"footnotes-list\\">
|
||||||
|
<li id=\\"fn1\\" class=\\"footnote-item\\"><p>hello-world <a href=\\"#fnref1\\" class=\\"footnote-backref\\">↩︎</a></p>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render line breaks correctly 1`] = `
|
||||||
|
"<p data-line=\\"0\\">This is the first line.<br />
|
||||||
|
This is the second line.</p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render line breaks correctly 2`] = `
|
||||||
|
"<p data-line=\\"0\\">This is the first line.
|
||||||
|
This is the second line.</p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should render shortcuts correctly 1`] = `
|
||||||
|
"<p data-line=\\"0\\"><kbd>Ctrl</kbd></p>
|
||||||
|
<p data-line=\\"2\\"><kbd>Ctrl</kbd></p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders [TOC] placholder correctly 1`] = `
|
||||||
|
"<p data-line=\\"1\\"><div class=\\"markdownIt-TOC-wrapper\\"><ul class=\\"markdownIt-TOC\\">
|
||||||
|
<li><a href=\\"#H1\\">H1</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href=\\"#H2\\">H2</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href=\\"#H3\\">H3</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div></p>
|
||||||
|
<h1 id=\\"H1\\" data-line=\\"2\\">H1</h1>
|
||||||
|
<h2 id=\\"H2\\" data-line=\\"3\\">H2</h2>
|
||||||
|
<h3 id=\\"H3\\" data-line=\\"4\\">H3</h3>
|
||||||
|
<p data-line=\\"5\\">###$ H4</p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders KaTeX correctly 1`] = `
|
||||||
|
"<span class=\\"katex-display\\"><span class=\\"katex\\"><span class=\\"katex-mathml\\"><math><semantics><mrow><mi>c</mi><mo>=</mo><mi>p</mi><mi>m</mi><mi>s</mi><mi>q</mi><mi>r</mi><mi>t</mi><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></mrow><annotation encoding=\\"application/x-tex\\">c = pmsqrt{a^2 + b^2}</annotation></semantics></math></span><span class=\\"katex-html\\" aria-hidden=\\"true\\"><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:0.43056em;vertical-align:0em;\\"></span><span class=\\"mord mathdefault\\">c</span><span class=\\"mspace\\" style=\\"margin-right:0.2777777777777778em;\\"></span><span class=\\"mrel\\">=</span><span class=\\"mspace\\" style=\\"margin-right:0.2777777777777778em;\\"></span></span><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:1.0585479999999998em;vertical-align:-0.19444em;\\"></span><span class=\\"mord mathdefault\\">p</span><span class=\\"mord mathdefault\\">m</span><span class=\\"mord mathdefault\\">s</span><span class=\\"mord mathdefault\\" style=\\"margin-right:0.03588em;\\">q</span><span class=\\"mord mathdefault\\" style=\\"margin-right:0.02778em;\\">r</span><span class=\\"mord mathdefault\\">t</span><span class=\\"mord\\"><span class=\\"mord\\"><span class=\\"mord mathdefault\\">a</span><span class=\\"msupsub\\"><span class=\\"vlist-t\\"><span class=\\"vlist-r\\"><span class=\\"vlist\\" style=\\"height:0.8641079999999999em;\\"><span style=\\"top:-3.113em;margin-right:0.05em;\\"><span class=\\"pstrut\\" style=\\"height:2.7em;\\"></span><span class=\\"sizing reset-size6 size3 mtight\\"><span class=\\"mord mtight\\">2</span></span></span></span></span></span></span></span><span class=\\"mspace\\" style=\\"margin-right:0.2222222222222222em;\\"></span><span class=\\"mbin\\">+</span><span class=\\"mspace\\" style=\\"margin-right:0.2222222222222222em;\\"></span><span class=\\"mord\\"><span class=\\"mord mathdefault\\">b</span><span class=\\"msupsub\\"><span class=\\"vlist-t\\"><span class=\\"vlist-r\\"><span class=\\"vlist\\" style=\\"height:0.8641079999999999em;\\"><span style=\\"top:-3.113em;margin-right:0.05em;\\"><span class=\\"pstrut\\" style=\\"height:2.7em;\\"></span><span class=\\"sizing reset-size6 size3 mtight\\"><span class=\\"mord mtight\\">2</span></span></span></span></span></span></span></span></span></span></span></span></span>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders abbrevations correctly 1`] = `
|
||||||
|
"<h2 id=\\"abbr\\" data-line=\\"1\\">abbr</h2>
|
||||||
|
<p data-line=\\"3\\">The <abbr title=\\"Hyper Text Markup Language\\">HTML</abbr> specification<br />
|
||||||
|
is maintained by the <abbr title=\\"World Wide Web Consortium\\">W3C</abbr>.</p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders checkboxes 1`] = `
|
||||||
|
"<ul>
|
||||||
|
<li class=\\"taskListItem\\" data-line=\\"1\\"><input type=\\"checkbox\\" id=\\"checkbox-2\\" /> Unchecked</li>
|
||||||
|
<li class=\\"taskListItem checked\\" data-line=\\"2\\"><input type=\\"checkbox\\" checked id=\\"checkbox-3\\" /> Checked</li>
|
||||||
|
</ul>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders codeblock correctly 1`] = `
|
||||||
|
"<pre class=\\"code CodeMirror\\" data-line=\\"1\\">
|
||||||
|
<span class=\\"filename\\">filename.js</span>
|
||||||
|
<span class=\\"lineNumber CodeMirror-gutters\\"><span class=\\"CodeMirror-linenumber\\">2</span></span>
|
||||||
|
<code class=\\"js\\">var project = 'boostnote';
|
||||||
|
</code>
|
||||||
|
</pre>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders definition lists correctly 1`] = `
|
||||||
|
"<h2 id=\\"definition-list\\" data-line=\\"1\\">definition list</h2>
|
||||||
|
<h3 id=\\"list-1\\" data-line=\\"3\\">list 1</h3>
|
||||||
|
<dl>
|
||||||
|
<dt data-line=\\"5\\">Term 1</dt>
|
||||||
|
<dd data-line=\\"6\\">Definition 1</dd>
|
||||||
|
<dt data-line=\\"8\\">Term 2</dt>
|
||||||
|
<dd data-line=\\"9\\">Definition 2a</dd>
|
||||||
|
<dd data-line=\\"10\\">Definition 2b</dd>
|
||||||
|
</dl>
|
||||||
|
<p data-line=\\"12\\">Term 3<br />
|
||||||
|
~</p>
|
||||||
|
<h3 id=\\"list-2\\" data-line=\\"16\\">list 2</h3>
|
||||||
|
<dl>
|
||||||
|
<dt data-line=\\"18\\">Term 1</dt>
|
||||||
|
<dd data-line=\\"20\\">
|
||||||
|
<p data-line=\\"20\\">Definition 1</p>
|
||||||
|
</dd>
|
||||||
|
<dt data-line=\\"22\\">Term 2 with <em>inline markup</em></dt>
|
||||||
|
<dd data-line=\\"24\\">
|
||||||
|
<p data-line=\\"24\\">Definition 2</p>
|
||||||
|
<pre><code> { some code, part of Definition 2 }
|
||||||
|
</code></pre>
|
||||||
|
<p data-line=\\"28\\">Third paragraph of definition 2.</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders markdown correctly 1`] = `
|
||||||
|
"<h1 id=\\"Welcome-to-Boostnote\\" data-line=\\"1\\">Welcome to Boostnote!</h1>
|
||||||
|
<h2 id=\\"Click-here-to-edit-markdown\\" data-line=\\"2\\">Click here to edit markdown 👋</h2>
|
||||||
|
<iframe width=\\"560\\" height=\\"315\\" src=\\"https://www.youtube.com/embed/L0qNPLsvmyM\\" frameborder=\\"0\\" allowfullscreen></iframe>
|
||||||
|
<h2 id=\\"Docs\\" data-line=\\"6\\">Docs 📝</h2>
|
||||||
|
<ul>
|
||||||
|
<li data-line=\\"7\\"><a href=\\"https://hackernoon.com/boostnote-boost-your-happiness-productivity-and-creativity-315034efeebe\\">Boostnote | Boost your happiness, productivity and creativity.</a></li>
|
||||||
|
<li data-line=\\"8\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Cloud-Syncing-and-Backup\\">Cloud Syncing & Backups</a></li>
|
||||||
|
<li data-line=\\"9\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Sync-Data-Across-Desktop-and-Mobile-apps\\">How to sync your data across Desktop and Mobile apps</a></li>
|
||||||
|
<li data-line=\\"10\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Evernote\\">Convert data from <strong>Evernote</strong> to Boostnote.</a></li>
|
||||||
|
<li data-line=\\"11\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Keyboard-Shortcuts\\">Keyboard Shortcuts</a></li>
|
||||||
|
<li data-line=\\"12\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Keymaps-in-Editor-mode\\">Keymaps in Editor mode</a></li>
|
||||||
|
<li data-line=\\"13\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Syntax-Highlighting\\">How to set syntax highlight in Snippet note</a></li>
|
||||||
|
</ul>
|
||||||
|
<hr />
|
||||||
|
<h2 id=\\"Article-Archive\\" data-line=\\"17\\">Article Archive 📚</h2>
|
||||||
|
<ul>
|
||||||
|
<li data-line=\\"18\\"><a href=\\"http://bit.ly/2mOJPu7\\">Reddit English</a></li>
|
||||||
|
<li data-line=\\"19\\"><a href=\\"https://www.reddit.com/r/boostnote_es/\\">Reddit Spanish</a></li>
|
||||||
|
<li data-line=\\"20\\"><a href=\\"https://www.reddit.com/r/boostnote_cn/\\">Reddit Chinese</a></li>
|
||||||
|
<li data-line=\\"21\\"><a href=\\"https://www.reddit.com/r/boostnote_jp/\\">Reddit Japanese</a></li>
|
||||||
|
</ul>
|
||||||
|
<hr />
|
||||||
|
<h2 id=\\"Community\\" data-line=\\"25\\">Community 🍻</h2>
|
||||||
|
<ul>
|
||||||
|
<li data-line=\\"26\\"><a href=\\"http://bit.ly/2AWWzkD\\">GitHub</a></li>
|
||||||
|
<li data-line=\\"27\\"><a href=\\"http://bit.ly/2z8BUJZ\\">Twitter</a></li>
|
||||||
|
<li data-line=\\"28\\"><a href=\\"http://bit.ly/2jcca8t\\">Facebook Group</a></li>
|
||||||
|
</ul>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders sub correctly 1`] = `
|
||||||
|
"<h2 id=\\"sub\\" data-line=\\"1\\">sub</h2>
|
||||||
|
<p data-line=\\"3\\">H<sub>2</sub>0</p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should renders sup correctly 1`] = `
|
||||||
|
"<h2 id=\\"sup\\" data-line=\\"1\\">sup</h2>
|
||||||
|
<p data-line=\\"3\\">29<sup>th</sup></p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should text with quotes correctly 1`] = `
|
||||||
|
"<p data-line=\\"0\\">This is a “QUOTE”.</p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Markdown.render() should text with quotes correctly 2`] = `
|
||||||
|
"<p data-line=\\"0\\">This is a "QUOTE".</p>
|
||||||
|
"
|
||||||
|
`;
|
||||||
@@ -1,46 +1,45 @@
|
|||||||
const { escapeHtmlCharacters } = require('browser/lib/utils')
|
const { escapeHtmlCharacters } = require('browser/lib/utils')
|
||||||
const test = require('ava')
|
|
||||||
|
|
||||||
test('escapeHtmlCharacters should return the original string if nothing needed to escape', t => {
|
test('escapeHtmlCharacters should return the original string if nothing needed to escape', () => {
|
||||||
const input = 'Nothing to be escaped'
|
const input = 'Nothing to be escaped'
|
||||||
const expected = 'Nothing to be escaped'
|
const expected = 'Nothing to be escaped'
|
||||||
const actual = escapeHtmlCharacters(input)
|
const actual = escapeHtmlCharacters(input)
|
||||||
t.is(actual, expected)
|
expect(actual).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('escapeHtmlCharacters should skip code block if that option is enabled', t => {
|
test('escapeHtmlCharacters should skip code block if that option is enabled', () => {
|
||||||
const input = ` <no escape>
|
const input = ` <no escape>
|
||||||
<escapeMe>`
|
<escapeMe>`
|
||||||
const expected = ` <no escape>
|
const expected = ` <no escape>
|
||||||
<escapeMe>`
|
<escapeMe>`
|
||||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||||
t.is(actual, expected)
|
expect(actual).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('escapeHtmlCharacters should NOT skip character not in code block but start with 4 spaces', t => {
|
test('escapeHtmlCharacters should NOT skip character not in code block but start with 4 spaces', () => {
|
||||||
const input = '4 spaces &'
|
const input = '4 spaces &'
|
||||||
const expected = '4 spaces &'
|
const expected = '4 spaces &'
|
||||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||||
t.is(actual, expected)
|
expect(actual).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('escapeHtmlCharacters should NOT skip code block if that option is NOT enabled', t => {
|
test('escapeHtmlCharacters should NOT skip code block if that option is NOT enabled', () => {
|
||||||
const input = ` <no escape>
|
const input = ` <no escape>
|
||||||
<escapeMe>`
|
<escapeMe>`
|
||||||
const expected = ` <no escape>
|
const expected = ` <no escape>
|
||||||
<escapeMe>`
|
<escapeMe>`
|
||||||
const actual = escapeHtmlCharacters(input)
|
const actual = escapeHtmlCharacters(input)
|
||||||
t.is(actual, expected)
|
expect(actual).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("escapeHtmlCharacters should NOT escape & character if it's a part of an escaped character", t => {
|
test("escapeHtmlCharacters should NOT escape & character if it's a part of an escaped character", () => {
|
||||||
const input = 'Do not escape & or " but do escape &'
|
const input = 'Do not escape & or " but do escape &'
|
||||||
const expected = 'Do not escape & or " but do escape &'
|
const expected = 'Do not escape & or " but do escape &'
|
||||||
const actual = escapeHtmlCharacters(input)
|
const actual = escapeHtmlCharacters(input)
|
||||||
t.is(actual, expected)
|
expect(actual).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('escapeHtmlCharacters should skip char if in code block', t => {
|
test('escapeHtmlCharacters should skip char if in code block', () => {
|
||||||
const input = `
|
const input = `
|
||||||
\`\`\`
|
\`\`\`
|
||||||
<dontescapeme>
|
<dontescapeme>
|
||||||
@@ -62,12 +61,12 @@ dasdasdasd
|
|||||||
\`\`\`
|
\`\`\`
|
||||||
`
|
`
|
||||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||||
t.is(actual, expected)
|
expect(actual).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('escapeHtmlCharacters should return the correct result', t => {
|
test('escapeHtmlCharacters should return the correct result', () => {
|
||||||
const input = '& < > " \''
|
const input = '& < > " \''
|
||||||
const expected = '& < > " ''
|
const expected = '& < > " ''
|
||||||
const actual = escapeHtmlCharacters(input)
|
const actual = escapeHtmlCharacters(input)
|
||||||
t.is(actual, expected)
|
expect(actual).toBe(expected)
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
const test = require('ava')
|
|
||||||
const { findStorage } = require('browser/lib/findStorage')
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
global.document = require('jsdom').jsdom('<body></body>')
|
global.document = require('jsdom').jsdom('<body></body>')
|
||||||
@@ -16,20 +15,22 @@ const sander = require('sander')
|
|||||||
const os = require('os')
|
const os = require('os')
|
||||||
const storagePath = path.join(os.tmpdir(), 'test/find-storage')
|
const storagePath = path.join(os.tmpdir(), 'test/find-storage')
|
||||||
|
|
||||||
test.beforeEach(t => {
|
let storageContext
|
||||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
|
||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
beforeEach(() => {
|
||||||
|
storageContext = TestDummy.dummyStorage(storagePath)
|
||||||
|
localStorage.setItem('storages', JSON.stringify([storageContext.cache]))
|
||||||
})
|
})
|
||||||
|
|
||||||
// Unit test
|
// Unit test
|
||||||
test('findStorage() should return a correct storage path(string)', t => {
|
test('findStorage() should return a correct storage path(string)', () => {
|
||||||
const storageKey = t.context.storage.cache.key
|
const storageKey = storageContext.cache.key
|
||||||
|
|
||||||
t.is(findStorage(storageKey).key, storageKey)
|
expect(findStorage(storageKey).key).toBe(storageKey)
|
||||||
t.is(findStorage(storageKey).path, storagePath)
|
expect(findStorage(storageKey).path).toBe(storagePath)
|
||||||
})
|
})
|
||||||
|
|
||||||
test.after(function after() {
|
afterAll(function after() {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
sander.rimrafSync(storagePath)
|
sander.rimrafSync(storagePath)
|
||||||
})
|
})
|
||||||
@@ -2,11 +2,10 @@
|
|||||||
* @fileoverview Unit test for browser/lib/findTitle
|
* @fileoverview Unit test for browser/lib/findTitle
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const test = require('ava')
|
|
||||||
const { findNoteTitle } = require('browser/lib/findNoteTitle')
|
const { findNoteTitle } = require('browser/lib/findNoteTitle')
|
||||||
|
|
||||||
// Unit test
|
// Unit test
|
||||||
test('findNoteTitle#find should return a correct title (string)', t => {
|
test('findNoteTitle#find should return a correct title (string)', () => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['# hoge\nfuga', '# hoge'],
|
['# hoge\nfuga', '# hoge'],
|
||||||
@@ -20,15 +19,11 @@ test('findNoteTitle#find should return a correct title (string)', t => {
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(findNoteTitle(input, false)).toBe(expected)
|
||||||
findNoteTitle(input, false),
|
|
||||||
expected,
|
|
||||||
`Test for find() input: ${input} expected: ${expected}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('findNoteTitle#find should ignore front matter when enableFrontMatterTitle=false', t => {
|
test('findNoteTitle#find should ignore front matter when enableFrontMatterTitle=false', () => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['---\nlayout: test\ntitle: hoge hoge hoge \n---\n# fuga', '# fuga'],
|
['---\nlayout: test\ntitle: hoge hoge hoge \n---\n# fuga', '# fuga'],
|
||||||
@@ -38,15 +33,11 @@ test('findNoteTitle#find should ignore front matter when enableFrontMatterTitle
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(findNoteTitle(input, false)).toBe(expected)
|
||||||
findNoteTitle(input, false),
|
|
||||||
expected,
|
|
||||||
`Test for find() input: ${input} expected: ${expected}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('findNoteTitle#find should respect front matter when enableFrontMatterTitle=true', t => {
|
test('findNoteTitle#find should respect front matter when enableFrontMatterTitle=true', () => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
[
|
[
|
||||||
@@ -59,15 +50,11 @@ test('findNoteTitle#find should respect front matter when enableFrontMatterTitl
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(findNoteTitle(input, true)).toBe(expected)
|
||||||
findNoteTitle(input, true),
|
|
||||||
expected,
|
|
||||||
`Test for find() input: ${input} expected: ${expected}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('findNoteTitle#find should respect frontMatterTitleField when provided', t => {
|
test('findNoteTitle#find should respect frontMatterTitleField when provided', () => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['---\ntitle: hoge\n---\n# fuga', '# fuga'],
|
['---\ntitle: hoge\n---\n# fuga', '# fuga'],
|
||||||
@@ -76,10 +63,6 @@ test('findNoteTitle#find should respect frontMatterTitleField when provided', t
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(findNoteTitle(input, true, 'custom')).toBe(expected)
|
||||||
findNoteTitle(input, true, 'custom'),
|
|
||||||
expected,
|
|
||||||
`Test for find() input: ${input} expected: ${expected}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
const test = require('ava')
|
|
||||||
const { getTodoStatus } = require('browser/lib/getTodoStatus')
|
const { getTodoStatus } = require('browser/lib/getTodoStatus')
|
||||||
|
|
||||||
// Unit test
|
// Unit test
|
||||||
test('getTodoStatus should return a correct hash object', t => {
|
test('getTodoStatus should return a correct hash object', () => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['', { total: 0, completed: 0 }],
|
['', { total: 0, completed: 0 }],
|
||||||
@@ -40,15 +39,7 @@ test('getTodoStatus should return a correct hash object', t => {
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(getTodoStatus(input).total).toBe(expected.total)
|
||||||
getTodoStatus(input).total,
|
expect(getTodoStatus(input).completed).toBe(expected.completed)
|
||||||
expected.total,
|
|
||||||
`Test for getTodoStatus() input: ${input} expected: ${expected.total}`
|
|
||||||
)
|
|
||||||
t.is(
|
|
||||||
getTodoStatus(input).completed,
|
|
||||||
expected.completed,
|
|
||||||
`Test for getTodoStatus() input: ${input} expected: ${expected.completed}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* @fileoverview Unit test for browser/lib/htmlTextHelper
|
* @fileoverview Unit test for browser/lib/htmlTextHelper
|
||||||
*/
|
*/
|
||||||
const test = require('ava')
|
|
||||||
const htmlTextHelper = require('browser/lib/htmlTextHelper')
|
const htmlTextHelper = require('browser/lib/htmlTextHelper')
|
||||||
|
|
||||||
// Unit test
|
// Unit test
|
||||||
test('htmlTextHelper#decodeEntities should return encoded text (string)', t => {
|
test('htmlTextHelper#decodeEntities should return encoded text (string)', () => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['<a href=', '<a href='],
|
['<a href=', '<a href='],
|
||||||
@@ -21,15 +20,11 @@ test('htmlTextHelper#decodeEntities should return encoded text (string)', t => {
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(htmlTextHelper.decodeEntities(input)).toBe(expected)
|
||||||
htmlTextHelper.decodeEntities(input),
|
|
||||||
expected,
|
|
||||||
`Test for decodeEntities() input: ${input} expected: ${expected}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('htmlTextHelper#decodeEntities() should return decoded text (string)', t => {
|
test('htmlTextHelper#decodeEntities() should return decoded text (string)', () => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['<a href=', '<a href='],
|
['<a href=', '<a href='],
|
||||||
@@ -44,16 +39,12 @@ test('htmlTextHelper#decodeEntities() should return decoded text (string)', t =>
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(htmlTextHelper.encodeEntities(input)).toBe(expected)
|
||||||
htmlTextHelper.encodeEntities(input),
|
|
||||||
expected,
|
|
||||||
`Test for encodeEntities() input: ${input} expected: ${expected}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Integration test
|
// Integration test
|
||||||
test(t => {
|
test(() => {
|
||||||
const testCases = [
|
const testCases = [
|
||||||
"var test = 'test'",
|
"var test = 'test'",
|
||||||
"<a href='https://boostnote.io'>Boostnote",
|
"<a href='https://boostnote.io'>Boostnote",
|
||||||
@@ -63,10 +54,6 @@ test(t => {
|
|||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const encodedText = htmlTextHelper.encodeEntities(testCase)
|
const encodedText = htmlTextHelper.encodeEntities(testCase)
|
||||||
const decodedText = htmlTextHelper.decodeEntities(encodedText)
|
const decodedText = htmlTextHelper.decodeEntities(encodedText)
|
||||||
t.is(
|
expect(decodedText).toBe(testCase)
|
||||||
decodedText,
|
|
||||||
testCase,
|
|
||||||
'Integration test through encodedText() and decodedText()'
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* @fileoverview Unit test for browser/lib/markdown
|
* @fileoverview Unit test for browser/lib/markdown
|
||||||
*/
|
*/
|
||||||
const test = require('ava')
|
|
||||||
const markdown = require('browser/lib/markdownTextHelper')
|
const markdown = require('browser/lib/markdownTextHelper')
|
||||||
|
|
||||||
test(t => {
|
test(() => {
|
||||||
// [input, expected]
|
// [input, expected]
|
||||||
const testCases = [
|
const testCases = [
|
||||||
// List
|
// List
|
||||||
@@ -42,10 +41,6 @@ test(t => {
|
|||||||
|
|
||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expected] = testCase
|
const [input, expected] = testCase
|
||||||
t.is(
|
expect(markdown.strip(input)).toBe(expected)
|
||||||
markdown.strip(input),
|
|
||||||
expected,
|
|
||||||
`Test for strip() input: ${input} expected: ${expected}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -4,11 +4,10 @@
|
|||||||
|
|
||||||
import CodeMirror from 'codemirror'
|
import CodeMirror from 'codemirror'
|
||||||
require('codemirror/addon/search/searchcursor.js')
|
require('codemirror/addon/search/searchcursor.js')
|
||||||
const test = require('ava')
|
|
||||||
const markdownToc = require('browser/lib/markdown-toc-generator')
|
const markdownToc = require('browser/lib/markdown-toc-generator')
|
||||||
const EOL = require('os').EOL
|
const EOL = require('os').EOL
|
||||||
|
|
||||||
test(t => {
|
test(() => {
|
||||||
/**
|
/**
|
||||||
* Contains array of test cases in format :
|
* Contains array of test cases in format :
|
||||||
* [
|
* [
|
||||||
@@ -261,15 +260,11 @@ this is a text
|
|||||||
const expectedToc = testCase[2].trim()
|
const expectedToc = testCase[2].trim()
|
||||||
const generatedToc = markdownToc.generate(inputMd)
|
const generatedToc = markdownToc.generate(inputMd)
|
||||||
|
|
||||||
t.is(
|
expect(generatedToc).toBe(expectedToc)
|
||||||
generatedToc,
|
|
||||||
expectedToc,
|
|
||||||
`generate test : ${title} , generated : ${EOL}${generatedToc}, expected : ${EOL}${expectedToc}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test(t => {
|
test(() => {
|
||||||
/**
|
/**
|
||||||
* Contains array of test cases in format :
|
* Contains array of test cases in format :
|
||||||
* [
|
* [
|
||||||
@@ -667,10 +662,6 @@ this is a level one text
|
|||||||
editor.setCursor(cursor)
|
editor.setCursor(cursor)
|
||||||
markdownToc.generateInEditor(editor)
|
markdownToc.generateInEditor(editor)
|
||||||
|
|
||||||
t.is(
|
expect(expectedMd).toBe(editor.getValue())
|
||||||
expectedMd,
|
|
||||||
editor.getValue(),
|
|
||||||
`generateInEditor test : ${title} , generated : ${EOL}${editor.getValue()}, expected : ${EOL}${expectedMd}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,17 @@
|
|||||||
import test from 'ava'
|
jest.mock(
|
||||||
|
'electron',
|
||||||
|
() => {
|
||||||
|
return {
|
||||||
|
remote: {
|
||||||
|
app: {
|
||||||
|
getPath: jest.fn().mockReturnValue('.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ virtual: true }
|
||||||
|
)
|
||||||
|
|
||||||
import Markdown from 'browser/lib/markdown'
|
import Markdown from 'browser/lib/markdown'
|
||||||
import markdownFixtures from '../fixtures/markdowns'
|
import markdownFixtures from '../fixtures/markdowns'
|
||||||
|
|
||||||
@@ -6,100 +19,100 @@ import markdownFixtures from '../fixtures/markdowns'
|
|||||||
// To test markdown options, initialize a new instance in your test case
|
// To test markdown options, initialize a new instance in your test case
|
||||||
const md = new Markdown()
|
const md = new Markdown()
|
||||||
|
|
||||||
test('Markdown.render() should renders markdown correctly', t => {
|
test('Markdown.render() should renders markdown correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.basic)
|
const rendered = md.render(markdownFixtures.basic)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders codeblock correctly', t => {
|
test('Markdown.render() should renders codeblock correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.codeblock)
|
const rendered = md.render(markdownFixtures.codeblock)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders KaTeX correctly', t => {
|
test('Markdown.render() should renders KaTeX correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.katex)
|
const rendered = md.render(markdownFixtures.katex)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders checkboxes', t => {
|
test('Markdown.render() should renders checkboxes', () => {
|
||||||
const rendered = md.render(markdownFixtures.checkboxes)
|
const rendered = md.render(markdownFixtures.checkboxes)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should text with quotes correctly', t => {
|
test('Markdown.render() should text with quotes correctly', () => {
|
||||||
const renderedSmartQuotes = md.render(markdownFixtures.smartQuotes)
|
const renderedSmartQuotes = md.render(markdownFixtures.smartQuotes)
|
||||||
t.snapshot(renderedSmartQuotes)
|
expect(renderedSmartQuotes).toMatchSnapshot()
|
||||||
|
|
||||||
const newmd = new Markdown({ typographer: false })
|
const newmd = new Markdown({ typographer: false })
|
||||||
const renderedNonSmartQuotes = newmd.render(markdownFixtures.smartQuotes)
|
const renderedNonSmartQuotes = newmd.render(markdownFixtures.smartQuotes)
|
||||||
t.snapshot(renderedNonSmartQuotes)
|
expect(renderedNonSmartQuotes).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render line breaks correctly', t => {
|
test('Markdown.render() should render line breaks correctly', () => {
|
||||||
const renderedBreaks = md.render(markdownFixtures.breaks)
|
const renderedBreaks = md.render(markdownFixtures.breaks)
|
||||||
t.snapshot(renderedBreaks)
|
expect(renderedBreaks).toMatchSnapshot()
|
||||||
|
|
||||||
const newmd = new Markdown({ breaks: false })
|
const newmd = new Markdown({ breaks: false })
|
||||||
const renderedNonBreaks = newmd.render(markdownFixtures.breaks)
|
const renderedNonBreaks = newmd.render(markdownFixtures.breaks)
|
||||||
t.snapshot(renderedNonBreaks)
|
expect(renderedNonBreaks).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders abbrevations correctly', t => {
|
test('Markdown.render() should renders abbrevations correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.abbrevations)
|
const rendered = md.render(markdownFixtures.abbrevations)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders sub correctly', t => {
|
test('Markdown.render() should renders sub correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.subTexts)
|
const rendered = md.render(markdownFixtures.subTexts)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders sup correctly', t => {
|
test('Markdown.render() should renders sup correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.supTexts)
|
const rendered = md.render(markdownFixtures.supTexts)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders definition lists correctly', t => {
|
test('Markdown.render() should renders definition lists correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.deflists)
|
const rendered = md.render(markdownFixtures.deflists)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render shortcuts correctly', t => {
|
test('Markdown.render() should render shortcuts correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.shortcuts)
|
const rendered = md.render(markdownFixtures.shortcuts)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render footnote correctly', t => {
|
test('Markdown.render() should render footnote correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.footnote)
|
const rendered = md.render(markdownFixtures.footnote)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should renders [TOC] placholder correctly', t => {
|
test('Markdown.render() should renders [TOC] placholder correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.tocPlaceholder)
|
const rendered = md.render(markdownFixtures.tocPlaceholder)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render PlantUML MindMaps correctly', t => {
|
test('Markdown.render() should render PlantUML MindMaps correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.plantUmlMindMap)
|
const rendered = md.render(markdownFixtures.plantUmlMindMap)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render PlantUML Gantt correctly', t => {
|
test('Markdown.render() should render PlantUML Gantt correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.plantUmlGantt)
|
const rendered = md.render(markdownFixtures.plantUmlGantt)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render PlantUML WBS correctly', t => {
|
test('Markdown.render() should render PlantUML WBS correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.plantUmlWbs)
|
const rendered = md.render(markdownFixtures.plantUmlWbs)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render PlantUML Umls correctly', t => {
|
test('Markdown.render() should render PlantUML Umls correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.plantUmlUml)
|
const rendered = md.render(markdownFixtures.plantUmlUml)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Markdown.render() should render PlantUML Ditaa correctly', t => {
|
test('Markdown.render() should render PlantUML Ditaa correctly', () => {
|
||||||
const rendered = md.render(markdownFixtures.plantUmlDitaa)
|
const rendered = md.render(markdownFixtures.plantUmlDitaa)
|
||||||
t.snapshot(rendered)
|
expect(rendered).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
@@ -1,19 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* @fileoverview Unit test for browser/lib/normalizeEditorFontFamily
|
* @fileoverview Unit test for browser/lib/normalizeEditorFontFamily
|
||||||
*/
|
*/
|
||||||
import test from 'ava'
|
|
||||||
import normalizeEditorFontFamily from '../../browser/lib/normalizeEditorFontFamily'
|
import normalizeEditorFontFamily from '../../browser/lib/normalizeEditorFontFamily'
|
||||||
import consts from '../../browser/lib/consts'
|
import consts from '../../browser/lib/consts'
|
||||||
const defaultEditorFontFamily = consts.DEFAULT_EDITOR_FONT_FAMILY
|
const defaultEditorFontFamily = consts.DEFAULT_EDITOR_FONT_FAMILY
|
||||||
|
|
||||||
test('normalizeEditorFontFamily() should return default font family (string[])', t => {
|
test('normalizeEditorFontFamily() should return default font family (string[])', () => {
|
||||||
t.is(normalizeEditorFontFamily(), defaultEditorFontFamily.join(', '))
|
expect(normalizeEditorFontFamily()).toBe(defaultEditorFontFamily.join(', '))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('normalizeEditorFontFamily(["hoge", "huga"]) should return default font family connected with arg.', t => {
|
test('normalizeEditorFontFamily(["hoge", "huga"]) should return default font family connected with arg.', () => {
|
||||||
const arg = 'font1, font2'
|
const arg = 'font1, font2'
|
||||||
t.is(
|
expect(normalizeEditorFontFamily(arg)).toBe(
|
||||||
normalizeEditorFontFamily(arg),
|
|
||||||
`${arg}, ${defaultEditorFontFamily.join(', ')}`
|
`${arg}, ${defaultEditorFontFamily.join(', ')}`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
const test = require('ava')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { parse } = require('browser/lib/RcParser')
|
const { parse } = require('browser/lib/RcParser')
|
||||||
|
|
||||||
// Unit test
|
// Unit test
|
||||||
test('RcParser should return a json object', t => {
|
test('RcParser should return a json object', () => {
|
||||||
const validJson = {
|
const validJson = {
|
||||||
editor: { keyMap: 'vim', switchPreview: 'BLUR', theme: 'monokai' },
|
editor: { keyMap: 'vim', switchPreview: 'BLUR', theme: 'monokai' },
|
||||||
hotkey: { toggleMain: 'Control + L' },
|
hotkey: { toggleMain: 'Control + L' },
|
||||||
@@ -51,20 +50,12 @@ test('RcParser should return a json object', t => {
|
|||||||
|
|
||||||
validTestCases.forEach(validTestCase => {
|
validTestCases.forEach(validTestCase => {
|
||||||
const [input, expected] = validTestCase
|
const [input, expected] = validTestCase
|
||||||
t.is(
|
expect(parse(filePath(input)).editor.keyMap).toBe(expected.editor.keyMap)
|
||||||
parse(filePath(input)).editor.keyMap,
|
|
||||||
expected.editor.keyMap,
|
|
||||||
`Test for getTodoStatus() input: ${input} expected: ${expected.keyMap}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
invalidTestCases.forEach(invalidTestCase => {
|
invalidTestCases.forEach(invalidTestCase => {
|
||||||
const [input, expected] = invalidTestCase
|
const [input, expected] = invalidTestCase
|
||||||
t.is(
|
expect(parse(filePath(input)).editor).toBe(expected.editor)
|
||||||
parse(filePath(input)).editor,
|
|
||||||
expected.editor,
|
|
||||||
`Test for getTodoStatus() input: ${input} expected: ${expected.editor}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import test from 'ava'
|
|
||||||
import searchFromNotes from 'browser/lib/search'
|
import searchFromNotes from 'browser/lib/search'
|
||||||
import { dummyNote } from '../fixtures/TestDummy'
|
import { dummyNote } from '../fixtures/TestDummy'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
@@ -11,7 +10,7 @@ const pickContents = notes =>
|
|||||||
let notes = []
|
let notes = []
|
||||||
let note1, note2, note3
|
let note1, note2, note3
|
||||||
|
|
||||||
test.before(t => {
|
beforeAll(() => {
|
||||||
const data1 = { type: 'MARKDOWN_NOTE', content: 'content1', tags: ['tag1'] }
|
const data1 = { type: 'MARKDOWN_NOTE', content: 'content1', tags: ['tag1'] }
|
||||||
const data2 = {
|
const data2 = {
|
||||||
type: 'MARKDOWN_NOTE',
|
type: 'MARKDOWN_NOTE',
|
||||||
@@ -27,7 +26,7 @@ test.before(t => {
|
|||||||
notes = [note1, note2, note3]
|
notes = [note1, note2, note3]
|
||||||
})
|
})
|
||||||
|
|
||||||
test('it can find notes by tags and words', t => {
|
test('it can find notes by tags and words', () => {
|
||||||
// [input, expected content (Array)]
|
// [input, expected content (Array)]
|
||||||
const testWithTags = [
|
const testWithTags = [
|
||||||
['#tag1', [note1.content, note2.content, note3.content]],
|
['#tag1', [note1.content, note2.content, note3.content]],
|
||||||
@@ -49,6 +48,8 @@ test('it can find notes by tags and words', t => {
|
|||||||
testCases.forEach(testCase => {
|
testCases.forEach(testCase => {
|
||||||
const [input, expectedContents] = testCase
|
const [input, expectedContents] = testCase
|
||||||
const results = searchFromNotes(notes, input)
|
const results = searchFromNotes(notes, input)
|
||||||
t.true(_.isEqual(pickContents(results).sort(), expectedContents.sort()))
|
expect(
|
||||||
|
_.isEqual(pickContents(results).sort(), expectedContents.sort())
|
||||||
|
).toBe(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1,58 +1,57 @@
|
|||||||
import test from 'ava'
|
|
||||||
import slugify from 'browser/lib/slugify'
|
import slugify from 'browser/lib/slugify'
|
||||||
|
|
||||||
test('alphabet and digit', t => {
|
test('alphabet and digit', () => {
|
||||||
const upperAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
const upperAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
const lowerAlphabet = 'abcdefghijklmnopqrstuvwxyz'
|
const lowerAlphabet = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
const digit = '0123456789'
|
const digit = '0123456789'
|
||||||
const testCase = upperAlphabet + lowerAlphabet + digit
|
const testCase = upperAlphabet + lowerAlphabet + digit
|
||||||
const decodeSlug = decodeURI(slugify(testCase))
|
const decodeSlug = decodeURI(slugify(testCase))
|
||||||
|
|
||||||
t.true(decodeSlug === testCase)
|
expect(decodeSlug === testCase).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should delete unavailable symbols', t => {
|
test('should delete unavailable symbols', () => {
|
||||||
const availableSymbols = '_-'
|
const availableSymbols = '_-'
|
||||||
const testCase = availableSymbols + "][!'#$%&()*+,./:;<=>?@\\^{|}~`"
|
const testCase = availableSymbols + "][!'#$%&()*+,./:;<=>?@\\^{|}~`"
|
||||||
const decodeSlug = decodeURI(slugify(testCase))
|
const decodeSlug = decodeURI(slugify(testCase))
|
||||||
|
|
||||||
t.true(decodeSlug === availableSymbols)
|
expect(decodeSlug === availableSymbols).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should convert from white spaces between words to hyphens', t => {
|
test('should convert from white spaces between words to hyphens', () => {
|
||||||
const testCase = 'This is one'
|
const testCase = 'This is one'
|
||||||
const expectedString = 'This-is-one'
|
const expectedString = 'This-is-one'
|
||||||
const decodeSlug = decodeURI(slugify(testCase))
|
const decodeSlug = decodeURI(slugify(testCase))
|
||||||
|
|
||||||
t.true(decodeSlug === expectedString)
|
expect(decodeSlug === expectedString).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should remove leading white spaces', t => {
|
test('should remove leading white spaces', () => {
|
||||||
const testCase = ' This is one'
|
const testCase = ' This is one'
|
||||||
const expectedString = 'This-is-one'
|
const expectedString = 'This-is-one'
|
||||||
const decodeSlug = decodeURI(slugify(testCase))
|
const decodeSlug = decodeURI(slugify(testCase))
|
||||||
|
|
||||||
t.true(decodeSlug === expectedString)
|
expect(decodeSlug === expectedString).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should remove trailing white spaces', t => {
|
test('should remove trailing white spaces', () => {
|
||||||
const testCase = 'This is one '
|
const testCase = 'This is one '
|
||||||
const expectedString = 'This-is-one'
|
const expectedString = 'This-is-one'
|
||||||
const decodeSlug = decodeURI(slugify(testCase))
|
const decodeSlug = decodeURI(slugify(testCase))
|
||||||
|
|
||||||
t.true(decodeSlug === expectedString)
|
expect(decodeSlug === expectedString).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('2-byte charactor support', t => {
|
test('2-byte charactor support', () => {
|
||||||
const testCase = '菠萝芒果テストÀžƁƵ'
|
const testCase = '菠萝芒果テストÀžƁƵ'
|
||||||
const decodeSlug = decodeURI(slugify(testCase))
|
const decodeSlug = decodeURI(slugify(testCase))
|
||||||
|
|
||||||
t.true(decodeSlug === testCase)
|
expect(decodeSlug === testCase).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('emoji', t => {
|
test('emoji', () => {
|
||||||
const testCase = '🌸'
|
const testCase = '🌸'
|
||||||
const decodeSlug = decodeURI(slugify(testCase))
|
const decodeSlug = decodeURI(slugify(testCase))
|
||||||
|
|
||||||
t.true(decodeSlug === testCase)
|
expect(decodeSlug === testCase).toBe(true)
|
||||||
})
|
})
|
||||||
Binary file not shown.
103
tests/lib/themeManager.test.js
Normal file
103
tests/lib/themeManager.test.js
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
* @fileoverview Unit test for browser/main/lib/ThemeManager.js
|
||||||
|
*/
|
||||||
|
const { chooseTheme, applyTheme } = require('browser/main/lib/ThemeManager')
|
||||||
|
jest.mock('../../browser/main/lib/ConfigManager', () => {
|
||||||
|
return {
|
||||||
|
set: () => {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const originalDate = Date
|
||||||
|
let context = {}
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
const constantDate = new Date('2017-11-27T14:33:42')
|
||||||
|
global.Date = class extends Date {
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
return constantDate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
context = {
|
||||||
|
ui: {
|
||||||
|
theme: 'white',
|
||||||
|
scheduledTheme: 'dark',
|
||||||
|
enableScheduleTheme: true,
|
||||||
|
defaultTheme: 'monokai'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
global.Date = originalDate
|
||||||
|
})
|
||||||
|
|
||||||
|
test("enableScheduleTheme is false, theme shouldn't change", () => {
|
||||||
|
context.ui.enableScheduleTheme = false
|
||||||
|
|
||||||
|
const beforeTheme = context.ui.theme
|
||||||
|
chooseTheme(context)
|
||||||
|
const afterTheme = context.ui.theme
|
||||||
|
|
||||||
|
expect(afterTheme).toBe(beforeTheme)
|
||||||
|
})
|
||||||
|
|
||||||
|
// NOT IN SCHEDULE
|
||||||
|
test("scheduleEnd is bigger than scheduleStart and not in schedule, theme shouldn't change", () => {
|
||||||
|
const beforeTheme = context.ui.defaultTheme
|
||||||
|
context.ui.scheduleStart = 720 // 12:00
|
||||||
|
context.ui.scheduleEnd = 870 // 14:30
|
||||||
|
chooseTheme(context)
|
||||||
|
const afterTheme = context.ui.theme
|
||||||
|
|
||||||
|
expect(afterTheme).toBe(beforeTheme)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("scheduleStart is bigger than scheduleEnd and not in schedule, theme shouldn't change", () => {
|
||||||
|
const beforeTheme = context.ui.defaultTheme
|
||||||
|
context.ui.scheduleStart = 960 // 16:00
|
||||||
|
context.ui.scheduleEnd = 600 // 10:00
|
||||||
|
chooseTheme(context)
|
||||||
|
const afterTheme = context.ui.theme
|
||||||
|
|
||||||
|
expect(afterTheme).toBe(beforeTheme)
|
||||||
|
})
|
||||||
|
|
||||||
|
// IN SCHEDULE
|
||||||
|
test('scheduleEnd is bigger than scheduleStart and in schedule, theme should change', () => {
|
||||||
|
const beforeTheme = context.ui.scheduledTheme
|
||||||
|
context.ui.scheduleStart = 720 // 12:00
|
||||||
|
context.ui.scheduleEnd = 900 // 15:00
|
||||||
|
chooseTheme(context)
|
||||||
|
const afterTheme = context.ui.theme
|
||||||
|
|
||||||
|
expect(afterTheme).toBe(beforeTheme)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('scheduleStart is bigger than scheduleEnd and in schedule, theme should change', () => {
|
||||||
|
const beforeTheme = context.ui.scheduledTheme
|
||||||
|
context.ui.scheduleStart = 1200 // 20:00
|
||||||
|
context.ui.scheduleEnd = 900 // 15:00
|
||||||
|
chooseTheme(context)
|
||||||
|
const afterTheme = context.ui.theme
|
||||||
|
|
||||||
|
expect(afterTheme).toBe(beforeTheme)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("theme to apply is not a supported theme, theme shouldn't change", () => {
|
||||||
|
applyTheme('notATheme')
|
||||||
|
const afterTheme = document.body.dataset.theme
|
||||||
|
|
||||||
|
expect(afterTheme).toBe('default')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('theme to apply is a supported theme, theme should change', () => {
|
||||||
|
applyTheme(context.ui.defaultTheme)
|
||||||
|
const afterTheme = document.body.dataset.theme
|
||||||
|
|
||||||
|
expect(afterTheme).toBe(context.ui.defaultTheme)
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user