mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-09 10:50:42 +00:00
Merge branch 'master' of https://git.scc.kit.edu/pse-typinferenz/typicalc
This commit is contained in:
commit
7a28facd83
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);
|
||||
});
|
||||
});
|
||||
}
|
@ -22,16 +22,16 @@ function listener(area) {
|
||||
var value = parseBack(area.value);
|
||||
var start = area.selectionStart;
|
||||
var end = area.selectionEnd;
|
||||
if (value.startsWith('t') && isNumeric(value.substr(1, value.length - 1))) {
|
||||
area.value = value.replace('t', '\u03C4');
|
||||
area.value = area.value.replace(/[0123456789]/g, toUnicode);
|
||||
} else {
|
||||
area.value = value;
|
||||
}
|
||||
// ignore brackets, allow '>' or spaces in front and '-' or spaces at the end of string
|
||||
area.value = value.replace(/(^|\s+|\(|\)|>)t[0-9]+(?=\s+|\)|\(|\-|$)/ig, replacer);
|
||||
area.selectionStart = start;
|
||||
area.selectionEnd = end;
|
||||
}
|
||||
|
||||
function replacer(value) {
|
||||
value = value.replace('t', '\u03C4');
|
||||
return value.replace(/[0123456789]/g, toUnicode);
|
||||
}
|
||||
|
||||
function toUnicode(number) {
|
||||
return subscripted[number];
|
||||
@ -44,10 +44,6 @@ function toNumber(unicode) {
|
||||
}
|
||||
|
||||
function parseBack(value) {
|
||||
value = value.replace('\u03C4', 't');
|
||||
value = value.replaceAll('\u03C4', 't');
|
||||
return value.replace(/./g, toNumber);
|
||||
}
|
||||
|
||||
function isNumeric(value) {
|
||||
return /^\d+$/.test(value);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#startPage-Heading {
|
||||
margin-top: 50px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 50px;
|
||||
}
|
||||
@ -26,11 +26,6 @@
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#controlPanel {
|
||||
margin-top: auto;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
#startPage {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
|
@ -42,6 +42,8 @@ public class ControlPanel extends HorizontalLayout implements LocaleChangeObserv
|
||||
previousStep = new Button(new Icon(VaadinIcon.ANGLE_LEFT), evt -> view.previousStepButton());
|
||||
previousStep.setId(PREVIOUS_STEP_ID);
|
||||
share = new Button(new Icon(VaadinIcon.CONNECT), evt -> view.shareButton());
|
||||
share.getStyle().set("margin-left", "auto");
|
||||
lastStep.getStyle().set("margin-right", "auto");
|
||||
|
||||
add(share, firstStep, previousStep, nextStep, lastStep);
|
||||
}
|
||||
|
@ -5,12 +5,7 @@ import com.flowingcode.vaadin.addons.carousel.Slide;
|
||||
import com.vaadin.flow.component.Text;
|
||||
import com.vaadin.flow.component.dependency.CssImport;
|
||||
import com.vaadin.flow.component.dependency.JsModule;
|
||||
import com.vaadin.flow.component.html.Anchor;
|
||||
import com.vaadin.flow.component.html.Div;
|
||||
import com.vaadin.flow.component.html.H1;
|
||||
import com.vaadin.flow.component.html.Hr;
|
||||
import com.vaadin.flow.component.html.Paragraph;
|
||||
import com.vaadin.flow.component.html.Span;
|
||||
import com.vaadin.flow.component.html.*;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.component.progressbar.ProgressBar;
|
||||
import com.vaadin.flow.i18n.LocaleChangeEvent;
|
||||
@ -53,6 +48,7 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L
|
||||
* Fills the view with content.
|
||||
*/
|
||||
public StartPageView() {
|
||||
VerticalLayout content = new VerticalLayout();
|
||||
ControlPanel controlPanel = new ControlPanel(this);
|
||||
controlPanel.setId(CONTROL_PANEL_ID);
|
||||
controlPanel.setEnabledShareButton(false);
|
||||
@ -81,8 +77,17 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L
|
||||
slideProgress = new ProgressBar(slideShow.getStartPosition(), slideShow.getSlides().length - 1);
|
||||
slideProgress.setId(SLIDE_PROGRESS_ID);
|
||||
|
||||
add(heading, line1, textContainer, slideProgress, slideShow, line2, controlPanel);
|
||||
content.setAlignItems(Alignment.CENTER);
|
||||
content.add(heading, line1, textContainer, slideProgress, slideShow, line2);
|
||||
setId(START_PAGE_ID);
|
||||
|
||||
Footer footer = new Footer(controlPanel);
|
||||
footer.setWidthFull();
|
||||
footer.getStyle().set("position", "sticky");
|
||||
footer.getStyle().set("bottom", "1em");
|
||||
footer.getStyle().set("background-color", "white");
|
||||
content.setWidthFull();
|
||||
add(content, footer);
|
||||
}
|
||||
|
||||
private Carousel createScenarioCarousel() {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.vaadin.flow.component.UI;
|
||||
import com.vaadin.flow.component.dependency.CssImport;
|
||||
import com.vaadin.flow.component.dependency.JavaScript;
|
||||
import com.vaadin.flow.component.html.Div;
|
||||
import com.vaadin.flow.component.orderedlayout.Scroller;
|
||||
import com.vaadin.flow.component.html.Footer;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.i18n.LocaleChangeEvent;
|
||||
import com.vaadin.flow.i18n.LocaleChangeObserver;
|
||||
@ -33,7 +33,6 @@ public class TypeInferenceView extends VerticalLayout
|
||||
* Route of this view.
|
||||
*/
|
||||
public static final String ROUTE = "infer";
|
||||
private static final String SCROLLER_ID = "scroller";
|
||||
private static final String CONTENT_ID = "content";
|
||||
private static final String ID = "type-inference-view";
|
||||
|
||||
@ -64,14 +63,17 @@ public class TypeInferenceView extends VerticalLayout
|
||||
content = new Div();
|
||||
content.setId(CONTENT_ID);
|
||||
controlPanel = new ControlPanel(this);
|
||||
Scroller scroller = new Scroller(content);
|
||||
scroller.setId(SCROLLER_ID);
|
||||
scroller.setScrollDirection(Scroller.ScrollDirection.BOTH);
|
||||
add(scroller, controlPanel);
|
||||
treeNumbers = lc.getTreeNumbers();
|
||||
setContent();
|
||||
controlPanel.setEnabledFirstStep(false);
|
||||
controlPanel.setEnabledPreviousStep(false);
|
||||
|
||||
Footer footer = new Footer(controlPanel);
|
||||
footer.getStyle().set("position", "sticky");
|
||||
footer.getStyle().set("bottom", "1em");
|
||||
content.getStyle().set("overflow", "auto");
|
||||
content.setWidthFull();
|
||||
add(content, footer);
|
||||
}
|
||||
|
||||
private void setContent() {
|
||||
|
Loading…
Reference in New Issue
Block a user