mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-31 11:19:10 +00:00
Mo' comments
This commit is contained in:
parent
caf32d9598
commit
0830cdac73
@ -19,12 +19,15 @@ function TextEditor(macroNode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextEditor.prototype.getChild = function() {
|
TextEditor.prototype.getChild = function() {
|
||||||
|
// Get the current tiddler and the field name
|
||||||
var tiddler = this.macroNode.wiki.getTiddler(this.macroNode.tiddlerTitle),
|
var tiddler = this.macroNode.wiki.getTiddler(this.macroNode.tiddlerTitle),
|
||||||
field = this.macroNode.hasParameter("field") ? this.macroNode.params.field : "title",
|
field = this.macroNode.hasParameter("field") ? this.macroNode.params.field : "title",
|
||||||
value;
|
value;
|
||||||
|
// If we've got a tiddler, the value to display is the field string value
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
value = tiddler.getFieldString(field);
|
value = tiddler.getFieldString(field);
|
||||||
} else {
|
} else {
|
||||||
|
// Otherwise, we need to construct a default value for the editor
|
||||||
switch(field) {
|
switch(field) {
|
||||||
case "text":
|
case "text":
|
||||||
value = "Type the text for the tiddler '" + this.macroNode.tiddlerTitle + "'";
|
value = "Type the text for the tiddler '" + this.macroNode.tiddlerTitle + "'";
|
||||||
@ -42,6 +45,7 @@ TextEditor.prototype.getChild = function() {
|
|||||||
},
|
},
|
||||||
tagName,
|
tagName,
|
||||||
content = [];
|
content = [];
|
||||||
|
// Make a textarea for text fields and an input box for other fields
|
||||||
if(field === "text") {
|
if(field === "text") {
|
||||||
tagName = "textarea";
|
tagName = "textarea";
|
||||||
content.push($tw.Tree.Text(value));
|
content.push($tw.Tree.Text(value));
|
||||||
@ -50,6 +54,7 @@ TextEditor.prototype.getChild = function() {
|
|||||||
attributes.type = "text";
|
attributes.type = "text";
|
||||||
attributes.value = value;
|
attributes.value = value;
|
||||||
}
|
}
|
||||||
|
// Wrap the editor control in a div
|
||||||
return $tw.Tree.Element("div",{},[$tw.Tree.Element(tagName,attributes,content)]);
|
return $tw.Tree.Element("div",{},[$tw.Tree.Element(tagName,attributes,content)]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user