Merge branch 'master' into new_translate

pull/179/head
dima-bzz 4 years ago committed by GitHub
commit 63dcda3452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,6 @@
language: node_js
node_js:
- '14' # EOL: April 2023
- '12' # EOL: April 2022
- '11' # EOL: June 2019
- '10' # EOL: April 2021

@ -4,7 +4,14 @@ All notable changes to easymde will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
<!--## [Unreleased]-->
## [Unreleased]
### Added
- Support for Node.js 14.
### Fixed
- Fix cursor displayed position on activity ([#183]).
- Checkboxes always have bullets in front of them ([#136]).
## [2.10.1] - 2020-04-06
### Fixed
- Typescript error when entering certain strings for toolbar buttons ([#178]).
@ -145,7 +152,9 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
- Cursor not always showing in "text" mode over the edit field
<!-- Linked issues -->
[#183]: https://github.com/Ionaru/easy-markdown-editor/issues/183
[#178]: https://github.com/Ionaru/easy-markdown-editor/issues/178
[#136]: https://github.com/Ionaru/easy-markdown-editor/issues/136
[#126]: https://github.com/Ionaru/easy-markdown-editor/issues/126
[#99]: https://github.com/Ionaru/easy-markdown-editor/issues/99
[#45]: https://github.com/Ionaru/easy-markdown-editor/issues/45

@ -17,4 +17,4 @@
</script>
</body>
</html>
</html>

846
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -19,13 +19,13 @@
"license": "MIT",
"author": "Jeroen Akkerman",
"dependencies": {
"codemirror": "^5.52.2",
"codemirror": "^5.53.2",
"codemirror-spell-checker": "1.1.2",
"marked": "^0.8.2"
"marked": "^1.0.0"
},
"devDependencies": {
"@types/codemirror": "0.0.89",
"@types/marked": "^0.7.2",
"@types/codemirror": "0.0.91",
"@types/marked": "^0.7.4",
"browserify": "^16.5.1",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.2.0",

@ -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

Loading…
Cancel
Save