Merge pull request #2368 from ether/hook_for_exportHTMLStyles
Hook for export html styles
This commit is contained in:
commit
70ba525430
|
@ -80,6 +80,22 @@ This hook is called during the attribute processing procedure, and should be use
|
|||
|
||||
The return value for this function should be a list of classes, which will then be parsed into a valid class string.
|
||||
|
||||
## aceAttribClasses
|
||||
Called from: src/static/js/linestylefilter.js
|
||||
|
||||
Things in context:
|
||||
1. Attributes - Object of Attributes
|
||||
|
||||
This hook is called when attributes are investigated on a line. It is useful if you want to add another attribute type or property type to a pad.
|
||||
|
||||
Example:
|
||||
```
|
||||
exports.aceAttribClasses = function(hook_name, attr, cb){
|
||||
attr.sub = 'tag:sub';
|
||||
cb(attr);
|
||||
}
|
||||
```
|
||||
|
||||
## aceGetFilterStack
|
||||
Called from: src/static/js/linestylefilter.js
|
||||
|
||||
|
|
|
@ -247,6 +247,40 @@ Things in context:
|
|||
|
||||
This hook will allow a plug-in developer to re-write each line when exporting to HTML.
|
||||
|
||||
## stylesForExport
|
||||
Called from: src/node/utils/ExportHtml.js
|
||||
|
||||
Things in context:
|
||||
|
||||
1. padId - The Pad Id
|
||||
|
||||
This hook will allow a plug-in developer to append Styles to the Exported HTML.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
exports.stylesForExport = function(hook, padId, cb){
|
||||
cb("body{font-size:13.37em !important}");
|
||||
}
|
||||
```
|
||||
|
||||
## aceAttribClasses
|
||||
Called from: src/static/js/linestylefilter.js
|
||||
|
||||
Things in context:
|
||||
1. Attributes - Object of Attributes
|
||||
|
||||
This hook is called when attributes are investigated on a line. It is useful if you want to add another attribute type or property type to a pad.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
exports.aceAttribClasses = function(hook_name, attr, cb){
|
||||
attr.sub = 'tag:sub';
|
||||
cb(attr);
|
||||
}
|
||||
```
|
||||
|
||||
## exportFileName
|
||||
Called from src/node/handler/ExportHandler.js
|
||||
|
||||
|
@ -264,6 +298,24 @@ exports.exportFileName = function(hook, padId, callback){
|
|||
}
|
||||
```
|
||||
|
||||
## exportHtmlAdditionalTags
|
||||
Called from src/node/utils/ExportHtml.js
|
||||
|
||||
Things in context:
|
||||
|
||||
1. Pad object
|
||||
|
||||
This hook will allow a plug-in developer to include more properties and attributes to support during HTML Export. An Array should be returned.
|
||||
|
||||
Example:
|
||||
```
|
||||
// Add the props to be supported in export
|
||||
exports.exportHtmlAdditionalTags = function(hook, pad, cb){
|
||||
var padId = pad.id;
|
||||
cb(["massive","jugs"]);
|
||||
};
|
||||
|
||||
|
||||
## userLeave
|
||||
Called from src/node/handler/PadMessageHandler.js
|
||||
|
||||
|
|
|
@ -78,6 +78,14 @@ function getHTMLFromAtext(pad, atext, authorColors)
|
|||
|
||||
var tags = ['h1', 'h2', 'strong', 'em', 'u', 's'];
|
||||
var props = ['heading1', 'heading2', 'bold', 'italic', 'underline', 'strikethrough'];
|
||||
|
||||
hooks.aCallAll("exportHtmlAdditionalTags", pad, function(err, newProps){
|
||||
newProps.forEach(function (propName, i){
|
||||
tags.push(propName);
|
||||
props.push(propName);
|
||||
});
|
||||
});
|
||||
|
||||
// holds a map of used styling attributes (*1, *2, etc) in the apool
|
||||
// and maps them to an index in props
|
||||
// *3:2 -> the attribute *3 means strong
|
||||
|
@ -425,32 +433,40 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback)
|
|||
{
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
var head =
|
||||
(noDocType ? '' : '<!doctype html>\n') +
|
||||
'<html lang="en">\n' + (noDocType ? '' : '<head>\n' +
|
||||
'<title>' + Security.escapeHTML(padId) + '</title>\n' +
|
||||
'<meta charset="utf-8">\n' +
|
||||
'<style> * { font-family: arial, sans-serif;\n' +
|
||||
'font-size: 13px;\n' +
|
||||
'line-height: 17px; }' +
|
||||
'ul.indent { list-style-type: none; }' +
|
||||
'ol { list-style-type: decimal; }' +
|
||||
'ol ol { list-style-type: lower-latin; }' +
|
||||
'ol ol ol { list-style-type: lower-roman; }' +
|
||||
'ol ol ol ol { list-style-type: decimal; }' +
|
||||
'ol ol ol ol ol { list-style-type: lower-latin; }' +
|
||||
'ol ol ol ol ol ol{ list-style-type: lower-roman; }' +
|
||||
'ol ol ol ol ol ol ol { list-style-type: decimal; }' +
|
||||
'ol ol ol ol ol ol ol ol{ list-style-type: lower-latin; }' +
|
||||
'</style>\n' + '</head>\n') +
|
||||
'<body>';
|
||||
var stylesForExportCSS = "";
|
||||
// Include some Styles into the Head for Export
|
||||
hooks.aCallAll("stylesForExport", padId, function(err, stylesForExport){
|
||||
stylesForExport.forEach(function(css){
|
||||
stylesForExportCSS += css;
|
||||
});
|
||||
// Core inclusion of head etc.
|
||||
var head =
|
||||
(noDocType ? '' : '<!doctype html>\n') +
|
||||
'<html lang="en">\n' + (noDocType ? '' : '<head>\n' +
|
||||
'<title>' + Security.escapeHTML(padId) + '</title>\n' +
|
||||
'<meta charset="utf-8">\n' +
|
||||
'<style> * { font-family: arial, sans-serif;\n' +
|
||||
'font-size: 13px;\n' +
|
||||
'line-height: 17px; }' +
|
||||
'ul.indent { list-style-type: none; }' +
|
||||
'ol { list-style-type: decimal; }' +
|
||||
'ol ol { list-style-type: lower-latin; }' +
|
||||
'ol ol ol { list-style-type: lower-roman; }' +
|
||||
'ol ol ol ol { list-style-type: decimal; }' +
|
||||
'ol ol ol ol ol { list-style-type: lower-latin; }' +
|
||||
'ol ol ol ol ol ol{ list-style-type: lower-roman; }' +
|
||||
'ol ol ol ol ol ol ol { list-style-type: decimal; }' +
|
||||
'ol ol ol ol ol ol ol ol{ list-style-type: lower-latin; }' +
|
||||
stylesForExportCSS +
|
||||
'</style>\n' + '</head>\n') +
|
||||
'<body>';
|
||||
var foot = '</body>\n</html>\n';
|
||||
|
||||
var foot = '</body>\n</html>\n';
|
||||
|
||||
getPadHTML(pad, revNum, function (err, html)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, head + html + foot);
|
||||
getPadHTML(pad, revNum, function (err, html)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, head + html + foot);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -105,6 +105,17 @@ a img {
|
|||
-moz-box-shadow: 0 0 8px rgba(0,0,0,.1) inset;
|
||||
box-shadow: 0 0 8px rgba(0,0,0,.1) inset;
|
||||
}
|
||||
.toolbar ul li .activeButton {
|
||||
background: #eee;
|
||||
background: -webkit-linear-gradient(#ddd, #fff);
|
||||
background: -moz-linear-gradient(#ddd, #fff);
|
||||
background: -o-linear-gradient(#ddd, #fff);
|
||||
background: -ms-linear-gradient(#ddd, #fff);
|
||||
background: linear-gradient(#ddd, #fff);
|
||||
-webkit-box-shadow: 0 0 8px rgba(0,0,0,.1) inset;
|
||||
-moz-box-shadow: 0 0 8px rgba(0,0,0,.1) inset;
|
||||
box-shadow: 0 0 8px rgba(0,0,0,.1) inset;
|
||||
}
|
||||
.toolbar ul li a {
|
||||
background: #fff;
|
||||
background: -webkit-linear-gradient(#fff, #f0f0f0);
|
||||
|
|
|
@ -27,6 +27,7 @@ var Changeset = require('./Changeset');
|
|||
var linestylefilter = require('./linestylefilter').linestylefilter;
|
||||
var colorutils = require('./colorutils').colorutils;
|
||||
var _ = require('./underscore');
|
||||
var hooks = require('./pluginfw/hooks');
|
||||
|
||||
// These parameters were global, now they are injected. A reference to the
|
||||
// Timeslider controller would probably be more appropriate.
|
||||
|
@ -534,6 +535,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
var savedRev = obj.savedRev;
|
||||
BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev);
|
||||
}
|
||||
hooks.callAll('handleClientTimesliderMessage_' + obj.type, {payload: obj});
|
||||
}
|
||||
else if(obj.type == "CHANGESET_REQ")
|
||||
{
|
||||
|
|
|
@ -34,7 +34,6 @@ var linestylefilter = {};
|
|||
var _ = require('./underscore');
|
||||
var AttributeManager = require('./AttributeManager');
|
||||
|
||||
|
||||
linestylefilter.ATTRIB_CLASSES = {
|
||||
'bold': 'tag:b',
|
||||
'italic': 'tag:i',
|
||||
|
@ -59,6 +58,13 @@ linestylefilter.getAuthorClassName = function(author)
|
|||
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
|
||||
{
|
||||
|
||||
// Plugin Hook to add more Attrib Classes
|
||||
hooks.aCallAll('aceAttribClasses', linestylefilter.ATTRIB_CLASSES, function(err, ATTRIB_CLASSES){
|
||||
if(ATTRIB_CLASSES){
|
||||
linestylefilter.ATTRIB_CLASSES = ATTRIB_CLASSES[0];
|
||||
}
|
||||
});
|
||||
|
||||
if (lineLength == 0) return textAndClassFunc;
|
||||
|
||||
var nextAfterAuthorColors = textAndClassFunc;
|
||||
|
|
Loading…
Reference in New Issue