1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 10:16:26 +00:00

Compare commits

...

49 Commits

Author SHA1 Message Date
Sota Sugiura
33fe3ff733 Merge pull request #527 from BoostIO/fix-add-description
Add description for package.json
2017-04-29 16:25:03 +09:00
sota1235
aa77180957 modify: backword compatibility 2017-04-29 16:24:08 +09:00
sota1235
3d80b6a4cd modify: add descriptoin (it is reuqired for building windows app) 2017-04-29 16:01:39 +09:00
Sota Sugiura
d76f9243a3 Merge pull request #524 from BoostIO/feature-v0-8-9
v0.8.9
2017-04-29 15:25:15 +09:00
sota1235
88f1a0d5cd v0.8.9 2017-04-29 15:22:15 +09:00
Kazu Yokomizo
26c435d6da Merge pull request #526 from BoostIO/change-noteitem-border-color
Change noteitem border color
2017-04-29 15:19:39 +09:00
Kazu Yokomizo
e66abdea2d Change the border color at NoteItemSimple 2017-04-29 15:11:48 +09:00
Kazu Yokomizo
c7d2eeb71a Change the border color at NoteItem 2017-04-29 15:07:13 +09:00
Kazu Yokomizo
0e8d681954 Merge pull request #525 from BoostIO/update-slack-link
Update slack link
2017-04-29 14:20:24 +09:00
Kazu Yokomizo
433d110cf0 Update slack invitation link 2017-04-29 14:17:48 +09:00
Kazu Yokomizo
4a514cd7bd Update slack invitation link 2017-04-29 14:17:10 +09:00
Kazu Yokomizo
417fee16bd Merge pull request #512 from LeoLamCY/fix-md-viewer-line-breaks
Fix md viewer line breaks when copying
2017-04-29 14:09:23 +09:00
Kazu Yokomizo
49a821d9ee Merge pull request #480 from SalvatoreTosti/master
Changed wordings on 'Make a Note' pane
2017-04-29 14:09:00 +09:00
Kazu Yokomizo
6a5ce098e0 Merge pull request #513 from bbtran/master
fixes (#504) scrollbar no longer appears above modal.
2017-04-29 12:47:27 +09:00
Kazu Yokomizo
1af73eebea Merge pull request #523 from BoostIO/change-donate-link
Change donate link
2017-04-29 12:31:16 +09:00
Sota Sugiura
b7ba29ac92 Merge pull request #341 from asmsuechan/fix-incorrect-tag-completion
Fix incorrect tag completion in code block
2017-04-29 12:24:50 +09:00
Kazu Yokomizo
133c2ec308 Change the donation link Patreon to Bountysource 2017-04-29 12:19:26 +09:00
Kazu Yokomizo
a70fe1bba8 Merge pull request #522 from BoostIO/change-star-layout
fix: modify the star layout at NoteItem
2017-04-29 12:09:53 +09:00
Kazu Yokomizo
6dcd653eac Merge pull request #520 from BoostIO/improvement-of-sidebar-uiux
Improvement of sidebar uiux
2017-04-29 11:17:03 +09:00
Kazu Yokomizo
db2f90b1ce fix: modify the star layout at NoteItem 2017-04-29 05:56:48 +09:00
Kazu Yokomizo
60e5665133 Fix the layout and UX of StorageItem at SIdebra 2017-04-28 16:07:55 +09:00
Kazu Yokomizo
7aa982849f Fix the layout and UX at create-folder-btn at sidebar 2017-04-28 15:42:46 +09:00
Kohei TAKATA
d94f7626c2 Merge pull request #477 from BoostIO/hotfix-fix-package-name
Fix package name
2017-04-28 00:39:06 +09:00
Benjamin Tran
549c289f81 fixes #504 scrollbar no longer appears above modal.
Edit NoteList style properties on modal component. Remove overflow to hide scrollbar on modal open.
2017-04-26 19:12:56 -07:00
Leo Lam
b35953d1f9 fix md viewer line breaks when copying
-set white-space to normal to remove extra space between lines
2017-04-26 19:37:12 -04:00
Leo
941c4aeb19 Merge pull request #2 from BoostIO/master
update fork
2017-04-26 14:08:30 -04:00
Sota Sugiura
75b2c7bd2e Merge pull request #484 from asmsuechan/fix-delete-shortcut
Fix a shortcut for deletion
2017-04-24 23:14:42 +09:00
Leo
5fd9866eef Merge pull request #1 from BoostIO/master
update fork
2017-04-24 00:59:37 -04:00
SuenagaRyota
ff7024e38f Merge pull request #488 from tkshnwesper/master
Added `Shift` to HotkeyTab.js
2017-04-23 00:21:05 -07:00
Saurabh
8c11a0b42d Added Shift to HotkeyTab.js 2017-04-23 12:43:39 +05:30
asmsuechan
2df295dc1d Fix styles by lint 2017-04-22 17:30:55 -07:00
asmsuechan
b695d27817 Add test for htmlTextHelper 2017-04-22 17:19:05 -07:00
asmsuechan
8e2fd300f6 Delete an encode table
because when & is encoded, it affect other encodes due to they use &
2017-04-22 16:14:09 -07:00
asmsuechan
1722e103fc Change methods to helper methods 2017-04-22 16:14:09 -07:00
asmsuechan
71464112ce Remove a disused condition 2017-04-22 16:14:09 -07:00
asmsuechan
003d8a1b21 Fix a bug on regexp of a question mark 2017-04-22 16:14:09 -07:00
asmsuechan
adf81175f3 Reduce the code 2017-04-22 16:14:09 -07:00
asmsuechan
39274ce483 Fix to handle with multiple entities in one line 2017-04-22 16:14:09 -07:00
asmsuechan
1daf07edeb Refactor to more readable 2017-04-22 16:14:09 -07:00
asmsuechan
cd2dc471c7 Fix to string literal 2017-04-22 16:14:09 -07:00
asmsuechan
6229ca7ac9 Refactor to ES6 2017-04-22 16:14:09 -07:00
asmsuechan
10043cc755 Fix to handle when codeBlocks is null 2017-04-22 16:14:09 -07:00
asmsuechan
e60a5430b4 Fix to replace only CodeBlock 2017-04-22 16:14:09 -07:00
asmsuechan
f7e0cb655f Add question mark 2017-04-22 16:14:09 -07:00
asmsuechan
04097ecfcd Fix incorrect tag completion in code block 2017-04-22 16:14:09 -07:00
asmsuechan
2222192bcd Fix to enable a shortcut for deleting a note 2017-04-22 15:38:55 -07:00
Salvatore Tosti
ae93c38d46 Changed wordings on 'Make a Note' pane
Note type descriptions are now more concise and uniform in style.
2017-04-22 08:16:05 -07:00
Sota Sugiura
9ff9dcbe6d Merge branch 'master' into hotfix-fix-package-name 2017-04-22 18:45:52 +09:00
sota1235
94d442af7d modify: fix package name 2017-04-22 18:43:56 +09:00
16 changed files with 166 additions and 44 deletions

View File

@@ -8,21 +8,7 @@ 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) {
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
@@ -73,6 +59,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;
}
` `
} }
@@ -241,6 +231,13 @@ export default class MarkdownPreview extends React.Component {
let { value, theme, indentSize, codeBlockTheme } = this.props let { value, theme, indentSize, codeBlockTheme } = 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) => {
@@ -263,7 +260,7 @@ 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)
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 +278,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 +294,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) => {

View File

@@ -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
@@ -53,6 +55,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
@@ -111,11 +115,11 @@ $control-height = 30px
.item-star .item-star
position absolute position absolute
top 19px top 34px
left 5px left 5px
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 +158,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

View File

@@ -96,7 +96,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

View File

@@ -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

View File

@@ -0,0 +1,43 @@
/**
* @fileoverview Text trimmer for html.
*/
/**
* @param {string} text
* @return {string}
*/
export function decodeEntities (text) {
var entities = [
['apos', '\''],
['amp', '&'],
['lt', '<'],
['gt', '>'],
['#63', '\\?']
]
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']
]
entities.forEach((entity) => {
text = text.replace(new RegExp(entity[0], 'g'), `&${entity[1]};`)
})
return text
}
export default {
decodeEntities,
encodeEntities
}

View File

@@ -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>`

View File

@@ -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.handleDeleteButtonClick()
} }
} }

View File

@@ -4,12 +4,13 @@
.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 +31,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 +64,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 +124,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 +143,9 @@ body[data-theme="dark"]
.header-addFolderButton .header-addFolderButton
&:hover &:hover
color $ui-dark-text-color transition 0.2s
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

View File

@@ -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})
} }

View File

@@ -117,7 +117,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 +129,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>

View File

@@ -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>
} }

View File

@@ -47,9 +47,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'

View File

@@ -1,8 +1,8 @@
{ {
"name": "boost", "name": "boost",
"version": "0.8.8", "version": "0.8.9",
"description": "Boostnote",
"main": "index.js", "main": "index.js",
"description": "Boostnote",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {
"start": "electron ./index.js", "start": "electron ./index.js",

View File

@@ -25,13 +25,13 @@
## slack group ## slack group
私たちにはslack groupもあります世界中のプログラマー達と、Boostnoteについてディスカッションをしましょう <br> 私たちにはslack groupもあります世界中のプログラマー達と、Boostnoteについてディスカッションをしましょう <br>
[こちらから](https://boostnote-group.slack.com/shared_invite/MTcxMjIwODk5Mzk3LTE0OTI1NjQxNDUtMTkwZTBjOWFkMg) [こちらから](https://join.slack.com/boostnote-group/shared_invite/MTc2NTc5MTkyMjc3LTE0OTM0NDI5MzgtNzdkNjZjMzJhNA)
## More Information ## More Information
* Website: http://boostnote.io/ * Website: http://boostnote.io/
* Roadmap(upcoming features and bug fixes): https://github.com/BoostIO/Boostnote/wiki/List-of-the-requested-features * Roadmap(upcoming features and bug fixes): https://github.com/BoostIO/Boostnote/wiki/List-of-the-requested-features
* Boostnote Shop(Products are shipped to all over the world :+1:): https://boostnote.paintory.com/ * Boostnote Shop(Products are shipped to all over the world :+1:): https://boostnote.paintory.com/
* Donation: [Patreon](https://www.patreon.com/boostnote) * Donation: [Bountysource](https://salt.bountysource.com/teams/boostnote)
* Development: https://github.com/BoostIO/Boostnote/blob/master/docs/build.md * Development: https://github.com/BoostIO/Boostnote/blob/master/docs/build.md
* Copyright (C) 2017 Maisin&Co. * Copyright (C) 2017 Maisin&Co.

View File

@@ -25,12 +25,12 @@
## Slack Group ## Slack Group
Let's talk about Boostnote's great features, new feature requests and things like Japanese gourmet. 🍣 <br> Let's talk about Boostnote's great features, new feature requests and things like Japanese gourmet. 🍣 <br>
[Join us](https://boostnote-group.slack.com/shared_invite/MTcxMjIwODk5Mzk3LTE0OTI1NjQxNDUtMTkwZTBjOWFkMg) [Join us](https://join.slack.com/boostnote-group/shared_invite/MTc2NTc5MTkyMjc3LTE0OTM0NDI5MzgtNzdkNjZjMzJhNA)
## More Information ## More Information
* [Website](https://boostnote.io) * [Website](https://boostnote.io)
* [Boostnote Shop](https://boostnote.paintory.com/) : Products are shipped to all over the world 🌏 * [Boostnote Shop](https://boostnote.paintory.com/) : Products are shipped to all over the world 🌏
* [Donate via Patreon](https://www.patreon.com/boostnote) : Thank you for your support 🎉 * [Donate via Bountysource](https://salt.bountysource.com/teams/boostnote) : Thank you for your support 🎉
* [GitHub Issues](https://github.com/BoostIO/Boostnote/issues) : We'd love to hear your feedback 🙌 * [GitHub Issues](https://github.com/BoostIO/Boostnote/issues) : We'd love to hear your feedback 🙌
* [Development](https://github.com/BoostIO/Boostnote/blob/master/docs/build.md) : Development configurations for Boostnote 🚀 * [Development](https://github.com/BoostIO/Boostnote/blob/master/docs/build.md) : Development configurations for Boostnote 🚀
* Copyright (C) 2017 Maisin&Co. * Copyright (C) 2017 Maisin&Co.

View File

@@ -0,0 +1,52 @@
/**
* @fileoverview Unit test for browser/lib/htmlTextHelper
*/
const test = require('ava')
const htmlTextHelper = require('browser/lib/htmlTextHelper')
// Unit test
test('htmlTextHelper#decodeEntities should return encoded text (string)', t => {
// [input, expected]
const testCases = [
['&lt;a href=', '<a href='],
['var test = &apos;test&apos;', 'var test = \'test\''],
['&lt;a href=&apos;https://boostnote.io&apos;&gt;Boostnote', '<a href=\'https://boostnote.io\'>Boostnote'],
['&lt;\\\\?php\n var = &apos;hoge&apos;;', '<\\\\?php\n var = \'hoge\';'],
['&amp;', '&']
]
testCases.forEach(testCase => {
const [input, expected] = testCase
t.is(htmlTextHelper.decodeEntities(input), expected, `Test for decodeEntities() input: ${input} expected: ${expected}`)
})
})
test('htmlTextHelper#decodeEntities() should return decoded text (string)', t => {
// [input, expected]
const testCases = [
['<a href=', '&lt;a href='],
['var test = \'test\'', 'var test = &apos;test&apos;'],
['<a href=\'https://boostnote.io\'>Boostnote', '&lt;a href=&apos;https://boostnote.io&apos;&gt;Boostnote'],
['<?php\n var = \'hoge\';', '&lt;&#63;php\n var = &apos;hoge&apos;;']
]
testCases.forEach(testCase => {
const [input, expected] = testCase
t.is(htmlTextHelper.encodeEntities(input), expected, `Test for encodeEntities() input: ${input} expected: ${expected}`)
})
})
// Integration test
test(t => {
const testCases = [
'var test = \'test\'',
'<a href=\'https://boostnote.io\'>Boostnote',
'<Component styleName=\'test\' />'
]
testCases.forEach(testCase => {
const encodedText = htmlTextHelper.encodeEntities(testCase)
const decodedText = htmlTextHelper.decodeEntities(encodedText)
t.is(decodedText, testCase, 'Integration test through encodedText() and decodedText()')
})
})