diff --git a/.codegraph/.gitignore b/.codegraph/.gitignore new file mode 100644 index 0000000..d20c0fe --- /dev/null +++ b/.codegraph/.gitignore @@ -0,0 +1,5 @@ +# CodeGraph data files — local to each machine, not for committing. +# Ignore everything in .codegraph/ except this file itself, so transient +# files (the database, daemon.pid, sockets, logs) never show up in git. +* +!.gitignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 646e79c..c747721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Migrated the RichTextArea renderer to the JavaFX 27 incubator APIs. +- Baseline for JavaFX is jdk25 and thus this project now requires Java 25. + ## [0.2.0] - 2026-07-22 ### Added diff --git a/README.md b/README.md index b1bcf80..847b7ad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # html-to-node + [![APIdia](https://apidia.net/mvn/org.jabref/html-to-node/badge.svg)](https://apidia.net/mvn/org.jabref/html-to-node) A JavaFX library that renders HTML as plain scene-graph nodes (`TextFlow`, `Text`, `ImageView`), @@ -13,8 +14,8 @@ markup. ## Requirements -- Java 24 or later -- JavaFX 26 or later, provided by the consuming application: `javafx.base`, `javafx.graphics`, +- Java 25 or later +- JavaFX 27 or later, provided by the consuming application: `javafx.base`, `javafx.graphics`, and — for the RichTextArea renderer — `javafx.controls`, `jfx.incubator.input`, and `jfx.incubator.richtext` @@ -30,7 +31,7 @@ Released versions are available from [Maven Central](https://central.sonatype.co ```kotlin dependencies { - implementation("org.jabref:html-to-node:0.2.0") + implementation("org.jabref:html-to-node:0.3.0") } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 7779dbd..5c38774 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "org.jabref" -// -PversionSuffix=PR17 turns 0.3.0-SNAPSHOT into 0.3.0-PR17-SNAPSHOT, so a pull request +// -PversionSuffix=PR17 turns 1.0.0-SNAPSHOT into 1.0.0-PR17-SNAPSHOT, so a pull request // snapshot is identifiable and does not clobber the one built from main version = "0.3.0" + (findProperty("versionSuffix")?.let { "-$it" } ?: "") + "-SNAPSHOT" @@ -23,13 +23,13 @@ java { } tasks.withType().configureEach { - // JavaFX 26 ships Java-24 class files; 24 keeps the library usable one release below JabRef's 25 - options.release = 24 + // JavaFX 27 baseline is now jdk 25 + options.release = 25 options.encoding = "UTF-8" } // JavaFX artifacts are platform-specific; consumers provide their own JavaFX (hence compileOnly) -val javafxVersion = "26.0.1" +val javafxVersion = "27" val jfxPlatform = run { val osName = System.getProperty("os.name").lowercase() val arch = System.getProperty("os.arch").lowercase() @@ -136,7 +136,7 @@ tasks.test { } // Tests of the RichTextArea renderer need the JavaFX toolkit: a display or xvfb-run -val guiTest by tasks.registering(Test::class) { +val guiTest = tasks.register("guiTest") { description = "Runs tests requiring the JavaFX toolkit (tag 'gui'); needs a display or xvfb-run" group = "verification" testClassesDirs = sourceSets.test.get().output.classesDirs diff --git a/src/main/java/org/jabref/htmltonode/rich/RichTextRenderer.java b/src/main/java/org/jabref/htmltonode/rich/RichTextRenderer.java index e0a84de..de1bbe1 100644 --- a/src/main/java/org/jabref/htmltonode/rich/RichTextRenderer.java +++ b/src/main/java/org/jabref/htmltonode/rich/RichTextRenderer.java @@ -34,7 +34,7 @@ public final class RichTextRenderer { /// Character attribute carrying a link target; resolved on mouse click. - public static final StyleAttribute HREF = new StyleAttribute<>("HREF", String.class, false); + public static final StyleAttribute HREF = StyleAttribute.character("HREF", String.class); /// Fallback link color; matches FxRenderer's un-themed link fill. private static final Color LINK_COLOR = Color.web("#0b66c3"); @@ -98,7 +98,7 @@ public static void configure(RichTextArea area, HtmlRenderOptions options) { if (position != null) { // Node segments (embedded images, tables) carry no character attributes, so the // model returns null there — only text runs can hold an HREF. - StyleAttributeMap attributes = area.getModel().getStyleAttributeMap(null, position); + StyleAttributeMap attributes = area.getStyleAttributeMap(position, false); String href = attributes != null ? attributes.get(HREF) : null; if (href != null) { options.linkHandler().accept(href); @@ -114,7 +114,7 @@ public static void configure(RichTextArea area, HtmlRenderOptions options) { /// returns a null attribute map there — only text runs can hold an [#HREF]. Clicking an /// image therefore lands on a null map, which this method tolerates. public static @Nullable String hrefAt(StyledTextModel model, TextPos position) { - StyleAttributeMap attributes = model.getStyleAttributeMap(null, position); + StyleAttributeMap attributes = model.getStyleAttributeMap(null, position, false); return attributes != null ? attributes.get(HREF) : null; } diff --git a/src/test/java/org/jabref/htmltonode/HtmlRichTextAreaTest.java b/src/test/java/org/jabref/htmltonode/HtmlRichTextAreaTest.java index b992bc1..b89b68b 100644 --- a/src/test/java/org/jabref/htmltonode/HtmlRichTextAreaTest.java +++ b/src/test/java/org/jabref/htmltonode/HtmlRichTextAreaTest.java @@ -11,6 +11,7 @@ import org.jabref.htmltonode.rich.HtmlRichTextArea; import org.jabref.htmltonode.rich.RichTextRenderer; +import jfx.incubator.scene.control.richtext.model.StyleAttribute; import jfx.incubator.scene.control.richtext.model.StyleAttributeMap; import jfx.incubator.scene.control.richtext.skin.CellContext; import org.junit.jupiter.api.BeforeAll; @@ -62,6 +63,11 @@ public StyleAttributeMap getAttributes() { return StyleAttributeMap.builder().build(); } + @Override + public void decorateRun(StyleAttribute attribute, RunDecor type, String styleName) { + // Decorations are not involved in the cursor-style handler under test. + } + String style() { return style.toString(); } diff --git a/src/test/java/org/jabref/htmltonode/RichTextAreaSpikeTest.java b/src/test/java/org/jabref/htmltonode/RichTextAreaSpikeTest.java index 848a4d9..9a3633c 100644 --- a/src/test/java/org/jabref/htmltonode/RichTextAreaSpikeTest.java +++ b/src/test/java/org/jabref/htmltonode/RichTextAreaSpikeTest.java @@ -29,7 +29,7 @@ @Tag("gui") class RichTextAreaSpikeTest { - private static final StyleAttribute HREF = new StyleAttribute<>("HREF", String.class, false); + private static final StyleAttribute HREF = StyleAttribute.character("HREF", String.class); @BeforeAll static void startToolkit() throws InterruptedException { @@ -83,7 +83,7 @@ void styledModelCarriesSegmentsHighlightsAndCustomAttributes() { assertEquals("Kopp, O.: Some Paper", model.getPlainText(0)); assertEquals("doi.org/10.1/x", model.getPlainText(1)); - StyleAttributeMap linkAttrs = model.getStyleAttributeMap(null, jfx.incubator.scene.control.richtext.TextPos.ofLeading(1, 3)); + StyleAttributeMap linkAttrs = model.getStyleAttributeMap(null, jfx.incubator.scene.control.richtext.TextPos.ofLeading(1, 3), false); assertEquals("https://doi.org/10.1/x", linkAttrs.get(HREF)); assertEquals(Boolean.TRUE, linkAttrs.get(StyleAttributeMap.UNDERLINE)); } diff --git a/src/test/java/org/jabref/htmltonode/RichTextRendererTest.java b/src/test/java/org/jabref/htmltonode/RichTextRendererTest.java index b75c79d..e6f350d 100644 --- a/src/test/java/org/jabref/htmltonode/RichTextRendererTest.java +++ b/src/test/java/org/jabref/htmltonode/RichTextRendererTest.java @@ -27,7 +27,7 @@ private static StyledTextModel model(String html) { } private static StyleAttributeMap attributesAt(StyledTextModel model, int paragraph, int offset) { - return model.getStyleAttributeMap(null, TextPos.ofLeading(paragraph, offset)); + return model.getStyleAttributeMap(null, TextPos.ofLeading(paragraph, offset), false); } @Test