mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 10:16:26 +00:00
add default language for snippet note
This commit is contained in:
@@ -573,11 +573,12 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addSnippet () {
|
addSnippet () {
|
||||||
|
const { config } = this.props
|
||||||
const { note } = this.state
|
const { note } = this.state
|
||||||
|
|
||||||
note.snippets = note.snippets.concat([{
|
note.snippets = note.snippets.concat([{
|
||||||
name: '',
|
name: '',
|
||||||
mode: 'Plain Text',
|
mode: config.editor.snippetDefaultLanguage || 'text',
|
||||||
content: ''
|
content: ''
|
||||||
}])
|
}])
|
||||||
const snippetIndex = note.snippets.length - 1
|
const snippetIndex = note.snippets.length - 1
|
||||||
|
|||||||
@@ -34,14 +34,15 @@ class NewNoteButton extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNewNoteButtonClick (e) {
|
handleNewNoteButtonClick (e) {
|
||||||
const { location, dispatch } = this.props
|
const { location, dispatch, config } = this.props
|
||||||
const { storage, folder } = this.resolveTargetFolder()
|
const { storage, folder } = this.resolveTargetFolder()
|
||||||
|
|
||||||
modal.open(NewNoteModal, {
|
modal.open(NewNoteModal, {
|
||||||
storage: storage.key,
|
storage: storage.key,
|
||||||
folder: folder.key,
|
folder: folder.key,
|
||||||
dispatch,
|
dispatch,
|
||||||
location
|
location,
|
||||||
|
config
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class NewNoteModal extends React.Component {
|
|||||||
handleSnippetNoteButtonClick (e) {
|
handleSnippetNoteButtonClick (e) {
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
||||||
const { storage, folder, dispatch, location } = this.props
|
const { storage, folder, dispatch, location, config } = this.props
|
||||||
|
|
||||||
dataApi
|
dataApi
|
||||||
.createNote(storage, {
|
.createNote(storage, {
|
||||||
@@ -72,7 +72,7 @@ class NewNoteModal extends React.Component {
|
|||||||
snippets: [
|
snippets: [
|
||||||
{
|
{
|
||||||
name: '',
|
name: '',
|
||||||
mode: 'text',
|
mode: config.editor.snippetDefaultLanguage || 'text',
|
||||||
content: ''
|
content: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
line-height 30px
|
line-height 30px
|
||||||
|
|
||||||
.group-section-label
|
.group-section-label
|
||||||
width 150px
|
width 200px
|
||||||
text-align left
|
text-align left
|
||||||
margin-right 10px
|
margin-right 10px
|
||||||
font-size 14px
|
font-size 14px
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class UiTab extends React.Component {
|
|||||||
displayLineNumbers: this.refs.editorDisplayLineNumbers.checked,
|
displayLineNumbers: this.refs.editorDisplayLineNumbers.checked,
|
||||||
switchPreview: this.refs.editorSwitchPreview.value,
|
switchPreview: this.refs.editorSwitchPreview.value,
|
||||||
keyMap: this.refs.editorKeyMap.value,
|
keyMap: this.refs.editorKeyMap.value,
|
||||||
|
snippetDefaultLanguage: this.refs.editorSnippetDefaultLanguage.value,
|
||||||
scrollPastEnd: this.refs.scrollPastEnd.checked,
|
scrollPastEnd: this.refs.scrollPastEnd.checked,
|
||||||
fetchUrlTitle: this.refs.editorFetchUrlTitle.checked
|
fetchUrlTitle: this.refs.editorFetchUrlTitle.checked
|
||||||
},
|
},
|
||||||
@@ -387,6 +388,22 @@ class UiTab extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div styleName='group-section'>
|
||||||
|
<div styleName='group-section-label'>
|
||||||
|
{i18n.__('Snippet Default Language')}
|
||||||
|
</div>
|
||||||
|
<div styleName='group-section-control'>
|
||||||
|
<select value={config.editor.snippetDefaultLanguage}
|
||||||
|
ref='editorSnippetDefaultLanguage'
|
||||||
|
onChange={(e) => this.handleUIChange(e)}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
_.sortBy(CodeMirror.modeInfo.map(mode => mode.name)).map(name => (<option value={name}>{name}</option>))
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div styleName='group-checkBoxSection'>
|
<div styleName='group-checkBoxSection'>
|
||||||
<label>
|
<label>
|
||||||
<input onChange={(e) => this.handleUIChange(e)}
|
<input onChange={(e) => this.handleUIChange(e)}
|
||||||
|
|||||||
Reference in New Issue
Block a user