|
|
|
@ -97,6 +97,33 @@ function addAnchorTargetBlank(htmlText) {
|
|
|
|
|
return htmlText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify HTML to remove the list-style when rendering checkboxes.
|
|
|
|
|
* @param {string} htmlText - HTML to be modified.
|
|
|
|
|
* @return {string} The modified HTML text.
|
|
|
|
|
*/
|
|
|
|
|
function removeListStyleWhenCheckbox(htmlText) {
|
|
|
|
|
|
|
|
|
|
var parser = new DOMParser();
|
|
|
|
|
var htmlDoc = parser.parseFromString(htmlText, 'text/html');
|
|
|
|
|
var listItems = htmlDoc.getElementsByTagName('li');
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < listItems.length; i++) {
|
|
|
|
|
var listItem = listItems[i];
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < listItem.children.length; j++) {
|
|
|
|
|
var listItemChild = listItem.children[j];
|
|
|
|
|
|
|
|
|
|
if (listItemChild instanceof HTMLInputElement && listItemChild.type === 'checkbox') {
|
|
|
|
|
// From Github: margin: 0 .2em .25em -1.6em;
|
|
|
|
|
listItem.style.marginLeft = '-1.5em';
|
|
|
|
|
listItem.style.listStyleType = 'none';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return htmlDoc.documentElement.innerHTML;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fix shortcut. Mac use Command, others use Ctrl.
|
|
|
|
@ -306,12 +333,10 @@ function toggleFullScreen(editor) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update toolbar class
|
|
|
|
|
var wrap = cm.getWrapperElement();
|
|
|
|
|
|
|
|
|
|
if (!/fullscreen/.test(wrap.previousSibling.className)) {
|
|
|
|
|
wrap.previousSibling.className += ' fullscreen';
|
|
|
|
|
if (!/fullscreen/.test(editor.toolbar_div.className)) {
|
|
|
|
|
editor.toolbar_div.className += ' fullscreen';
|
|
|
|
|
} else {
|
|
|
|
|
wrap.previousSibling.className = wrap.previousSibling.className.replace(/\s*fullscreen\b/, '');
|
|
|
|
|
editor.toolbar_div.className = editor.toolbar_div.className.replace(/\s*fullscreen\b/, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -859,7 +884,7 @@ function toggleSideBySide(editor) {
|
|
|
|
|
/\s*editor-preview-active\s*/g, ''
|
|
|
|
|
);
|
|
|
|
|
var toolbar = editor.toolbarElements.preview;
|
|
|
|
|
var toolbar_div = wrapper.previousSibling;
|
|
|
|
|
var toolbar_div = editor.toolbar_div;
|
|
|
|
|
toolbar.className = toolbar.className.replace(/\s*active\s*/g, '');
|
|
|
|
|
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, '');
|
|
|
|
|
}
|
|
|
|
@ -896,7 +921,7 @@ function toggleSideBySide(editor) {
|
|
|
|
|
function togglePreview(editor) {
|
|
|
|
|
var cm = editor.codemirror;
|
|
|
|
|
var wrapper = cm.getWrapperElement();
|
|
|
|
|
var toolbar_div = wrapper.previousSibling;
|
|
|
|
|
var toolbar_div = editor.toolbar_div;
|
|
|
|
|
var toolbar = editor.options.toolbar ? editor.toolbarElements.preview : false;
|
|
|
|
|
var preview = wrapper.lastChild;
|
|
|
|
|
if (!preview || !/editor-preview-full/.test(preview.className)) {
|
|
|
|
@ -1855,6 +1880,9 @@ EasyMDE.prototype.markdown = function (text) {
|
|
|
|
|
// Edit the HTML anchors to add 'target="_blank"' by default.
|
|
|
|
|
htmlText = addAnchorTargetBlank(htmlText);
|
|
|
|
|
|
|
|
|
|
// Remove list-style when rendering checkboxes
|
|
|
|
|
htmlText = removeListStyleWhenCheckbox(htmlText);
|
|
|
|
|
|
|
|
|
|
return htmlText;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -2358,6 +2386,7 @@ EasyMDE.prototype.createToolbar = function (items) {
|
|
|
|
|
})(items[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.toolbar_div = bar;
|
|
|
|
|
self.toolbarElements = toolbarData;
|
|
|
|
|
|
|
|
|
|
var cm = this.codemirror;
|
|
|
|
@ -2438,7 +2467,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|
|
|
|
defaultValue = function (el) {
|
|
|
|
|
el.innerHTML = '0:0';
|
|
|
|
|
};
|
|
|
|
|
onUpdate = function (el) {
|
|
|
|
|
onActivity = function (el) {
|
|
|
|
|
var pos = cm.getCursor();
|
|
|
|
|
el.innerHTML = pos.line + ':' + pos.ch;
|
|
|
|
|
};
|
|
|
|
@ -2506,6 +2535,14 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|
|
|
|
};
|
|
|
|
|
}(el, item)));
|
|
|
|
|
}
|
|
|
|
|
if (typeof item.onActivity === 'function') {
|
|
|
|
|
// Create a closure around the span of the current action, then execute the onActivity handler
|
|
|
|
|
this.codemirror.on('cursorActivity', (function (el, item) {
|
|
|
|
|
return function () {
|
|
|
|
|
item.onActivity(el);
|
|
|
|
|
};
|
|
|
|
|
}(el, item)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ensure the onActivity is a function
|
|
|
|
|