1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-08 02:49:56 +00:00
TiddlyWiki5/js/macros/edit.js

54 lines
1.0 KiB
JavaScript
Raw Normal View History

2012-03-29 14:32:36 +00:00
/*\
title: js/macros/edit.js
\*/
(function(){
/*jslint node: true */
"use strict";
var Renderer = require("../Renderer.js").Renderer,
Dependencies = require("../Dependencies.js").Dependencies,
utils = require("../Utils.js");
exports.macro = {
name: "edit",
params: {
field: {byPos: 0, type: "text"}
},
execute: function() {
var tiddler = this.store.getTiddler(this.tiddlerTitle),
field = this.hasParameter("field") ? this.params.field : "title",
value;
if(tiddler) {
value = tiddler[field];
} else {
switch(field) {
case "text":
value = "Type the text for the tiddler '" + this.tiddlerTitle + "'";
break;
case "title":
value = this.tiddlerTitle;
break;
default:
value = "";
break;
}
}
var type = "div";
switch(field) {
case "text":
type = "pre";
break;
}
2012-03-29 14:32:36 +00:00
var attributes = {
"contenteditable": true,
"class": ["tw-edit-field"]
2012-03-29 14:33:47 +00:00
};
return [Renderer.ElementNode(type,attributes,[Renderer.TextNode(value)])];
2012-03-29 14:32:36 +00:00
}
};
})();