1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00
This commit is contained in:
Jermolene 2016-10-18 16:39:18 +01:00
parent 5aba7292e7
commit 8e02bde938
5 changed files with 57 additions and 34 deletions

View File

@ -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");

View File

@ -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

View File

@ -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);

View File

@ -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);
};
/*

View File

@ -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;