Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Allow direct use of images

Author DaveJarvis <email>
Date 2020-07-05 11:29:37 GMT-0700
Commit 5b6695bd9bf1ab5de9bd8b7b2c30fb8c2f21a112
Parent ebd0670
Delta 27 lines added, 8 lines removed, 19-line increase
CREDITS.md
* Mikael Grev: [MigLayout](http://www.miglayout.com/)
* Tom Eugelink: [MigPane](https://github.com/mikaelgrev/miglayout/blob/master/javafx/src/main/java/org/tbee/javafx/scene/layout/fxml/MigPane.java)
-* Vladimir Schneider: [flexmark](https://github.com/vsch/flexmark-java)
* Jens Deters: [FontAwesomeFX](https://bitbucket.org/Jerady/fontawesomefx)
-* Shy Shalom, Kohei Taketa: [juniversalchardet](https://github.com/takscape/juniversalchardet)
+* Dieter Holz, [PreferencesFX](https://github.com/dlsc-software-consulting-gmbh/PreferencesFX)
* David Croft, [File Preferences](http://www.davidc.net/programming/java/java-preferences-using-file-backing-store)
* Alex Bertram, [Renjin](https://www.renjin.org/)
+* Vladimir Schneider: [flexmark](https://github.com/vsch/flexmark-java)
* Michael Kay, [XSLT Processor](http://www.saxonica.com/)
+* Shy Shalom, Kohei Taketa: [juniversalchardet](https://github.com/takscape/juniversalchardet)
src/main/java/com/scrivenvar/preview/HTMLPreviewPane.java
@Override
public void componentResized( final ComponentEvent e ) {
- // Scaling a bit below the full width prevents the horizontal scrollbar
- // from appearing.
- final int width = (int) (e.getComponent().getWidth() * .95);
- HTMLPreviewPane.this.mImageLoader.widthProperty().set( width );
+ setWidth( e );
}
@Override
- public void componentMoved( final ComponentEvent e ) {
+ public void componentShown( final ComponentEvent e ) {
+ setWidth( e );
}
@Override
- public void componentShown( final ComponentEvent e ) {
+ public void componentMoved( final ComponentEvent e ) {
}
@Override
public void componentHidden( final ComponentEvent e ) {
+ }
+
+ /**
+ * Sets the width of the {@link HTMLPreviewPane} so that images can be
+ * scaled to fit. The scale factor is adjusted a bit below the full width
+ * to prevent the horizontal scrollbar from appearing.
+ *
+ * @param e The component that defines the image scaling width.
+ */
+ private void setWidth( final ComponentEvent e ) {
+ final int width = (int) (e.getComponent().getWidth() * .95);
+ HTMLPreviewPane.this.mImageLoader.widthProperty().set( width );
}
}
src/main/java/com/scrivenvar/processors/markdown/ImageLinkExtension.java
try {
+ // If the direct file name exists, then use it directly.
+ if( Path.of( url ).toFile().exists() ) {
+ return link.withStatus( LinkStatus.VALID ).withUrl( url );
+ }
+ } catch( final Exception ignored ) {
+ }
+
+ try {
final Path imagePrefix = getImagePrefix().toPath();