diff --git a/core/modules/startup/render.js b/core/modules/startup/render.js index bb4aac51e..43ef48207 100644 --- a/core/modules/startup/render.js +++ b/core/modules/startup/render.js @@ -17,7 +17,7 @@ exports.synchronous = true; // Default story and history lists var PAGE_TITLE_TITLE = "$:/core/wiki/title"; -var ROOT_STYLESHEET_TITLE = "$:/core/ui/RootStylesheet"; +var PAGE_STYLESHEET_TITLE = "$:/core/ui/PageStylesheet"; var PAGE_TEMPLATE_TITLE = "$:/core/ui/RootTemplate"; // Time (in ms) that we defer refreshing changes to draft tiddlers @@ -44,13 +44,22 @@ exports.startup = function() { publishTitle(); } }); - - var styleParser = $tw.wiki.parseTiddler(ROOT_STYLESHEET_TITLE,{parseAsInline: true}), - styleWidgetNode = $tw.wiki.makeWidget(styleParser,{document: document}); - styleWidgetNode.render(document.head,null); - + // Set up the styles + $tw.styleWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_STYLESHEET_TITLE,{document: $tw.fakeDocument}); + $tw.styleContainer = $tw.fakeDocument.createElement("style"); + $tw.styleWidgetNode.render($tw.styleContainer,null); + $tw.styleWidgetNode.assignedStyles = $tw.styleContainer.textContent; + $tw.styleElement = document.createElement("style"); + $tw.styleElement.innerHTML = $tw.styleWidgetNode.assignedStyles; + document.head.insertBefore($tw.styleElement,document.head.firstChild); $tw.wiki.addEventListener("change",$tw.perf.report("styleRefresh",function(changes) { - styleWidgetNode.refresh(changes,document.head,null); + if($tw.styleWidgetNode.refresh(changes,$tw.styleContainer,null)) { + var newStyles = $tw.styleContainer.textContent; + if(newStyles !== $tw.styleWidgetNode.assignedStyles) { + $tw.styleWidgetNode.assignedStyles = newStyles; + $tw.styleElement.innerHTML = $tw.styleWidgetNode.assignedStyles; + } + } })); // Display the $:/core/ui/PageTemplate tiddler to kick off the display $tw.perf.report("mainRender",function() { @@ -59,7 +68,7 @@ exports.startup = function() { $tw.utils.addClass($tw.pageContainer,"tc-page-container-wrapper"); document.body.insertBefore($tw.pageContainer,document.body.firstChild); $tw.pageWidgetNode.render($tw.pageContainer,null); - $tw.hooks.invokeHook("th-page-refreshed"); + $tw.hooks.invokeHook("th-page-refreshed"); })(); // Remove any splash screen elements var removeList = document.querySelectorAll(".tc-remove-when-wiki-loaded"); diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index 3fa70d127..39a2f59d6 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -63,16 +63,24 @@ exports.startup = function() { $tw.eventBus.emit("window:closed",{windowID}); },false); // Set up the styles - var styleParser = $tw.wiki.parseTiddler("$:/core/ui/RootStylesheet",{parseAsInline: true}), - styleWidgetNode = $tw.wiki.makeWidget(styleParser,{document: srcDocument}); - styleWidgetNode.render(srcDocument.head,null); + var styleWidgetNode = $tw.wiki.makeTranscludeWidget("$:/core/ui/PageStylesheet",{ + document: $tw.fakeDocument, + variables: variables, + importPageMacros: true}), + styleContainer = $tw.fakeDocument.createElement("style"); + styleWidgetNode.render(styleContainer,null); + var styleElement = srcDocument.createElement("style"); + styleElement.innerHTML = styleContainer.textContent; + 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, parentWidget: $tw.rootWidget, variables: variables}); widgetNode.render(srcDocument.body,srcDocument.body.firstChild); // Function to handle refreshes refreshHandler = function(changes) { - styleWidgetNode.refresh(changes); + if(styleWidgetNode.refresh(changes,styleContainer,null)) { + styleElement.innerHTML = styleContainer.textContent; + } widgetNode.refresh(changes); }; $tw.wiki.addEventListener("change",refreshHandler); diff --git a/core/templates/exporters/StaticRiver.tid b/core/templates/exporters/StaticRiver.tid index 176ab80be..3b70c9d11 100644 --- a/core/templates/exporters/StaticRiver.tid +++ b/core/templates/exporters/StaticRiver.tid @@ -22,7 +22,9 @@ extension: .html
{{$:/boot/boot.css||$:/core/templates/css-tiddler}}
-{{$:/core/ui/RootStylesheet||$:/core/templates/wikified-tiddler}} + {{$:/StaticBanner||$:/core/templates/html-tiddler}} diff --git a/core/templates/static.template.html.tid b/core/templates/static.template.html.tid index ef290053b..8b6482846 100644 --- a/core/templates/static.template.html.tid +++ b/core/templates/static.template.html.tid @@ -23,7 +23,9 @@ type: text/vnd.tiddlywiki-html
{{$:/boot/boot.css||$:/core/templates/css-tiddler}}
-{{$:/core/ui/RootStylesheet||$:/core/templates/wikified-tiddler}} + {{$:/StaticBanner||$:/core/templates/html-tiddler}} diff --git a/core/templates/tiddlywiki5.html.tid b/core/templates/tiddlywiki5.html.tid index c38cde960..721b3d9ce 100644 --- a/core/templates/tiddlywiki5.html.tid +++ b/core/templates/tiddlywiki5.html.tid @@ -25,7 +25,6 @@ title: $:/core/templates/tiddlywiki5.html `{{{ [enlisttag[$:/core/wiki/rawmarkup]] ||$:/core/templates/plain-text-tiddler}}} {{{ [enlisttag[$:/tags/RawMarkup]] ||$:/core/templates/plain-text-tiddler}}} {{{ [enlisttag[$:/tags/RawMarkupWikified]] ||$:/core/templates/raw-static-tiddler}}}` - diff --git a/core/ui/RootStylesheet.tid b/core/ui/RootStylesheet.tid deleted file mode 100644 index 67145d93c..000000000 --- a/core/ui/RootStylesheet.tid +++ /dev/null @@ -1,13 +0,0 @@ -title: $:/core/ui/RootStylesheet -code-body: yes - -\import [subfilter{$:/core/config/GlobalImportFilter}] -\whitespace trim -<$let currentTiddler={{$:/language}} languageTitle={{!!name}}> - <$list filter="[all[shadows+tiddlers]tag[$:/tags/Stylesheet]!is[draft]]"> - - - diff --git a/editions/tw5.com/tiddlers/releasenotes/5.4.0/#8130 - root-stylesheet-refresh.tid b/editions/tw5.com/tiddlers/releasenotes/5.4.0/#8130 - root-stylesheet-refresh.tid deleted file mode 100644 index d57f8b596..000000000 --- a/editions/tw5.com/tiddlers/releasenotes/5.4.0/#8130 - root-stylesheet-refresh.tid +++ /dev/null @@ -1,15 +0,0 @@ -title: $:/changenotes/5.4.0/#9554 -created: 20251212171804335 -modified: 20251212171804335 -tags: $:/tags/ChangeNote -change-type: performance -change-category: internal -description: Different Stylesheets are now included as single `