diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index 9ce34f842..69966f346 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -49,7 +49,10 @@ exports.startup = function() { $tw.wiki.removeEventListener("change",refreshHandler); },false); // Set up the styles - var styleWidgetNode = $tw.wiki.makeTranscludeWidget("$:/core/ui/PageStylesheet",{document: $tw.fakeDocument, variables: variables}), + 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"); diff --git a/core/modules/utils/dom/modal.js b/core/modules/utils/dom/modal.js index 2286d31cb..74fceb1ba 100644 --- a/core/modules/utils/dom/modal.js +++ b/core/modules/utils/dom/modal.js @@ -81,14 +81,16 @@ Modal.prototype.display = function(title,options) { }}}], parentWidget: $tw.rootWidget, document: document, - variables: variables + variables: variables, + importPageMacros: true }); headerWidgetNode.render(headerTitle,null); // Render the body of the message var bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{ parentWidget: $tw.rootWidget, document: document, - variables: variables + variables: variables, + importPageMacros: true }); bodyWidgetNode.render(modalBody,null); // Setup the link if present @@ -128,7 +130,8 @@ Modal.prototype.display = function(title,options) { ]}], parentWidget: $tw.rootWidget, document: document, - variables: variables + variables: variables, + importPageMacros: true }); footerWidgetNode.render(modalFooterButtons,null); // Set up the refresh handler diff --git a/core/modules/utils/dom/notifier.js b/core/modules/utils/dom/notifier.js index ca8e54ad7..3897b0e52 100644 --- a/core/modules/utils/dom/notifier.js +++ b/core/modules/utils/dom/notifier.js @@ -41,7 +41,11 @@ Notifier.prototype.display = function(title,options) { // Create the variables var variables = $tw.utils.extend({currentTiddler: title},options.variables); // Render the body of the notification - var widgetNode = this.wiki.makeTranscludeWidget(title,{parentWidget: $tw.rootWidget, document: document, variables: variables}); + var widgetNode = this.wiki.makeTranscludeWidget(title,{ + parentWidget: $tw.rootWidget, + document: document, + variables: variables, + importPageMacros: true}); widgetNode.render(notification,null); refreshHandler = function(changes) { widgetNode.refresh(changes,notification,null); diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 4628e5acc..63e31303c 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -328,7 +328,7 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,is var result = isNaN(x) && !isNaN(y) ? (isDescending ? -1 : 1) : !isNaN(x) && isNaN(y) ? (isDescending ? 1 : -1) : - (isDescending ? y - x : x - y); + (isDescending ? y - x : x - y); return result; }; if(sortField !== "title") { @@ -904,44 +904,54 @@ options: as for wiki.makeWidget() plus: options.field: optional field to transclude (defaults to "text") options.mode: transclusion mode "inline" or "block" options.children: optional array of children for the transclude widget +options.importVariables: optional importvariables filter string for macros to be included +options.importPageMacros: optional boolean; if true, equivalent to passing "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]" to options.importVariables */ exports.makeTranscludeWidget = function(title,options) { options = options || {}; - var parseTree = {tree: [{ + var parseTreeDiv = {tree: [{ type: "element", tag: "div", - children: [{ - type: "importvariables", - attributes: { - filter: { - name: "filter", - type: "string", - value: "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]" - } - }, - tag: "$importvariables", - isBlock: false, - children: [{ - type: "transclude", - attributes: { - tiddler: { - name: "tiddler", - type: "string", - value: title}}, - isBlock: !options.parseAsInline} - ] - }]} - ]}; + children: []}]}, + parseTreeImportVariables = { + type: "importvariables", + attributes: { + filter: { + name: "filter", + type: "string" + } + }, + isBlock: false, + children: []}, + parseTreeTransclude = { + type: "transclude", + attributes: { + tiddler: { + name: "tiddler", + type: "string", + value: title}}, + isBlock: !options.parseAsInline}; + if(options.importVariables || options.importPageMacros) { + if(options.importVariables) { + parseTreeImportVariables.attributes.filter.value = options.importVariables; + } else if(options.importPageMacros) { + parseTreeImportVariables.attributes.filter.value = "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]"; + } + parseTreeDiv.tree[0].children.push(parseTreeImportVariables); + parseTreeImportVariables.children.push(parseTreeTransclude); + } else { + parseTreeDiv.tree[0].children.push(parseTreeTransclude); + } if(options.field) { - parseTree.tree[0].children[0].attributes.field = {type: "string", value: options.field}; + parseTreeTransclude.attributes.field = {type: "string", value: options.field}; } if(options.mode) { - parseTree.tree[0].children[0].attributes.mode = {type: "string", value: options.mode}; + parseTreeTransclude.attributes.mode = {type: "string", value: options.mode}; } if(options.children) { - parseTree.tree[0].children[0].children = options.children; + parseTreeTransclude.children = options.children; } - return $tw.wiki.makeWidget(parseTree,options); + return $tw.wiki.makeWidget(parseTreeDiv,options); }; /* diff --git a/plugins/tiddlywiki/text-slicer/modules/slicer.js b/plugins/tiddlywiki/text-slicer/modules/slicer.js index 68ef8bbdc..2514b3d64 100644 --- a/plugins/tiddlywiki/text-slicer/modules/slicer.js +++ b/plugins/tiddlywiki/text-slicer/modules/slicer.js @@ -122,7 +122,10 @@ Slicer.prototype.getSourceHtmlDocument = function(tiddler) { }; Slicer.prototype.getSourceWikiDocument = function(tiddler) { - var widgetNode = this.wiki.makeTranscludeWidget(this.sourceTitle,{document: $tw.fakeDocument, parseAsInline: false}), + var widgetNode = this.wiki.makeTranscludeWidget(this.sourceTitle,{ + document: $tw.fakeDocument, + parseAsInline: false, + importPageMacros: true}), container = $tw.fakeDocument.createElement("div"); widgetNode.render(container,null); return container;