mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-08 23:20:03 +00:00
Extended edit macro
Now it accepts a default value for the field if the tiddler doesn't exist. It also allows the forcing of a single line input control
This commit is contained in:
parent
6e86de5652
commit
36ff53f40b
@ -16,7 +16,9 @@ exports.info = {
|
|||||||
name: "edit",
|
name: "edit",
|
||||||
params: {
|
params: {
|
||||||
field: {byPos: 0, type: "text"},
|
field: {byPos: 0, type: "text"},
|
||||||
tiddler: {byName: true, type: "tiddler"}
|
tiddler: {byName: true, type: "tiddler"},
|
||||||
|
singleline: {byName: true, type: "text"},
|
||||||
|
"default": {byName: true, type: "text"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,16 +30,20 @@ TextEditor.prototype.getEditText = function() {
|
|||||||
value = tiddler.getFieldString(this.macroNode.editField);
|
value = tiddler.getFieldString(this.macroNode.editField);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, we need to construct a default value for the editor
|
// Otherwise, we need to construct a default value for the editor
|
||||||
switch(this.macroNode.editField) {
|
if(this.macroNode.hasParameter("default")) {
|
||||||
case "text":
|
value = this.macroNode.params["default"];
|
||||||
value = "Type the text for the tiddler '" + this.macroNode.editTiddler + "'";
|
} else {
|
||||||
break;
|
switch(this.macroNode.editField) {
|
||||||
case "title":
|
case "text":
|
||||||
value = this.macroNode.editTiddler;
|
value = "Type the text for the tiddler '" + this.macroNode.editTiddler + "'";
|
||||||
break;
|
break;
|
||||||
default:
|
case "title":
|
||||||
value = "";
|
value = this.macroNode.editTiddler;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
value = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {tiddler: tiddler, field: this.macroNode.editField, value: value};
|
return {tiddler: tiddler, field: this.macroNode.editField, value: value};
|
||||||
@ -53,16 +57,16 @@ TextEditor.prototype.getChild = function() {
|
|||||||
tagName,
|
tagName,
|
||||||
content = [];
|
content = [];
|
||||||
// Make a textarea for text fields and an input box for other fields
|
// Make a textarea for text fields and an input box for other fields
|
||||||
if(edit.field === "text") {
|
if(edit.field !== "text" || this.macroNode.hasParameter("singleline")) {
|
||||||
tagName = "textarea";
|
|
||||||
content.push($tw.Tree.Text(edit.value));
|
|
||||||
} else {
|
|
||||||
tagName = "input";
|
tagName = "input";
|
||||||
attributes.type = "text";
|
attributes.type = "text";
|
||||||
attributes.value = edit.value;
|
attributes.value = edit.value;
|
||||||
|
} else {
|
||||||
|
tagName = "textarea";
|
||||||
|
content.push($tw.Tree.Text(edit.value));
|
||||||
}
|
}
|
||||||
// Wrap the editor control in a div
|
// Wrap the editor control in a div
|
||||||
return $tw.Tree.Element("div",{},[$tw.Tree.Element(tagName,attributes,content)],{
|
return $tw.Tree.Element(this.macroNode.isBlock ? "div" : "span",{},[$tw.Tree.Element(tagName,attributes,content)],{
|
||||||
events: ["focus","keyup"],
|
events: ["focus","keyup"],
|
||||||
eventHandler: this
|
eventHandler: this
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user