| Author | DaveJarvis <email> |
|---|---|
| Date | 2021-11-09 17:11:01 GMT-0800 |
| Commit | 4c866cad81ff1333891b5153d4b93e666395ae0f |
| Parent | bf2b611 |
| Delta | 41 lines added, 36 lines removed, 5-line increase |
| } | ||
| - static class Factory implements @NotNull NodeRendererFactory { | ||
| + static class Factory implements NodeRendererFactory { | ||
| @Override | ||
| public @NotNull NodeRenderer apply( @NotNull final DataHolder options ) { |
| * Responsible for configuring FlyingSaucer's {@link XHTMLPanel}. | ||
| */ | ||
| -public final class FlyingSaucerPanel extends XHTMLPanel implements HtmlPanel { | ||
| +public final class FlyingSaucerPanel extends XHTMLPanel implements | ||
| + HtmlRenderer { | ||
| /** |
| -package com.keenwrite.preview; | ||
| - | ||
| -import org.w3c.dom.Document; | ||
| - | ||
| -import javax.swing.*; | ||
| - | ||
| -public interface HtmlPanel { | ||
| - | ||
| - /** | ||
| - * Renders an HTML document with respect to a base location. | ||
| - * | ||
| - * @param doc The document to render. | ||
| - * @param baseUri The document's relative URI. | ||
| - */ | ||
| - void render( final Document doc, final String baseUri ); | ||
| - | ||
| - /** | ||
| - * Scrolls the given {@link JScrollPane} to the first HTML element that | ||
| - * has an {@code id} attribute that matches the given identifier. | ||
| - * | ||
| - * @param id The HTML element identifier. | ||
| - * @param scrollPane The GUI widget that controls scrolling. | ||
| - */ | ||
| - void scrollTo( final String id, final JScrollPane scrollPane ); | ||
| - | ||
| - /** | ||
| - * Clears the cache (e.g., so that images are re-rendered using updated | ||
| - * dimensions). | ||
| - */ | ||
| - void clearCache(); | ||
| -} | ||
| private final StringBuilder mDocument = new StringBuilder( 65536 ); | ||
| - private HtmlPanel mPreview; | ||
| + private HtmlRenderer mPreview; | ||
| private JScrollPane mScrollPane; | ||
| private String mBaseUriPath = ""; | ||
| public void render( final String html ) { | ||
| final var doc = CONVERTER.fromJsoup( parse( decorate( html ) ) ); | ||
| - doc.setDocumentURI( getBaseUri() ); | ||
| + final var uri = getBaseUri(); | ||
| + doc.setDocumentURI( uri ); | ||
| - invokeLater( () -> mPreview.render( doc, getBaseUri() ) ); | ||
| + invokeLater( () -> mPreview.render( doc, uri ) ); | ||
| fireDocumentChangedEvent( html ); | ||
| +package com.keenwrite.preview; | ||
| + | ||
| +import org.w3c.dom.Document; | ||
| + | ||
| +import javax.swing.*; | ||
| + | ||
| +/** | ||
| + * Denotes the ability to render an HTML document onto a Swing component. | ||
| + */ | ||
| +public interface HtmlRenderer { | ||
| + | ||
| + /** | ||
| + * Renders an HTML document with respect to a base location. | ||
| + * | ||
| + * @param doc The document to render. | ||
| + * @param baseUri The document's relative URI. | ||
| + */ | ||
| + void render( final Document doc, final String baseUri ); | ||
| + | ||
| + /** | ||
| + * Scrolls the given {@link JScrollPane} to the first HTML element that | ||
| + * has an {@code id} attribute that matches the given identifier. | ||
| + * | ||
| + * @param id The HTML element identifier. | ||
| + * @param scrollPane The GUI widget that controls scrolling. | ||
| + */ | ||
| + void scrollTo( final String id, final JScrollPane scrollPane ); | ||
| + | ||
| + /** | ||
| + * Clears the cache (e.g., so that images are re-rendered using updated | ||
| + * dimensions). | ||
| + */ | ||
| + void clearCache(); | ||
| +} | ||