Merge e32fe3f91c2d45f27f72a3662133b1c0e1a5bda1 into 6abda7ab68cc20f4aca870eb243747951b90ab04

This commit is contained in:
F-loat 2017-10-16 15:43:59 +00:00 committed by GitHub
commit 6684b4fe46
14 changed files with 459 additions and 231 deletions

5
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,5 @@
If you're submitting a bug, complete these tasks:
- Set up a [JSFiddle](https://jsfiddle.net/) that replicates the bug
- Link to your JSFiddle
- Provide an exact list of step-by-step instructions that will replicate the bug

View File

@ -3,16 +3,15 @@ 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
deploy: deploy:
provider: npm provider: npm
email: support@nextstepwebs.com email: support@sparksuite.com
api_key: api_key:
secure: nADZupyOhJAhTQgr5uOIydbDEjCTAj+3nGHW7ZBJUrVJcb0uR4pg8ngmwrUpvaCeNXgKPG9Uag75/mPcBre9ly2cigBIG9LHlxImlF8qi1jRJykcNRmBb9N2MJJj+zdAMwLaF5Ns+f2v3zt97qxovbEzunhXGcZeCaxc6y40nDM8OTyo0PESNBjQYqaNblt2gO2KHysrwFL8i4kCCKLa+HOBLu2iqgk/fYVqTmfhEeOiiwQ4lIXJeyPyzgb3OPhKCMV1FI5H0T48fRD0MPczt8ds3Daj1OjCbIZurQ7s1dcKwz1g6TKATN59HcMsSarW4lImrEeYmfQxz2F5NjKDRhnith5V0W2IssrkpDG9teTFQ20eQdl5cpnlGjgBvsjb8GhPLR44GvefyJL4+kJGI3O1KVq3/7wbmu/IXrvhtKHEQSdGL2PTqW8QxKasAoUCnk3LGZKN12g8bg0xDg2tvoCUk5Z3asHLRdCJpDbBq1h8QfZ4HV5VLYjr84xduOUZbEUtfMVAixPpJ4h1E3OXJ1wil97BlHjxOZ8JkkxJg5lgSUZ/O/QWwJokEAYXR9c+ouMoVokChAyleV77cRZ5qLn9zbnUxZtnKX8w0IUKeu95/z8QgiaRcERKVCpZvceo8Qw0Y+JoiEtno7Zg/nsrZGxsS6K/V3yg1QQmT3bjDHQ= secure: nADZupyOhJAhTQgr5uOIydbDEjCTAj+3nGHW7ZBJUrVJcb0uR4pg8ngmwrUpvaCeNXgKPG9Uag75/mPcBre9ly2cigBIG9LHlxImlF8qi1jRJykcNRmBb9N2MJJj+zdAMwLaF5Ns+f2v3zt97qxovbEzunhXGcZeCaxc6y40nDM8OTyo0PESNBjQYqaNblt2gO2KHysrwFL8i4kCCKLa+HOBLu2iqgk/fYVqTmfhEeOiiwQ4lIXJeyPyzgb3OPhKCMV1FI5H0T48fRD0MPczt8ds3Daj1OjCbIZurQ7s1dcKwz1g6TKATN59HcMsSarW4lImrEeYmfQxz2F5NjKDRhnith5V0W2IssrkpDG9teTFQ20eQdl5cpnlGjgBvsjb8GhPLR44GvefyJL4+kJGI3O1KVq3/7wbmu/IXrvhtKHEQSdGL2PTqW8QxKasAoUCnk3LGZKN12g8bg0xDg2tvoCUk5Z3asHLRdCJpDbBq1h8QfZ4HV5VLYjr84xduOUZbEUtfMVAixPpJ4h1E3OXJ1wil97BlHjxOZ8JkkxJg5lgSUZ/O/QWwJokEAYXR9c+ouMoVokChAyleV77cRZ5qLn9zbnUxZtnKX8w0IUKeu95/z8QgiaRcERKVCpZvceo8Qw0Y+JoiEtno7Zg/nsrZGxsS6K/V3yg1QQmT3bjDHQ=
on: on:
tags: true tags: true
repo: NextStepWebs/simplemde-markdown-editor repo: sparksuite/simplemde-markdown-editor
branch: production branch: production

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015 Next Step Webs, Inc. Copyright (c) 2015 Sparksuite, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -20,11 +20,11 @@ Via [bower](https://www.bower.io).
bower install simplemde --save bower install simplemde --save
``` ```
Via [jsDelivr](https://www.jsdelivr.com/#!simplemde). *Please note, jsDelivr may take a few days to update to the latest release.* Via [jsDelivr](https://www.jsdelivr.com/).
```HTML ```HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sparksuite/simplemde-markdown-editor@1/dist/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/sparksuite/simplemde-markdown-editor@1/dist/simplemde.min.js"></script>
``` ```
## Quick start ## Quick start
@ -74,9 +74,9 @@ simplemde.value("This text will appear in the editor");
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s). - **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
- **uniqueId**: You must set a unique string identifier so that SimpleMDE can autosave. Something that separates this from other instances of SimpleMDE elsewhere on your website. - **uniqueId**: You must set a unique string identifier so that SimpleMDE can autosave. Something that separates this from other instances of SimpleMDE elsewhere on your website.
- **blockStyles**: Customize how certain buttons that style blocks of text behave. - **blockStyles**: Customize how certain buttons that style blocks of text behave.
- **bold** Can be set to `**` or `__`. Defaults to `**`. - **bold**: Can be set to `**` or `__`. Defaults to `**`.
- **code** Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````. - **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
- **italic** Can be set to `*` or `_`. Defaults to `*`. - **italic**: Can be set to `*` or `_`. Defaults to `*`.
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page. - **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
- **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to `false`. - **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to `false`.
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar. - **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
@ -88,22 +88,29 @@ 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`.
- **promptTexts**: Customize the text used to prompt for URLs.
- **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`.
- **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`.
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing). - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
- **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 or pass in using the `hljs` option. 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">`
- **hljs**: An injectible instance of [highlight.js](https://github.com/isagalaev/highlight.js). If you don't want to rely on the global namespace (`window.hljs`), you can provide an instance here. Defaults to `undefined`.
- **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`. - **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">`
- **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`.
- **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items. - **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items.
- Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items. - Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.
- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`. - **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`.
- **syncSideBySidePreviewScroll**: If set to `false`, disable syncing scroll in side by side mode. Defaults to `true`.
- **tabSize**: If set, customize the tab size. Defaults to `2`. - **tabSize**: If set, customize the tab size. Defaults to `2`.
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons). - **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`. - **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
@ -133,6 +140,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,
@ -150,6 +158,10 @@ var simplemde = new SimpleMDE({
return "Loading..."; return "Loading...";
}, },
promptURLs: true, promptURLs: true,
promptTexts: {
image: "Custom prompt for URL:",
link: "Custom prompt for URL:",
},
renderingConfig: { renderingConfig: {
singleLineBreaks: false, singleLineBreaks: false,
codeSyntaxHighlighting: true, codeSyntaxHighlighting: true,
@ -172,6 +184,7 @@ var simplemde = new SimpleMDE({
} }
}], // Another optional usage, with a custom status bar item that counts keystrokes }], // Another optional usage, with a custom status bar item that counts keystrokes
styleSelectedText: false, styleSelectedText: false,
syncSideBySidePreviewScroll: false,
tabSize: 4, tabSize: 4,
toolbar: false, toolbar: false,
toolbarTips: false, toolbarTips: false,
@ -276,24 +289,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,7 +1,7 @@
{ {
"name": "simplemde", "name": "simplemde",
"version": "1.11.2", "version": "1.11.2",
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor", "homepage": "https://github.com/sparksuite/simplemde-markdown-editor",
"authors": [ "authors": [
"Wes Cossick <https://wescossick.com>" "Wes Cossick <https://wescossick.com>"
], ],

View File

@ -1,7 +1,7 @@
/** /**
* simplemde v1.11.2 * simplemde v1.11.2
* Copyright Next Step Webs, Inc. * Copyright Sparksuite, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor * @link https://github.com/sparksuite/simplemde-markdown-editor
* @license MIT * @license MIT
*/ */
/* BASICS */ /* BASICS */
@ -94,8 +94,14 @@
.cm-tab { display: inline-block; text-decoration: inherit; } .cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: -20px;
overflow: hidden;
}
.CodeMirror-ruler { .CodeMirror-ruler {
border-left: 1px solid #ccc; border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute; position: absolute;
} }
@ -297,7 +303,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
visibility: hidden; visibility: hidden;
} }
.CodeMirror-cursor { position: absolute; } .CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; } .CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors { div.CodeMirror-cursors {
@ -345,7 +354,6 @@ span.CodeMirror-selectedtext { background: none; }
.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;
@ -354,10 +362,6 @@ span.CodeMirror-selectedtext { background: none; }
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;
@ -367,6 +371,8 @@ span.CodeMirror-selectedtext { background: none; }
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 {

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
/** /**
* simplemde v1.11.2 * simplemde v1.11.2
* Copyright Next Step Webs, Inc. * Copyright Sparksuite, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor * @link https://github.com/sparksuite/simplemde-markdown-editor
* @license MIT * @license MIT
*/ */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SimpleMDE = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SimpleMDE = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
@ -173,7 +173,7 @@ exports.kMaxLength = kMaxLength()
function typedArraySupport () { function typedArraySupport () {
try { try {
var arr = new Uint8Array(1) var arr = new Uint8Array(1)
arr.foo = function () { return 42 } arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
return arr.foo() === 42 && // typed array instances can be augmented return arr.foo() === 42 && // typed array instances can be augmented
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
@ -317,7 +317,7 @@ function allocUnsafe (that, size) {
assertSize(size) assertSize(size)
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
if (!Buffer.TYPED_ARRAY_SUPPORT) { if (!Buffer.TYPED_ARRAY_SUPPORT) {
for (var i = 0; i < size; i++) { for (var i = 0; i < size; ++i) {
that[i] = 0 that[i] = 0
} }
} }
@ -373,7 +373,9 @@ function fromArrayBuffer (that, array, byteOffset, length) {
throw new RangeError('\'length\' is out of bounds') throw new RangeError('\'length\' is out of bounds')
} }
if (length === undefined) { if (byteOffset === undefined && length === undefined) {
array = new Uint8Array(array)
} else if (length === undefined) {
array = new Uint8Array(array, byteOffset) array = new Uint8Array(array, byteOffset)
} else { } else {
array = new Uint8Array(array, byteOffset, length) array = new Uint8Array(array, byteOffset, length)
@ -495,14 +497,14 @@ Buffer.concat = function concat (list, length) {
var i var i
if (length === undefined) { if (length === undefined) {
length = 0 length = 0
for (i = 0; i < list.length; i++) { for (i = 0; i < list.length; ++i) {
length += list[i].length length += list[i].length
} }
} }
var buffer = Buffer.allocUnsafe(length) var buffer = Buffer.allocUnsafe(length)
var pos = 0 var pos = 0
for (i = 0; i < list.length; i++) { for (i = 0; i < list.length; ++i) {
var buf = list[i] var buf = list[i]
if (!Buffer.isBuffer(buf)) { if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers') throw new TypeError('"list" argument must be an Array of Buffers')
@ -534,7 +536,6 @@ function byteLength (string, encoding) {
switch (encoding) { switch (encoding) {
case 'ascii': case 'ascii':
case 'binary': case 'binary':
// Deprecated
case 'raw': case 'raw':
case 'raws': case 'raws':
return len return len
@ -772,15 +773,16 @@ function arrayIndexOf (arr, val, byteOffset, encoding) {
} }
var foundIndex = -1 var foundIndex = -1
for (var i = 0; byteOffset + i < arrLength; i++) { for (var i = byteOffset; i < arrLength; ++i) {
if (read(arr, byteOffset + i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i if (foundIndex === -1) foundIndex = i
if (i - foundIndex + 1 === valLength) return (byteOffset + foundIndex) * indexSize if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
} else { } else {
if (foundIndex !== -1) i -= i - foundIndex if (foundIndex !== -1) i -= i - foundIndex
foundIndex = -1 foundIndex = -1
} }
} }
return -1 return -1
} }
@ -845,7 +847,7 @@ function hexWrite (buf, string, offset, length) {
if (length > strLen / 2) { if (length > strLen / 2) {
length = strLen / 2 length = strLen / 2
} }
for (var i = 0; i < length; i++) { for (var i = 0; i < length; ++i) {
var parsed = parseInt(string.substr(i * 2, 2), 16) var parsed = parseInt(string.substr(i * 2, 2), 16)
if (isNaN(parsed)) return i if (isNaN(parsed)) return i
buf[offset + i] = parsed buf[offset + i] = parsed
@ -1059,7 +1061,7 @@ function asciiSlice (buf, start, end) {
var ret = '' var ret = ''
end = Math.min(buf.length, end) end = Math.min(buf.length, end)
for (var i = start; i < end; i++) { for (var i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i] & 0x7F) ret += String.fromCharCode(buf[i] & 0x7F)
} }
return ret return ret
@ -1069,7 +1071,7 @@ function binarySlice (buf, start, end) {
var ret = '' var ret = ''
end = Math.min(buf.length, end) end = Math.min(buf.length, end)
for (var i = start; i < end; i++) { for (var i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i]) ret += String.fromCharCode(buf[i])
} }
return ret return ret
@ -1082,7 +1084,7 @@ function hexSlice (buf, start, end) {
if (!end || end < 0 || end > len) end = len if (!end || end < 0 || end > len) end = len
var out = '' var out = ''
for (var i = start; i < end; i++) { for (var i = start; i < end; ++i) {
out += toHex(buf[i]) out += toHex(buf[i])
} }
return out return out
@ -1125,7 +1127,7 @@ Buffer.prototype.slice = function slice (start, end) {
} else { } else {
var sliceLen = end - start var sliceLen = end - start
newBuf = new Buffer(sliceLen, undefined) newBuf = new Buffer(sliceLen, undefined)
for (var i = 0; i < sliceLen; i++) { for (var i = 0; i < sliceLen; ++i) {
newBuf[i] = this[i + start] newBuf[i] = this[i + start]
} }
} }
@ -1352,7 +1354,7 @@ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
function objectWriteUInt16 (buf, value, offset, littleEndian) { function objectWriteUInt16 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffff + value + 1 if (value < 0) value = 0xffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
(littleEndian ? i : 1 - i) * 8 (littleEndian ? i : 1 - i) * 8
} }
@ -1386,7 +1388,7 @@ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert
function objectWriteUInt32 (buf, value, offset, littleEndian) { function objectWriteUInt32 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffffffff + value + 1 if (value < 0) value = 0xffffffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
} }
} }
@ -1601,12 +1603,12 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
if (this === target && start < targetStart && targetStart < end) { if (this === target && start < targetStart && targetStart < end) {
// descending copy from end // descending copy from end
for (i = len - 1; i >= 0; i--) { for (i = len - 1; i >= 0; --i) {
target[i + targetStart] = this[i + start] target[i + targetStart] = this[i + start]
} }
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
// ascending copy from start // ascending copy from start
for (i = 0; i < len; i++) { for (i = 0; i < len; ++i) {
target[i + targetStart] = this[i + start] target[i + targetStart] = this[i + start]
} }
} else { } else {
@ -1667,7 +1669,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
var i var i
if (typeof val === 'number') { if (typeof val === 'number') {
for (i = start; i < end; i++) { for (i = start; i < end; ++i) {
this[i] = val this[i] = val
} }
} else { } else {
@ -1675,7 +1677,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
? val ? val
: utf8ToBytes(new Buffer(val, encoding).toString()) : utf8ToBytes(new Buffer(val, encoding).toString())
var len = bytes.length var len = bytes.length
for (i = 0; i < end - start; i++) { for (i = 0; i < end - start; ++i) {
this[i + start] = bytes[i % len] this[i + start] = bytes[i % len]
} }
} }
@ -1717,7 +1719,7 @@ function utf8ToBytes (string, units) {
var leadSurrogate = null var leadSurrogate = null
var bytes = [] var bytes = []
for (var i = 0; i < length; i++) { for (var i = 0; i < length; ++i) {
codePoint = string.charCodeAt(i) codePoint = string.charCodeAt(i)
// is surrogate component // is surrogate component
@ -1792,7 +1794,7 @@ function utf8ToBytes (string, units) {
function asciiToBytes (str) { function asciiToBytes (str) {
var byteArray = [] var byteArray = []
for (var i = 0; i < str.length; i++) { for (var i = 0; i < str.length; ++i) {
// Node's code seems to be doing this and not & 0x7F.. // Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i) & 0xFF) byteArray.push(str.charCodeAt(i) & 0xFF)
} }
@ -1802,7 +1804,7 @@ function asciiToBytes (str) {
function utf16leToBytes (str, units) { function utf16leToBytes (str, units) {
var c, hi, lo var c, hi, lo
var byteArray = [] var byteArray = []
for (var i = 0; i < str.length; i++) { for (var i = 0; i < str.length; ++i) {
if ((units -= 2) < 0) break if ((units -= 2) < 0) break
c = str.charCodeAt(i) c = str.charCodeAt(i)
@ -1820,7 +1822,7 @@ function base64ToBytes (str) {
} }
function blitBuffer (src, dst, offset, length) { function blitBuffer (src, dst, offset, length) {
for (var i = 0; i < length; i++) { for (var i = 0; i < length; ++i) {
if ((i + offset >= dst.length) || (i >= src.length)) break if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i] dst[i + offset] = src[i]
} }
@ -3543,7 +3545,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
}; };
function hiddenTextarea() { function hiddenTextarea() {
var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none"); var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
// The textarea is kept positioned near the cursor to prevent the // The textarea is kept positioned near the cursor to prevent the
// fact that it'll be scrolled into view on input from scrolling // fact that it'll be scrolled into view on input from scrolling
@ -5010,6 +5012,16 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}; return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
} }
function getUsefulRect(rects, bias) {
var rect = nullRect
if (bias == "left") for (var i = 0; i < rects.length; i++) {
if ((rect = rects[i]).left != rect.right) break
} else for (var i = rects.length - 1; i >= 0; i--) {
if ((rect = rects[i]).left != rect.right) break
}
return rect
}
function measureCharInner(cm, prepared, ch, bias) { function measureCharInner(cm, prepared, ch, bias) {
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
var node = place.node, start = place.start, end = place.end, collapse = place.collapse; var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
@ -5019,17 +5031,10 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start; while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end; while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) { if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
rect = node.parentNode.getBoundingClientRect(); rect = node.parentNode.getBoundingClientRect();
} else if (ie && cm.options.lineWrapping) { else
var rects = range(node, start, end).getClientRects(); rect = getUsefulRect(range(node, start, end).getClientRects(), bias)
if (rects.length)
rect = rects[bias == "right" ? rects.length - 1 : 0];
else
rect = nullRect;
} else {
rect = range(node, start, end).getBoundingClientRect() || nullRect;
}
if (rect.left || rect.right || start == 0) break; if (rect.left || rect.right || start == 0) break;
end = start; end = start;
start = start - 1; start = start - 1;
@ -5255,10 +5260,23 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
for (;;) { for (;;) {
if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) { if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
var ch = x < fromX || x - fromX <= toX - x ? from : to; var ch = x < fromX || x - fromX <= toX - x ? from : to;
var outside = ch == from ? fromOutside : toOutside
var xDiff = x - (ch == from ? fromX : toX); var xDiff = x - (ch == from ? fromX : toX);
// This is a kludge to handle the case where the coordinates
// are after a line-wrapped line. We should replace it with a
// more general handling of cursor positions around line
// breaks. (Issue #4078)
if (toOutside && !bidi && !/\s/.test(lineObj.text.charAt(ch)) && xDiff > 0 &&
ch < lineObj.text.length && preparedMeasure.view.measure.heights.length > 1) {
var charSize = measureCharPrepared(cm, preparedMeasure, ch, "right");
if (innerOff <= charSize.bottom && innerOff >= charSize.top && Math.abs(x - charSize.right) < xDiff) {
outside = false
ch++
xDiff = x - charSize.right
}
}
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch; while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside, var pos = PosWithInfo(lineNo, ch, outside, xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
return pos; return pos;
} }
var step = Math.ceil(dist / 2), middle = from + step; var step = Math.ceil(dist / 2), middle = from + step;
@ -5982,6 +6000,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
// Let the drag handler handle this. // Let the drag handler handle this.
if (webkit) display.scroller.draggable = true; if (webkit) display.scroller.draggable = true;
cm.state.draggingText = dragEnd; cm.state.draggingText = dragEnd;
dragEnd.copy = mac ? e.altKey : e.ctrlKey
// IE's approach to draggable // IE's approach to draggable
if (display.scroller.dragDrop) display.scroller.dragDrop(); if (display.scroller.dragDrop) display.scroller.dragDrop();
on(document, "mouseup", dragEnd); on(document, "mouseup", dragEnd);
@ -6212,7 +6231,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
try { try {
var text = e.dataTransfer.getData("Text"); var text = e.dataTransfer.getData("Text");
if (text) { if (text) {
if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey)) if (cm.state.draggingText && !cm.state.draggingText.copy)
var selected = cm.listSelections(); var selected = cm.listSelections();
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
if (selected) for (var i = 0; i < selected.length; ++i) if (selected) for (var i = 0; i < selected.length; ++i)
@ -6727,7 +6746,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
// Revert a change stored in a document's history. // Revert a change stored in a document's history.
function makeChangeFromHistory(doc, type, allowSelectionOnly) { function makeChangeFromHistory(doc, type, allowSelectionOnly) {
if (doc.cm && doc.cm.state.suppressEdits) return; if (doc.cm && doc.cm.state.suppressEdits && !allowSelectionOnly) return;
var hist = doc.history, event, selAfter = doc.sel; var hist = doc.history, event, selAfter = doc.sel;
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
@ -9252,6 +9271,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content, var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
col: 0, pos: 0, cm: cm, col: 0, pos: 0, cm: cm,
trailingSpace: false,
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
lineView.measure = {}; lineView.measure = {};
@ -9313,7 +9333,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
// the line map. Takes care to render special characters separately. // the line map. Takes care to render special characters separately.
function buildToken(builder, text, style, startStyle, endStyle, title, css) { function buildToken(builder, text, style, startStyle, endStyle, title, css) {
if (!text) return; if (!text) return;
var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text; var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
var special = builder.cm.state.specialChars, mustWrap = false; var special = builder.cm.state.specialChars, mustWrap = false;
if (!special.test(text)) { if (!special.test(text)) {
builder.col += text.length; builder.col += text.length;
@ -9358,6 +9378,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
builder.pos++; builder.pos++;
} }
} }
builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32
if (style || startStyle || endStyle || mustWrap || css) { if (style || startStyle || endStyle || mustWrap || css) {
var fullStyle = style || ""; var fullStyle = style || "";
if (startStyle) fullStyle += startStyle; if (startStyle) fullStyle += startStyle;
@ -9369,11 +9390,17 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
builder.content.appendChild(content); builder.content.appendChild(content);
} }
function splitSpaces(old) { function splitSpaces(text, trailingBefore) {
var out = " "; if (text.length > 1 && !/ /.test(text)) return text
for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0"; var spaceBefore = trailingBefore, result = ""
out += " "; for (var i = 0; i < text.length; i++) {
return out; var ch = text.charAt(i)
if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
ch = "\u00a0"
result += ch
spaceBefore = ch == " "
}
return result
} }
// Work around nonsense dimensions being reported for stretches of // Work around nonsense dimensions being reported for stretches of
@ -9410,6 +9437,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
builder.content.appendChild(widget); builder.content.appendChild(widget);
} }
builder.pos += size; builder.pos += size;
builder.trailingSpace = false
} }
// Outputs a number of spans to make up a line, taking highlighting // Outputs a number of spans to make up a line, taking highlighting
@ -10857,8 +10885,9 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
if (badBidiRects != null) return badBidiRects; if (badBidiRects != null) return badBidiRects;
var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
var r0 = range(txt, 0, 1).getBoundingClientRect(); var r0 = range(txt, 0, 1).getBoundingClientRect();
if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
var r1 = range(txt, 1, 2).getBoundingClientRect(); var r1 = range(txt, 1, 2).getBoundingClientRect();
removeChildren(measure);
if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
return badBidiRects = (r1.right - r0.right < 3); return badBidiRects = (r1.right - r0.right < 3);
} }
@ -11224,7 +11253,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
// THE END // THE END
CodeMirror.version = "5.15.2"; CodeMirror.version = "5.17.0";
return CodeMirror; return CodeMirror;
}); });
@ -11427,7 +11456,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
list2: "variable-3", list2: "variable-3",
list3: "keyword", list3: "keyword",
hr: "hr", hr: "hr",
image: "tag", image: "image",
imageAltText: "image-alt-text",
imageMarker: "image-marker",
formatting: "formatting", formatting: "formatting",
linkInline: "link", linkInline: "link",
linkEmail: "link", linkEmail: "link",
@ -11677,6 +11708,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); } if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
if (state.linkText) { styles.push(tokenTypes.linkText); } if (state.linkText) { styles.push(tokenTypes.linkText); }
if (state.code) { styles.push(tokenTypes.code); } if (state.code) { styles.push(tokenTypes.code); }
if (state.image) { styles.push(tokenTypes.image); }
if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
} }
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); } if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
@ -11796,12 +11830,29 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} }
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
stream.match(/\[[^\]]*\]/); state.imageMarker = true;
state.inline = state.f = linkHref; state.image = true;
return tokenTypes.image; if (modeCfg.highlightFormatting) state.formatting = "image";
return getType(state);
} }
if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false)) { if (ch === '[' && state.imageMarker) {
state.imageMarker = false;
state.imageAltText = true
if (modeCfg.highlightFormatting) state.formatting = "image";
return getType(state);
}
if (ch === ']' && state.imageAltText) {
if (modeCfg.highlightFormatting) state.formatting = "image";
var type = getType(state);
state.imageAltText = false;
state.image = false;
state.inline = state.f = linkHref;
return type;
}
if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && !state.image) {
state.linkText = true; state.linkText = true;
if (modeCfg.highlightFormatting) state.formatting = "link"; if (modeCfg.highlightFormatting) state.formatting = "link";
return getType(state); return getType(state);
@ -15784,8 +15835,10 @@ 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 = {},
var endPoint = cm.getCursor("end"); endPoint = {};
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);
} }
@ -15885,18 +15938,21 @@ function _toggleLine(cm, name) {
if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
return; return;
var listRegexp = /^(\s*)(\*|\-|\+|\d*\.)(\s+)/;
var whitespacesRegexp = /^\s*/;
var stat = getState(cm); var stat = getState(cm);
var startPoint = cm.getCursor("start"); var startPoint = cm.getCursor("start");
var endPoint = cm.getCursor("end"); var endPoint = cm.getCursor("end");
var repl = { var repl = {
"quote": /^(\s*)\>\s+/, "quote": /^(\s*)\>\s+/,
"unordered-list": /^(\s*)(\*|\-|\+)\s+/, "unordered-list": listRegexp,
"ordered-list": /^(\s*)\d+\.\s+/ "ordered-list": listRegexp
}; };
var map = { var map = {
"quote": "> ", "quote": ">",
"unordered-list": "* ", "unordered-list": "*",
"ordered-list": "1. " "ordered-list": "1."
}; };
for(var i = startPoint.line; i <= endPoint.line; i++) { for(var i = startPoint.line; i <= endPoint.line; i++) {
(function(i) { (function(i) {
@ -15904,7 +15960,16 @@ function _toggleLine(cm, name) {
if(stat[name]) { if(stat[name]) {
text = text.replace(repl[name], "$1"); text = text.replace(repl[name], "$1");
} else { } else {
text = map[name] + text; var arr = listRegexp.exec(text);
if(arr !== null) {
var char = map[name];
if(arr[2] && arr[2] == map[name]) {
char = "";
}
text = arr[1] + char + arr[3] + text.replace(whitespacesRegexp, "").replace(repl[name], "$1");
} else {
text = map[name] + " " + text;
}
} }
cm.replaceRange(text, { cm.replaceRange(text, {
line: i, line: i,
@ -16353,6 +16418,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 != "")
@ -16381,8 +16448,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) {
@ -16391,10 +16462,17 @@ SimpleMDE.prototype.markdown = function(text) {
markedOptions.breaks = true; markedOptions.breaks = true;
} }
if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true && window.hljs) { if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true) {
markedOptions.highlight = function(code) {
return window.hljs.highlightAuto(code).value; /* Get HLJS from config or window */
}; var hljs = this.options.renderingConfig.hljs || window.hljs;
/* Check if HLJS loaded */
if(hljs) {
markedOptions.highlight = function(code) {
return hljs.highlightAuto(code).value;
};
}
} }
@ -16484,6 +16562,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() {

File diff suppressed because one or more lines are too long

22
dist/simplemde.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -9,16 +9,16 @@
"javascript", "javascript",
"wysiwyg" "wysiwyg"
], ],
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor", "homepage": "https://github.com/sparksuite/simplemde-markdown-editor",
"main": "./src/js/simplemde.js", "main": "./src/js/simplemde.js",
"license": "MIT", "license": "MIT",
"company": "Next Step Webs, Inc.", "company": "Sparksuite, Inc.",
"author": { "author": {
"name": "Wes Cossick", "name": "Wes Cossick",
"url": "http://www.WesCossick.com" "url": "http://www.WesCossick.com"
}, },
"bugs": { "bugs": {
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues" "url": "https://github.com/sparksuite/simplemde-markdown-editor/issues"
}, },
"dependencies": { "dependencies": {
"codemirror": "*", "codemirror": "*",
@ -43,6 +43,6 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor" "url": "https://github.com/sparksuite/simplemde-markdown-editor"
} }
} }

View File

@ -1,16 +1,13 @@
.CodeMirror { .CodeMirror {
box-sizing: border-box;
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;
padding: 10px; padding: 10px;
font: inherit; font: inherit;
z-index: 1; z-index: 1;
} word-wrap: break-word;
.CodeMirror-scroll {
min-height: 300px
} }
.CodeMirror-fullscreen { .CodeMirror-fullscreen {
@ -22,6 +19,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 {
@ -115,7 +114,9 @@
padding: 0; padding: 0;
} }
.editor-toolbar a { .editor-toolbar a,
.editor-toolbar button {
background: transparent;
display: inline-block; display: inline-block;
text-align: center; text-align: center;
text-decoration: none!important; text-decoration: none!important;
@ -123,18 +124,22 @@
width: 30px; width: 30px;
height: 30px; height: 30px;
margin: 0; margin: 0;
padding: 0;
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 3px; border-radius: 3px;
cursor: pointer; cursor: pointer;
} }
.editor-toolbar a.active, .editor-toolbar a.active,
.editor-toolbar a:hover { .editor-toolbar a:hover,
.editor-toolbar button.active,
.editor-toolbar button:hover {
background: #fcfcfc; background: #fcfcfc;
border-color: #95a5a6; border-color: #95a5a6;
} }
.editor-toolbar a:before { .editor-toolbar a:before,
.editor-toolbar button:before {
line-height: 30px line-height: 30px
} }
@ -241,6 +246,7 @@
display: none; display: none;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #ddd; border: 1px solid #ddd;
word-wrap: break-word;
} }
.editor-preview-active-side { .editor-preview-active-side {

View File

@ -96,11 +96,11 @@ function fixShortcut(name) {
*/ */
function createIcon(options, enableTooltips, shortcuts) { function createIcon(options, enableTooltips, shortcuts) {
options = options || {}; options = options || {};
var el = document.createElement("a"); var el = document.createElement("button");
enableTooltips = (enableTooltips == undefined) ? true : enableTooltips; enableTooltips = (enableTooltips == undefined) ? true : enableTooltips;
if(options.title && enableTooltips) { if(options.title && enableTooltips) {
el.title = createTootlip(options.title, options.action, shortcuts); el.title = createTooltip(options.title, options.action, shortcuts);
if(isMac) { if(isMac) {
el.title = el.title.replace("Ctrl", "⌘"); el.title = el.title.replace("Ctrl", "⌘");
@ -120,7 +120,7 @@ function createSep() {
return el; return el;
} }
function createTootlip(title, action, shortcuts) { function createTooltip(title, action, shortcuts) {
var actionName; var actionName;
var tooltip = title; var tooltip = title;
@ -211,12 +211,14 @@ function toggleFullScreen(editor) {
// Update toolbar button // Update toolbar button
var toolbarButton = editor.toolbarElements.fullscreen; if (editor.toolbarElements.fullscreen) {
var toolbarButton = editor.toolbarElements.fullscreen;
if(!/active/.test(toolbarButton.className)) { if(!/active/.test(toolbarButton.className)) {
toolbarButton.className += " active"; toolbarButton.className += " active";
} else { } else {
toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, ""); toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, "");
}
} }
@ -795,8 +797,10 @@ 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 = {},
var endPoint = cm.getCursor("end"); endPoint = {};
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);
} }
@ -896,26 +900,57 @@ function _toggleLine(cm, name) {
if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
return; return;
var listRegexp = /^(\s*)(\*|\-|\+|\d*\.)(\s+)/;
var whitespacesRegexp = /^\s*/;
var stat = getState(cm); var stat = getState(cm);
var startPoint = cm.getCursor("start"); var startPoint = cm.getCursor("start");
var endPoint = cm.getCursor("end"); var endPoint = cm.getCursor("end");
var repl = { var repl = {
"quote": /^(\s*)\>\s+/, "quote": /^(\s*)\>\s+/,
"unordered-list": /^(\s*)(\*|\-|\+)\s+/, "unordered-list": listRegexp,
"ordered-list": /^(\s*)\d+\.\s+/ "ordered-list": listRegexp
}; };
var map = {
"quote": "> ", var _getChar = function(name, i) {
"unordered-list": "* ", var map = {
"ordered-list": "1. " "quote": ">",
"unordered-list": "*",
"ordered-list": "%%i."
};
return map[name].replace("%%i", i);
}; };
var _checkChar = function(name, char) {
var map = {
"quote": "\>",
"unordered-list": "\*",
"ordered-list": "\d+."
};
var rt = new RegExp(map[name]);
return char && rt.test(char);
};
var line = 1;
for(var i = startPoint.line; i <= endPoint.line; i++) { for(var i = startPoint.line; i <= endPoint.line; i++) {
(function(i) { (function(i) {
var text = cm.getLine(i); var text = cm.getLine(i);
if(stat[name]) { if(stat[name]) {
text = text.replace(repl[name], "$1"); text = text.replace(repl[name], "$1");
} else { } else {
text = map[name] + text; var arr = listRegexp.exec(text);
var char = _getChar(name, line);
if(arr !== null) {
if(_checkChar(name, arr[2])) {
char = "";
}
text = arr[1] + char + arr[3] + text.replace(whitespacesRegexp, "").replace(repl[name], "$1");
} else {
text = char + " " + text;
}
line += 1;
} }
cm.replaceRange(text, { cm.replaceRange(text, {
line: i, line: i,
@ -1354,7 +1389,7 @@ function SimpleMDE(options) {
// Merging the promptTexts, with the given options // Merging the promptTexts, with the given options
options.promptTexts = promptTexts; options.promptTexts = extend({}, promptTexts, options.promptTexts || {});
// Merging the blockStyles, with the given options // Merging the blockStyles, with the given options
@ -1364,6 +1399,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 +1429,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) {
@ -1402,10 +1443,17 @@ SimpleMDE.prototype.markdown = function(text) {
markedOptions.breaks = true; markedOptions.breaks = true;
} }
if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true && window.hljs) { if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true) {
markedOptions.highlight = function(code) {
return window.hljs.highlightAuto(code).value; /* Get HLJS from config or window */
}; var hljs = this.options.renderingConfig.hljs || window.hljs;
/* Check if HLJS loaded */
if(hljs) {
markedOptions.highlight = function(code) {
return hljs.highlightAuto(code).value;
};
}
} }
@ -1492,9 +1540,11 @@ SimpleMDE.prototype.render = function(el) {
lineWrapping: (options.lineWrapping === false) ? false : true, lineWrapping: (options.lineWrapping === false) ? false : true,
allowDropFileTypes: ["text/plain"], allowDropFileTypes: ["text/plain"],
placeholder: options.placeholder || el.getAttribute("placeholder") || "", placeholder: options.placeholder || el.getAttribute("placeholder") || "",
styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : true styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : !isMobile(),
}); });
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() {
@ -1619,6 +1669,7 @@ SimpleMDE.prototype.createSideBySide = function() {
wrapper.parentNode.insertBefore(preview, wrapper.nextSibling); wrapper.parentNode.insertBefore(preview, wrapper.nextSibling);
} }
if(this.options.syncSideBySidePreviewScroll === false) return preview;
// Syncs scroll editor -> preview // Syncs scroll editor -> preview
var cScroll = false; var cScroll = false;
var pScroll = false; var pScroll = false;
@ -1867,10 +1918,16 @@ SimpleMDE.prototype.createStatusbar = function(status) {
* Get or set the text content. * Get or set the text content.
*/ */
SimpleMDE.prototype.value = function(val) { SimpleMDE.prototype.value = function(val) {
var cm = this.codemirror;
if(val === undefined) { if(val === undefined) {
return this.codemirror.getValue(); return cm.getValue();
} else { } else {
this.codemirror.getDoc().setValue(val); cm.getDoc().setValue(val);
if(this.isPreviewActive()) {
var wrapper = cm.getWrapperElement();
var preview = wrapper.lastChild;
preview.innerHTML = this.options.previewRender(val, preview);
}
return this; return this;
} }
}; };