From 9f8246a26a2387b5dcae7e59bd8174c350cfee99 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Thu, 30 Aug 2018 17:52:50 +0200 Subject: [PATCH 1/2] add default language for snippet note --- browser/main/Detail/SnippetNoteDetail.js | 3 ++- browser/main/NewNoteButton/index.js | 5 +++-- browser/main/modals/NewNoteModal.js | 4 ++-- .../main/modals/PreferencesModal/ConfigTab.styl | 2 +- browser/main/modals/PreferencesModal/UiTab.js | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js index 652d1f53..6220b5a4 100644 --- a/browser/main/Detail/SnippetNoteDetail.js +++ b/browser/main/Detail/SnippetNoteDetail.js @@ -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 diff --git a/browser/main/NewNoteButton/index.js b/browser/main/NewNoteButton/index.js index a9b8de58..85dc7f40 100644 --- a/browser/main/NewNoteButton/index.js +++ b/browser/main/NewNoteButton/index.js @@ -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 }) } diff --git a/browser/main/modals/NewNoteModal.js b/browser/main/modals/NewNoteModal.js index b748587c..f6aa2c67 100644 --- a/browser/main/modals/NewNoteModal.js +++ b/browser/main/modals/NewNoteModal.js @@ -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: '' } ] diff --git a/browser/main/modals/PreferencesModal/ConfigTab.styl b/browser/main/modals/PreferencesModal/ConfigTab.styl index 0e5f81fb..31994d97 100644 --- a/browser/main/modals/PreferencesModal/ConfigTab.styl +++ b/browser/main/modals/PreferencesModal/ConfigTab.styl @@ -24,7 +24,7 @@ line-height 30px .group-section-label - width 150px + width 200px text-align left margin-right 10px font-size 14px diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index aa3568e7..8ad8666c 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -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 {

{i18n.__('⚠️ Please restart boostnote after you change the keymap')}

+ +
+
+ {i18n.__('Snippet Default Language')} +
+
+ +
+
- +
{i18n.__('Snippet Default Language')} @@ -398,7 +398,7 @@ class UiTab extends React.Component { onChange={(e) => this.handleUIChange(e)} > { - _.sortBy(CodeMirror.modeInfo.map(mode => mode.name)).map(name => ()) + _.sortBy(CodeMirror.modeInfo.map(mode => mode.name)).map(name => ()) }
diff --git a/locales/en.json b/locales/en.json index a9767492..ab7b33f6 100644 --- a/locales/en.json +++ b/locales/en.json @@ -175,5 +175,6 @@ "Allow styles": "Allow styles", "Allow dangerous html tags": "Allow dangerous html tags", "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.", - "⚠ 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! ⚠" + "⚠ 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! ⚠", + "Snippet Default Language": "Snippet Default Language" } diff --git a/locales/fr.json b/locales/fr.json index 8b880aa6..e5ce7314 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -152,5 +152,6 @@ "Allow styles": "Accepter les styles", "Allow dangerous html tags": "Accepter les tags html dangereux", "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.", - "⚠ 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 ! ⚠" + "⚠ 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 ! ⚠", + "Snippet Default Language": "Langage par défaut d'un snippet" }