Merge 580a4b0286737a49ce5d0116ffc88da1f508b27c into 6abda7ab68cc20f4aca870eb243747951b90ab04

This commit is contained in:
Psycho 2016-07-20 09:55:44 +00:00 committed by GitHub
commit bb56ba8b83
4 changed files with 21 additions and 31 deletions

View File

@ -3,7 +3,6 @@ node_js:
- '6' - '6'
- '5' - '5'
- '4' - '4'
- '0.12'
before_script: before_script:
- npm install -g gulp - npm install -g gulp
script: gulp script: gulp

View File

@ -88,16 +88,18 @@ simplemde.value("This text will appear in the editor");
- link - link
- table - table
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`. - **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
- **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). - **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`. - **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`. - **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`. - **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. - **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`. - **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). - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
- **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:<br>`<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>`<br>`<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">` - **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:<br>`<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>`<br>`<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">`
- **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). - **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. - **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`. - **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
@ -133,6 +135,7 @@ var simplemde = new SimpleMDE({
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"], table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
}, },
lineWrapping: false, lineWrapping: false,
minHeight: "500px",
parsingConfig: { parsingConfig: {
allowAtxHeaderWithoutSpace: true, allowAtxHeaderWithoutSpace: true,
strikethrough: false, strikethrough: false,
@ -276,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). 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 ## Event handling
You can catch the following list of events: https://codemirror.net/doc/manual.html#events You can catch the following list of events: https://codemirror.net/doc/manual.html#events

View File

@ -1,6 +1,5 @@
.CodeMirror { .CodeMirror {
height: auto; height: auto;
min-height: 300px;
border: 1px solid #ddd; border: 1px solid #ddd;
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
@ -9,10 +8,6 @@
z-index: 1; z-index: 1;
} }
.CodeMirror-scroll {
min-height: 300px
}
.CodeMirror-fullscreen { .CodeMirror-fullscreen {
background: #fff; background: #fff;
position: fixed !important; position: fixed !important;
@ -22,6 +17,8 @@
bottom: 0; bottom: 0;
height: auto; height: auto;
z-index: 9; z-index: 9;
border-right: none !important;
border-bottom-right-radius: 0 !important;
} }
.CodeMirror-sided { .CodeMirror-sided {

View File

@ -795,8 +795,9 @@ function _replaceSelection(cm, active, startEnd, url) {
var text; var text;
var start = startEnd[0]; var start = startEnd[0];
var end = startEnd[1]; var end = startEnd[1];
var startPoint = cm.getCursor("start"); var startPoint = {}, endPoint = {};
var endPoint = cm.getCursor("end"); Object.assign(startPoint, cm.getCursor("start"));
Object.assign(endPoint, cm.getCursor("end"));
if(url) { if(url) {
end = end.replace("#url#", url); end = end.replace("#url#", url);
} }
@ -1364,6 +1365,8 @@ function SimpleMDE(options) {
// Merging the shortcuts, with the given options // Merging the shortcuts, with the given options
options.shortcuts = extend({}, shortcuts, options.shortcuts || {}); options.shortcuts = extend({}, shortcuts, options.shortcuts || {});
options.minHeight = options.minHeight || "300px";
// Change unique_id to uniqueId for backwards compatibility // Change unique_id to uniqueId for backwards compatibility
if(options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != "") if(options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != "")
@ -1392,8 +1395,12 @@ function SimpleMDE(options) {
SimpleMDE.prototype.markdown = function(text) { SimpleMDE.prototype.markdown = function(text) {
if(marked) { if(marked) {
// Initialize // Initialize
var markedOptions = {}; var markedOptions;
if(this.options && this.options.renderingConfig && this.options.renderingConfig.markedOptions) {
markedOptions = this.options.renderingConfig.markedOptions;
} else {
markedOptions = {};
}
// Update options // Update options
if(this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks === false) { if(this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks === false) {
@ -1495,6 +1502,8 @@ SimpleMDE.prototype.render = function(el) {
styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : true styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : true
}); });
this.codemirror.getScrollerElement().style.minHeight = options.minHeight;
if(options.forceSync === true) { if(options.forceSync === true) {
var cm = this.codemirror; var cm = this.codemirror;
cm.on("change", function() { cm.on("change", function() {