Browse Source

Fixed Task list rendeing

develop
pandao 6 years ago
parent
commit
7b2cec6c35
  1. 22
      editormd.amd.js
  2. 2
      editormd.amd.min.js
  3. 22
      editormd.js
  4. 2
      editormd.min.js
  5. 5
      examples/task-lists.html
  6. 2
      lib/codemirror/addons.min.js
  7. 22
      src/editormd.js

22
editormd.amd.js

@ -2105,6 +2105,10 @@
{
previewContainer.html(newMarkdownDoc);
previewContainer.find(".task-list-item").each(function () {
$(this).parent().addClass("task-list");
});
this.previewCodeHighlight();
if (settings.toc)
@ -3723,16 +3727,12 @@
return tag + this.atLink(this.emoji(content)) + "</" + type + ">\n";
};
markedRenderer.listitem = function(text) {
if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text))
{
text = text.replace(/^\s*\[\s\]\s*/, "<input type=\"checkbox\" class=\"task-list-item-checkbox\" /> ")
.replace(/^\s*\[x\]\s*/, "<input type=\"checkbox\" class=\"task-list-item-checkbox\" checked disabled /> ");
markedRenderer.listitem = function(text, task) {
if (settings.taskList && task) {
text = text.replace("<input ", "<input class='task-list-item-checkbox' ");
return "<li style=\"list-style: none;\">" + this.atLink(this.emoji(text)) + "</li>";
}
else
{
return "<li class=\"task-list-item\">" + this.atLink(this.emoji(text)) + "</li>";
} else {
return "<li>" + this.atLink(this.emoji(text)) + "</li>";
}
};
@ -4049,6 +4049,10 @@
div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed);
div.find(".task-list-item").each(function () {
$(this).parent().addClass("task-list");
});
var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div;
if (settings.tocContainer !== "")

2
editormd.amd.min.js

File diff suppressed because one or more lines are too long

22
editormd.js

@ -2035,6 +2035,10 @@
{
previewContainer.html(newMarkdownDoc);
previewContainer.find(".task-list-item").each(function () {
$(this).parent().addClass("task-list");
});
this.previewCodeHighlight();
if (settings.toc)
@ -3653,16 +3657,12 @@
return tag + this.atLink(this.emoji(content)) + "</" + type + ">\n";
};
markedRenderer.listitem = function(text) {
if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text))
{
text = text.replace(/^\s*\[\s\]\s*/, "<input type=\"checkbox\" class=\"task-list-item-checkbox\" /> ")
.replace(/^\s*\[x\]\s*/, "<input type=\"checkbox\" class=\"task-list-item-checkbox\" checked disabled /> ");
markedRenderer.listitem = function(text, task) {
if (settings.taskList && task) {
text = text.replace("<input ", "<input class='task-list-item-checkbox' ");
return "<li style=\"list-style: none;\">" + this.atLink(this.emoji(text)) + "</li>";
}
else
{
return "<li class=\"task-list-item\">" + this.atLink(this.emoji(text)) + "</li>";
} else {
return "<li>" + this.atLink(this.emoji(text)) + "</li>";
}
};
@ -3979,6 +3979,10 @@
div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed);
div.find(".task-list-item").each(function () {
$(this).parent().addClass("task-list");
});
var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div;
if (settings.tocContainer !== "")

2
editormd.min.js

File diff suppressed because one or more lines are too long

5
examples/task-lists.html

@ -22,13 +22,13 @@
### Examples
- [x] @mentions, #refs, [links](), **formatting**, and <del>tags</del> supported;
- [x] list syntax required (any unordered or ordered list supported);
- [x] list syntax required (any unordered or ordered list supported); :heart: :blush:
- [x] this is a complete item;
- [ ] this is an incomplete item [test link](#);
- [ ] this is an incomplete item;
- [ ] this is an incomplete item [test link](#);
- [ ] this is an incomplete item [test link](#);
- [x] list syntax required (any unordered or ordered list supported);
- [x] list syntax required (any unordered or ordered list supported); :smile:
- [x] this is a complete item;
- [ ] this is an incomplete item [test link](#);
- [ ] this is an incomplete item;
@ -53,6 +53,7 @@
testEditor = editormd("test-editormd", {
width : "90%",
height : 720,
emoji : true, // enable for test
taskList : true,
path : '../lib/',
htmlDebode : true,

2
lib/codemirror/addons.min.js

File diff suppressed because one or more lines are too long

22
src/editormd.js

@ -2023,6 +2023,10 @@
{
previewContainer.html(newMarkdownDoc);
previewContainer.find(".task-list-item").each(function () {
$(this).parent().addClass("task-list");
});
this.previewCodeHighlight();
if (settings.toc)
@ -3641,16 +3645,12 @@
return tag + this.atLink(this.emoji(content)) + "</" + type + ">\n";
};
markedRenderer.listitem = function(text) {
if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text))
{
text = text.replace(/^\s*\[\s\]\s*/, "<input type=\"checkbox\" class=\"task-list-item-checkbox\" /> ")
.replace(/^\s*\[x\]\s*/, "<input type=\"checkbox\" class=\"task-list-item-checkbox\" checked disabled /> ");
markedRenderer.listitem = function(text, task) {
if (settings.taskList && task) {
text = text.replace("<input ", "<input class='task-list-item-checkbox' ");
return "<li style=\"list-style: none;\">" + this.atLink(this.emoji(text)) + "</li>";
}
else
{
return "<li class=\"task-list-item\">" + this.atLink(this.emoji(text)) + "</li>";
} else {
return "<li>" + this.atLink(this.emoji(text)) + "</li>";
}
};
@ -3967,6 +3967,10 @@
div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed);
div.find(".task-list-item").each(function () {
$(this).parent().addClass("task-list");
});
var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div;
if (settings.tocContainer !== "")

Loading…
Cancel
Save