Send position x,y of cursor into an ACE editors on POST form
This commit is contained in:
parent
b69beb98b8
commit
e0377d788c
@ -287,6 +287,8 @@ class DolEditor
|
|||||||
$out .= '">';
|
$out .= '">';
|
||||||
$out .= htmlspecialchars($this->content);
|
$out .= htmlspecialchars($this->content);
|
||||||
$out .= '</pre>';
|
$out .= '</pre>';
|
||||||
|
$out .= '<input type="hidden" id="'.$this->htmlname.'_x" name="'.$this->htmlname.'_x">';
|
||||||
|
$out .= '<input type="hidden" id="'.$this->htmlname.'_y" name="'.$this->htmlname.'_y">';
|
||||||
$out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">';
|
$out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">';
|
||||||
$out .= htmlspecialchars($this->content);
|
$out .= htmlspecialchars($this->content);
|
||||||
$out .= '</textarea>';
|
$out .= '</textarea>';
|
||||||
@ -315,11 +317,23 @@ class DolEditor
|
|||||||
$out .= 'jQuery(document).ready(function() {
|
$out .= 'jQuery(document).ready(function() {
|
||||||
jQuery(".buttonforacesave").click(function() {
|
jQuery(".buttonforacesave").click(function() {
|
||||||
console.log("We click on savefile button for component '.$this->htmlname.'");
|
console.log("We click on savefile button for component '.$this->htmlname.'");
|
||||||
var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid")
|
var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid");
|
||||||
console.log(aceEditor.getSession().getValue());
|
if (aceEditor) {
|
||||||
jQuery("#'.$this->htmlname.'").val(aceEditor.getSession().getValue());
|
var cursorPos = aceEditor.getCursorPosition();
|
||||||
/*if (jQuery("#'.$this->htmlname.'").html().length > 0) return true;
|
console.log(cursorPos);
|
||||||
else return false;*/
|
if (cursorPos) {
|
||||||
|
jQuery("#'.$this->htmlname.'_x").val(cursorPos.row);
|
||||||
|
jQuery("#'.$this->htmlname.'_y").val(cursorPos.column);
|
||||||
|
}
|
||||||
|
//console.log(aceEditor.getSession().getValue());
|
||||||
|
// Inject content of editor into the original HTML field.
|
||||||
|
jQuery("#'.$this->htmlname.'").val(aceEditor.getSession().getValue());
|
||||||
|
/*if (jQuery("#'.$this->htmlname.'").html().length > 0) return true;
|
||||||
|
else return false;*/
|
||||||
|
} else {
|
||||||
|
console.log("Failed to retrieve js object ACE from its name");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})';
|
})';
|
||||||
$out .= '</script>'."\n";
|
$out .= '</script>'."\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user