mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-01-01 06:41:18 -08:00
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
45 lines
900 B
JavaScript
45 lines
900 B
JavaScript
/*\
|
|
title: $:/core/modules/macros/image.js
|
|
type: application/javascript
|
|
module-type: macro
|
|
|
|
Image macro for displaying images
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
exports.info = {
|
|
name: "image",
|
|
params: {
|
|
src: {byName: "default", type: "tiddler"},
|
|
text: {byName: true, type: "text"},
|
|
alignment: {byName: true, type: "text"}
|
|
}
|
|
};
|
|
|
|
exports.executeMacro = function() {
|
|
if(this.wiki.tiddlerExists(this.params.src)) {
|
|
var imageTree = this.wiki.parseTiddler(this.params.src).tree,
|
|
cloneImage = imageTree[0].clone();
|
|
if(this.params.text) {
|
|
return $tw.Tree.Element("div",{
|
|
alt: this.params.text,
|
|
title: this.params.text
|
|
},[cloneImage]);
|
|
} else {
|
|
return cloneImage;
|
|
}
|
|
} else {
|
|
return $tw.Tree.Element("img",{
|
|
src: this.params.src,
|
|
alt: this.params.text,
|
|
title: this.params.text
|
|
});
|
|
}
|
|
};
|
|
|
|
})();
|