From d5c4aa250a194c27fe8b0c83ae735836ca83eed2 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Mon, 2 Nov 2020 23:52:02 +0100 Subject: [PATCH] Remove dependency on wiki.js for story-startup and navigator (#4200) * Update story.js * Update wiki.js * Update navigator.js * Add deprecation console logs to addToHistory and addToStory --- core/modules/startup/story.js | 9 +++++++-- core/modules/widgets/navigator.js | 9 +++++++-- core/modules/wiki.js | 6 ++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/core/modules/startup/story.js b/core/modules/startup/story.js index 14d45554a..0ca975ce3 100644 --- a/core/modules/startup/story.js +++ b/core/modules/startup/story.js @@ -150,6 +150,11 @@ function openStartupTiddlers(options) { // Save the story list $tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: "", list: storyList},$tw.wiki.getModificationFields()); // Update history + var story = new $tw.Story({ + wiki: $tw.wiki, + storyTitle: DEFAULT_STORY_TITLE, + historyTitle: DEFAULT_HISTORY_TITLE + }); if(!options.disableHistory) { // If a target tiddler was specified add it to the history stack if(target && target !== "") { @@ -157,9 +162,9 @@ function openStartupTiddlers(options) { if(target.indexOf("[[") === 0 && target.substr(-2) === "]]") { target = target.substr(2,target.length - 4); } - $tw.wiki.addToHistory(target); + story.addToHistory(target); } else if(storyList.length > 0) { - $tw.wiki.addToHistory(storyList[0]); + story.addToHistory(storyList[0]); } } } diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index bbbb57cb8..189765396 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -62,6 +62,11 @@ NavigatorWidget.prototype.execute = function() { this.historyTitle = this.getAttribute("history"); this.setVariable("tv-story-list",this.storyTitle); this.setVariable("tv-history-list",this.historyTitle); + this.story = new $tw.Story({ + wiki: this.wiki, + storyTitle: this.storyTitle, + historyTitle: this.historyTitle + }); // Construct the child widgets this.makeChildWidgets(); }; @@ -123,7 +128,7 @@ NavigatorWidget.prototype.replaceFirstTitleInStory = function(storyList,oldTitle NavigatorWidget.prototype.addToStory = function(title,fromTitle) { if(this.storyTitle) { - this.wiki.addToStory(title,fromTitle,this.storyTitle,{ + this.story.addToStory(title,fromTitle,this.storyTitle,{ openLinkFromInsideRiver: this.getAttribute("openLinkFromInsideRiver","top"), openLinkFromOutsideRiver: this.getAttribute("openLinkFromOutsideRiver","top") }); @@ -136,7 +141,7 @@ title: a title string or an array of title strings fromPageRect: page coordinates of the origin of the navigation */ NavigatorWidget.prototype.addToHistory = function(title,fromPageRect) { - this.wiki.addToHistory(title,fromPageRect,this.historyTitle); + this.story.addToHistory(title,fromPageRect,this.historyTitle); }; /* diff --git a/core/modules/wiki.js b/core/modules/wiki.js index c158e6b38..9fb5166b0 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -1426,7 +1426,8 @@ historyTitle: title of history tiddler (defaults to $:/HistoryList) */ exports.addToHistory = function(title,fromPageRect,historyTitle) { var story = new $tw.Story({wiki: this, historyTitle: historyTitle}); - story.addToHistory(title,fromPageRect); + story.addToHistory(title,fromPageRect); + console.log("$tw.wiki.addToHistory() is deprecated since V5.1.23! Use the this.story.addToHistory() from the story-object!") }; /* @@ -1438,7 +1439,8 @@ options: see story.js */ exports.addToStory = function(title,fromTitle,storyTitle,options) { var story = new $tw.Story({wiki: this, storyTitle: storyTitle}); - story.addToStory(title,fromTitle,options); + story.addToStory(title,fromTitle,options); + console.log("$tw.wiki.addToStory() is deprecated since V5.1.23! Use the this.story.addToStory() from the story-object!") }; /*