mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Add button clear all checkboxes
This commit is contained in:
@@ -64,6 +64,10 @@ class MarkdownEditor extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setValue (value) {
|
||||||
|
this.refs.code.setValue(value)
|
||||||
|
}
|
||||||
|
|
||||||
handleChange (e) {
|
handleChange (e) {
|
||||||
this.value = this.refs.code.value
|
this.value = this.refs.code.value
|
||||||
this.props.onChange(e)
|
this.props.onChange(e)
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setValue (value) {
|
||||||
|
this.refs.code.setValue(value)
|
||||||
|
}
|
||||||
|
|
||||||
handleOnChange () {
|
handleOnChange () {
|
||||||
this.value = this.refs.code.value
|
this.value = this.refs.code.value
|
||||||
this.props.onChange()
|
this.props.onChange()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import styles from './TodoListPercentage.styl'
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const TodoListPercentage = ({
|
const TodoListPercentage = ({
|
||||||
percentageOfTodo
|
percentageOfTodo, onClick
|
||||||
}) => (
|
}) => (
|
||||||
<div styleName='percentageBar' style={{display: isNaN(percentageOfTodo) ? 'none' : ''}}>
|
<div styleName='percentageBar' style={{display: isNaN(percentageOfTodo) ? 'none' : ''}}>
|
||||||
<div styleName='progressBar' style={{width: `${percentageOfTodo}%`}}>
|
<div styleName='progressBar' style={{width: `${percentageOfTodo}%`}}>
|
||||||
@@ -20,11 +20,15 @@ const TodoListPercentage = ({
|
|||||||
<p styleName='percentageText'>{percentageOfTodo}%</p>
|
<p styleName='percentageText'>{percentageOfTodo}%</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div styleName='todoClear'>
|
||||||
|
<p styleName='todoClearText' onClick={(e) => onClick(e)}>clear</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
TodoListPercentage.propTypes = {
|
TodoListPercentage.propTypes = {
|
||||||
percentageOfTodo: PropTypes.number.isRequired
|
percentageOfTodo: PropTypes.number.isRequired,
|
||||||
|
onClick: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(TodoListPercentage, styles)
|
export default CSSModules(TodoListPercentage, styles)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.percentageBar
|
.percentageBar
|
||||||
|
display: flex
|
||||||
position absolute
|
position absolute
|
||||||
top 72px
|
top 72px
|
||||||
right 0px
|
right 0px
|
||||||
@@ -30,6 +31,20 @@
|
|||||||
color #f4f4f4
|
color #f4f4f4
|
||||||
font-weight 600
|
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"]
|
body[data-theme="dark"]
|
||||||
.percentageBar
|
.percentageBar
|
||||||
background-color #444444
|
background-color #444444
|
||||||
@@ -39,6 +54,9 @@ body[data-theme="dark"]
|
|||||||
|
|
||||||
.percentageText
|
.percentageText
|
||||||
color $ui-dark-text-color
|
color $ui-dark-text-color
|
||||||
|
|
||||||
|
.todoClearText
|
||||||
|
color $ui-dark-text-color
|
||||||
|
|
||||||
body[data-theme="solarized-dark"]
|
body[data-theme="solarized-dark"]
|
||||||
.percentageBar
|
.percentageBar
|
||||||
@@ -50,6 +68,9 @@ body[data-theme="solarized-dark"]
|
|||||||
.percentageText
|
.percentageText
|
||||||
color #fdf6e3
|
color #fdf6e3
|
||||||
|
|
||||||
|
.todoClearText
|
||||||
|
color #fdf6e3
|
||||||
|
|
||||||
body[data-theme="monokai"]
|
body[data-theme="monokai"]
|
||||||
.percentageBar
|
.percentageBar
|
||||||
background-color: $ui-monokai-borderColor
|
background-color: $ui-monokai-borderColor
|
||||||
@@ -69,3 +90,6 @@ body[data-theme="dracula"]
|
|||||||
|
|
||||||
.percentageText
|
.percentageText
|
||||||
color $ui-dracula-text-color
|
color $ui-dracula-text-color
|
||||||
|
|
||||||
|
.percentageText
|
||||||
|
color $ui-dracula-text-color
|
||||||
|
|||||||
@@ -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 () {
|
renderEditor () {
|
||||||
const { config, ignorePreviewPointerEvents } = this.props
|
const { config, ignorePreviewPointerEvents } = this.props
|
||||||
const { note } = this.state
|
const { note } = this.state
|
||||||
|
|
||||||
if (this.state.editorType === 'EDITOR_PREVIEW') {
|
if (this.state.editorType === 'EDITOR_PREVIEW') {
|
||||||
return <MarkdownEditor
|
return <MarkdownEditor
|
||||||
ref='content'
|
ref='content'
|
||||||
@@ -375,7 +395,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
data={data}
|
data={data}
|
||||||
onChange={this.handleUpdateTag.bind(this)}
|
onChange={this.handleUpdateTag.bind(this)}
|
||||||
/>
|
/>
|
||||||
<TodoListPercentage percentageOfTodo={getTodoPercentageOfCompleted(note.content)} />
|
<TodoListPercentage onClick={(e) => this.handleClearTodo(e)} percentageOfTodo={getTodoPercentageOfCompleted(note.content)} />
|
||||||
</div>
|
</div>
|
||||||
<div styleName='info-right'>
|
<div styleName='info-right'>
|
||||||
<ToggleModeButton onClick={(e) => this.handleSwitchMode(e)} editorType={editorType} />
|
<ToggleModeButton onClick={(e) => this.handleSwitchMode(e)} editorType={editorType} />
|
||||||
|
|||||||
Reference in New Issue
Block a user