1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-09 03:53:00 +00:00

Refactored macro mechanism

Now there is now longer a dummy DOM element corresponding to the macro
itself. Instead, macros must create a single element child. This allows
us to more easily fit Bootstrap's requirements for HTML layout (eg,
that problem with links in navbars not being recognised). The
refactoring isn't complete, there are still a few bugs to chase down
This commit is contained in:
Jeremy Ruston
2012-06-09 18:36:32 +01:00
parent 121d491af2
commit 04e91245cb
22 changed files with 134 additions and 183 deletions

View File

@@ -35,11 +35,9 @@ exports.executeMacro = function() {
}
this.editor = new Editor(this);
// Call the editor to generate the child nodes
var children = this.editor.getChildren();
for(var t=0; t<children.length; t++) {
children[t].execute(this.parents,this.tiddlerTitle);
}
return children;
var child = this.editor.getChild();
child.execute(this.parents,this.tiddlerTitle);
return child;
};
exports.addEventHandlers = function() {
@@ -60,22 +58,19 @@ exports.refreshInDom = function(changes) {
if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) {
// Only refresh if the editor lets us
if(this.editor.isRefreshable()) {
// Remove the previous children
while(this.domNode.hasChildNodes()) {
this.domNode.removeChild(this.domNode.firstChild);
}
// Execute the new children
// Remove the previous child
var parent = this.child.domNode.parentNode,
nextSibling = this.child.domNode.nextSibling;
parent.removeChild(this.child.domNode);
// Execute the macro
this.execute(this.parents,this.tiddlerTitle);
// Render to the DOM
for(t=0; t<this.children.length; t++) {
this.children[t].renderInDom(this.domNode);
}
this.child.renderInDom(parent,nextSibling);
this.addEventHandlers();
}
} else {
// Refresh any children
for(t=0; t<this.children.length; t++) {
this.children[t].refreshInDom(changes);
}
this.child.refreshInDom(changes);
}
};