/*\
title: $:/plugins/bimlas/my-plugin/startup/relink-or-rename.js
type: application/javascript
module-type: startup
Hook on rename
\*/
(function() {
/*jslint node: true, browser: false */
/*global $tw: true */
"use strict";
// Export name and synchronous status
exports.name = "my-rename-hook";
exports.platforms = ["browser"];
exports.after = ["startup"];
exports.synchronous = true;
exports.startup = function() {
console.log('LOADED');
$tw.hooks.addHook("th-renaming-tiddler",function handleEvent(newTiddler, tiddler) {
console.log('RENAME',newTiddler);
$tw.wiki.addTiddler(new $tw.Tiddler({title: "NAME CHANGED", text: "rename"}));
return newTiddler;
});
$tw.hooks.addHook("th-relinking-tiddler",function handleEvent(newTiddler, tiddler) {
console.log('RELINK', newTiddler);
$tw.wiki.addTiddler(new $tw.Tiddler({title: "NAME CHANGED", text: "relink"}));
return newTiddler;
});
};
})();
On 31 Jan 2020, at 09:16, bimlas <bimba....@gmail.com> wrote:
I've found the problem: the tiddler I wanted to rename was not listed in othe tiddler's fields (neither in the "tags" nor in the "list" field), so the hook didn't executed and therefore the messages didn't appear.Can I create hooks that will be executed anyway when renaming, even if they have not been changed in the "list" or "tags" field?
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/08efea4e-0b4f-4913-b26b-f070d4b3dc33%40googlegroups.com.
On 31 Jan 2020, at 12:41, bimlas <bimba....@gmail.com> wrote:
I tried importing the above example into the Text-Slicer edition and after slicing the example text when I turned on the toolbar (which sends the "tm-rename-tiddler" message) in the left sidebar and renamed the tiddler there, in the console "RENAME" appeared, so the hook is executed here, but if for example i open the tiddler itself in edit mode and rewrite its name, the hook doesn't execute.
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/480cbb8a-0ad2-46a1-a861-cf3c452358fe%40googlegroups.com.
Hi! I came accross exactly the issue discussed here andin https://github.com/Jermolene/TiddlyWiki5/pull/4434.
My Use-Case is just as follows: Beside tags and list renaming (that is directly supported by TW5) i want to update my own list-fields (custom named) on ANY title-change (API or manual via editor) that occurs. As far as i understand the TW5-code, the best way to implement that is to listen on exactly the mentioned "th-renaming-tiddler"-event but that is not fired when renaming a tiddler by the standard edit-mode.
Or is there any other approach i should use that i don't see now (beside changing core-code)?
Thanks,
Mirko
when renaming a tiddler by the standard edit-mode