mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-02 12:19:11 +00:00
Starting to get the behaviour of the search popup more correct
This commit is contained in:
parent
42d4be3f20
commit
81a565e608
@ -15,10 +15,11 @@ Edit macro for editting fields and tiddlers
|
||||
exports.info = {
|
||||
name: "edit",
|
||||
params: {
|
||||
field: {byPos: 0, type: "text"},
|
||||
tiddler: {byName: true, type: "tiddler"},
|
||||
field: {byPos: 0, type: "text"},
|
||||
type: {byName: true, type: "text"},
|
||||
"default": {byName: true, type: "text"}
|
||||
"default": {byName: true, type: "text"},
|
||||
requireFocus: {byName: true, type: "text"}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -81,28 +81,34 @@ TextEditor.prototype.getChild = function() {
|
||||
break;
|
||||
}
|
||||
// Wrap the editor control in a div
|
||||
return $tw.Tree.Element(this.macroNode.isBlock ? "div" : "span",{},[$tw.Tree.Element(tagName,attributes,content)],{
|
||||
events: ["focus","keyup"],
|
||||
return $tw.Tree.Element(this.macroNode.isBlock ? "div" : "span",{},[$tw.Tree.Element(tagName,attributes,content,{
|
||||
events: ["focus","blur","keyup"],
|
||||
eventHandler: this
|
||||
});
|
||||
})]);
|
||||
};
|
||||
|
||||
TextEditor.prototype.handleEvent = function(event) {
|
||||
console.log("event type",event.type);
|
||||
// Get the value of the field if it might have changed
|
||||
if("keyup".split(" ").indexOf(event.type) !== -1) {
|
||||
if("keyup focus blur".split(" ").indexOf(event.type) !== -1) {
|
||||
this.saveChanges();
|
||||
}
|
||||
// Whatever the event, fix the height of the textarea if required
|
||||
// Fix the height of the textarea if required
|
||||
if("keyup focus".split(" ").indexOf(event.type) !== -1) {
|
||||
var self = this;
|
||||
window.setTimeout(function() {
|
||||
self.fixHeight();
|
||||
},5);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
TextEditor.prototype.saveChanges = function() {
|
||||
var text = this.macroNode.child.children[0].domNode.value,
|
||||
tiddler = this.macroNode.wiki.getTiddler(this.macroNode.editTiddler);
|
||||
if(this.macroNode.params.requireFocus === "yes" && document.activeElement !== this.macroNode.child.children[0].domNode) {
|
||||
text = this.macroNode.params["default"] || "";
|
||||
}
|
||||
if(!tiddler) {
|
||||
tiddler = new $tw.Tiddler({title: this.macroNode.editTiddler});
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ title: $:/templates/PageTemplate
|
||||
* [[Docs]]
|
||||
*{{divider-vertical}}
|
||||
|
||||
<!-- Search box -->
|
||||
<form class="form-search">
|
||||
|
||||
{{search-query{
|
||||
<<edit tiddler:[[$:/search/text]] type:search>>
|
||||
<<edit tiddler:[[$:/search/text]] type:search requireFocus:yes>>
|
||||
}}}
|
||||
|
||||
<div style="position:absolute; z-index:1000;">
|
||||
|
Loading…
Reference in New Issue
Block a user