mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-01-22 10:54:46 +00:00
Compare commits
33 Commits
v5.3.3
...
single-tid
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d9b00bdb5 | ||
|
|
b88bfda0b4 | ||
|
|
834610cdb9 | ||
|
|
5272b13af1 | ||
|
|
5f25b21c0d | ||
|
|
f256b7791d | ||
|
|
66fc63ed7f | ||
|
|
f703330962 | ||
|
|
0ea4bfe99f | ||
|
|
7f99b8c32e | ||
|
|
95111db7ee | ||
|
|
5e148c1d26 | ||
|
|
1ff40c6b22 | ||
|
|
a0084eee9a | ||
|
|
55740fbfaf | ||
|
|
226a635c5c | ||
|
|
a5dca25078 | ||
|
|
a15a711d4a | ||
|
|
9bc8cbfe98 | ||
|
|
f8b81616fb | ||
|
|
b7611e23b4 | ||
|
|
eacbb928e9 | ||
|
|
04d6677949 | ||
|
|
ee25af758e | ||
|
|
33aa37f7dc | ||
|
|
0d40b691e7 | ||
|
|
81fda40486 | ||
|
|
7a50edb56d | ||
|
|
f76e3f5d41 | ||
|
|
9f2ce65a71 | ||
|
|
9a77ec4591 | ||
|
|
8625d6cd01 | ||
|
|
aba835fb74 |
4
core/images/storyview-solo.tid
Normal file
4
core/images/storyview-solo.tid
Normal file
@@ -0,0 +1,4 @@
|
||||
title: $:/core/images/storyview-solo
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg width="22pt" height="22pt" class="tc-image-storyview-single tc-image-button" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M8.007 0A8.01 8.01 0 000 8.007v111.986A8.01 8.01 0 008.007 128h111.986a8.01 8.01 0 008.007-8.007V8.007A8.01 8.01 0 00119.993 0H8.007zm15.992 16A8 8 0 0016 24.009V71.99C16 76.414 19.588 80 24 80h80a8 8 0 008-8.009V24.01c0-4.423-3.588-8.009-8-8.009H24z"/></svg>
|
||||
@@ -4,6 +4,7 @@ All/Caption: All
|
||||
Contents/Caption: Contents
|
||||
Drafts/Caption: Drafts
|
||||
Explorer/Caption: Explorer
|
||||
History/Caption: History
|
||||
Missing/Caption: Missing
|
||||
More/Caption: More
|
||||
Open/Caption: Open
|
||||
|
||||
38
core/modules/filters/getstoryviewmode.js
Normal file
38
core/modules/filters/getstoryviewmode.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/getstoryviewmode.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for retrieving modes from a storyview. Only "singletiddlermode" is implemented at present
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter functions
|
||||
*/
|
||||
|
||||
exports.getstoryviewmode = function(source,operator,options) {
|
||||
// Initialise the storyviews if they've not been done already
|
||||
var storyviews = {};
|
||||
$tw.modules.applyMethods("storyview",storyviews);
|
||||
if(operator.operand !== "singletiddlermode") {
|
||||
return [];
|
||||
}
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
var storyview = storyviews[title];
|
||||
if(storyview && storyview.singleTiddlerMode) {
|
||||
results.push("yes");
|
||||
} else {
|
||||
results.push("no");
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -37,44 +37,48 @@ Story.prototype.getStoryList = function() {
|
||||
Story.prototype.addToStory = function(navigateTo,navigateFromTitle,options) {
|
||||
options = options || {};
|
||||
var storyList = this.getStoryList();
|
||||
// See if the tiddler is already there
|
||||
var slot = storyList.indexOf(navigateTo);
|
||||
// Quit if it already exists in the story river
|
||||
if(slot >= 0) {
|
||||
return;
|
||||
}
|
||||
// First we try to find the position of the story element we navigated from
|
||||
var fromIndex = storyList.indexOf(navigateFromTitle);
|
||||
if(fromIndex >= 0) {
|
||||
// The tiddler is added from inside the river
|
||||
// Determine where to insert the tiddler; Fallback is "below"
|
||||
switch(options.openLinkFromInsideRiver) {
|
||||
case "top":
|
||||
slot = 0;
|
||||
break;
|
||||
case "bottom":
|
||||
slot = storyList.length;
|
||||
break;
|
||||
case "above":
|
||||
slot = fromIndex;
|
||||
break;
|
||||
case "below": // Intentional fall-through
|
||||
default:
|
||||
slot = fromIndex + 1;
|
||||
break;
|
||||
}
|
||||
if(options.singleTiddlerMode) {
|
||||
storyList = [navigateTo];
|
||||
} else {
|
||||
// The tiddler is opened from outside the river. Determine where to insert the tiddler; default is "top"
|
||||
if(options.openLinkFromOutsideRiver === "bottom") {
|
||||
// Insert at bottom
|
||||
slot = storyList.length;
|
||||
} else {
|
||||
// Insert at top
|
||||
slot = 0;
|
||||
// See if the tiddler is already there
|
||||
var slot = storyList.indexOf(navigateTo);
|
||||
// Quit if it already exists in the story river
|
||||
if(slot >= 0) {
|
||||
return;
|
||||
}
|
||||
// First we try to find the position of the story element we navigated from
|
||||
var fromIndex = storyList.indexOf(navigateFromTitle);
|
||||
if(fromIndex >= 0) {
|
||||
// The tiddler is added from inside the river
|
||||
// Determine where to insert the tiddler; Fallback is "below"
|
||||
switch(options.openLinkFromInsideRiver) {
|
||||
case "top":
|
||||
slot = 0;
|
||||
break;
|
||||
case "bottom":
|
||||
slot = storyList.length;
|
||||
break;
|
||||
case "above":
|
||||
slot = fromIndex;
|
||||
break;
|
||||
case "below": // Intentional fall-through
|
||||
default:
|
||||
slot = fromIndex + 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// The tiddler is opened from outside the river. Determine where to insert the tiddler; default is "top"
|
||||
if(options.openLinkFromOutsideRiver === "bottom") {
|
||||
// Insert at bottom
|
||||
slot = storyList.length;
|
||||
} else {
|
||||
// Insert at top
|
||||
slot = 0;
|
||||
}
|
||||
}
|
||||
// Add the tiddler
|
||||
storyList.splice(slot,0,navigateTo);
|
||||
}
|
||||
// Add the tiddler
|
||||
storyList.splice(slot,0,navigateTo);
|
||||
// Save the story
|
||||
this.saveStoryList(storyList);
|
||||
};
|
||||
@@ -93,11 +97,20 @@ Story.prototype.saveStoryList = function(storyList) {
|
||||
Story.prototype.addToHistory = function(navigateTo,navigateFromClientRect) {
|
||||
var titles = $tw.utils.isArray(navigateTo) ? navigateTo : [navigateTo];
|
||||
// Add a new record to the top of the history stack
|
||||
var historyList = this.wiki.getTiddlerData(this.historyTitle,[]);
|
||||
var historyList = this.wiki.getTiddlerData(this.historyTitle,[]),
|
||||
historyTitles = this.wiki.getTiddlerList(this.historyTitle);
|
||||
$tw.utils.each(titles,function(title) {
|
||||
historyList.push({title: title, fromPageRect: navigateFromClientRect});
|
||||
var p;
|
||||
do {
|
||||
p = historyTitles.indexOf(title);
|
||||
if(p !== -1) {
|
||||
historyTitles.splice(p,1);
|
||||
}
|
||||
} while(p !== -1);
|
||||
historyTitles.unshift(title);
|
||||
});
|
||||
this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler": titles[titles.length-1]});
|
||||
this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler": titles[titles.length-1], list: historyTitles});
|
||||
};
|
||||
|
||||
Story.prototype.storyCloseTiddler = function(targetTitle) {
|
||||
|
||||
23
core/modules/storyviews/solo.js
Normal file
23
core/modules/storyviews/solo.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/*\
|
||||
title: $:/core/modules/storyviews/solo.js
|
||||
type: application/javascript
|
||||
module-type: storyview
|
||||
|
||||
Flip between individual tiddlers
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var SoloListView = function(listWidget) {
|
||||
};
|
||||
|
||||
// Engage single tiddler mode
|
||||
SoloListView.singleTiddlerMode = true;
|
||||
|
||||
exports.solo = SoloListView;
|
||||
|
||||
})();
|
||||
@@ -39,6 +39,9 @@ var ZoominListView = function(listWidget) {
|
||||
});
|
||||
};
|
||||
|
||||
// Engage single tiddler mode
|
||||
ZoominListView.singleTiddlerMode = true;
|
||||
|
||||
ZoominListView.prototype.navigateTo = function(historyInfo) {
|
||||
var duration = $tw.utils.getAnimationDuration(),
|
||||
listElementIndex = this.listWidget.findListItem(0,historyInfo.title);
|
||||
|
||||
@@ -60,6 +60,10 @@ NavigatorWidget.prototype.execute = function() {
|
||||
// Get our parameters
|
||||
this.storyTitle = this.getAttribute("story");
|
||||
this.historyTitle = this.getAttribute("history");
|
||||
this.openLinkFromInsideRiver = this.getAttribute("openLinkFromInsideRiver","top");
|
||||
this.openLinkFromOutsideRiver = this.getAttribute("openLinkFromOutsideRiver","top");
|
||||
this.singleTiddlerMode = this.getAttribute("singleTiddlerMode","no") === "yes";
|
||||
this.relinkOnRename = this.getAttribute("relinkOnRename","no").toLowerCase().trim() === "yes";
|
||||
this.setVariable("tv-story-list",this.storyTitle);
|
||||
this.setVariable("tv-history-list",this.historyTitle);
|
||||
// Construct the child widgets
|
||||
@@ -71,7 +75,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
||||
*/
|
||||
NavigatorWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(changedAttributes.story || changedAttributes.history) {
|
||||
if(changedAttributes.story || changedAttributes.history || changedAttributes.openLinkFromInsideRiver || changedAttributes.openLinkFromOutsideRiver || changedAttributes.singleTiddlerMode || changedAttributes.relinkOnRename) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else {
|
||||
@@ -122,12 +126,17 @@ NavigatorWidget.prototype.replaceFirstTitleInStory = function(storyList,oldTitle
|
||||
};
|
||||
|
||||
NavigatorWidget.prototype.addToStory = function(title,fromTitle) {
|
||||
if(this.storyTitle) {
|
||||
this.wiki.addToStory(title,fromTitle,this.storyTitle,{
|
||||
openLinkFromInsideRiver: this.getAttribute("openLinkFromInsideRiver","top"),
|
||||
openLinkFromOutsideRiver: this.getAttribute("openLinkFromOutsideRiver","top")
|
||||
});
|
||||
}
|
||||
this.wiki.addToStory(title,fromTitle,this.storyTitle,{
|
||||
openLinkFromInsideRiver: this.openLinkFromInsideRiver,
|
||||
openLinkFromOutsideRiver: this.openLinkFromOutsideRiver,
|
||||
singleTiddlerMode: this.singleTiddlerMode
|
||||
});
|
||||
};
|
||||
|
||||
NavigatorWidget.prototype.removeFromStory = function(title) {
|
||||
var storyList = this.getStoryList();
|
||||
this.removeTitleFromStory(storyList,title);
|
||||
this.saveStoryList(storyList);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -155,11 +164,34 @@ NavigatorWidget.prototype.handleNavigateEvent = function(event) {
|
||||
|
||||
// Close a specified tiddler
|
||||
NavigatorWidget.prototype.handleCloseTiddlerEvent = function(event) {
|
||||
var title = event.param || event.tiddlerTitle,
|
||||
storyList = this.getStoryList();
|
||||
// Look for tiddlers with this title to close
|
||||
this.removeTitleFromStory(storyList,title);
|
||||
this.saveStoryList(storyList);
|
||||
var title = event.param || event.tiddlerTitle;
|
||||
if(this.singleTiddlerMode) {
|
||||
// Get the history stack and find the topmost occurance of the current tiddler
|
||||
var history = this.wiki.getTiddlerDataCached(this.historyTitle,[]),
|
||||
currPos = history.findIndex(function(historyRecord) {
|
||||
return historyRecord.title === title;
|
||||
}),
|
||||
newTitle;
|
||||
// Skip over any duplicates
|
||||
while(currPos > 0 && history[currPos - 1].title === title) {
|
||||
currPos--;
|
||||
}
|
||||
// Get the new title
|
||||
if(currPos > 0) {
|
||||
newTitle = history[currPos - 1].title;
|
||||
}
|
||||
// Navigate to the new title if we've got one
|
||||
if(newTitle) {
|
||||
this.addToStory(newTitle);
|
||||
this.addToHistory(newTitle);
|
||||
} else {
|
||||
// If there's nothing to navigate back to then we really do close the last tiddler
|
||||
this.removeFromStory(title);
|
||||
}
|
||||
} else {
|
||||
// Look for tiddlers with this title to close
|
||||
this.removeFromStory(title);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -323,8 +355,7 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
|
||||
newTiddler = $tw.hooks.invokeHook("th-saving-tiddler",newTiddler);
|
||||
this.wiki.addTiddler(newTiddler);
|
||||
// If enabled, relink references to renamed tiddler
|
||||
var shouldRelink = this.getAttribute("relinkOnRename","no").toLowerCase().trim() === "yes";
|
||||
if(isRename && shouldRelink && this.wiki.tiddlerExists(draftOf)) {
|
||||
if(isRename && this.relinkOnRename && this.wiki.tiddlerExists(draftOf)) {
|
||||
console.log("Relinking '" + draftOf + "' to '" + draftTitle + "'");
|
||||
this.wiki.relinkTiddler(draftOf,draftTitle);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
|
||||
|
||||
<div class=<<containerClasses>>>
|
||||
|
||||
<$navigator story="$:/StoryList" history="$:/HistoryList">
|
||||
<$navigator story="$:/StoryList" history="$:/HistoryList" singleTiddlerMode={{{ [<storyviewTitle>getstoryviewmode[singletiddlermode]] }}}>
|
||||
|
||||
<$transclude mode="block"/>
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
|
||||
|
||||
<$set name="storyviewTitle" value={{$:/view}}>
|
||||
|
||||
<$set name="tv-storyview-single-tiddler-mode" value={{{ [<storyviewTitle>getstoryviewmode[singletiddlermode]] }}}>
|
||||
|
||||
<$set name="languageTitle" value={{{ [{$:/language}get[name]] }}}>
|
||||
|
||||
<div class=<<containerClasses>>>
|
||||
|
||||
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
|
||||
<$navigator story="$:/StoryList" history="$:/HistoryList" singleTiddlerMode=<<tv-storyview-single-tiddler-mode>> openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
|
||||
|
||||
<$dropzone enable=<<tv-enable-drag-and-drop>>>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
title: $:/core/ui/SideBar/Open
|
||||
tags: $:/tags/SideBar
|
||||
caption: {{$:/language/SideBar/Open/Caption}}
|
||||
caption: <$list filter="[<tv-storyview-single-tiddler-mode>prefix[yes]]" emptyMessage="{{$:/language/SideBar/Open/Caption}}">{{$:/language/SideBar/History/Caption}}</$list>
|
||||
|
||||
\whitespace trim
|
||||
\define lingo-base() $:/language/CloseAll/
|
||||
@@ -23,6 +23,7 @@ $button$
|
||||
</$droppable>
|
||||
\end
|
||||
|
||||
\define open()
|
||||
<div class="tc-sidebar-tab-open">
|
||||
<$list filter="[list<tv-story-list>]" history=<<tv-history-list>> storyview="pop">
|
||||
<div class="tc-sidebar-tab-open-item">
|
||||
@@ -34,4 +35,8 @@ $button$
|
||||
<$macrocall $name="droppable-item" button="""<$button message="tm-close-all-tiddlers" class="tc-btn-invisible tc-btn-mini"><<lingo Button>></$button>"""/>
|
||||
</div>
|
||||
</$tiddler>
|
||||
</div>
|
||||
\end
|
||||
|
||||
<$list filter="[<tv-storyview-single-tiddler-mode>prefix[yes]]" emptyMessage=<<open>>>
|
||||
<$list filter="[list[$:/HistoryList]limit[100]]" template="$:/core/ui/ListItemTemplate"/>
|
||||
</$list>
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
title: TiddlyWiki Pre-release
|
||||
modified: 20150428204930183
|
||||
|
||||
!! Experimental Single Tiddler Mode
|
||||
|
||||
This build of the TiddlyWiki Pre-release is built from the "single-tiddler-mode" branch, and incorporates the work in progress from this pull request:
|
||||
|
||||
https://github.com/Jermolene/TiddlyWiki5/pull/3412
|
||||
|
||||
Essentially, "Single Tiddler Mode" means that the ''zoomin'' storyview no longer keeps previously navigated tiddlers hidden but open. Instead, there is only ever one tiddler open in the story river.
|
||||
|
||||
This has some implications for familiar TiddlyWiki features:
|
||||
|
||||
* The "close" button now navigates to the previous tiddler in the history stack
|
||||
* The "open" tab in the sidebar mutates into a more useful new "history" tab when "single tiddler mode" is engaged
|
||||
|
||||
You can switch storyviews here to experiment with the effect:
|
||||
|
||||
{{$:/snippets/viewswitcher}}
|
||||
|
||||
---
|
||||
|
||||
This is a pre-release build of TiddlyWiki, [[also available in empty form|https://tiddlywiki.com/prerelease/empty.html]]. It is provided for testing purposes. ''Please don't try to use it for anything important'' -- you should use the latest official release from https://tiddlywiki.com.
|
||||
|
||||
<$list filter="[tag[ReleaseNotes]!has[released]!sort[created]]">
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
title: $:/view
|
||||
|
||||
classic
|
||||
solo
|
||||
@@ -11,7 +11,7 @@ TiddlyWiki ships with defaults that are designed to get the best out of modern d
|
||||
* ''Avoid the "Recent" tab''. It is computationally slow to generate and update in response to tiddler changes.
|
||||
* ''Use the "Vanilla" theme''. The default "Snow White" theme includes visual effects like shadows, transparency and blurring that can be slow to render on older devices
|
||||
* ''Avoid large tiddlers''. Large bitmaps can significantly slow TiddlyWiki's performance. For example, an image taken with a modern smartphone will often be 5MB or more. Use ExternalImages whenever possible
|
||||
* ''Don't have too many tiddlers open at once''. Every tiddler you have open will require processing to keep it up to date as the store changes (for example, while you type into a draft tiddler). It is particularly easy when using zoomin story view to end up with dozens of tiddlers listed in the ''Open'' tab in the sidebar. Get into the habit of periodically closing all open tiddlers with the <<.icon $:/core/images/close-all-button>> ''close all'' button
|
||||
* ''Don't have too many tiddlers open at once''. Every tiddler you have open will require processing to keep it up to date as the store changes (for example, while you type into a draft tiddler). It is easy to end up with dozens of tiddlers listed in the ''Open'' tab in the sidebar. Get into the habit of periodically closing all open tiddlers with the {{$:/core/images/close-all-button}} ''close all'' button, or use zoomin story view which only keeps one tiddler open at a time.
|
||||
|
||||
!! WikiText
|
||||
|
||||
@@ -28,4 +28,3 @@ TiddlyWiki ships with defaults that are designed to get the best out of modern d
|
||||
** Note that the field indexer currently defaults to indexing field values of less than 128 characters; longer values can still be searched for, but no index will be constructed
|
||||
** Also note that the “field” operator is also used when the operator name is a fieldname, so, for example, `[all[shadows+tiddlers]caption[x]...` is optimised.
|
||||
* Use the [[throttling|RefreshThrottling]] feature of the RefreshMechanism judiciously
|
||||
|
||||
|
||||
Reference in New Issue
Block a user