diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index 14920061b..16a878b88 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -18,7 +18,11 @@ exports.platforms = ["browser"]; exports.after = ["startup"]; exports.synchronous = true; +// Global to keep track of open windows (hashmap by title) +var windows = {}; + exports.startup = function() { + // Handle open window message $tw.rootWidget.addEventListener("tm-open-window",function(event) { // Get the parameters var refreshHandler, @@ -30,6 +34,7 @@ exports.startup = function() { // Open the window var srcWindow = window.open("","external-" + title,"width=" + width + ",height=" + height), srcDocument = srcWindow.document; + windows[title] = srcWindow; // Check for reopening the same window if(srcWindow.haveInitialisedWindow) { return; @@ -39,6 +44,7 @@ exports.startup = function() { srcDocument.close(); srcDocument.title = title; srcWindow.addEventListener("beforeunload",function(event) { + delete windows[title]; $tw.wiki.removeEventListener("change",refreshHandler); },false); // Set up the styles @@ -50,7 +56,7 @@ exports.startup = function() { srcDocument.head.insertBefore(styleElement,srcDocument.head.firstChild); // Render the text of the tiddler var parser = $tw.wiki.parseTiddler(template), - widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, variables: {currentTiddler: title}}); + widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, parentWidget: $tw.rootWidget, variables: {currentTiddler: title}}); widgetNode.render(srcDocument.body,null); // Function to handle refreshes refreshHandler = function(changes) { @@ -62,6 +68,13 @@ exports.startup = function() { $tw.wiki.addEventListener("change",refreshHandler); srcWindow.haveInitialisedWindow = true; }); + // Close open windows when unloading main window + $tw.addUnloadTask(function() { + $tw.utils.each(windows,function(win) { + win.close(); + }); + }); + }; })(); diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index b47476a9b..cf8848d3b 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -66,10 +66,6 @@ body.tc-body { <> } -body.tc-body.tc-single-tiddler-window { - margin: 1em; -} - h1, h2, h3, h4, h5, h6 { line-height: 1.2; font-weight: 300; @@ -345,6 +341,7 @@ button svg, button img { height: 2em; width: 2em; vertical-align: middle; + fill: <>; } .tc-sidebar-lists input { @@ -821,6 +818,11 @@ canvas.tc-edit-bitmapeditor { overflow: hidden; /* https://github.com/Jermolene/TiddlyWiki5/issues/282 */ } +html body.tc-body.tc-single-tiddler-window { + margin: 1em; + background-color: <>; +} + /* ** Toolbar buttons */ @@ -1740,6 +1742,7 @@ body.tc-dirty span.tc-dirty-indicator, body.tc-dirty span.tc-dirty-indicator svg opacity: 1; min-width: 100%; min-height: 100%; + max-width: 100%; } .tc-thumbnail-wrapper:hover .tc-thumbnail-image svg,