mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
Merge pull request #2487 from ether/html-e-hook
Better HTML Export rewrite hook allows functions to be passed instead of strings means state is saved between plugins
This commit is contained in:
commit
831151cfba
2 changed files with 51 additions and 4 deletions
|
@ -411,14 +411,28 @@ function getHTMLFromAtext(pad, atext, authorColors)
|
|||
}
|
||||
lists = []
|
||||
|
||||
var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport",
|
||||
{
|
||||
var context = {
|
||||
line: line,
|
||||
lineContent: lineContent,
|
||||
apool: apool,
|
||||
attribLine: attribLines[i],
|
||||
text: textLines[i]
|
||||
}, " ", " ", "");
|
||||
}
|
||||
|
||||
// See https://github.com/ether/etherpad-lite/issues/2486
|
||||
hooks.aCallAll("asyncLineHTMLForExport", context, function(err, newLineFunction){
|
||||
// For each function returned by the hook call
|
||||
// Process the text based on the function
|
||||
newLineFunction.forEach(function(fn){
|
||||
context.lineContent = fn(context); // note the fn
|
||||
});
|
||||
// We now have a line that has been processed by each hook function
|
||||
lineContent = context.lineContent; // modified lineContent here
|
||||
});
|
||||
|
||||
// Old hook probably not to be used..
|
||||
var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport", context, " ", " ", "");
|
||||
|
||||
if (lineContentFromHook)
|
||||
{
|
||||
pieces.push(lineContentFromHook, '');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue