From 9fe9e1a1c4294cf1b6364482f452a131bb341960 Mon Sep 17 00:00:00 2001 From: JianXu Date: Thu, 13 Jun 2019 20:50:09 +0800 Subject: [PATCH 01/51] Add menu item "About" to "Help" --- lib/main-menu.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/main-menu.js b/lib/main-menu.js index f20f1e90..124c6675 100644 --- a/lib/main-menu.js +++ b/lib/main-menu.js @@ -3,6 +3,7 @@ const BrowserWindow = electron.BrowserWindow const shell = electron.shell const ipc = electron.ipcMain const mainWindow = require('./main-window') +const os = require('os') const macOS = process.platform === 'darwin' // const WIN = process.platform === 'win32' @@ -411,6 +412,28 @@ const help = { click () { shell.openExternal('https://github.com/TobseF/boostnote-markdown-cheatsheet/blob/master/BOOSTNOTE_MARKDOWN_CHEAT_SHEET.md') } } ] + }, + { + type: 'separator' + }, + { + label: 'About', + click () { + const version = electron.app.getVersion() + const electronVersion = process.versions.electron + const chromeVersion = process.versions.chrome + const nodeVersion = process.versions.node + const v8Version = process.versions.v8 + const OSInfo = `${os.type()} ${os.arch()} ${os.release()}` + const detail = `Version: ${version}\nElectron: ${electronVersion}\nChrome: ${chromeVersion}\nNode.js: ${nodeVersion}\nV8: ${v8Version}\nOS: ${OSInfo}` + electron.dialog.showMessageBox(BrowserWindow.getFocusedWindow(), + { + title: 'BoostNote', + message: 'BoostNote', + type: 'info', + detail: `\n${detail}` + }) + } } ] } From 6b868658aa763b07fd8f3947f631c38c22f7624b Mon Sep 17 00:00:00 2001 From: David Thomason Date: Wed, 12 Jun 2019 18:13:03 -0400 Subject: [PATCH 02/51] Changed "insert date & time" hotkey on mac from Shift-Cmd-/ to Alt-Cmd-/ --- browser/components/CodeEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 1abd15a9..bec7711a 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -220,7 +220,7 @@ export default class CodeEditor extends React.Component { const dateNow = new Date() cm.replaceSelection(dateNow.toLocaleString()) }, - 'Shift-Cmd-/': function (cm) { + 'Alt-Cmd-/': function (cm) { if (global.process.platform !== 'darwin') { return } const dateNow = new Date() cm.replaceSelection(dateNow.toLocaleString()) From db396ec107e835107bfbf61afde2c4a0456080d4 Mon Sep 17 00:00:00 2001 From: David Thomason Date: Wed, 12 Jun 2019 19:20:23 -0400 Subject: [PATCH 03/51] Added insert date & time info to HotkeyTab settings --- browser/main/lib/ConfigManager.js | 2 ++ .../main/modals/PreferencesModal/HotkeyTab.js | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index bea019fa..21e40ace 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -31,6 +31,8 @@ export const DEFAULT_CONFIG = { toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M', deleteNote: OSX ? 'Command + Shift + Backspace' : 'Ctrl + Shift + Backspace', pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V', + insertDate: OSX ? 'Command + /' : 'Ctrl + /', + insertDateTime: OSX ? 'Command + Alt + /' : 'Ctrl + Shift + /', toggleMenuBar: 'Alt' }, ui: { diff --git a/browser/main/modals/PreferencesModal/HotkeyTab.js b/browser/main/modals/PreferencesModal/HotkeyTab.js index 713f6a65..2c528fba 100644 --- a/browser/main/modals/PreferencesModal/HotkeyTab.js +++ b/browser/main/modals/PreferencesModal/HotkeyTab.js @@ -173,6 +173,26 @@ class HotkeyTab extends React.Component { /> +
+
{i18n.__('Insert Current Date')}
+
+ +
+
+
+
{i18n.__('Insert Current Date and Time')}
+
+ +
+
+
+ +
+
Date: Tue, 11 Jun 2019 09:02:33 +0900 Subject: [PATCH 25/51] fix UI change handler --- browser/main/modals/PreferencesModal/UiTab.js | 1 + 1 file changed, 1 insertion(+) diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 30b3f40a..e26f088f 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -92,6 +92,7 @@ class UiTab extends React.Component { enableRulers: this.refs.enableEditorRulers.value === 'true', rulers: this.refs.editorRulers.value.replace(/[^0-9,]/g, '').split(','), displayLineNumbers: this.refs.editorDisplayLineNumbers.checked, + lineWrapping: this.refs.editorLineWrapping.checked, switchPreview: this.refs.editorSwitchPreview.value, keyMap: this.refs.editorKeyMap.value, snippetDefaultLanguage: this.refs.editorSnippetDefaultLanguage.value, From c83e5cc7d8e772ce7a56c4257e735ca9a42d596f Mon Sep 17 00:00:00 2001 From: amedora Date: Tue, 11 Jun 2019 08:48:17 +0900 Subject: [PATCH 26/51] add locales --- locales/da.json | 3 ++- locales/de.json | 3 ++- locales/en.json | 3 ++- locales/es-ES.json | 3 ++- locales/fa.json | 3 ++- locales/fr.json | 3 ++- locales/hu.json | 3 ++- locales/it.json | 3 ++- locales/ja.json | 3 ++- locales/ko.json | 3 ++- locales/no.json | 3 ++- locales/pl.json | 3 ++- locales/pt-BR.json | 3 ++- locales/pt-PT.json | 3 ++- locales/ru.json | 3 ++- locales/sq.json | 3 ++- locales/th.json | 3 ++- locales/tr.json | 3 ++- locales/zh-CN.json | 3 ++- locales/zh-TW.json | 3 ++- 20 files changed, 40 insertions(+), 20 deletions(-) diff --git a/locales/da.json b/locales/da.json index 79503ab3..55962cdb 100644 --- a/locales/da.json +++ b/locales/da.json @@ -156,5 +156,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/de.json b/locales/de.json index 518a4e65..22d0913a 100644 --- a/locales/de.json +++ b/locales/de.json @@ -212,5 +212,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/en.json b/locales/en.json index 1e09bfc7..0a8b8780 100644 --- a/locales/en.json +++ b/locales/en.json @@ -187,5 +187,6 @@ "Snippet Default Language": "Snippet Default Language", "New notes are tagged with the filtering tags": "New notes are tagged with the filtering tags", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/es-ES.json b/locales/es-ES.json index f8003088..9f1dc19a 100644 --- a/locales/es-ES.json +++ b/locales/es-ES.json @@ -158,5 +158,6 @@ "Spellcheck disabled": "Deshabilitar corrector ortográfico", "Show menu bar": "Mostrar barra del menú", "Auto Detect": "Detección automática", - "Snippet Default Language": "Lenguaje por defecto de los fragmentos de código" + "Snippet Default Language": "Lenguaje por defecto de los fragmentos de código", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/fa.json b/locales/fa.json index d29e0e75..311fe18d 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -160,5 +160,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/fr.json b/locales/fr.json index c44b057e..2e060ec5 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -172,5 +172,6 @@ "Snippet name": "Nom du snippet", "Snippet prefix": "Préfixe du snippet", "Delete Note": "Supprimer la note", - "New notes are tagged with the filtering tags": "Les nouvelles notes sont taggées avec les tags de filtrage" + "New notes are tagged with the filtering tags": "Les nouvelles notes sont taggées avec les tags de filtrage", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/hu.json b/locales/hu.json index 558770b9..0f6e3832 100644 --- a/locales/hu.json +++ b/locales/hu.json @@ -180,5 +180,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/it.json b/locales/it.json index 3b070197..43bc15fa 100644 --- a/locales/it.json +++ b/locales/it.json @@ -160,5 +160,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/ja.json b/locales/ja.json index e1dc553b..b5722795 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -219,5 +219,6 @@ "⚠ 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! ⚠": "⚠ このノートのストレージに存在しない添付ファイルへのリンクを貼り付けました。添付ファイルへのリンクの貼り付けは同一ストレージ内でのみサポートされています。代わりに添付ファイルをドラッグアンドドロップしてください! ⚠", "Spellcheck disabled": "スペルチェック無効", "Show menu bar": "メニューバーを表示", - "Auto Detect": "自動検出" + "Auto Detect": "自動検出", + "Wrap line in Snippet Note": "行を右端で折り返す(Snippet Note)" } diff --git a/locales/ko.json b/locales/ko.json index 3dbb1ada..d762ee15 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -163,5 +163,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/no.json b/locales/no.json index ff858153..42d17dc3 100644 --- a/locales/no.json +++ b/locales/no.json @@ -156,5 +156,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/pl.json b/locales/pl.json index ffdc14be..34f053cc 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -165,5 +165,6 @@ "Add tag...": "Dodaj tag...", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/pt-BR.json b/locales/pt-BR.json index ada02453..028f9b93 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -156,5 +156,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 159c2255..739a2181 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -155,5 +155,6 @@ "⚠ 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! ⚠": "⚠ Você colou um link referente a um anexo que não pôde ser encontrado no local de armazenamento desta nota. A vinculação de anexos de referência de links só é suportada se o local de origem e de destino for o mesmo de armazenamento. Por favor, arraste e solte o anexo na nota! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/ru.json b/locales/ru.json index 70d140ce..c71f1556 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -153,5 +153,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/sq.json b/locales/sq.json index 33d8ec97..d6104c9b 100644 --- a/locales/sq.json +++ b/locales/sq.json @@ -155,5 +155,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/th.json b/locales/th.json index ade52990..4637f735 100644 --- a/locales/th.json +++ b/locales/th.json @@ -182,5 +182,6 @@ "Snippet Default Language": "ทำการ Snippet ภาษาที่เป็นค่าเริ่มต้น", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/tr.json b/locales/tr.json index d9dd28f1..45cc0cbb 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -155,5 +155,6 @@ "Allow dangerous html tags": "Tehlikeli html etiketlerine izin ver", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 76700a7f..8b249245 100755 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -220,5 +220,6 @@ "Render newlines in Markdown paragraphs as
":"在 Markdown 段落中使用
换行", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/zh-TW.json b/locales/zh-TW.json index ec6fa80c..bdea0f16 100755 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -164,5 +164,6 @@ "⚠ 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! ⚠", "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", - "Auto Detect": "Auto Detect" + "Auto Detect": "Auto Detect", + "Wrap line in Snippet Note": "Wrap line in Snippet Note" } From e85767b4a0c268de806318b58ba0fcef65fa9f27 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Sun, 9 Jun 2019 13:28:53 +0800 Subject: [PATCH 27/51] feat: Added Context Menu for markdown preview mode and copy url when hyperlink --- browser/components/CodeEditor.js | 2 +- browser/components/MarkdownPreview.js | 33 ++------------ browser/lib/contextMenuBuilder.js | 65 ++++++++++++++++++++++++++- tests/lib/contextMenuBuilder.test.js | 12 +++++ 4 files changed, 81 insertions(+), 31 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index e209a9fd..2a4ae71b 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -20,7 +20,7 @@ import styles from '../components/CodeEditor.styl' const { ipcRenderer, remote, clipboard } = require('electron') import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily' const spellcheck = require('browser/lib/spellcheck') -const buildEditorContextMenu = require('browser/lib/contextMenuBuilder') +const buildEditorContextMenu = require('browser/lib/contextMenuBuilder').buildEditorContextMenu import TurndownService from 'turndown' import {languageMaps} from '../lib/CMLanguageList' import snippetManager from '../lib/SnippetManager' diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index 11d8dca6..ab9dd6dd 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -18,15 +18,13 @@ import mdurl from 'mdurl' import exportNote from 'browser/main/lib/dataApi/exportNote' import { escapeHtmlCharacters } from 'browser/lib/utils' import yaml from 'js-yaml' -import context from 'browser/lib/context' -import i18n from 'browser/lib/i18n' -import fs from 'fs' import { render } from 'react-dom' import Carousel from 'react-image-carousel' import ConfigManager from '../main/lib/ConfigManager' const { remote, shell } = require('electron') const attachmentManagement = require('../main/lib/dataApi/attachmentManagement') +const buildMarkdownPreviewContextMenu = require('browser/lib/contextMenuBuilder').buildMarkdownPreviewContextMenu const { app } = remote const path = require('path') @@ -34,8 +32,6 @@ const fileUrl = require('file-url') const dialog = remote.dialog -const uri2path = require('file-uri-to-path') - const markdownStyle = require('!!css!stylus?sourceMap!./markdown.styl')[0][1] const appPath = fileUrl( process.env.NODE_ENV === 'production' ? app.getAppPath() : path.resolve() @@ -250,30 +246,9 @@ export default class MarkdownPreview extends React.Component { } handleContextMenu (event) { - // If a contextMenu handler was passed to us, use it instead of the self-defined one -> return - if (_.isFunction(this.props.onContextMenu)) { - this.props.onContextMenu(event) - return - } - // No contextMenu was passed to us -> execute our own link-opener - if (event.target.tagName.toLowerCase() === 'a' && event.target.getAttribute('href')) { - const href = event.target.href - const isLocalFile = href.startsWith('file:') - if (isLocalFile) { - const absPath = uri2path(href) - try { - if (fs.lstatSync(absPath).isFile()) { - context.popup([ - { - label: i18n.__('Show in explorer'), - click: (e) => shell.showItemInFolder(absPath) - } - ]) - } - } catch (e) { - console.log('Error while evaluating if the file is locally available', e) - } - } + const menu = buildMarkdownPreviewContextMenu(this, event) + if (menu != null) { + setTimeout(() => menu.popup(remote.getCurrentWindow()), 30) } } diff --git a/browser/lib/contextMenuBuilder.js b/browser/lib/contextMenuBuilder.js index cf92f52e..c46f0dc4 100644 --- a/browser/lib/contextMenuBuilder.js +++ b/browser/lib/contextMenuBuilder.js @@ -1,6 +1,12 @@ +import i18n from 'browser/lib/i18n' +import fs from 'fs' + const {remote} = require('electron') const {Menu} = remote.require('electron') +const {clipboard} = remote.require('electron') +const {shell} = remote.require('electron') const spellcheck = require('./spellcheck') +const uri2path = require('file-uri-to-path') /** * Creates the context menu that is shown when there is a right click in the editor of a (not-snippet) note. @@ -62,4 +68,61 @@ const buildEditorContextMenu = function (editor, event) { return Menu.buildFromTemplate(template) } -module.exports = buildEditorContextMenu +/** + * Creates the context menu that is shown when there is a right click Markdown preview of a (not-snippet) note. + * @param {MarkdownPreview} markdownPreview + * @param {MouseEvent} event that has triggered the creation of the context menu + * @returns {Electron.Menu} The created electron context menu + */ +const buildMarkdownPreviewContextMenu = function (markdownPreview, event) { + if (markdownPreview == null || event == null || event.pageX == null || event.pageY == null) { + return null + } + + // Default context menu inclusions + const template = [{ + role: 'cut' + }, { + role: 'copy' + }, { + role: 'paste' + }, { + role: 'selectall' + }] + + if (event.target.tagName.toLowerCase() === 'a' && event.target.getAttribute('href')) { + // Link opener for files on the local system pointed to by href + const href = event.target.href + const isLocalFile = href.startsWith('file:') + if (isLocalFile) { + const absPath = uri2path(href) + try { + if (fs.lstatSync(absPath).isFile()) { + template.push( + { + label: i18n.__('Show in explorer'), + click: (e) => shell.showItemInFolder(absPath) + } + ) + } + } catch (e) { + console.log('Error while evaluating if the file is locally available', e) + } + } + + // Add option to context menu to copy url + template.push( + { + label: i18n.__('Copy Url'), + click: (e) => clipboard.writeText(href) + } + ) + } + return Menu.buildFromTemplate(template) +} + +module.exports = +{ + buildEditorContextMenu: buildEditorContextMenu, + buildMarkdownPreviewContextMenu: buildMarkdownPreviewContextMenu +} diff --git a/tests/lib/contextMenuBuilder.test.js b/tests/lib/contextMenuBuilder.test.js index 12ed2c32..e61d4b73 100644 --- a/tests/lib/contextMenuBuilder.test.js +++ b/tests/lib/contextMenuBuilder.test.js @@ -5,11 +5,13 @@ jest.mock('electron', () => { const spellcheck = require('browser/lib/spellcheck') const buildEditorContextMenu = require('browser/lib/contextMenuBuilder') +const buildMarkdownPreviewContextMenu = require('browser/lib/contextMenuBuilder') beforeEach(() => { menuBuilderParameter = null }) +// Editor Context Menu it('should make sure that no context menu is build if the passed editor instance was null', function () { const event = { pageX: 12, @@ -124,3 +126,13 @@ it('should make sure that word suggestions creates a correct menu if there was a expect(menuBuilderParameter[7].role).toEqual('selectall') expect(spellcheck.getSpellingSuggestion).toHaveBeenCalledWith(wordToCorrect) }) + +// Markdown Preview Context Menu +it('should make sure that no context menu is built if the Markdown Preview instance was null', function () { + const event = { + pageX: 12, + pageY: 12 + } + buildMarkdownPreviewContextMenu(null, event) + expect(menuBuilderParameter).toEqual(null) +}) From f2a02a25a79ec1f4290a8fd8bb6ae025408499ef Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Sun, 9 Jun 2019 13:56:59 +0800 Subject: [PATCH 28/51] Fixed Test Fail Issue due to incorrect Require for context menu items --- tests/lib/contextMenuBuilder.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib/contextMenuBuilder.test.js b/tests/lib/contextMenuBuilder.test.js index e61d4b73..b7009bf1 100644 --- a/tests/lib/contextMenuBuilder.test.js +++ b/tests/lib/contextMenuBuilder.test.js @@ -4,8 +4,8 @@ jest.mock('electron', () => { }) const spellcheck = require('browser/lib/spellcheck') -const buildEditorContextMenu = require('browser/lib/contextMenuBuilder') -const buildMarkdownPreviewContextMenu = require('browser/lib/contextMenuBuilder') +const buildEditorContextMenu = require('browser/lib/contextMenuBuilder').buildEditorContextMenu +const buildMarkdownPreviewContextMenu = require('browser/lib/contextMenuBuilder').buildMarkdownPreviewContextMenu beforeEach(() => { menuBuilderParameter = null From caf1f92fef424bd0a557f7e9c8e802bb60f8fdf6 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Wed, 3 Jul 2019 11:24:00 +0800 Subject: [PATCH 29/51] Removed SetTimeout on Markdown Preview Context menu --- browser/components/MarkdownPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index ab9dd6dd..ef178298 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -248,7 +248,7 @@ export default class MarkdownPreview extends React.Component { handleContextMenu (event) { const menu = buildMarkdownPreviewContextMenu(this, event) if (menu != null) { - setTimeout(() => menu.popup(remote.getCurrentWindow()), 30) + menu.popup(remote.getCurrentWindow()) } } From f88fc23e58cd73aecc819bd64e63f2265d34c019 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Wed, 3 Jul 2019 11:43:00 +0800 Subject: [PATCH 30/51] Removed Paste / Cut options from preview context menu as they are not relevant in preview mode --- browser/lib/contextMenuBuilder.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/browser/lib/contextMenuBuilder.js b/browser/lib/contextMenuBuilder.js index c46f0dc4..ff3349eb 100644 --- a/browser/lib/contextMenuBuilder.js +++ b/browser/lib/contextMenuBuilder.js @@ -81,11 +81,7 @@ const buildMarkdownPreviewContextMenu = function (markdownPreview, event) { // Default context menu inclusions const template = [{ - role: 'cut' - }, { role: 'copy' - }, { - role: 'paste' }, { role: 'selectall' }] From 2b4d20b94e4f1394b2b8ce925664c4b171ee740a Mon Sep 17 00:00:00 2001 From: Tobias Doll Date: Sun, 7 Jul 2019 19:48:55 +0200 Subject: [PATCH 31/51] Dont highlight search term if search field is emptied --- browser/main/TopBar/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js index 3d4bcf99..3fd688f1 100644 --- a/browser/main/TopBar/index.js +++ b/browser/main/TopBar/index.js @@ -71,6 +71,7 @@ class TopBar extends React.Component { this.refs.search.childNodes[0].blur dispatch(push('/searched')) e.preventDefault() + this.debouncedUpdateKeyword("") } handleKeyDown (e) { From e940253cafc2d9e065e889ee7b7e92bf8e5252be Mon Sep 17 00:00:00 2001 From: Tobias Doll Date: Sun, 7 Jul 2019 20:06:50 +0200 Subject: [PATCH 32/51] Using single quotes for empty string --- browser/main/TopBar/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js index 3fd688f1..09fd56b2 100644 --- a/browser/main/TopBar/index.js +++ b/browser/main/TopBar/index.js @@ -71,7 +71,7 @@ class TopBar extends React.Component { this.refs.search.childNodes[0].blur dispatch(push('/searched')) e.preventDefault() - this.debouncedUpdateKeyword("") + this.debouncedUpdateKeyword('') } handleKeyDown (e) { From 9f9e036c6849a3d81f6e45fc9b5a9f5ee9528c0e Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Wed, 24 Jul 2019 16:57:04 +0900 Subject: [PATCH 33/51] 0.12.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f327874..56379086 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "boost", "productName": "Boostnote", - "version": "0.11.17", + "version": "0.12.0", "main": "index.js", "description": "Boostnote", "license": "GPL-3.0", From 779766148971a9e37ec7ddc7466ab959b355ea11 Mon Sep 17 00:00:00 2001 From: Matt Gabriel Date: Wed, 24 Jul 2019 08:29:24 -0700 Subject: [PATCH 34/51] Fixed permissions --- locales/zh-CN.json | 0 locales/zh-TW.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 locales/zh-CN.json mode change 100755 => 100644 locales/zh-TW.json diff --git a/locales/zh-CN.json b/locales/zh-CN.json old mode 100755 new mode 100644 diff --git a/locales/zh-TW.json b/locales/zh-TW.json old mode 100755 new mode 100644 From 972d053c83e2179e383d054908ee9184e00dbf05 Mon Sep 17 00:00:00 2001 From: hikerpig Date: Wed, 24 Jul 2019 23:49:07 +0800 Subject: [PATCH 35/51] fix: array access error when `token.map` is null, fix #3123 --- browser/lib/markdown.js | 4 +++- tests/fixtures/markdowns.js | 8 +++++++- tests/lib/markdown-test.js | 5 +++++ tests/lib/snapshots/markdown-test.js.md | 15 +++++++++++++++ tests/lib/snapshots/markdown-test.js.snap | Bin 2301 -> 2471 bytes 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/browser/lib/markdown.js b/browser/lib/markdown.js index 2dc98121..49183442 100644 --- a/browser/lib/markdown.js +++ b/browser/lib/markdown.js @@ -289,7 +289,9 @@ class Markdown { case 'list_item_open': case 'paragraph_open': case 'table_open': - token.attrPush(['data-line', token.map[0]]) + if (token.map) { + token.attrPush(['data-line', token.map[0]]) + } } }) const result = originalRender.call(this.md.renderer, tokens, options, env) diff --git a/tests/fixtures/markdowns.js b/tests/fixtures/markdowns.js index 0ee80909..340f2ddd 100644 --- a/tests/fixtures/markdowns.js +++ b/tests/fixtures/markdowns.js @@ -104,6 +104,11 @@ Term 2 with *inline markup* ` const shortcuts = 'Ctrl\n\n[[Ctrl]]' +const footnote = ` +^[hello-world] +hello-world: https://github.com/BoostIO/Boostnote/ +` + export default { basic, codeblock, @@ -115,5 +120,6 @@ export default { subTexts, supTexts, deflists, - shortcuts + shortcuts, + footnote } diff --git a/tests/lib/markdown-test.js b/tests/lib/markdown-test.js index 46ae5941..31ffc518 100644 --- a/tests/lib/markdown-test.js +++ b/tests/lib/markdown-test.js @@ -68,3 +68,8 @@ test('Markdown.render() should render shortcuts correctly', t => { const rendered = md.render(markdownFixtures.shortcuts) t.snapshot(rendered) }) + +test('Markdown.render() should render footnote correctly', t => { + const rendered = md.render(markdownFixtures.footnote) + t.snapshot(rendered) +}) diff --git a/tests/lib/snapshots/markdown-test.js.md b/tests/lib/snapshots/markdown-test.js.md index 56c4466f..4111c2f2 100644 --- a/tests/lib/snapshots/markdown-test.js.md +++ b/tests/lib/snapshots/markdown-test.js.md @@ -4,6 +4,21 @@ The actual snapshot is saved in `markdown-test.js.snap`. Generated by [AVA](https://ava.li). +## Markdown.render() should render footnote correctly + +> Snapshot 1 + + `

[1]
␊ + hello-world: https://github.com/BoostIO/Boostnote/

␊ +
␊ +
␊ +
    ␊ +
  1. hello-world ↩︎

    ␊ +
  2. ␊ +
␊ +
␊ + ` + ## Markdown.render() should render line breaks correctly > Snapshot 1 diff --git a/tests/lib/snapshots/markdown-test.js.snap b/tests/lib/snapshots/markdown-test.js.snap index 67d43616d4a6a971121a41c67b649aab3983da83..3f5ec41c0d4710ca98ea132da2e1ca9c30ff7799 100644 GIT binary patch literal 2471 zcmV;Y30U?)RzVr=7)FxiPRiiN_u!mDdGJb&Z0vtO$`cTYi{Jg_v7fA6_lGS-DShSMLgCbvV^L_`bN%NF|9Im=m%s4Pkd(gfzT}yJ=gWt# zpR8Uw@$@6!bEoDvJnsxi>9zEE2cFI64?n%`cYnOF{!j0mZhZbph*d~$tS=NAuRnS7 z=GTW8e>O_jJo~FRPZXte(}qIfudlv(AiZmx@w)9-jAJIrHZ5)Ppbo z`i-~j&;9NG=d<-IbyYS)p-fBdJXpSk+lM<4vu zg{e;-zgCpe!=ES=h6*2$%oX2XxOeEGH8rP#T)VE!5YM7MQ8`t2QX27qa-tv`bF6x9 zKM&^#ViLt@4+nZQ85$&@P#bCs>c&EVg*sTJnuej< zp4-!fu|8dxb-5FpGJNT2??J8YU0ZaUt~TM(*jA4$2bLSm%D8tzx8qO@Ikcd(1#QHB zxE&>J(ZCqS?BbD*jvLv7h$uln73^>G-fZlLalgg}|gS}Vp zcG7UXq)tM1@kEA!N!pnogo`->?Z|1hi*SwvZWuyaGBoXYG?@?_hO|x|*}=GL!MxkS zEXQ5QWmm`+X*){WMSA(>;Pg_-FHY#9>GG1dtm*#2eTQN|JWOnnR(A)po*OxX>FT$} zL@H&{UQ)(7$?7zTv^MsU5C-|>53fNZA!JcqL@)|tMdcUc?0`^?k!QO`<@GN-0 zF`J;i9|w>mv%A-bSgC0XjMHO38az(==-_eMF*9?fxl1t~cKKv%4(?}uE9rtbGq&^S zzT=89z36gI*kFtmrpugV;W4fld$0vNBWGXr~%nDfQ?o$T5qK}NGL*OfQ0}&5W|+vx}2%AvFJFYr;Kiw zf-noDnPTXvgC0M!3#siKfGuDq_RKkAaa2c}+LLJ0cA!Hjw`^+~5MgAnOxe~?24xd>d=Hw$3n&mD2aq2k5HPw3->zZRH2ALh)TqN7m9j9ExrX0< zi`sAV?Kjqbr%%QyG%O1?)q~zRIE)7@9BcsIME_P{%+*2`Z1;Ms5h?Krz z_)uyh5u{BTIQC$fS$);uk44)4pc0;iO^~Ht^{tuD*kEsrz?`Z7hduN`TPoe9%o?0$d#)pT8?|{Q_b!z_V)S^|X4PdTZ9T`jLn*X<8^cL%EbwTq%YRala zSuosx#z0{nn>phJs3o|{`$}0qY40K$8y&8cJ5ypj8F*=!szTAdO|6zHl`6F5nHuTR zPaTDQC!b#0I&e-!?iq0iVNe5b75

B)+T2=fbuxV`)on6S;$*J6Mmo&)~ITx`85c z@_*06Y9^5R{|WTJm_YyfCtIierqHfQ(?B?mno~gPUQYacp;mK)Fy@Fahw$HWh}AUd zk|GP?)<0EOpgu-N11TVOr`YU+k5Z-l)z1Jwsdm<1Rr;IAcpMsJNv<(!6#Bv*Hk(Y7+q59Z`!!)4V$Xu3zXV7OT^K3NZ zLQy_LOept*h(gT}`-(ABok+3!a5mZMo=7{n-bLbw)wgq#HE5Ho5`N0PsCzr8VJ~Vp z097Bai8`1&0$0?-`N4Q;sD%q@)P=JoFr+34FYBYzj6`$ljVnKvs+&bg4H3TReA z(-tYf=G`iAf}JMJ7b-Rvt#s8v1f6RgU6V6w-ouzo zFtAO5F`i{ObOb`z+|x_ly_JKMStk2>5>~Bg+QtNDUQH8kY0&xIppQ~!om?yC=7QK; zA>p(x5-3eB(HUuUU2;6o2r9|m)d)ZUMkgvKlS>V`9Fu9}5YMCPqDVK}(4E~GD#ohR z5|?3ewUi4vQX>*7^1=!7wj?>PA!Y*gdJScsNOs<&kI>mXA+Fftjaq1Q^%8XxBzfsE lGqKf_T;96;{o5~G>2x67eW_STS{ksi_MfXTBG{lC005BY)zAO{ literal 2301 zcmVqUbD-eIJVm00000000y1 zSZ|EnMit*ZkT}u`)Hade6H_B4qKVhL-o49S;V;Uyx7{{ZNU5gc?Cr_>hW5AQd50%7<1+Ab2zD{bR3v zT*9AEtmNI<_viQCym|BHjT_}s>5kHC(>q?g{;Ts}tG#eTiT}Q`9fp4}H8eD2QQ{qgbbe|q=P&gY*2Upe*q_EM?y`ZG6f ze7({8>1;6l{4d{pxGboI>!t?&C=iY2AeCm~7 zzwws!x!-?PDhuiZ9|MoxF1_@Fm;dsOr}5vOymIBYaamBGhi9tvArYVQ2TONP-8Ze- zHRM<=X^FUI;1QVx^1&d8m>)1AAqz7syN*voKl(|<^?3%t!vsD4pb{(@T z+k^@vVmVCqFzs4F&rhMLk}gCM7v+Fl6b(etpTBeED*&tlu+yO!Z1xgoe07os(9c4|+WRB2efDjoU_8XrV+)1gx)xxK^RFwd!qodw7i}1#CFI9r!S2 zeJ46J@Q@ZU8u-ilKt@v%LTVcpuVJlrTP}T?Y#0Hiu#R>>nHe(()qsYEv|_93?OOG4 z7|D(=ABKVuP}vJCA}n({a(vXMBTg^2UccR>VR&7hhw9?;3Ij zl<$Ng@cK(L^hXf|!KO$V)sX{~IVR-Y0czULTBf=}wMh6V;q&tH&EoP>%Wh7XqT#TL zyP>GwiDM^YKzxu`ysRGfmt7~ai^G+-$9O5FLSKZ8j*8WzBvOXhr$X#+hOOr9h)u9f ze}vt(dGRVgGJSf@@SU1)V4a@)QSmydv&HLl zU}@=G_mHID@38sUD4u8bC>et|*F1Ro*k>huvF9*GXfehn>9S&)xXC2_2sYtl47%uk z8pL5XGO5PlBV{dwgWGg*6tyH1HX~}o*Kvo^fM)xKZ7BI@5d?jp)PZX1!$B+QgHdG# z3JMn~(BOa%#Bik3F=O&_%qI@zDJ455z}0-ACh2NoV8V`=LZZ6@U~8E2GjoNQ47Jd% zVG`}y58>d#16@slKUA&QTQ}FU=&^9sKbAiPNAV56qLw$&V zK!YB9JG!YU@U3})-hxpeXkkKgbZ_A8TC=4I22TzP<?}W0Ijg=!BQy5TuD! zb#Lm^EVf1o7Y#|42s}ZYJsx!@*#@@NXr#Trsxmu~sH5!duh+()jF>h;P(U!yt zB3G@?H2dLN{kLG$LDcEioMuI0(w0bRFr1$;(3rKKP4_;zUa8gUz{^HzW=uXY6y_$MTG?BeQ;~CyUqUGK08EBIWES!7I`SCT z&5c;X$s8iL@N*0MG4mmQ?u!w^=;ozwedhFu#ltr*U4?6Mn9)=>(cHNj2W-Dk z?hkYH7Yg;6O;E?75ks6+(F}3380SXB416nLPaq%JD)QDbr>>U0o%`t6SMij^my6H%r4?r ztlY`XYrqq`5`LJ=u5t91_FKuJQ zMx344v+F`v)XkcdG0v%|29kA6DXxQN9#*UG-(9NFYD)&xQ`K~QrM z=28eM9zdjo`0KK9DI<|mgu`L>g_1B=Pjcv@h-WGYYC3MSNfgxLDAbyphJnAl$oQdF zv!Mxv!;|q*2Og^k?&dbqh^IR~=ZW{+JZ*rIZ?`dNw~-E2-!8v;imR)R(0LT`m-GDJ z9u#8AP|!i+D(J%C>e|1vW-T;Dfq`QRl<_jfq0JG-a!;*{&sHo_YMUIJC|Fw8u=F;g XuBPx&;&k>j$PxM{Wy)f%+8F=<3N?BD From 71d27d0e551021f6a9c75fc7d90948d105e25570 Mon Sep 17 00:00:00 2001 From: amedora Date: Thu, 25 Jul 2019 10:43:07 +0900 Subject: [PATCH 36/51] MarkdownEditor and MarkdownSplitEditor always wrap lines --- browser/components/MarkdownEditor.js | 1 + browser/components/MarkdownSplitEditor.js | 1 + 2 files changed, 2 insertions(+) diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index e956655c..7077c5dc 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -304,6 +304,7 @@ class MarkdownEditor extends React.Component { enableRulers={config.editor.enableRulers} rulers={config.editor.rulers} displayLineNumbers={config.editor.displayLineNumbers} + lineWrapping matchingPairs={config.editor.matchingPairs} matchingTriples={config.editor.matchingTriples} explodingPairs={config.editor.explodingPairs} diff --git a/browser/components/MarkdownSplitEditor.js b/browser/components/MarkdownSplitEditor.js index 2b63d345..deb9d89b 100644 --- a/browser/components/MarkdownSplitEditor.js +++ b/browser/components/MarkdownSplitEditor.js @@ -160,6 +160,7 @@ class MarkdownSplitEditor extends React.Component { fontFamily={config.editor.fontFamily} fontSize={editorFontSize} displayLineNumbers={config.editor.displayLineNumbers} + lineWrapping matchingPairs={config.editor.matchingPairs} matchingTriples={config.editor.matchingTriples} explodingPairs={config.editor.explodingPairs} From fa65e7feef406b7077554989ac96913bbfb2bdff Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 08:49:07 +0900 Subject: [PATCH 37/51] Fix isTagActive --- browser/main/SideNav/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/SideNav/index.js b/browser/main/SideNav/index.js index fc665052..6a978979 100644 --- a/browser/main/SideNav/index.js +++ b/browser/main/SideNav/index.js @@ -440,7 +440,7 @@ class SideNav extends React.Component { const style = {} if (!isFolded) style.width = this.props.width - const isTagActive = location.pathname.match(/tag/) + const isTagActive = !!location.pathname.match(/tag/) return (

Date: Fri, 26 Jul 2019 08:49:21 +0900 Subject: [PATCH 38/51] Discard unused props --- browser/components/SideNavFilter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/browser/components/SideNavFilter.js b/browser/components/SideNavFilter.js index 3a259ce7..291700cf 100644 --- a/browser/components/SideNavFilter.js +++ b/browser/components/SideNavFilter.js @@ -73,8 +73,7 @@ SideNavFilter.propTypes = { handleAllNotesButtonClick: PropTypes.func.isRequired, isStarredActive: PropTypes.bool.isRequired, isTrashedActive: PropTypes.bool.isRequired, - handleStarredButtonClick: PropTypes.func.isRequired, - handleTrashdButtonClick: PropTypes.func.isRequired + handleStarredButtonClick: PropTypes.func.isRequired } export default CSSModules(SideNavFilter, styles) From c8a2baca3c8531fd3c6f418b4a284eba49793fd9 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 08:49:52 +0900 Subject: [PATCH 39/51] Use default value prop rather than value prop --- browser/main/Detail/InfoPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/Detail/InfoPanel.js b/browser/main/Detail/InfoPanel.js index 8fe0a855..86b5ae86 100644 --- a/browser/main/Detail/InfoPanel.js +++ b/browser/main/Detail/InfoPanel.js @@ -60,7 +60,7 @@ class InfoPanel extends React.Component {
- { e.target.select() }} /> + { e.target.select() }} /> From 1c8af47bac978e9fc1652117805bfcdace62b1cd Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 08:50:12 +0900 Subject: [PATCH 40/51] Fix warnings in ToggleModeButton --- browser/main/Detail/ToggleModeButton.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/browser/main/Detail/ToggleModeButton.js b/browser/main/Detail/ToggleModeButton.js index fcbaab34..5fd3a3c5 100644 --- a/browser/main/Detail/ToggleModeButton.js +++ b/browser/main/Detail/ToggleModeButton.js @@ -8,11 +8,11 @@ const ToggleModeButton = ({ onClick, editorType }) => (
-
onClick('SPLIT')}> - +
onClick('SPLIT')}> +
-
onClick('EDITOR_PREVIEW')}> - +
onClick('EDITOR_PREVIEW')}> +
{i18n.__('Toggle Mode')}
@@ -20,7 +20,7 @@ const ToggleModeButton = ({ ToggleModeButton.propTypes = { onClick: PropTypes.func.isRequired, - editorType: PropTypes.string.Required + editorType: PropTypes.string } export default CSSModules(ToggleModeButton, styles) From 410b611b14ee5cc0ae8fa282f1ba1e42be3aaa37 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 09:03:32 +0900 Subject: [PATCH 41/51] Discard all style warnings --- browser/components/MarkdownSplitEditor.js | 2 -- browser/main/Detail/FullscreenButton.js | 2 +- browser/main/Detail/MarkdownNoteDetail.js | 4 ++-- browser/main/Detail/PermanentDeleteButton.js | 2 +- browser/main/Detail/TrashButton.js | 2 +- browser/main/NewNoteButton/index.js | 2 +- browser/main/NoteList/index.js | 4 ++-- browser/main/SideNav/PreferenceButton.js | 2 +- browser/main/SideNav/StorageItem.js | 6 +++--- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/browser/components/MarkdownSplitEditor.js b/browser/components/MarkdownSplitEditor.js index deb9d89b..af8b0e11 100644 --- a/browser/components/MarkdownSplitEditor.js +++ b/browser/components/MarkdownSplitEditor.js @@ -150,7 +150,6 @@ class MarkdownSplitEditor extends React.Component { onMouseMove={e => this.handleMouseMove(e)} onMouseUp={e => this.handleMouseUp(e)}> onClick(e)}> - + {i18n.__('Fullscreen')}({hotkey}) ) diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index 9d05d4a3..45024751 100755 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -450,7 +450,7 @@ class MarkdownNoteDetail extends React.Component { const detailTopBar =
-
+
this.handleFocus(e)} onMouseDown={(e) => this.handleLockButtonMouseDown(e)} > - + {this.state.isLocked ? Unlock : Lock} diff --git a/browser/main/Detail/PermanentDeleteButton.js b/browser/main/Detail/PermanentDeleteButton.js index fa00ef17..7c27ede1 100644 --- a/browser/main/Detail/PermanentDeleteButton.js +++ b/browser/main/Detail/PermanentDeleteButton.js @@ -10,7 +10,7 @@ const PermanentDeleteButton = ({ ) diff --git a/browser/main/Detail/TrashButton.js b/browser/main/Detail/TrashButton.js index d26be66e..8ca27ce9 100644 --- a/browser/main/Detail/TrashButton.js +++ b/browser/main/Detail/TrashButton.js @@ -10,7 +10,7 @@ const TrashButton = ({ ) diff --git a/browser/main/NewNoteButton/index.js b/browser/main/NewNoteButton/index.js index 115d9530..27e2baa5 100644 --- a/browser/main/NewNoteButton/index.js +++ b/browser/main/NewNoteButton/index.js @@ -90,7 +90,7 @@ class NewNoteButton extends React.Component {
diff --git a/browser/main/SideNav/PreferenceButton.js b/browser/main/SideNav/PreferenceButton.js index 187171f4..187bc41a 100644 --- a/browser/main/SideNav/PreferenceButton.js +++ b/browser/main/SideNav/PreferenceButton.js @@ -8,7 +8,7 @@ const PreferenceButton = ({ onClick }) => ( ) diff --git a/browser/main/SideNav/StorageItem.js b/browser/main/SideNav/StorageItem.js index 74881b9e..5cd4a491 100644 --- a/browser/main/SideNav/StorageItem.js +++ b/browser/main/SideNav/StorageItem.js @@ -362,14 +362,14 @@ class StorageItem extends React.Component { }
{this.state.isOpen && -
+
{folderList}
} From f3e2205e698757b797755c0875281cd8c436c486 Mon Sep 17 00:00:00 2001 From: hikerpig Date: Sat, 20 Jul 2019 23:53:14 +0800 Subject: [PATCH 42/51] fix several propType errors raised by 'react.development.js' some are caused by typo, some are caused by unused propType declarations --- browser/components/NoteItem.js | 7 +++---- browser/components/SideNavFilter.js | 2 +- browser/components/TodoProcess.js | 4 ++-- browser/main/Detail/ToggleModeButton.js | 2 +- browser/main/SideNav/index.js | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/browser/components/NoteItem.js b/browser/components/NoteItem.js index 625bb38d..9ef691da 100644 --- a/browser/components/NoteItem.js +++ b/browser/components/NoteItem.js @@ -148,15 +148,14 @@ NoteItem.propTypes = { tags: PropTypes.array, isStarred: PropTypes.bool.isRequired, isTrashed: PropTypes.bool.isRequired, - blog: { + blog: PropTypes.shape({ blogLink: PropTypes.string, blogId: PropTypes.number - } + }) }), handleNoteClick: PropTypes.func.isRequired, handleNoteContextMenu: PropTypes.func.isRequired, - handleDragStart: PropTypes.func.isRequired, - handleDragEnd: PropTypes.func.isRequired + handleDragStart: PropTypes.func.isRequired } export default CSSModules(NoteItem, styles) diff --git a/browser/components/SideNavFilter.js b/browser/components/SideNavFilter.js index 3a259ce7..5d5d627f 100644 --- a/browser/components/SideNavFilter.js +++ b/browser/components/SideNavFilter.js @@ -74,7 +74,7 @@ SideNavFilter.propTypes = { isStarredActive: PropTypes.bool.isRequired, isTrashedActive: PropTypes.bool.isRequired, handleStarredButtonClick: PropTypes.func.isRequired, - handleTrashdButtonClick: PropTypes.func.isRequired + handleTrashedButtonClick: PropTypes.func.isRequired } export default CSSModules(SideNavFilter, styles) diff --git a/browser/components/TodoProcess.js b/browser/components/TodoProcess.js index 251fd5b9..9d1f93cf 100644 --- a/browser/components/TodoProcess.js +++ b/browser/components/TodoProcess.js @@ -25,10 +25,10 @@ const TodoProcess = ({ ) TodoProcess.propTypes = { - todoStatus: { + todoStatus: PropTypes.exact({ total: PropTypes.number.isRequired, completed: PropTypes.number.isRequired - } + }) } export default CSSModules(TodoProcess, styles) diff --git a/browser/main/Detail/ToggleModeButton.js b/browser/main/Detail/ToggleModeButton.js index fcbaab34..4d090ead 100644 --- a/browser/main/Detail/ToggleModeButton.js +++ b/browser/main/Detail/ToggleModeButton.js @@ -20,7 +20,7 @@ const ToggleModeButton = ({ ToggleModeButton.propTypes = { onClick: PropTypes.func.isRequired, - editorType: PropTypes.string.Required + editorType: PropTypes.string.isRequired } export default CSSModules(ToggleModeButton, styles) diff --git a/browser/main/SideNav/index.js b/browser/main/SideNav/index.js index fc665052..9d18a72c 100644 --- a/browser/main/SideNav/index.js +++ b/browser/main/SideNav/index.js @@ -440,7 +440,7 @@ class SideNav extends React.Component { const style = {} if (!isFolded) style.width = this.props.width - const isTagActive = location.pathname.match(/tag/) + const isTagActive = /tag/.test(location.pathname) return (
Date: Fri, 26 Jul 2019 11:32:07 +0900 Subject: [PATCH 43/51] Fix style of FolderItem --- browser/main/modals/PreferencesModal/FolderItem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/browser/main/modals/PreferencesModal/FolderItem.js b/browser/main/modals/PreferencesModal/FolderItem.js index e6bd1e37..648db4e6 100644 --- a/browser/main/modals/PreferencesModal/FolderItem.js +++ b/browser/main/modals/PreferencesModal/FolderItem.js @@ -225,7 +225,7 @@ class FolderItem extends React.Component {
- {folder.name} + {folder.name} ({folder.key})
@@ -288,10 +288,10 @@ class Handle extends React.Component { class SortableFolderItemComponent extends React.Component { render () { - const StyledHandle = CSSModules(Handle, this.props.styles) + const StyledHandle = CSSModules(Handle, styles) const DragHandle = SortableHandle(StyledHandle) - const StyledFolderItem = CSSModules(FolderItem, this.props.styles) + const StyledFolderItem = CSSModules(FolderItem, styles) return (
From bc1e837466cbf6f87fdf8a06574a1780c87d88c3 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 11:32:41 +0900 Subject: [PATCH 44/51] Set alias to stylus mode inof --- browser/lib/customMeta.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/browser/lib/customMeta.js b/browser/lib/customMeta.js index 0d4ee1e3..b890cf55 100644 --- a/browser/lib/customMeta.js +++ b/browser/lib/customMeta.js @@ -1,5 +1,10 @@ import CodeMirror from 'codemirror' import 'codemirror-mode-elixir' -CodeMirror.modeInfo.push({name: 'Stylus', mime: 'text/x-styl', mode: 'stylus', ext: ['styl'], alias: ['styl']}) +const stylusCodeInfo = CodeMirror.modeInfo.find(info => info.name === 'Stylus') +if (stylusCodeInfo == null) { + CodeMirror.modeInfo.push({name: 'Stylus', mime: 'text/x-styl', mode: 'stylus', ext: ['styl'], alias: ['styl']}) +} else { + stylusCodeInfo.alias = ['styl'] +} CodeMirror.modeInfo.push({name: 'Elixir', mime: 'text/x-elixir', mode: 'elixir', ext: ['ex']}) From e425417d68cf8a2d46ba9e03e6769546f3e7302b Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 11:33:05 +0900 Subject: [PATCH 45/51] Load bfm mode info script only once --- lib/main.development.html | 1 - lib/main.production.html | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/main.development.html b/lib/main.development.html index 38e2cea9..cbcda295 100644 --- a/lib/main.development.html +++ b/lib/main.development.html @@ -110,7 +110,6 @@ - diff --git a/lib/main.production.html b/lib/main.production.html index ffd9eec3..cab38981 100644 --- a/lib/main.production.html +++ b/lib/main.production.html @@ -105,7 +105,6 @@ - From 4b62e9325728a22c39a149f8079ec941a81391d4 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 11:37:07 +0900 Subject: [PATCH 46/51] Fix more style warnings --- browser/components/ModalEscButton.js | 2 +- browser/components/SnippetTab.js | 2 +- browser/main/Detail/SnippetNoteDetail.js | 2 +- browser/main/modals/PreferencesModal/FolderList.js | 2 +- browser/main/modals/PreferencesModal/index.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/browser/components/ModalEscButton.js b/browser/components/ModalEscButton.js index 836c0052..39129d18 100644 --- a/browser/components/ModalEscButton.js +++ b/browser/components/ModalEscButton.js @@ -8,7 +8,7 @@ const ModalEscButton = ({ }) => ( ) diff --git a/browser/components/SnippetTab.js b/browser/components/SnippetTab.js index c030351f..d29130c7 100644 --- a/browser/components/SnippetTab.js +++ b/browser/components/SnippetTab.js @@ -114,7 +114,7 @@ class SnippetTab extends React.Component { > {snippet.name.trim().length > 0 ? snippet.name - : + : {i18n.__('Unnamed')} } diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js index 31a28c35..2ae01082 100644 --- a/browser/main/Detail/SnippetNoteDetail.js +++ b/browser/main/Detail/SnippetNoteDetail.js @@ -808,7 +808,7 @@ class SnippetNoteDetail extends React.Component { const detailTopBar =
-
+
+
{folderList.length > 0 ? folderList :
{i18n.__('No Folders')}
diff --git a/browser/main/modals/PreferencesModal/index.js b/browser/main/modals/PreferencesModal/index.js index f3fc3751..86957083 100644 --- a/browser/main/modals/PreferencesModal/index.js +++ b/browser/main/modals/PreferencesModal/index.js @@ -147,7 +147,7 @@ class Preferences extends React.Component { key={tab.target} onClick={(e) => this.handleNavButtonClick(tab.target)(e)} > - + {tab.label} {isUiHotkeyTab ? this.haveToSaveNotif(tab[tab.label].type, tab[tab.label].message) : null} From ed427130a910b2081c79a2761b21c8685ce60d60 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 11:51:51 +0900 Subject: [PATCH 47/51] 0.12.1-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 56379086..c86f443e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "boost", "productName": "Boostnote", - "version": "0.12.0", + "version": "0.12.1-0", "main": "index.js", "description": "Boostnote", "license": "GPL-3.0", From 484b003b34c74b33e2b5b955796c7bc0e765e570 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 13:04:53 +0900 Subject: [PATCH 48/51] Fix theme paths --- browser/components/MarkdownPreview.js | 10 +++++----- browser/lib/consts.js | 9 ++++----- browser/main/lib/ConfigManager.js | 4 ++-- browser/main/modals/PreferencesModal/UiTab.js | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index ef178298..ed13099f 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -325,7 +325,7 @@ export default class MarkdownPreview extends React.Component { body, this.props.storagePath ) - const files = [this.GetCodeThemeLink(codeBlockTheme), ...CSS_FILES] + const files = [this.getCodeThemeLink(codeBlockTheme), ...CSS_FILES] files.forEach(file => { if (global.process.platform === 'win32') { file = file.replace('file:///', '') @@ -637,7 +637,7 @@ export default class MarkdownPreview extends React.Component { this.getWindow().document.getElementById( 'codeTheme' - ).href = this.GetCodeThemeLink(codeBlockTheme) + ).href = this.getCodeThemeLink(codeBlockTheme) this.getWindow().document.getElementById('style').innerHTML = buildStyle( fontFamily, fontSize, @@ -650,11 +650,11 @@ export default class MarkdownPreview extends React.Component { ) } - GetCodeThemeLink (name) { + getCodeThemeLink (name) { const theme = consts.THEMES.find(theme => theme.name === name) - return theme - ? (win ? theme.path : `${appPath}/${theme.path}`) + return theme != null + ? theme.path : `${appPath}/node_modules/codemirror/theme/elegant.css` } diff --git a/browser/lib/consts.js b/browser/lib/consts.js index 3603c202..ed497376 100644 --- a/browser/lib/consts.js +++ b/browser/lib/consts.js @@ -19,7 +19,7 @@ const themes = paths return { name, - path: path.join(directory.split(/\//g).slice(-3).join('/'), file), + path: path.join(directory, file), className: `cm-s-${name}` } })) @@ -28,17 +28,16 @@ const themes = paths themes.splice(themes.findIndex(({ name }) => name === 'solarized'), 1, { name: 'solarized dark', - path: `${CODEMIRROR_THEME_PATH}/solarized.css`, + path: path.join(paths[0], 'solarized.css'), className: `cm-s-solarized cm-s-dark` }, { name: 'solarized light', - path: `${CODEMIRROR_THEME_PATH}/solarized.css`, + path: path.join(paths[0], 'solarized.css'), className: `cm-s-solarized cm-s-light` }) - themes.splice(0, 0, { name: 'default', - path: `${CODEMIRROR_THEME_PATH}/elegant.css`, + path: path.join(paths[0], 'elegant.css'), className: `cm-s-default` }) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 1ef27d5e..e13cdbc1 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -143,7 +143,7 @@ function get () { const theme = consts.THEMES.find(theme => theme.name === config.editor.theme) if (theme) { - editorTheme.setAttribute('href', win ? theme.path : `../${theme.path}`) + editorTheme.setAttribute('href', theme.path) } else { config.editor.theme = 'default' } @@ -191,7 +191,7 @@ function set (updates) { const newTheme = consts.THEMES.find(theme => theme.name === newConfig.editor.theme) if (newTheme) { - editorTheme.setAttribute('href', win ? newTheme.path : `../${newTheme.path}`) + editorTheme.setAttribute('href', newTheme.path) } ipcRenderer.send('config-renew', { diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index e26f088f..cff063ff 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -14,7 +14,7 @@ import { getLanguages } from 'browser/lib/Languages' import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily' const OSX = global.process.platform === 'darwin' -const win = global.process.platform === 'win32' +const WIN = global.process.platform === 'win32' const electron = require('electron') const ipc = electron.ipcRenderer @@ -137,7 +137,7 @@ class UiTab extends React.Component { const theme = consts.THEMES.find(theme => theme.name === newCodemirrorTheme) if (theme) { - checkHighLight.setAttribute('href', win ? theme.path : `../${theme.path}`) + checkHighLight.setAttribute('href', theme.path) } } From 93b8ef35f7228532cbf8bde1bca92c0c8fae8deb Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 13:50:44 +0900 Subject: [PATCH 49/51] 0.12.1-1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c86f443e..fd29b286 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "boost", "productName": "Boostnote", - "version": "0.12.1-0", + "version": "0.12.1-1", "main": "index.js", "description": "Boostnote", "license": "GPL-3.0", From 329066719e3964d5447e4d3d56c4e16f80021d82 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Sat, 27 Jul 2019 11:51:40 +0900 Subject: [PATCH 50/51] 0.12.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd29b286..e5c78247 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "boost", "productName": "Boostnote", - "version": "0.12.1-1", + "version": "0.12.1", "main": "index.js", "description": "Boostnote", "license": "GPL-3.0", From 606be4304d75552a8c4d7d9e334e8e10d3dbae56 Mon Sep 17 00:00:00 2001 From: amedora <32722363+amedora@users.noreply.github.com> Date: Sat, 27 Jul 2019 12:39:12 +0900 Subject: [PATCH 51/51] Fix 3007 (#3028) * fix code fences never sanitized * fix mermaid xss * Revert "fix mermaid xss" This reverts commit 1ff179a1bde88fd20f8956871d367c7d490ec160. * configuable mermaid HTML label * add locales for mermaid configuration --- browser/components/MarkdownEditor.js | 1 + browser/components/MarkdownPreview.js | 6 ++++-- browser/components/MarkdownSplitEditor.js | 1 + browser/components/render/MermaidRender.js | 5 +++-- browser/lib/markdown-it-sanitize-html.js | 2 +- browser/main/lib/ConfigManager.js | 2 ++ browser/main/modals/PreferencesModal/UiTab.js | 11 +++++++++++ locales/da.json | 1 + locales/de.json | 1 + locales/en.json | 1 + locales/es-ES.json | 1 + locales/fa.json | 1 + locales/fr.json | 1 + locales/hu.json | 1 + locales/it.json | 1 + locales/ja.json | 1 + locales/ko.json | 1 + locales/no.json | 1 + locales/pl.json | 1 + locales/pt-BR.json | 1 + locales/pt-PT.json | 1 + locales/ru.json | 1 + locales/sq.json | 1 + locales/th.json | 1 + locales/tr.json | 1 + locales/zh-CN.json | 1 + locales/zh-TW.json | 1 + 27 files changed, 43 insertions(+), 5 deletions(-) diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index 7077c5dc..3dd57f70 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -341,6 +341,7 @@ class MarkdownEditor extends React.Component { smartArrows={config.preview.smartArrows} breaks={config.preview.breaks} sanitize={config.preview.sanitize} + mermaidHTMLLabel={config.preview.mermaidHTMLLabel} ref='preview' onContextMenu={(e) => this.handleContextMenu(e)} onDoubleClick={(e) => this.handleDoubleClick(e)} diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index ed13099f..0072e403 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -560,6 +560,7 @@ export default class MarkdownPreview extends React.Component { if ( prevProps.smartQuotes !== this.props.smartQuotes || prevProps.sanitize !== this.props.sanitize || + prevProps.mermaidHTMLLabel !== this.props.mermaidHTMLLabel || prevProps.smartArrows !== this.props.smartArrows || prevProps.breaks !== this.props.breaks || prevProps.lineThroughCheckbox !== this.props.lineThroughCheckbox @@ -681,7 +682,8 @@ export default class MarkdownPreview extends React.Component { showCopyNotification, storagePath, noteKey, - sanitize + sanitize, + mermaidHTMLLabel } = this.props let { value, codeBlockTheme } = this.props @@ -823,7 +825,7 @@ export default class MarkdownPreview extends React.Component { _.forEach( this.refs.root.contentWindow.document.querySelectorAll('.mermaid'), el => { - mermaidRender(el, htmlTextHelper.decodeEntities(el.innerHTML), theme) + mermaidRender(el, htmlTextHelper.decodeEntities(el.innerHTML), theme, mermaidHTMLLabel) } ) diff --git a/browser/components/MarkdownSplitEditor.js b/browser/components/MarkdownSplitEditor.js index af8b0e11..b283228c 100644 --- a/browser/components/MarkdownSplitEditor.js +++ b/browser/components/MarkdownSplitEditor.js @@ -199,6 +199,7 @@ class MarkdownSplitEditor extends React.Component { smartArrows={config.preview.smartArrows} breaks={config.preview.breaks} sanitize={config.preview.sanitize} + mermaidHTMLLabel={config.preview.mermaidHTMLLabel} ref='preview' tabInde='0' value={value} diff --git a/browser/components/render/MermaidRender.js b/browser/components/render/MermaidRender.js index e28e06ea..d9ea549b 100644 --- a/browser/components/render/MermaidRender.js +++ b/browser/components/render/MermaidRender.js @@ -19,7 +19,7 @@ function getId () { return id } -function render (element, content, theme) { +function render (element, content, theme, enableHTMLLabel) { try { const height = element.attributes.getNamedItem('data-height') if (height && height.value !== 'undefined') { @@ -29,7 +29,8 @@ function render (element, content, theme) { mermaidAPI.initialize({ theme: isDarkTheme ? 'dark' : 'default', themeCSS: isDarkTheme ? darkThemeStyling : '', - useMaxWidth: false + useMaxWidth: false, + flowchart: { htmlLabels: enableHTMLLabel } }) mermaidAPI.render(getId(), content, (svgGraph) => { element.innerHTML = svgGraph diff --git a/browser/lib/markdown-it-sanitize-html.js b/browser/lib/markdown-it-sanitize-html.js index 8f6d86a8..3325604a 100644 --- a/browser/lib/markdown-it-sanitize-html.js +++ b/browser/lib/markdown-it-sanitize-html.js @@ -15,7 +15,7 @@ module.exports = function sanitizePlugin (md, options) { options ) } - if (state.tokens[tokenIdx].type === '_fence') { + if (state.tokens[tokenIdx].type.match(/.*_fence$/)) { // escapeHtmlCharacters has better performance state.tokens[tokenIdx].content = escapeHtmlCharacters( state.tokens[tokenIdx].content, diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index e13cdbc1..b3fb65d7 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -86,8 +86,10 @@ export const DEFAULT_CONFIG = { breaks: true, smartArrows: false, allowCustomCSS: false, + customCSS: '/* Drop Your Custom CSS Code Here */', sanitize: 'STRICT', // 'STRICT', 'ALLOW_STYLES', 'NONE' + mermaidHTMLLabel: false, lineThroughCheckbox: true }, blog: { diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index cff063ff..fc09a37f 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -125,6 +125,7 @@ class UiTab extends React.Component { breaks: this.refs.previewBreaks.checked, smartArrows: this.refs.previewSmartArrows.checked, sanitize: this.refs.previewSanitize.value, + mermaidHTMLLabel: this.refs.previewMermaidHTMLLabel.checked, allowCustomCSS: this.refs.previewAllowCustomCSS.checked, lineThroughCheckbox: this.refs.lineThroughCheckbox.checked, customCSS: this.customCSSCM.getCodeMirror().getValue() @@ -813,6 +814,16 @@ class UiTab extends React.Component {
+
+ +
{i18n.__('LaTeX Inline Open Delimiter')} diff --git a/locales/da.json b/locales/da.json index 55962cdb..38a8fbeb 100644 --- a/locales/da.json +++ b/locales/da.json @@ -157,5 +157,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/de.json b/locales/de.json index 22d0913a..cac158c5 100644 --- a/locales/de.json +++ b/locales/de.json @@ -213,5 +213,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/en.json b/locales/en.json index 0a8b8780..a10f3be9 100644 --- a/locales/en.json +++ b/locales/en.json @@ -188,5 +188,6 @@ "New notes are tagged with the filtering tags": "New notes are tagged with the filtering tags", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/es-ES.json b/locales/es-ES.json index 9f1dc19a..56945819 100644 --- a/locales/es-ES.json +++ b/locales/es-ES.json @@ -159,5 +159,6 @@ "Show menu bar": "Mostrar barra del menú", "Auto Detect": "Detección automática", "Snippet Default Language": "Lenguaje por defecto de los fragmentos de código", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/fa.json b/locales/fa.json index 311fe18d..784c4864 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -161,5 +161,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/fr.json b/locales/fr.json index 2e060ec5..698d4791 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -173,5 +173,6 @@ "Snippet prefix": "Préfixe du snippet", "Delete Note": "Supprimer la note", "New notes are tagged with the filtering tags": "Les nouvelles notes sont taggées avec les tags de filtrage", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/hu.json b/locales/hu.json index 0f6e3832..97b92212 100644 --- a/locales/hu.json +++ b/locales/hu.json @@ -181,5 +181,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/it.json b/locales/it.json index 43bc15fa..26eafff1 100644 --- a/locales/it.json +++ b/locales/it.json @@ -161,5 +161,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/ja.json b/locales/ja.json index b5722795..390386d4 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -220,5 +220,6 @@ "Spellcheck disabled": "スペルチェック無効", "Show menu bar": "メニューバーを表示", "Auto Detect": "自動検出", + "Enable HTML label in mermaid flowcharts": "mermaid flowchartでHTMLラベルを有効にする ⚠ このオプションには潜在的なXSSの危険性があります。", "Wrap line in Snippet Note": "行を右端で折り返す(Snippet Note)" } diff --git a/locales/ko.json b/locales/ko.json index d762ee15..b6bd75be 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -164,5 +164,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/no.json b/locales/no.json index 42d17dc3..fa018e86 100644 --- a/locales/no.json +++ b/locales/no.json @@ -157,5 +157,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/pl.json b/locales/pl.json index 34f053cc..c289ef23 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -166,5 +166,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 028f9b93..0005a44e 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -157,5 +157,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 739a2181..677cce4d 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -156,5 +156,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/ru.json b/locales/ru.json index c71f1556..990374ef 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -154,5 +154,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/sq.json b/locales/sq.json index d6104c9b..dec7402f 100644 --- a/locales/sq.json +++ b/locales/sq.json @@ -156,5 +156,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/th.json b/locales/th.json index 4637f735..1f06ceb6 100644 --- a/locales/th.json +++ b/locales/th.json @@ -183,5 +183,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/tr.json b/locales/tr.json index 45cc0cbb..78038402 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -156,5 +156,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 8b249245..581e38d6 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -221,5 +221,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" } diff --git a/locales/zh-TW.json b/locales/zh-TW.json index bdea0f16..33b71699 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -165,5 +165,6 @@ "Spellcheck disabled": "Spellcheck disabled", "Show menu bar": "Show menu bar", "Auto Detect": "Auto Detect", + "Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "Wrap line in Snippet Note": "Wrap line in Snippet Note" }