From 090b5c32f01a8e87e8aec19113108b1a7ba918e1 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Sun, 9 Jun 2019 13:28:53 +0800 Subject: [PATCH 01/63] 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 1abd15a9..59782e08 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 bb663c5e..a407651e 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() @@ -249,30 +245,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 ef1809305c2d3286b81221644830023ceeba0e44 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Tue, 11 Jun 2019 18:20:24 +0800 Subject: [PATCH 02/63] feat(prettierOnMarkdown): Added Reference To Prettier --- package.json | 3 ++- yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0893e681..2634ac14 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "boost", "productName": "Boostnote", - "version": "0.11.17", + "version": "0.11.17", "main": "index.js", "description": "Boostnote", "license": "GPL-3.0", @@ -98,6 +98,7 @@ "mousetrap": "^1.6.2", "mousetrap-global-bind": "^1.1.0", "node-ipc": "^8.1.0", + "prettier": "^1.18.2", "prop-types": "^15.7.2", "query-string": "^6.5.0", "raphael": "^2.2.7", diff --git a/yarn.lock b/yarn.lock index 30640d17..c4af1e91 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7482,6 +7482,11 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" + integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== + pretty-bytes@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" From 25bdaf9f00a7a9584948e5ec19940588a411c21c Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Tue, 11 Jun 2019 19:09:50 +0800 Subject: [PATCH 03/63] feat(prettierOnMarkdown): Added Reference to prettier in Code Editor and created config file --- browser/components/CodeEditor.js | 5 +++++ prettier.config | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 prettier.config diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 1abd15a9..c758ea07 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -28,6 +28,7 @@ import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-gene import markdownlint from 'markdownlint' import Jsonlint from 'jsonlint-mod' import { DEFAULT_CONFIG } from '../main/lib/ConfigManager' +const prettier = require('prettier') CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js' @@ -232,6 +233,10 @@ export default class CodeEditor extends React.Component { } return CodeMirror.Pass }, + 'Shift-Alt-F': cm => { + // console.log(prettier.format('foo ( );', { semi: false, parser: 'babel' })) + // console.log('Key Combo Pressed') + }, [translateHotkey(hotkey.pasteSmartly)]: cm => { this.handlePaste(cm, true) } diff --git a/prettier.config b/prettier.config new file mode 100644 index 00000000..8b8b7b99 --- /dev/null +++ b/prettier.config @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 4, + "semi": false, + "singleQuote": true +} \ No newline at end of file From f0380ef733bd5eabab94168e27686e9709618d0f Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Sat, 15 Jun 2019 16:23:51 +0800 Subject: [PATCH 04/63] feat(prettierOnMarkdown): Added support for prettyifing markdown as well as added hot key option. Partial Implementation of Prettier config in configuration screen. TODO Fix defaulting of prettier configuration --- browser/components/CodeEditor.js | 26 +++++++++++++---- browser/components/MarkdownEditor.js | 1 + browser/main/lib/ConfigManager.js | 1 + .../main/modals/PreferencesModal/HotkeyTab.js | 12 ++++++++ browser/main/modals/PreferencesModal/UiTab.js | 29 +++++++++++++++++-- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index c758ea07..d1354bb4 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -233,9 +233,23 @@ export default class CodeEditor extends React.Component { } return CodeMirror.Pass }, - 'Shift-Alt-F': cm => { - // console.log(prettier.format('foo ( );', { semi: false, parser: 'babel' })) - // console.log('Key Combo Pressed') + [translateHotkey(hotkey.prettifyMarkdown)]: cm => { + // Default / User configured prettier options + const currentConfig = JSON.parse(self.props.prettierConfig) + // Get current cursor position. + const cursorPos = cm.getCursor() + currentConfig.cursorOffset = cm.doc.indexFromPos(cursorPos) + + // Prettify contents of editor. + const formattedTextDetails = prettier.formatWithCursor(cm.doc.getValue(), currentConfig) + + const formattedText = formattedTextDetails.formatted + const formattedCursorPos = formattedTextDetails.cursorOffset + cm.doc.setValue(formattedText) + + // Reset Cursor position to be at the same markdown as was before prettifying + const newCursorPos = cm.doc.posFromIndex(formattedCursorPos) + cm.doc.setCursor(newCursorPos) }, [translateHotkey(hotkey.pasteSmartly)]: cm => { this.handlePaste(cm, true) @@ -290,7 +304,8 @@ export default class CodeEditor extends React.Component { explode: this.props.explodingPairs, override: true }, - extraKeys: this.defaultKeyMap + extraKeys: this.defaultKeyMap, + prettierConfig: this.props.prettierConfig }) document.querySelector('.CodeMirror-lint-markers').style.display = enableMarkdownLint ? 'inline-block' : 'none' @@ -1200,5 +1215,6 @@ CodeEditor.defaultProps = { autoDetect: false, spellCheck: false, enableMarkdownLint: DEFAULT_CONFIG.editor.enableMarkdownLint, - customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig + customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig, + prettierConfig: DEFAULT_CONFIG.editor.prettierConfig } diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index e956655c..a7154e68 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -321,6 +321,7 @@ class MarkdownEditor extends React.Component { switchPreview={config.editor.switchPreview} enableMarkdownLint={config.editor.enableMarkdownLint} customMarkdownLintConfig={config.editor.customMarkdownLintConfig} + prettierConfig={config.editor.prettierConfig} /> +
+
{i18n.__('Prettify Markdown')}
+
+ this.handleHotkeyChange(e)} + ref='prettifyMarkdown' + value={config.hotkey.prettifyMarkdown} + type='text' + /> +
+
- +
+
+ {i18n.__('Prettier Config')} +
+
+
+ this.handleUIChange(e)} + ref={e => (this.prettierConfigCM = e)} + value={config.editor.prettierConfig} + options={{ + lineNumbers: true, + mode: 'json', + theme: codemirrorTheme + }} /> +
+
+
From ed4a670f0aa57027fef70be3711ab0031b84d172 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Sun, 23 Jun 2019 13:54:17 +0800 Subject: [PATCH 08/63] feat(prettierOnMarkdown): Changed default hotkey value --- browser/main/lib/ConfigManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 9e4e4d13..f2d6d85a 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -31,7 +31,7 @@ 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', - prettifyMarkdown: 'Shift + Alt + F', + prettifyMarkdown: 'Shift + F', toggleMenuBar: 'Alt' }, ui: { From bde357f95200197b4bedcb44aac57136ca32569a Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Wed, 3 Jul 2019 09:03:24 +0800 Subject: [PATCH 09/63] feat(prettierOnMarkdown): Changed Prettier require to use import --- 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 d1354bb4..ed24c671 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -28,7 +28,7 @@ import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-gene import markdownlint from 'markdownlint' import Jsonlint from 'jsonlint-mod' import { DEFAULT_CONFIG } from '../main/lib/ConfigManager' -const prettier = require('prettier') +import prettier from 'prettier' CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js' From 1d59d89588a9b328b81d19714e7b410bc7cef8c8 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Wed, 3 Jul 2019 09:28:36 +0800 Subject: [PATCH 10/63] feat(prettierOnMarkdown): Forced prettier options to always have parser set to markdown when used. --- browser/components/CodeEditor.js | 8 ++++++-- browser/main/lib/ConfigManager.js | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index ed24c671..8421b520 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -236,11 +236,15 @@ export default class CodeEditor extends React.Component { [translateHotkey(hotkey.prettifyMarkdown)]: cm => { // Default / User configured prettier options const currentConfig = JSON.parse(self.props.prettierConfig) - // Get current cursor position. + + // Parser type will always need to be markdown so we override the option before use + currentConfig.parser = 'markdown' + + // Get current cursor position const cursorPos = cm.getCursor() currentConfig.cursorOffset = cm.doc.indexFromPos(cursorPos) - // Prettify contents of editor. + // Prettify contents of editor const formattedTextDetails = prettier.formatWithCursor(cm.doc.getValue(), currentConfig) const formattedText = formattedTextDetails.formatted diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index f2d6d85a..d4c73b4a 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -71,8 +71,7 @@ export const DEFAULT_CONFIG = { "trailingComma": "es5", "tabWidth": 4, "semi": false, - "singleQuote": true, - "parser":"markdown" + "singleQuote": true }` }, From fe508307b235a33e4246522f0a9a7333c4ab2b5e Mon Sep 17 00:00:00 2001 From: amedora Date: Thu, 6 Jun 2019 15:48:36 +0900 Subject: [PATCH 11/63] make lineWrapping configurable --- browser/components/CodeEditor.js | 6 +++++- browser/main/Detail/SnippetNoteDetail.js | 1 + browser/main/lib/ConfigManager.js | 1 + browser/main/modals/PreferencesModal/UiTab.js | 11 +++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 72ecbf23..e209a9fd 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -251,7 +251,7 @@ export default class CodeEditor extends React.Component { value: this.props.value, linesHighlighted: this.props.linesHighlighted, lineNumbers: this.props.displayLineNumbers, - lineWrapping: true, + lineWrapping: this.props.lineWrapping, theme: this.props.theme, indentUnit: this.props.indentSize, tabSize: this.props.indentSize, @@ -550,6 +550,10 @@ export default class CodeEditor extends React.Component { this.editor.setOption('lineNumbers', this.props.displayLineNumbers) } + if (prevProps.lineWrapping !== this.props.lineWrapping) { + this.editor.setOption('lineWrapping', this.props.lineWrapping) + } + if (prevProps.scrollPastEnd !== this.props.scrollPastEnd) { this.editor.setOption('scrollPastEnd', this.props.scrollPastEnd) } diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js index 7503addb..478ab902 100644 --- a/browser/main/Detail/SnippetNoteDetail.js +++ b/browser/main/Detail/SnippetNoteDetail.js @@ -720,6 +720,7 @@ class SnippetNoteDetail extends React.Component { mode={snippet.mode || (autoDetect ? null : config.editor.snippetDefaultLanguage)} value={snippet.content} linesHighlighted={snippet.linesHighlighted} + lineWrapping={config.editor.lineWrapping} theme={config.editor.theme} fontFamily={config.editor.fontFamily} fontSize={editorFontSize} diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 4a44f148..1ef27d5e 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -50,6 +50,7 @@ export const DEFAULT_CONFIG = { fontFamily: win ? 'Consolas' : 'Monaco', indentType: 'space', indentSize: '2', + lineWrapping: true, enableRulers: false, rulers: [80, 120], displayLineNumbers: true, diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 29071a8f..30b3f40a 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -546,6 +546,17 @@ class UiTab extends React.Component { +
+ +
+
Date: Tue, 11 Jun 2019 09:02:33 +0900 Subject: [PATCH 14/63] 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 15/63] 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 16/63] 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 17/63] 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 18/63] 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 19/63] 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 20/63] 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 21/63] 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 22/63] 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 23/63] 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 24/63] 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 25/63] 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 26/63] 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 27/63] 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 28/63] 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 29/63] 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 30/63] 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 31/63] 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 32/63] 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 33/63] 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 34/63] 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 35/63] 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 36/63] 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 37/63] 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 38/63] 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 39/63] 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 40/63] 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" } From a39e9c2da64b29602ffbad7160291078b6c32ced Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Tue, 11 Jun 2019 18:20:24 +0800 Subject: [PATCH 41/63] feat(prettierOnMarkdown): Added Reference To Prettier --- package.json | 3 ++- yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0893e681..2634ac14 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "boost", "productName": "Boostnote", - "version": "0.11.17", + "version": "0.11.17", "main": "index.js", "description": "Boostnote", "license": "GPL-3.0", @@ -98,6 +98,7 @@ "mousetrap": "^1.6.2", "mousetrap-global-bind": "^1.1.0", "node-ipc": "^8.1.0", + "prettier": "^1.18.2", "prop-types": "^15.7.2", "query-string": "^6.5.0", "raphael": "^2.2.7", diff --git a/yarn.lock b/yarn.lock index 30640d17..c4af1e91 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7482,6 +7482,11 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" + integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== + pretty-bytes@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" From 7e3c662374904ecbe24f5062d2bb9f4c6e143919 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Tue, 11 Jun 2019 19:09:50 +0800 Subject: [PATCH 42/63] feat(prettierOnMarkdown): Added Reference to prettier in Code Editor and created config file --- browser/components/CodeEditor.js | 5 +++++ prettier.config | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 prettier.config diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 59782e08..a8f00169 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -28,6 +28,7 @@ import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-gene import markdownlint from 'markdownlint' import Jsonlint from 'jsonlint-mod' import { DEFAULT_CONFIG } from '../main/lib/ConfigManager' +const prettier = require('prettier') CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js' @@ -232,6 +233,10 @@ export default class CodeEditor extends React.Component { } return CodeMirror.Pass }, + 'Shift-Alt-F': cm => { + // console.log(prettier.format('foo ( );', { semi: false, parser: 'babel' })) + // console.log('Key Combo Pressed') + }, [translateHotkey(hotkey.pasteSmartly)]: cm => { this.handlePaste(cm, true) } diff --git a/prettier.config b/prettier.config new file mode 100644 index 00000000..8b8b7b99 --- /dev/null +++ b/prettier.config @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 4, + "semi": false, + "singleQuote": true +} \ No newline at end of file From 33161e46e63e54d2bd26aceb91232b80973c0126 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Sat, 15 Jun 2019 16:23:51 +0800 Subject: [PATCH 43/63] feat(prettierOnMarkdown): Added support for prettyifing markdown as well as added hot key option. Partial Implementation of Prettier config in configuration screen. TODO Fix defaulting of prettier configuration --- browser/components/CodeEditor.js | 26 +++++++++++++---- browser/components/MarkdownEditor.js | 1 + browser/main/lib/ConfigManager.js | 1 + .../main/modals/PreferencesModal/HotkeyTab.js | 12 ++++++++ browser/main/modals/PreferencesModal/UiTab.js | 29 +++++++++++++++++-- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index a8f00169..241a099a 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -233,9 +233,23 @@ export default class CodeEditor extends React.Component { } return CodeMirror.Pass }, - 'Shift-Alt-F': cm => { - // console.log(prettier.format('foo ( );', { semi: false, parser: 'babel' })) - // console.log('Key Combo Pressed') + [translateHotkey(hotkey.prettifyMarkdown)]: cm => { + // Default / User configured prettier options + const currentConfig = JSON.parse(self.props.prettierConfig) + // Get current cursor position. + const cursorPos = cm.getCursor() + currentConfig.cursorOffset = cm.doc.indexFromPos(cursorPos) + + // Prettify contents of editor. + const formattedTextDetails = prettier.formatWithCursor(cm.doc.getValue(), currentConfig) + + const formattedText = formattedTextDetails.formatted + const formattedCursorPos = formattedTextDetails.cursorOffset + cm.doc.setValue(formattedText) + + // Reset Cursor position to be at the same markdown as was before prettifying + const newCursorPos = cm.doc.posFromIndex(formattedCursorPos) + cm.doc.setCursor(newCursorPos) }, [translateHotkey(hotkey.pasteSmartly)]: cm => { this.handlePaste(cm, true) @@ -290,7 +304,8 @@ export default class CodeEditor extends React.Component { explode: this.props.explodingPairs, override: true }, - extraKeys: this.defaultKeyMap + extraKeys: this.defaultKeyMap, + prettierConfig: this.props.prettierConfig }) document.querySelector('.CodeMirror-lint-markers').style.display = enableMarkdownLint ? 'inline-block' : 'none' @@ -1200,5 +1215,6 @@ CodeEditor.defaultProps = { autoDetect: false, spellCheck: false, enableMarkdownLint: DEFAULT_CONFIG.editor.enableMarkdownLint, - customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig + customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig, + prettierConfig: DEFAULT_CONFIG.editor.prettierConfig } diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index e956655c..a7154e68 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -321,6 +321,7 @@ class MarkdownEditor extends React.Component { switchPreview={config.editor.switchPreview} enableMarkdownLint={config.editor.enableMarkdownLint} customMarkdownLintConfig={config.editor.customMarkdownLintConfig} + prettierConfig={config.editor.prettierConfig} />
+
+
{i18n.__('Prettify Markdown')}
+
+ this.handleHotkeyChange(e)} + ref='prettifyMarkdown' + value={config.hotkey.prettifyMarkdown} + type='text' + /> +
+
- +
+
+ {i18n.__('Prettier Config')} +
+
+
+ this.handleUIChange(e)} + ref={e => (this.prettierConfigCM = e)} + value={config.editor.prettierConfig} + options={{ + lineNumbers: true, + mode: 'json', + theme: codemirrorTheme + }} /> +
+
+
From 0ad3da5bbcdcb8771bd3f3dc9a0348abdaca191f Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Sun, 23 Jun 2019 13:54:17 +0800 Subject: [PATCH 47/63] feat(prettierOnMarkdown): Changed default hotkey value --- browser/main/lib/ConfigManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 9e4e4d13..f2d6d85a 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -31,7 +31,7 @@ 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', - prettifyMarkdown: 'Shift + Alt + F', + prettifyMarkdown: 'Shift + F', toggleMenuBar: 'Alt' }, ui: { From 911fd9a0042d39faf7c681815017ebe59783e7fd Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Wed, 3 Jul 2019 09:03:24 +0800 Subject: [PATCH 48/63] feat(prettierOnMarkdown): Changed Prettier require to use import --- 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 241a099a..e6debd76 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -28,7 +28,7 @@ import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-gene import markdownlint from 'markdownlint' import Jsonlint from 'jsonlint-mod' import { DEFAULT_CONFIG } from '../main/lib/ConfigManager' -const prettier = require('prettier') +import prettier from 'prettier' CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js' From 1173631255d66b40d824a3e01565997d56258603 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Wed, 3 Jul 2019 09:28:36 +0800 Subject: [PATCH 49/63] feat(prettierOnMarkdown): Forced prettier options to always have parser set to markdown when used. --- browser/components/CodeEditor.js | 8 ++++++-- browser/main/lib/ConfigManager.js | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index e6debd76..da479fd5 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -236,11 +236,15 @@ export default class CodeEditor extends React.Component { [translateHotkey(hotkey.prettifyMarkdown)]: cm => { // Default / User configured prettier options const currentConfig = JSON.parse(self.props.prettierConfig) - // Get current cursor position. + + // Parser type will always need to be markdown so we override the option before use + currentConfig.parser = 'markdown' + + // Get current cursor position const cursorPos = cm.getCursor() currentConfig.cursorOffset = cm.doc.indexFromPos(cursorPos) - // Prettify contents of editor. + // Prettify contents of editor const formattedTextDetails = prettier.formatWithCursor(cm.doc.getValue(), currentConfig) const formattedText = formattedTextDetails.formatted diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index f2d6d85a..d4c73b4a 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -71,8 +71,7 @@ export const DEFAULT_CONFIG = { "trailingComma": "es5", "tabWidth": 4, "semi": false, - "singleQuote": true, - "parser":"markdown" + "singleQuote": true }` }, From eeca031c86b518223d32a8eb45f572f4d001af24 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Thu, 1 Aug 2019 19:56:38 +0800 Subject: [PATCH 50/63] Merge upstream into master --- browser/components/MarkdownPreview.js | 4 ---- browser/lib/contextMenuBuilder.js | 9 --------- tests/lib/contextMenuBuilder.test.js | 5 ----- 3 files changed, 18 deletions(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index e4c88de9..0072e403 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -248,11 +248,7 @@ export default class MarkdownPreview extends React.Component { handleContextMenu (event) { const menu = buildMarkdownPreviewContextMenu(this, event) if (menu != null) { -<<<<<<< HEAD - setTimeout(() => menu.popup(remote.getCurrentWindow()), 30) -======= menu.popup(remote.getCurrentWindow()) ->>>>>>> upstream/master } } diff --git a/browser/lib/contextMenuBuilder.js b/browser/lib/contextMenuBuilder.js index 34f84789..ff3349eb 100644 --- a/browser/lib/contextMenuBuilder.js +++ b/browser/lib/contextMenuBuilder.js @@ -81,17 +81,8 @@ const buildMarkdownPreviewContextMenu = function (markdownPreview, event) { // Default context menu inclusions const template = [{ -<<<<<<< HEAD - role: 'cut' - }, { role: 'copy' }, { - role: 'paste' - }, { -======= - role: 'copy' - }, { ->>>>>>> upstream/master role: 'selectall' }] diff --git a/tests/lib/contextMenuBuilder.test.js b/tests/lib/contextMenuBuilder.test.js index e3753aca..b7009bf1 100644 --- a/tests/lib/contextMenuBuilder.test.js +++ b/tests/lib/contextMenuBuilder.test.js @@ -4,13 +4,8 @@ jest.mock('electron', () => { }) const spellcheck = require('browser/lib/spellcheck') -<<<<<<< HEAD -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 ->>>>>>> upstream/master beforeEach(() => { menuBuilderParameter = null From 2d3c69d178328b4d54ab639aac4e93d22470f000 Mon Sep 17 00:00:00 2001 From: nathan-castlehow Date: Thu, 1 Aug 2019 20:13:46 +0800 Subject: [PATCH 51/63] Fixed eslint issue --- browser/main/modals/PreferencesModal/HotkeyTab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/modals/PreferencesModal/HotkeyTab.js b/browser/main/modals/PreferencesModal/HotkeyTab.js index 54639f20..a7e42c0f 100644 --- a/browser/main/modals/PreferencesModal/HotkeyTab.js +++ b/browser/main/modals/PreferencesModal/HotkeyTab.js @@ -181,7 +181,7 @@ class HotkeyTab extends React.Component { onChange={(e) => this.handleHotkeyChange(e)} ref='prettifyMarkdown' value={config.hotkey.prettifyMarkdown} - type='text'/> + type='text' />
From f09297f4060275c5bd28781e35d01c0ddb309a13 Mon Sep 17 00:00:00 2001 From: Jack Hsieh Date: Sun, 11 Aug 2019 07:22:53 -0700 Subject: [PATCH 52/63] Fix 2636 (#3206) * Fix 2636 Can't scroll to bottom of editor pane * Fix minor lint issues --- .eslintrc | 4 +++- browser/components/MarkdownPreview.js | 2 +- browser/components/NoteItem.js | 4 ++-- browser/lib/keygen.js | 1 - browser/main/Detail/MarkdownNoteDetail.js | 1 - browser/main/Main.js | 1 + browser/main/SideNav/index.js | 7 ++++--- browser/main/lib/dataApi/attachmentManagement.js | 3 ++- browser/main/lib/dataApi/deleteFolder.js | 1 - browser/main/lib/dataApi/moveNote.js | 1 - browser/main/modals/PreferencesModal/UiTab.js | 1 - lib/main.development.html | 5 +++++ lib/main.production.html | 5 +++++ 13 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.eslintrc b/.eslintrc index 1709c9d8..be8cb903 100644 --- a/.eslintrc +++ b/.eslintrc @@ -18,7 +18,9 @@ "globals": { "FileReader": true, "localStorage": true, - "fetch": true + "fetch": true, + "Image": true, + "MutationObserver": true }, "env": { "jest": true diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index 0072e403..cc2e8166 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -41,7 +41,6 @@ const CSS_FILES = [ `${appPath}/node_modules/codemirror/lib/codemirror.css`, `${appPath}/node_modules/react-image-carousel/lib/css/main.min.css` ] -const win = global.process.platform === 'win32' function buildStyle ( fontFamily, @@ -815,6 +814,7 @@ export default class MarkdownPreview extends React.Component { canvas.height = height.value + 'vh' } + // eslint-disable-next-line no-unused-vars const chart = new Chart(canvas, chartConfig) } catch (e) { el.className = 'chart-error' diff --git a/browser/components/NoteItem.js b/browser/components/NoteItem.js index 9ef691da..168af1ff 100644 --- a/browser/components/NoteItem.js +++ b/browser/components/NoteItem.js @@ -3,7 +3,7 @@ */ import PropTypes from 'prop-types' import React from 'react' -import { isArray } from 'lodash' +import { isArray, sortBy } from 'lodash' import invertColor from 'invert-color' import CSSModules from 'browser/lib/CSSModules' import { getTodoStatus } from 'browser/lib/getTodoStatus' @@ -43,7 +43,7 @@ const TagElementList = (tags, showTagsAlphabetically, coloredTags) => { } if (showTagsAlphabetically) { - return _.sortBy(tags).map(tag => TagElement({ tagName: tag, color: coloredTags[tag] })) + return sortBy(tags).map(tag => TagElement({ tagName: tag, color: coloredTags[tag] })) } else { return tags.map(tag => TagElement({ tagName: tag, color: coloredTags[tag] })) } diff --git a/browser/lib/keygen.js b/browser/lib/keygen.js index 814efedd..557a8a40 100644 --- a/browser/lib/keygen.js +++ b/browser/lib/keygen.js @@ -1,5 +1,4 @@ const crypto = require('crypto') -const _ = require('lodash') const uuidv4 = require('uuid/v4') module.exports = function (uuid) { diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index 45024751..a3b69469 100755 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -152,7 +152,6 @@ class MarkdownNoteDetail extends React.Component { } handleFolderChange (e) { - const { dispatch } = this.props const { note } = this.state const value = this.refs.folder.value const splitted = value.split('-') diff --git a/browser/main/Main.js b/browser/main/Main.js index 30bf8e8a..19d76025 100644 --- a/browser/main/Main.js +++ b/browser/main/Main.js @@ -169,6 +169,7 @@ class Main extends React.Component { } }) + // eslint-disable-next-line no-undef delete CodeMirror.keyMap.emacs['Ctrl-V'] eventEmitter.on('editor:fullscreen', this.toggleFullScreen) diff --git a/browser/main/SideNav/index.js b/browser/main/SideNav/index.js index 9d18a72c..1a60ae27 100644 --- a/browser/main/SideNav/index.js +++ b/browser/main/SideNav/index.js @@ -22,9 +22,10 @@ import context from 'browser/lib/context' import { remote } from 'electron' import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote' import ColorPicker from 'browser/components/ColorPicker' +import { every, sortBy } from 'lodash' function matchActiveTags (tags, activeTags) { - return _.every(activeTags, v => tags.indexOf(v) >= 0) + return every(activeTags, v => tags.indexOf(v) >= 0) } class SideNav extends React.Component { @@ -283,7 +284,7 @@ class SideNav extends React.Component { const { colorPicker } = this.state const activeTags = this.getActiveTags(location.pathname) const relatedTags = this.getRelatedTags(activeTags, data.noteMap) - let tagList = _.sortBy(data.tagNoteMap.map( + let tagList = sortBy(data.tagNoteMap.map( (tag, name) => ({ name, size: tag.size, related: relatedTags.has(name) }) ).filter( tag => tag.size > 0 @@ -296,7 +297,7 @@ class SideNav extends React.Component { }) } if (config.sortTagsBy === 'COUNTER') { - tagList = _.sortBy(tagList, item => (0 - item.size)) + tagList = sortBy(tagList, item => (0 - item.size)) } if (config.ui.showOnlyRelatedTags && (relatedTags.size > 0)) { tagList = tagList.filter( diff --git a/browser/main/lib/dataApi/attachmentManagement.js b/browser/main/lib/dataApi/attachmentManagement.js index 725bdc11..9419435c 100644 --- a/browser/main/lib/dataApi/attachmentManagement.js +++ b/browser/main/lib/dataApi/attachmentManagement.js @@ -8,6 +8,7 @@ const escapeStringRegexp = require('escape-string-regexp') const sander = require('sander') const url = require('url') import i18n from 'browser/lib/i18n' +import { isString } from 'lodash' const STORAGE_FOLDER_PLACEHOLDER = ':storage' const DESTINATION_FOLDER = 'attachments' @@ -19,7 +20,7 @@ const PATH_SEPARATORS = escapeStringRegexp(path.posix.sep) + escapeStringRegexp( * @returns {Promise} Image element created */ function getImage (file) { - if (_.isString(file)) { + if (isString(file)) { return new Promise(resolve => { const img = new Image() img.onload = () => resolve(img) diff --git a/browser/main/lib/dataApi/deleteFolder.js b/browser/main/lib/dataApi/deleteFolder.js index 0c7486f5..5ccc1414 100644 --- a/browser/main/lib/dataApi/deleteFolder.js +++ b/browser/main/lib/dataApi/deleteFolder.js @@ -3,7 +3,6 @@ const path = require('path') const resolveStorageData = require('./resolveStorageData') const resolveStorageNotes = require('./resolveStorageNotes') const CSON = require('@rokt33r/season') -const sander = require('sander') const { findStorage } = require('browser/lib/findStorage') const deleteSingleNote = require('./deleteNote') diff --git a/browser/main/lib/dataApi/moveNote.js b/browser/main/lib/dataApi/moveNote.js index 2d306cdf..c38968cb 100644 --- a/browser/main/lib/dataApi/moveNote.js +++ b/browser/main/lib/dataApi/moveNote.js @@ -1,7 +1,6 @@ const resolveStorageData = require('./resolveStorageData') const _ = require('lodash') const path = require('path') -const fs = require('fs') const CSON = require('@rokt33r/season') const keygen = require('browser/lib/keygen') const sander = require('sander') diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index fc09a37f..c494bfc4 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -14,7 +14,6 @@ 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 electron = require('electron') const ipc = electron.ipcRenderer diff --git a/lib/main.development.html b/lib/main.development.html index cbcda295..63e50af1 100644 --- a/lib/main.development.html +++ b/lib/main.development.html @@ -72,6 +72,11 @@ border-left-color: rgba(142, 142, 142, 0.5); mix-blend-mode: difference; } + + .CodeMirror-scroll { + margin-bottom: 0; + padding-bottom: 0; + } .CodeMirror-lint-tooltip { z-index: 1003; diff --git a/lib/main.production.html b/lib/main.production.html index cab38981..d6828acc 100644 --- a/lib/main.production.html +++ b/lib/main.production.html @@ -71,6 +71,11 @@ border-left-color: rgba(142, 142, 142, 0.5); mix-blend-mode: difference; } + + .CodeMirror-scroll { + margin-bottom: 0; + padding-bottom: 0; + } From ff9789b5a7aec06dfd9170f542c94a554096cf0f Mon Sep 17 00:00:00 2001 From: sirrah23 Date: Mon, 29 Jul 2019 00:20:56 -0400 Subject: [PATCH 53/63] Fix 3060 Right now there are only two export types that are using a special output formatter, pdf and html. Both of these formatters currently populate the `/html/head/base` portion of the associated html document with the name of the target directory for the file that the user is exporting. In order for internal links within the exported document to work correctly, the value of base must also include the filename. This fix removes the call to `path.dirname`, which gets rid of the necessary filename. --- browser/main/lib/dataApi/exportNote.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/lib/dataApi/exportNote.js b/browser/main/lib/dataApi/exportNote.js index 75c451c1..42e1fa56 100755 --- a/browser/main/lib/dataApi/exportNote.js +++ b/browser/main/lib/dataApi/exportNote.js @@ -43,7 +43,7 @@ function exportNote (nodeKey, storageKey, noteContent, targetPath, outputFormatt ) if (outputFormatter) { - exportedData = outputFormatter(exportedData, exportTasks, path.dirname(targetPath)) + exportedData = outputFormatter(exportedData, exportTasks, targetPath) } else { exportedData = Promise.resolve(exportedData) } From 6ef9c3865fe7c88520bf91b8f0a1bdc259c408b6 Mon Sep 17 00:00:00 2001 From: Antonio Cangiano Date: Mon, 5 Aug 2019 17:46:26 -0700 Subject: [PATCH 54/63] Fix JavaScript hello world example The current snippet note example references a non-existent element with id `enjoy`. I updated it to reference the correct id (i.e., `hello`). --- browser/main/Main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/Main.js b/browser/main/Main.js index 19d76025..e277c421 100644 --- a/browser/main/Main.js +++ b/browser/main/Main.js @@ -102,7 +102,7 @@ class Main extends React.Component { { name: 'example.js', mode: 'javascript', - content: "var boostnote = document.getElementById('enjoy').innerHTML\n\nconsole.log(boostnote)", + content: "var boostnote = document.getElementById('hello').innerHTML\n\nconsole.log(boostnote)", linesHighlighted: [] } ] From 2352c78cb6c9287755733d6113d3ec81e8ce11fb Mon Sep 17 00:00:00 2001 From: hikerpig Date: Fri, 2 Aug 2019 10:41:12 +0800 Subject: [PATCH 55/63] Add `CodeEditor::setLineContent` method to manipulate line contents, related #3163 Avoid changing all CodeMirror instance's contents --- browser/components/CodeEditor.js | 11 +++++++++++ browser/components/MarkdownEditor.js | 7 ++++--- browser/components/MarkdownSplitEditor.js | 7 ++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 2a4ae71b..c972103e 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -836,6 +836,17 @@ export default class CodeEditor extends React.Component { this.editor.setCursor(cursor) } + /** + * Update content of one line + * @param {Number} lineNumber + * @param {String} content + */ + setLineContent (lineNumber, content) { + const prevContent = this.editor.getLine(lineNumber) + const prevContentLength = prevContent ? prevContent.length : 0 + this.editor.replaceRange(content, { line: lineNumber, ch: 0 }, { line: lineNumber, ch: prevContentLength }) + } + handleDropImage (dropEvent) { dropEvent.preventDefault() const { diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index 3dd57f70..ef238166 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -169,14 +169,15 @@ class MarkdownEditor extends React.Component { .split('\n') const targetLine = lines[lineIndex] + let newLine = targetLine if (targetLine.match(checkedMatch)) { - lines[lineIndex] = targetLine.replace(checkReplace, '[ ]') + newLine = targetLine.replace(checkReplace, '[ ]') } if (targetLine.match(uncheckedMatch)) { - lines[lineIndex] = targetLine.replace(uncheckReplace, '[x]') + newLine = targetLine.replace(uncheckReplace, '[x]') } - this.refs.code.setValue(lines.join('\n')) + this.refs.code.setLineContent(lineIndex, newLine) } } diff --git a/browser/components/MarkdownSplitEditor.js b/browser/components/MarkdownSplitEditor.js index b283228c..56f6ef8f 100644 --- a/browser/components/MarkdownSplitEditor.js +++ b/browser/components/MarkdownSplitEditor.js @@ -88,14 +88,15 @@ class MarkdownSplitEditor extends React.Component { .split('\n') const targetLine = lines[lineIndex] + let newLine = targetLine if (targetLine.match(checkedMatch)) { - lines[lineIndex] = targetLine.replace(checkReplace, '[ ]') + newLine = targetLine.replace(checkReplace, '[ ]') } if (targetLine.match(uncheckedMatch)) { - lines[lineIndex] = targetLine.replace(uncheckReplace, '[x]') + newLine = targetLine.replace(uncheckReplace, '[x]') } - this.refs.code.setValue(lines.join('\n')) + this.refs.code.setLineContent(lineIndex, newLine) } } From 08070f3e2dbdf851544a84b5f6ea99cad920aa76 Mon Sep 17 00:00:00 2001 From: Ronald Walker Date: Tue, 30 Jul 2019 17:04:36 -0700 Subject: [PATCH 56/63] fix #3144 --- browser/components/MarkdownPreview.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index cc2e8166..d95b7898 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -246,8 +246,11 @@ export default class MarkdownPreview extends React.Component { handleContextMenu (event) { const menu = buildMarkdownPreviewContextMenu(this, event) - if (menu != null) { + const switchPreview = ConfigManager.get().editor.switchPreview + if (menu != null && switchPreview !== 'RIGHTCLICK') { menu.popup(remote.getCurrentWindow()) + } else if (_.isFunction(this.props.onContextMenu)) { + this.props.onContextMenu(event) } } From a47dac2854083b1a57af9c154d1bc4b1a63fb764 Mon Sep 17 00:00:00 2001 From: alwxkxk Date: Mon, 29 Jul 2019 11:04:27 +0800 Subject: [PATCH 57/63] fix #3159 --- browser/lib/markdown-it-sanitize-html.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/browser/lib/markdown-it-sanitize-html.js b/browser/lib/markdown-it-sanitize-html.js index 3325604a..641216e3 100644 --- a/browser/lib/markdown-it-sanitize-html.js +++ b/browser/lib/markdown-it-sanitize-html.js @@ -96,6 +96,10 @@ function sanitizeInline (html, options) { function naughtyHRef (href, options) { // href = href.replace(/[\x00-\x20]+/g, '') + if (!href) { + // No href + return false + } href = href.replace(/<\!\-\-.*?\-\-\>/g, '') const matches = href.match(/^([a-zA-Z]+)\:/) From 330a444fc5cf63d74ea9e174c67c89adde60f123 Mon Sep 17 00:00:00 2001 From: hikerpig Date: Sun, 28 Jul 2019 14:31:33 +0800 Subject: [PATCH 58/63] optimize: should highlight any non-empty search query, fix #3164 --- 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 c972103e..743d4feb 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -106,7 +106,7 @@ export default class CodeEditor extends React.Component { const component = this if (component.searchState) cm.removeOverlay(component.searchState) - if (msg.length < 3) return + if (msg.length < 1) return cm.operation(function () { component.searchState = makeOverlay(msg, 'searching') From 084decaa85f92543e33b87c1829da44a0ac31c0f Mon Sep 17 00:00:00 2001 From: hikerpig Date: Sun, 28 Jul 2019 16:42:57 +0800 Subject: [PATCH 59/63] improvement: MarkdownPreview, `rewriteIframe` attempt can be combined to one call --- browser/components/MarkdownPreview.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index d95b7898..63db2dd5 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -558,7 +558,9 @@ export default class MarkdownPreview extends React.Component { } componentDidUpdate (prevProps) { - if (prevProps.value !== this.props.value) this.rewriteIframe() + // actual rewriteIframe function should be called only once + let needsRewriteIframe = false + if (prevProps.value !== this.props.value) needsRewriteIframe = true if ( prevProps.smartQuotes !== this.props.smartQuotes || prevProps.sanitize !== this.props.sanitize || @@ -568,7 +570,7 @@ export default class MarkdownPreview extends React.Component { prevProps.lineThroughCheckbox !== this.props.lineThroughCheckbox ) { this.initMarkdown() - this.rewriteIframe() + needsRewriteIframe = true } if ( prevProps.fontFamily !== this.props.fontFamily || @@ -583,6 +585,10 @@ export default class MarkdownPreview extends React.Component { prevProps.customCSS !== this.props.customCSS ) { this.applyStyle() + needsRewriteIframe = true + } + + if (needsRewriteIframe) { this.rewriteIframe() } } From 25ef456af25706874a5f69d58d4bf54a97c4c72c Mon Sep 17 00:00:00 2001 From: hikerpig Date: Sun, 28 Jul 2019 16:53:21 +0800 Subject: [PATCH 60/63] feat: should scroll to top after selecting another note, also fix #3023 --- browser/components/MarkdownPreview.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index 63db2dd5..302575e8 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -591,6 +591,11 @@ export default class MarkdownPreview extends React.Component { if (needsRewriteIframe) { this.rewriteIframe() } + + // Should scroll to top after selecting another note + if (prevProps.noteKey !== this.props.noteKey) { + this.getWindow().scrollTo(0, 0) + } } getStyleParams () { @@ -962,8 +967,6 @@ export default class MarkdownPreview extends React.Component { overlay.appendChild(zoomImg) document.body.appendChild(overlay) } - - this.getWindow().scrollTo(0, 0) } focus () { From 7d0404657e82b63066107a11c2e617eb29dfba00 Mon Sep 17 00:00:00 2001 From: AWolf81 Date: Thu, 1 Aug 2019 00:16:49 +0200 Subject: [PATCH 61/63] Fix routing for tag filtering --- browser/main/Detail/MarkdownNoteDetail.js | 3 ++- browser/main/Detail/SnippetNoteDetail.js | 3 ++- browser/main/Detail/TagSelect.js | 13 +++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index a3b69469..5ed45916 100755 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -409,7 +409,7 @@ class MarkdownNoteDetail extends React.Component { } render () { - const { data, location, config } = this.props + const { data, dispatch, location, config } = this.props const { note, editorType } = this.state const storageKey = note.storage const folderKey = note.folder @@ -464,6 +464,7 @@ class MarkdownNoteDetail extends React.Component { saveTagsAlphabetically={config.ui.saveTagsAlphabetically} showTagsAlphabetically={config.ui.showTagsAlphabetically} data={data} + dispatch={dispatch} onChange={this.handleUpdateTag.bind(this)} coloredTags={config.coloredTags} /> diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js index 2ae01082..ec9a1d0b 100644 --- a/browser/main/Detail/SnippetNoteDetail.js +++ b/browser/main/Detail/SnippetNoteDetail.js @@ -699,7 +699,7 @@ class SnippetNoteDetail extends React.Component { } render () { - const { data, config, location } = this.props + const { data, dispatch, config, location } = this.props const { note } = this.state const storageKey = note.storage @@ -823,6 +823,7 @@ class SnippetNoteDetail extends React.Component { saveTagsAlphabetically={config.ui.saveTagsAlphabetically} showTagsAlphabetically={config.ui.showTagsAlphabetically} data={data} + dispatch={dispatch} onChange={(e) => this.handleChange(e)} coloredTags={config.coloredTags} /> diff --git a/browser/main/Detail/TagSelect.js b/browser/main/Detail/TagSelect.js index e3d9a567..615cb5d2 100644 --- a/browser/main/Detail/TagSelect.js +++ b/browser/main/Detail/TagSelect.js @@ -8,6 +8,7 @@ import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig' import i18n from 'browser/lib/i18n' import ee from 'browser/main/lib/eventEmitter' import Autosuggest from 'react-autosuggest' +import { push } from 'connected-react-router' class TagSelect extends React.Component { constructor (props) { @@ -96,8 +97,11 @@ class TagSelect extends React.Component { } handleTagLabelClick (tag) { - const { router } = this.context - router.push(`/tags/${tag}`) + const { dispatch } = this.props + + // Note: `tag` requires encoding later. + // E.g. % in tag is a problem (see issue #3170) - encodeURIComponent(tag) is not working. + dispatch(push(`/tags/${tag}`)) } handleTagRemoveButtonClick (tag) { @@ -255,11 +259,8 @@ class TagSelect extends React.Component { } } -TagSelect.contextTypes = { - router: PropTypes.shape({}) -} - TagSelect.propTypes = { + dispatch: PropTypes.func, className: PropTypes.string, value: PropTypes.arrayOf(PropTypes.string), onChange: PropTypes.func, From 2f1dadfc3e65fd75a27491302942013a0c109c0a Mon Sep 17 00:00:00 2001 From: AWolf81 Date: Thu, 1 Aug 2019 18:18:14 +0200 Subject: [PATCH 62/63] Change drag disable styles to be more specific --- browser/main/Detail/MarkdownNoteDetail.styl | 9 +-------- browser/main/Detail/NoteDetailInfo.styl | 10 +++++++++- browser/main/Detail/ToggleModeButton.styl | 7 +++++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/browser/main/Detail/MarkdownNoteDetail.styl b/browser/main/Detail/MarkdownNoteDetail.styl index 819bef2e..a24e9881 100644 --- a/browser/main/Detail/MarkdownNoteDetail.styl +++ b/browser/main/Detail/MarkdownNoteDetail.styl @@ -81,11 +81,4 @@ body[data-theme="dracula"] .root border-left 1px solid $ui-dracula-borderColor background-color $ui-dracula-noteDetail-backgroundColor - -div - > button, div - -webkit-user-drag none - user-select none - > img, span - -webkit-user-drag none - user-select none + diff --git a/browser/main/Detail/NoteDetailInfo.styl b/browser/main/Detail/NoteDetailInfo.styl index 1ca46516..21670a1b 100644 --- a/browser/main/Detail/NoteDetailInfo.styl +++ b/browser/main/Detail/NoteDetailInfo.styl @@ -107,4 +107,12 @@ body[data-theme="monokai"] body[data-theme="dracula"] .info border-color $ui-dracula-borderColor - background-color $ui-dracula-noteDetail-backgroundColor \ No newline at end of file + background-color $ui-dracula-noteDetail-backgroundColor + +.info > div + > button + -webkit-user-drag none + user-select none + > img, span + -webkit-user-drag none + user-select none \ No newline at end of file diff --git a/browser/main/Detail/ToggleModeButton.styl b/browser/main/Detail/ToggleModeButton.styl index 2b47b932..39d30973 100644 --- a/browser/main/Detail/ToggleModeButton.styl +++ b/browser/main/Detail/ToggleModeButton.styl @@ -75,3 +75,10 @@ body[data-theme="dracula"] .active background-color #bd93f9 box-shadow 2px 0px 7px #222222 + +.control-toggleModeButton + -webkit-user-drag none + user-select none + > div img + -webkit-user-drag none + user-select none From 857e75594de9a5980d7236e67a0cf0ea93305617 Mon Sep 17 00:00:00 2001 From: AWolf81 Date: Thu, 1 Aug 2019 01:35:11 +0200 Subject: [PATCH 63/63] Disable Javascript for printout window --- 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 302575e8..15941cf8 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -363,7 +363,7 @@ export default class MarkdownPreview extends React.Component { handleSaveAsPdf () { this.exportAsDocument('pdf', (noteContent, exportTasks, targetDir) => { - const printout = new remote.BrowserWindow({show: false, webPreferences: {webSecurity: false}}) + const printout = new remote.BrowserWindow({show: false, webPreferences: {webSecurity: false, javascript: false}}) printout.loadURL('data:text/html;charset=UTF-8,' + this.htmlContentFormatter(noteContent, exportTasks, targetDir)) return new Promise((resolve, reject) => { printout.webContents.on('did-finish-load', () => {