MDL-44225 atto_equation: Set focus after adding equation from toolbar
This commit is contained in:
committed by
Damyon Wiese
parent
a279604330
commit
9ee8a359c9
+14
-1
@@ -322,8 +322,21 @@ M.atto_equation = M.atto_equation || {
|
||||
value = value.substring(0, this.lastcursorpos) + tex + value.substring(this.lastcursorpos, value.length);
|
||||
|
||||
input.set('value', value);
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this.lastcursorpos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
} else if (typeof realInput.createTextRange !== "undefined") {
|
||||
// Legacy browsers (IE<=9) use createTextRange().
|
||||
var range = realInput.createTextRange();
|
||||
range.moveToPoint(focusPoint);
|
||||
range.select();
|
||||
}
|
||||
// Focus must be set before updating the preview for the cursor box to be in the correct location.
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+14
-1
@@ -322,8 +322,21 @@ M.atto_equation = M.atto_equation || {
|
||||
value = value.substring(0, this.lastcursorpos) + tex + value.substring(this.lastcursorpos, value.length);
|
||||
|
||||
input.set('value', value);
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this.lastcursorpos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
} else if (typeof realInput.createTextRange !== "undefined") {
|
||||
// Legacy browsers (IE<=9) use createTextRange().
|
||||
var range = realInput.createTextRange();
|
||||
range.moveToPoint(focusPoint);
|
||||
range.select();
|
||||
}
|
||||
// Focus must be set before updating the preview for the cursor box to be in the correct location.
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -320,8 +320,21 @@ M.atto_equation = M.atto_equation || {
|
||||
value = value.substring(0, this.lastcursorpos) + tex + value.substring(this.lastcursorpos, value.length);
|
||||
|
||||
input.set('value', value);
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this.lastcursorpos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
} else if (typeof realInput.createTextRange !== "undefined") {
|
||||
// Legacy browsers (IE<=9) use createTextRange().
|
||||
var range = realInput.createTextRange();
|
||||
range.moveToPoint(focusPoint);
|
||||
range.select();
|
||||
}
|
||||
// Focus must be set before updating the preview for the cursor box to be in the correct location.
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user