-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a2e745
commit 207f10f
Showing
8 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
jpro-mdfx/src/main/java/one/jpro/platform/mdfx/extensions/ImageExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package one.jpro.platform.mdfx.extensions; | ||
|
||
import javafx.scene.Node; | ||
import one.jpro.platform.mdfx.MarkdownView; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
/** | ||
* An extension for the MarkdownView. | ||
* The scheme is used to identify the extension in the markdown string. | ||
* | ||
* An scheme of null is used to identify the default image extension. | ||
*/ | ||
public class ImageExtension { | ||
String scheme; | ||
BiFunction<String, MarkdownView, Node> function; | ||
|
||
public ImageExtension(String scheme, BiFunction<String, MarkdownView, Node> function) { | ||
this.scheme = scheme; | ||
this.function = function; | ||
} | ||
|
||
public String getScheme() { | ||
return scheme; | ||
} | ||
|
||
public BiFunction<String, MarkdownView, Node> getFunction() { | ||
return function; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
jpro-mdfx/src/main/java/one/jpro/platform/mdfx/extensions/YoutubeExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package one.jpro.platform.mdfx.extensions; | ||
|
||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.VBox; | ||
import one.jpro.platform.youtube.YoutubeNode; | ||
|
||
public class YoutubeExtension { | ||
|
||
public static ImageExtension create() { | ||
return new ImageExtension( | ||
"youtube", (url, view) -> { | ||
var uri = java.net.URI.create(url); | ||
var schemeSpecificPart = uri.getSchemeSpecificPart(); | ||
var node = new VBox(new Label(""), new YoutubeNode(schemeSpecificPart)); | ||
node.prefWidthProperty().bind(view.widthProperty()); | ||
node.maxWidthProperty().bind(view.widthProperty()); | ||
return node; | ||
}); | ||
} | ||
} |