mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-09 10:50:42 +00:00
Autoselect for ShareDialog
This commit is contained in:
parent
24feec3bc4
commit
e06041bfcb
12
frontend/src/share-dialog-autoselect.js
Normal file
12
frontend/src/share-dialog-autoselect.js
Normal file
@ -0,0 +1,12 @@
|
||||
window.autoSelect = (className) => {
|
||||
let el = document.getElementsByClassName(className);
|
||||
Array.from(el).forEach(field => {
|
||||
field.addEventListener('focus', event => {
|
||||
let e = event.target.shadowRoot.querySelector('input');
|
||||
if (!e) {
|
||||
e = event.target.shadowRoot.querySelector('textArea');
|
||||
}
|
||||
e.setSelectionRange(0, e.value.length);
|
||||
});
|
||||
});
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package edu.kit.typicalc.view.content.typeinferencecontent;
|
||||
|
||||
import com.vaadin.flow.component.UI;
|
||||
import com.vaadin.flow.component.dependency.CssImport;
|
||||
import com.vaadin.flow.component.dependency.JsModule;
|
||||
import com.vaadin.flow.component.dialog.Dialog;
|
||||
import com.vaadin.flow.component.html.H3;
|
||||
import com.vaadin.flow.component.icon.Icon;
|
||||
@ -15,6 +17,7 @@ import com.vaadin.flow.i18n.LocaleChangeObserver;
|
||||
/**
|
||||
* Contains GUI elements to extract the URL and LaTeX code of the currently shown proof tree.
|
||||
*/
|
||||
@JsModule("./src/share-dialog-autoselect.js")
|
||||
@CssImport("./styles/view/share-dialog.css")
|
||||
public class ShareDialog extends Dialog implements LocaleChangeObserver {
|
||||
|
||||
@ -62,6 +65,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver {
|
||||
packageArea.setClassName(FIELD_CLASS);
|
||||
latexArea.setValue(latexCode);
|
||||
latexArea.setClassName(FIELD_CLASS);
|
||||
UI.getCurrent().getPage().executeJs("window.autoSelect($0)", FIELD_CLASS);
|
||||
|
||||
layout.add(urlField, packageArea, latexArea);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user