"use strict";
-import DropZone from "dropzone";
-import markdown from "marked";
+const DropZone = require("dropzone");
+const markdown = require("marked");
-export default function (ngApp, events) {
+module.exports = function (ngApp, events) {
/**
* Common tab controls using simple jQuery functions.
}
}]);
+ let renderer = new markdown.Renderer();
+ // Custom markdown checkbox list item
+ // Attribution: https://github.com/chjj/marked/issues/107#issuecomment-44542001
+ renderer.listitem = function(text) {
+ if (/^\s*\[[x ]\]\s*/.test(text)) {
+ text = text
+ .replace(/^\s*\[ \]\s*/, '<input type="checkbox"/>')
+ .replace(/^\s*\[x\]\s*/, '<input type="checkbox" checked/>');
+ return `<li class="checkbox-item">${text}</li>`;
+ }
+ return `<li>${text}</li>`;
+ };
+
/**
* Markdown input
* Handles the logic for just the editor input field.
element = element.find('textarea').first();
let content = element.val();
scope.mdModel = content;
- scope.mdChange(markdown(content));
+ scope.mdChange(markdown(content, {renderer: renderer}));
element.on('change input', (event) => {
content = element.val();
$timeout(() => {
scope.mdModel = content;
- scope.mdChange(markdown(content));
+ scope.mdChange(markdown(content, {renderer: renderer}));
});
});