Well, I am trying to create help dialog using markdown and to include download link to some template. However then I press on link vaadin acts as if this link was not created. In general it would be even better to use target=“_blank” on the link, but I was not able to do that. For below example to work - please put any test.xlsx file in your src\main\resources\META-INF\resources\assets. Are were any workarounds? Maybe some improvements on framework level?
@Component
@Scope("prototype")
@Route(value = "md_test")
@AnonymousAllowed
public class MarkdownTest extends VerticalLayout {
public MarkdownTest() {
add(new Button("Test", e -> {
new TestDialog(mdText).open();
}));
}
class TestDialog extends Dialog {
public TestDialog(String markdownText) {
this.add(new Markdown(markdownText));
this.setCloseOnEsc(true);
this.setCloseOnOutsideClick(true);
this.setWidth("700px");
this.setHeight("500px");
}
}
private static final String mdText = """
## Test
- <a href="http://localhost:8080/assets/test.xlsx" target="_blank">test1</a>
- [test2](http://localhost:8080/assets/test.xlsx)
- [test3 Kmarkdown](http://localhost:8080/assets/test.xlsx){:target="_blank"}
""";
}
Yes, it is within application. I added router-ignore however behaviour didnt changed. Also target=“_blank” is not working, because it was ignored by framework. Please check screen shot.
I added rel=“noopener” it passed to generated HTML <a rel="noopener" href="http://localhost:8080/assets/test.xlsx">test2</a> however the behaviour still the same. It is not working as expected