"use strict";
-import DropZone from "dropzone";
-import markdown from "marked";
+const DropZone = require("dropzone");
+const MarkdownIt = require("markdown-it");
+const mdTasksLists = require('markdown-it-task-lists');
-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>`;
- };
+ const md = new MarkdownIt({html: true});
+ md.use(mdTasksLists, {label: true});
/**
* Markdown input
element = element.find('textarea').first();
let content = element.val();
scope.mdModel = content;
- scope.mdChange(markdown(content, {renderer: renderer}));
+ scope.mdChange(md.render(content));
element.on('change input', (event) => {
content = element.val();
$timeout(() => {
scope.mdModel = content;
- scope.mdChange(markdown(content, {renderer: renderer}));
+ scope.mdChange(md.render(content));
});
});
scope.$on('markdown-update', (event, value) => {
element.val(value);
scope.mdModel = value;
- scope.mdChange(markdown(value));
+ scope.mdChange(md.render(value));
});
}
}
}
}]);
+
+ ngApp.directive('commentReply', ['$timeout', function ($timeout) {
+ return {
+ restrict: 'E',
+ templateUrl: 'comment-reply.html',
+ scope: {
+
+ },
+ link: function (scope, element, attr) {
+
+ }
+ }
+
+ }]);
+ ngApp.directive('commentReplyLink', ['$document', '$compile', function ($document, $compile) {
+ return {
+ link: function (scope, element, attr) {
+ element.on('$destroy', function () {
+ element.off('click');
+ scope.$destroy();
+ });
+
+ element.on('click', function () {
+ var $container = element.parents('.comment-box').first();
+ if (!$container.length) {
+ console.error('commentReplyLink directive should be placed inside a container with class comment-box!');
+ return;
+ }
+ if (attr.noCommentReplyDupe) {
+ removeDupe();
+ }
+ var compiledHTML = $compile('<comment-reply></comment-reply>')(scope);
+ $container.append(compiledHTML);
+ });
+ }
+ };
+
+
+ function removeDupe() {
+ let $existingElement = $document.find('comment-reply');
+ if (!$existingElement.length) {
+ return;
+ }
+
+ $existingElement.remove();
+ }
+ }]);
};