From ade1b4f1444d25168904ab976108b51ff9f4bd1b Mon Sep 17 00:00:00 2001 From: Brian Long Date: Mon, 18 Jan 2021 00:29:47 -0500 Subject: [PATCH] added github/table extensions, but still not using --- .../META-INF/components/markdown-edit.js | 96 +++++++++++++++++++ .../META-INF/components/preview/MarkDown.js | 74 ++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 share/src/main/resources/META-INF/components/markdown-edit.js create mode 100644 share/src/main/resources/META-INF/components/preview/MarkDown.js diff --git a/share/src/main/resources/META-INF/components/markdown-edit.js b/share/src/main/resources/META-INF/components/markdown-edit.js new file mode 100644 index 0000000..d3d0b45 --- /dev/null +++ b/share/src/main/resources/META-INF/components/markdown-edit.js @@ -0,0 +1,96 @@ +require(["dojo/dom", "dojo/query", "dojo/on", "dojo/request", "showdown", "showdown-github", "showdown-table", "dojo/domReady!"], function(dom, query, on, request, showdown, showdownGithub, showdownTable){ + + function resizeFrame(elem) { + elem.style.height = (window.innerHeight - 280) + "px"; + } + + function getURLParameter(name) { + return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null + } + + var nodePath = getURLParameter("nodeRef").replace(":/",""); + + request.get(Alfresco.constants.PROXY_URI_RELATIVE + "/slingshot/doclib2/node/" + nodePath,{ handleAs: "json"}).then(function(nodeData) { + + + var locationPath = Alfresco.constants.PROXY_URI_RELATIVE + "markdown" + nodeData.item.location.repoPath + "/"; + + //Once we have the content, let's create a converter and add the html to the div element + var converter = new showdown.Converter({ + extensions: [ + function() { + return [{ + type: 'output', + filter: function(source) { + return source.replace(/