mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
create note with selected tags
This commit is contained in:
@@ -3,14 +3,18 @@ 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) {
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
||||||
|
|
||||||
|
const tags = location.pathname.match(/\/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 +33,18 @@ 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')
|
||||||
|
|
||||||
|
const tags = location.pathname.match(/\/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)
|
||||||
} 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 } = this.props
|
||||||
createMarkdownNote(storage, folder, dispatch, location).then(() => {
|
createMarkdownNote(storage, folder, dispatch, location, params).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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user