/*\
title: $:/plugins/felixhayashi/taskgraph/taskgraph.js
type: application/javascript
module-type: widget
TaskGraphWidget class
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var TaskGraphWidget = function(parseTreeNode, options) {
console.log("creating object");
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode, options);
this.addEventListeners([
{type: "tm-delete-tiddler", handler: "handleWikiContentChange"},
{type: "tm-save-tiddler", handler: "handleWikiContentChange"}
]);
};
/*
Inherit from the base widget class
*/
TaskGraphWidget.prototype = new Widget();
TaskGraphWidget.prototype.handleWikiContentChange = function(event) {
console.log("content change");
};
console.log("hello world");
exports.taskgraph = TaskGraphWidget;
})();
{
"title": "$:/plugins/felixhayashi/taskgraph",
"description": "Extending TW5 to become an innovative ticket system",
"author": "felixhayashi",
"version": "0.0.1",
"core-version": ">=5.1.3",
"source": "https://github.com/felixhayashi/taskgraph",
"type": "application/json",
"plugin-type": "plugin"
}
"tm-save-tiddler" travel from the leaves of the widget tree to the root, this means you widget will only see these messages from other widgets that descend from it (ie messages are passed up from its child widget). If you want to listen for changes to tiddlers in general, the names of changed tiddler are broadcast through the refresh mechanism.TaskGraphWidget.prototype.refresh = function(changedTiddlers) {
console.log("refresh");
};One thing to decide on is whether you want to track tiddlers or their rendered representation. Monitoring tiddlers is about monitoring changes to the store. I don't yet remember the details, but looking at the core syncer should tell you how to monitor changes to the store, as the syncer needs to do exactly this.
Monitoring events won't allow you to see all the changes. Instead, events control and reflect user actions.
Regards,
TheDiveO
From your description I would say that startup modules are not what you are looking for. Your initial attempt using a widget seems much more plausible. You probably want your canvas to be in a tiddler and not somewhere else.
Monitoring tiddlers is about monitoring changes to the store. I don't yet remember the details, but looking at the core syncer should tell you how to monitor changes to the store, as the syncer needs to do exactly this.
/*\
title: $:/plugins/felixhayashi/taskgraph/taskgraph.js
type: application/javascript
module-type: startup
Task graph
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "taskgraph";
exports.after = ["load-modules"];
exports.synchronous = true;
exports.startup = function() {
// SOMETHING LIKE THIS
UNKNOWN.addEventListener("tm-delete-tiddler", function(event) {
console.log("deleted");
};
}
})();
Looking at https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/syncer.js#L36 I see that you need to register an event listener with the wiki object:
$tw.wiki.addEventListener("change",function(changes) {...});
Glad you like my plugins. I was in a similar situation that you are currently when I develop them: I use TW a lot and I missed those kind of features.
I discovered that the navigator widget is instantiated on PageTemplate, that's why it is capturing events and mine not. I get my inspiration from the fieldmanglerWidget which mades me suspect.
If you are using vis.js take a look at this:Maybe can speed up your work.
In my opinion, this should be released as a standalone plugin rather than a pull request to the core. That way I will be able to enjoy it earlier, and I really want to try it out!!