mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-03 20:59:09 +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:
parent
b95aa6ec6a
commit
523060e823
@ -82,6 +82,8 @@ Permaview/Caption: permaview
|
|||||||
Permaview/Hint: Set browser address bar to a direct link to all the tiddlers in this story
|
Permaview/Hint: Set browser address bar to a direct link to all the tiddlers in this story
|
||||||
Print/Caption: print page
|
Print/Caption: print page
|
||||||
Print/Hint: Print the current page
|
Print/Hint: Print the current page
|
||||||
|
PrintWindow/Caption: print in new window
|
||||||
|
PrintWindow/Hint: Print tiddler in new window
|
||||||
Refresh/Caption: refresh
|
Refresh/Caption: refresh
|
||||||
Refresh/Hint: Perform a full refresh of the wiki
|
Refresh/Hint: Perform a full refresh of the wiki
|
||||||
Save/Caption: ok
|
Save/Caption: ok
|
||||||
|
@ -29,6 +29,7 @@ exports.startup = function() {
|
|||||||
title = event.param || event.tiddlerTitle,
|
title = event.param || event.tiddlerTitle,
|
||||||
paramObject = event.paramObject || {},
|
paramObject = event.paramObject || {},
|
||||||
template = paramObject.template || "$:/core/templates/single.tiddler.window",
|
template = paramObject.template || "$:/core/templates/single.tiddler.window",
|
||||||
|
print = paramObject.print === "yes",
|
||||||
width = paramObject.width || "700",
|
width = paramObject.width || "700",
|
||||||
height = paramObject.height || "600",
|
height = paramObject.height || "600",
|
||||||
variables = $tw.utils.extend({},paramObject,{currentTiddler: title});
|
variables = $tw.utils.extend({},paramObject,{currentTiddler: title});
|
||||||
@ -62,6 +63,10 @@ exports.startup = function() {
|
|||||||
var parser = $tw.wiki.parseTiddler(template),
|
var parser = $tw.wiki.parseTiddler(template),
|
||||||
widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, parentWidget: $tw.rootWidget, variables: variables});
|
widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, parentWidget: $tw.rootWidget, variables: variables});
|
||||||
widgetNode.render(srcDocument.body,srcDocument.body.firstChild);
|
widgetNode.render(srcDocument.body,srcDocument.body.firstChild);
|
||||||
|
// Print the window if required
|
||||||
|
if(print) {
|
||||||
|
srcWindow.print();
|
||||||
|
}
|
||||||
// Function to handle refreshes
|
// Function to handle refreshes
|
||||||
refreshHandler = function(changes) {
|
refreshHandler = function(changes) {
|
||||||
if(styleWidgetNode.refresh(changes,styleContainer,null)) {
|
if(styleWidgetNode.refresh(changes,styleContainer,null)) {
|
||||||
|
18
core/ui/ViewToolbar/print-window.tid
Normal file
18
core/ui/ViewToolbar/print-window.tid
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
title: $:/core/ui/Buttons/print-window
|
||||||
|
tags: $:/tags/ViewToolbar
|
||||||
|
caption: {{$:/core/images/print-button}} {{$:/language/Buttons/PrintWindow/Caption}}
|
||||||
|
description: {{$:/language/Buttons/PrintWindow/Hint}}
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
<$button tooltip={{$:/language/Buttons/PrintWindow/Hint}} aria-label={{$:/language/Buttons/PrintWindow/Caption}} class=<<tv-config-toolbar-class>>>
|
||||||
|
<$action-sendmessage $message="tm-open-window" print="yes"/>
|
||||||
|
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
|
||||||
|
{{$:/core/images/print-button}}
|
||||||
|
</$list>
|
||||||
|
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
|
||||||
|
<span class="tc-btn-text">
|
||||||
|
<$text text=" "/>
|
||||||
|
<$text text={{$:/language/Buttons/PrintWindow/Caption}}/>
|
||||||
|
</span>
|
||||||
|
</$list>
|
||||||
|
</$button>
|
@ -12,6 +12,7 @@ The `tm-open-window` message opens a tiddler in a new //browser// window. If no
|
|||||||
|template |Template in which the tiddler will be rendered in |
|
|template |Template in which the tiddler will be rendered in |
|
||||||
|width |Width of the new browser window |
|
|width |Width of the new browser window |
|
||||||
|height |Height of the new browser window |
|
|height |Height of the new browser window |
|
||||||
|
|print |Set to "yes" to trigger opening of the browser print dialogue |
|
||||||
|paramObject |Hashmap of variables that will be provided to the window |
|
|paramObject |Hashmap of variables that will be provided to the window |
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user