Skip to content

Commit

Permalink
feature: once a tiddler editor is focused, add it to the history top
Browse files Browse the repository at this point in the history
  • Loading branch information
YakovL committed Dec 24, 2024
1 parent bd71e78 commit 00dea67
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion JumpKeysPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
|Description|Adds an interface and hotkeys for jumping between tiddlers and more|
|Source |https://github.com/YakovL/TiddlyWiki_JumpKeysPlugin/blob/master/JumpKeysPlugin.js|
|Author |Yakov Litvin|
|Version |1.2.0|
|Version |1.2.1|
|License |[[MIT|https://github.com/YakovL/TiddlyWiki_YL_ExtensionsCollection/blob/master/Common%20License%20(MIT)]]|
!!!Usage
The plugin works more or less like the tab switching in a browser: press {{{ctrl + j}}} or the "jump" command in tiddler toolbar to open the jumping interface and:
Expand Down Expand Up @@ -261,6 +261,7 @@ config.shadowTiddlers['JumpKeysSettings'] = JSON.stringify(config.jumper.default
// reinstall-safe decorating and setting handlers
if(!config.jumper.orig_story_displayTiddler) {
config.jumper.orig_story_displayTiddler = story.displayTiddler
config.jumper.orig_editHandler = config.macros.edit.handler

store.addNotification('JumpKeysStyleSheet', refreshStyles)
store.addNotification("ColorPalette", (unused, doc) => refreshStyles('JumpKeysStyleSheet', doc))
Expand Down Expand Up @@ -289,6 +290,17 @@ story.displayTiddler = function(srcElement, tiddler, template, animate, unused,
})
return config.jumper.orig_story_displayTiddler.apply(this, arguments)
}

// once a tiddler editor is focused, add it to the history top
// (this doesn't cover other editors yet, like CodeMirror or WYSIWYG)
config.macros.edit.handler = config.macros.edit.handler = function() {
const editor = config.jumper.orig_editHandler.apply(this, arguments)
const tiddler = arguments[5]
editor.addEventListener('focus', () => {
config.jumper.pushTouchedTiddler({ title: tiddler.title })
})
return editor
}
//}}}
/***
!!!Jumper styles
Expand Down

0 comments on commit 00dea67

Please sign in to comment.