Compare commits

...

17 Commits

Author SHA1 Message Date
Simon Huber 1bd4e5efc8
Merge e98ca4a180 into a081e58273 2024-04-25 23:45:33 +08:00
Matt Lauber a081e58273
HTTP Client: Return success calls for all 2XX response codes (#8150)
APIs especially use 2XX response codes outside of 200, 201, 204 for responding to responses.  Treat all "Successful" response codes (i.e. anything between 200-299) as successes, and pass the responseText.
2024-04-16 16:24:53 +01:00
Joshua Fontany 5f74f4c2fa
Fix bug 7878: Save command (#8140)
* first pass at fixing bug 7878, needs testing

* clarify default behaviour in comment

* fix property typo, tested and works as intended

* remove debugger
2024-04-11 21:54:46 +01:00
Joshua Fontany 9167b190d2
Fix bug 8138: server cache-control (#8141)
* cache-control no-store by default

* clarify comment spec reference

* comment typo

* fix else formatting

* Update server.js

allow route definitions to set their own cache-control
2024-04-11 19:23:32 +01:00
Cameron Fischer df8731f760
Made library boot module requirements consistent (#8083) 2024-04-10 10:52:22 +01:00
Rob Hoelz e9aa3c6c93
Add $timestamp argument for <$action-deletefield> widget (#8115)
* Start on some tests for <$action-deletefield />

* Only update modified field if we actually delete a field

…in the <$action-deletefield /> widget.

Fixes a bug where <$action-deletefield foo /> would update the modified field
if the "foo" field wasn't present on a tiddler.

* action-deletefield: Test when modified does and doesn't exist

* Add $timestamp argument to action-deletefield

To make it more consistent with other tiddler-manipulating action widgets

* Add docs for action-deletefield $timestamp
2024-04-04 16:03:15 +01:00
Jeremy Ruston 105e8195d5 Merge branch 'tiddlywiki-com' 2024-04-03 21:51:13 +01:00
Simon Huber eeb4e7a7f7
Add a "Refresh Browser" keyboard shortcut (#8121)
* Create a `refresh` keyboard shortcut

This creates a `refresh` keyboard shortcut that refreshes the page.
In TiddlyDesktop <kbd>ctrl-R</kbd> doesn't work

* Update refresh.tid

* Update shortcuts-not-mac.multids

* Update shortcuts-mac.multids

* Update ShortcutInfo.multids
2024-04-03 09:58:56 +01:00
Simon Huber 7ce85a2ddb
Update reset.tid to use modern-normalize 2.0.0 (#8120)
This PR updates the vanilla/reset stylesheet to use the newer `modern-normalize 2.0.0`
2024-04-02 17:35:10 +01:00
Crystal Person 804f227815
Signing CLA (#8126) 2024-03-31 17:08:09 +01:00
Mario Pietsch b595651fe1
Fix hide-show button code needs to be transcluded mode=block (#8082) 2024-03-28 21:50:22 +00:00
Mario Pietsch 9cd6affcae
Minor changes to Widgets tiddler (#8107) 2024-03-28 19:29:57 +00:00
Simon Huber e98ca4a180
Update dragndrop.js - remove unnecessary variable 2024-03-11 08:19:45 +01:00
Simon Huber ba8304e0d0
Don't remove the tc-draggable class if there's a dragHandleSelector 2024-03-10 07:29:48 +01:00
Simon Huber e1f05f82cf
Forgot to add var self = this; 2024-03-09 17:38:10 +01:00
Simon Huber cde2b03534
Update dragndrop.js to store the handler in variables
This stores the EventHandlers in variables that are then passed to the widget that makes the element draggable.
In the widget we can then remove the EventListeners if needed
2024-03-09 17:32:56 +01:00
Simon Huber b596a4bd12
Update draggable.js no to refresh when enable attr changes
This updates the draggable widget so that if the enable attr changes it just adds/removes the tc-draggable class, the draggable attr and the necessary EventListeners
2024-03-09 17:27:49 +01:00
23 changed files with 440 additions and 233 deletions

View File

@ -43,7 +43,9 @@ Saves individual tiddlers in their raw text or binary format to the specified fi
directory: path.resolve(self.commander.outputPath),
pathFilters: [filenameFilter],
wiki: wiki,
fileInfo: {}
fileInfo: {
overwrite: true
}
});
if(self.commander.verbose) {
console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\"");

View File

@ -140,6 +140,11 @@ function sendResponse(request,response,statusCode,headers,data,encoding) {
return;
}
}
} else {
// RFC 7231, 6.1. Overview of Status Codes:
// Browser clients may cache 200, 203, 204, 206, 300, 301,
// 404, 405, 410, 414, and 501 unless given explicit cache controls
headers["Cache-Control"] = headers["Cache-Control"] || "no-store";
}
/*
If the gzip=yes is set, check if the user agent permits compression. If so,

View File

@ -30,122 +30,130 @@ exports.makeDraggable = function(options) {
if(!options.selector && ((domNode.tagName || "").toLowerCase() !== "a")) {
domNode.setAttribute("draggable","true");
}
// Add event handlers
$tw.utils.addEventListeners(domNode,[
{name: "dragstart", handlerFunction: function(event) {
if(event.dataTransfer === undefined) {
return false;
var dragStartHandlerFunction = function(event) {
if(event.dataTransfer === undefined) {
return false;
}
// Collect the tiddlers being dragged
var dragTiddler = options.dragTiddlerFn && options.dragTiddlerFn(),
dragFilter = options.dragFilterFn && options.dragFilterFn(),
titles = dragTiddler ? [dragTiddler] : [],
startActions = options.startActions,
variables,
domNodeRect;
if(dragFilter) {
titles.push.apply(titles,options.widget.wiki.filterTiddlers(dragFilter,options.widget));
}
var titleString = $tw.utils.stringifyList(titles);
// Check that we've something to drag
if(titles.length > 0 && (options.selector && $tw.utils.domMatchesSelector(event.target,options.selector) || event.target === domNode)) {
// Mark the drag in progress
$tw.dragInProgress = domNode;
// Set the dragging class on the element being dragged
$tw.utils.addClass(domNode,"tc-dragging");
// Invoke drag-start actions if given
if(startActions !== undefined) {
// Collect our variables
variables = $tw.utils.collectDOMVariables(domNode,null,event);
variables.modifier = $tw.keyboardManager.getEventModifierKeyDescriptor(event);
variables["actionTiddler"] = titleString;
options.widget.invokeActionString(startActions,options.widget,event,variables);
}
// Create the drag image elements
dragImage = options.widget.document.createElement("div");
dragImage.className = "tc-tiddler-dragger";
var inner = options.widget.document.createElement("div");
inner.className = "tc-tiddler-dragger-inner";
inner.appendChild(options.widget.document.createTextNode(
titles.length === 1 ?
titles[0] :
titles.length + " tiddlers"
));
dragImage.appendChild(inner);
options.widget.document.body.appendChild(dragImage);
// Set the data transfer properties
var dataTransfer = event.dataTransfer;
// Set up the image
dataTransfer.effectAllowed = "all";
if(dataTransfer.setDragImage) {
if(dragImageType === "pill") {
dataTransfer.setDragImage(dragImage.firstChild,-16,-16);
} else if(dragImageType === "blank") {
dragImage.removeChild(dragImage.firstChild);
dataTransfer.setDragImage(dragImage,0,0);
} else {
var r = domNode.getBoundingClientRect();
dataTransfer.setDragImage(domNode,event.clientX-r.left,event.clientY-r.top);
}
}
// Set up the data transfer
if(dataTransfer.clearData) {
dataTransfer.clearData();
}
var jsonData = [];
if(titles.length > 1) {
titles.forEach(function(title) {
jsonData.push(options.widget.wiki.getTiddlerAsJson(title));
});
jsonData = "[" + jsonData.join(",") + "]";
} else {
jsonData = options.widget.wiki.getTiddlerAsJson(titles[0]);
}
// IE doesn't like these content types
if(!$tw.browser.isIE) {
dataTransfer.setData("text/vnd.tiddler",jsonData);
dataTransfer.setData("text/plain",titleString);
dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
}
// If browser is Chrome-like and has a touch-input device do NOT .setData
if(!($tw.browser.isMobileChrome)) {
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
}
dataTransfer.setData("Text",titleString);
event.stopPropagation();
}
return false;
};
var dragEndHandlerFunction = function(event) {
if((options.selector && $tw.utils.domMatchesSelector(event.target,options.selector)) || event.target === domNode) {
// Collect the tiddlers being dragged
var dragTiddler = options.dragTiddlerFn && options.dragTiddlerFn(),
dragFilter = options.dragFilterFn && options.dragFilterFn(),
titles = dragTiddler ? [dragTiddler] : [],
startActions = options.startActions,
variables,
domNodeRect;
endActions = options.endActions,
variables;
if(dragFilter) {
titles.push.apply(titles,options.widget.wiki.filterTiddlers(dragFilter,options.widget));
}
var titleString = $tw.utils.stringifyList(titles);
// Check that we've something to drag
if(titles.length > 0 && (options.selector && $tw.utils.domMatchesSelector(event.target,options.selector) || event.target === domNode)) {
// Mark the drag in progress
$tw.dragInProgress = domNode;
// Set the dragging class on the element being dragged
$tw.utils.addClass(domNode,"tc-dragging");
// Invoke drag-start actions if given
if(startActions !== undefined) {
// Collect our variables
variables = $tw.utils.collectDOMVariables(domNode,null,event);
variables.modifier = $tw.keyboardManager.getEventModifierKeyDescriptor(event);
variables["actionTiddler"] = titleString;
options.widget.invokeActionString(startActions,options.widget,event,variables);
}
// Create the drag image elements
dragImage = options.widget.document.createElement("div");
dragImage.className = "tc-tiddler-dragger";
var inner = options.widget.document.createElement("div");
inner.className = "tc-tiddler-dragger-inner";
inner.appendChild(options.widget.document.createTextNode(
titles.length === 1 ?
titles[0] :
titles.length + " tiddlers"
));
dragImage.appendChild(inner);
options.widget.document.body.appendChild(dragImage);
// Set the data transfer properties
var dataTransfer = event.dataTransfer;
// Set up the image
dataTransfer.effectAllowed = "all";
if(dataTransfer.setDragImage) {
if(dragImageType === "pill") {
dataTransfer.setDragImage(dragImage.firstChild,-16,-16);
} else if(dragImageType === "blank") {
dragImage.removeChild(dragImage.firstChild);
dataTransfer.setDragImage(dragImage,0,0);
} else {
var r = domNode.getBoundingClientRect();
dataTransfer.setDragImage(domNode,event.clientX-r.left,event.clientY-r.top);
}
}
// Set up the data transfer
if(dataTransfer.clearData) {
dataTransfer.clearData();
}
var jsonData = [];
if(titles.length > 1) {
titles.forEach(function(title) {
jsonData.push(options.widget.wiki.getTiddlerAsJson(title));
});
jsonData = "[" + jsonData.join(",") + "]";
} else {
jsonData = options.widget.wiki.getTiddlerAsJson(titles[0]);
}
// IE doesn't like these content types
if(!$tw.browser.isIE) {
dataTransfer.setData("text/vnd.tiddler",jsonData);
dataTransfer.setData("text/plain",titleString);
dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
}
// If browser is Chrome-like and has a touch-input device do NOT .setData
if(!($tw.browser.isMobileChrome)) {
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
}
dataTransfer.setData("Text",titleString);
event.stopPropagation();
$tw.dragInProgress = null;
// Invoke drag-end actions if given
if(endActions !== undefined) {
variables = $tw.utils.collectDOMVariables(domNode,null,event);
variables.modifier = $tw.keyboardManager.getEventModifierKeyDescriptor(event);
variables["actionTiddler"] = titleString;
options.widget.invokeActionString(endActions,options.widget,event,variables);
}
return false;
}},
{name: "dragend", handlerFunction: function(event) {
if((options.selector && $tw.utils.domMatchesSelector(event.target,options.selector)) || event.target === domNode) {
// Collect the tiddlers being dragged
var dragTiddler = options.dragTiddlerFn && options.dragTiddlerFn(),
dragFilter = options.dragFilterFn && options.dragFilterFn(),
titles = dragTiddler ? [dragTiddler] : [],
endActions = options.endActions,
variables;
if(dragFilter) {
titles.push.apply(titles,options.widget.wiki.filterTiddlers(dragFilter,options.widget));
}
var titleString = $tw.utils.stringifyList(titles);
$tw.dragInProgress = null;
// Invoke drag-end actions if given
if(endActions !== undefined) {
variables = $tw.utils.collectDOMVariables(domNode,null,event);
variables.modifier = $tw.keyboardManager.getEventModifierKeyDescriptor(event);
variables["actionTiddler"] = titleString;
options.widget.invokeActionString(endActions,options.widget,event,variables);
}
// Remove the dragging class on the element being dragged
$tw.utils.removeClass(domNode,"tc-dragging");
// Delete the drag image element
if(dragImage) {
dragImage.parentNode.removeChild(dragImage);
dragImage = null;
}
// Remove the dragging class on the element being dragged
$tw.utils.removeClass(domNode,"tc-dragging");
// Delete the drag image element
if(dragImage) {
dragImage.parentNode.removeChild(dragImage);
dragImage = null;
}
return false;
}}
}
return false;
};
// Add the EventListener references to the widget
options.widget.dragStartReference = dragStartHandlerFunction;
options.widget.dragEndReference = dragEndHandlerFunction;
// Add event handlers
$tw.utils.addEventListeners(domNode,[
{name: "dragstart", handlerFunction: dragStartHandlerFunction},
{name: "dragend", handlerFunction: dragEndHandlerFunction}
]);
};

View File

@ -283,7 +283,7 @@ exports.httpRequest = function(options) {
// Set up the state change handler
request.onreadystatechange = function() {
if(this.readyState === 4) {
if(this.status === 200 || this.status === 201 || this.status === 204) {
if(this.status >= 200 && this.status < 300) {
// Success!
options.callback(null,this[returnProp],this);
return;

View File

@ -316,11 +316,13 @@ Options include:
pathFilters: optional array of filters to be used to generate the base path
wiki: optional wiki for evaluating the pathFilters
fileInfo: an existing fileInfo object to check against
fileInfo.overwrite: if true, turns off filename clash numbers (defaults to false)
*/
exports.generateTiddlerFilepath = function(title,options) {
var directory = options.directory || "",
extension = options.extension || "",
originalpath = (options.fileInfo && options.fileInfo.originalpath) ? options.fileInfo.originalpath : "",
overwrite = options.fileInfo && options.fileInfo.overwrite || false,
filepath;
// Check if any of the pathFilters applies
if(options.pathFilters && options.wiki) {
@ -381,19 +383,20 @@ exports.generateTiddlerFilepath = function(title,options) {
filepath += char.charCodeAt(0).toString();
});
}
// Add a uniquifier if the file already exists
var fullPath, oldPath = (options.fileInfo) ? options.fileInfo.filepath : undefined,
// Add a uniquifier if the file already exists (default)
var fullPath = path.resolve(directory, filepath + extension);
if (!overwrite) {
var oldPath = (options.fileInfo) ? options.fileInfo.filepath : undefined,
count = 0;
do {
fullPath = path.resolve(directory,filepath + (count ? "_" + count : "") + extension);
if(oldPath && oldPath == fullPath) {
break;
}
count++;
} while(fs.existsSync(fullPath));
do {
fullPath = path.resolve(directory,filepath + (count ? "_" + count : "") + extension);
if(oldPath && oldPath == fullPath) break;
count++;
} while(fs.existsSync(fullPath));
}
// If the last write failed with an error, or if path does not start with:
// the resolved options.directory, the resolved wikiPath directory, the wikiTiddlersPath directory,
// or the 'originalpath' directory, then $tw.utils.encodeURIComponentExtended() and resolve to tiddler directory.
// or the 'originalpath' directory, then $tw.utils.encodeURIComponentExtended() and resolve to options.directory.
var writePath = $tw.hooks.invokeHook("th-make-tiddler-path",fullPath,fullPath),
encode = (options.fileInfo || {writeError: false}).writeError == true;
if(!encode) {

View File

@ -37,6 +37,7 @@ Compute the internal state of the widget
DeleteFieldWidget.prototype.execute = function() {
this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
this.actionField = this.getAttribute("$field",null);
this.actionTimestamp = this.getAttribute("$timestamp","yes") === "yes";
};
/*
@ -69,11 +70,15 @@ DeleteFieldWidget.prototype.invokeAction = function(triggeringWidget,event) {
$tw.utils.each(this.attributes,function(attribute,name) {
if(name.charAt(0) !== "$" && name !== "title") {
removeFields[name] = undefined;
hasChanged = true;
if(name in tiddler.fields) {
hasChanged = true;
}
}
});
if(hasChanged) {
this.wiki.addTiddler(new $tw.Tiddler(this.wiki.getCreationFields(),tiddler,removeFields,this.wiki.getModificationFields()));
var creationFields = this.actionTimestamp ? this.wiki.getCreationFields() : {};
var modificationFields = this.actionTimestamp ? this.wiki.getModificationFields() : {};
this.wiki.addTiddler(new $tw.Tiddler(creationFields,tiddler,removeFields,modificationFields));
}
}
return true; // Action was invoked

View File

@ -27,8 +27,7 @@ DraggableWidget.prototype = new Widget();
Render this widget into the DOM
*/
DraggableWidget.prototype.render = function(parent,nextSibling) {
var self = this,
tag,
var tag,
domNode,
classes = [];
// Save the parent dom node
@ -60,19 +59,8 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
// Insert the node into the DOM and render any children
parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null);
// Add event handlers
if(this.dragEnable) {
$tw.utils.makeDraggable({
domNode: domNode,
dragTiddlerFn: function() {return self.getAttribute("tiddler");},
dragFilterFn: function() {return self.getAttribute("filter");},
startActions: self.startActions,
endActions: self.endActions,
dragImageType: self.dragImageType,
widget: this,
selector: self.dragHandleSelector
});
}
// Make the DOM node draggable if needed
this.makeDraggable(domNode);
this.domNodes.push(domNode);
};
@ -92,6 +80,30 @@ DraggableWidget.prototype.execute = function() {
this.makeChildWidgets();
};
/*
Make a DOM node draggable or remove the draggable attr and the EventListeners
*/
DraggableWidget.prototype.makeDraggable = function(domNode) {
var self = this;
if(this.dragEnable) {
// Add event handlers
$tw.utils.makeDraggable({
domNode: domNode,
dragTiddlerFn: function() {return self.getAttribute("tiddler");},
dragFilterFn: function() {return self.getAttribute("filter");},
startActions: self.startActions,
endActions: self.endActions,
dragImageType: self.dragImageType,
widget: this,
selector: self.dragHandleSelector
});
} else if(this.dragStartReference && this.dragEndReference) {
domNode.removeAttribute("draggable");
domNode.removeEventListener("dragstart",this.dragStartReference,false);
domNode.removeEventListener("dragend",this.dragEndReference,false);
}
};
DraggableWidget.prototype.updateDomNodeClasses = function() {
var domNodeClasses = this.domNodes[0].className.split(" "),
@ -114,10 +126,19 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
DraggableWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.tag || changedAttributes.selector || changedAttributes.dragimagetype || changedAttributes.enable || changedAttributes.startactions || changedAttributes.endactions) {
if(changedAttributes.tag || changedAttributes.selector || changedAttributes.dragimagetype || changedAttributes.startactions || changedAttributes.endactions) {
this.refreshSelf();
return true;
} else {
if(changedAttributes.enable) {
this.dragEnable = this.getAttribute("enable","yes") === "yes";
this.makeDraggable(this.domNodes[0]);
if(!this.dragHandleSelector && this.dragEnable && !this.domNodes[0].classList.contains("tc-draggable")) {
this.domNodes[0].classList.add("tc-draggable");
} else if(!this.dragHandleSelector && !this.dragEnable && this.domNodes[0].classList.contains("tc-draggable")) {
this.domNodes[0].classList.remove("tc-draggable");
}
}
if(changedAttributes["class"]) {
this.updateDomNodeClasses();
}

View File

@ -3,7 +3,7 @@ title: $:/core/save/all-external-js
\whitespace trim
\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)$
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/core]] -[[$:/boot/boot.css]] -[is[system]type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$
\end
<!-- Important: core library is provided by serving URI encoded $:/core/templates/tiddlywiki5.js -->

View File

@ -3,7 +3,7 @@ title: $:/core/save/offline-external-js
\whitespace trim
\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)$
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/core]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/tiddlywiki/tiddlyweb]] -[[$:/boot/boot.css]] -[is[system]type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$
\end
\define defaultCoreURL() tiddlywikicore-$(version)$.js
<$let coreURL={{{ [[coreURL]is[variable]then<coreURL>else<defaultCoreURL>] }}}>

View File

@ -2,6 +2,6 @@ title: $:/core/save/all
\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)$
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/boot/boot.css]] -[is[system]type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$
\end
{{$:/core/templates/tiddlywiki5.html}}

View File

@ -1,6 +1,6 @@
title: $:/core/save/empty
\define saveTiddlerFilter()
[is[system]] -[prefix[$:/state/popup/]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]]
[is[system]] -[prefix[$:/state/popup/]] -[[$:/boot/boot.css]] -[is[system]type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]]
\end
{{$:/core/templates/tiddlywiki5.html}}

View File

@ -1,7 +1,7 @@
title: $:/core/save/lazy-all
\define saveTiddlerFilter()
[is[system]] -[prefix[$:/state/popup/]] -[[$:/HistoryList]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] [is[tiddler]type[application/javascript]] +[sort[title]]
[is[system]] -[prefix[$:/state/popup/]] -[[$:/HistoryList]] -[[$:/boot/boot.css]] -[is[system]type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] [is[tiddler]type[application/javascript]] +[sort[title]]
\end
\define skinnySaveTiddlerFilter()
[!is[system]] -[type[application/javascript]]

View File

@ -1,7 +1,7 @@
title: $:/core/save/lazy-images
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[[$:/HistoryList]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[!is[system]is[image]] +[sort[title]]
[is[tiddler]] -[prefix[$:/state/popup/]] -[[$:/HistoryList]] -[[$:/boot/boot.css]] -[is[system]type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[!is[system]is[image]] +[sort[title]]
\end
\define skinnySaveTiddlerFilter()
[!is[system]is[image]]

View File

@ -0,0 +1,5 @@
title: $:/core/ui/KeyboardShortcuts/refresh
tags: $:/tags/KeyboardShortcut
key: ((refresh))
<$action-sendmessage $message="tm-browser-refresh"/>

View File

@ -35,6 +35,7 @@ new-tiddler: {{$:/language/Buttons/NewTiddler/Hint}}
picture: {{$:/language/Buttons/Picture/Hint}}
preview: {{$:/language/Buttons/Preview/Hint}}
quote: {{$:/language/Buttons/Quote/Hint}}
refresh: {{$:/language/Buttons/Refresh/Hint}}
save-tiddler: {{$:/language/Buttons/Save/Hint}}
save-wiki: {{$:/language/Buttons/SaveWiki/Hint}}
sidebar-search: {{$:/language/Buttons/SidebarSearch/Hint}}

View File

@ -6,4 +6,5 @@ underline: meta-U
new-image: ctrl-I
new-journal: ctrl-J
new-tiddler: ctrl-N
refresh: meta-R
save-wiki: meta-S

View File

@ -6,3 +6,4 @@ underline: ctrl-U
new-image: alt-I
new-journal: alt-J
new-tiddler: alt-N
refresh: ctrl-R

View File

@ -0,0 +1,176 @@
/*\
title: test-action-deletefield.js
type: application/javascript
tags: [[$:/tags/test-spec]]
Tests <$action-deletefield />.
\*/
(function(){
/* jslint node: true, browser: true */
/* eslint-env node, browser, jasmine */
/* eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
/* global $tw, require */
"use strict";
describe("<$action-deletefield /> tests", function() {
const TEST_TIDDLER_TITLE = "TargetTiddler";
const TEST_TIDDLER_MODIFIED = "20240313114828368";
function setupWiki(condition, targetField, wikiOptions) {
// Create a wiki
var wiki = new $tw.Wiki({});
var tiddlers = [{
title: "Root",
text: "Some dummy content"
}];
var tiddler;
if(condition.targetTiddlerExists) {
var fields = {
title: TEST_TIDDLER_TITLE,
};
if(condition.modifiedFieldExists) {
fields.modified = TEST_TIDDLER_MODIFIED;
}
if(condition.targetFieldExists) {
fields[targetField] = "some text";
}
var tiddler = new $tw.Tiddler(fields);
tiddlers.push(tiddler);
}
wiki.addTiddlers(tiddlers);
wiki.addIndexersToWiki();
var widgetNode = wiki.makeTranscludeWidget("Root",{document: $tw.fakeDocument, parseAsInline: true});
var container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
return {
wiki: wiki,
widgetNode: widgetNode,
contaienr: container,
tiddler: tiddler,
};
}
function generateTestConditions() {
var conditions = [];
$tw.utils.each([true, false], function(tiddlerArgumentIsPresent) {
$tw.utils.each([true, false], function(targetTiddlerExists) {
$tw.utils.each([true, false], function(targetFieldExists) {
$tw.utils.each([true, false], function(fieldArgumentIsUsed) {
$tw.utils.each([true, false], function(modifiedFieldExists) {
$tw.utils.each(["", "yes", "no"], function(timestampArgument) {
conditions.push({
tiddlerArgumentIsPresent: tiddlerArgumentIsPresent,
targetTiddlerExists: targetTiddlerExists,
targetFieldExists: targetFieldExists,
fieldArgumentIsUsed: fieldArgumentIsUsed,
modifiedFieldExists: modifiedFieldExists,
timestampArgument: timestampArgument,
});
});
});
});
});
});
});
return conditions;
}
function generateActionWikitext(condition, targetField) {
var actionPieces = [
"<$action-deletefield",
(condition.tiddlerArgumentIsPresent ? "$tiddler='" + TEST_TIDDLER_TITLE + "'" : ""),
(condition.fieldArgumentIsUsed ? "$field='" + targetField + "'" : targetField),
(condition.timestampArgument !== "" ? "$timestamp='" + condition.timestampArgument + "'" : ""),
"/>",
];
return actionPieces.join(" ");
}
function generateTestContext(action, tiddler) {
var expectationContext = "action: " + action + "\ntiddler:\n\n";
if(tiddler) {
expectationContext += tiddler.getFieldStringBlock({exclude: ["text"]});
if(tiddler.text) {
expectationContext += "\n\n" + tiddler.text;
}
expectationContext += "\n\n";
} else {
expectationContext += "null";
}
return expectationContext;
}
it("should correctly delete fields", function() {
var fields = ['caption', 'description', 'text'];
var conditions = generateTestConditions();
$tw.utils.each(conditions, function(condition) {
$tw.utils.each(fields, function(field) {
var info = setupWiki(condition, field);
var originalTiddler = info.tiddler;
var invokeActions = function(actions) {
info.widgetNode.invokeActionString(actions,info.widgetNode,null,{
currentTiddler: TEST_TIDDLER_TITLE,
});
};
var action = generateActionWikitext(condition,field);
invokeActions(action);
var testContext = generateTestContext(action,originalTiddler);
var tiddler = info.wiki.getTiddler(TEST_TIDDLER_TITLE);
if(originalTiddler) {
// assert that the tiddler doesn't have the target field anymore
expect(tiddler.hasField(field)).withContext(testContext).toBeFalsy();
var targetFieldWasPresent = originalTiddler.hasField(field);
var updateTimestamps = condition.timestampArgument !== "no";
// "created" should exist if it did beforehand, or if the tiddler changed and we asked the widget to update timestamps
var createdFieldShouldExist = originalTiddler.hasField("created") || (targetFieldWasPresent && updateTimestamps);
// "created" should change only if it didn't exist beforehand and the tiddler changed and we asked the widget to update timestamps
var createdFieldShouldChange = !originalTiddler.hasField("created") && (targetFieldWasPresent && updateTimestamps);
// "modified" should exist if it did beforehand, or if the tiddler changed and we asked the widget to update timestamps
var modifiedFieldShouldExist = originalTiddler.hasField("modified") || (targetFieldWasPresent && updateTimestamps);
// "modified" should change if the tiddler changed and we asked the widget to update timestamps
var modifiedFieldShouldChange = targetFieldWasPresent && updateTimestamps;
expect(tiddler.hasField("created")).withContext(testContext).toBe(createdFieldShouldExist);
expect(tiddler.hasField("modified")).withContext(testContext).toBe(modifiedFieldShouldExist);
if(createdFieldShouldChange) {
expect(tiddler.fields.created).withContext(testContext).not.toEqual(originalTiddler.fields.created);
} else {
expect(tiddler.fields.created).withContext(testContext).toEqual(originalTiddler.fields.created);
}
if(modifiedFieldShouldChange) {
expect(tiddler.fields.modified).withContext(testContext).not.toEqual(originalTiddler.fields.modified);
} else {
expect(tiddler.fields.modified).withContext(testContext).toEqual(originalTiddler.fields.modified);
}
} else {
// assert that the tiddler didn't get created if it didn't exist already
expect(tiddler).withContext(testContext).toBeUndefined();
}
});
});
});
});
})();

View File

@ -1,8 +1,8 @@
code-body: yes
created: 20150117152607000
modified: 20240229155550000
modified: 20240317091700545
tags: $:/tags/Macro
title: $:/editions/tw5.com/doc-macros
code-body: yes
type: text/vnd.tiddlywiki
\whitespace trim
@ -165,7 +165,7 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]].
<dd><$button set=<<.state>> setTo="">Hide</$button></dd>
</dl>
<blockquote class="doc-example-result">
<<eg>>
<$transclude $variable="eg" $mode="block"/>
</blockquote>
</$reveal>
</$list>

View File

@ -16,6 +16,7 @@ The ''action-deletefield'' widget is invisible. Any content within it is ignored
|!Attribute |!Description |
|$tiddler |The title of the tiddler whose fields are to be modified (if not provided defaults to the [[current tiddler|Current Tiddler]]) |
|$field |Optional name of a field to delete |
|$timestamp |<<.from-version "5.3.4">> Specifies whether the timestamp(s) of the target tiddler will be updated (''modified'' and ''modifier'', plus ''created'' and ''creator'' for newly created tiddlers). Can be "yes" (the default) or "no" |
|//{any attributes not starting with $}// |Each attribute name specifies a field to be deleted. The attribute value is ignored and need not be specified |
! Examples

View File

@ -1,14 +1,14 @@
created: 20140908130500000
modified: 20150219182745000
modified: 20240326164134356
tags: Concepts Reference
title: Widgets
type: text/vnd.tiddlywiki
~TiddlyWiki's display is driven by an underlying collection of <<.def widgets>>. These are organised into a tree structure: each widget has a parent widget and zero or more child widgets.
~TiddlyWiki generates this <<.def "widget tree">> by parsing the WikiText of tiddlers. Each component of the WikiText syntax, including even the trivial case of ordinary text, generates a corresponding widget. The widget tree is an intermediate representation that is subsequently rendered into the actual display.
~TiddlyWiki generates this <<.def "widget tree">> by parsing the ~WikiText of tiddlers. Each component of the ~WikiText syntax, including even the trivial case of ordinary text, generates a corresponding widget. The widget tree is an intermediate representation that is subsequently rendered into the actual display.
Widgets are analogous to elements in an HTML document. Indeed, HTML tags in WikiText generate dedicated <<.def "element widgets">>.
Widgets are analogous to elements in an HTML document. Indeed, HTML tags in ~WikiText generate dedicated <<.def "element widgets">>.
Each class of widget contributes a specific ability to the overall functionality, such as the ability to <<.wlink2 "display an image" ImageWidget>> or <<.wlink2 "a button" ButtonWidget>>, to <<.wlink2 "call a macro" MacroCallWidget>> or <<.wlink2 "transclude text from elsewhere" TranscludeWidget>>, or to [[mark a piece of text as a heading|HTML in WikiText]].
@ -16,4 +16,4 @@ The more specialised widgets use a general-purpose [[widget syntax|Widgets in Wi
The following classes of widget are built into the core:
<<list-links "[tag[Widgets]]">>
<<list-links "[tag[Widgets]]" class:"multi-columns">>

View File

@ -563,3 +563,5 @@ John Long, @drevarr, 2023/12/12
Ed Holsinger, @eschlon, 2024/02/08
Kim I. McKinley, @PotOfCoffee2Go, 2024/03/16
@Jinix6, 2024/03/31

View File

@ -1,7 +1,7 @@
title: $:/themes/tiddlywiki/vanilla/reset
type: text/css
/*! modern-normalize v1.0.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
/*! modern-normalize v2.0.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
/*
Document
@ -13,28 +13,26 @@ Use a better box model (opinionated).
*/
*,
*::before,
*::after {
box-sizing: border-box;
::before,
::after {
box-sizing: border-box;
}
/**
Use a more readable tab size (opinionated).
*/
:root {
-moz-tab-size: 4;
tab-size: 4;
}
/**
1. Correct the line height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
/* Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3) */
font-family:
system-ui,
'Segoe UI',
Roboto,
Helvetica,
Arial,
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji';
line-height: 1.15; /* 1. Correct the line height in all browsers. */
-webkit-text-size-adjust: 100%; /* 2. Prevent adjustments of font size after orientation changes in iOS. */
-moz-tab-size: 4; /* 3. Use a more readable tab size (opinionated). */
tab-size: 4; /* 3 */
}
/*
@ -42,29 +40,8 @@ Sections
========
*/
/**
Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
*/
body {
font-family:
system-ui,
-apple-system, /* Firefox supports this but not yet `system-ui` */
'Segoe UI',
Roboto,
Helvetica,
Arial,
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji';
margin: 0; /* Remove the margin in all browsers. */
}
/*
@ -78,8 +55,8 @@ Grouping content
*/
hr {
height: 0; /* 1 */
color: inherit; /* 2 */
height: 0; /* 1 */
color: inherit; /* 2 */
}
/*
@ -92,7 +69,7 @@ Add the correct text decoration in Chrome, Edge, and Safari.
*/
abbr[title] {
text-decoration: underline dotted;
text-decoration: underline dotted;
}
/**
@ -101,7 +78,7 @@ Add the correct font weight in Edge and Safari.
b,
strong {
font-weight: bolder;
font-weight: bolder;
}
/**
@ -113,14 +90,14 @@ code,
kbd,
samp,
pre {
font-family:
ui-monospace,
SFMono-Regular,
Consolas,
'Liberation Mono',
Menlo,
monospace; /* 1 */
font-size: 1em; /* 2 */
font-family:
ui-monospace,
SFMono-Regular,
Consolas,
'Liberation Mono',
Menlo,
monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
@ -128,7 +105,7 @@ Add the correct font size in all browsers.
*/
small {
font-size: 80%;
font-size: 80%;
}
/**
@ -137,18 +114,18 @@ Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
bottom: -0.25em;
}
sup {
top: -0.5em;
top: -0.5em;
}
/*
@ -158,12 +135,12 @@ Tabular data
/**
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
2. Correct table border color inheritance in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
*/
table {
text-indent: 0; /* 1 */
border-color: inherit; /* 2 */
text-indent: 0; /* 1 */
border-color: inherit; /* 2 */
}
/*
@ -181,20 +158,19 @@ input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
Remove the inheritance of text transform in Edge and Firefox.
1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
select {
text-transform: none;
}
/**
@ -205,7 +181,7 @@ button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button;
-webkit-appearance: button;
}
/**
@ -213,8 +189,8 @@ Remove the inner border and padding in Firefox.
*/
::-moz-focus-inner {
border-style: none;
padding: 0;
border-style: none;
padding: 0;
}
/**
@ -222,7 +198,7 @@ Restore the focus styles unset by the previous rule.
*/
:-moz-focusring {
outline: 1px dotted ButtonText;
outline: 1px dotted ButtonText;
}
/**
@ -231,7 +207,7 @@ See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d4
*/
:-moz-ui-invalid {
box-shadow: none;
box-shadow: none;
}
/**
@ -239,7 +215,7 @@ Remove the padding so developers are not caught out when they zero out 'fieldset
*/
legend {
padding: 0;
padding: 0;
}
/**
@ -247,7 +223,7 @@ Add the correct vertical alignment in Chrome and Firefox.
*/
progress {
vertical-align: baseline;
vertical-align: baseline;
}
/**
@ -256,7 +232,7 @@ Correct the cursor style of increment and decrement buttons in Safari.
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
height: auto;
height: auto;
}
/**
@ -265,8 +241,8 @@ Correct the cursor style of increment and decrement buttons in Safari.
*/
[type='search'] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
@ -274,7 +250,7 @@ Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration {
-webkit-appearance: none;
-webkit-appearance: none;
}
/**
@ -283,8 +259,8 @@ Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/*
@ -297,5 +273,5 @@ Add the correct display in Chrome and Safari.
*/
summary {
display: list-item;
display: list-item;
}