summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-04-19 12:51:12 +0200
committerSzymon Kłos <eszkadev@gmail.com>2022-04-23 10:58:55 +0200
commitabe204adc7d649552e4146b23cd86af524880a8d (patch)
tree5fcef4f3b5c4cfa73ffcf034d39cf57cd81e46df
parentcypress: fix after formulabar conversion to jsdialogs (diff)
downloadonline-abe204adc7d649552e4146b23cd86af524880a8d.tar.gz
online-abe204adc7d649552e4146b23cd86af524880a8d.zip
jsdialog: apply selection in textarea
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com> Change-Id: I9856002b7f72ce8db9f6d2116871804fc4763f3b
-rw-r--r--browser/src/control/Control.JSDialogBuilder.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/browser/src/control/Control.JSDialogBuilder.js b/browser/src/control/Control.JSDialogBuilder.js
index 28718eefa9..cd6e2a1bf0 100644
--- a/browser/src/control/Control.JSDialogBuilder.js
+++ b/browser/src/control/Control.JSDialogBuilder.js
@@ -1425,6 +1425,9 @@ L.Control.JSDialogBuilder = L.Control.extend({
});
edit.addEventListener('keydown', function(event) {
+ if (edit.disabled)
+ return;
+
if (data.rawKeyEvents) {
if (event.key === 'Enter') {
builder.callback('edit', 'keypress', edit, UNOKey.RETURN, builder);
@@ -1449,6 +1452,9 @@ L.Control.JSDialogBuilder = L.Control.extend({
});
edit.addEventListener('keypress', function(event) {
+ if (edit.disabled)
+ return;
+
if (data.rawKeyEvents) {
if (event.key === 'Enter' ||
event.key === 'Escape' ||
@@ -1470,6 +1476,8 @@ L.Control.JSDialogBuilder = L.Control.extend({
if (data.rawKeyEvents) {
'select click'.split(' ').forEach(function(eventName) {
edit.addEventListener(eventName, function(event) {
+ if (edit.disabled)
+ return;
var selection = event.target.selectionStart + ';' + event.target.selectionEnd;
builder.callback('edit', 'textselection', edit, selection, builder);
});
@@ -3044,6 +3052,11 @@ L.Control.JSDialogBuilder = L.Control.extend({
case 'setText':
control.value = this._cleanText(data.text);
+ if (data.selection) {
+ var selection = data.selection.split(';');
+ if (selection.length === 2)
+ control.setSelectionRange(parseInt(selection[0]), parseInt(selection[1]));
+ }
break;
default: