mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 18:26:26 +00:00
Compare commits
464 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2027f60014 | ||
|
|
076edd375f | ||
|
|
ab1aa56059 | ||
|
|
46f7dfdfeb | ||
|
|
fcaa5e21cf | ||
|
|
1e202db50f | ||
|
|
9405b95825 | ||
|
|
f05e256afc | ||
|
|
731ffd4a22 | ||
|
|
8f4566b7e1 | ||
|
|
95aec54f60 | ||
|
|
f14ce0d68e | ||
|
|
cc1c7f3820 | ||
|
|
2df901288a | ||
|
|
821a7c780e | ||
|
|
6e2e48fa64 | ||
|
|
2864ac88f5 | ||
|
|
4a292d6518 | ||
|
|
e934182e86 | ||
|
|
d8fa73287b | ||
|
|
35938c09e8 | ||
|
|
9eaa90c691 | ||
|
|
049835d426 | ||
|
|
af91c40406 | ||
|
|
4940ad6825 | ||
|
|
d02b740300 | ||
|
|
9cb443dc2f | ||
|
|
1c7cba2951 | ||
|
|
473b80710d | ||
|
|
2247c0835d | ||
|
|
b7b715ba3d | ||
|
|
6c43fb2325 | ||
|
|
a6fe3c27d4 | ||
|
|
d47ff96b13 | ||
|
|
a0def654bd | ||
|
|
4873b40e49 | ||
|
|
0a758f20a7 | ||
|
|
5e58d457a3 | ||
|
|
0f745361ad | ||
|
|
bf6cae9a0e | ||
|
|
ab640a7676 | ||
|
|
820171e19e | ||
|
|
f1e9d0ab81 | ||
|
|
0646484c83 | ||
|
|
a27b79c213 | ||
|
|
773a9b4b7f | ||
|
|
07b838ef7b | ||
|
|
85217a7171 | ||
|
|
886d7b7227 | ||
|
|
6987b762dd | ||
|
|
f32ac81f84 | ||
|
|
87ea66bb92 | ||
|
|
ff6fd62932 | ||
|
|
76728448ff | ||
|
|
3b7225e0fa | ||
|
|
d6280f4397 | ||
|
|
8df867046f | ||
|
|
331c822816 | ||
|
|
6219173945 | ||
|
|
6207e02e7f | ||
|
|
537ba537dc | ||
|
|
3e919241e6 | ||
|
|
2324327e7e | ||
|
|
b8374494ea | ||
|
|
a480ca7b55 | ||
|
|
bfd67fb7f1 | ||
|
|
e6bd6a5077 | ||
|
|
350af844ca | ||
|
|
a49d53179a | ||
|
|
e68069fd2f | ||
|
|
a193ba3e6c | ||
|
|
9034b3ab54 | ||
|
|
f39b7594ab | ||
|
|
f79734391e | ||
|
|
e54f516418 | ||
|
|
e86464535d | ||
|
|
e8553caa65 | ||
|
|
044e6b7180 | ||
|
|
0266770657 | ||
|
|
2d6f7c08e8 | ||
|
|
0a27819a7f | ||
|
|
3185c25ee1 | ||
|
|
820802cdc2 | ||
|
|
2c169e6f15 | ||
|
|
49be1320f9 | ||
|
|
6bc4ecce48 | ||
|
|
0290d23832 | ||
|
|
e001c97e01 | ||
|
|
976d1bb4f3 | ||
|
|
dee6495b08 | ||
|
|
4a77f250f1 | ||
|
|
c697f19642 | ||
|
|
f7d1f9e949 | ||
|
|
27b9952f8e | ||
|
|
961dab4a97 | ||
|
|
930b6bc927 | ||
|
|
ed7d8258cf | ||
|
|
762425125f | ||
|
|
03bdf0c653 | ||
|
|
7002026190 | ||
|
|
b35395e6bd | ||
|
|
b74fb76d03 | ||
|
|
72d2df465b | ||
|
|
2592c943f7 | ||
|
|
7b3a3ba200 | ||
|
|
8369832585 | ||
|
|
d94a674343 | ||
|
|
260611ffd6 | ||
|
|
690549b57f | ||
|
|
5d9aeb4c04 | ||
|
|
eddfdea2ca | ||
|
|
a40385f87f | ||
|
|
0123526c98 | ||
|
|
275e3317a3 | ||
|
|
d0b835a825 | ||
|
|
f450260ff8 | ||
|
|
5f7b119e5c | ||
|
|
bb9eb494e9 | ||
|
|
6ea2b5e1d9 | ||
|
|
b21baf1ce5 | ||
|
|
4c3fd461e4 | ||
|
|
8365a60d5d | ||
|
|
804ac1aa96 | ||
|
|
49fd2cfc4d | ||
|
|
2bb2a52f27 | ||
|
|
8d71b28afa | ||
|
|
86eac7054d | ||
|
|
dccb92d72b | ||
|
|
2e628de9c6 | ||
|
|
2d243abc12 | ||
|
|
ae08bf4d7a | ||
|
|
cbff5fb585 | ||
|
|
2650cc2f1c | ||
|
|
ec560ceab1 | ||
|
|
ad17cb8837 | ||
|
|
4f98d9641a | ||
|
|
17535ccd4c | ||
|
|
110c1ea337 | ||
|
|
7e087bfbab | ||
|
|
85e0d4b922 | ||
|
|
265262ccbf | ||
|
|
345008e9b6 | ||
|
|
849aa05d76 | ||
|
|
5ff5ec6a71 | ||
|
|
684c3f64aa | ||
|
|
4ff73ede59 | ||
|
|
7302d83f60 | ||
|
|
f9836fd66e | ||
|
|
c0f05695fe | ||
|
|
e50a1172d6 | ||
|
|
7a4234e73c | ||
|
|
4b9640e5a3 | ||
|
|
4b58054100 | ||
|
|
8951dbf4ed | ||
|
|
5047bc94eb | ||
|
|
75fb29c594 | ||
|
|
bd75f7fd2c | ||
|
|
8b8cb3c9b4 | ||
|
|
b479b21c37 | ||
|
|
525c490704 | ||
|
|
2e3599d005 | ||
|
|
f005bb1e46 | ||
|
|
21f96febdb | ||
|
|
805829be78 | ||
|
|
a7bd3f253f | ||
|
|
81e8a290f0 | ||
|
|
f46a967b6e | ||
|
|
b78d9534aa | ||
|
|
bdefaf7427 | ||
|
|
43550c7dec | ||
|
|
1b07d393f2 | ||
|
|
44fc356775 | ||
|
|
5623c68170 | ||
|
|
d5f82943cf | ||
|
|
96a020341d | ||
|
|
99b5f75763 | ||
|
|
a128ff7cd8 | ||
|
|
59329cc5da | ||
|
|
ecd5daaf55 | ||
|
|
514232d720 | ||
|
|
93abfe3202 | ||
|
|
4d9e0e3bd7 | ||
|
|
75d9bf8e38 | ||
|
|
ccb9752254 | ||
|
|
0f2ca19c6c | ||
|
|
d5a77aade4 | ||
|
|
3c89e6a128 | ||
|
|
a36be79977 | ||
|
|
617f0e0f9c | ||
|
|
0db1a94105 | ||
|
|
f29f97a00f | ||
|
|
032b5a59f2 | ||
|
|
1e5bc395ac | ||
|
|
fef4afe660 | ||
|
|
679ed1eacf | ||
|
|
78a9320017 | ||
|
|
927981bf30 | ||
|
|
70ea2f6c14 | ||
|
|
a6779414ff | ||
|
|
b62fcf523a | ||
|
|
d0bbea5a97 | ||
|
|
212d7027fc | ||
|
|
be1a5b09da | ||
|
|
3de2db4459 | ||
|
|
f2405a5b34 | ||
|
|
94abb8f959 | ||
|
|
2e30db05bc | ||
|
|
c93f3cc5dd | ||
|
|
068f8f2ba9 | ||
|
|
0980c3b012 | ||
|
|
5288d6768f | ||
|
|
34491f4ea4 | ||
|
|
8c73ca8854 | ||
|
|
0786d8eab6 | ||
|
|
209518c815 | ||
|
|
b2753b6457 | ||
|
|
4775a920c0 | ||
|
|
0e94dc8740 | ||
|
|
cf68d202d5 | ||
|
|
d29ba2bf16 | ||
|
|
720686cef5 | ||
|
|
0625c65cf0 | ||
|
|
acaefe22d1 | ||
|
|
df1f083ebf | ||
|
|
5a1dfc2ca9 | ||
|
|
d84894f1bf | ||
|
|
0fdc444c4c | ||
|
|
4d216c6f13 | ||
|
|
1c0af8eede | ||
|
|
f443f9264a | ||
|
|
d9b2981327 | ||
|
|
68e36d2a6d | ||
|
|
68b91bf98c | ||
|
|
b91ddfad05 | ||
|
|
a110cbfb5d | ||
|
|
d69f45b0c9 | ||
|
|
07df26d5c4 | ||
|
|
d24bcb7f86 | ||
|
|
9f383ba491 | ||
|
|
c38a76d587 | ||
|
|
994ca5dd02 | ||
|
|
9281f8f6cb | ||
|
|
324f579474 | ||
|
|
10bd2d4547 | ||
|
|
d1942868e4 | ||
|
|
a409b3e48d | ||
|
|
21004aab6a | ||
|
|
eaf88c6491 | ||
|
|
17dcd1b6f1 | ||
|
|
244a06eea6 | ||
|
|
afb13af7a1 | ||
|
|
ff9b935e98 | ||
|
|
4250d6fe52 | ||
|
|
5bc2094f10 | ||
|
|
552653c0ed | ||
|
|
c9bbc61c95 | ||
|
|
41a04aa3f1 | ||
|
|
cd421c4662 | ||
|
|
063e2e02bd | ||
|
|
0c3019b52e | ||
|
|
2ee2494dc4 | ||
|
|
df6ff1fffe | ||
|
|
0d2e6a6a12 | ||
|
|
79ed55a76f | ||
|
|
cbe58b9437 | ||
|
|
afc729b1c3 | ||
|
|
5d0cb0302e | ||
|
|
29e0d121cd | ||
|
|
48ca13f82c | ||
|
|
278061e4f1 | ||
|
|
186a815821 | ||
|
|
2fea9eb874 | ||
|
|
f8b6453be9 | ||
|
|
be625f8884 | ||
|
|
2271def5d3 | ||
|
|
275a8ea7cc | ||
|
|
dc236f33b1 | ||
|
|
678d739e75 | ||
|
|
8fe05a4c24 | ||
|
|
77adfdb9f0 | ||
|
|
30c94028fb | ||
|
|
b5bf0780fa | ||
|
|
ad838d82ee | ||
|
|
d5ec0c0cdd | ||
|
|
ff29f1e0c6 | ||
|
|
1f58698a04 | ||
|
|
a275f331d0 | ||
|
|
0862c6e059 | ||
|
|
46fddfd26c | ||
|
|
c547ccb4cb | ||
|
|
86e82fb149 | ||
|
|
00a284bfbd | ||
|
|
f6fbec0a2e | ||
|
|
b24c06bee6 | ||
|
|
95e7f4f645 | ||
|
|
4b75d501f5 | ||
|
|
b28d5c8b25 | ||
|
|
86e61661e6 | ||
|
|
cdd5717e63 | ||
|
|
42bd7fb4fb | ||
|
|
66e478a001 | ||
|
|
c8259abcac | ||
|
|
d6d16a63a4 | ||
|
|
df8d1f0714 | ||
|
|
fbbc6411c3 | ||
|
|
bc1e94fcab | ||
|
|
418439e3d5 | ||
|
|
46cbd04ba7 | ||
|
|
0ade6d9ece | ||
|
|
823599192f | ||
|
|
9496ab88f7 | ||
|
|
290e6ab170 | ||
|
|
a9e3572f4f | ||
|
|
92b2b7dde3 | ||
|
|
dad1e40234 | ||
|
|
b75c8b0373 | ||
|
|
fc4c471a87 | ||
|
|
24de71f240 | ||
|
|
805c39e60c | ||
|
|
10e75041e8 | ||
|
|
2364348df4 | ||
|
|
e643443660 | ||
|
|
d72e876b23 | ||
|
|
f3612774ba | ||
|
|
67d8b02c49 | ||
|
|
7abf53009a | ||
|
|
90bb4632b6 | ||
|
|
630da00235 | ||
|
|
245e0dd7ee | ||
|
|
824e288a80 | ||
|
|
99228f2e60 | ||
|
|
0f71139eba | ||
|
|
2bbe7056d1 | ||
|
|
005d8f84fd | ||
|
|
908cd7a890 | ||
|
|
d4865adf6a | ||
|
|
20411a2fd5 | ||
|
|
19f8930f5a | ||
|
|
ffc4ca1dd4 | ||
|
|
0bc9c6fb5a | ||
|
|
983f453afd | ||
|
|
60a0293495 | ||
|
|
4807d22763 | ||
|
|
e8d451bcbb | ||
|
|
4809bb6f06 | ||
|
|
d6d694cf66 | ||
|
|
132e3c3088 | ||
|
|
3c7ff78549 | ||
|
|
adbdc2cb1c | ||
|
|
e52b74bbc9 | ||
|
|
575f1b4b33 | ||
|
|
a528c99900 | ||
|
|
e6047ed383 | ||
|
|
381b7d960a | ||
|
|
045a8bde22 | ||
|
|
e528182c2a | ||
|
|
b86cdb461a | ||
|
|
7265f76770 | ||
|
|
2ed092279d | ||
|
|
7d71819be0 | ||
|
|
e848c74511 | ||
|
|
968ed146b2 | ||
|
|
5e03f12875 | ||
|
|
09f8e5f25a | ||
|
|
89f4ed3006 | ||
|
|
8d14a9557d | ||
|
|
513042d769 | ||
|
|
c28980c2a9 | ||
|
|
1c31ff4e98 | ||
|
|
7c9d3904b3 | ||
|
|
e23707f0a0 | ||
|
|
a952b18b96 | ||
|
|
35cc07bf63 | ||
|
|
118bf18434 | ||
|
|
34da15208b | ||
|
|
e0dc62c00b | ||
|
|
b58df2f172 | ||
|
|
90846fab81 | ||
|
|
efd80d5c0c | ||
|
|
e37e28a22e | ||
|
|
a1e71b318c | ||
|
|
aee6541d45 | ||
|
|
50ad5e3791 | ||
|
|
b34d72f21a | ||
|
|
e5ae420ef6 | ||
|
|
7269750264 | ||
|
|
33fe3ff733 | ||
|
|
aa77180957 | ||
|
|
3d80b6a4cd | ||
|
|
d76f9243a3 | ||
|
|
88f1a0d5cd | ||
|
|
26c435d6da | ||
|
|
e66abdea2d | ||
|
|
c7d2eeb71a | ||
|
|
0e8d681954 | ||
|
|
433d110cf0 | ||
|
|
4a514cd7bd | ||
|
|
417fee16bd | ||
|
|
49a821d9ee | ||
|
|
6a5ce098e0 | ||
|
|
1af73eebea | ||
|
|
b7ba29ac92 | ||
|
|
133c2ec308 | ||
|
|
a70fe1bba8 | ||
|
|
6dcd653eac | ||
|
|
db2f90b1ce | ||
|
|
60e5665133 | ||
|
|
7aa982849f | ||
|
|
d94f7626c2 | ||
|
|
549c289f81 | ||
|
|
b35953d1f9 | ||
|
|
941c4aeb19 | ||
|
|
11f7fcbaef | ||
|
|
6b8488ae0f | ||
|
|
ee5268a07e | ||
|
|
28bc331318 | ||
|
|
098153b6ba | ||
|
|
878f31e91e | ||
|
|
b40d09fa86 | ||
|
|
eb48f48f6b | ||
|
|
7961008500 | ||
|
|
ff87c6b226 | ||
|
|
0c2807a08b | ||
|
|
f0cf369317 | ||
|
|
5e9954c060 | ||
|
|
0c7bdf20af | ||
|
|
9c1179a6f9 | ||
|
|
43cb290c80 | ||
|
|
f8b7b7df9f | ||
|
|
b73f0a8012 | ||
|
|
75b2c7bd2e | ||
|
|
5fd9866eef | ||
|
|
4e7204bdbc | ||
|
|
ff7024e38f | ||
|
|
8c11a0b42d | ||
|
|
2df295dc1d | ||
|
|
b695d27817 | ||
|
|
8e2fd300f6 | ||
|
|
1722e103fc | ||
|
|
71464112ce | ||
|
|
003d8a1b21 | ||
|
|
adf81175f3 | ||
|
|
39274ce483 | ||
|
|
1daf07edeb | ||
|
|
cd2dc471c7 | ||
|
|
6229ca7ac9 | ||
|
|
10043cc755 | ||
|
|
e60a5430b4 | ||
|
|
f7e0cb655f | ||
|
|
04097ecfcd | ||
|
|
2222192bcd | ||
|
|
ae93c38d46 | ||
|
|
9ff9dcbe6d | ||
|
|
94d442af7d | ||
|
|
25685dc8b0 | ||
|
|
50cd0b794b | ||
|
|
720f07f62c | ||
|
|
893a92c87b | ||
|
|
0f3230110c | ||
|
|
65573bd4db | ||
|
|
928df018dc | ||
|
|
b2187b72ab | ||
|
|
aae2bddd32 | ||
|
|
b6eddf0821 |
33
.boostnoterc.sample
Normal file
33
.boostnoterc.sample
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"amaEnabled": true,
|
||||||
|
"editor": {
|
||||||
|
"fontFamily": "Monaco, Consolas",
|
||||||
|
"fontSize": "14",
|
||||||
|
"indentSize": "2",
|
||||||
|
"indentType": "space",
|
||||||
|
"keyMap": "vim",
|
||||||
|
"switchPreview": "BLUR",
|
||||||
|
"theme": "monokai"
|
||||||
|
},
|
||||||
|
"hotkey": {
|
||||||
|
"toggleFinder": "Cmd + Alt + S",
|
||||||
|
"toggleMain": "Cmd + Alt + L"
|
||||||
|
},
|
||||||
|
"isSideNavFolded": false,
|
||||||
|
"listStyle": "DEFAULT",
|
||||||
|
"listWidth": 174,
|
||||||
|
"navWidth": 200,
|
||||||
|
"preview": {
|
||||||
|
"codeBlockTheme": "dracula",
|
||||||
|
"fontFamily": "Lato",
|
||||||
|
"fontSize": "14",
|
||||||
|
"lineNumber": true
|
||||||
|
},
|
||||||
|
"sortBy": "UPDATED_AT",
|
||||||
|
"ui": {
|
||||||
|
"defaultNote": "ALWAYS_ASK",
|
||||||
|
"disableDirectWrite": false,
|
||||||
|
"theme": "default"
|
||||||
|
},
|
||||||
|
"zoom": 1
|
||||||
|
}
|
||||||
5
Backers.md
Normal file
5
Backers.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Become a [backer](https://salt.bountysource.com/teams/boostnote) and support Boostnote!
|
||||||
|
You can support Boostnote from $ 5 a month!
|
||||||
|
|
||||||
|
# Backers
|
||||||
|
[Kazu Yokomizo](https://twitter.com/kazup_bot)
|
||||||
1
ISSUE_TEMPLATE.md
Normal file
1
ISSUE_TEMPLATE.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Please paste some **screenshots** with the **developer tool** open if you report a bug.
|
||||||
@@ -2,6 +2,7 @@ import React, { PropTypes } from 'react'
|
|||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import CodeMirror from 'codemirror'
|
import CodeMirror from 'codemirror'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import copyImage from 'browser/main/lib/dataApi/copyImage'
|
||||||
|
|
||||||
CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js'
|
CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js'
|
||||||
|
|
||||||
@@ -83,7 +84,13 @@ export default class CodeEditor extends React.Component {
|
|||||||
'Cmd-T': function (cm) {
|
'Cmd-T': function (cm) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
},
|
},
|
||||||
Enter: 'newlineAndIndentContinueMarkdownList'
|
Enter: 'newlineAndIndentContinueMarkdownList',
|
||||||
|
'Ctrl-C': (cm) => {
|
||||||
|
if (cm.getOption('keyMap').substr(0, 3) === 'vim') {
|
||||||
|
document.execCommand('copy')
|
||||||
|
}
|
||||||
|
return CodeMirror.Pass
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -184,13 +191,17 @@ export default class CodeEditor extends React.Component {
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const imagePath = e.dataTransfer.files[0].path
|
const imagePath = e.dataTransfer.files[0].path
|
||||||
const filename = path.basename(imagePath)
|
const filename = path.basename(imagePath)
|
||||||
const imageMd = `})`
|
|
||||||
this.insertImage(imageMd)
|
copyImage(imagePath, this.props.storageKey).then((imagePath) => {
|
||||||
|
const imageMd = `})`
|
||||||
|
this.insertImageMd(imageMd)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
insertImage (imageMd) {
|
insertImageMd (imageMd) {
|
||||||
const textarea = this.editor.getInputField()
|
const textarea = this.editor.getInputField()
|
||||||
textarea.value = textarea.value.substr(0, textarea.selectionStart) + imageMd + textarea.value.substr(textarea.selectionEnd)
|
const cm = this.editor
|
||||||
|
textarea.value = `${textarea.value.substr(0, textarea.selectionStart)}${imageMd}${textarea.value.substr(textarea.selectionEnd)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|||||||
@@ -4,19 +4,23 @@ import styles from './MarkdownEditor.styl'
|
|||||||
import CodeEditor from 'browser/components/CodeEditor'
|
import CodeEditor from 'browser/components/CodeEditor'
|
||||||
import MarkdownPreview from 'browser/components/MarkdownPreview'
|
import MarkdownPreview from 'browser/components/MarkdownPreview'
|
||||||
import eventEmitter from 'browser/main/lib/eventEmitter'
|
import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||||
|
import { findStorage } from 'browser/lib/findStorage'
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
class MarkdownEditor extends React.Component {
|
class MarkdownEditor extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.escapeFromEditor = ['Control', 'w']
|
// char codes for ctrl + w
|
||||||
|
this.escapeFromEditor = [17, 87]
|
||||||
|
|
||||||
this.supportMdSelectionBold = ['Control', ':']
|
// ctrl + shift + ;
|
||||||
|
this.supportMdSelectionBold = [16, 17, 186]
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
status: 'PREVIEW',
|
status: 'PREVIEW',
|
||||||
renderValue: props.value,
|
renderValue: props.value,
|
||||||
keyPressed: {},
|
keyPressed: new Set(),
|
||||||
isLocked: false
|
isLocked: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +81,6 @@ class MarkdownEditor extends React.Component {
|
|||||||
if (newStatus === 'CODE') {
|
if (newStatus === 'CODE') {
|
||||||
this.refs.code.focus()
|
this.refs.code.focus()
|
||||||
} else {
|
} else {
|
||||||
this.refs.code.blur()
|
|
||||||
this.refs.preview.focus()
|
this.refs.preview.focus()
|
||||||
}
|
}
|
||||||
eventEmitter.emit('topbar:togglelockbutton', this.state.status)
|
eventEmitter.emit('topbar:togglelockbutton', this.state.status)
|
||||||
@@ -87,7 +90,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
|
|
||||||
handleBlur (e) {
|
handleBlur (e) {
|
||||||
if (this.state.isLocked) return
|
if (this.state.isLocked) return
|
||||||
this.setState({ keyPressed: [] })
|
this.setState({ keyPressed: new Set() })
|
||||||
let { config } = this.props
|
let { config } = this.props
|
||||||
if (config.editor.switchPreview === 'BLUR') {
|
if (config.editor.switchPreview === 'BLUR') {
|
||||||
let cursorPosition = this.refs.code.editor.getCursor()
|
let cursorPosition = this.refs.code.editor.getCursor()
|
||||||
@@ -160,16 +163,20 @@ class MarkdownEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleKeyDown (e) {
|
handleKeyDown (e) {
|
||||||
|
let { config } = this.props
|
||||||
if (this.state.status !== 'CODE') return false
|
if (this.state.status !== 'CODE') return false
|
||||||
const keyPressed = Object.assign(this.state.keyPressed, {
|
const keyPressed = this.state.keyPressed
|
||||||
[e.key]: true
|
keyPressed.add(e.keyCode)
|
||||||
})
|
|
||||||
this.setState({ keyPressed })
|
this.setState({ keyPressed })
|
||||||
let isNoteHandlerKey = (el) => { return this.state.keyPressed[el] }
|
let isNoteHandlerKey = (el) => { return keyPressed.has(el) }
|
||||||
if (!this.state.isLocked && this.state.status === 'CODE' && this.escapeFromEditor.every(isNoteHandlerKey)) {
|
// These conditions are for ctrl-e and ctrl-w
|
||||||
document.activeElement.blur()
|
if (keyPressed.size === this.escapeFromEditor.length &&
|
||||||
|
!this.state.isLocked && this.state.status === 'CODE' &&
|
||||||
|
this.escapeFromEditor.every(isNoteHandlerKey)) {
|
||||||
|
this.handleContextMenu()
|
||||||
|
if (config.editor.switchPreview === 'BLUR') document.activeElement.blur()
|
||||||
}
|
}
|
||||||
if (this.supportMdSelectionBold.every(isNoteHandlerKey)) {
|
if (keyPressed.size === this.supportMdSelectionBold.length && this.supportMdSelectionBold.every(isNoteHandlerKey)) {
|
||||||
this.addMdAroundWord('**')
|
this.addMdAroundWord('**')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,9 +197,8 @@ class MarkdownEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleKeyUp (e) {
|
handleKeyUp (e) {
|
||||||
const keyPressed = Object.assign(this.state.keyPressed, {
|
const keyPressed = this.state.keyPressed
|
||||||
[e.key]: false
|
keyPressed.delete(e.keyCode)
|
||||||
})
|
|
||||||
this.setState({ keyPressed })
|
this.setState({ keyPressed })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +207,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { className, value, config } = this.props
|
let { className, value, config, storageKey } = this.props
|
||||||
|
|
||||||
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
|
||||||
@@ -211,6 +217,8 @@ class MarkdownEditor extends React.Component {
|
|||||||
let previewStyle = {}
|
let previewStyle = {}
|
||||||
if (this.props.ignorePreviewPointerEvents) previewStyle.pointerEvents = 'none'
|
if (this.props.ignorePreviewPointerEvents) previewStyle.pointerEvents = 'none'
|
||||||
|
|
||||||
|
const storage = findStorage(storageKey)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className == null
|
<div className={className == null
|
||||||
? 'MarkdownEditor'
|
? 'MarkdownEditor'
|
||||||
@@ -221,7 +229,10 @@ class MarkdownEditor extends React.Component {
|
|||||||
onKeyDown={(e) => this.handleKeyDown(e)}
|
onKeyDown={(e) => this.handleKeyDown(e)}
|
||||||
onKeyUp={(e) => this.handleKeyUp(e)}
|
onKeyUp={(e) => this.handleKeyUp(e)}
|
||||||
>
|
>
|
||||||
<CodeEditor styleName='codeEditor'
|
<CodeEditor styleName={this.state.status === 'CODE'
|
||||||
|
? 'codeEditor'
|
||||||
|
: 'codeEditor--hide'
|
||||||
|
}
|
||||||
ref='code'
|
ref='code'
|
||||||
mode='GitHub Flavored Markdown'
|
mode='GitHub Flavored Markdown'
|
||||||
value={value}
|
value={value}
|
||||||
@@ -231,6 +242,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
fontSize={editorFontSize}
|
fontSize={editorFontSize}
|
||||||
indentType={config.editor.indentType}
|
indentType={config.editor.indentType}
|
||||||
indentSize={editorIndentSize}
|
indentSize={editorIndentSize}
|
||||||
|
storageKey={storageKey}
|
||||||
onChange={(e) => this.handleChange(e)}
|
onChange={(e) => this.handleChange(e)}
|
||||||
onBlur={(e) => this.handleBlur(e)}
|
onBlur={(e) => this.handleBlur(e)}
|
||||||
/>
|
/>
|
||||||
@@ -254,6 +266,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
onMouseUp={(e) => this.handlePreviewMouseUp(e)}
|
onMouseUp={(e) => this.handlePreviewMouseUp(e)}
|
||||||
onMouseDown={(e) => this.handlePreviewMouseDown(e)}
|
onMouseDown={(e) => this.handlePreviewMouseDown(e)}
|
||||||
onCheckboxClick={(e) => this.handleCheckboxClick(e)}
|
onCheckboxClick={(e) => this.handleCheckboxClick(e)}
|
||||||
|
storagePath={storage.path}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,8 +4,14 @@
|
|||||||
.codeEditor
|
.codeEditor
|
||||||
absolute top bottom left right
|
absolute top bottom left right
|
||||||
|
|
||||||
|
.hide
|
||||||
|
z-index 0
|
||||||
|
opacity 0
|
||||||
|
pointer-events none
|
||||||
|
|
||||||
.codeEditor--hide
|
.codeEditor--hide
|
||||||
@extend .codeEditor
|
@extend .codeEditor
|
||||||
|
@extend .hide
|
||||||
|
|
||||||
.preview
|
.preview
|
||||||
display block
|
display block
|
||||||
@@ -17,7 +23,5 @@
|
|||||||
|
|
||||||
.preview--hide
|
.preview--hide
|
||||||
@extend .preview
|
@extend .preview
|
||||||
z-index 0
|
@extend .hide
|
||||||
opacity 0
|
|
||||||
pointer-events none
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,21 +8,8 @@ import flowchart from 'flowchart'
|
|||||||
import SequenceDiagram from 'js-sequence-diagrams'
|
import SequenceDiagram from 'js-sequence-diagrams'
|
||||||
import eventEmitter from 'browser/main/lib/eventEmitter'
|
import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
import htmlTextHelper from 'browser/lib/htmlTextHelper'
|
||||||
function decodeHTMLEntities (text) {
|
import copy from 'copy-to-clipboard'
|
||||||
var entities = [
|
|
||||||
['apos', '\''],
|
|
||||||
['amp', '&'],
|
|
||||||
['lt', '<'],
|
|
||||||
['gt', '>']
|
|
||||||
]
|
|
||||||
|
|
||||||
for (var i = 0, max = entities.length; i < max; ++i) {
|
|
||||||
text = text.replace(new RegExp('&' + entities[i][0] + ';', 'g'), entities[i][1])
|
|
||||||
}
|
|
||||||
|
|
||||||
return text
|
|
||||||
}
|
|
||||||
|
|
||||||
const { remote } = require('electron')
|
const { remote } = require('electron')
|
||||||
const { app } = remote
|
const { app } = remote
|
||||||
@@ -60,6 +47,26 @@ code {
|
|||||||
font-family: ${codeBlockFontFamily.join(', ')};
|
font-family: ${codeBlockFontFamily.join(', ')};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clipboardButton {
|
||||||
|
color: rgba(147,147,149,0.8);;
|
||||||
|
fill: rgba(147,147,149,1);;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin: 7px;
|
||||||
|
border: none;
|
||||||
|
background-color: transparent;
|
||||||
|
outline: none;
|
||||||
|
height: 32px;
|
||||||
|
width: 32px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clipboardButton:hover {
|
||||||
|
transition: 0.2s;
|
||||||
|
color: #939395;
|
||||||
|
fill: #939395;
|
||||||
|
background-color: rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
h1, h2 {
|
h1, h2 {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
@@ -73,6 +80,10 @@ h2 {
|
|||||||
padding-bottom: 0.2em;
|
padding-bottom: 0.2em;
|
||||||
margin: 1em 0 0.37em;
|
margin: 1em 0 0.37em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body p {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +108,9 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
this.checkboxClickHandler = (e) => this.handleCheckboxClick(e)
|
this.checkboxClickHandler = (e) => this.handleCheckboxClick(e)
|
||||||
this.saveAsTextHandler = () => this.handleSaveAsText()
|
this.saveAsTextHandler = () => this.handleSaveAsText()
|
||||||
this.saveAsMdHandler = () => this.handleSaveAsMd()
|
this.saveAsMdHandler = () => this.handleSaveAsMd()
|
||||||
|
this.printHandler = () => this.handlePrint()
|
||||||
|
|
||||||
|
this.linkClickHandler = this.handlelinkClick.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePreviewAnchorClick (e) {
|
handlePreviewAnchorClick (e) {
|
||||||
@@ -149,6 +163,10 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
this.exportAsDocument('md')
|
this.exportAsDocument('md')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePrint () {
|
||||||
|
this.refs.root.contentWindow.print()
|
||||||
|
}
|
||||||
|
|
||||||
exportAsDocument (fileType) {
|
exportAsDocument (fileType) {
|
||||||
const options = {
|
const options = {
|
||||||
filters: [
|
filters: [
|
||||||
@@ -185,6 +203,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
this.refs.root.contentWindow.document.addEventListener('dragover', this.preventImageDroppedHandler)
|
this.refs.root.contentWindow.document.addEventListener('dragover', this.preventImageDroppedHandler)
|
||||||
eventEmitter.on('export:save-text', this.saveAsTextHandler)
|
eventEmitter.on('export:save-text', this.saveAsTextHandler)
|
||||||
eventEmitter.on('export:save-md', this.saveAsMdHandler)
|
eventEmitter.on('export:save-md', this.saveAsMdHandler)
|
||||||
|
eventEmitter.on('print', this.printHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
@@ -195,6 +214,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
this.refs.root.contentWindow.document.removeEventListener('dragover', this.preventImageDroppedHandler)
|
this.refs.root.contentWindow.document.removeEventListener('dragover', this.preventImageDroppedHandler)
|
||||||
eventEmitter.off('export:save-text', this.saveAsTextHandler)
|
eventEmitter.off('export:save-text', this.saveAsTextHandler)
|
||||||
eventEmitter.off('export:save-md', this.saveAsMdHandler)
|
eventEmitter.off('export:save-md', this.saveAsMdHandler)
|
||||||
|
eventEmitter.off('print', this.printHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate (prevProps) {
|
componentDidUpdate (prevProps) {
|
||||||
@@ -238,9 +258,20 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
el.removeEventListener('click', this.checkboxClickHandler)
|
el.removeEventListener('click', this.checkboxClickHandler)
|
||||||
})
|
})
|
||||||
|
|
||||||
let { value, theme, indentSize, codeBlockTheme } = this.props
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
||||||
|
el.removeEventListener('click', this.linkClickHandler)
|
||||||
|
})
|
||||||
|
|
||||||
|
let { value, theme, indentSize, codeBlockTheme, storagePath } = this.props
|
||||||
|
|
||||||
this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)
|
this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)
|
||||||
|
|
||||||
|
const codeBlocks = value.match(/(```)(.|[\n])*?(```)/g)
|
||||||
|
if (codeBlocks !== null) {
|
||||||
|
codeBlocks.forEach((codeBlock) => {
|
||||||
|
value = value.replace(codeBlock, htmlTextHelper.encodeEntities(codeBlock))
|
||||||
|
})
|
||||||
|
}
|
||||||
this.refs.root.contentWindow.document.body.innerHTML = markdown.render(value)
|
this.refs.root.contentWindow.document.body.innerHTML = markdown.render(value)
|
||||||
|
|
||||||
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.taskListItem'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.taskListItem'), (el) => {
|
||||||
@@ -255,6 +286,15 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
el.addEventListener('click', this.checkboxClickHandler)
|
el.addEventListener('click', this.checkboxClickHandler)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
|
||||||
|
el.addEventListener('click', this.linkClickHandler)
|
||||||
|
})
|
||||||
|
|
||||||
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('img'), (el) => {
|
||||||
|
if (!/\/:storage/.test(el.src)) return
|
||||||
|
el.src = `file:///${path.join(storagePath, 'images', path.basename(el.src))}`
|
||||||
|
})
|
||||||
|
|
||||||
codeBlockTheme = consts.THEMES.some((_theme) => _theme === codeBlockTheme)
|
codeBlockTheme = consts.THEMES.some((_theme) => _theme === codeBlockTheme)
|
||||||
? codeBlockTheme
|
? codeBlockTheme
|
||||||
: 'default'
|
: 'default'
|
||||||
@@ -263,7 +303,17 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
let syntax = CodeMirror.findModeByName(el.className)
|
let syntax = CodeMirror.findModeByName(el.className)
|
||||||
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
|
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
|
||||||
CodeMirror.requireMode(syntax.mode, () => {
|
CodeMirror.requireMode(syntax.mode, () => {
|
||||||
let content = decodeHTMLEntities(el.innerHTML)
|
let content = htmlTextHelper.decodeEntities(el.innerHTML)
|
||||||
|
const copyIcon = document.createElement('i')
|
||||||
|
copyIcon.innerHTML = '<button class="clipboardButton"><svg width="13" height="13" viewBox="0 0 1792 1792" ><path d="M768 1664h896v-640h-416q-40 0-68-28t-28-68v-416h-384v1152zm256-1440v-64q0-13-9.5-22.5t-22.5-9.5h-704q-13 0-22.5 9.5t-9.5 22.5v64q0 13 9.5 22.5t22.5 9.5h704q13 0 22.5-9.5t9.5-22.5zm256 672h299l-299-299v299zm512 128v672q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-160h-544q-40 0-68-28t-28-68v-1344q0-40 28-68t68-28h1088q40 0 68 28t28 68v328q21 13 36 28l408 408q28 28 48 76t20 88z"/></svg></button>'
|
||||||
|
copyIcon.onclick = (e) => {
|
||||||
|
copy(content)
|
||||||
|
this.notify('Saved to Clipboard!', {
|
||||||
|
body: 'Paste it wherever you want!',
|
||||||
|
silent: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
el.parentNode.appendChild(copyIcon)
|
||||||
el.innerHTML = ''
|
el.innerHTML = ''
|
||||||
el.parentNode.className += ` cm-s-${codeBlockTheme} CodeMirror`
|
el.parentNode.className += ` cm-s-${codeBlockTheme} CodeMirror`
|
||||||
CodeMirror.runMode(content, syntax.mime, el, {
|
CodeMirror.runMode(content, syntax.mime, el, {
|
||||||
@@ -281,7 +331,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.flowchart'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.flowchart'), (el) => {
|
||||||
Raphael.setWindow(this.getWindow())
|
Raphael.setWindow(this.getWindow())
|
||||||
try {
|
try {
|
||||||
let diagram = flowchart.parse(decodeHTMLEntities(el.innerHTML))
|
let diagram = flowchart.parse(htmlTextHelper.decodeEntities(el.innerHTML))
|
||||||
el.innerHTML = ''
|
el.innerHTML = ''
|
||||||
diagram.drawSVG(el, opts)
|
diagram.drawSVG(el, opts)
|
||||||
_.forEach(el.querySelectorAll('a'), (el) => {
|
_.forEach(el.querySelectorAll('a'), (el) => {
|
||||||
@@ -297,7 +347,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.sequence'), (el) => {
|
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.sequence'), (el) => {
|
||||||
Raphael.setWindow(this.getWindow())
|
Raphael.setWindow(this.getWindow())
|
||||||
try {
|
try {
|
||||||
let diagram = SequenceDiagram.parse(decodeHTMLEntities(el.innerHTML))
|
let diagram = SequenceDiagram.parse(htmlTextHelper.decodeEntities(el.innerHTML))
|
||||||
el.innerHTML = ''
|
el.innerHTML = ''
|
||||||
diagram.drawSVG(el, {theme: 'simple'})
|
diagram.drawSVG(el, {theme: 'simple'})
|
||||||
_.forEach(el.querySelectorAll('a'), (el) => {
|
_.forEach(el.querySelectorAll('a'), (el) => {
|
||||||
@@ -338,6 +388,21 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notify (title, options) {
|
||||||
|
if (global.process.platform === 'win32') {
|
||||||
|
options.icon = path.join('file://', global.__dirname, '../../resources/app.png')
|
||||||
|
}
|
||||||
|
return new window.Notification(title, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
handlelinkClick (e) {
|
||||||
|
const noteHash = e.target.href.split('/').pop()
|
||||||
|
const regexIsNoteLink = /^(.{20})-(.{20})$/
|
||||||
|
if (regexIsNoteLink.test(noteHash)) {
|
||||||
|
eventEmitter.emit('list:jump', noteHash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { className, style, tabIndex } = this.props
|
let { className, style, tabIndex } = this.props
|
||||||
return (
|
return (
|
||||||
@@ -359,5 +424,6 @@ MarkdownPreview.propTypes = {
|
|||||||
onMouseUp: PropTypes.func,
|
onMouseUp: PropTypes.func,
|
||||||
onMouseDown: PropTypes.func,
|
onMouseDown: PropTypes.func,
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
value: PropTypes.string
|
value: PropTypes.string,
|
||||||
|
storagePath: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|||||||
18
browser/components/ModalEscButton.js
Normal file
18
browser/components/ModalEscButton.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import React, {PropTypes} from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './ModalEscButton.styl'
|
||||||
|
|
||||||
|
const ModalEscButton = ({
|
||||||
|
handleEscButtonClick
|
||||||
|
}) => (
|
||||||
|
<button styleName='escButton' onClick={handleEscButtonClick}>
|
||||||
|
<div styleName='esc-mark'>x</div>
|
||||||
|
<div styleName='esc-text'>esc</div>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
|
||||||
|
ModalEscButton.propTypes = {
|
||||||
|
handleEscButtonClick: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(ModalEscButton, styles)
|
||||||
14
browser/components/ModalEscButton.styl
Normal file
14
browser/components/ModalEscButton.styl
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
.escButton
|
||||||
|
height 50px
|
||||||
|
position absolute
|
||||||
|
background-color transparent
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
border none
|
||||||
|
top 1px
|
||||||
|
right 10px
|
||||||
|
text-align center
|
||||||
|
width top-bar--height
|
||||||
|
height top-bar-height
|
||||||
|
|
||||||
|
.esc-mark
|
||||||
|
font-size 15px
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
import React, { PropTypes } from 'react'
|
import React, { PropTypes } from 'react'
|
||||||
import { isArray } from 'lodash'
|
import { isArray } from 'lodash'
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import { getTodoStatus } from 'browser/lib/getTodoStatus'
|
||||||
import styles from './NoteItem.styl'
|
import styles from './NoteItem.styl'
|
||||||
|
import TodoProcess from './TodoProcess'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Tag element component.
|
* @description Tag element component.
|
||||||
@@ -39,17 +41,18 @@ const TagElementList = (tags) => {
|
|||||||
* @param {boolean} isActive
|
* @param {boolean} isActive
|
||||||
* @param {Object} note
|
* @param {Object} note
|
||||||
* @param {Function} handleNoteClick
|
* @param {Function} handleNoteClick
|
||||||
* @param {Function} handleNoteContextMenu
|
* @param {Function} handleDragStart
|
||||||
* @param {string} dateDisplay
|
* @param {string} dateDisplay
|
||||||
*/
|
*/
|
||||||
const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteContextMenu }) => (
|
const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleDragStart }) => (
|
||||||
<div styleName={isActive
|
<div styleName={isActive
|
||||||
? 'item--active'
|
? 'item--active'
|
||||||
: 'item'
|
: 'item'
|
||||||
}
|
}
|
||||||
key={`${note.storage}-${note.key}`}
|
key={`${note.storage}-${note.key}`}
|
||||||
onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)}
|
onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)}
|
||||||
onContextMenu={e => handleNoteContextMenu(e, `${note.storage}-${note.key}`)}
|
onDragStart={e => handleDragStart(e, note)}
|
||||||
|
draggable='true'
|
||||||
>
|
>
|
||||||
<div styleName='item-wrapper'>
|
<div styleName='item-wrapper'>
|
||||||
{note.type === 'SNIPPET_NOTE'
|
{note.type === 'SNIPPET_NOTE'
|
||||||
@@ -67,6 +70,10 @@ const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteCont
|
|||||||
{note.isStarred
|
{note.isStarred
|
||||||
? <i styleName='item-star' className='fa fa-star' /> : ''
|
? <i styleName='item-star' className='fa fa-star' /> : ''
|
||||||
}
|
}
|
||||||
|
{note.type === 'MARKDOWN_NOTE'
|
||||||
|
? <TodoProcess todoStatus={getTodoStatus(note.content)} />
|
||||||
|
: ''
|
||||||
|
}
|
||||||
<div styleName='item-bottom'>
|
<div styleName='item-bottom'>
|
||||||
<div styleName='item-bottom-tagList'>
|
<div styleName='item-bottom-tagList'>
|
||||||
{note.tags.length > 0
|
{note.tags.length > 0
|
||||||
@@ -88,10 +95,12 @@ NoteItem.propTypes = {
|
|||||||
type: PropTypes.string.isRequired,
|
type: PropTypes.string.isRequired,
|
||||||
title: PropTypes.string.isrequired,
|
title: PropTypes.string.isrequired,
|
||||||
tags: PropTypes.array,
|
tags: PropTypes.array,
|
||||||
isStarred: PropTypes.bool.isRequired
|
isStarred: PropTypes.bool.isRequired,
|
||||||
|
isTrashed: PropTypes.bool.isRequired
|
||||||
}),
|
}),
|
||||||
handleNoteClick: PropTypes.func.isRequired,
|
handleNoteClick: PropTypes.func.isRequired,
|
||||||
handleNoteContextMenu: PropTypes.func.isRequired
|
handleDragStart: PropTypes.func.isRequired,
|
||||||
|
handleDragEnd: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(NoteItem, styles)
|
export default CSSModules(NoteItem, styles)
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ $control-height = 30px
|
|||||||
.item-bottom-tagList-item
|
.item-bottom-tagList-item
|
||||||
background-color alpha(white, 0.6)
|
background-color alpha(white, 0.6)
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
.item-star
|
||||||
|
color $ui-favorite-star-button-color
|
||||||
&:active
|
&:active
|
||||||
background-color $ui-button--active-backgroundColor
|
background-color $ui-button--active-backgroundColor
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
@@ -37,6 +39,7 @@ $control-height = 30px
|
|||||||
.item-wrapper
|
.item-wrapper
|
||||||
padding 15px 0
|
padding 15px 0
|
||||||
border-bottom $ui-border
|
border-bottom $ui-border
|
||||||
|
position relative
|
||||||
|
|
||||||
.item--active
|
.item--active
|
||||||
@extend .item
|
@extend .item
|
||||||
@@ -53,6 +56,8 @@ $control-height = 30px
|
|||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
.item-wrapper
|
.item-wrapper
|
||||||
border-color transparent
|
border-color transparent
|
||||||
|
.item-star
|
||||||
|
color $ui-favorite-star-button-color
|
||||||
&:hover
|
&:hover
|
||||||
background-color $ui-button--active-backgroundColor
|
background-color $ui-button--active-backgroundColor
|
||||||
|
|
||||||
@@ -62,7 +67,7 @@ $control-height = 30px
|
|||||||
color $ui-inactive-text-color
|
color $ui-inactive-text-color
|
||||||
|
|
||||||
.item-title
|
.item-title
|
||||||
font-size 13px
|
font-size 14px
|
||||||
position relative
|
position relative
|
||||||
top -12px
|
top -12px
|
||||||
left 20px
|
left 20px
|
||||||
@@ -79,7 +84,6 @@ $control-height = 30px
|
|||||||
position relative
|
position relative
|
||||||
bottom 0px
|
bottom 0px
|
||||||
margin-top 2px
|
margin-top 2px
|
||||||
height 20px
|
|
||||||
font-size 12px
|
font-size 12px
|
||||||
line-height 20px
|
line-height 20px
|
||||||
overflow ellipsis
|
overflow ellipsis
|
||||||
@@ -89,10 +93,12 @@ $control-height = 30px
|
|||||||
flex 1
|
flex 1
|
||||||
overflow ellipsis
|
overflow ellipsis
|
||||||
line-height 20px
|
line-height 20px
|
||||||
|
padding-top 7px
|
||||||
padding-left 2px
|
padding-left 2px
|
||||||
|
margin-right 27px
|
||||||
|
|
||||||
.item-bottom-tagList-item
|
.item-bottom-tagList-item
|
||||||
font-size 10px
|
font-size 11px
|
||||||
margin-right 8px
|
margin-right 8px
|
||||||
padding 0
|
padding 0
|
||||||
height 20px
|
height 20px
|
||||||
@@ -105,17 +111,17 @@ $control-height = 30px
|
|||||||
|
|
||||||
.item-bottom-time
|
.item-bottom-time
|
||||||
color $ui-inactive-text-color
|
color $ui-inactive-text-color
|
||||||
font-size 10px
|
font-size 11px
|
||||||
padding-left 2px
|
padding-left 2px
|
||||||
padding-bottom 2px
|
padding-bottom 2px
|
||||||
|
|
||||||
.item-star
|
.item-star
|
||||||
position absolute
|
position absolute
|
||||||
top 19px
|
right -20px
|
||||||
left 5px
|
bottom 2px
|
||||||
width 34px
|
width 34px
|
||||||
height 34px
|
height 34px
|
||||||
color $ui-favorite-star-button-color
|
color alpha($ui-favorite-star-button-color, 60%)
|
||||||
font-size 12px
|
font-size 12px
|
||||||
padding 0
|
padding 0
|
||||||
border-radius 17px
|
border-radius 17px
|
||||||
@@ -154,7 +160,7 @@ body[data-theme="dark"]
|
|||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
|
|
||||||
.item-wrapper
|
.item-wrapper
|
||||||
border-color $ui-dark-borderColor
|
border-color alpha($ui-dark-button--active-backgroundColor, 60%)
|
||||||
|
|
||||||
.item--active
|
.item--active
|
||||||
border-color $ui-dark-borderColor
|
border-color $ui-dark-borderColor
|
||||||
|
|||||||
@@ -10,16 +10,17 @@ import styles from './NoteItemSimple.styl'
|
|||||||
* @param {boolean} isActive
|
* @param {boolean} isActive
|
||||||
* @param {Object} note
|
* @param {Object} note
|
||||||
* @param {Function} handleNoteClick
|
* @param {Function} handleNoteClick
|
||||||
* @param {Function} handleNoteContextMenu
|
* @param {Function} handleDragStart
|
||||||
*/
|
*/
|
||||||
const NoteItemSimple = ({ isActive, note, handleNoteClick, handleNoteContextMenu }) => (
|
const NoteItemSimple = ({ isActive, note, handleNoteClick, handleDragStart }) => (
|
||||||
<div styleName={isActive
|
<div styleName={isActive
|
||||||
? 'item-simple--active'
|
? 'item-simple--active'
|
||||||
: 'item-simple'
|
: 'item-simple'
|
||||||
}
|
}
|
||||||
key={`${note.storage}-${note.key}`}
|
key={`${note.storage}-${note.key}`}
|
||||||
onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)}
|
onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)}
|
||||||
onContextMenu={e => handleNoteContextMenu(e, `${note.storage}-${note.key}`)}
|
onDragStart={e => handleDragStart(e, note)}
|
||||||
|
draggable='true'
|
||||||
>
|
>
|
||||||
<div styleName='item-simple-title'>
|
<div styleName='item-simple-title'>
|
||||||
{note.type === 'SNIPPET_NOTE'
|
{note.type === 'SNIPPET_NOTE'
|
||||||
@@ -43,7 +44,7 @@ NoteItemSimple.propTypes = {
|
|||||||
title: PropTypes.string.isrequired
|
title: PropTypes.string.isrequired
|
||||||
}),
|
}),
|
||||||
handleNoteClick: PropTypes.func.isRequired,
|
handleNoteClick: PropTypes.func.isRequired,
|
||||||
handleNoteContextMenu: PropTypes.func.isRequired
|
handleDragStart: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(NoteItemSimple, styles)
|
export default CSSModules(NoteItemSimple, styles)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ $control-height = 30px
|
|||||||
|
|
||||||
.item-simple
|
.item-simple
|
||||||
position relative
|
position relative
|
||||||
padding 0 25px
|
padding 0 20px
|
||||||
user-select none
|
user-select none
|
||||||
cursor pointer
|
cursor pointer
|
||||||
background-color $ui-noteList-backgroundColor
|
background-color $ui-noteList-backgroundColor
|
||||||
@@ -40,7 +40,7 @@ $control-height = 30px
|
|||||||
background-color $ui-button--active-backgroundColor
|
background-color $ui-button--active-backgroundColor
|
||||||
|
|
||||||
.item-simple-title
|
.item-simple-title
|
||||||
font-size 12px
|
font-size 13px
|
||||||
height 40px
|
height 40px
|
||||||
box-sizing border-box
|
box-sizing border-box
|
||||||
line-height 24px
|
line-height 24px
|
||||||
@@ -48,6 +48,7 @@ $control-height = 30px
|
|||||||
overflow ellipsis
|
overflow ellipsis
|
||||||
color $ui-inactive-text-color
|
color $ui-inactive-text-color
|
||||||
border-bottom $ui-border
|
border-bottom $ui-border
|
||||||
|
position relative
|
||||||
|
|
||||||
.item-simple-title-icon
|
.item-simple-title-icon
|
||||||
font-size 12px
|
font-size 12px
|
||||||
@@ -96,7 +97,7 @@ body[data-theme="dark"]
|
|||||||
|
|
||||||
.item-simple-title
|
.item-simple-title
|
||||||
color $ui-inactive-text-color
|
color $ui-inactive-text-color
|
||||||
border-color $ui-dark-borderColor
|
border-color alpha($ui-dark-button--active-backgroundColor, 60%)
|
||||||
|
|
||||||
.item-simple-title-icon
|
.item-simple-title-icon
|
||||||
color $ui-darkinactive-text-color
|
color $ui-darkinactive-text-color
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import React, { PropTypes } from 'react'
|
|
||||||
import md5 from 'md5'
|
|
||||||
|
|
||||||
export default class ProfileImage extends React.Component {
|
|
||||||
render () {
|
|
||||||
let className = this.props.className == null ? 'ProfileImage' : 'ProfileImage ' + this.props.className
|
|
||||||
let email = this.props.email != null ? this.props.email : ''
|
|
||||||
let src = 'http://www.gravatar.com/avatar/' + md5(email.trim().toLowerCase()) + '?s=' + this.props.size
|
|
||||||
|
|
||||||
return (
|
|
||||||
<img
|
|
||||||
className={className}
|
|
||||||
width={this.props.size}
|
|
||||||
height={this.props.size}
|
|
||||||
src={src} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfileImage.propTypes = {
|
|
||||||
email: PropTypes.string,
|
|
||||||
size: PropTypes.string,
|
|
||||||
className: PropTypes.string
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ import styles from './SideNavFilter.styl'
|
|||||||
*/
|
*/
|
||||||
const SideNavFilter = ({
|
const SideNavFilter = ({
|
||||||
isFolded, isHomeActive, handleAllNotesButtonClick,
|
isFolded, isHomeActive, handleAllNotesButtonClick,
|
||||||
isStarredActive, handleStarredButtonClick
|
isStarredActive, handleStarredButtonClick, isTrashedActive, handleTrashedButtonClick
|
||||||
}) => (
|
}) => (
|
||||||
<div styleName={isFolded ? 'menu--folded' : 'menu'}>
|
<div styleName={isFolded ? 'menu--folded' : 'menu'}>
|
||||||
<button styleName={isHomeActive ? 'menu-button--active' : 'menu-button'}
|
<button styleName={isHomeActive ? 'menu-button--active' : 'menu-button'}
|
||||||
@@ -30,6 +30,12 @@ const SideNavFilter = ({
|
|||||||
<i className='fa fa-star fa-fw' />
|
<i className='fa fa-star fa-fw' />
|
||||||
<span styleName='menu-button-label'>Starred</span>
|
<span styleName='menu-button-label'>Starred</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button styleName={isTrashedActive ? 'menu-button--active' : 'menu-button'}
|
||||||
|
onClick={handleTrashedButtonClick}
|
||||||
|
>
|
||||||
|
<i className='fa fa-trash fa-fw' />
|
||||||
|
<span styleName='menu-button-label'>Trash</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -38,7 +44,9 @@ SideNavFilter.propTypes = {
|
|||||||
isHomeActive: PropTypes.bool.isRequired,
|
isHomeActive: PropTypes.bool.isRequired,
|
||||||
handleAllNotesButtonClick: PropTypes.func.isRequired,
|
handleAllNotesButtonClick: PropTypes.func.isRequired,
|
||||||
isStarredActive: PropTypes.bool.isRequired,
|
isStarredActive: PropTypes.bool.isRequired,
|
||||||
handleStarredButtonClick: PropTypes.func.isRequired
|
isTrashedActive: PropTypes.bool.isRequired,
|
||||||
|
handleStarredButtonClick: PropTypes.func.isRequired,
|
||||||
|
handleTrashdButtonClick: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(SideNavFilter, styles)
|
export default CSSModules(SideNavFilter, styles)
|
||||||
|
|||||||
@@ -14,11 +14,14 @@ import { isNumber } from 'lodash'
|
|||||||
* @param {string} folderColor
|
* @param {string} folderColor
|
||||||
* @param {boolean} isFolded
|
* @param {boolean} isFolded
|
||||||
* @param {number} noteCount
|
* @param {number} noteCount
|
||||||
|
* @param {Function} handleDrop
|
||||||
|
* @param {Function} handleDragEnter
|
||||||
|
* @param {Function} handleDragOut
|
||||||
* @return {React.Component}
|
* @return {React.Component}
|
||||||
*/
|
*/
|
||||||
const StorageItem = ({
|
const StorageItem = ({
|
||||||
isActive, handleButtonClick, handleContextMenu, folderName,
|
isActive, handleButtonClick, handleContextMenu, folderName,
|
||||||
folderColor, isFolded, noteCount
|
folderColor, isFolded, noteCount, handleDrop, handleDragEnter, handleDragLeave
|
||||||
}) => (
|
}) => (
|
||||||
<button styleName={isActive
|
<button styleName={isActive
|
||||||
? 'folderList-item--active'
|
? 'folderList-item--active'
|
||||||
@@ -26,6 +29,9 @@ const StorageItem = ({
|
|||||||
}
|
}
|
||||||
onClick={handleButtonClick}
|
onClick={handleButtonClick}
|
||||||
onContextMenu={handleContextMenu}
|
onContextMenu={handleContextMenu}
|
||||||
|
onDrop={handleDrop}
|
||||||
|
onDragEnter={handleDragEnter}
|
||||||
|
onDragLeave={handleDragLeave}
|
||||||
>
|
>
|
||||||
<span styleName={isFolded
|
<span styleName={isFolded
|
||||||
? 'folderList-item-name--folded' : 'folderList-item-name'
|
? 'folderList-item-name--folded' : 'folderList-item-name'
|
||||||
@@ -52,6 +58,8 @@ StorageItem.propTypes = {
|
|||||||
folderName: PropTypes.string.isRequired,
|
folderName: PropTypes.string.isRequired,
|
||||||
folderColor: PropTypes.string,
|
folderColor: PropTypes.string,
|
||||||
isFolded: PropTypes.bool.isRequired,
|
isFolded: PropTypes.bool.isRequired,
|
||||||
|
handleDragEnter: PropTypes.func.isRequired,
|
||||||
|
handleDragLeave: PropTypes.func.isRequired,
|
||||||
noteCount: PropTypes.number
|
noteCount: PropTypes.number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
.folderList-item-name
|
.folderList-item-name
|
||||||
display block
|
display block
|
||||||
flex 1
|
flex 1
|
||||||
padding 0 15px
|
padding 0 25px
|
||||||
height 26px
|
height 26px
|
||||||
line-height 26px
|
line-height 26px
|
||||||
border-width 0 0 0 2px
|
border-width 0 0 0 2px
|
||||||
|
|||||||
27
browser/components/TodoListPercentage.js
Normal file
27
browser/components/TodoListPercentage.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* @fileoverview Percentage of todo achievement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './TodoListPercentage.styl'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} percentageOfTodo
|
||||||
|
*/
|
||||||
|
|
||||||
|
const TodoListPercentage = ({
|
||||||
|
percentageOfTodo
|
||||||
|
}) => (
|
||||||
|
<div styleName='percentageBar' style={{display: isNaN(percentageOfTodo) ? 'none' : ''}}>
|
||||||
|
<div styleName='progressBar' style={{width: `${percentageOfTodo}%`}}>
|
||||||
|
<p styleName='percentageText'>{percentageOfTodo}%</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
TodoListPercentage.propTypes = {
|
||||||
|
percentageOfTodo: PropTypes.number.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(TodoListPercentage, styles)
|
||||||
31
browser/components/TodoListPercentage.styl
Normal file
31
browser/components/TodoListPercentage.styl
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
.percentageBar
|
||||||
|
position absolute
|
||||||
|
top 58px
|
||||||
|
right: 0px
|
||||||
|
left 0px
|
||||||
|
background-color #DADFE1
|
||||||
|
width 100%
|
||||||
|
height: 15px
|
||||||
|
font-size: 12px
|
||||||
|
z-index 100
|
||||||
|
border-radius 2px
|
||||||
|
|
||||||
|
.progressBar
|
||||||
|
background-color: #6C7A89
|
||||||
|
height 15px
|
||||||
|
border-radius 2px
|
||||||
|
transition 0.3s
|
||||||
|
|
||||||
|
.percentageText
|
||||||
|
color #f4f4f4
|
||||||
|
padding: 2px 43%
|
||||||
|
|
||||||
|
body[data-theme="dark"]
|
||||||
|
.percentageBar
|
||||||
|
background-color #363A3D
|
||||||
|
|
||||||
|
.progressBar
|
||||||
|
background-color: alpha(#939395, 50%)
|
||||||
|
|
||||||
|
.percentageText
|
||||||
|
color $ui-dark-text-color
|
||||||
33
browser/components/TodoProcess.js
Normal file
33
browser/components/TodoProcess.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* @fileoverview Percentage of todo achievement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './TodoProcess.styl'
|
||||||
|
|
||||||
|
const TodoProcess = ({
|
||||||
|
todoStatus: {
|
||||||
|
total: totalTodo,
|
||||||
|
completed: completedTodo
|
||||||
|
}
|
||||||
|
}) => (
|
||||||
|
<div styleName='todo-process' style={{display: totalTodo > 0 ? '' : 'none'}}>
|
||||||
|
<div styleName='todo-process-text'>
|
||||||
|
<i className='fa fa-fw fa-check-square-o' />
|
||||||
|
{completedTodo} of {totalTodo}
|
||||||
|
</div>
|
||||||
|
<div styleName='todo-process-bar'>
|
||||||
|
<div styleName='todo-process-bar--inner' style={{width: parseInt(completedTodo / totalTodo * 100) + '%'}} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
TodoProcess.propTypes = {
|
||||||
|
todoStatus: {
|
||||||
|
total: PropTypes.number.isRequired,
|
||||||
|
completed: PropTypes.number.isRequired
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(TodoProcess, styles)
|
||||||
45
browser/components/TodoProcess.styl
Normal file
45
browser/components/TodoProcess.styl
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
.todo-process
|
||||||
|
font-size 12px
|
||||||
|
display flex
|
||||||
|
padding-top 15px
|
||||||
|
width 85%
|
||||||
|
|
||||||
|
.todo-process-text
|
||||||
|
display inline-block
|
||||||
|
padding-right 10px
|
||||||
|
white-space nowrap
|
||||||
|
text-overflow ellipsis
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
i
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
padding-right 5px
|
||||||
|
|
||||||
|
.todo-process-bar
|
||||||
|
display inline-block
|
||||||
|
margin auto
|
||||||
|
height 4px
|
||||||
|
border-radius 10px
|
||||||
|
background-color #DADFE1
|
||||||
|
border-radius 2px
|
||||||
|
flex-grow 1
|
||||||
|
border 1px solid alpha(#6C7A89, 10%)
|
||||||
|
|
||||||
|
.todo-process-bar--inner
|
||||||
|
height 100%
|
||||||
|
border-radius 5px
|
||||||
|
background-color #6C7A89
|
||||||
|
transition 0.3s
|
||||||
|
|
||||||
|
|
||||||
|
body[data-theme="dark"]
|
||||||
|
.todo-process
|
||||||
|
color $ui-dark-text-color
|
||||||
|
|
||||||
|
.todo-process-bar
|
||||||
|
background-color #363A3D
|
||||||
|
|
||||||
|
.todo-process-text
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
|
||||||
|
.todo-process-bar--inner
|
||||||
|
background-color: alpha(#939395, 50%)
|
||||||
@@ -270,7 +270,7 @@ table
|
|||||||
border-right solid 1px borderColor
|
border-right solid 1px borderColor
|
||||||
|
|
||||||
themeDarkBackground = darken(#21252B, 10%)
|
themeDarkBackground = darken(#21252B, 10%)
|
||||||
themeDarkText = #DDDDDD
|
themeDarkText = #f9f9f9
|
||||||
themeDarkBorder = lighten(themeDarkBackground, 20%)
|
themeDarkBorder = lighten(themeDarkBackground, 20%)
|
||||||
themeDarkPreview = $ui-dark-noteDetail-backgroundColor
|
themeDarkPreview = $ui-dark-noteDetail-backgroundColor
|
||||||
themeDarkTableOdd = themeDarkPreview
|
themeDarkTableOdd = themeDarkPreview
|
||||||
@@ -288,8 +288,9 @@ body[data-theme="dark"]
|
|||||||
background-color alpha(lighten(brandColor, 30%), 0.2) !important
|
background-color alpha(lighten(brandColor, 30%), 0.2) !important
|
||||||
|
|
||||||
code
|
code
|
||||||
|
color #EA6730
|
||||||
border-color darken(themeDarkBorder, 10%)
|
border-color darken(themeDarkBorder, 10%)
|
||||||
background-color lighten(themeDarkPreview, 10%)
|
background-color lighten(themeDarkPreview, 5%)
|
||||||
|
|
||||||
pre
|
pre
|
||||||
border-color lighten(#21252B, 20%)
|
border-color lighten(#21252B, 20%)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ $list-width = 250px
|
|||||||
|
|
||||||
.result-nav-storageList
|
.result-nav-storageList
|
||||||
absolute bottom left right
|
absolute bottom left right
|
||||||
top 80px + 32px + 10px + 10px
|
top 110px + 32px + 10px + 10px
|
||||||
overflow-y auto
|
overflow-y auto
|
||||||
|
|
||||||
.result-list
|
.result-list
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import MarkdownPreview from 'browser/components/MarkdownPreview'
|
|||||||
import MarkdownEditor from 'browser/components/MarkdownEditor'
|
import MarkdownEditor from 'browser/components/MarkdownEditor'
|
||||||
import CodeEditor from 'browser/components/CodeEditor'
|
import CodeEditor from 'browser/components/CodeEditor'
|
||||||
import CodeMirror from 'codemirror'
|
import CodeMirror from 'codemirror'
|
||||||
|
import { findStorage } from 'browser/lib/findStorage'
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { clipboard } = electron
|
const { clipboard } = electron
|
||||||
@@ -106,6 +107,8 @@ class NoteDetail extends React.Component {
|
|||||||
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
||||||
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
|
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
|
||||||
|
|
||||||
|
const storage = findStorage(note.storage)
|
||||||
|
|
||||||
if (note.type === 'SNIPPET_NOTE') {
|
if (note.type === 'SNIPPET_NOTE') {
|
||||||
let tabList = note.snippets.map((snippet, index) => {
|
let tabList = note.snippets.map((snippet, index) => {
|
||||||
let isActive = this.state.snippetIndex === index
|
let isActive = this.state.snippetIndex === index
|
||||||
@@ -143,6 +146,7 @@ class NoteDetail extends React.Component {
|
|||||||
config={config}
|
config={config}
|
||||||
value={snippet.content}
|
value={snippet.content}
|
||||||
ref={'code-' + index}
|
ref={'code-' + index}
|
||||||
|
storageKey={note.storage}
|
||||||
/>
|
/>
|
||||||
: <CodeEditor styleName='tabView-content'
|
: <CodeEditor styleName='tabView-content'
|
||||||
mode={snippet.mode}
|
mode={snippet.mode}
|
||||||
@@ -192,6 +196,7 @@ class NoteDetail extends React.Component {
|
|||||||
lineNumber={config.preview.lineNumber}
|
lineNumber={config.preview.lineNumber}
|
||||||
indentSize={editorIndentSize}
|
indentSize={editorIndentSize}
|
||||||
value={note.content}
|
value={note.content}
|
||||||
|
storagePath={storage.path}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ class NoteList extends React.Component {
|
|||||||
dateDisplay={dateDisplay}
|
dateDisplay={dateDisplay}
|
||||||
key={key}
|
key={key}
|
||||||
handleNoteClick={(e) => this.props.handleNoteClick(e, _index)}
|
handleNoteClick={(e) => this.props.handleNoteClick(e, _index)}
|
||||||
handleNoteContextMenu={() => ''}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import StorageSection from './StorageSection'
|
|||||||
import NoteList from './NoteList'
|
import NoteList from './NoteList'
|
||||||
import NoteDetail from './NoteDetail'
|
import NoteDetail from './NoteDetail'
|
||||||
import SideNavFilter from 'browser/components/SideNavFilter'
|
import SideNavFilter from 'browser/components/SideNavFilter'
|
||||||
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
require('!!style!css!stylus?sourceMap!../main/global.styl')
|
require('!!style!css!stylus?sourceMap!../main/global.styl')
|
||||||
require('../lib/customMeta')
|
require('../lib/customMeta')
|
||||||
|
|
||||||
@@ -94,6 +95,7 @@ class FinderMain extends React.Component {
|
|||||||
|
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
this.refs.detail.saveToClipboard()
|
this.refs.detail.saveToClipboard()
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('COPY_FINDER')
|
||||||
hideFinder()
|
hideFinder()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
|
|||||||
21
browser/lib/RcParser.js
Normal file
21
browser/lib/RcParser.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import path from 'path'
|
||||||
|
import sander from 'sander'
|
||||||
|
|
||||||
|
const BOOSTNOTERC = '.boostnoterc'
|
||||||
|
const homePath = global.process.env.HOME || global.process.env.USERPROFILE
|
||||||
|
const _boostnotercPath = path.join(homePath, BOOSTNOTERC)
|
||||||
|
|
||||||
|
export function parse (boostnotercPath = _boostnotercPath) {
|
||||||
|
if (!sander.existsSync(boostnotercPath)) return {}
|
||||||
|
try {
|
||||||
|
return JSON.parse(sander.readFileSync(boostnotercPath).toString())
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(e)
|
||||||
|
console.warn('Your .boostnoterc is broken so it\'s not used.')
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
parse
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import moment from 'moment'
|
|||||||
* @param {mixed}
|
* @param {mixed}
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
export function getLastUpdated (date) {
|
export function formatDate (date) {
|
||||||
const m = moment(date)
|
const m = moment(date)
|
||||||
if (!m.isValid()) {
|
if (!m.isValid()) {
|
||||||
throw Error('Invalid argument.')
|
throw Error('Invalid argument.')
|
||||||
|
|||||||
33
browser/lib/findNoteTitle.js
Normal file
33
browser/lib/findNoteTitle.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
export function findNoteTitle (value) {
|
||||||
|
let splitted = value.split('\n')
|
||||||
|
let title = null
|
||||||
|
let isInsideCodeBlock = false
|
||||||
|
|
||||||
|
splitted.some((line, index) => {
|
||||||
|
let trimmedLine = line.trim()
|
||||||
|
let trimmedNextLine = splitted[index + 1] === undefined ? '' : splitted[index + 1].trim()
|
||||||
|
if (trimmedLine.match('```')) {
|
||||||
|
isInsideCodeBlock = !isInsideCodeBlock
|
||||||
|
}
|
||||||
|
if (isInsideCodeBlock === false && (trimmedLine.match(/^# +/) || trimmedNextLine.match(/^=+$/))) {
|
||||||
|
title = trimmedLine
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (title === null) {
|
||||||
|
title = ''
|
||||||
|
splitted.some((line) => {
|
||||||
|
if (line.trim().length > 0) {
|
||||||
|
title = line.trim()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return title
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
findNoteTitle
|
||||||
|
}
|
||||||
14
browser/lib/findStorage.js
Normal file
14
browser/lib/findStorage.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
|
export function findStorage (storageKey) {
|
||||||
|
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
||||||
|
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
||||||
|
const storage = _.find(cachedStorageList, {key: storageKey})
|
||||||
|
if (storage === undefined) throw new Error('Target storage doesn\'t exist.')
|
||||||
|
|
||||||
|
return storage
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
findStorage
|
||||||
|
}
|
||||||
25
browser/lib/getTodoStatus.js
Normal file
25
browser/lib/getTodoStatus.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
export function getTodoStatus (content) {
|
||||||
|
let splitted = content.split('\n')
|
||||||
|
let numberOfTodo = 0
|
||||||
|
let numberOfCompletedTodo = 0
|
||||||
|
|
||||||
|
splitted.forEach((line) => {
|
||||||
|
let trimmedLine = line.trim()
|
||||||
|
if (trimmedLine.match(/^[\+\-\*] \[\s|x\] ./)) {
|
||||||
|
numberOfTodo++
|
||||||
|
}
|
||||||
|
if (trimmedLine.match(/^[\+\-\*] \[x\] ./)) {
|
||||||
|
numberOfCompletedTodo++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
total: numberOfTodo,
|
||||||
|
completed: numberOfCompletedTodo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTodoPercentageOfCompleted (content) {
|
||||||
|
const state = getTodoStatus(content)
|
||||||
|
return Math.floor(state.completed / state.total * 100)
|
||||||
|
}
|
||||||
45
browser/lib/htmlTextHelper.js
Normal file
45
browser/lib/htmlTextHelper.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* @fileoverview Text trimmer for html.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} text
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function decodeEntities (text) {
|
||||||
|
var entities = [
|
||||||
|
['apos', '\''],
|
||||||
|
['amp', '&'],
|
||||||
|
['lt', '<'],
|
||||||
|
['gt', '>'],
|
||||||
|
['#63', '\\?'],
|
||||||
|
['#36', '\\$']
|
||||||
|
]
|
||||||
|
|
||||||
|
for (var i = 0, max = entities.length; i < max; ++i) {
|
||||||
|
text = text.replace(new RegExp(`&${entities[i][0]};`, 'g'), entities[i][1])
|
||||||
|
}
|
||||||
|
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
export function encodeEntities (text) {
|
||||||
|
const entities = [
|
||||||
|
['\'', 'apos'],
|
||||||
|
['<', 'lt'],
|
||||||
|
['>', 'gt'],
|
||||||
|
['\\?', '#63'],
|
||||||
|
['\\$', '#36']
|
||||||
|
]
|
||||||
|
|
||||||
|
entities.forEach((entity) => {
|
||||||
|
text = text.replace(new RegExp(entity[0], 'g'), `&${entity[1]};`)
|
||||||
|
})
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
decodeEntities,
|
||||||
|
encodeEntities
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ var md = markdownit({
|
|||||||
linkify: true,
|
linkify: true,
|
||||||
html: true,
|
html: true,
|
||||||
xhtmlOut: true,
|
xhtmlOut: true,
|
||||||
|
breaks: true,
|
||||||
highlight: function (str, lang) {
|
highlight: function (str, lang) {
|
||||||
if (lang === 'flowchart') {
|
if (lang === 'flowchart') {
|
||||||
return `<pre class="flowchart">${str}</pre>`
|
return `<pre class="flowchart">${str}</pre>`
|
||||||
@@ -56,6 +57,7 @@ md.use(math, {
|
|||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
md.use(require('markdown-it-imsize'))
|
||||||
md.use(require('markdown-it-footnote'))
|
md.use(require('markdown-it-footnote'))
|
||||||
// Override task item
|
// Override task item
|
||||||
md.block.ruler.at('paragraph', function (state, startLine/*, endLine */) {
|
md.block.ruler.at('paragraph', function (state, startLine/*, endLine */) {
|
||||||
@@ -157,7 +159,8 @@ function strip (input) {
|
|||||||
const markdown = {
|
const markdown = {
|
||||||
render: function markdown (content) {
|
render: function markdown (content) {
|
||||||
if (!_.isString(content)) content = ''
|
if (!_.isString(content)) content = ''
|
||||||
return md.render(content)
|
const renderedContent = md.render(content)
|
||||||
|
return md.normalizeLinkText(renderedContent)
|
||||||
},
|
},
|
||||||
strip
|
strip
|
||||||
}
|
}
|
||||||
|
|||||||
42
browser/lib/search.js
Normal file
42
browser/lib/search.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
|
export default function searchFromNotes (notes, search) {
|
||||||
|
if (search.trim().length === 0) return []
|
||||||
|
let searchBlocks = search.split(' ')
|
||||||
|
searchBlocks.forEach((block) => {
|
||||||
|
if (block.match(/^#.+/)) {
|
||||||
|
notes = findByTag(notes, block)
|
||||||
|
} else {
|
||||||
|
notes = findByWord(notes, block)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return notes
|
||||||
|
}
|
||||||
|
|
||||||
|
function findByTag (notes, block) {
|
||||||
|
const tag = block.match(/#(.+)/)[1]
|
||||||
|
let regExp = new RegExp(_.escapeRegExp(tag), 'i')
|
||||||
|
return notes.filter((note) => {
|
||||||
|
if (!_.isArray(note.tags)) return false
|
||||||
|
return note.tags.some((_tag) => {
|
||||||
|
return _tag.match(regExp)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function findByWord (notes, block) {
|
||||||
|
let regExp = new RegExp(_.escapeRegExp(block), 'i')
|
||||||
|
return notes.filter((note) => {
|
||||||
|
if (_.isArray(note.tags) && note.tags.some((_tag) => {
|
||||||
|
return _tag.match(regExp)
|
||||||
|
})) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (note.type === 'SNIPPET_NOTE') {
|
||||||
|
return note.description.match(regExp)
|
||||||
|
} else if (note.type === 'MARKDOWN_NOTE') {
|
||||||
|
return note.content.match(regExp)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
.root
|
.root
|
||||||
position relative
|
position relative
|
||||||
border solid 1px transparent
|
border solid 1px transparent
|
||||||
line-height 34px
|
line-height 26px
|
||||||
vertical-align middle
|
vertical-align middle
|
||||||
border-radius 2px
|
border-radius 2px
|
||||||
transition 0.15s
|
transition 0.15s
|
||||||
|
|||||||
19
browser/main/Detail/InfoButton.js
Normal file
19
browser/main/Detail/InfoButton.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './InfoButton.styl'
|
||||||
|
|
||||||
|
const InfoButton = ({
|
||||||
|
onClick
|
||||||
|
}) => (
|
||||||
|
<button styleName='control-infoButton'
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
<i className='fa fa-info infoButton' styleName='info-button' />
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
|
||||||
|
InfoButton.propTypes = {
|
||||||
|
onClick: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(InfoButton, styles)
|
||||||
21
browser/main/Detail/InfoButton.styl
Normal file
21
browser/main/Detail/InfoButton.styl
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
.control-infoButton
|
||||||
|
float right
|
||||||
|
topBarButtonLight()
|
||||||
|
|
||||||
|
.control-infoPanel
|
||||||
|
position fixed
|
||||||
|
pointer-events none
|
||||||
|
top 50px
|
||||||
|
z-index 200
|
||||||
|
line-height normal
|
||||||
|
border-radius 2px
|
||||||
|
opacity 0
|
||||||
|
transition 0.1s
|
||||||
|
|
||||||
|
.infoButton
|
||||||
|
padding 0px
|
||||||
|
margin 15px 0
|
||||||
|
|
||||||
|
body[data-theme="dark"]
|
||||||
|
.control-infoButton
|
||||||
|
topBarButtonDark()
|
||||||
79
browser/main/Detail/InfoPanel.js
Normal file
79
browser/main/Detail/InfoPanel.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './InfoPanel.styl'
|
||||||
|
|
||||||
|
const InfoPanel = ({
|
||||||
|
storageName, folderName, noteLink, updatedAt, createdAt, exportAsMd, exportAsTxt
|
||||||
|
}) => (
|
||||||
|
<div className='infoPanel' styleName='control-infoButton-panel' style={{display: 'none'}}>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Storage
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
{storageName}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Folder
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
{folderName}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Created
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
{createdAt}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Updated
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
{updatedAt}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Note Link
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
<input value={noteLink} onClick={(e) => { e.target.select() }} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id='export-wrap'>
|
||||||
|
<button styleName='export--enable' onClick={(e) => exportAsMd(e)}>
|
||||||
|
<i className='fa fa-file-code-o fa-fw' />
|
||||||
|
<p>.md</p>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button styleName='export--enable' onClick={(e) => exportAsTxt(e)}>
|
||||||
|
<i className='fa fa-file-text-o fa-fw' />
|
||||||
|
<p>.txt</p>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button styleName='export--unable'>
|
||||||
|
<i className='fa fa-file-pdf-o fa-fw' />
|
||||||
|
<p>.pdf</p>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
InfoPanel.propTypes = {
|
||||||
|
storageName: PropTypes.string.isRequired,
|
||||||
|
folderName: PropTypes.string.isRequired,
|
||||||
|
noteLink: PropTypes.string.isRequired,
|
||||||
|
updatedAt: PropTypes.string.isRequired,
|
||||||
|
createdAt: PropTypes.string.isRequired,
|
||||||
|
exportAsMd: PropTypes.func.isRequired,
|
||||||
|
exportAsTxt: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(InfoPanel, styles)
|
||||||
124
browser/main/Detail/InfoPanel.styl
Normal file
124
browser/main/Detail/InfoPanel.styl
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
.control-infoPanel
|
||||||
|
position fixed
|
||||||
|
pointer-events none
|
||||||
|
top 50px
|
||||||
|
z-index 200
|
||||||
|
line-height normal
|
||||||
|
border-radius 4px
|
||||||
|
opacity 0
|
||||||
|
transition 0.2s
|
||||||
|
|
||||||
|
.control-infoButton-panel
|
||||||
|
z-index 200
|
||||||
|
margin-top 45px
|
||||||
|
margin-left -210px
|
||||||
|
position absolute
|
||||||
|
padding 20px 20px 0 20px
|
||||||
|
width 340px
|
||||||
|
background-color $ui-noteList-backgroundColor
|
||||||
|
border 1px solid $border-color
|
||||||
|
|
||||||
|
.control-infoButton-panel-trash
|
||||||
|
z-index 200
|
||||||
|
margin-top 45px
|
||||||
|
margin-left -230px
|
||||||
|
position absolute
|
||||||
|
padding 20px 20px 0 20px
|
||||||
|
width 320px
|
||||||
|
background-color $ui-noteList-backgroundColor
|
||||||
|
border 1px solid $border-color
|
||||||
|
|
||||||
|
.group-section
|
||||||
|
display flex
|
||||||
|
line-height 30px
|
||||||
|
font-size 13px
|
||||||
|
|
||||||
|
.group-section-label
|
||||||
|
width 70px
|
||||||
|
height 20px
|
||||||
|
text-align left
|
||||||
|
margin-right 50px
|
||||||
|
font-size 13px
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
|
||||||
|
.group-section-control
|
||||||
|
flex 1
|
||||||
|
font-size 13px
|
||||||
|
color $ui-text-color
|
||||||
|
|
||||||
|
.group-section-control input
|
||||||
|
width 160px
|
||||||
|
height 25px
|
||||||
|
|
||||||
|
.group-section-control text
|
||||||
|
color #EA4447
|
||||||
|
font-weight 600
|
||||||
|
font-size 14px
|
||||||
|
width 70px
|
||||||
|
height 25px
|
||||||
|
background-color rgba(226,33,113,0.1)
|
||||||
|
border none
|
||||||
|
outline none
|
||||||
|
border-radius 2px
|
||||||
|
margin-right 5px
|
||||||
|
padding 2px 5px
|
||||||
|
|
||||||
|
[id=export-wrap]
|
||||||
|
height 90px
|
||||||
|
display flex
|
||||||
|
justify-content center
|
||||||
|
margin 20px 0 10px 0
|
||||||
|
button
|
||||||
|
outline none
|
||||||
|
font-size 48px
|
||||||
|
color #A0A0A0
|
||||||
|
background-color transparent
|
||||||
|
border none
|
||||||
|
margin 0 5px
|
||||||
|
border-radius 5px
|
||||||
|
&:hover
|
||||||
|
transition 0.2s
|
||||||
|
background-color alpha($ui-button--hover-backgroundColor, 30%)
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
p
|
||||||
|
font-size 13px
|
||||||
|
color #A0A0A0
|
||||||
|
font-weight light
|
||||||
|
&:hover
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
|
||||||
|
.export--enable
|
||||||
|
cursor pointer
|
||||||
|
|
||||||
|
.export--unable
|
||||||
|
cursor not-allowed
|
||||||
|
|
||||||
|
body[data-theme="dark"]
|
||||||
|
.control-infoButton-panel
|
||||||
|
background-color $ui-dark-noteList-backgroundColor
|
||||||
|
border 1px solid $ui-dark-borderColor
|
||||||
|
|
||||||
|
.control-infoButton-panel-trash
|
||||||
|
background-color $ui-dark-noteList-backgroundColor
|
||||||
|
border 1px solid $ui-dark-borderColor
|
||||||
|
|
||||||
|
.group-section-label
|
||||||
|
color $ui-inactive-text-color
|
||||||
|
|
||||||
|
.group-section-control
|
||||||
|
color $ui-dark-text-color
|
||||||
|
|
||||||
|
.group-section-control input
|
||||||
|
background-color alpha($ui-dark-borderColor, 80%)
|
||||||
|
color $ui-dark-text-color
|
||||||
|
|
||||||
|
[id=export-wrap]
|
||||||
|
button
|
||||||
|
color $ui-dark-inactive-text-color
|
||||||
|
&:hover
|
||||||
|
background-color alpha($ui-dark-borderColor, 20%)
|
||||||
|
color $ui-dark-text-color
|
||||||
|
p
|
||||||
|
color $ui-dark-inactive-text-color
|
||||||
|
&:hover
|
||||||
|
color $ui-dark-text-color
|
||||||
70
browser/main/Detail/InfoPanelTrashed.js
Normal file
70
browser/main/Detail/InfoPanelTrashed.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './InfoPanel.styl'
|
||||||
|
|
||||||
|
const InfoPanelTrashed = ({
|
||||||
|
storageName, folderName, updatedAt, createdAt, exportAsMd, exportAsTxt
|
||||||
|
}) => (
|
||||||
|
<div className='infoPanel' styleName='control-infoButton-panel-trash' style={{display: 'none'}}>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Storage
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
{storageName}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Folder
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
<text>Trash</text>{folderName}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Created
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
{createdAt}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
Updated
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
{updatedAt}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id='export-wrap'>
|
||||||
|
<button styleName='export--enable' onClick={(e) => exportAsMd(e)}>
|
||||||
|
<i className='fa fa-file-code-o fa-fw' />
|
||||||
|
<p>.md</p>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button styleName='export--enable' onClick={(e) => exportAsTxt(e)}>
|
||||||
|
<i className='fa fa-file-text-o fa-fw' />
|
||||||
|
<p>.txt</p>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button styleName='export--unable'>
|
||||||
|
<i className='fa fa-file-pdf-o fa-fw' />
|
||||||
|
<p>.pdf</p>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
InfoPanelTrashed.propTypes = {
|
||||||
|
storageName: PropTypes.string.isRequired,
|
||||||
|
folderName: PropTypes.string.isRequired,
|
||||||
|
updatedAt: PropTypes.string.isRequired,
|
||||||
|
createdAt: PropTypes.string.isRequired,
|
||||||
|
exportAsMd: PropTypes.func.isRequired,
|
||||||
|
exportAsTxt: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(InfoPanelTrashed, styles)
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Component for show updated date of the detail.
|
|
||||||
*/
|
|
||||||
import React, { PropTypes } from 'react'
|
|
||||||
import { getLastUpdated } from 'browser/lib/date-formatter'
|
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
|
||||||
import styles from './LastUpdatedString.styl'
|
|
||||||
|
|
||||||
const LastUpdatedString = ({ date }) => {
|
|
||||||
let text = ''
|
|
||||||
|
|
||||||
try {
|
|
||||||
text = `Last updated at ${getLastUpdated(date)}`
|
|
||||||
} catch (e) {
|
|
||||||
text = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<p styleName='info-right-date'>{text}</p>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
LastUpdatedString.propTypes = {
|
|
||||||
date: PropTypes.string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CSSModules(LastUpdatedString, styles)
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
.info-right-date
|
|
||||||
display inline
|
|
||||||
line-height 24px
|
|
||||||
padding-right 25px
|
|
||||||
font-size 11px
|
|
||||||
color $ui-button-color
|
|
||||||
|
|
||||||
body[data-theme="dark"]
|
|
||||||
.info-right-date
|
|
||||||
color $ui-dark-button-color
|
|
||||||
@@ -2,6 +2,7 @@ import React, { PropTypes } from 'react'
|
|||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './MarkdownNoteDetail.styl'
|
import styles from './MarkdownNoteDetail.styl'
|
||||||
import MarkdownEditor from 'browser/components/MarkdownEditor'
|
import MarkdownEditor from 'browser/components/MarkdownEditor'
|
||||||
|
import TodoListPercentage from 'browser/components/TodoListPercentage'
|
||||||
import StarButton from './StarButton'
|
import StarButton from './StarButton'
|
||||||
import TagSelect from './TagSelect'
|
import TagSelect from './TagSelect'
|
||||||
import FolderSelect from './FolderSelect'
|
import FolderSelect from './FolderSelect'
|
||||||
@@ -11,6 +12,14 @@ import ee from 'browser/main/lib/eventEmitter'
|
|||||||
import markdown from 'browser/lib/markdown'
|
import markdown from 'browser/lib/markdown'
|
||||||
import StatusBar from '../StatusBar'
|
import StatusBar from '../StatusBar'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import { findNoteTitle } from 'browser/lib/findNoteTitle'
|
||||||
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
import TrashButton from './TrashButton'
|
||||||
|
import InfoButton from './InfoButton'
|
||||||
|
import InfoPanel from './InfoPanel'
|
||||||
|
import InfoPanelTrashed from './InfoPanelTrashed'
|
||||||
|
import { formatDate } from 'browser/lib/date-formatter'
|
||||||
|
import { getTodoPercentageOfCompleted } from 'browser/lib/getTodoStatus'
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { remote } = electron
|
const { remote } = electron
|
||||||
@@ -49,7 +58,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
note: Object.assign({}, nextProps.note)
|
note: Object.assign({}, nextProps.note)
|
||||||
}, () => {
|
}, () => {
|
||||||
this.refs.content.reload()
|
this.refs.content.reload()
|
||||||
this.refs.tags.reset()
|
if (this.refs.tags) this.refs.tags.reset()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,45 +71,12 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
ee.off('topbar:togglelockbutton', this.toggleLockButton)
|
ee.off('topbar:togglelockbutton', this.toggleLockButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
findTitle (value) {
|
|
||||||
let splitted = value.split('\n')
|
|
||||||
let title = null
|
|
||||||
let isMarkdownInCode = false
|
|
||||||
|
|
||||||
for (let i = 0; i < splitted.length; i++) {
|
|
||||||
let trimmedLine = splitted[i].trim()
|
|
||||||
if (trimmedLine.match('```')) {
|
|
||||||
isMarkdownInCode = !isMarkdownInCode
|
|
||||||
} else if (isMarkdownInCode === false && trimmedLine.match(/^# +/)) {
|
|
||||||
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (title == null) {
|
|
||||||
for (let i = 0; i < splitted.length; i++) {
|
|
||||||
let trimmedLine = splitted[i].trim()
|
|
||||||
if (trimmedLine.length > 0) {
|
|
||||||
title = trimmedLine
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (title == null) {
|
|
||||||
title = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
title = markdown.strip(title)
|
|
||||||
|
|
||||||
return title
|
|
||||||
}
|
|
||||||
|
|
||||||
handleChange (e) {
|
handleChange (e) {
|
||||||
let { note } = this.state
|
let { note } = this.state
|
||||||
|
|
||||||
note.content = this.refs.content.value
|
note.content = this.refs.content.value
|
||||||
note.tags = this.refs.tags.value
|
if (this.refs.tags) note.tags = this.refs.tags.value
|
||||||
note.title = this.findTitle(note.content)
|
note.title = markdown.strip(findNoteTitle(note.content))
|
||||||
note.updatedAt = new Date()
|
note.updatedAt = new Date()
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -129,6 +105,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
type: 'UPDATE_NOTE',
|
type: 'UPDATE_NOTE',
|
||||||
note: note
|
note: note
|
||||||
})
|
})
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('EDIT_NOTE')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +144,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
|
|
||||||
handleStarButtonClick (e) {
|
handleStarButtonClick (e) {
|
||||||
let { note } = this.state
|
let { note } = this.state
|
||||||
|
if (!note.isStarred) AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_STAR')
|
||||||
|
|
||||||
note.isStarred = !note.isStarred
|
note.isStarred = !note.isStarred
|
||||||
|
|
||||||
@@ -181,14 +159,26 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDeleteButtonClick (e) {
|
exportAsMd () {
|
||||||
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
ee.emit('export:save-md')
|
||||||
type: 'warning',
|
}
|
||||||
message: 'Delete a note',
|
|
||||||
detail: 'This work cannot be undone.',
|
exportAsTxt () {
|
||||||
buttons: ['Confirm', 'Cancel']
|
ee.emit('export:save-text')
|
||||||
})
|
}
|
||||||
if (index === 0) {
|
|
||||||
|
handleTrashButtonClick (e) {
|
||||||
|
let { note } = this.state
|
||||||
|
const { isTrashed } = note
|
||||||
|
|
||||||
|
if (isTrashed) {
|
||||||
|
let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Confirm note deletion',
|
||||||
|
detail: 'This will permanently remove this note.',
|
||||||
|
buttons: ['Confirm', 'Cancel']
|
||||||
|
})
|
||||||
|
if (dialogueButtonIndex === 1) return
|
||||||
let { note, dispatch } = this.props
|
let { note, dispatch } = this.props
|
||||||
dataApi
|
dataApi
|
||||||
.deleteNote(note.storage, note.key)
|
.deleteNote(note.storage, note.key)
|
||||||
@@ -201,9 +191,35 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
ee.once('list:moved', dispatchHandler)
|
ee.once('list:moved', dispatchHandler)
|
||||||
ee.emit('list:next')
|
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
note.isTrashed = true
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
note
|
||||||
|
}, () => {
|
||||||
|
this.save()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
ee.emit('list:next')
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUndoButtonClick (e) {
|
||||||
|
let { note } = this.state
|
||||||
|
|
||||||
|
note.isTrashed = false
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
note
|
||||||
|
}, () => {
|
||||||
|
this.save()
|
||||||
|
this.refs.content.reload()
|
||||||
|
ee.emit('list:next')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
handleFullScreenButton (e) {
|
||||||
|
ee.emit('editor:fullscreen')
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLockButtonMouseDown (e) {
|
handleLockButtonMouseDown (e) {
|
||||||
@@ -214,7 +230,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getToggleLockButton () {
|
getToggleLockButton () {
|
||||||
return this.state.isLocked ? 'fa-lock' : 'fa-unlock-alt'
|
return this.state.isLocked ? 'fa-lock' : 'fa-unlock'
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDeleteKeyDown (e) {
|
handleDeleteKeyDown (e) {
|
||||||
@@ -234,68 +250,120 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
this.focus()
|
this.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleInfoButtonClick (e) {
|
||||||
|
const infoPanel = document.querySelector('.infoPanel')
|
||||||
|
if (infoPanel.style) infoPanel.style.display = infoPanel.style.display === 'none' ? 'inline' : 'none'
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { data, config } = this.props
|
let { data, config, location } = this.props
|
||||||
let { note } = this.state
|
let { note } = this.state
|
||||||
|
let storageKey = note.storage
|
||||||
|
let folderKey = note.folder
|
||||||
|
|
||||||
|
let options = []
|
||||||
|
data.storageMap.forEach((storage, index) => {
|
||||||
|
storage.folders.forEach((folder) => {
|
||||||
|
options.push({
|
||||||
|
storage: storage,
|
||||||
|
folder: folder
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
let currentOption = options.filter((option) => option.storage.key === storageKey && option.folder.key === folderKey)[0]
|
||||||
|
|
||||||
|
const trashTopBar = <div styleName='info'>
|
||||||
|
<div styleName='info-left'>
|
||||||
|
<i styleName='undo-button'
|
||||||
|
className='fa fa-undo fa-fw'
|
||||||
|
onClick={(e) => this.handleUndoButtonClick(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div styleName='info-right'>
|
||||||
|
<TrashButton onClick={(e) => this.handleTrashButtonClick(e)} />
|
||||||
|
<InfoButton
|
||||||
|
onClick={(e) => this.handleInfoButtonClick(e)}
|
||||||
|
/>
|
||||||
|
<InfoPanelTrashed
|
||||||
|
storageName={currentOption.storage.name}
|
||||||
|
folderName={currentOption.folder.name}
|
||||||
|
updatedAt={formatDate(note.updatedAt)}
|
||||||
|
createdAt={formatDate(note.createdAt)}
|
||||||
|
exportAsMd={this.exportAsMd}
|
||||||
|
exportAsTxt={this.exportAsTxt}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
const detailTopBar = <div styleName='info'>
|
||||||
|
<div styleName='info-left'>
|
||||||
|
<StarButton styleName='info-left-button'
|
||||||
|
onClick={(e) => this.handleStarButtonClick(e)}
|
||||||
|
isActive={note.isStarred}
|
||||||
|
/>
|
||||||
|
<div styleName='info-left-top'>
|
||||||
|
<FolderSelect styleName='info-left-top-folderSelect'
|
||||||
|
value={this.state.note.storage + '-' + this.state.note.folder}
|
||||||
|
ref='folder'
|
||||||
|
data={data}
|
||||||
|
onChange={(e) => this.handleFolderChange(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TagSelect
|
||||||
|
ref='tags'
|
||||||
|
value={this.state.note.tags}
|
||||||
|
onChange={(e) => this.handleChange(e)}
|
||||||
|
/>
|
||||||
|
<TodoListPercentage
|
||||||
|
percentageOfTodo={getTodoPercentageOfCompleted(note.content)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div styleName='info-right'>
|
||||||
|
{(() => {
|
||||||
|
const faClassName = `fa ${this.getToggleLockButton()}`
|
||||||
|
const lockButtonComponent =
|
||||||
|
<button styleName='control-lockButton'
|
||||||
|
onFocus={(e) => this.handleFocus(e)}
|
||||||
|
onMouseDown={(e) => this.handleLockButtonMouseDown(e)}
|
||||||
|
>
|
||||||
|
<i className={faClassName} styleName='lock-button' />
|
||||||
|
<span styleName='control-lockButton-tooltip'>
|
||||||
|
{this.state.isLocked ? 'Unlock' : 'Lock'}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
return (
|
||||||
|
this.state.isLockButtonShown ? lockButtonComponent : ''
|
||||||
|
)
|
||||||
|
})()}
|
||||||
|
<TrashButton onClick={(e) => this.handleTrashButtonClick(e)} />
|
||||||
|
<button styleName='control-fullScreenButton'
|
||||||
|
onMouseDown={(e) => this.handleFullScreenButton(e)}
|
||||||
|
>
|
||||||
|
<i className='fa fa-expand' styleName='fullScreen-button' />
|
||||||
|
</button>
|
||||||
|
<InfoButton
|
||||||
|
onClick={(e) => this.handleInfoButtonClick(e)}
|
||||||
|
/>
|
||||||
|
<InfoPanel
|
||||||
|
storageName={currentOption.storage.name}
|
||||||
|
folderName={currentOption.folder.name}
|
||||||
|
noteLink={`[${note.title}](${location.query.key})`}
|
||||||
|
updatedAt={formatDate(note.updatedAt)}
|
||||||
|
createdAt={formatDate(note.createdAt)}
|
||||||
|
exportAsMd={this.exportAsMd}
|
||||||
|
exportAsTxt={this.exportAsTxt}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='NoteDetail'
|
<div className='NoteDetail'
|
||||||
style={this.props.style}
|
style={this.props.style}
|
||||||
styleName='root'
|
styleName='root'
|
||||||
>
|
>
|
||||||
<div styleName='info'>
|
|
||||||
<div styleName='info-left'>
|
|
||||||
<StarButton styleName='info-left-button'
|
|
||||||
onClick={(e) => this.handleStarButtonClick(e)}
|
|
||||||
isActive={note.isStarred}
|
|
||||||
/>
|
|
||||||
<div styleName='info-left-top'>
|
|
||||||
<FolderSelect styleName='info-left-top-folderSelect'
|
|
||||||
value={this.state.note.storage + '-' + this.state.note.folder}
|
|
||||||
ref='folder'
|
|
||||||
data={data}
|
|
||||||
onChange={(e) => this.handleFolderChange(e)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<TagSelect
|
{location.pathname === '/trashed' ? trashTopBar : detailTopBar}
|
||||||
ref='tags'
|
|
||||||
value={this.state.note.tags}
|
|
||||||
onChange={(e) => this.handleChange(e)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div styleName='info-right'>
|
|
||||||
{(() => {
|
|
||||||
const faClassName = `fa ${this.getToggleLockButton()}`
|
|
||||||
const lockButtonComponent =
|
|
||||||
<button styleName='control-lockButton'
|
|
||||||
onFocus={(e) => this.handleFocus(e)}
|
|
||||||
onMouseDown={(e) => this.handleLockButtonMouseDown(e)}
|
|
||||||
>
|
|
||||||
<i className={faClassName} styleName='lock-button' />
|
|
||||||
<span styleName='control-lockButton-tooltip'>
|
|
||||||
{this.state.isLocked ? 'Unlock' : 'Lock'}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
return (
|
|
||||||
this.state.isLockButtonShown ? lockButtonComponent : ''
|
|
||||||
)
|
|
||||||
})()}
|
|
||||||
<button styleName='control-trashButton'
|
|
||||||
onClick={(e) => this.handleDeleteButtonClick(e)}
|
|
||||||
>
|
|
||||||
<svg height='14px' id='Capa_1' style={{enableBackground: 'new 0 0 753.23 753.23'}} width='14px' version='1.1' viewBox='0 0 753.23 753.23' x='0px' y='0px' xmlSpace='preserve'>
|
|
||||||
<g>
|
|
||||||
<g id='_x34__19_'>
|
|
||||||
<g>
|
|
||||||
<path d='M494.308,659.077c12.993,0,23.538-10.546,23.538-23.539V353.077c0-12.993-10.545-23.539-23.538-23.539
				s-23.538,10.545-23.538,23.539v282.461C470.77,648.531,481.314,659.077,494.308,659.077z M635.538,94.154h-141.23V47.077
				C494.308,21.067,473.24,0,447.23,0H306c-26.01,0-47.077,21.067-47.077,47.077v47.077h-141.23
				c-26.01,0-47.077,21.067-47.077,47.077v47.077c0,25.986,21.067,47.077,47.077,47.077v423.692
				c0,51.996,42.157,94.153,94.154,94.153h329.539c51.996,0,94.153-42.157,94.153-94.153V235.385
				c26.01,0,47.077-21.091,47.077-47.077V141.23C682.615,115.221,661.548,94.154,635.538,94.154z M306,70.615
				c0-12.993,10.545-23.539,23.538-23.539h94.154c12.993,0,23.538,10.545,23.538,23.539v23.539c-22.809,0-141.23,0-141.23,0V70.615z
				 M588.461,659.077c0,25.986-21.066,47.076-47.076,47.076H211.846c-26.01,0-47.077-21.09-47.077-47.076V235.385h423.692V659.077z
				 M612,188.308H141.23c-12.993,0-23.538-10.545-23.538-23.539s10.545-23.539,23.538-23.539H612
				c12.993,0,23.538,10.545,23.538,23.539S624.993,188.308,612,188.308z M258.923,659.077c12.993,0,23.539-10.546,23.539-23.539
				V353.077c0-12.993-10.545-23.539-23.539-23.539s-23.539,10.545-23.539,23.539v282.461
				C235.384,648.531,245.93,659.077,258.923,659.077z M376.615,659.077c12.993,0,23.538-10.546,23.538-23.539V353.077
				c0-12.993-10.545-23.539-23.538-23.539s-23.539,10.545-23.539,23.539v282.461C353.077,648.531,363.622,659.077,376.615,659.077z' />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div styleName='body'>
|
<div styleName='body'>
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
@@ -303,6 +371,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
styleName='body-noteEditor'
|
styleName='body-noteEditor'
|
||||||
config={config}
|
config={config}
|
||||||
value={this.state.note.content}
|
value={this.state.note.content}
|
||||||
|
storageKey={this.state.note.storage}
|
||||||
onChange={(e) => this.handleChange(e)}
|
onChange={(e) => this.handleChange(e)}
|
||||||
ignorePreviewPointerEvents={this.props.ignorePreviewPointerEvents}
|
ignorePreviewPointerEvents={this.props.ignorePreviewPointerEvents}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -27,8 +27,9 @@
|
|||||||
opacity 0
|
opacity 0
|
||||||
transition 0.1s
|
transition 0.1s
|
||||||
|
|
||||||
.control-trashButton
|
.control-fullScreenButton
|
||||||
float right
|
float right
|
||||||
|
padding 0 0 2px 0
|
||||||
topBarButtonLight()
|
topBarButtonLight()
|
||||||
|
|
||||||
.body
|
.body
|
||||||
@@ -53,5 +54,5 @@ body[data-theme="dark"]
|
|||||||
.control-lockButton-tooltip
|
.control-lockButton-tooltip
|
||||||
darkTooltip()
|
darkTooltip()
|
||||||
|
|
||||||
.control-trashButton
|
.control-fullScreenButton
|
||||||
topBarButtonDark()
|
topBarButtonDark()
|
||||||
|
|||||||
@@ -15,26 +15,26 @@ $info-margin-under-border = 27px
|
|||||||
float left
|
float left
|
||||||
padding 0 5px
|
padding 0 5px
|
||||||
margin 0px 2px
|
margin 0px 2px
|
||||||
|
|
||||||
.info-left-top
|
.info-left-top
|
||||||
display inline-block
|
display inline-block
|
||||||
height $info-height
|
height $info-height
|
||||||
line-height $info-height
|
line-height $info-height
|
||||||
|
|
||||||
.info-left-top-folderSelect
|
.info-left-top-folderSelect
|
||||||
display inline-block
|
|
||||||
padding 0 3px
|
padding 0 3px
|
||||||
height 34px
|
height 34px
|
||||||
line-height 34px
|
line-height 26px
|
||||||
vertical-align middle
|
display flex
|
||||||
|
align-items center
|
||||||
|
justify-content center
|
||||||
border-radius 3px
|
border-radius 3px
|
||||||
|
|
||||||
.info-left-button
|
.info-left-button
|
||||||
width 34px
|
width 34px
|
||||||
height 34px
|
height 34px
|
||||||
navButtonColor()
|
navButtonColor()
|
||||||
color $ui-favorite-star-button-color
|
color $ui-favorite-star-button-color
|
||||||
font-size 14px
|
font-size 14px
|
||||||
|
line-height 0
|
||||||
margin 13px 2px
|
margin 13px 2px
|
||||||
padding 0
|
padding 0
|
||||||
border-radius 17px
|
border-radius 17px
|
||||||
@@ -44,7 +44,7 @@ $info-margin-under-border = 27px
|
|||||||
border-color $ui-favorite-star-button-color
|
border-color $ui-favorite-star-button-color
|
||||||
&:active, &:active:hover
|
&:active, &:active:hover
|
||||||
background-color $ui-favorite-star-button-color
|
background-color $ui-favorite-star-button-color
|
||||||
color $ui-button--active-color
|
color $ui-button--color
|
||||||
|
|
||||||
.info-right
|
.info-right
|
||||||
position absolute
|
position absolute
|
||||||
@@ -54,6 +54,27 @@ $info-margin-under-border = 27px
|
|||||||
bottom 1px
|
bottom 1px
|
||||||
padding-left 30px
|
padding-left 30px
|
||||||
|
|
||||||
|
.undo-button
|
||||||
|
width 34px
|
||||||
|
height 34px
|
||||||
|
border-radius 17px
|
||||||
|
font-size 14px
|
||||||
|
margin 15px 7px
|
||||||
|
border none
|
||||||
|
color $ui-button-color
|
||||||
|
display flex
|
||||||
|
align-items center
|
||||||
|
justify-content center
|
||||||
|
fill $ui-button-color
|
||||||
|
background-color transparent
|
||||||
|
cursor pointer
|
||||||
|
&:active
|
||||||
|
border-color $ui-button--active-backgroundColor
|
||||||
|
&:hover
|
||||||
|
background-color alpha($ui-button--hover-backgroundColor, 60%)
|
||||||
|
.control-lockButton-tooltip
|
||||||
|
opacity 1
|
||||||
|
|
||||||
body[data-theme="dark"]
|
body[data-theme="dark"]
|
||||||
.info
|
.info
|
||||||
border-color $ui-dark-borderColor
|
border-color $ui-dark-borderColor
|
||||||
@@ -73,3 +94,6 @@ body[data-theme="dark"]
|
|||||||
|
|
||||||
.info-right
|
.info-right
|
||||||
background-color $ui-dark-noteDetail-backgroundColor
|
background-color $ui-dark-noteDetail-backgroundColor
|
||||||
|
|
||||||
|
.undo-button
|
||||||
|
topBarButtonDark()
|
||||||
@@ -15,6 +15,13 @@ import StatusBar from '../StatusBar'
|
|||||||
import context from 'browser/lib/context'
|
import context from 'browser/lib/context'
|
||||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import { findNoteTitle } from 'browser/lib/findNoteTitle'
|
||||||
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
import TrashButton from './TrashButton'
|
||||||
|
import InfoButton from './InfoButton'
|
||||||
|
import InfoPanel from './InfoPanel'
|
||||||
|
import InfoPanelTrashed from './InfoPanelTrashed'
|
||||||
|
import { formatDate } from 'browser/lib/date-formatter'
|
||||||
|
|
||||||
function pass (name) {
|
function pass (name) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
@@ -51,7 +58,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if (nextProps.note.key !== this.props.note.key) {
|
if (nextProps.note.key !== this.props.note.key && !this.isMovingNote) {
|
||||||
if (this.saveQueue != null) this.saveNow()
|
if (this.saveQueue != null) this.saveNow()
|
||||||
let nextNote = Object.assign({
|
let nextNote = Object.assign({
|
||||||
description: ''
|
description: ''
|
||||||
@@ -66,7 +73,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
snippets.forEach((snippet, index) => {
|
snippets.forEach((snippet, index) => {
|
||||||
this.refs['code-' + index].reload()
|
this.refs['code-' + index].reload()
|
||||||
})
|
})
|
||||||
this.refs.tags.reset()
|
if (this.refs.tags) this.refs.tags.reset()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,41 +82,13 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
if (this.saveQueue != null) this.saveNow()
|
if (this.saveQueue != null) this.saveNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
findTitle (value) {
|
|
||||||
let splitted = value.split('\n')
|
|
||||||
let title = null
|
|
||||||
|
|
||||||
for (let i = 0; i < splitted.length; i++) {
|
|
||||||
let trimmedLine = splitted[i].trim()
|
|
||||||
if (trimmedLine.match(/^# .+/)) {
|
|
||||||
title = trimmedLine.substring(1, trimmedLine.length).trim()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (title == null) {
|
|
||||||
for (let i = 0; i < splitted.length; i++) {
|
|
||||||
let trimmedLine = splitted[i].trim()
|
|
||||||
if (trimmedLine.length > 0) {
|
|
||||||
title = trimmedLine
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (title == null) {
|
|
||||||
title = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return title
|
|
||||||
}
|
|
||||||
|
|
||||||
handleChange (e) {
|
handleChange (e) {
|
||||||
let { note } = this.state
|
let { note } = this.state
|
||||||
|
|
||||||
note.tags = this.refs.tags.value
|
if (this.refs.tags) note.tags = this.refs.tags.value
|
||||||
note.description = this.refs.description.value
|
note.description = this.refs.description.value
|
||||||
note.updatedAt = new Date()
|
note.updatedAt = new Date()
|
||||||
note.title = this.findTitle(note.description)
|
note.title = findNoteTitle(note.description)
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
note
|
note
|
||||||
@@ -137,6 +116,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
type: 'UPDATE_NOTE',
|
type: 'UPDATE_NOTE',
|
||||||
note: note
|
note: note
|
||||||
})
|
})
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('EDIT_NOTE')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +155,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
|
|
||||||
handleStarButtonClick (e) {
|
handleStarButtonClick (e) {
|
||||||
let { note } = this.state
|
let { note } = this.state
|
||||||
|
if (!note.isStarred) AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_STAR')
|
||||||
|
|
||||||
note.isStarred = !note.isStarred
|
note.isStarred = !note.isStarred
|
||||||
|
|
||||||
@@ -189,14 +170,18 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDeleteButtonClick (e) {
|
handleTrashButtonClick (e) {
|
||||||
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
let { note } = this.state
|
||||||
type: 'warning',
|
const { isTrashed } = note
|
||||||
message: 'Delete a note',
|
|
||||||
detail: 'This work cannot be undone.',
|
if (isTrashed) {
|
||||||
buttons: ['Confirm', 'Cancel']
|
let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
})
|
type: 'warning',
|
||||||
if (index === 0) {
|
message: 'Confirm note deletion',
|
||||||
|
detail: 'This will permanently remove this note.',
|
||||||
|
buttons: ['Confirm', 'Cancel']
|
||||||
|
})
|
||||||
|
if (dialogueButtonIndex === 1) return
|
||||||
let { note, dispatch } = this.props
|
let { note, dispatch } = this.props
|
||||||
dataApi
|
dataApi
|
||||||
.deleteNote(note.storage, note.key)
|
.deleteNote(note.storage, note.key)
|
||||||
@@ -209,9 +194,34 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
ee.once('list:moved', dispatchHandler)
|
ee.once('list:moved', dispatchHandler)
|
||||||
ee.emit('list:next')
|
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
note.isTrashed = true
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
note
|
||||||
|
}, () => {
|
||||||
|
this.save()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
ee.emit('list:next')
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUndoButtonClick (e) {
|
||||||
|
let { note } = this.state
|
||||||
|
|
||||||
|
note.isTrashed = false
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
note
|
||||||
|
}, () => {
|
||||||
|
this.save()
|
||||||
|
ee.emit('list:next')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
handleFullScreenButton (e) {
|
||||||
|
ee.emit('editor:fullscreen')
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTabPlusButtonClick (e) {
|
handleTabPlusButtonClick (e) {
|
||||||
@@ -452,10 +462,27 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
this.refs['code-' + this.state.snippetIndex].focus()
|
this.refs['code-' + this.state.snippetIndex].focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleInfoButtonClick (e) {
|
||||||
|
const infoPanel = document.querySelector('.infoPanel')
|
||||||
|
if (infoPanel.style) infoPanel.style.display = infoPanel.style.display === 'none' ? 'inline' : 'none'
|
||||||
|
}
|
||||||
|
|
||||||
|
showWarning () {
|
||||||
|
dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Sorry!',
|
||||||
|
detail: 'md/text import is available only a markdown note.',
|
||||||
|
buttons: ['OK']
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { data, config } = this.props
|
let { data, config, location } = this.props
|
||||||
let { note } = this.state
|
let { note } = this.state
|
||||||
|
|
||||||
|
let storageKey = note.storage
|
||||||
|
let folderKey = note.folder
|
||||||
|
|
||||||
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
|
||||||
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
||||||
@@ -493,6 +520,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
onChange={(e) => this.handleCodeChange(index)(e)}
|
onChange={(e) => this.handleCodeChange(index)(e)}
|
||||||
ref={'code-' + index}
|
ref={'code-' + index}
|
||||||
ignorePreviewPointerEvents={this.props.ignorePreviewPointerEvents}
|
ignorePreviewPointerEvents={this.props.ignorePreviewPointerEvents}
|
||||||
|
storageKey={storageKey}
|
||||||
/>
|
/>
|
||||||
: <CodeEditor styleName='tabView-content'
|
: <CodeEditor styleName='tabView-content'
|
||||||
mode={snippet.mode}
|
mode={snippet.mode}
|
||||||
@@ -510,49 +538,90 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let options = []
|
||||||
|
data.storageMap.forEach((storage, index) => {
|
||||||
|
storage.folders.forEach((folder) => {
|
||||||
|
options.push({
|
||||||
|
storage: storage,
|
||||||
|
folder: folder
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
let currentOption = options.filter((option) => option.storage.key === storageKey && option.folder.key === folderKey)[0]
|
||||||
|
|
||||||
|
const trashTopBar = <div styleName='info'>
|
||||||
|
<div styleName='info-left'>
|
||||||
|
<i styleName='undo-button'
|
||||||
|
className='fa fa-undo fa-fw'
|
||||||
|
onClick={(e) => this.handleUndoButtonClick(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div styleName='info-right'>
|
||||||
|
<TrashButton onClick={(e) => this.handleTrashButtonClick(e)} />
|
||||||
|
<InfoButton
|
||||||
|
onClick={(e) => this.handleInfoButtonClick(e)}
|
||||||
|
/>
|
||||||
|
<InfoPanelTrashed
|
||||||
|
storageName={currentOption.storage.name}
|
||||||
|
folderName={currentOption.folder.name}
|
||||||
|
updatedAt={formatDate(note.updatedAt)}
|
||||||
|
createdAt={formatDate(note.createdAt)}
|
||||||
|
exportAsMd={this.showWarning}
|
||||||
|
exportAsTxt={this.showWarning}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
const detailTopBar = <div styleName='info'>
|
||||||
|
<div styleName='info-left'>
|
||||||
|
<StarButton styleName='info-left-button'
|
||||||
|
onClick={(e) => this.handleStarButtonClick(e)}
|
||||||
|
isActive={note.isStarred}
|
||||||
|
/>
|
||||||
|
<div styleName='info-left-top'>
|
||||||
|
<FolderSelect styleName='info-left-top-folderSelect'
|
||||||
|
value={this.state.note.storage + '-' + this.state.note.folder}
|
||||||
|
ref='folder'
|
||||||
|
data={data}
|
||||||
|
onChange={(e) => this.handleFolderChange(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TagSelect
|
||||||
|
ref='tags'
|
||||||
|
value={this.state.note.tags}
|
||||||
|
onChange={(e) => this.handleChange(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div styleName='info-right'>
|
||||||
|
<TrashButton onClick={(e) => this.handleTrashButtonClick(e)} />
|
||||||
|
<button styleName='control-fullScreenButton'
|
||||||
|
onMouseDown={(e) => this.handleFullScreenButton(e)}
|
||||||
|
>
|
||||||
|
<i className='fa fa-expand' styleName='fullScreen-button' />
|
||||||
|
</button>
|
||||||
|
<InfoButton
|
||||||
|
onClick={(e) => this.handleInfoButtonClick(e)}
|
||||||
|
/>
|
||||||
|
<InfoPanel
|
||||||
|
storageName={currentOption.storage.name}
|
||||||
|
folderName={currentOption.folder.name}
|
||||||
|
noteLink={`[${note.title}](${location.query.key})`}
|
||||||
|
updatedAt={formatDate(note.updatedAt)}
|
||||||
|
createdAt={formatDate(note.createdAt)}
|
||||||
|
exportAsMd={this.showWarning}
|
||||||
|
exportAsTxt={this.showWarning}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='NoteDetail'
|
<div className='NoteDetail'
|
||||||
style={this.props.style}
|
style={this.props.style}
|
||||||
styleName='root'
|
styleName='root'
|
||||||
onKeyDown={(e) => this.handleKeyDown(e)}
|
onKeyDown={(e) => this.handleKeyDown(e)}
|
||||||
>
|
>
|
||||||
<div styleName='info'>
|
{location.pathname === '/trashed' ? trashTopBar : detailTopBar}
|
||||||
<div styleName='info-left'>
|
|
||||||
<StarButton styleName='info-left-button'
|
|
||||||
onClick={(e) => this.handleStarButtonClick(e)}
|
|
||||||
isActive={note.isStarred}
|
|
||||||
/>
|
|
||||||
<div styleName='info-left-top'>
|
|
||||||
<FolderSelect styleName='info-left-top-folderSelect'
|
|
||||||
value={this.state.note.storage + '-' + this.state.note.folder}
|
|
||||||
ref='folder'
|
|
||||||
data={data}
|
|
||||||
onChange={(e) => this.handleFolderChange(e)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<TagSelect
|
|
||||||
ref='tags'
|
|
||||||
value={this.state.note.tags}
|
|
||||||
onChange={(e) => this.handleChange(e)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div styleName='info-right'>
|
|
||||||
<button styleName='control-trashButton'
|
|
||||||
onClick={(e) => this.handleDeleteButtonClick(e)}
|
|
||||||
>
|
|
||||||
<svg height='14px' id='Capa_1' style={{enableBackground: 'new 0 0 753.23 753.23'}} width='14px' version='1.1' viewBox='0 0 753.23 753.23' x='0px' y='0px' xmlSpace='preserve'>
|
|
||||||
<g>
|
|
||||||
<g id='_x34__19_'>
|
|
||||||
<g>
|
|
||||||
<path d='M494.308,659.077c12.993,0,23.538-10.546,23.538-23.539V353.077c0-12.993-10.545-23.539-23.538-23.539
				s-23.538,10.545-23.538,23.539v282.461C470.77,648.531,481.314,659.077,494.308,659.077z M635.538,94.154h-141.23V47.077
				C494.308,21.067,473.24,0,447.23,0H306c-26.01,0-47.077,21.067-47.077,47.077v47.077h-141.23
				c-26.01,0-47.077,21.067-47.077,47.077v47.077c0,25.986,21.067,47.077,47.077,47.077v423.692
				c0,51.996,42.157,94.153,94.154,94.153h329.539c51.996,0,94.153-42.157,94.153-94.153V235.385
				c26.01,0,47.077-21.091,47.077-47.077V141.23C682.615,115.221,661.548,94.154,635.538,94.154z M306,70.615
				c0-12.993,10.545-23.539,23.538-23.539h94.154c12.993,0,23.538,10.545,23.538,23.539v23.539c-22.809,0-141.23,0-141.23,0V70.615z
				 M588.461,659.077c0,25.986-21.066,47.076-47.076,47.076H211.846c-26.01,0-47.077-21.09-47.077-47.076V235.385h423.692V659.077z
				 M612,188.308H141.23c-12.993,0-23.538-10.545-23.538-23.539s10.545-23.539,23.538-23.539H612
				c12.993,0,23.538,10.545,23.538,23.539S624.993,188.308,612,188.308z M258.923,659.077c12.993,0,23.539-10.546,23.539-23.539
				V353.077c0-12.993-10.545-23.539-23.539-23.539s-23.539,10.545-23.539,23.539v282.461
				C235.384,648.531,245.93,659.077,258.923,659.077z M376.615,659.077c12.993,0,23.538-10.546,23.538-23.539V353.077
				c0-12.993-10.545-23.539-23.538-23.539s-23.539,10.545-23.539,23.539v282.461C353.077,648.531,363.622,659.077,376.615,659.077z' />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div styleName='body'>
|
<div styleName='body'>
|
||||||
<div styleName='description'>
|
<div styleName='description'>
|
||||||
|
|||||||
@@ -66,8 +66,9 @@
|
|||||||
&:active .update-icon
|
&:active .update-icon
|
||||||
color white
|
color white
|
||||||
|
|
||||||
.control-trashButton
|
.control-fullScreenButton
|
||||||
float right
|
float right
|
||||||
|
padding 0 0 2px 0
|
||||||
topBarButtonLight()
|
topBarButtonLight()
|
||||||
|
|
||||||
body[data-theme="dark"]
|
body[data-theme="dark"]
|
||||||
@@ -100,5 +101,5 @@ body[data-theme="dark"]
|
|||||||
transition 0.15s
|
transition 0.15s
|
||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
|
|
||||||
.control-trashButton
|
.control-fullScreenButton
|
||||||
topBarButtonDark()
|
topBarButtonDark()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { PropTypes } from 'react'
|
|||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './TagSelect.styl'
|
import styles from './TagSelect.styl'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
|
||||||
class TagSelect extends React.Component {
|
class TagSelect extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@@ -56,6 +57,7 @@ class TagSelect extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitTag () {
|
submitTag () {
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_TAG')
|
||||||
let { value } = this.props
|
let { value } = this.props
|
||||||
let newTag = this.refs.newTag.value.trim().replace(/ +/g, '_')
|
let newTag = this.refs.newTag.value.trim().replace(/ +/g, '_')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.root
|
.root
|
||||||
display inline-block
|
display inline-block
|
||||||
top 19px
|
|
||||||
user-select none
|
user-select none
|
||||||
|
height 23px
|
||||||
vertical-align middle
|
vertical-align middle
|
||||||
width 300px
|
width 300px
|
||||||
overflow-x scroll
|
overflow-x scroll
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
display inline-block
|
display inline-block
|
||||||
margin 1px 3px
|
margin 1px 3px
|
||||||
padding 0
|
padding 0
|
||||||
vertical-align middle
|
|
||||||
height 20px
|
height 20px
|
||||||
background-color alpha($ui-tag-backgroundColor, 10%)
|
background-color alpha($ui-tag-backgroundColor, 10%)
|
||||||
border-radius 3px
|
border-radius 3px
|
||||||
@@ -49,9 +48,9 @@
|
|||||||
|
|
||||||
.newTag
|
.newTag
|
||||||
display inline-block
|
display inline-block
|
||||||
margin 0 2px
|
margin 2px 0 15px 2px
|
||||||
vertical-align middle
|
vertical-align middle
|
||||||
height 24px
|
height 18px
|
||||||
box-sizing borde-box
|
box-sizing borde-box
|
||||||
border none
|
border none
|
||||||
background-color transparent
|
background-color transparent
|
||||||
|
|||||||
19
browser/main/Detail/TrashButton.js
Normal file
19
browser/main/Detail/TrashButton.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './TrashButton.styl'
|
||||||
|
|
||||||
|
const TrashButton = ({
|
||||||
|
onClick
|
||||||
|
}) => (
|
||||||
|
<button styleName='control-trashButton'
|
||||||
|
onClick={(e) => onClick(e)}
|
||||||
|
>
|
||||||
|
<i className='fa fa-trash trashButton' styleName='info-button' />
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
|
||||||
|
TrashButton.propTypes = {
|
||||||
|
onClick: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(TrashButton, styles)
|
||||||
11
browser/main/Detail/TrashButton.styl
Normal file
11
browser/main/Detail/TrashButton.styl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.control-trashButton
|
||||||
|
float right
|
||||||
|
topBarButtonLight()
|
||||||
|
|
||||||
|
.trashButton
|
||||||
|
padding 0px
|
||||||
|
margin 15px 0
|
||||||
|
|
||||||
|
body[data-theme="dark"]
|
||||||
|
.control-trashButton
|
||||||
|
topBarButtonDark()
|
||||||
@@ -17,7 +17,7 @@ class Detail extends React.Component {
|
|||||||
this.refs.root != null && this.refs.root.focus()
|
this.refs.root != null && this.refs.root.focus()
|
||||||
}
|
}
|
||||||
this.deleteHandler = () => {
|
this.deleteHandler = () => {
|
||||||
this.refs.root != null && this.refs.root.handleDeleteMenuClick()
|
this.refs.root != null && this.refs.root.handleTrashButtonClick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ class Detail extends React.Component {
|
|||||||
tabIndex='0'
|
tabIndex='0'
|
||||||
>
|
>
|
||||||
<div styleName='empty'>
|
<div styleName='empty'>
|
||||||
<div styleName='empty-message'>{OSX ? 'Command(⌘)' : 'Ctrl(^)'} + N<br />to create a new post</div>
|
<div styleName='empty-message'>{OSX ? 'Command(⌘)' : 'Ctrl(^)'} + N<br />to create a new note</div>
|
||||||
</div>
|
</div>
|
||||||
<StatusBar
|
<StatusBar
|
||||||
{..._.pick(this.props, ['config', 'location', 'dispatch'])}
|
{..._.pick(this.props, ['config', 'location', 'dispatch'])}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import ConfigManager from 'browser/main/lib/ConfigManager'
|
|||||||
import modal from 'browser/main/lib/modal'
|
import modal from 'browser/main/lib/modal'
|
||||||
import InitModal from 'browser/main/modals/InitModal'
|
import InitModal from 'browser/main/modals/InitModal'
|
||||||
import mixpanel from 'browser/main/lib/mixpanel'
|
import mixpanel from 'browser/main/lib/mixpanel'
|
||||||
|
import mobileAnalytics from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||||
|
|
||||||
function focused () {
|
function focused () {
|
||||||
mixpanel.track('MAIN_FOCUSED')
|
mixpanel.track('MAIN_FOCUSED')
|
||||||
@@ -21,14 +23,23 @@ class Main extends React.Component {
|
|||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
mobileAnalytics.initAwsMobileAnalytics()
|
||||||
|
}
|
||||||
|
|
||||||
let { config } = props
|
let { config } = props
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isRightSliderFocused: false,
|
isRightSliderFocused: false,
|
||||||
listWidth: config.listWidth,
|
listWidth: config.listWidth,
|
||||||
navWidth: config.navWidth,
|
navWidth: config.navWidth,
|
||||||
isLeftSliderFocused: false
|
isLeftSliderFocused: false,
|
||||||
|
fullScreen: false,
|
||||||
|
noteDetailWidth: 0,
|
||||||
|
mainBodyWidth: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.toggleFullScreen = () => this.handleFullScreenButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildContext () {
|
getChildContext () {
|
||||||
@@ -63,11 +74,13 @@ class Main extends React.Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
eventEmitter.on('editor:fullscreen', this.toggleFullScreen)
|
||||||
window.addEventListener('focus', focused)
|
window.addEventListener('focus', focused)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
window.removeEventListener('focus', focused)
|
window.removeEventListener('focus', focused)
|
||||||
|
eventEmitter.off('editor:fullscreen', this.toggleFullScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLeftSlideMouseDown (e) {
|
handleLeftSlideMouseDown (e) {
|
||||||
@@ -144,6 +157,34 @@ class Main extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleFullScreenButton (e) {
|
||||||
|
this.setState({ fullScreen: !this.state.fullScreen }, () => {
|
||||||
|
const noteDetail = document.querySelector('.NoteDetail')
|
||||||
|
const noteList = document.querySelector('.NoteList')
|
||||||
|
const mainBody = document.querySelector('#main-body')
|
||||||
|
|
||||||
|
if (this.state.fullScreen) {
|
||||||
|
this.hideLeftLists(noteDetail, noteList, mainBody)
|
||||||
|
} else {
|
||||||
|
this.showLeftLists(noteDetail, noteList, mainBody)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLeftLists (noteDetail, noteList, mainBody) {
|
||||||
|
this.state.noteDetailWidth = noteDetail.style.left
|
||||||
|
this.state.mainBodyWidth = mainBody.style.left
|
||||||
|
noteDetail.style.left = '0px'
|
||||||
|
mainBody.style.left = '0px'
|
||||||
|
noteList.style.display = 'none'
|
||||||
|
}
|
||||||
|
|
||||||
|
showLeftLists (noteDetail, noteList, mainBody) {
|
||||||
|
noteDetail.style.left = this.state.noteDetailWidth
|
||||||
|
mainBody.style.left = this.state.mainBodyWidth
|
||||||
|
noteList.style.display = 'inline'
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { config } = this.props
|
let { config } = this.props
|
||||||
|
|
||||||
@@ -173,6 +214,7 @@ class Main extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div styleName={config.isSideNavFolded ? 'body--expanded' : 'body'}
|
<div styleName={config.isSideNavFolded ? 'body--expanded' : 'body'}
|
||||||
|
id='main-body'
|
||||||
ref='body'
|
ref='body'
|
||||||
style={{left: config.isSideNavFolded ? 44 : this.state.navWidth}}
|
style={{left: config.isSideNavFolded ? 44 : this.state.navWidth}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
absolute top bottom
|
absolute top bottom
|
||||||
top -2px
|
top -2px
|
||||||
width 0
|
width 0
|
||||||
|
z-index 0
|
||||||
|
|
||||||
.slider-right
|
.slider-right
|
||||||
@extend .slider
|
@extend .slider
|
||||||
width 1px
|
width 1px
|
||||||
|
z-index 0
|
||||||
|
|
||||||
.slider--active
|
.slider--active
|
||||||
@extend .slider
|
@extend .slider
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ $control-height = 30px
|
|||||||
|
|
||||||
.control-sortBy
|
.control-sortBy
|
||||||
flex 1
|
flex 1
|
||||||
padding-left 25px
|
padding-left 22px
|
||||||
|
|
||||||
.control-sortBy-select
|
.control-sortBy-select
|
||||||
appearance: none;
|
appearance: none;
|
||||||
@@ -28,11 +28,14 @@ $control-height = 30px
|
|||||||
background-color transparent
|
background-color transparent
|
||||||
outline none
|
outline none
|
||||||
cursor pointer
|
cursor pointer
|
||||||
font-size 10px
|
font-size 11px
|
||||||
&:hover
|
&:hover
|
||||||
transition 0.2s
|
transition 0.2s
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
|
.control-button-area
|
||||||
|
margin-right 12px
|
||||||
|
|
||||||
.control-button
|
.control-button
|
||||||
width 25px
|
width 25px
|
||||||
padding 0
|
padding 0
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import dataApi from 'browser/main/lib/dataApi'
|
|||||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
import NoteItem from 'browser/components/NoteItem'
|
import NoteItem from 'browser/components/NoteItem'
|
||||||
import NoteItemSimple from 'browser/components/NoteItemSimple'
|
import NoteItemSimple from 'browser/components/NoteItemSimple'
|
||||||
|
import searchFromNotes from 'browser/lib/search'
|
||||||
|
import fs from 'fs'
|
||||||
|
import { hashHistory } from 'react-router'
|
||||||
|
import markdown from 'browser/lib/markdown'
|
||||||
|
import { findNoteTitle } from 'browser/lib/findNoteTitle'
|
||||||
|
|
||||||
const { remote } = require('electron')
|
const { remote } = require('electron')
|
||||||
const { Menu, MenuItem, dialog } = remote
|
const { Menu, MenuItem, dialog } = remote
|
||||||
@@ -41,10 +46,8 @@ class NoteList extends React.Component {
|
|||||||
this.alertIfSnippetHandler = () => {
|
this.alertIfSnippetHandler = () => {
|
||||||
this.alertIfSnippet()
|
this.alertIfSnippet()
|
||||||
}
|
}
|
||||||
|
this.importFromFileHandler = this.importFromFile.bind(this)
|
||||||
this.jumpToTopHandler = () => {
|
this.jumpNoteByHash = this.jumpNoteByHashHandler.bind(this)
|
||||||
this.jumpToTop()
|
|
||||||
}
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
}
|
}
|
||||||
@@ -56,8 +59,8 @@ class NoteList extends React.Component {
|
|||||||
ee.on('list:prior', this.selectPriorNoteHandler)
|
ee.on('list:prior', this.selectPriorNoteHandler)
|
||||||
ee.on('list:focus', this.focusHandler)
|
ee.on('list:focus', this.focusHandler)
|
||||||
ee.on('list:isMarkdownNote', this.alertIfSnippetHandler)
|
ee.on('list:isMarkdownNote', this.alertIfSnippetHandler)
|
||||||
ee.on('list:top', this.jumpToTopHandler)
|
ee.on('import:file', this.importFromFileHandler)
|
||||||
ee.on('list:jumpToTop', this.jumpToTopHandler)
|
ee.on('list:jump', this.jumpNoteByHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
@@ -77,8 +80,8 @@ class NoteList extends React.Component {
|
|||||||
ee.off('list:prior', this.selectPriorNoteHandler)
|
ee.off('list:prior', this.selectPriorNoteHandler)
|
||||||
ee.off('list:focus', this.focusHandler)
|
ee.off('list:focus', this.focusHandler)
|
||||||
ee.off('list:isMarkdownNote', this.alertIfSnippetHandler)
|
ee.off('list:isMarkdownNote', this.alertIfSnippetHandler)
|
||||||
ee.off('list:top', this.jumpToTopHandler)
|
ee.off('import:file', this.importFromFileHandler)
|
||||||
ee.off('list:jumpToTop', this.jumpToTopHandler)
|
ee.off('list:jump', this.jumpNoteByHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate (prevProps) {
|
componentDidUpdate (prevProps) {
|
||||||
@@ -171,6 +174,31 @@ class NoteList extends React.Component {
|
|||||||
ee.emit('list:moved')
|
ee.emit('list:moved')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jumpNoteByHashHandler (event, noteHash) {
|
||||||
|
// first argument event isn't used.
|
||||||
|
if (this.notes === null || this.notes.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const { router } = this.context
|
||||||
|
const { location } = this.props
|
||||||
|
|
||||||
|
let targetIndex = _.findIndex(this.notes, (note) => {
|
||||||
|
return note.storage + '-' + note.key === noteHash
|
||||||
|
})
|
||||||
|
|
||||||
|
if (targetIndex < 0) targetIndex = 0
|
||||||
|
|
||||||
|
router.push({
|
||||||
|
pathname: location.pathname,
|
||||||
|
query: {
|
||||||
|
key: this.notes[targetIndex].storage + '-' + this.notes[targetIndex].key
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ee.emit('list:moved')
|
||||||
|
}
|
||||||
|
|
||||||
handleNoteListKeyDown (e) {
|
handleNoteListKeyDown (e) {
|
||||||
if (e.metaKey || e.ctrlKey) return true
|
if (e.metaKey || e.ctrlKey) return true
|
||||||
|
|
||||||
@@ -202,6 +230,7 @@ class NoteList extends React.Component {
|
|||||||
|
|
||||||
getNotes () {
|
getNotes () {
|
||||||
let { data, params, location } = this.props
|
let { data, params, location } = this.props
|
||||||
|
let { router } = this.context
|
||||||
|
|
||||||
if (location.pathname.match(/\/home/)) {
|
if (location.pathname.match(/\/home/)) {
|
||||||
return data.noteMap.map((note) => note)
|
return data.noteMap.map((note) => note)
|
||||||
@@ -212,6 +241,19 @@ class NoteList extends React.Component {
|
|||||||
.map((uniqueKey) => data.noteMap.get(uniqueKey))
|
.map((uniqueKey) => data.noteMap.get(uniqueKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (location.pathname.match(/\/searched/)) {
|
||||||
|
const searchInputText = document.getElementsByClassName('searchInput')[0].value
|
||||||
|
if (searchInputText === '') {
|
||||||
|
router.push('/home')
|
||||||
|
}
|
||||||
|
return searchFromNotes(this.notes, searchInputText)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.pathname.match(/\/trashed/)) {
|
||||||
|
return data.trashedSet.toJS()
|
||||||
|
.map((uniqueKey) => data.noteMap.get(uniqueKey))
|
||||||
|
}
|
||||||
|
|
||||||
let storageKey = params.storageKey
|
let storageKey = params.storageKey
|
||||||
let folderKey = params.folderKey
|
let folderKey = params.folderKey
|
||||||
let storage = data.storageMap.get(storageKey)
|
let storage = data.storageMap.get(storageKey)
|
||||||
@@ -247,49 +289,6 @@ class NoteList extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNoteContextMenu (e, uniqueKey) {
|
|
||||||
let menu = new Menu()
|
|
||||||
menu.append(new MenuItem({
|
|
||||||
label: 'Delete Note',
|
|
||||||
click: (e) => this.handleDeleteNote(e, uniqueKey)
|
|
||||||
}))
|
|
||||||
menu.popup()
|
|
||||||
}
|
|
||||||
|
|
||||||
handleDeleteNote (e, uniqueKey) {
|
|
||||||
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
|
||||||
type: 'warning',
|
|
||||||
message: 'Delete a note',
|
|
||||||
detail: 'This work cannot be undone.',
|
|
||||||
buttons: ['Confirm', 'Cancel']
|
|
||||||
})
|
|
||||||
if (index === 0) {
|
|
||||||
let { dispatch, location } = this.props
|
|
||||||
let splitted = uniqueKey.split('-')
|
|
||||||
let storageKey = splitted.shift()
|
|
||||||
let noteKey = splitted.shift()
|
|
||||||
|
|
||||||
dataApi
|
|
||||||
.deleteNote(storageKey, noteKey)
|
|
||||||
.then((data) => {
|
|
||||||
let dispatchHandler = () => {
|
|
||||||
dispatch({
|
|
||||||
type: 'DELETE_NOTE',
|
|
||||||
storageKey: data.storageKey,
|
|
||||||
noteKey: data.noteKey
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (location.query.key === uniqueKey) {
|
|
||||||
ee.once('list:moved', dispatchHandler)
|
|
||||||
ee.emit('list:next')
|
|
||||||
} else {
|
|
||||||
dispatchHandler()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSortByChange (e) {
|
handleSortByChange (e) {
|
||||||
let { dispatch } = this.props
|
let { dispatch } = this.props
|
||||||
|
|
||||||
@@ -327,30 +326,64 @@ class NoteList extends React.Component {
|
|||||||
dialog.showMessageBox(remote.getCurrentWindow(), {
|
dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Sorry!',
|
message: 'Sorry!',
|
||||||
detail: 'md/text import is available only a markdown note.'
|
detail: 'md/text import is available only a markdown note.',
|
||||||
|
buttons: ['OK', 'Cancel']
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jumpToTop () {
|
handleDragStart (e, note) {
|
||||||
if (this.notes === null || this.notes.length === 0) {
|
const noteData = JSON.stringify(note)
|
||||||
return
|
e.dataTransfer.setData('note', noteData)
|
||||||
|
}
|
||||||
|
|
||||||
|
importFromFile () {
|
||||||
|
const { dispatch, location } = this.props
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
filters: [
|
||||||
|
{ name: 'Documents', extensions: ['md', 'txt'] }
|
||||||
|
],
|
||||||
|
properties: ['openFile', 'multiSelections']
|
||||||
}
|
}
|
||||||
let { router } = this.context
|
|
||||||
let { location } = this.props
|
|
||||||
|
|
||||||
const targetIndex = 0
|
const targetIndex = _.findIndex(this.notes, (note) => {
|
||||||
|
return note !== null && `${note.storage}-${note.key}` === location.query.key
|
||||||
|
})
|
||||||
|
|
||||||
router.push({
|
const storageKey = this.notes[targetIndex].storage
|
||||||
pathname: location.pathname,
|
const folderKey = this.notes[targetIndex].folder
|
||||||
query: {
|
|
||||||
key: this.notes[targetIndex].storage + '-' + this.notes[targetIndex].key
|
dialog.showOpenDialog(remote.getCurrentWindow(), options, (filepaths) => {
|
||||||
}
|
if (filepaths === undefined) return
|
||||||
|
filepaths.forEach((filepath) => {
|
||||||
|
fs.readFile(filepath, (err, data) => {
|
||||||
|
if (err) throw Error('File reading error: ', err)
|
||||||
|
const content = data.toString()
|
||||||
|
const newNote = {
|
||||||
|
content: content,
|
||||||
|
folder: folderKey,
|
||||||
|
title: markdown.strip(findNoteTitle(content)),
|
||||||
|
type: 'MARKDOWN_NOTE'
|
||||||
|
}
|
||||||
|
dataApi.createNote(storageKey, newNote)
|
||||||
|
.then((note) => {
|
||||||
|
dispatch({
|
||||||
|
type: 'UPDATE_NOTE',
|
||||||
|
note: note
|
||||||
|
})
|
||||||
|
hashHistory.push({
|
||||||
|
pathname: location.pathname,
|
||||||
|
query: {key: `${note.storage}-${note.key}`}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { location, notes, config } = this.props
|
let { location, notes, config, dispatch } = this.props
|
||||||
let sortFunc = config.sortBy === 'CREATED_AT'
|
let sortFunc = config.sortBy === 'CREATED_AT'
|
||||||
? sortByCreatedAt
|
? sortByCreatedAt
|
||||||
: config.sortBy === 'ALPHABETICAL'
|
: config.sortBy === 'ALPHABETICAL'
|
||||||
@@ -358,6 +391,10 @@ class NoteList extends React.Component {
|
|||||||
: sortByUpdatedAt
|
: sortByUpdatedAt
|
||||||
this.notes = notes = this.getNotes()
|
this.notes = notes = this.getNotes()
|
||||||
.sort(sortFunc)
|
.sort(sortFunc)
|
||||||
|
.filter((note) => {
|
||||||
|
// this is for the trash box
|
||||||
|
if (note.isTrashed !== true || location.pathname === '/trashed') return true
|
||||||
|
})
|
||||||
|
|
||||||
let noteList = notes
|
let noteList = notes
|
||||||
.map(note => {
|
.map(note => {
|
||||||
@@ -381,7 +418,7 @@ class NoteList extends React.Component {
|
|||||||
dateDisplay={dateDisplay}
|
dateDisplay={dateDisplay}
|
||||||
key={key}
|
key={key}
|
||||||
handleNoteClick={this.handleNoteClick.bind(this)}
|
handleNoteClick={this.handleNoteClick.bind(this)}
|
||||||
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
|
handleDragStart={this.handleDragStart.bind(this)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -392,7 +429,7 @@ class NoteList extends React.Component {
|
|||||||
note={note}
|
note={note}
|
||||||
key={key}
|
key={key}
|
||||||
handleNoteClick={this.handleNoteClick.bind(this)}
|
handleNoteClick={this.handleNoteClick.bind(this)}
|
||||||
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
|
handleDragStart={this.handleDragStart.bind(this)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -409,27 +446,29 @@ class NoteList extends React.Component {
|
|||||||
value={config.sortBy}
|
value={config.sortBy}
|
||||||
onChange={(e) => this.handleSortByChange(e)}
|
onChange={(e) => this.handleSortByChange(e)}
|
||||||
>
|
>
|
||||||
<option value='UPDATED_AT'>Updated Time</option>
|
<option value='UPDATED_AT'>Last Updated</option>
|
||||||
<option value='CREATED_AT'>Created Time</option>
|
<option value='CREATED_AT'>Creation Time</option>
|
||||||
<option value='ALPHABETICAL'>Alphabetical</option>
|
<option value='ALPHABETICAL'>Alphabetically</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<button styleName={config.listStyle === 'DEFAULT'
|
<div styleName='control-button-area'>
|
||||||
? 'control-button--active'
|
<button styleName={config.listStyle === 'DEFAULT'
|
||||||
: 'control-button'
|
? 'control-button--active'
|
||||||
}
|
: 'control-button'
|
||||||
onClick={(e) => this.handleListStyleButtonClick(e, 'DEFAULT')}
|
}
|
||||||
>
|
onClick={(e) => this.handleListStyleButtonClick(e, 'DEFAULT')}
|
||||||
<i className='fa fa-th-large' />
|
>
|
||||||
</button>
|
<i className='fa fa-th-large' />
|
||||||
<button styleName={config.listStyle === 'SMALL'
|
</button>
|
||||||
? 'control-button--active'
|
<button styleName={config.listStyle === 'SMALL'
|
||||||
: 'control-button'
|
? 'control-button--active'
|
||||||
}
|
: 'control-button'
|
||||||
onClick={(e) => this.handleListStyleButtonClick(e, 'SMALL')}
|
}
|
||||||
>
|
onClick={(e) => this.handleListStyleButtonClick(e, 'SMALL')}
|
||||||
<i className='fa fa-list-ul' />
|
>
|
||||||
</button>
|
<i className='fa fa-list-ul' />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div styleName='list'
|
<div styleName='list'
|
||||||
ref='list'
|
ref='list'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.root
|
.root
|
||||||
absolute top left bottom
|
absolute top left bottom
|
||||||
width $sideNav-width
|
width $sideNav-width
|
||||||
background-color $ui-backgroundColor
|
background-color #f9f9f9
|
||||||
user-select none
|
user-select none
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import CreateFolderModal from 'browser/main/modals/CreateFolderModal'
|
|||||||
import RenameFolderModal from 'browser/main/modals/RenameFolderModal'
|
import RenameFolderModal from 'browser/main/modals/RenameFolderModal'
|
||||||
import dataApi from 'browser/main/lib/dataApi'
|
import dataApi from 'browser/main/lib/dataApi'
|
||||||
import StorageItemChild from 'browser/components/StorageItem'
|
import StorageItemChild from 'browser/components/StorageItem'
|
||||||
|
import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||||
|
|
||||||
const { remote } = require('electron')
|
const { remote } = require('electron')
|
||||||
const { Menu, MenuItem, dialog } = remote
|
const { Menu, MenuItem, dialog } = remote
|
||||||
@@ -113,7 +114,7 @@ class StorageItem extends React.Component {
|
|||||||
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Delete Folder',
|
message: 'Delete Folder',
|
||||||
detail: 'This work will deletes all notes in the folder and can not be undone.',
|
detail: 'This will delete all notes in the folder and can not be undone.',
|
||||||
buttons: ['Confirm', 'Cancel']
|
buttons: ['Confirm', 'Cancel']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -131,16 +132,68 @@ class StorageItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDragEnter (e) {
|
||||||
|
e.dataTransfer.setData('defaultColor', e.target.style.backgroundColor)
|
||||||
|
e.target.style.backgroundColor = 'rgba(129, 130, 131, 0.08)'
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDragLeave (e) {
|
||||||
|
e.target.style.opacity = '1'
|
||||||
|
e.target.style.backgroundColor = e.dataTransfer.getData('defaultColor')
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDrop (e, storage, folder, dispatch, location) {
|
||||||
|
e.target.style.opacity = '1'
|
||||||
|
e.target.style.backgroundColor = e.dataTransfer.getData('defaultColor')
|
||||||
|
const noteData = JSON.parse(e.dataTransfer.getData('note'))
|
||||||
|
const newNoteData = Object.assign({}, noteData, {storage: storage, folder: folder.key})
|
||||||
|
if (folder.key === noteData.folder) return
|
||||||
|
dataApi
|
||||||
|
.createNote(storage.key, newNoteData)
|
||||||
|
.then((note) => {
|
||||||
|
dataApi
|
||||||
|
.deleteNote(noteData.storage, noteData.key)
|
||||||
|
.then((data) => {
|
||||||
|
let dispatchHandler = () => {
|
||||||
|
dispatch({
|
||||||
|
type: 'DELETE_NOTE',
|
||||||
|
storageKey: data.storageKey,
|
||||||
|
noteKey: data.noteKey
|
||||||
|
})
|
||||||
|
}
|
||||||
|
eventEmitter.once('list:moved', dispatchHandler)
|
||||||
|
eventEmitter.emit('list:next')
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
dispatch({
|
||||||
|
type: 'UPDATE_NOTE',
|
||||||
|
note: note
|
||||||
|
})
|
||||||
|
hashHistory.push({
|
||||||
|
pathname: location.pathname,
|
||||||
|
query: {key: `${note.storage}-${note.key}`}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { storage, location, isFolded, data } = this.props
|
let { storage, location, isFolded, data, dispatch } = this.props
|
||||||
let { folderNoteMap } = data
|
let { folderNoteMap, trashedSet } = data
|
||||||
let folderList = storage.folders.map((folder) => {
|
let folderList = storage.folders.map((folder) => {
|
||||||
let isActive = !!(location.pathname.match(new RegExp('\/storages\/' + storage.key + '\/folders\/' + folder.key)))
|
let isActive = !!(location.pathname.match(new RegExp('\/storages\/' + storage.key + '\/folders\/' + folder.key)))
|
||||||
let noteSet = folderNoteMap.get(storage.key + '-' + folder.key)
|
let noteSet = folderNoteMap.get(storage.key + '-' + folder.key)
|
||||||
|
|
||||||
let noteCount = noteSet != null
|
let noteCount = 0
|
||||||
? noteSet.size
|
if (noteSet) {
|
||||||
: 0
|
let trashedNoteCount = 0
|
||||||
|
const noteKeys = noteSet.map(noteKey => { return noteKey })
|
||||||
|
trashedSet.toJS().forEach(trashedKey => {
|
||||||
|
if (noteKeys.some(noteKey => { return noteKey === trashedKey })) trashedNoteCount++
|
||||||
|
})
|
||||||
|
noteCount = noteSet.size - trashedNoteCount
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<StorageItemChild
|
<StorageItemChild
|
||||||
key={folder.key}
|
key={folder.key}
|
||||||
@@ -151,6 +204,9 @@ class StorageItem extends React.Component {
|
|||||||
folderColor={folder.color}
|
folderColor={folder.color}
|
||||||
isFolded={isFolded}
|
isFolded={isFolded}
|
||||||
noteCount={noteCount}
|
noteCount={noteCount}
|
||||||
|
handleDrop={(e) => this.handleDrop(e, storage, folder, dispatch, location)}
|
||||||
|
handleDragEnter={this.handleDragEnter}
|
||||||
|
handleDragLeave={this.handleDragLeave}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
.root
|
.root
|
||||||
width 100%
|
width 100%
|
||||||
user-select none
|
user-select none
|
||||||
|
padding-top 20px
|
||||||
|
|
||||||
.header
|
.header
|
||||||
position relative
|
position relative
|
||||||
height 26px
|
height 25px
|
||||||
width 100%
|
width 100%
|
||||||
margin-bottom 5px
|
margin-bottom 5px
|
||||||
transition 0.15s
|
transition 0.15s
|
||||||
|
|
||||||
.header--active
|
.header--active
|
||||||
|
margin-bottom 5px
|
||||||
background-color $ui-button--active-backgroundColor
|
background-color $ui-button--active-backgroundColor
|
||||||
transition color background-color 0.15s
|
transition color background-color 0.15s
|
||||||
|
|
||||||
@@ -30,26 +32,29 @@
|
|||||||
position absolute
|
position absolute
|
||||||
left 0
|
left 0
|
||||||
width 25px
|
width 25px
|
||||||
height 26px
|
height 25px
|
||||||
padding 0
|
padding 0
|
||||||
border none
|
border none
|
||||||
|
border-radius 50%
|
||||||
&:hover
|
&:hover
|
||||||
background-color transparent
|
transition 0.2s
|
||||||
|
background-color alpha($ui-button--active-backgroundColor, 40%)
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
.header-info
|
.header-info
|
||||||
navButtonColor()
|
navButtonColor()
|
||||||
display block
|
display block
|
||||||
width 100%
|
width 100%
|
||||||
height 30px
|
height 25px
|
||||||
padding-left 25px
|
padding-left 23px
|
||||||
padding-right 10px
|
padding-right 10px
|
||||||
line-height 26px
|
line-height 22px
|
||||||
cursor pointer
|
cursor pointer
|
||||||
font-size 13px
|
font-size 13px
|
||||||
border none
|
border none
|
||||||
overflow ellipsis
|
overflow ellipsis
|
||||||
text-align left
|
text-align left
|
||||||
|
background-color alpha($ui-button--active-backgroundColor, 20%)
|
||||||
|
|
||||||
.header-info-path
|
.header-info-path
|
||||||
font-size 10px
|
font-size 10px
|
||||||
@@ -60,11 +65,14 @@
|
|||||||
position absolute
|
position absolute
|
||||||
right 0
|
right 0
|
||||||
width 25px
|
width 25px
|
||||||
height 26px
|
height 25px
|
||||||
padding 0
|
padding 0
|
||||||
border none
|
border none
|
||||||
|
margin-right 5px
|
||||||
|
border-radius 50%
|
||||||
&:hover
|
&:hover
|
||||||
background-color transparent
|
transition 0.2s
|
||||||
|
background-color alpha($ui-button--active-backgroundColor, 40%)
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
.root--folded
|
.root--folded
|
||||||
@@ -117,10 +125,17 @@ body[data-theme="dark"]
|
|||||||
|
|
||||||
.header-toggleButton
|
.header-toggleButton
|
||||||
&:hover
|
&:hover
|
||||||
|
transition 0.2s
|
||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
|
background-color alpha($ui-dark-button--active-backgroundColor, 60%)
|
||||||
|
&:active, &:active:hover
|
||||||
|
color $ui-dark-text-color
|
||||||
|
background-color $ui-dark-button--active-backgroundColor
|
||||||
|
|
||||||
.header-info
|
.header-info
|
||||||
|
background-color alpha($ui-dark-button--active-backgroundColor, 20%)
|
||||||
&:hover
|
&:hover
|
||||||
|
transition 0.2s
|
||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
background-color alpha($ui-dark-button--active-backgroundColor, 20%)
|
background-color alpha($ui-dark-button--active-backgroundColor, 20%)
|
||||||
&:active, &:active:hover
|
&:active, &:active:hover
|
||||||
@@ -129,4 +144,9 @@ body[data-theme="dark"]
|
|||||||
|
|
||||||
.header-addFolderButton
|
.header-addFolderButton
|
||||||
&:hover
|
&:hover
|
||||||
|
transition 0.2s
|
||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
|
background-color alpha($ui-dark-button--active-backgroundColor, 60%)
|
||||||
|
&:active, &:active:hover
|
||||||
|
color $ui-dark-text-color
|
||||||
|
background-color $ui-dark-button--active-backgroundColor
|
||||||
@@ -33,12 +33,18 @@ class SideNav extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleTrashedButtonClick (e) {
|
||||||
|
let { router } = this.context
|
||||||
|
router.push('/trashed')
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { data, location, config, dispatch } = this.props
|
let { data, location, config, dispatch } = this.props
|
||||||
|
|
||||||
let isFolded = config.isSideNavFolded
|
let isFolded = config.isSideNavFolded
|
||||||
let isHomeActive = !!location.pathname.match(/^\/home$/)
|
let isHomeActive = !!location.pathname.match(/^\/home$/)
|
||||||
let isStarredActive = !!location.pathname.match(/^\/starred$/)
|
let isStarredActive = !!location.pathname.match(/^\/starred$/)
|
||||||
|
let isTrashedActive = !!location.pathname.match(/^\/trashed$/)
|
||||||
|
|
||||||
let storageList = data.storageMap.map((storage, key) => {
|
let storageList = data.storageMap.map((storage, key) => {
|
||||||
return <StorageItem
|
return <StorageItem
|
||||||
@@ -62,8 +68,8 @@ class SideNav extends React.Component {
|
|||||||
<button styleName='top-menu'
|
<button styleName='top-menu'
|
||||||
onClick={(e) => this.handleMenuButtonClick(e)}
|
onClick={(e) => this.handleMenuButtonClick(e)}
|
||||||
>
|
>
|
||||||
<i className='fa fa-navicon fa-fw' />
|
<i className='fa fa-wrench fa-fw' />
|
||||||
<span styleName='top-menu-label'>Menu</span>
|
<span styleName='top-menu-label'>Preferences</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -72,7 +78,9 @@ class SideNav extends React.Component {
|
|||||||
isHomeActive={isHomeActive}
|
isHomeActive={isHomeActive}
|
||||||
handleAllNotesButtonClick={(e) => this.handleHomeButtonClick(e)}
|
handleAllNotesButtonClick={(e) => this.handleHomeButtonClick(e)}
|
||||||
isStarredActive={isStarredActive}
|
isStarredActive={isStarredActive}
|
||||||
|
isTrashedActive={isTrashedActive}
|
||||||
handleStarredButtonClick={(e) => this.handleStarredButtonClick(e)}
|
handleStarredButtonClick={(e) => this.handleStarredButtonClick(e)}
|
||||||
|
handleTrashedButtonClick={(e) => this.handleTrashedButtonClick(e)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div styleName='storageList'>
|
<div styleName='storageList'>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React, { PropTypes } from 'react'
|
|||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './StatusBar.styl'
|
import styles from './StatusBar.styl'
|
||||||
import ZoomManager from 'browser/main/lib/ZoomManager'
|
import ZoomManager from 'browser/main/lib/ZoomManager'
|
||||||
import LastUpdatedString from '../Detail/LastUpdatedString'
|
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { remote, ipcRenderer } = electron
|
const { remote, ipcRenderer } = electron
|
||||||
@@ -68,8 +67,6 @@ class StatusBar extends React.Component {
|
|||||||
</button>
|
</button>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
||||||
<LastUpdatedString date={this.props.date} />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,26 +19,25 @@ $control-height = 34px
|
|||||||
|
|
||||||
.control-search
|
.control-search
|
||||||
height 32px
|
height 32px
|
||||||
|
width 1px
|
||||||
flex 1
|
flex 1
|
||||||
background-color white
|
background-color white
|
||||||
position relative
|
position relative
|
||||||
|
|
||||||
.control-search-icon
|
|
||||||
absolute top bottom left
|
|
||||||
line-height 32px
|
|
||||||
width 35px
|
|
||||||
color $ui-inactive-text-color
|
|
||||||
background-color $ui-noteList-backgroundColor
|
|
||||||
|
|
||||||
.control-search-input
|
.control-search-input
|
||||||
display block
|
display block
|
||||||
absolute top bottom right
|
absolute top bottom right
|
||||||
left 30px
|
width 100%
|
||||||
|
padding-left 12px
|
||||||
|
background-color $ui-noteList-backgroundColor
|
||||||
input
|
input
|
||||||
width 100%
|
width 100%
|
||||||
height 100%
|
height 100%
|
||||||
outline none
|
outline none
|
||||||
border none
|
border none
|
||||||
|
color $ui-text-color
|
||||||
|
font-size 16px
|
||||||
|
padding-bottom 2px
|
||||||
background-color $ui-noteList-backgroundColor
|
background-color $ui-noteList-backgroundColor
|
||||||
|
|
||||||
.control-search-optionList
|
.control-search-optionList
|
||||||
@@ -92,9 +91,7 @@ $control-height = 34px
|
|||||||
width 32px
|
width 32px
|
||||||
height $control-height - 2
|
height $control-height - 2
|
||||||
navButtonColor()
|
navButtonColor()
|
||||||
border $ui-border
|
font-size 16px
|
||||||
border-radius 32px
|
|
||||||
font-size 14px
|
|
||||||
line-height 28px
|
line-height 28px
|
||||||
padding 0
|
padding 0
|
||||||
&:active
|
&:active
|
||||||
@@ -132,6 +129,7 @@ body[data-theme="dark"]
|
|||||||
background-color $ui-dark-noteList-backgroundColor
|
background-color $ui-dark-noteList-backgroundColor
|
||||||
|
|
||||||
.control-search-input
|
.control-search-input
|
||||||
|
background-color $ui-dark-noteList-backgroundColor
|
||||||
input
|
input
|
||||||
background-color $ui-dark-noteList-backgroundColor
|
background-color $ui-dark-noteList-backgroundColor
|
||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import ee from 'browser/main/lib/eventEmitter'
|
|||||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
import dataApi from 'browser/main/lib/dataApi'
|
import dataApi from 'browser/main/lib/dataApi'
|
||||||
|
|
||||||
|
const { remote } = require('electron')
|
||||||
|
const { dialog } = remote
|
||||||
|
|
||||||
const OSX = window.process.platform === 'darwin'
|
const OSX = window.process.platform === 'darwin'
|
||||||
|
|
||||||
class TopBar extends React.Component {
|
class TopBar extends React.Component {
|
||||||
@@ -18,7 +21,7 @@ class TopBar extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
search: '',
|
search: '',
|
||||||
searchOptions: [],
|
searchOptions: [],
|
||||||
searchPopupOpen: false
|
isSearching: false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.newNoteHandler = () => {
|
this.newNoteHandler = () => {
|
||||||
@@ -41,7 +44,17 @@ class TopBar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNewPostButtonClick (e) {
|
handleNewPostButtonClick (e) {
|
||||||
let { config } = this.props
|
let { config, location } = this.props
|
||||||
|
|
||||||
|
if (location.pathname === '/trashed') {
|
||||||
|
dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Cannot create new note',
|
||||||
|
detail: 'You cannot create new note in trash box.',
|
||||||
|
buttons: ['OK']
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch (config.ui.defaultNote) {
|
switch (config.ui.defaultNote) {
|
||||||
case 'MARKDOWN_NOTE':
|
case 'MARKDOWN_NOTE':
|
||||||
@@ -87,79 +100,17 @@ class TopBar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSearchChange (e) {
|
handleSearchChange (e) {
|
||||||
|
let { router } = this.context
|
||||||
|
router.push('/searched')
|
||||||
this.setState({
|
this.setState({
|
||||||
search: this.refs.searchInput.value
|
search: this.refs.searchInput.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getOptions () {
|
|
||||||
let { data } = this.props
|
|
||||||
let { search } = this.state
|
|
||||||
let notes = data.noteMap.map((note) => note)
|
|
||||||
if (search.trim().length === 0) return []
|
|
||||||
let searchBlocks = search.split(' ')
|
|
||||||
searchBlocks.forEach((block) => {
|
|
||||||
if (block.match(/^!#.+/)) {
|
|
||||||
let tag = block.match(/^!#(.+)/)[1]
|
|
||||||
let regExp = new RegExp(_.escapeRegExp(tag), 'i')
|
|
||||||
notes = notes
|
|
||||||
.filter((note) => {
|
|
||||||
if (!_.isArray(note.tags)) return false
|
|
||||||
return note.tags.some((_tag) => {
|
|
||||||
return _tag.match(regExp)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} else if (block.match(/^!.+/)) {
|
|
||||||
let block = block.match(/^!(.+)/)[1]
|
|
||||||
let regExp = new RegExp(_.escapeRegExp(block), 'i')
|
|
||||||
notes = notes.filter((note) => {
|
|
||||||
if (!_.isArray(note.tags) || !note.tags.some((_tag) => {
|
|
||||||
return _tag.match(regExp)
|
|
||||||
})) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (note.type === 'SNIPPET_NOTE') {
|
|
||||||
return !note.description.match(regExp)
|
|
||||||
} else if (note.type === 'MARKDOWN_NOTE') {
|
|
||||||
return !note.content.match(regExp)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
} else if (block.match(/^#.+/)) {
|
|
||||||
let tag = block.match(/#(.+)/)[1]
|
|
||||||
let regExp = new RegExp(_.escapeRegExp(tag), 'i')
|
|
||||||
notes = notes
|
|
||||||
.filter((note) => {
|
|
||||||
if (!_.isArray(note.tags)) return false
|
|
||||||
return note.tags.some((_tag) => {
|
|
||||||
return _tag.match(regExp)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
let regExp = new RegExp(_.escapeRegExp(block), 'i')
|
|
||||||
notes = notes.filter((note) => {
|
|
||||||
if (_.isArray(note.tags) && note.tags.some((_tag) => {
|
|
||||||
return _tag.match(regExp)
|
|
||||||
})) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (note.type === 'SNIPPET_NOTE') {
|
|
||||||
return note.description.match(regExp)
|
|
||||||
} else if (note.type === 'MARKDOWN_NOTE') {
|
|
||||||
return note.content.match(regExp)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return notes
|
|
||||||
}
|
|
||||||
|
|
||||||
handleOptionClick (uniqueKey) {
|
handleOptionClick (uniqueKey) {
|
||||||
return (e) => {
|
return (e) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
searchPopupOpen: false
|
isSearching: false
|
||||||
}, () => {
|
}, () => {
|
||||||
let { location } = this.props
|
let { location } = this.props
|
||||||
hashHistory.push({
|
hashHistory.push({
|
||||||
@@ -174,7 +125,7 @@ class TopBar extends React.Component {
|
|||||||
|
|
||||||
handleSearchFocus (e) {
|
handleSearchFocus (e) {
|
||||||
this.setState({
|
this.setState({
|
||||||
searchPopupOpen: true
|
isSearching: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
handleSearchBlur (e) {
|
handleSearchBlur (e) {
|
||||||
@@ -191,7 +142,7 @@ class TopBar extends React.Component {
|
|||||||
}
|
}
|
||||||
if (!isStillFocused) {
|
if (!isStillFocused) {
|
||||||
this.setState({
|
this.setState({
|
||||||
searchPopupOpen: false
|
isSearching: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +202,7 @@ class TopBar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOnSearchFocus () {
|
handleOnSearchFocus () {
|
||||||
if (this.state.searchPopupOpen) {
|
if (this.state.isSearching) {
|
||||||
this.refs.search.childNodes[0].blur()
|
this.refs.search.childNodes[0].blur()
|
||||||
} else {
|
} else {
|
||||||
this.refs.search.childNodes[0].focus()
|
this.refs.search.childNodes[0].focus()
|
||||||
@@ -260,27 +211,6 @@ class TopBar extends React.Component {
|
|||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { config, style, data } = this.props
|
let { config, style, data } = this.props
|
||||||
let searchOptionList = this.getOptions()
|
|
||||||
.map((note) => {
|
|
||||||
let storage = data.storageMap.get(note.storage)
|
|
||||||
let folder = _.find(storage.folders, {key: note.folder})
|
|
||||||
return <div styleName='control-search-optionList-item'
|
|
||||||
key={note.storage + '-' + note.key}
|
|
||||||
onClick={(e) => this.handleOptionClick(note.storage + '-' + note.key)(e)}
|
|
||||||
>
|
|
||||||
<div styleName='control-search-optionList-item-folder'
|
|
||||||
style={{borderColor: folder.color}}>
|
|
||||||
{folder.name}
|
|
||||||
<span styleName='control-search-optionList-item-folder-surfix'>in {storage.name}</span>
|
|
||||||
</div>
|
|
||||||
{note.type === 'SNIPPET_NOTE'
|
|
||||||
? <i styleName='control-search-optionList-item-type' className='fa fa-code' />
|
|
||||||
: <i styleName='control-search-optionList-item-type' className='fa fa-file-text-o' />
|
|
||||||
}
|
|
||||||
{note.title}
|
|
||||||
</div>
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='TopBar'
|
<div className='TopBar'
|
||||||
styleName={config.isSideNavFolded ? 'root--expanded' : 'root'}
|
styleName={config.isSideNavFolded ? 'root--expanded' : 'root'}
|
||||||
@@ -288,7 +218,6 @@ class TopBar extends React.Component {
|
|||||||
>
|
>
|
||||||
<div styleName='control'>
|
<div styleName='control'>
|
||||||
<div styleName='control-search'>
|
<div styleName='control-search'>
|
||||||
<i styleName='control-search-icon' className='fa fa-search fa-fw' />
|
|
||||||
<div styleName='control-search-input'
|
<div styleName='control-search-input'
|
||||||
onFocus={(e) => this.handleSearchFocus(e)}
|
onFocus={(e) => this.handleSearchFocus(e)}
|
||||||
onBlur={(e) => this.handleSearchBlur(e)}
|
onBlur={(e) => this.handleSearchBlur(e)}
|
||||||
@@ -301,15 +230,8 @@ class TopBar extends React.Component {
|
|||||||
onChange={(e) => this.handleSearchChange(e)}
|
onChange={(e) => this.handleSearchChange(e)}
|
||||||
placeholder='Search'
|
placeholder='Search'
|
||||||
type='text'
|
type='text'
|
||||||
|
className='searchInput'
|
||||||
/>
|
/>
|
||||||
{this.state.searchPopupOpen &&
|
|
||||||
<div styleName='control-search-optionList'>
|
|
||||||
{searchOptionList.length > 0
|
|
||||||
? searchOptionList
|
|
||||||
: <div styleName='control-search-optionList-empty'>Empty List</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
{this.state.search > 0 &&
|
{this.state.search > 0 &&
|
||||||
<button styleName='left-search-clearButton'
|
<button styleName='left-search-clearButton'
|
||||||
@@ -322,7 +244,7 @@ class TopBar extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
<button styleName='control-newPostButton'
|
<button styleName='control-newPostButton'
|
||||||
onClick={(e) => this.handleNewPostButtonClick(e)}>
|
onClick={(e) => this.handleNewPostButtonClick(e)}>
|
||||||
<i className='fa fa-plus' />
|
<i className='fa fa-pencil-square-o' />
|
||||||
<span styleName='control-newPostButton-tooltip'>
|
<span styleName='control-newPostButton-tooltip'>
|
||||||
Make a Note {OSX ? '⌘' : '^'} + n
|
Make a Note {OSX ? '⌘' : '^'} + n
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ document.addEventListener('dragover', function (e) {
|
|||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.addEventListener('click', function (e) {
|
||||||
|
const className = e.target.className
|
||||||
|
if (!className && typeof (className) !== 'string') return
|
||||||
|
const isInfoButton = className.includes('infoButton')
|
||||||
|
const isInfoPanel = e.target.offsetParent.className.includes('infoPanel')
|
||||||
|
if (isInfoButton || isInfoPanel) return
|
||||||
|
const infoPanel = document.querySelector('.infoPanel')
|
||||||
|
if (infoPanel) infoPanel.style.display = 'none'
|
||||||
|
})
|
||||||
|
|
||||||
let el = document.getElementById('content')
|
let el = document.getElementById('content')
|
||||||
const history = syncHistoryWithStore(hashHistory, store)
|
const history = syncHistoryWithStore(hashHistory, store)
|
||||||
|
|
||||||
@@ -50,6 +60,8 @@ ReactDOM.render((
|
|||||||
<IndexRedirect to='/home' />
|
<IndexRedirect to='/home' />
|
||||||
<Route path='home' />
|
<Route path='home' />
|
||||||
<Route path='starred' />
|
<Route path='starred' />
|
||||||
|
<Route path='searched' />
|
||||||
|
<Route path='trashed' />
|
||||||
<Route path='storages'>
|
<Route path='storages'>
|
||||||
<IndexRedirect to='/home' />
|
<IndexRedirect to='/home' />
|
||||||
<Route path=':storageKey'>
|
<Route path=':storageKey'>
|
||||||
|
|||||||
41
browser/main/lib/AwsMobileAnalyticsConfig.js
Normal file
41
browser/main/lib/AwsMobileAnalyticsConfig.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
const AWS = require('aws-sdk')
|
||||||
|
const AMA = require('aws-sdk-mobile-analytics')
|
||||||
|
const ConfigManager = require('browser/main/lib/ConfigManager')
|
||||||
|
|
||||||
|
AWS.config.region = 'us-east-1'
|
||||||
|
if (process.env.NODE_ENV === 'production' && ConfigManager.default.get().amaEnabled) {
|
||||||
|
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
|
||||||
|
IdentityPoolId: 'us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||||
|
})
|
||||||
|
const mobileAnalyticsClient = new AMA.Manager({
|
||||||
|
appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
||||||
|
appTitle: 'xxxxxxxxxx'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function initAwsMobileAnalytics () {
|
||||||
|
if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return
|
||||||
|
AWS.config.credentials.get((err) => {
|
||||||
|
if (!err) {
|
||||||
|
console.log('Cognito Identity ID: ' + AWS.config.credentials.identityId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
recordStaticCustomEvent()
|
||||||
|
}
|
||||||
|
|
||||||
|
function recordDynamicCustomEvent (type) {
|
||||||
|
if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return
|
||||||
|
mobileAnalyticsClient.recordEvent(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
function recordStaticCustomEvent () {
|
||||||
|
if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return
|
||||||
|
mobileAnalyticsClient.recordEvent('UI_COLOR_THEME', {
|
||||||
|
uiColorTheme: ConfigManager.default.get().ui.theme
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
initAwsMobileAnalytics,
|
||||||
|
recordDynamicCustomEvent
|
||||||
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import RcParser from 'browser/lib/RcParser'
|
||||||
|
|
||||||
const OSX = global.process.platform === 'darwin'
|
const OSX = global.process.platform === 'darwin'
|
||||||
|
const win = global.process.platform === 'win32'
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { ipcRenderer } = electron
|
const { ipcRenderer } = electron
|
||||||
const consts = require('browser/lib/consts')
|
const consts = require('browser/lib/consts')
|
||||||
|
const path = require('path')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
let isInitialized = false
|
let isInitialized = false
|
||||||
|
|
||||||
@@ -14,6 +18,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
navWidth: 200,
|
navWidth: 200,
|
||||||
sortBy: 'UPDATED_AT', // 'CREATED_AT', 'UPDATED_AT', 'APLHABETICAL'
|
sortBy: 'UPDATED_AT', // 'CREATED_AT', 'UPDATED_AT', 'APLHABETICAL'
|
||||||
listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL'
|
listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL'
|
||||||
|
amaEnabled: true,
|
||||||
hotkey: {
|
hotkey: {
|
||||||
toggleFinder: OSX ? 'Cmd + Alt + S' : 'Super + Alt + S',
|
toggleFinder: OSX ? 'Cmd + Alt + S' : 'Super + Alt + S',
|
||||||
toggleMain: OSX ? 'Cmd + Alt + L' : 'Super + Alt + E'
|
toggleMain: OSX ? 'Cmd + Alt + L' : 'Super + Alt + E'
|
||||||
@@ -24,18 +29,18 @@ export const DEFAULT_CONFIG = {
|
|||||||
defaultNote: 'ALWAYS_ASK' // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
|
defaultNote: 'ALWAYS_ASK' // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
theme: 'default',
|
theme: 'base16-light',
|
||||||
keyMap: 'sublime',
|
keyMap: 'sublime',
|
||||||
fontSize: '14',
|
fontSize: '14',
|
||||||
fontFamily: 'Monaco, Consolas',
|
fontFamily: win ? 'Segoe UI' : 'Monaco, Consolas',
|
||||||
indentType: 'space',
|
indentType: 'space',
|
||||||
indentSize: '2',
|
indentSize: '2',
|
||||||
switchPreview: 'BLUR' // Available value: RIGHTCLICK, BLUR
|
switchPreview: 'BLUR' // Available value: RIGHTCLICK, BLUR
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
fontSize: '14',
|
fontSize: '14',
|
||||||
fontFamily: 'Lato',
|
fontFamily: win ? 'Segoe UI' : 'Lato',
|
||||||
codeBlockTheme: 'elegant',
|
codeBlockTheme: 'dracula',
|
||||||
lineNumber: true
|
lineNumber: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,17 +60,17 @@ function _save (config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get () {
|
function get () {
|
||||||
let config = window.localStorage.getItem('config')
|
const rawStoredConfig = window.localStorage.getItem('config')
|
||||||
|
const storedConfig = Object.assign({}, DEFAULT_CONFIG, JSON.parse(rawStoredConfig))
|
||||||
|
let config = storedConfig
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config = Object.assign({}, DEFAULT_CONFIG, JSON.parse(config))
|
const boostnotercConfig = RcParser.parse()
|
||||||
config.hotkey = Object.assign({}, DEFAULT_CONFIG.hotkey, config.hotkey)
|
config = assignConfigValues(storedConfig, boostnotercConfig)
|
||||||
config.ui = Object.assign({}, DEFAULT_CONFIG.ui, config.ui)
|
|
||||||
config.editor = Object.assign({}, DEFAULT_CONFIG.editor, config.editor)
|
|
||||||
config.preview = Object.assign({}, DEFAULT_CONFIG.preview, config.preview)
|
|
||||||
if (!validate(config)) throw new Error('INVALID CONFIG')
|
if (!validate(config)) throw new Error('INVALID CONFIG')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('Boostnote resets the malformed configuration.')
|
console.warn('Boostnote resets the invalid configuration.')
|
||||||
config = DEFAULT_CONFIG
|
config = DEFAULT_CONFIG
|
||||||
_save(config)
|
_save(config)
|
||||||
}
|
}
|
||||||
@@ -124,6 +129,15 @@ function set (updates) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assignConfigValues (originalConfig, rcConfig) {
|
||||||
|
let config = Object.assign({}, DEFAULT_CONFIG, originalConfig, rcConfig)
|
||||||
|
config.hotkey = Object.assign({}, DEFAULT_CONFIG.hotkey, originalConfig.hotkey, rcConfig.hotkey)
|
||||||
|
config.ui = Object.assign({}, DEFAULT_CONFIG.ui, originalConfig.ui, rcConfig.ui)
|
||||||
|
config.editor = Object.assign({}, DEFAULT_CONFIG.editor, originalConfig.editor, rcConfig.editor)
|
||||||
|
config.preview = Object.assign({}, DEFAULT_CONFIG.preview, originalConfig.preview, rcConfig.preview)
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
get,
|
get,
|
||||||
set,
|
set,
|
||||||
|
|||||||
33
browser/main/lib/dataApi/copyImage.js
Normal file
33
browser/main/lib/dataApi/copyImage.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const _ = require('lodash')
|
||||||
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description To copy an image and return the path.
|
||||||
|
* @param {String} filePath
|
||||||
|
* @param {String} storageKey
|
||||||
|
* @return {String} an image path
|
||||||
|
*/
|
||||||
|
function copyImage (filePath, storageKey) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const targetStorage = findStorage(storageKey)
|
||||||
|
|
||||||
|
const inputImage = fs.createReadStream(filePath)
|
||||||
|
const imageExt = path.extname(filePath)
|
||||||
|
const imageName = Math.random().toString(36).slice(-16)
|
||||||
|
const basename = `${imageName}${imageExt}`
|
||||||
|
const imageDir = path.join(targetStorage.path, 'images')
|
||||||
|
if (!fs.existsSync(imageDir)) fs.mkdirSync(imageDir)
|
||||||
|
const outputImage = fs.createWriteStream(path.join(imageDir, basename))
|
||||||
|
inputImage.pipe(outputImage)
|
||||||
|
resolve(basename)
|
||||||
|
} catch (e) {
|
||||||
|
return reject(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = copyImage
|
||||||
@@ -3,6 +3,7 @@ const keygen = require('browser/lib/keygen')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const resolveStorageData = require('./resolveStorageData')
|
const resolveStorageData = require('./resolveStorageData')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} storageKey
|
* @param {String} storageKey
|
||||||
@@ -29,11 +30,7 @@ function createFolder (storageKey, input) {
|
|||||||
if (!_.isString(input.name)) throw new Error('Name must be a string.')
|
if (!_.isString(input.name)) throw new Error('Name must be a string.')
|
||||||
if (!_.isString(input.color)) throw new Error('Color must be a string.')
|
if (!_.isString(input.color)) throw new Error('Color must be a string.')
|
||||||
|
|
||||||
rawStorages = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(rawStorages)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(rawStorages, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ const _ = require('lodash')
|
|||||||
const keygen = require('browser/lib/keygen')
|
const keygen = require('browser/lib/keygen')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function validateInput (input) {
|
function validateInput (input) {
|
||||||
if (!_.isArray(input.tags)) input.tags = []
|
if (!_.isArray(input.tags)) input.tags = []
|
||||||
input.tags = input.tags.filter((tag) => _.isString(tag) && tag.trim().length > 0)
|
input.tags = input.tags.filter((tag) => _.isString(tag) && tag.trim().length > 0)
|
||||||
if (!_.isString(input.title)) input.title = ''
|
if (!_.isString(input.title)) input.title = ''
|
||||||
input.isStarred = !!input.isStarred
|
input.isStarred = !!input.isStarred
|
||||||
|
input.isTrashed = !!input.isTrashed
|
||||||
|
|
||||||
switch (input.type) {
|
switch (input.type) {
|
||||||
case 'MARKDOWN_NOTE':
|
case 'MARKDOWN_NOTE':
|
||||||
@@ -37,11 +39,7 @@ function createNote (storageKey, input) {
|
|||||||
input = Object.assign({}, input)
|
input = Object.assign({}, input)
|
||||||
validateInput(input)
|
validateInput(input)
|
||||||
|
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const resolveStorageData = require('./resolveStorageData')
|
|||||||
const resolveStorageNotes = require('./resolveStorageNotes')
|
const resolveStorageNotes = require('./resolveStorageNotes')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} storageKey
|
* @param {String} storageKey
|
||||||
@@ -21,11 +22,7 @@ function deleteFolder (storageKey, folderKey) {
|
|||||||
let rawStorages
|
let rawStorages
|
||||||
let targetStorage
|
let targetStorage
|
||||||
try {
|
try {
|
||||||
rawStorages = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(rawStorages)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(rawStorages, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,12 @@ const resolveStorageData = require('./resolveStorageData')
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function deleteNote (storageKey, noteKey) {
|
function deleteNote (storageKey, noteKey) {
|
||||||
let targetStorage
|
let targetStorage
|
||||||
try {
|
try {
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function init () {
|
|||||||
.then((notes) => {
|
.then((notes) => {
|
||||||
let unknownCount = 0
|
let unknownCount = 0
|
||||||
notes.forEach((note) => {
|
notes.forEach((note) => {
|
||||||
if (!storage.folders.some((folder) => note.folder === folder.key)) {
|
if (note && !storage.folders.some((folder) => note.folder === folder.key)) {
|
||||||
unknownCount++
|
unknownCount++
|
||||||
storage.folders.push({
|
storage.folders.push({
|
||||||
key: note.folder,
|
key: note.folder,
|
||||||
|
|||||||
@@ -4,17 +4,13 @@ const path = require('path')
|
|||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
const keygen = require('browser/lib/keygen')
|
const keygen = require('browser/lib/keygen')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
|
function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
|
||||||
let oldStorage, newStorage
|
let oldStorage, newStorage
|
||||||
try {
|
try {
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
oldStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Storage doesn\'t exist.')
|
newStorage = findStorage(newStorageKey)
|
||||||
|
|
||||||
oldStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (oldStorage == null) throw new Error('Storage doesn\'t exist.')
|
|
||||||
|
|
||||||
newStorage = _.find(cachedStorageList, {key: newStorageKey})
|
|
||||||
if (newStorage == null) throw new Error('Target storage doesn\'t exist.')
|
if (newStorage == null) throw new Error('Target storage doesn\'t exist.')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const resolveStorageData = require('./resolveStorageData')
|
const resolveStorageData = require('./resolveStorageData')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} key
|
* @param {String} key
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ function resolveStorageNotes (storage) {
|
|||||||
return data
|
return data
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(notePath)
|
console.error(notePath)
|
||||||
throw err
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const resolveStorageData = require('./resolveStorageData')
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function validateInput (input) {
|
function validateInput (input) {
|
||||||
let validatedInput = {}
|
let validatedInput = {}
|
||||||
@@ -21,6 +22,10 @@ function validateInput (input) {
|
|||||||
validatedInput.isStarred = !!input.isStarred
|
validatedInput.isStarred = !!input.isStarred
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (input.isTrashed != null) {
|
||||||
|
validatedInput.isTrashed = !!input.isTrashed
|
||||||
|
}
|
||||||
|
|
||||||
validatedInput.type = input.type
|
validatedInput.type = input.type
|
||||||
switch (input.type) {
|
switch (input.type) {
|
||||||
case 'MARKDOWN_NOTE':
|
case 'MARKDOWN_NOTE':
|
||||||
@@ -64,11 +69,7 @@ function updateNote (storageKey, noteKey, input) {
|
|||||||
if (input == null) throw new Error('No input found.')
|
if (input == null) throw new Error('No input found.')
|
||||||
input = validateInput(input)
|
input = validateInput(input)
|
||||||
|
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
@@ -101,6 +102,7 @@ function updateNote (storageKey, noteKey, input) {
|
|||||||
noteData.createdAt = new Date()
|
noteData.createdAt = new Date()
|
||||||
noteData.updatedAt = new Date()
|
noteData.updatedAt = new Date()
|
||||||
noteData.isStarred = false
|
noteData.isStarred = false
|
||||||
|
noteData.isTrashed = false
|
||||||
noteData.tags = []
|
noteData.tags = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ class ModalBase extends React.Component {
|
|||||||
|
|
||||||
close () {
|
close () {
|
||||||
if (modalBase != null) modalBase.setState({component: null, componentProps: null, isHidden: true})
|
if (modalBase != null) modalBase.setState({component: null, componentProps: null, isHidden: true})
|
||||||
|
// Toggle overflow style on NoteList
|
||||||
|
let list = document.querySelector('.NoteList__list___browser-main-NoteList-')
|
||||||
|
list.style.overflow = 'auto'
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@@ -37,7 +40,9 @@ let modalBase = ReactDOM.render(<ModalBase />, el)
|
|||||||
|
|
||||||
export function openModal (component, props) {
|
export function openModal (component, props) {
|
||||||
if (modalBase == null) { return }
|
if (modalBase == null) { return }
|
||||||
|
// Hide scrollbar by removing overflow when modal opens
|
||||||
|
let list = document.querySelector('.NoteList__list___browser-main-NoteList-')
|
||||||
|
list.style.overflow = 'hidden'
|
||||||
document.body.setAttribute('data-modal', 'open')
|
document.body.setAttribute('data-modal', 'open')
|
||||||
modalBase.setState({component: component, componentProps: props, isHidden: false})
|
modalBase.setState({component: component, componentProps: props, isHidden: false})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import styles from './CreateFolderModal.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 consts from 'browser/lib/consts'
|
import consts from 'browser/lib/consts'
|
||||||
|
import ModalEscButton from 'browser/components/ModalEscButton'
|
||||||
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
|
||||||
class CreateFolderModal extends React.Component {
|
class CreateFolderModal extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@@ -47,6 +49,7 @@ class CreateFolderModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
confirm () {
|
confirm () {
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_FOLDER')
|
||||||
if (this.state.name.trim().length > 0) {
|
if (this.state.name.trim().length > 0) {
|
||||||
let { storage } = this.props
|
let { storage } = this.props
|
||||||
let input = {
|
let input = {
|
||||||
@@ -77,11 +80,7 @@ class CreateFolderModal extends React.Component {
|
|||||||
<div styleName='header'>
|
<div styleName='header'>
|
||||||
<div styleName='title'>Create new folder</div>
|
<div styleName='title'>Create new folder</div>
|
||||||
</div>
|
</div>
|
||||||
<button styleName='close' onClick={(e) => this.handleCloseButtonClick(e)}>
|
<ModalEscButton handleEscButtonClick={(e) => this.handleCloseButtonClick(e)} />
|
||||||
<div styleName='close-mark'>×</div>
|
|
||||||
<div styleName='close-text'>esc</div>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div styleName='control'>
|
<div styleName='control'>
|
||||||
<div styleName='control-folder'>
|
<div styleName='control-folder'>
|
||||||
<div styleName='control-folder-label'>Folder name</div>
|
<div styleName='control-folder-label'>Folder name</div>
|
||||||
|
|||||||
@@ -15,21 +15,6 @@
|
|||||||
background-color $ui-backgroundColor
|
background-color $ui-backgroundColor
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
.close-mark
|
|
||||||
font-size 15px
|
|
||||||
|
|
||||||
.close
|
|
||||||
height 70px
|
|
||||||
position absolute
|
|
||||||
background-color transparent
|
|
||||||
color $ui-inactive-text-color
|
|
||||||
border none
|
|
||||||
top 7px
|
|
||||||
right 30px
|
|
||||||
text-align center
|
|
||||||
width top-bar--height
|
|
||||||
height top-bar--height
|
|
||||||
|
|
||||||
.control-folder-label
|
.control-folder-label
|
||||||
text-align left
|
text-align left
|
||||||
font-size 12px
|
font-size 12px
|
||||||
@@ -85,12 +70,7 @@ body[data-theme="dark"]
|
|||||||
border 1px solid #C9C9C9 // TODO: use variable.
|
border 1px solid #C9C9C9 // TODO: use variable.
|
||||||
color white
|
color white
|
||||||
|
|
||||||
.closeButton
|
.description
|
||||||
border-color $ui-dark-borderColor
|
|
||||||
color $ui-dark-text-color
|
|
||||||
colorDarkDefaultButton()
|
|
||||||
|
|
||||||
.description
|
|
||||||
color $ui-inactive-text-color
|
color $ui-inactive-text-color
|
||||||
|
|
||||||
.control-confirmButton
|
.control-confirmButton
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import dataApi from 'browser/main/lib/dataApi'
|
|||||||
import store from 'browser/main/store'
|
import store from 'browser/main/store'
|
||||||
import { hashHistory } from 'react-router'
|
import { hashHistory } from 'react-router'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import ModalEscButton from 'browser/components/ModalEscButton'
|
||||||
|
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
@@ -102,7 +103,7 @@ class InitModal extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
return dataApi
|
return dataApi
|
||||||
.createFolder(data.storage.key, {
|
.createFolder(data.storage.key, {
|
||||||
color: '#6AA5E9',
|
color: '#1278BD',
|
||||||
name: 'Default'
|
name: 'Default'
|
||||||
})
|
})
|
||||||
.then((_data) => {
|
.then((_data) => {
|
||||||
@@ -121,19 +122,6 @@ class InitModal extends React.Component {
|
|||||||
notes: data.notes
|
notes: data.notes
|
||||||
})
|
})
|
||||||
|
|
||||||
let defaultMarkdownNote = dataApi
|
|
||||||
.createNote(data.storage.key, {
|
|
||||||
type: 'MARKDOWN_NOTE',
|
|
||||||
folder: data.storage.folders[0].key,
|
|
||||||
title: 'Welcome to Boostnote :)',
|
|
||||||
content: '# Welcome to Boostnote :)\nThis is a markdown note.\n\nClick to edit this note.'
|
|
||||||
})
|
|
||||||
.then((note) => {
|
|
||||||
store.dispatch({
|
|
||||||
type: 'UPDATE_NOTE',
|
|
||||||
note: note
|
|
||||||
})
|
|
||||||
})
|
|
||||||
let defaultSnippetNote = dataApi
|
let defaultSnippetNote = dataApi
|
||||||
.createNote(data.storage.key, {
|
.createNote(data.storage.key, {
|
||||||
type: 'SNIPPET_NOTE',
|
type: 'SNIPPET_NOTE',
|
||||||
@@ -144,12 +132,12 @@ class InitModal extends React.Component {
|
|||||||
{
|
{
|
||||||
name: 'example.html',
|
name: 'example.html',
|
||||||
mode: 'html',
|
mode: 'html',
|
||||||
content: '<html>\n<body>\n<h1 id=\'hello\'>Hello World</h1>\n</body>\n</html>'
|
content: '<html>\n<body>\n<h1 id=\'hello\'>Enjoy Boostnote!</h1>\n</body>\n</html>'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'example.js',
|
name: 'example.js',
|
||||||
mode: 'javascript',
|
mode: 'javascript',
|
||||||
content: 'var html = document.getElementById(\'hello\').innerHTML\n\nconsole.log(html)'
|
content: 'var boostnote = document.getElementById(\'enjoy\').innerHTML\n\nconsole.log(boostnote)'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -159,6 +147,19 @@ class InitModal extends React.Component {
|
|||||||
note: note
|
note: note
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
let defaultMarkdownNote = dataApi
|
||||||
|
.createNote(data.storage.key, {
|
||||||
|
type: 'MARKDOWN_NOTE',
|
||||||
|
folder: data.storage.folders[0].key,
|
||||||
|
title: 'Welcome to Boostnote!',
|
||||||
|
content: '# Welcome to Boostnote! \n### _Click to edit this note._\n\n---\n\nBoostnote is an *open source* note-taking app. \nRepository is published on [GitHub](https://github.com/BoostIO/Boostnote), and tweeting everyday on [@Boostnoteapp](https://twitter.com/boostnoteapp)!\n\n## Features \n- [x] No Internet and Registration Required. \n- [ ] Quick search and copy the content of note. `macOS: Cmd + Alt + S / windows: Ctrl + Alt + S` \n- [ ] Markdown & Snippet note. \n- [ ] Available for `vim` and `emacs` mode. \n- [ ] Choose your favorite theme on UI, Editor and Code Block! \n--- \n\n- Copy Codeblock on Markdown Preview.\n```javascript\nvar boostnote = document.getElementById(\'enjoy\').innerHTML\n\nconsole.log(boostnote)\n```'
|
||||||
|
})
|
||||||
|
.then((note) => {
|
||||||
|
store.dispatch({
|
||||||
|
type: 'UPDATE_NOTE',
|
||||||
|
note: note
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
return Promise.resolve(defaultSnippetNote)
|
return Promise.resolve(defaultSnippetNote)
|
||||||
.then(defaultMarkdownNote)
|
.then(defaultMarkdownNote)
|
||||||
@@ -199,6 +200,7 @@ class InitModal extends React.Component {
|
|||||||
<div styleName='header'>
|
<div styleName='header'>
|
||||||
<div styleName='header-title'>Initialize Storage</div>
|
<div styleName='header-title'>Initialize Storage</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ModalEscButton handleEscButtonClick={(e) => this.handleCloseButtonClick(e)} />
|
||||||
<div styleName='body'>
|
<div styleName='body'>
|
||||||
<div styleName='body-welcome'>
|
<div styleName='body-welcome'>
|
||||||
Welcome!
|
Welcome!
|
||||||
|
|||||||
@@ -22,15 +22,6 @@
|
|||||||
border-bottom solid 1px $ui-borderColor
|
border-bottom solid 1px $ui-borderColor
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
.closeButton
|
|
||||||
position absolute
|
|
||||||
top 10px
|
|
||||||
right 10px
|
|
||||||
height 30px
|
|
||||||
padding 0 25px
|
|
||||||
color $ui-text-color
|
|
||||||
colorDefaultButton()
|
|
||||||
|
|
||||||
.body
|
.body
|
||||||
padding 30px
|
padding 30px
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import styles from './NewNoteModal.styl'
|
|||||||
import dataApi from 'browser/main/lib/dataApi'
|
import dataApi from 'browser/main/lib/dataApi'
|
||||||
import { hashHistory } from 'react-router'
|
import { hashHistory } from 'react-router'
|
||||||
import ee from 'browser/main/lib/eventEmitter'
|
import ee from 'browser/main/lib/eventEmitter'
|
||||||
|
import ModalEscButton from 'browser/components/ModalEscButton'
|
||||||
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
|
||||||
class NewNoteModal extends React.Component {
|
class NewNoteModal extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@@ -22,6 +24,8 @@ class NewNoteModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleMarkdownNoteButtonClick (e) {
|
handleMarkdownNoteButtonClick (e) {
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
||||||
let { storage, folder, dispatch, location } = this.props
|
let { storage, folder, dispatch, location } = this.props
|
||||||
dataApi
|
dataApi
|
||||||
.createNote(storage, {
|
.createNote(storage, {
|
||||||
@@ -52,6 +56,8 @@ class NewNoteModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSnippetNoteButtonClick (e) {
|
handleSnippetNoteButtonClick (e) {
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
||||||
let { storage, folder, dispatch, location } = this.props
|
let { storage, folder, dispatch, location } = this.props
|
||||||
|
|
||||||
dataApi
|
dataApi
|
||||||
@@ -102,11 +108,7 @@ class NewNoteModal extends React.Component {
|
|||||||
<div styleName='header'>
|
<div styleName='header'>
|
||||||
<div styleName='title'>Make a Note</div>
|
<div styleName='title'>Make a Note</div>
|
||||||
</div>
|
</div>
|
||||||
<button styleName='closeButton' onClick={(e) => this.handleCloseButtonClick(e)}>
|
<ModalEscButton handleEscButtonClick={(e) => this.handleCloseButtonClick(e)} />
|
||||||
<div styleName='close-mark'>×</div>
|
|
||||||
<div styleName='close-text'>esc</div>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div styleName='control'>
|
<div styleName='control'>
|
||||||
<button styleName='control-button'
|
<button styleName='control-button'
|
||||||
onClick={(e) => this.handleMarkdownNoteButtonClick(e)}
|
onClick={(e) => this.handleMarkdownNoteButtonClick(e)}
|
||||||
@@ -117,7 +119,7 @@ class NewNoteModal extends React.Component {
|
|||||||
className='fa fa-file-text-o'
|
className='fa fa-file-text-o'
|
||||||
/><br />
|
/><br />
|
||||||
<span styleName='control-button-label'>Markdown Note</span><br />
|
<span styleName='control-button-label'>Markdown Note</span><br />
|
||||||
<span styleName='control-button-description'>It is good for any type of documents. Check List, Code block and Latex block are available.</span>
|
<span styleName='control-button-description'>This format is for creating text documents. Checklists, code blocks and Latex blocks are available.</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button styleName='control-button'
|
<button styleName='control-button'
|
||||||
@@ -129,7 +131,7 @@ class NewNoteModal extends React.Component {
|
|||||||
className='fa fa-code'
|
className='fa fa-code'
|
||||||
/><br />
|
/><br />
|
||||||
<span styleName='control-button-label'>Snippet Note</span><br />
|
<span styleName='control-button-label'>Snippet Note</span><br />
|
||||||
<span styleName='control-button-description'>This format is specialized on managing snippets like Gist. Multiple snippets can be grouped as a note.
|
<span styleName='control-button-description'>This format is for creating code snippets. Multiple snippets can be grouped into a single note.
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -13,25 +13,10 @@
|
|||||||
border-bottom solid 1px $ui-borderColor
|
border-bottom solid 1px $ui-borderColor
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
.closeButton
|
|
||||||
height 50px
|
|
||||||
position absolute
|
|
||||||
background-color transparent
|
|
||||||
color $ui-inactive-text-color
|
|
||||||
border none
|
|
||||||
top 1px
|
|
||||||
right 10px
|
|
||||||
text-align center
|
|
||||||
width top-bar--height
|
|
||||||
height top-bar--height
|
|
||||||
|
|
||||||
.control
|
.control
|
||||||
padding 25px 15px 15px
|
padding 25px 15px 15px
|
||||||
text-align center
|
text-align center
|
||||||
|
|
||||||
.close-mark
|
|
||||||
font-size 15px
|
|
||||||
|
|
||||||
.control-button
|
.control-button
|
||||||
width 220px
|
width 220px
|
||||||
height 220px
|
height 220px
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ class HotkeyTab extends React.Component {
|
|||||||
<li><code>VolumeUp</code>, <code>VolumeDown</code> and <code>VolumeMute</code></li>
|
<li><code>VolumeUp</code>, <code>VolumeDown</code> and <code>VolumeMute</code></li>
|
||||||
<li><code>MediaNextTrack</code>, <code>MediaPreviousTrack</code>, <code>MediaStop</code> and <code>MediaPlayPause</code></li>
|
<li><code>MediaNextTrack</code>, <code>MediaPreviousTrack</code>, <code>MediaStop</code> and <code>MediaPlayPause</code></li>
|
||||||
<li><code>Control</code> (or <code>Ctrl</code> for short)</li>
|
<li><code>Control</code> (or <code>Ctrl</code> for short)</li>
|
||||||
|
<li><code>Shift</code></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './InfoTab.styl'
|
import styles from './InfoTab.styl'
|
||||||
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
|
import store from 'browser/main/store'
|
||||||
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { shell, remote } = electron
|
const { shell, remote } = electron
|
||||||
@@ -11,6 +14,7 @@ class InfoTab extends React.Component {
|
|||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
config: this.props.config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +23,29 @@ class InfoTab extends React.Component {
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleConfigChange (e) {
|
||||||
|
const newConfig = { amaEnabled: this.refs.amaEnabled.checked }
|
||||||
|
|
||||||
|
this.setState({ config: newConfig })
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSaveButtonClick (e) {
|
||||||
|
let newConfig = {
|
||||||
|
amaEnabled: this.state.config.amaEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newConfig.amaEnabled) {
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('DISABLE_AMA')
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigManager.set(newConfig)
|
||||||
|
|
||||||
|
store.dispatch({
|
||||||
|
type: 'SET_CONFIG',
|
||||||
|
config: newConfig
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<div styleName='root'>
|
<div styleName='root'>
|
||||||
@@ -47,9 +74,9 @@ class InfoTab extends React.Component {
|
|||||||
>Boostnote Shop</a> : Products are shipped to all over the world 🌏
|
>Boostnote Shop</a> : Products are shipped to all over the world 🌏
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href='https://www.patreon.com/boostnote'
|
<a href='https://salt.bountysource.com/teams/boostnote'
|
||||||
onClick={(e) => this.handleLinkClick(e)}
|
onClick={(e) => this.handleLinkClick(e)}
|
||||||
>Donate via Patreon</a> : Thank you for your support 🎉
|
>Donate via Bountysource</a> : Thank you for your support 🎉
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href='https://github.com/BoostIO/Boostnote/issues'
|
<a href='https://github.com/BoostIO/Boostnote/issues'
|
||||||
@@ -68,6 +95,18 @@ class InfoTab extends React.Component {
|
|||||||
License: GPL v3
|
License: GPL v3
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<hr />
|
||||||
|
<div styleName='policy'>Data collection policy</div>
|
||||||
|
<p>We collect only the number of DAU for Boostnote and DO NOT collect any detail information</p>
|
||||||
|
<p>such as your note content. You can see how it works on <a href='https://github.com/BoostIO/Boostnote' onClick={(e) => this.handleLinkClick(e)}>GitHub</a>.</p>
|
||||||
|
<p>These data are only used for Boostnote improvements.</p>
|
||||||
|
<input onChange={(e) => this.handleConfigChange(e)}
|
||||||
|
checked={this.state.config.amaEnabled}
|
||||||
|
ref='amaEnabled'
|
||||||
|
type='checkbox'
|
||||||
|
/>
|
||||||
|
Enable to send analytics to our servers<br />
|
||||||
|
<button styleName='policy-submit' onClick={(e) => this.handleSaveButtonClick(e)}>Save</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,13 @@
|
|||||||
color #4E8EC6
|
color #4E8EC6
|
||||||
text-decoration none
|
text-decoration none
|
||||||
|
|
||||||
|
.policy
|
||||||
|
font-size 20px
|
||||||
|
margin-bottom 10px
|
||||||
|
|
||||||
|
.policy-submit
|
||||||
|
margin-top 10px
|
||||||
|
|
||||||
body[data-theme="dark"]
|
body[data-theme="dark"]
|
||||||
.root
|
.root
|
||||||
color alpha($tab--dark-text-color, 80%)
|
color alpha($tab--dark-text-color, 80%)
|
||||||
@@ -20,17 +20,6 @@ top-bar--height = 50px
|
|||||||
font-size 18px
|
font-size 18px
|
||||||
line-height top-bar--height
|
line-height top-bar--height
|
||||||
|
|
||||||
.top-bar-close
|
|
||||||
position absolute
|
|
||||||
background-color transparent
|
|
||||||
color $ui-inactive-text-color
|
|
||||||
border none
|
|
||||||
top 0
|
|
||||||
right 0
|
|
||||||
text-align center
|
|
||||||
width top-bar--height
|
|
||||||
height top-bar--height
|
|
||||||
|
|
||||||
.nav
|
.nav
|
||||||
absolute top left right
|
absolute top left right
|
||||||
top top-bar--height
|
top top-bar--height
|
||||||
|
|||||||
@@ -298,8 +298,8 @@ class StorageItem extends React.Component {
|
|||||||
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Unlink Storage',
|
message: 'Unlink Storage',
|
||||||
detail: 'This work just detatches a storage from Boostnote. (Any data won\'t be deleted.)',
|
detail: 'Unlinking removes this linked storage from Boostnote. No data is removed, please manually delete the folder from your hard drive if needed.',
|
||||||
buttons: ['Confirm', 'Cancel']
|
buttons: ['Unlink', 'Cancel']
|
||||||
})
|
})
|
||||||
|
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class UiTab extends React.Component {
|
|||||||
|
|
||||||
<div styleName='group-section'>
|
<div styleName='group-section'>
|
||||||
<div styleName='group-section-label'>
|
<div styleName='group-section-label'>
|
||||||
Switching Preview
|
Switch to Preview
|
||||||
</div>
|
</div>
|
||||||
<div styleName='group-section-control'>
|
<div styleName='group-section-control'>
|
||||||
<select value={config.editor.switchPreview}
|
<select value={config.editor.switchPreview}
|
||||||
@@ -200,7 +200,7 @@ class UiTab extends React.Component {
|
|||||||
onChange={(e) => this.handleUIChange(e)}
|
onChange={(e) => this.handleUIChange(e)}
|
||||||
>
|
>
|
||||||
<option value='BLUR'>When Editor Blurred</option>
|
<option value='BLUR'>When Editor Blurred</option>
|
||||||
<option value='RIGHTCLICK'>When Right Clicking</option>
|
<option value='RIGHTCLICK'>On Right Click</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -216,8 +216,9 @@ class UiTab extends React.Component {
|
|||||||
>
|
>
|
||||||
<option value='sublime'>default</option>
|
<option value='sublime'>default</option>
|
||||||
<option value='vim'>vim</option>
|
<option value='vim'>vim</option>
|
||||||
|
<option value='emacs'>emacs</option>
|
||||||
</select>
|
</select>
|
||||||
<span styleName='note-for-keymap'>Please reload boostnote after you change the keymap</span>
|
<span styleName='note-for-keymap'>Please restart boostnote after you change the keymap</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -270,7 +271,7 @@ class UiTab extends React.Component {
|
|||||||
ref='previewLineNumber'
|
ref='previewLineNumber'
|
||||||
type='checkbox'
|
type='checkbox'
|
||||||
/>
|
/>
|
||||||
Code block line numbering
|
Show line numbers for preview code blocks
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import HotkeyTab from './HotkeyTab'
|
|||||||
import UiTab from './UiTab'
|
import UiTab from './UiTab'
|
||||||
import InfoTab from './InfoTab'
|
import InfoTab from './InfoTab'
|
||||||
import StoragesTab from './StoragesTab'
|
import StoragesTab from './StoragesTab'
|
||||||
|
import ModalEscButton from 'browser/components/ModalEscButton'
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './PreferencesModal.styl'
|
import styles from './PreferencesModal.styl'
|
||||||
|
|
||||||
@@ -43,7 +44,12 @@ class Preferences extends React.Component {
|
|||||||
|
|
||||||
switch (this.state.currentTab) {
|
switch (this.state.currentTab) {
|
||||||
case 'INFO':
|
case 'INFO':
|
||||||
return <InfoTab />
|
return (
|
||||||
|
<InfoTab
|
||||||
|
dispatch={dispatch}
|
||||||
|
config={config}
|
||||||
|
/>
|
||||||
|
)
|
||||||
case 'HOTKEY':
|
case 'HOTKEY':
|
||||||
return (
|
return (
|
||||||
<HotkeyTab
|
<HotkeyTab
|
||||||
@@ -115,12 +121,9 @@ class Preferences extends React.Component {
|
|||||||
onKeyDown={(e) => this.handleKeyDown(e)}
|
onKeyDown={(e) => this.handleKeyDown(e)}
|
||||||
>
|
>
|
||||||
<div styleName='top-bar'>
|
<div styleName='top-bar'>
|
||||||
<p>Your menu for Boostnote</p>
|
<p>Your preferences for Boostnote</p>
|
||||||
</div>
|
</div>
|
||||||
<button styleName='top-bar-close' onClick={(e) => this.handleEscButtonClick(e)}>
|
<ModalEscButton handleEscButtonClick={(e) => this.handleEscButtonClick(e)} />
|
||||||
<div styleName='top-bar-close-mark'>×</div>
|
|
||||||
<div styleName='top-bar-close-text'>esc</div>
|
|
||||||
</button>
|
|
||||||
<div styleName='nav'>
|
<div styleName='nav'>
|
||||||
{navButtons}
|
{navButtons}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import CSSModules from 'browser/lib/CSSModules'
|
|||||||
import styles from './RenameFolderModal.styl'
|
import styles from './RenameFolderModal.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'
|
||||||
|
|
||||||
class RenameFolderModal extends React.Component {
|
class RenameFolderModal extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@@ -72,9 +73,7 @@ class RenameFolderModal extends React.Component {
|
|||||||
<div styleName='header'>
|
<div styleName='header'>
|
||||||
<div styleName='title'>Rename Folder</div>
|
<div styleName='title'>Rename Folder</div>
|
||||||
</div>
|
</div>
|
||||||
<button styleName='closeButton'
|
<ModalEscButton handleEscButtonClick={(e) => this.handleCloseButtonClick(e)} />
|
||||||
onClick={(e) => this.handleCloseButtonClick(e)}
|
|
||||||
>Close</button>
|
|
||||||
|
|
||||||
<div styleName='control'>
|
<div styleName='control'>
|
||||||
<input styleName='control-input'
|
<input styleName='control-input'
|
||||||
|
|||||||
@@ -13,17 +13,6 @@
|
|||||||
border-bottom solid 1px $ui-borderColor
|
border-bottom solid 1px $ui-borderColor
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
|
||||||
.closeButton
|
|
||||||
position absolute
|
|
||||||
top 10px
|
|
||||||
right 10px
|
|
||||||
height 30px
|
|
||||||
width 0 25px
|
|
||||||
border $ui-border
|
|
||||||
border-radius 2px
|
|
||||||
color $ui-text-color
|
|
||||||
colorDefaultButton()
|
|
||||||
|
|
||||||
.control
|
.control
|
||||||
padding 25px 15px 15px
|
padding 25px 15px 15px
|
||||||
text-align center
|
text-align center
|
||||||
@@ -65,12 +54,7 @@ body[data-theme="dark"]
|
|||||||
border-color $ui-dark-borderColor
|
border-color $ui-dark-borderColor
|
||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
|
|
||||||
.closeButton
|
.description
|
||||||
border-color $ui-dark-borderColor
|
|
||||||
color $ui-dark-text-color
|
|
||||||
colorDarkDefaultButton()
|
|
||||||
|
|
||||||
.description
|
|
||||||
color $ui-inactive-text-color
|
color $ui-inactive-text-color
|
||||||
|
|
||||||
.control-input
|
.control-input
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ function defaultDataMap () {
|
|||||||
starredSet: new Set(),
|
starredSet: new Set(),
|
||||||
storageNoteMap: new Map(),
|
storageNoteMap: new Map(),
|
||||||
folderNoteMap: new Map(),
|
folderNoteMap: new Map(),
|
||||||
tagNoteMap: new Map()
|
tagNoteMap: new Map(),
|
||||||
|
trashedSet: new Set()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +25,8 @@ function data (state = defaultDataMap(), action) {
|
|||||||
state.storageMap.set(storage.key, storage)
|
state.storageMap.set(storage.key, storage)
|
||||||
})
|
})
|
||||||
|
|
||||||
action.notes.forEach((note) => {
|
action.notes.some((note) => {
|
||||||
|
if (note === undefined) return true
|
||||||
let uniqueKey = note.storage + '-' + note.key
|
let uniqueKey = note.storage + '-' + note.key
|
||||||
let folderKey = note.storage + '-' + note.folder
|
let folderKey = note.storage + '-' + note.folder
|
||||||
state.noteMap.set(uniqueKey, note)
|
state.noteMap.set(uniqueKey, note)
|
||||||
@@ -33,6 +35,10 @@ function data (state = defaultDataMap(), action) {
|
|||||||
state.starredSet.add(uniqueKey)
|
state.starredSet.add(uniqueKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (note.isTrashed) {
|
||||||
|
state.trashedSet.add(uniqueKey)
|
||||||
|
}
|
||||||
|
|
||||||
let storageNoteList = state.storageNoteMap.get(note.storage)
|
let storageNoteList = state.storageNoteMap.get(note.storage)
|
||||||
if (storageNoteList == null) {
|
if (storageNoteList == null) {
|
||||||
storageNoteList = new Set(storageNoteList)
|
storageNoteList = new Set(storageNoteList)
|
||||||
@@ -77,6 +83,15 @@ function data (state = defaultDataMap(), action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldNote == null || oldNote.isTrashed !== note.isTrashed) {
|
||||||
|
state.trashedSet = new Set(state.trashedSet)
|
||||||
|
if (note.isTrashed) {
|
||||||
|
state.trashedSet.add(uniqueKey)
|
||||||
|
} else {
|
||||||
|
state.trashedSet.delete(uniqueKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update storageNoteMap if oldNote doesn't exist
|
// Update storageNoteMap if oldNote doesn't exist
|
||||||
if (oldNote == null) {
|
if (oldNote == null) {
|
||||||
state.storageNoteMap = new Map(state.storageNoteMap)
|
state.storageNoteMap = new Map(state.storageNoteMap)
|
||||||
@@ -162,6 +177,11 @@ function data (state = defaultDataMap(), action) {
|
|||||||
state.starredSet.delete(originKey)
|
state.starredSet.delete(originKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (originNote.isTrashed) {
|
||||||
|
state.trashedSet = new Set(state.trashedSet)
|
||||||
|
state.trashedSet.delete(originKey)
|
||||||
|
}
|
||||||
|
|
||||||
// From storageNoteMap
|
// From storageNoteMap
|
||||||
state.storageNoteMap = new Map(state.storageNoteMap)
|
state.storageNoteMap = new Map(state.storageNoteMap)
|
||||||
let noteSet = state.storageNoteMap.get(originNote.storage)
|
let noteSet = state.storageNoteMap.get(originNote.storage)
|
||||||
@@ -198,6 +218,15 @@ function data (state = defaultDataMap(), action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldNote == null || oldNote.isTrashed !== note.isTrashed) {
|
||||||
|
state.trashedSet = new Set(state.trashedSet)
|
||||||
|
if (note.isTrashed) {
|
||||||
|
state.trashedSet.add(uniqueKey)
|
||||||
|
} else {
|
||||||
|
state.trashedSet.delete(uniqueKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update storageNoteMap if oldNote doesn't exist
|
// Update storageNoteMap if oldNote doesn't exist
|
||||||
if (oldNote == null) {
|
if (oldNote == null) {
|
||||||
state.storageNoteMap = new Map(state.storageNoteMap)
|
state.storageNoteMap = new Map(state.storageNoteMap)
|
||||||
@@ -282,6 +311,11 @@ function data (state = defaultDataMap(), action) {
|
|||||||
state.starredSet.delete(uniqueKey)
|
state.starredSet.delete(uniqueKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (targetNote.isTrashed) {
|
||||||
|
state.trashedSet = new Set(state.trashedSet)
|
||||||
|
state.trashedSet.delete(uniqueKey)
|
||||||
|
}
|
||||||
|
|
||||||
// From folderNoteMap
|
// From folderNoteMap
|
||||||
let folderKey = targetNote.storage + '-' + targetNote.folder
|
let folderKey = targetNote.storage + '-' + targetNote.folder
|
||||||
state.folderNoteMap = new Map(state.folderNoteMap)
|
state.folderNoteMap = new Map(state.folderNoteMap)
|
||||||
@@ -347,6 +381,11 @@ function data (state = defaultDataMap(), action) {
|
|||||||
state.starredSet.delete(noteKey)
|
state.starredSet.delete(noteKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (note.isTrashed) {
|
||||||
|
state.trashedSet = new Set(state.trashedSet)
|
||||||
|
state.trashedSet.delete(noteKey)
|
||||||
|
}
|
||||||
|
|
||||||
// Delete key from tag map
|
// Delete key from tag map
|
||||||
state.tagNoteMap = new Map(state.tagNoteMap)
|
state.tagNoteMap = new Map(state.tagNoteMap)
|
||||||
note.tags.forEach((tag) => {
|
note.tags.forEach((tag) => {
|
||||||
|
|||||||
@@ -160,8 +160,7 @@ topBarButtonLight()
|
|||||||
height 34px
|
height 34px
|
||||||
border-radius 17px
|
border-radius 17px
|
||||||
font-size 14px
|
font-size 14px
|
||||||
margin 13px 7px
|
margin 15px 7px
|
||||||
padding-top 7px
|
|
||||||
border none
|
border none
|
||||||
color $ui-button-color
|
color $ui-button-color
|
||||||
fill $ui-button-color
|
fill $ui-button-color
|
||||||
@@ -169,20 +168,20 @@ topBarButtonLight()
|
|||||||
&:active
|
&:active
|
||||||
border-color $ui-button--active-backgroundColor
|
border-color $ui-button--active-backgroundColor
|
||||||
&:hover
|
&:hover
|
||||||
background-color $ui-button--hover-backgroundColor
|
background-color alpha($ui-button--hover-backgroundColor, 60%)
|
||||||
.control-lockButton-tooltip
|
.control-lockButton-tooltip
|
||||||
opacity 1
|
opacity 1
|
||||||
|
|
||||||
// Dark theme
|
// Dark theme
|
||||||
$ui-dark-active-color = #3A404C
|
$ui-dark-active-color = #3A404C
|
||||||
$ui-dark-borderColor = lighten(#21252B, 20%)
|
$ui-dark-borderColor = lighten(#21252B, 20%)
|
||||||
$ui-dark-backgroundColor = #1D1D1D
|
$ui-dark-backgroundColor = #1E2124
|
||||||
$ui-dark-noteList-backgroundColor = #181818
|
$ui-dark-noteList-backgroundColor = #282C30
|
||||||
$ui-dark-noteDetail-backgroundColor = #0D0D0D
|
$ui-dark-noteDetail-backgroundColor = #2D3033
|
||||||
$ui-dark-tag-backgroundColor = #3A404C
|
$ui-dark-tag-backgroundColor = #3A404C
|
||||||
$dark-background-color = lighten($ui-dark-backgroundColor, 10%)
|
$dark-background-color = lighten($ui-dark-backgroundColor, 10%)
|
||||||
$ui-dark-text-color = #DDDDDD
|
$ui-dark-text-color = #DDDDDD
|
||||||
$ui-dark-button--active-color = white
|
$ui-dark-button--active-color = #f4f4f4
|
||||||
$ui-dark-button--active-backgroundColor = #3A404C
|
$ui-dark-button--active-backgroundColor = #3A404C
|
||||||
$ui-dark-button--hover-backgroundColor = lighten($ui-dark-backgroundColor, 10%)
|
$ui-dark-button--hover-backgroundColor = lighten($ui-dark-backgroundColor, 10%)
|
||||||
$ui-dark-button--focus-borderColor = lighten(#369DCD, 25%)
|
$ui-dark-button--focus-borderColor = lighten(#369DCD, 25%)
|
||||||
@@ -232,10 +231,12 @@ topBarButtonDark()
|
|||||||
color $ui-dark-topbar-button-color
|
color $ui-dark-topbar-button-color
|
||||||
&:hover
|
&:hover
|
||||||
background-color $dark-default-button-background--hover
|
background-color $dark-default-button-background--hover
|
||||||
|
color $ui-dark-tooltip-text-color
|
||||||
&:active
|
&:active
|
||||||
border-color $ui-dark-button--focus-borderColor
|
border-color $ui-dark-button--focus-borderColor
|
||||||
&:active:hover
|
&:active:hover
|
||||||
background-color $ui-dark-button--active-backgroundColor
|
background-color $ui-dark-button--active-backgroundColor
|
||||||
|
color $ui-dark-tooltip-text-color
|
||||||
&:focus
|
&:focus
|
||||||
border-color $ui-button--focus-borderColor
|
border-color $ui-button--focus-borderColor
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,69 @@
|
|||||||
# Contributing to Boostnote
|
# Contributing to Boostnote (English)
|
||||||
|
|
||||||
## When you open an issue of a bug report
|
### When you open an issue of a bug report
|
||||||
There are no issue template. But there is a request.
|
There are no issue template. But there is a request.
|
||||||
|
|
||||||
**Please paste screenshots of Boostnote with developer tool open**
|
**Please paste screenshots of Boostnote with developer tool open**
|
||||||
|
|
||||||
Thank you for your help in advance.
|
Thank you for your help in advance.
|
||||||
|
|
||||||
## About copyright of Pull Request
|
### About copyright of Pull Request
|
||||||
|
|
||||||
If you make a pull request, It means you agree to transfer the copyright of the code changes to MAISIN&CO.
|
If you make a pull request, It means you agree to transfer the copyright of the code changes to Maisin&Co.
|
||||||
|
|
||||||
It doesn't mean Boostnote will become a paid app. If we want to earn some money, We will try other way, which is some kind of cloud storage, Mobile app integration or some SPECIAL features.
|
It doesn't mean Boostnote will become a paid app. If we want to earn some money, We will try other way, which is some kind of cloud storage, Mobile app integration or some SPECIAL features.
|
||||||
Because GPL v3 is too strict to be compatible with any other License, We thought this is needed to replace the license with much freer one(like BSD, MIT) somewhen.
|
Because GPL v3 is too strict to be compatible with any other License, We thought this is needed to replace the license with much freer one(like BSD, MIT) somewhen.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Contributing to Boostnote(Japanese)
|
# Contributing to Boostnote (Russian)
|
||||||
|
|
||||||
## バグレポートに関してのissueを立てる時
|
### Когда у вас появляется сообщение об ошибке
|
||||||
|
У нас нет шаблона, по которому вы должны описать ошибку. Просто расскажите, как вы получили ее
|
||||||
|
|
||||||
|
**Вставьте скриншот Boostnote с открытым инструментом разработчика (dev tools)**
|
||||||
|
|
||||||
|
Благодарим Вас за помощь!
|
||||||
|
|
||||||
|
### Об авторских правах Pull Request
|
||||||
|
|
||||||
|
Если вы делаете pull request, значит вы согласны передать авторские права на изменения кода в Maisin&Co.
|
||||||
|
|
||||||
|
Это не означает, что Boostnote станет платным приложением. Если мы захотим заработать немного денег, мы найдем другой способ. Например, использование облачного хранилища, интеграцией мобильных приложений или другими специальными функциями.
|
||||||
|
Так как лицензия GPL v3 слишком строгая, чтобы быть совместимой с любой другой лицензией, мы думаем, что нужно заменить лицензию на более свободную (например, BSD, MIT).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Contributing to Boostnote (Korean)
|
||||||
|
|
||||||
|
### 버그 리포트를 보고할 때
|
||||||
|
이슈의 양식은 없습니다. 하지만 부탁이 있습니다.
|
||||||
|
|
||||||
|
**개발자 도구를 연 상태의 Boostnote 스크린샷을 첨부해주세요**
|
||||||
|
|
||||||
|
도움을 주셔서 감사합니다.
|
||||||
|
|
||||||
|
### Pull Request의 저작권에 관하여
|
||||||
|
|
||||||
|
당신이 pull request를 요청하면, 코드 변경에 대한 저작권을 Maisin&Co에 양도한다는 것에 동의한다는 의미입니다.
|
||||||
|
|
||||||
|
이것은 Boostnote가 유료화가 되는 것을 의미하는 건 아닙니다. 만약 우리가 자금이 필요하다면, 우리는 클라우드 연동, 모바일 앱 통합 혹은 특수한 기능 같은 것을 사용해 수입 창출을 시도할 것입니다.
|
||||||
|
GPL v3 라이센스는 다른 라이센스와 혼합해 사용하기엔 너무 엄격하므로, 우리는 BSD, MIT 라이센스와 같은 더 자유로운 라이센스로 교체하는 것을 생각하고 있습니다.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Contributing to Boostnote (Japanese)
|
||||||
|
|
||||||
|
### バグレポートに関してのissueを立てる時
|
||||||
イシューテンプレートはありませんが、1つお願いがあります。
|
イシューテンプレートはありませんが、1つお願いがあります。
|
||||||
|
|
||||||
**開発者ツールを開いた状態のBoostnoteのスクリーンショットを貼ってください**
|
**開発者ツールを開いた状態のBoostnoteのスクリーンショットを貼ってください**
|
||||||
|
|
||||||
よろしくお願いします。
|
よろしくお願いします。
|
||||||
|
|
||||||
## Pull requestの著作権について
|
### Pull requestの著作権について
|
||||||
|
|
||||||
Pull requestをすることはその変化分のコードの著作権をMAISIN&CO.に譲渡することに同意することになります。
|
Pull requestをすることはその変化分のコードの著作権をMaisin&Co.に譲渡することに同意することになります。
|
||||||
|
|
||||||
アプリケーションのLicenseをいつでも変える選択肢を残したいと思うからです。
|
アプリケーションのLicenseをいつでも変える選択肢を残したいと思うからです。
|
||||||
これはいずれかBoostnoteが有料の商用アプリになる可能性がある話ではありません。
|
これはいずれかBoostnoteが有料の商用アプリになる可能性がある話ではありません。
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# Build
|
# Build
|
||||||
|
|
||||||
|
## Environments
|
||||||
|
* npm: 4.x
|
||||||
|
* node: 7.x
|
||||||
|
|
||||||
|
You should use `npm v4.x` because `$ grand pre-build` fails on `v5.x`.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
We use Webpack HMR to develop Boostnote.
|
We use Webpack HMR to develop Boostnote.
|
||||||
|
|||||||
57
docs/ru/build.md
Normal file
57
docs/ru/build.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Сборка
|
||||||
|
|
||||||
|
## Используемые инструменты
|
||||||
|
* npm: 4.x
|
||||||
|
* node: 7.x
|
||||||
|
|
||||||
|
Вы должны использовать `npm v4.x`, так как `$ grand pre-build` не работает в `v5.x`.
|
||||||
|
|
||||||
|
## Разработка
|
||||||
|
|
||||||
|
Мы используем Webpack HMR при разработке Boostnote.
|
||||||
|
Выполнение следующих команд в корне проекта запустит Boostnote с настройками по умолчанию.
|
||||||
|
|
||||||
|
Установите необходимые пакеты с помощью yarn.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ yarn
|
||||||
|
```
|
||||||
|
|
||||||
|
Соберите и запустите.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ yarn run dev-start
|
||||||
|
```
|
||||||
|
|
||||||
|
Эта команда выполняет `yarn run webpack` и `yarn run hot` параллельно. Результат будет такой же, если вы выполните эти две команды раздельно.
|
||||||
|
|
||||||
|
`Webpack` будет следить за изменениями в коде и будет применять их автоматически.
|
||||||
|
|
||||||
|
Если возникает следующая ошибка: `Failed to load resource: net::ERR_CONNECTION_REFUSED`, пожалуйста, перезапустите Boostnote.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> ### Примечание
|
||||||
|
> В некоторых случаях вам необходимо обновить приложение вручную.
|
||||||
|
> 1. При редактировании метода конструктора компонента
|
||||||
|
> 2. При добавлении нового класса CSS (аналогично 1: Класс CSS перезаписывается каждым компонентом. Этот процесс выполняется в методе Constructor.)
|
||||||
|
|
||||||
|
## Деплой
|
||||||
|
|
||||||
|
Мы используем Grunt для автоматического деплоя.
|
||||||
|
Вы можете создать задачу, используя `grunt`. Однако мы не рекомендуем этого делать, так как задача по умолчанию включает в себя код и аутентификацию.
|
||||||
|
|
||||||
|
Мы подготовили отдельный скрипт, который просто создает исполняемый файл:
|
||||||
|
|
||||||
|
```
|
||||||
|
grunt pre-build
|
||||||
|
```
|
||||||
|
|
||||||
|
Вы найдете исполняемый файл в папке `dist`. Обратите внимание: автоматическое обновление не будет работать, потому что приложение не подписано.
|
||||||
|
|
||||||
|
Если вам необходимо, вы можете использовать код или аутентификацию с помощью этого исполняемого файла.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Special thanks:
|
||||||
|
Translated by @AlexanderBelkevich
|
||||||
25
docs/ru/debug.md
Normal file
25
docs/ru/debug.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Как отладить Boostnote (приложение Electron)
|
||||||
|
Boostnote - это программа, сделанная с помощью Electron, поэтому она базируется на Chromium. Разработчики могут использовать `Developer Tools` в Google Chrome для отладки.
|
||||||
|
|
||||||
|
Вы можете переключиться в `Developer Tools` следующим образом:
|
||||||
|

|
||||||
|
|
||||||
|
`Developer Tools` будет выглядеть следующим образом:
|
||||||
|

|
||||||
|
|
||||||
|
Возможные ошибки отображаются во вкладке `console`.
|
||||||
|
|
||||||
|
## Отладка
|
||||||
|
Например, вы можете использовать `debugger`, чтобы установить точку остановы следующим образом:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Это всего лишь пример. Вы можете использовать любой свой способ отладки. Тот, который вам будет удобен.
|
||||||
|
|
||||||
|
## Рекомендации
|
||||||
|
* [Официальная документация Google Chrome об отладке](https://developer.chrome.com/devtools)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Special thanks:
|
||||||
|
Translated by @AlexanderBelkevich
|
||||||
@@ -259,6 +259,8 @@ module.exports = function (grunt) {
|
|||||||
case 'osx':
|
case 'osx':
|
||||||
grunt.task.run(['compile', 'pack:osx'])
|
grunt.task.run(['compile', 'pack:osx'])
|
||||||
break
|
break
|
||||||
|
case 'linux':
|
||||||
|
grunt.task.run(['compile', 'pack:linux'])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
<script src="../node_modules/codemirror/addon/mode/loadmode.js"></script>
|
<script src="../node_modules/codemirror/addon/mode/loadmode.js"></script>
|
||||||
<script src="../node_modules/codemirror/keymap/sublime.js"></script>
|
<script src="../node_modules/codemirror/keymap/sublime.js"></script>
|
||||||
<script src="../node_modules/codemirror/keymap/vim.js"></script>
|
<script src="../node_modules/codemirror/keymap/vim.js"></script>
|
||||||
|
<script src="../node_modules/codemirror/keymap/emacs.js"></script>
|
||||||
<script src="../node_modules/codemirror/addon/runmode/runmode.js"></script>
|
<script src="../node_modules/codemirror/addon/runmode/runmode.js"></script>
|
||||||
|
|
||||||
<script src="../node_modules/raphael/raphael.min.js"></script>
|
<script src="../node_modules/raphael/raphael.min.js"></script>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user