upgraded showdown to v1.9.1; including table/github extensions, but not using them yet
This commit is contained in:
parent
11a4729b03
commit
9950e45dee
2
pom.xml
2
pom.xml
@ -305,6 +305,7 @@
|
||||
<exclude>**/*.css</exclude>
|
||||
<exclude>**/*-min.js</exclude>
|
||||
<exclude>**/*-min.css</exclude>
|
||||
<exclude>**/*.min.js</exclude>
|
||||
</excludes>
|
||||
<force>true</force>
|
||||
<jswarn>false</jswarn>
|
||||
@ -325,6 +326,7 @@
|
||||
<exclude>**/*.css</exclude>
|
||||
<exclude>**/*-min.js</exclude>
|
||||
<exclude>**/*-min.css</exclude>
|
||||
<exclude>**/*.min.js</exclude>
|
||||
</excludes>
|
||||
<force>true</force>
|
||||
<jswarn>false</jswarn>
|
||||
|
@ -33,34 +33,6 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<!-- Override to not deal with already minified showdown -->
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compress-resources</id>
|
||||
<goals>
|
||||
<goal>compress</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/webscripts/**</exclude>
|
||||
<exclude>**/site-webscripts/**</exclude>
|
||||
<exclude>**/*.lib.js</exclude>
|
||||
<exclude>**/*.css</exclude>
|
||||
<exclude>**/*-min.js</exclude>
|
||||
<exclude>**/*-min.css</exclude>
|
||||
<exclude>**/showdown.js</exclude>
|
||||
</excludes>
|
||||
<force>true</force>
|
||||
<jswarn>false</jswarn>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -1,96 +0,0 @@
|
||||
require(["dojo/dom", "dojo/query", "dojo/on", "dojo/request", "showdown", "dojo/domReady!"], function(dom, query, on, request, showdown){
|
||||
|
||||
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(/<img src="([^"]*)"/g, function(match, src) {
|
||||
|
||||
if(src.startsWith("http")) {
|
||||
//if this includes external links, then don't change it.
|
||||
return match;
|
||||
} else {
|
||||
//if it's a relative link, we need to use our webscript
|
||||
return "<img src=\"" + locationPath + src + "\"";
|
||||
}
|
||||
});
|
||||
}
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
var editorFrame = dom.byId("md-text");
|
||||
var previewFrame = dom.byId("md-body");
|
||||
var saveBack = dom.byId("markdownSaveback");
|
||||
|
||||
resizeFrame(editorFrame);
|
||||
resizeFrame(previewFrame);
|
||||
|
||||
|
||||
on(window, "resize", function() {
|
||||
resizeFrame(editorFrame);
|
||||
resizeFrame(previewFrame);
|
||||
});
|
||||
|
||||
function updateMarkdown() {
|
||||
|
||||
previewFrame.innerHTML = converter.makeHtml(editorFrame.value);
|
||||
}
|
||||
|
||||
on(editorFrame, "change", updateMarkdown);
|
||||
on(editorFrame, "keyup", updateMarkdown);
|
||||
on(editorFrame, "paste", updateMarkdown);
|
||||
|
||||
request.get(Alfresco.constants.PROXY_URI_RELATIVE + "/api/node/content/" + nodePath).then(function(nodeContent) {
|
||||
editorFrame.value = nodeContent;
|
||||
updateMarkdown();
|
||||
});
|
||||
|
||||
|
||||
on(saveBack, "click", function() {
|
||||
|
||||
var postHeaders = {
|
||||
"Content-Type" : "application/json"
|
||||
}
|
||||
|
||||
if (Alfresco.util.CSRFPolicy && Alfresco.util.CSRFPolicy.isFilterEnabled()) {
|
||||
postHeaders[Alfresco.util.CSRFPolicy.getHeader()] = Alfresco.util.CSRFPolicy.getToken();
|
||||
}
|
||||
|
||||
request.post(Alfresco.constants.PROXY_URI_RELATIVE + "api/node/" + nodePath + "/formprocessor", {
|
||||
headers: postHeaders,
|
||||
data : JSON.stringify({
|
||||
prop_cm_content : editorFrame.value
|
||||
})
|
||||
}).then(function() {
|
||||
Alfresco.util.PopupManager.displayMessage({"text": "Update Submitted"});
|
||||
}, function (err) {
|
||||
//Tries to find the exception from the error page and send a prompt
|
||||
Alfresco.util.PopupManager.displayPrompt({"title": "Error Updating Alfresco"});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
@ -1,74 +0,0 @@
|
||||
(function() {
|
||||
|
||||
Alfresco.WebPreview.prototype.Plugins.MarkDown = function(wp, attributes)
|
||||
{
|
||||
this.wp = wp;
|
||||
this.attributes = YAHOO.lang.merge(Alfresco.util.deepCopy(this.attributes), attributes);
|
||||
return this;
|
||||
};
|
||||
|
||||
Alfresco.WebPreview.prototype.Plugins.MarkDown.prototype =
|
||||
{
|
||||
attributes: {},
|
||||
|
||||
report: function() {
|
||||
return null;
|
||||
},
|
||||
|
||||
display: function() {
|
||||
|
||||
var node = this.attributes.node;
|
||||
|
||||
//get the default relative path of the node
|
||||
var locationPath = Alfresco.constants.PROXY_URI_RELATIVE + "/markdown" + this.attributes.location.repoPath + "/";
|
||||
|
||||
//get the Div Element we'll be putting the Markdown
|
||||
var divElem = document.getElementById(this.wp.id + "-body")
|
||||
|
||||
|
||||
|
||||
//Execute Ajax request for content
|
||||
require(["dojo/request", "showdown"], function(request, showdown){
|
||||
|
||||
//Once we have the content, let's create a converter and add the html to the div element
|
||||
converter = new showdown.Converter({
|
||||
extensions: [
|
||||
function() {
|
||||
return [{
|
||||
type: 'output',
|
||||
filter: function(source) {
|
||||
return source.replace(/<img src="([^"]*)"/g, function(match, src) {
|
||||
|
||||
if(src.startsWith("http")) {
|
||||
//if this includes external links, then don't change it.
|
||||
return match;
|
||||
} else {
|
||||
//if it's a relative link, we need to use our webscript
|
||||
return "<img src=\"" + locationPath + src + "\"";
|
||||
}
|
||||
});
|
||||
}
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
|
||||
request.get(Alfresco.constants.PROXY_URI_RELATIVE + node.contentURL).then(function(mdData) {
|
||||
|
||||
|
||||
newHtml = converter.makeHtml(mdData);
|
||||
|
||||
divElem.className = "markdown-body";
|
||||
divElem.innerHTML = converter.makeHtml(mdData);
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
26
share/src/main/resources/META-INF/showdown-github.js
Normal file
26
share/src/main/resources/META-INF/showdown-github.js
Normal file
@ -0,0 +1,26 @@
|
||||
/*! showdown-github 03-06-2015 */
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var github = function () {
|
||||
return [
|
||||
{
|
||||
type: 'lang',
|
||||
regex: '(~T){2}([^~]+)(~T){2}',
|
||||
replace: function (match, prefix, content) {
|
||||
return '<del>' + content + '</del>';
|
||||
}
|
||||
}
|
||||
];
|
||||
};
|
||||
if (typeof window !== 'undefined' && window.showdown && window.showdown.extensions) {
|
||||
window.showdown.extensions.github = github;
|
||||
}
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = github;
|
||||
}
|
||||
|
||||
}());
|
||||
|
||||
//# sourceMappingURL=showdown-github.js.map
|
112
share/src/main/resources/META-INF/showdown-table.js
Normal file
112
share/src/main/resources/META-INF/showdown-table.js
Normal file
@ -0,0 +1,112 @@
|
||||
/*! showdown-table 17-06-2015 */
|
||||
/*
|
||||
* Basic table support with re-entrant parsing, where cell content
|
||||
* can also specify markdown.
|
||||
*
|
||||
* Tables
|
||||
* ======
|
||||
*
|
||||
* | Col 1 | Col 2 |
|
||||
* |======== |====================================================|
|
||||
* |**bold** | ![Valid XHTML] (http://w3.org/Icons/valid-xhtml10) |
|
||||
* | Plain | Value |
|
||||
*
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var table = function (converter) {
|
||||
|
||||
var tables = {}, style = 'text-align:left;', filter;
|
||||
tables.th = function (header) {
|
||||
if (header.trim() === '') {
|
||||
return '';
|
||||
}
|
||||
var id = header.trim().replace(/ /g, '_').toLowerCase();
|
||||
return '<th id="' + id + '" style="' + style + '">' + header + '</th>';
|
||||
};
|
||||
tables.td = function (cell) {
|
||||
return '<td style="' + style + '">' + converter.makeHtml(cell) + '</td>';
|
||||
};
|
||||
tables.ths = function () {
|
||||
var out = '',
|
||||
i = 0,
|
||||
hs = [].slice.apply(arguments);
|
||||
for (i; i < hs.length; i += 1) {
|
||||
out += tables.th(hs[i]) + '\n';
|
||||
}
|
||||
return out;
|
||||
};
|
||||
tables.tds = function () {
|
||||
var out = '', i = 0, ds = [].slice.apply(arguments);
|
||||
for (i; i < ds.length; i += 1) {
|
||||
out += tables.td(ds[i]) + '\n';
|
||||
}
|
||||
return out;
|
||||
};
|
||||
tables.thead = function () {
|
||||
var out,
|
||||
hs = [].slice.apply(arguments);
|
||||
out = '<thead>\n';
|
||||
out += '<tr>\n';
|
||||
out += tables.ths.apply(this, hs);
|
||||
out += '</tr>\n';
|
||||
out += '</thead>\n';
|
||||
return out;
|
||||
};
|
||||
tables.tr = function () {
|
||||
var out,
|
||||
cs = [].slice.apply(arguments);
|
||||
out = '<tr>\n';
|
||||
out += tables.tds.apply(this, cs);
|
||||
out += '</tr>\n';
|
||||
return out;
|
||||
};
|
||||
filter = function (text) {
|
||||
var i = 0, lines = text.split('\n'), line, hs, out = [];
|
||||
for (i; i < lines.length; i += 1) {
|
||||
line = lines[i];
|
||||
if (line.trim().match(/^[|].*[|]$/)) {
|
||||
line = line.trim();
|
||||
var tbl = [];
|
||||
tbl.push('<table>');
|
||||
hs = line.substring(1, line.length - 1).split('|');
|
||||
tbl.push(tables.thead.apply(this, hs));
|
||||
line = lines[++i];
|
||||
if (!line.trim().match(/^[|][-=|: ]+[|]$/)) {
|
||||
line = lines[--i];
|
||||
} else {
|
||||
line = lines[++i];
|
||||
tbl.push('<tbody>');
|
||||
while (line.trim().match(/^[|].*[|]$/)) {
|
||||
line = line.trim();
|
||||
tbl.push(tables.tr.apply(this, line.substring(1, line.length - 1).split('|')));
|
||||
line = lines[++i];
|
||||
}
|
||||
tbl.push('</tbody>');
|
||||
tbl.push('</table>');
|
||||
out.push(tbl.join('\n'));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out.push(line);
|
||||
}
|
||||
return out.join('\n');
|
||||
};
|
||||
return [
|
||||
{
|
||||
type: 'lang',
|
||||
filter: filter
|
||||
}
|
||||
];
|
||||
};
|
||||
if (typeof window !== 'undefined' && window.showdown && window.showdown.extensions) {
|
||||
window.showdown.extensions.table = table;
|
||||
}
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = table;
|
||||
}
|
||||
}());
|
||||
|
||||
//# sourceMappingURL=showdown-table.js.map
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,27 +1,45 @@
|
||||
<extension>
|
||||
<modules>
|
||||
<module>
|
||||
<id>Parashift Markdown Preview</id>
|
||||
<version>1.0</version>
|
||||
<auto-deploy>true</auto-deploy>
|
||||
<customizations>
|
||||
<customization>
|
||||
<targetPackageRoot>org.alfresco.components.preview</targetPackageRoot>
|
||||
<sourcePackageRoot>com.parashift.markdown.preview-config</sourcePackageRoot>
|
||||
<dependencies>
|
||||
<js>/res/components/preview/MarkDown.js</js>
|
||||
<css>/res/components/preview/MarkDown.css</css>
|
||||
</dependencies>
|
||||
</customization>
|
||||
<customization>
|
||||
<targetPackageRoot>org.alfresco.components.documentlibrary</targetPackageRoot>
|
||||
<sourcePackageRoot>com.parashift.markdown.preview-config</sourcePackageRoot>
|
||||
<dependencies>
|
||||
<js>/res/components/preview/MarkDown.js</js>
|
||||
<css>/res/components/preview/MarkDown.css</css>
|
||||
</dependencies>
|
||||
</customization>
|
||||
</customizations>
|
||||
</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>
|
||||
<id>Parashift Markdown Preview</id>
|
||||
<version>${project.version}</version>
|
||||
<auto-deploy>true</auto-deploy>
|
||||
<customizations>
|
||||
<customization>
|
||||
<targetPackageRoot>org.alfresco.components.preview</targetPackageRoot>
|
||||
<sourcePackageRoot>com.parashift.markdown.preview-config</sourcePackageRoot>
|
||||
<dependencies>
|
||||
<js>/res/components/preview/MarkDown.js</js>
|
||||
<css>/res/components/preview/MarkDown.css</css>
|
||||
</dependencies>
|
||||
</customization>
|
||||
<customization>
|
||||
<targetPackageRoot>org.alfresco.components.documentlibrary</targetPackageRoot>
|
||||
<sourcePackageRoot>com.parashift.markdown.preview-config</sourcePackageRoot>
|
||||
<dependencies>
|
||||
<js>/res/components/preview/MarkDown.js</js>
|
||||
<css>/res/components/preview/MarkDown.css</css>
|
||||
</dependencies>
|
||||
</customization>
|
||||
</customizations>
|
||||
</module>
|
||||
<module>
|
||||
<id>Showdown Library Override</id>
|
||||
<version>${project.version}</version>
|
||||
<auto-deploy>true</auto-deploy>
|
||||
<configurations>
|
||||
<config evaluator="string-compare" condition="WebFramework" replace="false">
|
||||
<web-framework>
|
||||
<dojo-pages>
|
||||
<packages>
|
||||
<package name="showdown" location="." main="showdown-min" />
|
||||
<package name="showdown-github" location="." main="showdown-github-min" />
|
||||
<package name="showdown-table" location="." main="showdown-table-min" />
|
||||
</packages>
|
||||
</dojo-pages>
|
||||
</web-framework>
|
||||
</config>
|
||||
</configurations>
|
||||
</module>
|
||||
</modules>
|
||||
</extension>
|
||||
|
Loading…
x
Reference in New Issue
Block a user