mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 17:36:14 -04:00
Merge pull request #2368 from ether/hook_for_exportHTMLStyles
Hook for export html styles
This commit is contained in:
commit
70ba525430
6 changed files with 129 additions and 26 deletions
|
@ -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.
|
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
|
## aceGetFilterStack
|
||||||
Called from: src/static/js/linestylefilter.js
|
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.
|
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
|
## exportFileName
|
||||||
Called from src/node/handler/ExportHandler.js
|
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
|
## userLeave
|
||||||
Called from src/node/handler/PadMessageHandler.js
|
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 tags = ['h1', 'h2', 'strong', 'em', 'u', 's'];
|
||||||
var props = ['heading1', 'heading2', 'bold', 'italic', 'underline', 'strikethrough'];
|
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
|
// holds a map of used styling attributes (*1, *2, etc) in the apool
|
||||||
// and maps them to an index in props
|
// and maps them to an index in props
|
||||||
// *3:2 -> the attribute *3 means strong
|
// *3:2 -> the attribute *3 means strong
|
||||||
|
@ -425,32 +433,40 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
|
||||||
var head =
|
var stylesForExportCSS = "";
|
||||||
(noDocType ? '' : '<!doctype html>\n') +
|
// Include some Styles into the Head for Export
|
||||||
'<html lang="en">\n' + (noDocType ? '' : '<head>\n' +
|
hooks.aCallAll("stylesForExport", padId, function(err, stylesForExport){
|
||||||
'<title>' + Security.escapeHTML(padId) + '</title>\n' +
|
stylesForExport.forEach(function(css){
|
||||||
'<meta charset="utf-8">\n' +
|
stylesForExportCSS += css;
|
||||||
'<style> * { font-family: arial, sans-serif;\n' +
|
});
|
||||||
'font-size: 13px;\n' +
|
// Core inclusion of head etc.
|
||||||
'line-height: 17px; }' +
|
var head =
|
||||||
'ul.indent { list-style-type: none; }' +
|
(noDocType ? '' : '<!doctype html>\n') +
|
||||||
'ol { list-style-type: decimal; }' +
|
'<html lang="en">\n' + (noDocType ? '' : '<head>\n' +
|
||||||
'ol ol { list-style-type: lower-latin; }' +
|
'<title>' + Security.escapeHTML(padId) + '</title>\n' +
|
||||||
'ol ol ol { list-style-type: lower-roman; }' +
|
'<meta charset="utf-8">\n' +
|
||||||
'ol ol ol ol { list-style-type: decimal; }' +
|
'<style> * { font-family: arial, sans-serif;\n' +
|
||||||
'ol ol ol ol ol { list-style-type: lower-latin; }' +
|
'font-size: 13px;\n' +
|
||||||
'ol ol ol ol ol ol{ list-style-type: lower-roman; }' +
|
'line-height: 17px; }' +
|
||||||
'ol ol ol ol ol ol ol { list-style-type: decimal; }' +
|
'ul.indent { list-style-type: none; }' +
|
||||||
'ol ol ol ol ol ol ol ol{ list-style-type: lower-latin; }' +
|
'ol { list-style-type: decimal; }' +
|
||||||
'</style>\n' + '</head>\n') +
|
'ol ol { list-style-type: lower-latin; }' +
|
||||||
'<body>';
|
'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)
|
||||||
|
{
|
||||||
getPadHTML(pad, revNum, function (err, html)
|
if(ERR(err, callback)) return;
|
||||||
{
|
callback(null, head + html + foot);
|
||||||
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;
|
-moz-box-shadow: 0 0 8px rgba(0,0,0,.1) inset;
|
||||||
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 {
|
.toolbar ul li a {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
background: -webkit-linear-gradient(#fff, #f0f0f0);
|
background: -webkit-linear-gradient(#fff, #f0f0f0);
|
||||||
|
|
|
@ -27,6 +27,7 @@ var Changeset = require('./Changeset');
|
||||||
var linestylefilter = require('./linestylefilter').linestylefilter;
|
var linestylefilter = require('./linestylefilter').linestylefilter;
|
||||||
var colorutils = require('./colorutils').colorutils;
|
var colorutils = require('./colorutils').colorutils;
|
||||||
var _ = require('./underscore');
|
var _ = require('./underscore');
|
||||||
|
var hooks = require('./pluginfw/hooks');
|
||||||
|
|
||||||
// These parameters were global, now they are injected. A reference to the
|
// These parameters were global, now they are injected. A reference to the
|
||||||
// Timeslider controller would probably be more appropriate.
|
// Timeslider controller would probably be more appropriate.
|
||||||
|
@ -534,6 +535,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
||||||
var savedRev = obj.savedRev;
|
var savedRev = obj.savedRev;
|
||||||
BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev);
|
BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev);
|
||||||
}
|
}
|
||||||
|
hooks.callAll('handleClientTimesliderMessage_' + obj.type, {payload: obj});
|
||||||
}
|
}
|
||||||
else if(obj.type == "CHANGESET_REQ")
|
else if(obj.type == "CHANGESET_REQ")
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,6 @@ var linestylefilter = {};
|
||||||
var _ = require('./underscore');
|
var _ = require('./underscore');
|
||||||
var AttributeManager = require('./AttributeManager');
|
var AttributeManager = require('./AttributeManager');
|
||||||
|
|
||||||
|
|
||||||
linestylefilter.ATTRIB_CLASSES = {
|
linestylefilter.ATTRIB_CLASSES = {
|
||||||
'bold': 'tag:b',
|
'bold': 'tag:b',
|
||||||
'italic': 'tag:i',
|
'italic': 'tag:i',
|
||||||
|
@ -59,6 +58,13 @@ linestylefilter.getAuthorClassName = function(author)
|
||||||
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
|
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;
|
if (lineLength == 0) return textAndClassFunc;
|
||||||
|
|
||||||
var nextAfterAuthorColors = textAndClassFunc;
|
var nextAfterAuthorColors = textAndClassFunc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue