mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Merge pull request #2498 from daiyam/create-note-with-tags
create note with selected tags
This commit is contained in:
@@ -3,14 +3,21 @@ import dataApi from 'browser/main/lib/dataApi'
|
|||||||
import ee from 'browser/main/lib/eventEmitter'
|
import ee from 'browser/main/lib/eventEmitter'
|
||||||
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
|
||||||
|
|
||||||
export function createMarkdownNote (storage, folder, dispatch, location) {
|
export function createMarkdownNote (storage, folder, dispatch, location, params, config) {
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
||||||
|
|
||||||
|
let tags = []
|
||||||
|
if (config.ui.tagNewNoteWithFilteringTags && location.pathname.match(/\/tags/)) {
|
||||||
|
tags = params.tagname.split(' ')
|
||||||
|
}
|
||||||
|
|
||||||
return dataApi
|
return dataApi
|
||||||
.createNote(storage, {
|
.createNote(storage, {
|
||||||
type: 'MARKDOWN_NOTE',
|
type: 'MARKDOWN_NOTE',
|
||||||
folder: folder,
|
folder: folder,
|
||||||
title: '',
|
title: '',
|
||||||
|
tags,
|
||||||
content: ''
|
content: ''
|
||||||
})
|
})
|
||||||
.then(note => {
|
.then(note => {
|
||||||
@@ -29,14 +36,21 @@ export function createMarkdownNote (storage, folder, dispatch, location) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createSnippetNote (storage, folder, dispatch, location, config) {
|
export function createSnippetNote (storage, folder, dispatch, location, params, config) {
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
||||||
|
|
||||||
|
let tags = []
|
||||||
|
if (config.ui.tagNewNoteWithFilteringTags && location.pathname.match(/\/tags/)) {
|
||||||
|
tags = params.tagname.split(' ')
|
||||||
|
}
|
||||||
|
|
||||||
return dataApi
|
return dataApi
|
||||||
.createNote(storage, {
|
.createNote(storage, {
|
||||||
type: 'SNIPPET_NOTE',
|
type: 'SNIPPET_NOTE',
|
||||||
folder: folder,
|
folder: folder,
|
||||||
title: '',
|
title: '',
|
||||||
|
tags,
|
||||||
description: '',
|
description: '',
|
||||||
snippets: [
|
snippets: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,19 +35,20 @@ class NewNoteButton extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNewNoteButtonClick (e) {
|
handleNewNoteButtonClick (e) {
|
||||||
const { location, dispatch, config } = this.props
|
const { location, params, dispatch, config } = this.props
|
||||||
const { storage, folder } = this.resolveTargetFolder()
|
const { storage, folder } = this.resolveTargetFolder()
|
||||||
|
|
||||||
if (config.ui.defaultNote === 'MARKDOWN_NOTE') {
|
if (config.ui.defaultNote === 'MARKDOWN_NOTE') {
|
||||||
createMarkdownNote(storage.key, folder.key, dispatch, location)
|
createMarkdownNote(storage.key, folder.key, dispatch, location, params, config)
|
||||||
} else if (config.ui.defaultNote === 'SNIPPET_NOTE') {
|
} else if (config.ui.defaultNote === 'SNIPPET_NOTE') {
|
||||||
createSnippetNote(storage.key, folder.key, dispatch, location, config)
|
createSnippetNote(storage.key, folder.key, dispatch, location, params, config)
|
||||||
} else {
|
} else {
|
||||||
modal.open(NewNoteModal, {
|
modal.open(NewNoteModal, {
|
||||||
storage: storage.key,
|
storage: storage.key,
|
||||||
folder: folder.key,
|
folder: folder.key,
|
||||||
dispatch,
|
dispatch,
|
||||||
location,
|
location,
|
||||||
|
params,
|
||||||
config
|
config
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class NewNoteModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleMarkdownNoteButtonClick (e) {
|
handleMarkdownNoteButtonClick (e) {
|
||||||
const { storage, folder, dispatch, location } = this.props
|
const { storage, folder, dispatch, location, params, config } = this.props
|
||||||
createMarkdownNote(storage, folder, dispatch, location).then(() => {
|
createMarkdownNote(storage, folder, dispatch, location, params, config).then(() => {
|
||||||
setTimeout(this.props.close, 200)
|
setTimeout(this.props.close, 200)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -35,8 +35,8 @@ class NewNoteModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSnippetNoteButtonClick (e) {
|
handleSnippetNoteButtonClick (e) {
|
||||||
const { storage, folder, dispatch, location, config } = this.props
|
const { storage, folder, dispatch, location, params, config } = this.props
|
||||||
createSnippetNote(storage, folder, dispatch, location, config).then(() => {
|
createSnippetNote(storage, folder, dispatch, location, params, config).then(() => {
|
||||||
setTimeout(this.props.close, 200)
|
setTimeout(this.props.close, 200)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class UiTab extends React.Component {
|
|||||||
theme: this.refs.uiTheme.value,
|
theme: this.refs.uiTheme.value,
|
||||||
language: this.refs.uiLanguage.value,
|
language: this.refs.uiLanguage.value,
|
||||||
defaultNote: this.refs.defaultNote.value,
|
defaultNote: this.refs.defaultNote.value,
|
||||||
|
tagNewNoteWithFilteringTags: this.refs.tagNewNoteWithFilteringTags.checked,
|
||||||
showCopyNotification: this.refs.showCopyNotification.checked,
|
showCopyNotification: this.refs.showCopyNotification.checked,
|
||||||
confirmDeletion: this.refs.confirmDeletion.checked,
|
confirmDeletion: this.refs.confirmDeletion.checked,
|
||||||
showOnlyRelatedTags: this.refs.showOnlyRelatedTags.checked,
|
showOnlyRelatedTags: this.refs.showOnlyRelatedTags.checked,
|
||||||
@@ -268,6 +269,7 @@ class UiTab extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
||||||
<div styleName='group-header2'>Tags</div>
|
<div styleName='group-header2'>Tags</div>
|
||||||
|
|
||||||
<div styleName='group-checkBoxSection'>
|
<div styleName='group-checkBoxSection'>
|
||||||
@@ -314,6 +316,17 @@ class UiTab extends React.Component {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div styleName='group-checkBoxSection'>
|
||||||
|
<label>
|
||||||
|
<input onChange={(e) => this.handleUIChange(e)}
|
||||||
|
checked={this.state.config.ui.tagNewNoteWithFilteringTags}
|
||||||
|
ref='tagNewNoteWithFilteringTags'
|
||||||
|
type='checkbox'
|
||||||
|
/>
|
||||||
|
{i18n.__('New notes are tagged with the filtering tags')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div styleName='group-header2'>Editor</div>
|
<div styleName='group-header2'>Editor</div>
|
||||||
|
|
||||||
<div styleName='group-section'>
|
<div styleName='group-section'>
|
||||||
|
|||||||
@@ -183,5 +183,6 @@
|
|||||||
"Save tags of a note in alphabetical order": "Save tags of a note in alphabetical order",
|
"Save tags of a note in alphabetical order": "Save tags of a note in alphabetical order",
|
||||||
"Enable live count of notes": "Enable live count of notes",
|
"Enable live count of notes": "Enable live count of notes",
|
||||||
"Enable smart table editor": "Enable smart table editor",
|
"Enable smart table editor": "Enable smart table editor",
|
||||||
"Snippet Default Language": "Snippet Default Language"
|
"Snippet Default Language": "Snippet Default Language",
|
||||||
|
"New notes are tagged with the filtering tags": "New notes are tagged with the filtering tags"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,7 @@
|
|||||||
"New Snippet": "Nouveau snippet",
|
"New Snippet": "Nouveau snippet",
|
||||||
"Custom CSS": "CSS personnalisé",
|
"Custom CSS": "CSS personnalisé",
|
||||||
"Snippet name": "Nom du snippet",
|
"Snippet name": "Nom du snippet",
|
||||||
"Snippet prefix": "Préfixe du snippet"
|
"Snippet prefix": "Préfixe du snippet",
|
||||||
"Delete Note": "Supprimer la note"
|
"Delete Note": "Supprimer la note",
|
||||||
|
"New notes are tagged with the filtering tags": "Les nouvelles notes sont taggées avec les tags de filtrage"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user