|
|
|
@ -126,7 +126,7 @@ function createToolbarButton(options, enableTooltips, shortcuts) {
|
|
|
|
|
if( options.name && options.name in shortcuts ){
|
|
|
|
|
bindings[options.name] = options.action;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (options.title && enableTooltips) {
|
|
|
|
|
el.title = createTooltip(options.title, options.action, shortcuts);
|
|
|
|
|
|
|
|
|
@ -988,13 +988,27 @@ function _toggleLine(cm, name) {
|
|
|
|
|
var map = {
|
|
|
|
|
'quote': '>',
|
|
|
|
|
'unordered-list': '*',
|
|
|
|
|
'ordered-list': 'd+.',
|
|
|
|
|
'ordered-list': '\\d+.',
|
|
|
|
|
};
|
|
|
|
|
var rt = new RegExp(map[name]);
|
|
|
|
|
|
|
|
|
|
return char && rt.test(char);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var _do = function (name, text, untoggleOnly) {
|
|
|
|
|
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 if (untoggleOnly == false){
|
|
|
|
|
text = char + ' ' + text;
|
|
|
|
|
}
|
|
|
|
|
return text;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var line = 1;
|
|
|
|
|
for (var i = startPoint.line; i <= endPoint.line; i++) {
|
|
|
|
|
(function (i) {
|
|
|
|
@ -1002,16 +1016,13 @@ function _toggleLine(cm, name) {
|
|
|
|
|
if (stat[name]) {
|
|
|
|
|
text = text.replace(repl[name], '$1');
|
|
|
|
|
} else {
|
|
|
|
|
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;
|
|
|
|
|
// If we're toggling unordered-list formatting, check if the current line
|
|
|
|
|
// is part of an ordered-list, and if so, untoggle that first.
|
|
|
|
|
// Workaround for https://github.com/Ionaru/easy-markdown-editor/issues/92
|
|
|
|
|
if (name == 'unordered-list') {
|
|
|
|
|
text = _do('ordered-list', text, true);
|
|
|
|
|
}
|
|
|
|
|
text = _do(name, text, false);
|
|
|
|
|
line += 1;
|
|
|
|
|
}
|
|
|
|
|
cm.replaceRange(text, {
|
|
|
|
@ -1367,6 +1378,7 @@ var blockStyles = {
|
|
|
|
|
* Interface of EasyMDE.
|
|
|
|
|
*/
|
|
|
|
|
function EasyMDE(options) {
|
|
|
|
|
console.log('oh hai');
|
|
|
|
|
// Handle options parameter
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
@ -1684,22 +1696,22 @@ EasyMDE.prototype.autosave = function () {
|
|
|
|
|
console.log('EasyMDE: You must set a uniqueId to use the autosave feature');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.options.autosave.binded !== true) {
|
|
|
|
|
if (easyMDE.element.form != null && easyMDE.element.form != undefined) {
|
|
|
|
|
easyMDE.element.form.addEventListener('submit', function () {
|
|
|
|
|
clearTimeout(easyMDE.autosaveTimeoutId);
|
|
|
|
|
easyMDE.autosaveTimeoutId = undefined;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
localStorage.removeItem('smde_' + easyMDE.options.autosave.uniqueId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Restart autosaving in case the submit will be cancelled down the line
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
easyMDE.autosave();
|
|
|
|
|
}, easyMDE.options.autosave.delay || 10000);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.options.autosave.binded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|