Skip to content

Commit e11a68a

Browse files
authored
Merge pull request #2352 from daiyam/issue-2349
add default language for snippet note
2 parents 168b0f8 + c844b60 commit e11a68a

File tree

7 files changed

+29
-8
lines changed

7 files changed

+29
-8
lines changed

browser/main/Detail/SnippetNoteDetail.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,12 @@ class SnippetNoteDetail extends React.Component {
573573
}
574574

575575
addSnippet () {
576+
const { config } = this.props
576577
const { note } = this.state
577578

578579
note.snippets = note.snippets.concat([{
579580
name: '',
580-
mode: 'Plain Text',
581+
mode: config.editor.snippetDefaultLanguage || 'text',
581582
content: ''
582583
}])
583584
const snippetIndex = note.snippets.length - 1

browser/main/NewNoteButton/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ class NewNoteButton extends React.Component {
3434
}
3535

3636
handleNewNoteButtonClick (e) {
37-
const { location, dispatch } = this.props
37+
const { location, dispatch, config } = this.props
3838
const { storage, folder } = this.resolveTargetFolder()
3939

4040
modal.open(NewNoteModal, {
4141
storage: storage.key,
4242
folder: folder.key,
4343
dispatch,
44-
location
44+
location,
45+
config
4546
})
4647
}
4748

browser/main/modals/NewNoteModal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class NewNoteModal extends React.Component {
6161
handleSnippetNoteButtonClick (e) {
6262
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
6363
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
64-
const { storage, folder, dispatch, location } = this.props
64+
const { storage, folder, dispatch, location, config } = this.props
6565

6666
dataApi
6767
.createNote(storage, {
@@ -72,7 +72,7 @@ class NewNoteModal extends React.Component {
7272
snippets: [
7373
{
7474
name: '',
75-
mode: 'text',
75+
mode: config.editor.snippetDefaultLanguage || 'text',
7676
content: ''
7777
}
7878
]

browser/main/modals/PreferencesModal/ConfigTab.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
line-height 30px
2525

2626
.group-section-label
27-
width 150px
27+
width 200px
2828
text-align left
2929
margin-right 10px
3030
font-size 14px

browser/main/modals/PreferencesModal/UiTab.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class UiTab extends React.Component {
8585
displayLineNumbers: this.refs.editorDisplayLineNumbers.checked,
8686
switchPreview: this.refs.editorSwitchPreview.value,
8787
keyMap: this.refs.editorKeyMap.value,
88+
snippetDefaultLanguage: this.refs.editorSnippetDefaultLanguage.value,
8889
scrollPastEnd: this.refs.scrollPastEnd.checked,
8990
fetchUrlTitle: this.refs.editorFetchUrlTitle.checked
9091
},
@@ -387,6 +388,22 @@ class UiTab extends React.Component {
387388
</div>
388389
</div>
389390

391+
<div styleName='group-section'>
392+
<div styleName='group-section-label'>
393+
{i18n.__('Snippet Default Language')}
394+
</div>
395+
<div styleName='group-section-control'>
396+
<select value={config.editor.snippetDefaultLanguage}
397+
ref='editorSnippetDefaultLanguage'
398+
onChange={(e) => this.handleUIChange(e)}
399+
>
400+
{
401+
_.sortBy(CodeMirror.modeInfo.map(mode => mode.name)).map(name => (<option key={name} value={name}>{name}</option>))
402+
}
403+
</select>
404+
</div>
405+
</div>
406+
390407
<div styleName='group-checkBoxSection'>
391408
<label>
392409
<input onChange={(e) => this.handleUIChange(e)}

locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,6 @@
175175
"Allow styles": "Allow styles",
176176
"Allow dangerous html tags": "Allow dangerous html tags",
177177
"Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.": "Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.",
178-
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠"
178+
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠",
179+
"Snippet Default Language": "Snippet Default Language"
179180
}

locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,6 @@
152152
"Allow styles": "Accepter les styles",
153153
"Allow dangerous html tags": "Accepter les tags html dangereux",
154154
"Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.": "Convertir des flèches textuelles en jolis signes. ⚠ Cela va interferérer avec les éventuels commentaires HTML dans votre Markdown.",
155-
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ Vous avez collé un lien qui référence une pièce-jointe qui n'a pas pu être récupéré dans le dossier de stockage de la note. Coller des liens qui font référence à des pièces-jointes ne fonctionne que si la source et la destination et la même. Veuillez plutôt utiliser du Drag & Drop ! ⚠"
155+
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ Vous avez collé un lien qui référence une pièce-jointe qui n'a pas pu être récupéré dans le dossier de stockage de la note. Coller des liens qui font référence à des pièces-jointes ne fonctionne que si la source et la destination et la même. Veuillez plutôt utiliser du Drag & Drop ! ⚠",
156+
"Snippet Default Language": "Langage par défaut d'un snippet"
156157
}

0 commit comments

Comments
 (0)