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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions browser/components/MarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class MarkdownEditor extends React.Component {
})
}

setValue (value) {
this.refs.code.setValue(value)
}

handleChange (e) {
this.value = this.refs.code.value
this.props.onChange(e)
Expand Down
4 changes: 4 additions & 0 deletions browser/components/MarkdownSplitEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class MarkdownSplitEditor extends React.Component {
}
}

setValue (value) {
this.refs.code.setValue(value)
}

handleOnChange () {
this.value = this.refs.code.value
this.props.onChange()
Expand Down
8 changes: 6 additions & 2 deletions browser/components/TodoListPercentage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ import styles from './TodoListPercentage.styl'
*/

const TodoListPercentage = ({
percentageOfTodo
percentageOfTodo, onClearCheckboxClick
}) => (
<div styleName='percentageBar' style={{display: isNaN(percentageOfTodo) ? 'none' : ''}}>
<div styleName='progressBar' style={{width: `${percentageOfTodo}%`}}>
<div styleName='progressBarInner'>
<p styleName='percentageText'>{percentageOfTodo}%</p>
</div>
</div>
<div styleName='todoClear'>
<p styleName='todoClearText' onClick={(e) => onClearCheckboxClick(e)}>clear</p>
</div>
</div>
)

TodoListPercentage.propTypes = {
percentageOfTodo: PropTypes.number.isRequired
percentageOfTodo: PropTypes.number.isRequired,
onClearCheckboxClick: PropTypes.func.isRequired
}

export default CSSModules(TodoListPercentage, styles)
24 changes: 24 additions & 0 deletions browser/components/TodoListPercentage.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.percentageBar
display: flex
position absolute
top 72px
right 0px
Expand Down Expand Up @@ -30,6 +31,20 @@
color #f4f4f4
font-weight 600

.todoClear
display flex
justify-content: flex-end
position absolute
z-index 120
width 100%
height 100%
padding 2px 10px

.todoClearText
color #f4f4f4
cursor pointer
font-weight 500

body[data-theme="dark"]
.percentageBar
background-color #444444
Expand All @@ -39,6 +54,9 @@ body[data-theme="dark"]

.percentageText
color $ui-dark-text-color

.todoClearText
color $ui-dark-text-color

body[data-theme="solarized-dark"]
.percentageBar
Expand All @@ -50,6 +68,9 @@ body[data-theme="solarized-dark"]
.percentageText
color #fdf6e3

.todoClearText
color #fdf6e3

body[data-theme="monokai"]
.percentageBar
background-color: $ui-monokai-borderColor
Expand All @@ -69,3 +90,6 @@ body[data-theme="dracula"]

.percentageText
color $ui-dracula-text-color

.percentageText
color $ui-dracula-text-color
22 changes: 21 additions & 1 deletion browser/main/Detail/MarkdownNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,29 @@ class MarkdownNoteDetail extends React.Component {
})
}

handleClearTodo () {
const { note } = this.state
const splitted = note.content.split('\n')

const clearTodoContent = splitted.map((line) => {
const trimmedLine = line.trim()
if (trimmedLine.match(/\[x\]/i)) {
return line.replace(/\[x\]/i, '[ ]')
} else {
return line
}
}).join('\n')

note.content = clearTodoContent
this.refs.content.setValue(note.content)

this.updateNote(note)
}

renderEditor () {
const { config, ignorePreviewPointerEvents } = this.props
const { note } = this.state

if (this.state.editorType === 'EDITOR_PREVIEW') {
return <MarkdownEditor
ref='content'
Expand Down Expand Up @@ -375,7 +395,7 @@ class MarkdownNoteDetail extends React.Component {
data={data}
onChange={this.handleUpdateTag.bind(this)}
/>
<TodoListPercentage percentageOfTodo={getTodoPercentageOfCompleted(note.content)} />
<TodoListPercentage onClearCheckboxClick={(e) => this.handleClearTodo(e)} percentageOfTodo={getTodoPercentageOfCompleted(note.content)} />
</div>
<div styleName='info-right'>
<ToggleModeButton onClick={(e) => this.handleSwitchMode(e)} editorType={editorType} />
Expand Down