From b0b2f1d4a369fa04479d9048250a74b798f54ae8 Mon Sep 17 00:00:00 2001 From: Josh Schonstal Date: Wed, 22 Jun 2016 09:36:09 -0700 Subject: [PATCH 1/7] Allow user to configure marked options --- README.md | 1 + src/js/simplemde.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03793c9..8e46969 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ simplemde.value("This text will appear in the editor"); - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews. - **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`. - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing). + - **markedOptions**: Set default marked markdown renderer default [options](https://github.com/chjj/marked#options-1). `singleLineBreaks` and `codeSyntaxHighlighting` options below will take precedence. - **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`. - **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page. For example, include the script and the CSS files like:
``
`` - **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts). diff --git a/src/js/simplemde.js b/src/js/simplemde.js index 016d693..a110ef4 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -1392,8 +1392,12 @@ function SimpleMDE(options) { SimpleMDE.prototype.markdown = function(text) { if(marked) { // Initialize - var markedOptions = {}; - + var markedOptions; + if(this.options && this.options.renderingConfig && this.options.renderingConfig.markedOptions) { + markedOptions = this.options.renderingConfig.markedOptions; + } else { + markedOptions = {}; + } // Update options if(this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks === false) { From 5081e100a6d83dd5ee07d828b40c76e2951ab69e Mon Sep 17 00:00:00 2001 From: Wes Cossick Date: Wed, 22 Jun 2016 13:00:10 -0500 Subject: [PATCH 2/7] Tweak README wording --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e46969..eef4675 100644 --- a/README.md +++ b/README.md @@ -96,9 +96,9 @@ simplemde.value("This text will appear in the editor"); - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews. - **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`. - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing). - - **markedOptions**: Set default marked markdown renderer default [options](https://github.com/chjj/marked#options-1). `singleLineBreaks` and `codeSyntaxHighlighting` options below will take precedence. - - **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`. - **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page. For example, include the script and the CSS files like:
``
`` + - **markedOptions**: Set the internal Markdown renderer's [options](https://github.com/chjj/marked#options-1). Other `renderingConfig` options will take precedence. + - **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`. - **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts). - **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar. - **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`. From 517d5ee2497b089a8920c34205029eac5888d6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 8 Jul 2016 15:31:30 +0200 Subject: [PATCH 3/7] Add an option indicating a minimal height of the editable area. --- README.md | 1 + src/css/simplemde.css | 5 ----- src/js/simplemde.js | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index eef4675..b36645f 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ simplemde.value("This text will appear in the editor"); - link - table - **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`. +- **minHeight**: A minimal height of the editable area. Should be a string containing a valid CSS value like: `"400px"`. Dafaults to `"300px"`. - **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing). - **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`. - **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`. diff --git a/src/css/simplemde.css b/src/css/simplemde.css index fb0e4c7..9f5a61e 100644 --- a/src/css/simplemde.css +++ b/src/css/simplemde.css @@ -1,6 +1,5 @@ .CodeMirror { height: auto; - min-height: 300px; border: 1px solid #ddd; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; @@ -9,10 +8,6 @@ z-index: 1; } -.CodeMirror-scroll { - min-height: 300px -} - .CodeMirror-fullscreen { background: #fff; position: fixed !important; diff --git a/src/js/simplemde.js b/src/js/simplemde.js index a110ef4..a5c1998 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -1364,6 +1364,8 @@ function SimpleMDE(options) { // Merging the shortcuts, with the given options options.shortcuts = extend({}, shortcuts, options.shortcuts || {}); + options.minHeight = options.minHeight || "300px"; + // Change unique_id to uniqueId for backwards compatibility if(options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != "") @@ -1499,6 +1501,8 @@ SimpleMDE.prototype.render = function(el) { styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : true }); + this.codemirror.getScrollerElement().style.minHeight = options.minHeight; + if(options.forceSync === true) { var cm = this.codemirror; cm.on("change", function() { From 69a63791f03749ae1a80f2af7fb26b7d2524f8e9 Mon Sep 17 00:00:00 2001 From: Wes Cossick Date: Sun, 10 Jul 2016 13:02:32 -0500 Subject: [PATCH 4/7] Remove support for Node.js version 0.12.x. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4515f20..eec94e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ node_js: - '6' - '5' - '4' -- '0.12' before_script: - npm install -g gulp script: gulp From 1872a278c6e9ba1c870c55bd42b0ce3b0c3d1fcb Mon Sep 17 00:00:00 2001 From: Wes Cossick Date: Sun, 10 Jul 2016 13:07:00 -0500 Subject: [PATCH 5/7] Tweak wording for minHeight setting --- README.md | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b36645f..6f98ca0 100644 --- a/README.md +++ b/README.md @@ -88,12 +88,12 @@ simplemde.value("This text will appear in the editor"); - link - table - **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`. -- **minHeight**: A minimal height of the editable area. Should be a string containing a valid CSS value like: `"400px"`. Dafaults to `"300px"`. +- **minHeight**: Sets the minimum height for the composition area, before it starts auto-growing. Should be a string containing a valid CSS value like `"500px"`. Dafaults to `"300px"`. - **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing). - **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`. - **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`. - **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`. -- **placeholder**: Custom placeholder that should be displayed +- **placeholder**: If set, displays a custom placeholder message. - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews. - **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`. - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing). @@ -135,6 +135,7 @@ var simplemde = new SimpleMDE({ table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"], }, lineWrapping: false, + minHeight: "500px", parsingConfig: { allowAtxHeaderWithoutSpace: true, strikethrough: false, @@ -278,24 +279,6 @@ Shortcuts are automatically converted between platforms. If you define a shortcu The list of actions that can be bound is the same as the list of built-in actions available for [toolbar buttons](#toolbar-icons). -#### Height - -To change the minimum height (before it starts auto-growing): - -```CSS -.CodeMirror, .CodeMirror-scroll { - min-height: 200px; -} -``` - -Or, you can keep the height static: - -```CSS -.CodeMirror { - height: 300px; -} -``` - ## Event handling You can catch the following list of events: https://codemirror.net/doc/manual.html#events From 8c9667980cb60c94a7695f229d367a747d1c040e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Masson?= Date: Sun, 10 Jul 2016 21:58:46 +0200 Subject: [PATCH 6/7] Delete editor right border + its radius in full screen mode --- src/css/simplemde.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/css/simplemde.css b/src/css/simplemde.css index fb0e4c7..1a7e775 100644 --- a/src/css/simplemde.css +++ b/src/css/simplemde.css @@ -22,6 +22,8 @@ bottom: 0; height: auto; z-index: 9; + border-right: none !important; + border-bottom-right-radius: 0 !important; } .CodeMirror-sided { From 6250a7d7e7d4dc0e49fbc2e3035ac1881f9ee123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 12 Jul 2016 00:53:45 +0200 Subject: [PATCH 7/7] Fix bug with inserting links and undoing things. --- src/js/simplemde.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/simplemde.js b/src/js/simplemde.js index 016d693..44a3ae7 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -795,8 +795,9 @@ function _replaceSelection(cm, active, startEnd, url) { var text; var start = startEnd[0]; var end = startEnd[1]; - var startPoint = cm.getCursor("start"); - var endPoint = cm.getCursor("end"); + var startPoint = {}, endPoint = {}; + Object.assign(startPoint, cm.getCursor("start")); + Object.assign(endPoint, cm.getCursor("end")); if(url) { end = end.replace("#url#", url); } @@ -2025,4 +2026,4 @@ SimpleMDE.prototype.toTextArea = function() { } }; -module.exports = SimpleMDE; \ No newline at end of file +module.exports = SimpleMDE;