diff --git a/README.md b/README.md index 3f2bdb8..451c3c0 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ easyMDE.value('New input for **EasyMDE**'); - table - **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"`. Defaults to `"300px"`. +- **maxHeight**: Sets fixed height for the composition area. `minHeight` option will be ignored. Should be a string containing a valid CSS value like `"500px"`. Defaults to `undefined`. - **onToggleFullScreen**: A function that gets called when the editor's full screen mode is toggled. The function will be passed a boolean as parameter, `true` when the editor is currently going into full screen mode, or `false`. - **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`. @@ -244,10 +245,10 @@ var editor = new EasyMDE({ underscoresBreakWords: true, }, placeholder: "Type here...", - + previewClass: "my-custom-styling", previewClass: ["my-custom-styling", "more-custom-styling"], - + previewRender: function(plainText) { return customMarkdownParser(plainText); // Returns HTML from a custom parser }, diff --git a/src/js/easymde.js b/src/js/easymde.js index 62aaa69..e5bba82 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -342,13 +342,11 @@ function toggleFullScreen(editor) { } // Remove or set maxHeight - if (cm.getOption('fullScreen')) { - if (editor.options.maxHeight !== false) { + if (typeof editor.options.maxHeight !== 'undefined') { + if (cm.getOption('fullScreen')) { cm.getScrollerElement().style.removeProperty('height'); sidebyside.style.removeProperty('height'); - } - } else { - if (editor.options.maxHeight !== false) { + } else { cm.getScrollerElement().style.height = editor.options.maxHeight; editor.setPreviewMaxHeight(); } @@ -1721,7 +1719,7 @@ function EasyMDE(options) { options.shortcuts = extend({}, shortcuts, options.shortcuts || {}); options.minHeight = options.minHeight || '300px'; - options.maxHeight = options.maxHeight || false; + options.maxHeight = options.maxHeight || undefined; options.errorCallback = options.errorCallback || function (errorMessage) { alert(errorMessage); @@ -2009,7 +2007,7 @@ EasyMDE.prototype.render = function (el) { this.codemirror.getScrollerElement().style.minHeight = options.minHeight; - if (options.maxHeight !== false) { + if (typeof options.maxHeight !== 'undefined') { this.codemirror.getScrollerElement().style.height = options.maxHeight; } @@ -2330,7 +2328,7 @@ EasyMDE.prototype.createSideBySide = function () { wrapper.parentNode.insertBefore(preview, wrapper.nextSibling); } - if (this.options.maxHeight !== false) { + if (typeof this.options.maxHeight !== 'undefined') { this.setPreviewMaxHeight(); } diff --git a/types/easymde-test.ts b/types/easymde-test.ts index fdf6077..32239db 100644 --- a/types/easymde-test.ts +++ b/types/easymde-test.ts @@ -182,6 +182,7 @@ new EasyMDE({ new EasyMDE({ sideBySideFullscreen: false, + maxHeight: '500px', toolbar: [ 'bold', 'italic', diff --git a/types/easymde.d.ts b/types/easymde.d.ts index 1e04120..b4c8045 100644 --- a/types/easymde.d.ts +++ b/types/easymde.d.ts @@ -172,6 +172,7 @@ declare namespace EasyMDE { insertTexts?: InsertTextOptions; lineWrapping?: boolean; minHeight?: string; + maxHeight?: string; parsingConfig?: ParsingOptions; placeholder?: string; previewClass?: string | ReadonlyArray;