Skip to content

Commit 99a6c3d

Browse files
author
Yubo-Cao
committed
Improve whitespace and MarkdownTextflow's coping experience
1 parent abd52c0 commit 99a6c3d

File tree

5 files changed

+371
-114
lines changed

5 files changed

+371
-114
lines changed

jabgui/src/main/java/module-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131

132132
requires flexmark;
133133
requires flexmark.html2md.converter;
134-
requires flexmark.util.data;
135134
requires flexmark.util.ast;
135+
requires flexmark.util.data;
136136

137137
// requires com.h2database.mvstore;
138138

@@ -189,5 +189,6 @@
189189
// requires mslinks;
190190
requires org.antlr.antlr4.runtime;
191191
requires org.libreoffice.uno;
192+
requires flexmark.ext.tables;
192193
// endregion
193194
}

jabgui/src/main/java/org/jabref/gui/ai/components/aichat/chatmessage/ChatMessageComponent.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,23 @@ public class ChatMessageComponent extends HBox {
3232
private final ObjectProperty<ChatMessage> chatMessage = new SimpleObjectProperty<>();
3333
private final ObjectProperty<Consumer<ChatMessageComponent>> onDelete = new SimpleObjectProperty<>();
3434

35-
@FXML private HBox wrapperHBox;
36-
@FXML private VBox vBox;
37-
@FXML private Label sourceLabel;
38-
@FXML private Pane markdownContentPane;
39-
@FXML private VBox buttonsVBox;
35+
@FXML
36+
private HBox wrapperHBox;
37+
@FXML
38+
private VBox vBox;
39+
@FXML
40+
private Label sourceLabel;
41+
@FXML
42+
private Pane markdownContentPane;
43+
@FXML
44+
private VBox buttonsVBox;
4045

4146
private MarkdownTextFlow markdownTextFlow;
4247

4348
public ChatMessageComponent() {
4449
ViewLoader.view(this)
45-
.root(this)
46-
.load();
50+
.root(this)
51+
.load();
4752

4853
chatMessage.addListener((_, _, newValue) -> {
4954
if (newValue != null) {
@@ -107,9 +112,14 @@ private void initialize() {
107112
markdownContentPane.getChildren().add(markdownTextFlow);
108113
markdownContentPane.minHeightProperty().bind(markdownTextFlow.heightProperty());
109114
markdownContentPane.prefHeightProperty().bind(markdownTextFlow.heightProperty());
110-
NumberBinding maxUsableWidth = Bindings.createDoubleBinding(() -> getScene().getWidth() - 20, sceneProperty(), getScene().widthProperty());
111-
markdownTextFlow.maxWidthProperty().bind(maxUsableWidth);
112-
wrapperHBox.maxWidthProperty().bind(maxUsableWidth);
115+
this.sceneProperty().addListener((_, _, scene) -> {
116+
if (scene == null) {
117+
return;
118+
}
119+
NumberBinding maxUsableWidth = Bindings.createDoubleBinding(() -> getScene().getWidth() - 20, sceneProperty(), getScene().widthProperty());
120+
markdownTextFlow.maxWidthProperty().bind(maxUsableWidth);
121+
wrapperHBox.maxWidthProperty().bind(maxUsableWidth);
122+
});
113123
setMaxWidth(Double.MAX_VALUE);
114124
HBox.setHgrow(this, Priority.ALWAYS);
115125
}

0 commit comments

Comments
 (0)