1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-12-08 09:48:05 +00:00

Add new "print tiddler" button for the view toolbar

It works by opening the tiddler in a new window and then triggering the browser print dialogue.
This commit is contained in:
Jermolene
2018-05-10 11:33:23 +01:00
parent b95aa6ec6a
commit 523060e823
4 changed files with 26 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ exports.startup = function() {
title = event.param || event.tiddlerTitle,
paramObject = event.paramObject || {},
template = paramObject.template || "$:/core/templates/single.tiddler.window",
print = paramObject.print === "yes",
width = paramObject.width || "700",
height = paramObject.height || "600",
variables = $tw.utils.extend({},paramObject,{currentTiddler: title});
@@ -62,6 +63,10 @@ exports.startup = function() {
var parser = $tw.wiki.parseTiddler(template),
widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, parentWidget: $tw.rootWidget, variables: variables});
widgetNode.render(srcDocument.body,srcDocument.body.firstChild);
// Print the window if required
if(print) {
srcWindow.print();
}
// Function to handle refreshes
refreshHandler = function(changes) {
if(styleWidgetNode.refresh(changes,styleContainer,null)) {