1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

add default language for snippet note

This commit is contained in:
Baptiste Augrain
2018-08-30 17:52:50 +02:00
parent 039f73711a
commit 9f8246a26a
5 changed files with 25 additions and 6 deletions

View File

@@ -573,11 +573,12 @@ class SnippetNoteDetail extends React.Component {
}
addSnippet () {
const { config } = this.props
const { note } = this.state
note.snippets = note.snippets.concat([{
name: '',
mode: 'Plain Text',
mode: config.editor.snippetDefaultLanguage || 'text',
content: ''
}])
const snippetIndex = note.snippets.length - 1

View File

@@ -34,14 +34,15 @@ class NewNoteButton extends React.Component {
}
handleNewNoteButtonClick (e) {
const { location, dispatch } = this.props
const { location, dispatch, config } = this.props
const { storage, folder } = this.resolveTargetFolder()
modal.open(NewNoteModal, {
storage: storage.key,
folder: folder.key,
dispatch,
location
location,
config
})
}

View File

@@ -61,7 +61,7 @@ class NewNoteModal extends React.Component {
handleSnippetNoteButtonClick (e) {
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
const { storage, folder, dispatch, location } = this.props
const { storage, folder, dispatch, location, config } = this.props
dataApi
.createNote(storage, {
@@ -72,7 +72,7 @@ class NewNoteModal extends React.Component {
snippets: [
{
name: '',
mode: 'text',
mode: config.editor.snippetDefaultLanguage || 'text',
content: ''
}
]

View File

@@ -24,7 +24,7 @@
line-height 30px
.group-section-label
width 150px
width 200px
text-align left
margin-right 10px
font-size 14px

View File

@@ -85,6 +85,7 @@ class UiTab extends React.Component {
displayLineNumbers: this.refs.editorDisplayLineNumbers.checked,
switchPreview: this.refs.editorSwitchPreview.value,
keyMap: this.refs.editorKeyMap.value,
snippetDefaultLanguage: this.refs.editorSnippetDefaultLanguage.value,
scrollPastEnd: this.refs.scrollPastEnd.checked,
fetchUrlTitle: this.refs.editorFetchUrlTitle.checked
},
@@ -386,6 +387,22 @@ class UiTab extends React.Component {
<p styleName='note-for-keymap'>{i18n.__('⚠️ Please restart boostnote after you change the keymap')}</p>
</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'>
<label>