1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Merge branch 'master' into geospatial-plugin

This commit is contained in:
jeremy@jermolene.com 2023-05-14 21:49:00 +01:00
commit a14f038780
56 changed files with 422 additions and 195 deletions

View File

@ -5,7 +5,7 @@
# Default to the current version number for building the plugin library
if [ -z "$TW5_BUILD_VERSION" ]; then
TW5_BUILD_VERSION=v5.2.8
TW5_BUILD_VERSION=v5.3.0
fi
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"

View File

@ -112,7 +112,7 @@ CheckboxWidget.prototype.getValue = function() {
var list;
if(this.checkboxListField) {
if($tw.utils.hop(tiddler.fields,this.checkboxListField)) {
list = tiddler.getFieldList(this.checkboxListField);
list = tiddler.getFieldList(this.checkboxListField) || [];
} else {
list = $tw.utils.parseStringArray(this.checkboxDefault || "") || [];
}
@ -208,16 +208,20 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) {
if(this.checkboxListField || this.checkboxListIndex) {
var fieldContents, listContents, oldPos, newPos;
if(this.checkboxListField) {
fieldContents = tiddler ? tiddler.fields[this.checkboxListField] : undefined;
fieldContents = (tiddler ? tiddler.fields[this.checkboxListField] : undefined) || [];
} else {
fieldContents = this.wiki.extractTiddlerDataItem(this.checkboxTitle,this.checkboxListIndex);
}
if($tw.utils.isArray(fieldContents)) {
// Make a copy so we can modify it without changing original that's refrenced elsewhere
listContents = fieldContents.slice(0);
} else {
listContents = $tw.utils.parseStringArray(fieldContents) || [];
} else if(typeof fieldContents === "string") {
listContents = $tw.utils.parseStringArray(fieldContents);
// No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere
} else {
// Field was neither an array nor a string; it's probably something that shouldn't become
// an array (such as a date field), so bail out *without* triggering actions
return;
}
oldPos = notValue ? listContents.indexOf(notValue) : -1;
newPos = value ? listContents.indexOf(value) : -1;

View File

@ -51,7 +51,8 @@ MacroCallWidget.prototype.execute = function() {
var positionalName = 0,
parseTreeNodes = [{
type: "transclude",
isBlock: this.parseTreeNode.isBlock
isBlock: this.parseTreeNode.isBlock,
children: this.parseTreeNode.children
}];
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$variable",this.macroName);
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$type",this.parseType);

View File

@ -48,7 +48,7 @@ SlotWidget.prototype.execute = function() {
var pointer = this.parentWidget,
depth = this.slotDepth;
while(pointer) {
if(pointer instanceof TranscludeWidget) {
if(pointer instanceof TranscludeWidget && pointer.hasVisibleSlots()) {
depth--;
if(depth <= 0) {
break;

View File

@ -45,7 +45,7 @@ TranscludeWidget.prototype.execute = function() {
var target = this.getTransclusionTarget(),
parseTreeNodes = target.parseTreeNodes;
this.sourceText = target.text;
this.sourceType = target.type;
this.parserType = target.type;
this.parseAsInline = target.parseAsInline;
// Process the transclusion according to the output type
switch(this.transcludeOutput || "text/html") {
@ -58,7 +58,7 @@ TranscludeWidget.prototype.execute = function() {
break;
default:
// text/plain
var plainText = this.wiki.renderText("text/plain",this.sourceType,this.sourceText,{parentWidget: this});
var plainText = this.wiki.renderText("text/plain",this.parserType,this.sourceText,{parentWidget: this});
parseTreeNodes = [{type: "text", text: plainText}];
break;
}
@ -171,11 +171,12 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
}
var parser;
// Get the parse tree
if(this.hasAttribute("$variable")) {
if(this.transcludeVariable) {
// Transcluding a variable
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
srcVariable = variableInfo && variableInfo.srcVariable;
if(srcVariable) {
if(variableInfo.text) {
if(srcVariable.isFunctionDefinition) {
// Function to return parameters by name or position
var fnGetParam = function(name,index) {
@ -267,6 +268,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
}
}
}
}
} else {
// Transcluding a text reference
parser = this.wiki.parseTextReference(
@ -382,6 +384,13 @@ TranscludeWidget.prototype.getTransclusionSlotFill = function(name,defaultParseT
}
};
/*
Return whether this transclusion should be visible to the slot widget
*/
TranscludeWidget.prototype.hasVisibleSlots = function() {
return this.getAttribute("$fillignore","no") === "no";
}
/*
Compose a string comprising the title, field and/or index to identify this transclusion for recursion detection
*/

View File

@ -324,7 +324,7 @@ Widget.prototype.makeFakeWidgetWithVariables = function(variables) {
};
/*
Evaluate a variable and associated actual parameters and result the resulting array.
Evaluate a variable and associated actual parameters and return the resulting array.
The way that the variable is evaluated depends upon its type:
* Functions are evaluated as parameterised filter strings
* Macros are returned as plain text with substitution of parameters

View File

@ -1149,7 +1149,7 @@ exports.makeTranscludeWidget = function(title,options) {
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]]";
parseTreeImportVariables.attributes.filter.value = this.getTiddlerText("$:/core/config/GlobalImportFilter");
}
parseTreeDiv.tree[0].children.push(parseTreeImportVariables);
parseTreeImportVariables.children.push(parseTreeTransclude);

View File

@ -3,5 +3,5 @@ title: $:/core/templates/exporters/StaticRiver/Content
\define renderContent()
{{{ $(exportFilter)$ ||$:/core/templates/static-tiddler}}}
\end
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
<<renderContent>>

View File

@ -7,5 +7,5 @@ condition: [<count>compare:lte[1]]
\define renderContent()
{{{ $(exportFilter)$ +[limit[1]] ||$:/core/templates/tid-tiddler}}}
\end
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
<<renderContent>>

View File

@ -1,7 +1,7 @@
title: $:/core/save/all-external-js
\whitespace trim
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/core]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$
\end

View File

@ -1,7 +1,7 @@
title: $:/core/save/offline-external-js
\whitespace trim
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/core]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/tiddlywiki/tiddlyweb]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$
\end

View File

@ -1,6 +1,6 @@
title: $:/core/save/all
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$
\end

View File

@ -2,7 +2,7 @@ title: $:/core/templates/server/static.tiddler.html
\whitespace trim
\define tv-wikilink-template() $uri_encoded$
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

View File

@ -4,7 +4,7 @@ title: $:/core/templates/single.tiddler.window
\define containerClasses()
tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
\end
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
<$vars
tv-config-toolbar-icons={{$:/config/Toolbar/Icons}}

View File

@ -4,7 +4,7 @@ title: $:/core/templates/static.tiddler.html
\define tv-config-toolbar-icons() no
\define tv-config-toolbar-text() no
\define tv-config-toolbar-class() tc-btn-invisible
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
`<!doctype html>
<html>
<head>

View File

@ -30,15 +30,15 @@ Block transclusions are shown in red, and inline transclusions are shown in gree
<!-- Look for a parameter starting with $ to determine if we are in legacy mode -->
<$list filter="[<@params>jsonindexes[]] :filter[<currentTiddler>prefix[$]] +[limit[1]]" variable="ignore" emptyMessage="""
<!-- Legacy mode: we render the transclusion without a dollar sign for recursionMarker and mode -->
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" recursionMarker="no" mode=<<mode>>>
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" recursionMarker="no" mode=<<mode>> $$fillignore="yes">
<!-- Reach back up to the grandparent transclusion to get the correct slot value -->
<$slot $name="ts-raw" $depth="2"/>
<$slot $name="ts-raw"/>
</$genesis>
""">
<!-- Non-legacy mode: we use dollar signs for the recursionMarker and mode -->
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" $$recursionMarker="no" $$mode=<<mode>>>
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" $$recursionMarker="no" $$mode=<<mode>> $$fillignore="yes">
<!-- Reach back up to the grandparent transclusion to get the correct slot fill value -->
<$slot $name="ts-raw" $depth="2"/>
<$slot $name="ts-raw"/>
</$genesis>
</$list>
</$genesis>

View File

@ -211,7 +211,7 @@ $:/state/add-plugin-info/$(connectionTiddler)$/$(assetInfo)$
</div>
\end
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
\whitespace trim
<div>

View File

@ -2,7 +2,7 @@ title: $:/core/ui/EditTemplate/body/preview/output
tags: $:/tags/EditPreview
caption: {{$:/language/EditTemplate/Body/Preview/Type/Output}}
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!has[draft.of]] [all[shadows+tiddlers]tag[$:/tags/Macro/View/Body]!has[draft.of]]
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Macro/View/Body]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View/Body]!is[draft]]
<$set name="tv-tiddler-preview" value="yes">
<$transclude tiddler={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/ViewTemplateBodyFilter]!is[draft]get[text]] :and[!is[blank]else[$:/core/ui/ViewTemplate/body/default]] }}} />

View File

@ -1,6 +1,6 @@
title: $:/core/ui/PageStylesheet
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
\whitespace trim
<$set name="currentTiddler" value={{$:/language}}>

View File

@ -4,7 +4,7 @@ description: {{$:/language/PageTemplate/Description}}
icon: $:/core/images/layout-button
\whitespace trim
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
<$vars
tv-config-toolbar-icons={{$:/config/Toolbar/Icons}}

View File

@ -5,10 +5,10 @@ title: $:/core/ui/ViewTemplate
$:/state/folded/$(currentTiddler)$
\end
\define cancel-delete-tiddler-actions(message) <$action-sendmessage $message="tm-$message$-tiddler"/>
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!has[draft.of]]
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View]!is[draft]]
<$vars storyTiddler=<<currentTiddler>> tiddlerInfoState=<<qualify "$:/state/popup/tiddler-info">>>
<div data-tiddler-title=<<currentTiddler>> data-tags={{!!tags}} class={{{ [all[shadows+tiddlers]tag[$:/tags/ClassFilters/TiddlerTemplate]!is[draft]] :map:flat[subfilter{!!text}] tc-tiddler-frame tc-tiddler-view-frame [<currentTiddler>is[tiddler]then[tc-tiddler-exists]] [<currentTiddler>is[missing]!is[shadow]then[tc-tiddler-missing]] [<currentTiddler>is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [<currentTiddler>is[shadow]is[tiddler]then[tc-tiddler-overridden-shadow]] [<currentTiddler>is[system]then[tc-tiddler-system]] [{!!class}] [<currentTiddler>tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}} role="article">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!has[draft.of]]" variable="listItem">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!is[draft]]" variable="listItem">
<$transclude tiddler=<<listItem>>/>
</$list>
</div>

View File

@ -1,7 +1,7 @@
title: $:/core/ui/ViewTemplate/body
tags: $:/tags/ViewTemplate
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View/Body]!has[draft.of]]
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View/Body]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View/Body]!is[draft]]
<$reveal tag="div" class="tc-tiddler-body" type="nomatch" stateTitle=<<folded-state>> text="hide" retain="yes" animate="yes">

View File

@ -0,0 +1,2 @@
title: $:/core/config/GlobalImportFilter
text: [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global]!is[draft]]

View File

@ -3,14 +3,26 @@ tags: $:/tags/Macro
\define translink(title,mode:"block")
\whitespace trim
<div style="border:1px solid #ccc; padding: 0.5em; background: black; foreground; white;">
<$list filter="[<__mode__>match[block]]">
<div class="tc-translink">
<div>
<$link to="""$title$""">
<$text text="""$title$"""/>
<h1><$text text="""$title$"""/></h1>
</$link>
<div style="border:1px solid #ccc; padding: 0.5em; background: white; foreground; black;">
<$transclude tiddler="""$title$""" mode="$mode$">
"<$text text="""$title$"""/>" is missing
<$transclude tiddler="""$title$""" mode="block">
<$set name="currentTiddler" value="""$title$"""><$transclude tiddler="$:/language/MissingTiddler/Hint"/></$set>
</$transclude>
</div>
</div>
</$list>
<$list filter="[<__mode__>match[inline]]">
<span class="tc-translink">
<$link to="""$title$""">
<$text text="""$title$"""/>
</$link>
&#32;(<$transclude tiddler="""$title$""" mode="inline">
<$set name="currentTiddler" value="""$title$"""><$transclude tiddler="$:/language/MissingTiddler/Hint"/></$set>
</$transclude>)
</span>
</$list>
\end

View File

@ -5,7 +5,7 @@ title: $:/core/ui/ViewTemplate
$:/state/folded/$(currentTiddler)$
\end
\define cancel-delete-tiddler-actions(message) <$action-sendmessage $message="tm-$message$-tiddler"/>
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!has[draft.of]]
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View]!is[draft]]
<$vars storyTiddler=<<currentTiddler>> tiddlerInfoState=<<qualify "$:/state/popup/tiddler-info">>>
<div data-tiddler-title=<<currentTiddler>> data-tags={{!!tags}} class={{{ tc-tiddler-frame tc-tiddler-view-frame [<currentTiddler>is[tiddler]then[tc-tiddler-exists]] [<currentTiddler>is[missing]!is[shadow]then[tc-tiddler-missing]] [<currentTiddler>is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [<currentTiddler>is[shadow]is[tiddler]then[tc-tiddler-overridden-shadow]] [<currentTiddler>is[system]then[tc-tiddler-system]] [{!!class}] [<currentTiddler>tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}}>
<$set name="state" value={{{ [[$:/state/viewtemplate/visibility/]addsuffix<currentTiddler>] }}}>

View File

@ -5,7 +5,7 @@ type: text/vnd.tiddlywiki
\define tv-wikilink-template() https://tiddlywiki.com/static/$uri_doubleencoded$.html
<$importvariables filter="[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]">
<$importvariables filter={{$:/core/config/GlobalImportFilter}}>
Bienvenue sur <<tw>>, un carnet de notes personnel web et non-linéaire que tout le monde peut utiliser et conserver, sans dépendre d'une quelconque entreprise.

View File

@ -0,0 +1,40 @@
title: Transclude/Macro/Missing
description: Transcluding a missing or blank variable
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$macrocall $name="missingmacro">
Fallback content
</$macrocall>
<$transclude $variable="missingmacro">
Fallback content
</$transclude>
<$macrocall $name="">
Fallback content
</$macrocall>
<$transclude $variable="">
Fallback content
</$transclude>
<$let emptyVariable="">
<$macrocall $name="emptyVariable">
Fallback content
</$macrocall>
<$transclude $variable="emptyVariable">
Fallback content
</$transclude>
</$let>
+
title: ExpectedResult
<p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p>

View File

@ -56,7 +56,7 @@ Tests the checkbox widget thoroughly.
* Test data for checkbox widget tests
*/
const fieldModeTests = [
var fieldModeTests = [
{
testName: "field mode checked",
tiddlers: [{title: "TiddlerOne", text: "Jolly Old World", expand: "yes"}],
@ -95,16 +95,16 @@ Tests the checkbox widget thoroughly.
},
];
const indexModeTests = fieldModeTests.map(data => {
const newData = {...data};
const newName = data.testName.replace('field mode', 'index mode');
const newTiddlers = data.tiddlers.map(tiddler => {
var indexModeTests = fieldModeTests.map(data => {
var newData = {...data};
var newName = data.testName.replace('field mode', 'index mode');
var newTiddlers = data.tiddlers.map(tiddler => {
return {title: tiddler.title, type: "application/x-tiddler-dictionary", text: `one: a\nexpand: ${tiddler.expand}\ntwo: b`}
});
const newWidgetText = data.widgetText.replace("field='expand'", "index='expand'");
const newChange = {};
for (const key of Object.keys(data.expectedChange)) {
const oldChange = data.expectedChange[key];
var newWidgetText = data.widgetText.replace("field='expand'", "index='expand'");
var newChange = {};
for (var key of Object.keys(data.expectedChange)) {
var oldChange = data.expectedChange[key];
if (oldChange.expand) {
newChange[key] = { text: `one: a\nexpand: ${oldChange.expand}\ntwo: b` }
} else {
@ -119,7 +119,26 @@ Tests the checkbox widget thoroughly.
return newData;
});
const listModeTests = [
var listModeTestsForDateFields = [
{
testName: "list mode created date field",
tiddlers: [{title: "Colors", created: "201304152222", modified: "202301022222"}],
widgetText: "<$checkbox tiddler='Colors' listField='created' checked='green' />",
startsOutChecked: false,
finalValue: false,
expectedChange: { "Colors": { created: new Date("2013-04-15T22:22:00Z")}} // created field should *not* be touched by a listField checkbox
},
{
testName: "list mode modified date field",
tiddlers: [{title: "Colors", created: "201304152222", modified: "202301022222"}],
widgetText: "<$checkbox tiddler='Colors' listField='modified' checked='green' />",
startsOutChecked: false,
finalValue: false,
expectedChange: { "Colors": { modified: new Date("2023-01-02T22:22:00Z")}} // modified field should *not* be touched by a listField checkbox
},
]
var listModeTests = [
{
testName: "list mode add",
tiddlers: [{title: "Colors", colors: "orange yellow"}],
@ -235,11 +254,11 @@ Tests the checkbox widget thoroughly.
];
// https://github.com/Jermolene/TiddlyWiki5/issues/6871
const listModeTestsWithListField = (
var listModeTestsWithListField = (
listModeTests
.filter(data => data.widgetText.includes("listField='colors'"))
.map(data => {
const newData = {
var newData = {
...data,
tiddlers: data.tiddlers.map(tiddler => ({...tiddler, list: tiddler.colors, colors: undefined})),
widgetText: data.widgetText.replace("listField='colors'", "listField='list'"),
@ -250,11 +269,11 @@ Tests the checkbox widget thoroughly.
return newData;
})
);
const listModeTestsWithTagsField = (
var listModeTestsWithTagsField = (
listModeTests
.filter(data => data.widgetText.includes("listField='colors'"))
.map(data => {
const newData = {
var newData = {
...data,
tiddlers: data.tiddlers.map(tiddler => ({...tiddler, tags: tiddler.colors, colors: undefined})),
widgetText: data.widgetText.replace("listField='colors'", "listField='tags'"),
@ -266,20 +285,20 @@ Tests the checkbox widget thoroughly.
})
);
const indexListModeTests = listModeTests.map(data => {
const newData = {...data};
const newName = data.testName.replace('list mode', 'index list mode');
const newTiddlers = data.tiddlers.map(tiddler => {
var indexListModeTests = listModeTests.map(data => {
var newData = {...data};
var newName = data.testName.replace('list mode', 'index list mode');
var newTiddlers = data.tiddlers.map(tiddler => {
if (tiddler.hasOwnProperty('colors')) {
return {title: tiddler.title, type: "application/x-tiddler-dictionary", text: `one: a\ncolors: ${tiddler.colors}\ntwo: b`}
} else if (tiddler.hasOwnProperty('someField')) {
return {title: tiddler.title, type: "application/x-tiddler-dictionary", text: `one: a\nsomeField: ${tiddler.someField}\ntwo: b`}
}
});
const newWidgetText = data.widgetText.replace("listField='colors'", "listIndex='colors'").replace(/\$field/g, '$index').replace("listField='someField'", "listIndex='someField'");
const newChange = {};
for (const key of Object.keys(data.expectedChange)) {
const oldChange = data.expectedChange[key];
var newWidgetText = data.widgetText.replace("listField='colors'", "listIndex='colors'").replace(/\$field/g, '$index').replace("listField='someField'", "listIndex='someField'");
var newChange = {};
for (var key of Object.keys(data.expectedChange)) {
var oldChange = data.expectedChange[key];
if (oldChange.colors) {
newChange[key] = { text: `one: a\ncolors: ${oldChange.colors}\ntwo: b` }
} else if (oldChange.someField !== undefined) {
@ -296,7 +315,7 @@ Tests the checkbox widget thoroughly.
return newData;
});
const filterModeTests = [
var filterModeTests = [
{
testName: "filter mode false -> true",
tiddlers: [{title: "Colors", colors: "red orange yellow"}],
@ -482,9 +501,10 @@ Tests the checkbox widget thoroughly.
},
];
const checkboxTestData = fieldModeTests.concat(
var checkboxTestData = fieldModeTests.concat(
indexModeTests,
listModeTests,
listModeTestsForDateFields,
listModeTestsWithListField,
listModeTestsWithTagsField,
indexListModeTests,
@ -494,7 +514,7 @@ Tests the checkbox widget thoroughly.
/*
* Checkbox widget tests using the test data above
*/
for (const data of checkboxTestData) {
for (var data of checkboxTestData) {
it('checkbox widget test: ' + data.testName, function() {
// Setup
@ -505,7 +525,7 @@ Tests the checkbox widget thoroughly.
// Check initial state
const widget = findNodeOfType('checkbox', widgetNode);
var widget = findNodeOfType('checkbox', widgetNode);
// Verify that the widget is or is not checked as expected
expect(widget.getValue()).toBe(data.startsOutChecked);
@ -519,16 +539,16 @@ Tests the checkbox widget thoroughly.
widget.handleChangeEvent(null);
// Check state again: in most tests, checkbox should be inverse of what it was
const finalValue = data.hasOwnProperty('finalValue') ? data.finalValue : !data.startsOutChecked;
var finalValue = data.hasOwnProperty('finalValue') ? data.finalValue : !data.startsOutChecked;
expect(widget.getValue()).toBe(finalValue);
// Check that tiddler(s) has/have gone through expected change(s)
for (const key of Object.keys(data.expectedChange)) {
const tiddler = wiki.getTiddler(key);
const change = data.expectedChange[key];
for (const fieldName of Object.keys(change)) {
const expectedValue = change[fieldName];
const fieldValue = tiddler.fields[fieldName];
for (var key of Object.keys(data.expectedChange)) {
var tiddler = wiki.getTiddler(key);
var change = data.expectedChange[key];
for (var fieldName of Object.keys(change)) {
var expectedValue = change[fieldName];
var fieldValue = tiddler.fields[fieldName];
expect(fieldValue).toEqual(expectedValue);
}
}

View File

@ -45,7 +45,7 @@ Special tags assign special behaviour or appearance to all of the tiddlers to wh
For example:
* $:/tags/Macro causes the macros defined in a tiddler to be available globally
* $:/tags/Global causes the definitions in a tiddler to be available globally
* $:/tags/Stylesheet causes the tiddler to be interpreted as a CSS stylesheet
* $:/tags/SideBar causes the tiddler to be displayed as a sidebar tab

View File

@ -36,7 +36,7 @@ The initial startup actions are useful for customising TiddlyWiki according to e
Note that global macros are not available within initial startup action tiddlers by default. If you need to access them then you'll need to explicitly include them with an [[Pragma: \import]] at the top of the tiddler:
```
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
```
!! Post-Render Startup Actions

View File

@ -77,11 +77,11 @@ In the [[Keyboard Shortcuts Tab|$:/core/ui/ControlPanel/KeyboardShortcuts]] the
> If the tiddler has the tag <<tag $:/tags/KeyboardShortcut>>, the field ''key'' with the [[Keyboard Shortcut Descriptor]] as its value and some actions in its text field, the actions will be triggered when the mechanism detects the configured key-combination
<br>
<$macrocall $name=".tip" _="""''Macros'' defined ''outside'' a global keyboard-shortcut (through a tiddler tagged `$:/tags/Macro`) need to be ''imported'' in order to be accessible.
<$macrocall $name=".tip" _="""''Macros'' defined ''outside'' a global keyboard-shortcut (through a tiddler tagged `$:/tags/Global`) need to be ''imported'' in order to be accessible.
The [[import pragma|Pragma]] can be used for that"""/>
<pre>
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
</pre>
If the tiddler that contains the macro definition is known and - for example - titled `my-macro-tiddler`

View File

@ -1,22 +1,18 @@
created: 20160810122928198
modified: 20160810122934291
modified: 20230505104214168
tags: [[Editor toolbar]]
title: Using Excise
type: text/vnd.tiddlywiki
! Excise text
From the EditorToolbar you can export selected text to a new tiddler and insert a [[link|Linking in WikiText]] [[Transclusion]] or [[macro|Macros]] in its place. Click ''Excise text'' (<<.icon $:/core/images/excise>>), input name of the new tiddler, and choose excise method.
!! How to excise text
# Highlight the relevant piece of text
#Click ''Excise text'' (<<.icon $:/core/images/excise>>)
# Click ''Excise text'' (<<.icon $:/core/images/excise>>)
# Give the new tiddler a title.
# Chosse if the new tiddler will be tagged with the title of the current tiddler''*''.
# Choose replacing method. [[link|Linking in WikiText]] [[Transclusion]] or [[macro|Macros]].
# Chosse if the new tiddler will be tagged with the title of the current tiddler (see note below).
# Choose replacing method: [[link|Linking in WikiText]], [[transclusion|Transclusion]], or [[macro|Macros]].
# Click the ''{{$:/language/Buttons/Excise/Caption/Excise}}'' button
''*NOTE:'' If you choose tic the option to `Tag new tiddler with the title of this tiddler`. The tag will be the'' draft title''. If you create a new tiddler (or clone an existing one), the draft title and the tag, will be `New Tiddler`. __You have to save the tiddler and re-edit it to get the new title as tag.__
<<.strong Note!>> If you choose the option to `Tag new tiddler with the title of this tiddler`, the new tiddler will be tagged with the name of the current tiddler before it has been edited. If you have changed the title of the current tiddler, save it first and edit it again to perform excision with this option.

View File

@ -0,0 +1,21 @@
created: 20230505090333510
modified: 20230505090333510
tags: Macros [[Core Macros]]
title: translink Macro
type: text/vnd.tiddlywiki
caption: translink
The <<.def translink>> [[macro|Macros]] returns a frame with the title and [[transcluded|Transclusion]] text of a chosen tiddler. The title links to the transcluded tiddler.
If the chosen tiddler is missing, an appropriate message will be shown instead of the transcluded text.
This is the default macro used when [[excising|Using Excise]] text and replacing it with a macro.
!! Parameters
; title
: The title of the tiddler to be transcluded
; mode
: The mode of the [[transclude widget|TranscludeWidget]] used inside the macro, defaults to `block`
<<.macro-examples "translink">>

View File

@ -0,0 +1,9 @@
created: 20230505092952569
modified: 20230505092952569
tags: [[translink Macro]] [[Macro Examples]]
title: translink Macro (Examples)
type: text/vnd.tiddlywiki
<$macrocall $name=".example" n="1" eg="""<<translink "Philosophy of Tiddlers">>"""/>
<$macrocall $name=".example" n="2" eg="""<<translink "Philosophy of Tiddlers" inline>>"""/>
<$macrocall $name=".example" n="3" eg="""<<translink Foo>>"""/>

View File

@ -13,7 +13,7 @@ Excises the currently selected text into a new tiddler and replaces it with a li
|!Name |!Description |
|title |Title of the new tiddler the selected content is excised to|
|type |Type of the replacement to be inserted: Can be one of <<.value "transclude">>, <<.value "link">> or <<.value "macro">>|
|macro |In case //type=<<.value "macro">>//, specifies the name of the macro to be inserted. The title of the new tiddler is provided as the first parameter to the macro. Defaults to the ''translink'' macro|
|macro |In case //type=<<.value "macro">>//, specifies the name of the macro to be inserted. The title of the new tiddler is provided as the first parameter to the macro. Defaults to the [[translink macro|translink Macro]]|
|tagnew |If '<<.value "yes">>', will tag the new tiddler with the title of the tiddler currently being edited |
</div>

View File

@ -13,5 +13,5 @@ The ''\import'' [[pragma|Pragmas]] is used to import definitions from other tidd
For example:
```
\import [all[shadows+tiddlers]tag[$:/tags/Macro]]
\import [all[shadows+tiddlers]tag[$:/tags/Global]]
```

View File

@ -34,10 +34,10 @@ Procedures are implemented as a special kind of [[variable|Variables]] and so in
The [[Pragma: \import]] or <<.wlink ImportVariablesWidget>> widget can be used to copy procedure definitions from another tiddler.
!! `$:/tags/Macro` Tag
!! `$:/tags/Global` Tag
Global procedures can be defined using the [[SystemTag: $:/tags/Macro]].
Global procedures can be defined using the [[SystemTag: $:/tags/Global]].
The tag [[SystemTag: $:/tags/Macro/View]] is used to define procedures that should only be available within the main view template and the preview panel.
The tag [[SystemTag: $:/tags/Global/View]] is used to define procedures that should only be available within the main view template and the preview panel.
The tag [[SystemTag: $:/tags/Macro/View/Body]] is used to define procedures that should only be available within the main view template body and the preview panel.
The tag [[SystemTag: $:/tags/Global/View/Body]] is used to define procedures that should only be available within the main view template body and the preview panel.

View File

@ -4,7 +4,7 @@ title: ReadMe
type: text/vnd.tiddlywiki
\define tv-wikilink-template() https://tiddlywiki.com/static/$uri_doubleencoded$.html
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
Welcome to TiddlyWiki, a non-linear personal web notebook that anyone can use and keep forever, independently of any corporation.

View File

@ -4,7 +4,7 @@ tags: $:/tags/RawMarkupWikified/TopBody
title: $:/SplashScreen
type: text/vnd.tiddlywiki
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
\procedure show-icon(title)
<$wikify name="icon" text={{{ [<title>addprefix[{{]addsuffix[}}]] }}} output="html">

View File

@ -0,0 +1,9 @@
caption: $:/tags/Global
created: 20230419103154329
description: marks global definitions
modified: 20230419103154329
tags: SystemTags
title: SystemTag: $:/tags/Global
type: text/vnd.tiddlywiki
The [[system tag|SystemTags]] `$:/tags/Global` marks global definitions that are made available everywhere.

View File

@ -0,0 +1,9 @@
caption: $:/tags/Global/View
created: 20230419103154329
description: marks global definitions only active in View template
modified: 20230419103154329
tags: SystemTags
title: SystemTag: $:/tags/Global/View
type: text/vnd.tiddlywiki
The [[system tag|SystemTags]] `$:/tags/Global/View` marks definitions that are only made available within the main view templates and the preview panel.

View File

@ -0,0 +1,9 @@
caption: $:/tags/Global/View/Body
created: 20230419103154329
description: marks global definitions only active in View template body
modified: 20230419103154329
tags: SystemTags
title: SystemTag: $:/tags/Global/View/Body
type: text/vnd.tiddlywiki
The [[system tag|SystemTags]] `$:/tags/Global/View/Body` marks definitions that are only made available within the main view template bodies and the preview panel.

View File

@ -6,4 +6,4 @@ tags: SystemTags
title: SystemTag: $:/tags/Macro
type: text/vnd.tiddlywiki
The [[system tag|SystemTags]] `$:/tags/Macro` marks global macros
The [[system tag|SystemTags]] `$:/tags/Macro` marks global macros. It is now deprecated in favour of [[SystemTag $:/tags/Global]].

View File

@ -6,4 +6,4 @@ tags: SystemTags
title: SystemTag: $:/tags/Macro/View
type: text/vnd.tiddlywiki
The [[system tag|SystemTags]] `$:/tags/Macro/View` marks macros that are only made available within the main view templates and the preview panel.
The [[system tag|SystemTags]] `$:/tags/Macro/View` marks macros that are only made available within the main view templates and the preview panel. It is now deprecated in favour of [[SystemTag $:/tags/Global/View]].

View File

@ -6,4 +6,4 @@ tags: SystemTags
title: SystemTag: $:/tags/Macro/View/Body
type: text/vnd.tiddlywiki
The [[system tag|SystemTags]] `$:/tags/Macro/View/Body` marks macros that are only made available within the main view template bodies and the preview panel.
The [[system tag|SystemTags]] `$:/tags/Macro/View/Body` marks macros that are only made available within the main view template bodies and the preview panel. It is now deprecated in favour of [[SystemTag $:/tags/Global/View/Body]].

View File

@ -10,9 +10,9 @@ The first example shows how <<.def thisTiddler>> works whithin transcluded templ
The second example shows <<.def thisTiddler>> in the body of tiddler and inside a macro.
<$macrocall $name=".example" n="1" eg="""<$text text=<<thisTiddler>>/>"""/>
<$macrocall $name=".example" n="2" eg="""<$text text=<<thisTiddler>>/>"""/>
<$macrocall $name=".example" n="2" eg="""\define example() <$text text=<<thisTiddler>>/>
<$macrocall $name=".example" n="3" eg="""\define example() <$text text=<<thisTiddler>>/>
<<example>>
"""/>

View File

@ -1,4 +1,4 @@
caption: currentTiddler
caption: thisTiddler
created: 20230304122810114
modified: 20230505200086200
tags: Variables [[Core Variables]]

View File

@ -1,6 +1,6 @@
caption: fill
created: 20220909111836951
modified: 20230419103154328
modified: 20230511123456782
tags: Widgets
title: FillWidget
type: text/vnd.tiddlywiki
@ -9,7 +9,7 @@ type: text/vnd.tiddlywiki
<<.from-version "5.3.0">> The <<.wlink FillWidget>> widget is used within a <<.wlink TranscludeWidget>> widget to specify the content that should be copied to the named "slot". Slots are defined by the <<.wlink SlotWidget>> widget within the transcluded content.
See the <<.wlink TranscludeWidget>> widget for details.
See the <<.wlink TranscludeWidget>> widget for details and an example. More examples can be found in the <<.wlink SlotWidget>> widget documentation.
! Attributes

View File

@ -1,6 +1,6 @@
caption: slot
created: 20220909111836951
modified: 20230419103154329
modified: 20230511123922283
tags: Widgets
title: SlotWidget
type: text/vnd.tiddlywiki
@ -17,3 +17,59 @@ The content of the <<.wlink SlotWidget>> widget is used as a fallback for the sl
|!Attribute |!Description |
|$name |The name of the slot being defined |
|$depth |Optional number indicating how deep the <<.wlink SlotWidget>> widget is compared to the matching <<.wlink FillWidget>> widget as measured by the number of nested transclude widgets (defaults to 1). Transclude widgets whose <<.attr $fillignore>> attribute is set to ''yes'' are ignored, and do not affect the depth count |
! Examples
!! Quoted content
When content contains quotes, passing it through attributes and parameters can be challenging. However, passing the content using the <<.wlink FillWidget>> widget content eliminates the need to wrap it in quotes, making the process easier.
<$let bold_slot='<b>
<$slot $name="body"/>
</b>
'>
If a variable named <<.var bold_slot>> contains the following <<.wlink SlotWidget>> definition:
<$codeblock code={{{[[bold_slot]getvariable[]]}}}/>
then the slot can be filled using this variable transclusion:
<<wikitext-example-without-html src:'<$transclude $variable=bold_slot>
<$fill $name=body>
"""
some text
using [[Hard Linebreaks in WikiText]]
syntax
"""
</$fill>
</$transclude>
'>>
</$let>
!! Depth
<$let table_slot="|!depth|!slot1|!slot2|
|1|<$slot $name=slot1/>|<$slot $name=slot2/>|
|2|<$slot $name=slot1 $depth=2>missing</$slot>|<$slot $name=slot2 $depth=2>missing</$slot>|
"
table_fill="""<$transclude $variable=table_slot $mode=block>
<$fill $name=slot1>outer1</$fill>
<$fill $name=slot2>outer2
<$transclude $variable=table_slot $mode=block>
<$fill $name=slot1>inner1</$fill>
<$fill $name=slot2>inner2</$fill>
</$transclude>
</$fill>
</$transclude>
""">
If a variable named <<.var table_slot>> contains the following <<.wlink SlotWidget>> definition:
<$codeblock code={{{[[table_slot]getvariable[]]}}}/>
then the slot values can be filled at different transclusion depths:
<$transclude $variable="wikitext-example-without-html" src=<<table_fill>>/>
The <<.var slot1>> slot is filled at both depths with a simple string (outer1 and outer2). For <<.var slot2>>, the outer instance is a simple string but the inner instance recursively transcludes the same <<.var table_slot>> variable again. The recursion ends at the third transclusion call since both "inner" slots are filled with simple strings.

View File

@ -1,6 +1,6 @@
caption: transclude
created: 20130824142500000
modified: 20230419103154329
modified: 20230511022612458
tags: Widgets
title: TranscludeWidget
type: text/vnd.tiddlywiki
@ -51,6 +51,7 @@ Modern mode is recommended for use in new applications.
|$type | |Optional ContentType used when transcluding variables, indexes or fields other than the ''text'' field|
|$output |- |ContentType for the output rendering (defaults to `text/html`, can also be `text/plain` or `text/raw`) |
|$recursionMarker |recursionMarker |Set to ''no'' to prevent creation of [[Legacy Transclusion Recursion Marker]] (defaults to ''yes'') |
|$fillignore |- |Set to ''yes'' to make this transclusion invisible to the <<.attr $depth>> attribute of the <<.wlink SlotWidget>> widget (defaults to ''no'') |
|//{attributes not starting with $}// | |Any other attributes that do not start with a dollar are used as parameters to the transclusion |
|//{other attributes starting with $}// | |Other attributes starting with a single dollar sign are reserved for future use |
|//{attributes starting with $$}// | |Attributes starting with two dollar signs are used as parameters to the transclusion, but with the name changed to use a single dollar sign |
@ -145,7 +146,7 @@ The output will be equivalent to:
</li>
</ol>
```
See <<.wlink SlotWidget>> for more examples.
! Missing Transclusion Targets

View File

@ -529,3 +529,5 @@ HuanC Fu, @hffqyd, 2023/03/03
Michelle Saad, @michsa, 2023-03-08
Yukai Chou, @muzimuzhi, 2023-04-07
Carmine Guida, @carmineguida, 2023-05-17

View File

@ -22,7 +22,7 @@ title: $:/plugins/tiddlywiki/blog/templates/html-page/page
<body class="tc-body">
`{{$:/StaticBanner||$:/core/templates/html-tiddler}}`
<section class="tc-story-river">
`<$importvariables filter="[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]">
`<$importvariables filter={{$:/core/config/GlobalImportFilter}}>
<$view tiddler="$:/plugins/tiddlywiki/blog/templates/tiddler" format="htmlwikified"/>
</$importvariables>`
</section>

View File

@ -22,7 +22,7 @@ title: $:/plugins/tiddlywiki/blog/templates/html-page/post
<body class="tc-body">
`{{$:/StaticBanner||$:/core/templates/html-tiddler}}`
<section class="tc-story-river">
`<$importvariables filter="[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]">
`<$importvariables filter={{$:/core/config/GlobalImportFilter}}>
<$view tiddler="$:/plugins/tiddlywiki/blog/templates/tiddler" format="htmlwikified"/>
<$view tiddler="$:/plugins/tiddlywiki/blog/templates/menu" format="htmlwikified"/>
</$importvariables>`

View File

@ -1,6 +1,6 @@
title: $:/plugins/tiddlywiki/tiddlyweb/save/offline
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\import [subfilter{$:/core/config/GlobalImportFilter}]
\define saveTiddlerFilter()
[is[tiddler]] -[[$:/boot/boot.css]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/tiddlywiki/tiddlyweb]] -[prefix[$:/temp/]] +[sort[title]] $(publishFilter)$
\end

View File

@ -0,0 +1,3 @@
title: $:/language/Import/
Upgrader/Plugins/Suppressed/Version: Your plugin will be upgraded from <<incoming>> to <<existing>>.

View File

@ -3118,6 +3118,30 @@ select {
background: <<colour select-tag-background>>;
}
/*
** Translink macro
*/
.tc-translink {
background-color: <<colour pre-background>>;
border: 1px solid <<colour pre-border>>;
padding: 0 3px;
border-radius: 3px;
}
div.tc-translink > div {
margin: 1em;
}
div.tc-translink > div > a:first-child > h1 {
font-size: 1.2em;
font-weight: bold;
}
span.tc-translink > a:first-child {
font-weight: bold;
}
/*
** Classes for displaying globals
*/