summaryrefslogtreecommitdiff
path: root/src/node/utils
diff options
context:
space:
mode:
authorLuiza Pagliari <lpagliari@gmail.com>2015-11-03 07:16:55 -0200
committerLuiza Pagliari <lpagliari@gmail.com>2015-11-03 07:16:55 -0200
commit92a82534499d8fc66dbb1046ed3e8ea0e87d3412 (patch)
tree86c7e7f54ff67a815fe1f41b4fccf9034fa5b518 /src/node/utils
parentd05fa6d97e2e3ea86e2e4f1925c46455047b6409 (diff)
downloadetherpad-lite-92a82534499d8fc66dbb1046ed3e8ea0e87d3412.zip
Create hook exportHtmlAdditionalTagsWithData
The new hook does the same as exportHtmlAdditionalTags, but is declared in another hook to avoid confusion about how to export tags when they are stored as ['tag', 'value'] on attribute pool. This complements #2762, as per @Gared suggestions.
Diffstat (limited to 'src/node/utils')
-rw-r--r--src/node/utils/ExportHtml.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js
index ffc7bc58..058127b3 100644
--- a/src/node/utils/ExportHtml.js
+++ b/src/node/utils/ExportHtml.js
@@ -78,16 +78,18 @@ function getHTMLFromAtext(pad, atext, authorColors)
var tags = ['h1', 'h2', 'strong', 'em', 'u', 's'];
var props = ['heading1', 'heading2', 'bold', 'italic', 'underline', 'strikethrough'];
+ // prepare tags stored as ['tag', true] to be exported
hooks.aCallAll("exportHtmlAdditionalTags", pad, function(err, newProps){
- // newProps can be simply a string (which means it is stored as attribute in the form of ['tag', 'true'])
- // or it can be a pair of values in an Array (for the case when it is stored as ['tag', 'value']).
- // The later scenario will generate HTML with tags like <span data-tag="value">
newProps.forEach(function (propName, i){
- if (_.isArray(propName)) {
- tags.push('span data-' + propName[0] + '="' + propName[1] + '"');
- } else {
- tags.push(propName);
- }
+ tags.push(propName);
+ props.push(propName);
+ });
+ });
+ // prepare tags stored as ['tag', 'value'] to be exported. This will generate HTML
+ // with tags like <span data-tag="value">
+ hooks.aCallAll("exportHtmlAdditionalTagsWithData", pad, function(err, newProps){
+ newProps.forEach(function (propName, i){
+ tags.push('span data-' + propName[0] + '="' + propName[1] + '"');
props.push(propName);
});
});
@@ -140,7 +142,8 @@ function getHTMLFromAtext(pad, atext, authorColors)
{
var attrib = [propName, true];
if (_.isArray(propName)) {
- // propName can be in the form of ['color', 'red']
+ // propName can be in the form of ['color', 'red'],
+ // see hook exportHtmlAdditionalTagsWithData
attrib = propName;
}
var propTrueNum = apool.putAttrib(attrib, true);
@@ -167,7 +170,8 @@ function getHTMLFromAtext(pad, atext, authorColors)
var property = props[i];
- // we are not insterested on properties in the form of ['color', 'red']
+ // we are not insterested on properties in the form of ['color', 'red'],
+ // see hook exportHtmlAdditionalTagsWithData
if (_.isArray(property)) {
return false;
}
@@ -183,6 +187,8 @@ function getHTMLFromAtext(pad, atext, authorColors)
return false;
}
+ // tags added by exportHtmlAdditionalTagsWithData will be exported as <span> with
+ // data attributes
function isSpanWithData(i){
var property = props[i];
return _.isArray(property);