Skip to content

MarkdownViewer article and demos#696

Open
laurenic0l wants to merge 6 commits intomainfrom
659-markdownviewer-doc
Open

MarkdownViewer article and demos#696
laurenic0l wants to merge 6 commits intomainfrom
659-markdownviewer-doc

Conversation

@laurenic0l
Copy link
Contributor

@laurenic0l laurenic0l commented Jan 22, 2026

Here's the first draft of the MarkdownViewer documentation. POM file should be updated with 25.11

closes #659

@laurenic0l laurenic0l added status: needs-snapshot Update to the latest snapshot before this PR can be merged. status: waiting-for-review The PR is ready. Waiting for team members to review. labels Jan 22, 2026
Copy link
Member

@hyyan hyyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurenic0l This article has a few issues. The flow is not completely smooth, and it makes some incorrect assumptions.

  1. Conflates "streaming" with "progressive rendering"

    • append() works independently - content appears immediately if progressiveRender is off
    • "Streaming methods" section title is misleading
    • Streaming is about receiving data from server
    • Progressive rendering is about displaying it character-by-character
  2. Missing dependency clarity

    • isRendering() only meaningful when progressiveRender is enabled
    • stop(), flush(), whenRenderComplete() only work with progressiveRender on
    • These dependencies aren't explained
  3. Auto-scroll placement

    • Presented as if related to streaming, but it's completely independent
    • Can be used with or without streaming/progressive rendering
  4. Organization implies wrong flow

    • Suggests you need "streaming methods" for progressive rendering
    • Reality: you can append() without progressiveRender

I suggest this structure, please verify:

  1. Setting content
  2. Appending content (for any incremental updates)
  3. Auto-scroll (independent feature)
  4. Progressive rendering (visual typewriter effect)
    • Enable it
    • Render speed
    • Render state (isRendering)
    • Controlling rendering (stop/flush)
    • Waiting for completion (whenRenderComplete)
  5. Clearing content
  6. Syntax highlighting

@laurenic0l laurenic0l added status: waiting-for-author Review is done. Waiting for the PR author to apply changes or respond. and removed status: waiting-for-review The PR is ready. Waiting for team members to review. labels Jan 22, 2026
@laurenic0l laurenic0l requested a review from hyyan January 26, 2026 23:20
@laurenic0l laurenic0l force-pushed the 659-markdownviewer-doc branch from 62c2859 to fde2508 Compare January 27, 2026 03:04
@laurenic0l laurenic0l added status: waiting-for-review The PR is ready. Waiting for team members to review. and removed status: waiting-for-author Review is done. Waiting for the PR author to apply changes or respond. labels Jan 27, 2026
@hyyan hyyan removed the status: needs-snapshot Update to the latest snapshot before this PR can be merged. label Feb 6, 2026
MarkdownViewer viewer = new MarkdownViewer("# Hello World");

// Replace content entirely
viewer.setContent("## New Content\n\n- Item 1\n- Item 2");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use java multiline strings instead for readability

card.setStyle("maxWidth", "600px")
.setStyle("width", "100%")
.setStyle("padding", "var(--dwc-space-l)")
.setStyle("background", "var(--dwc-color-surface-1)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that should be: var(--dwc-surface-3)

viewer.append("More content here...");
```

By default, appended content appears immediately. When progressive rendering is enabled, appended content goes into a buffer and displays character-by-character instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link progressive rendering section

viewer.setRenderSpeed(speed);
});

viewer.setProgressiveRender(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add var(--dwc-surface-3) background please

.setSpacing("var(--dwc-space-m)")
.setPadding("var(--dwc-space-l)");

speedChoice.setLabel("Render Speed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

align to right and give it 200px width please

return italicText;
}

public Locator getStrikethrough() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used anywhere

import com.webforj.samples.pages.markdownviewer.MarkdownViewerProgressivePage;
import com.webforj.samples.views.BaseTest;

public class MarkdownViewerProgressiveViewIT extends BaseTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests only check element visibility on initial load - they don't verify any behavior or content. For example, the streaming test never types a message, clicks send, or checks that streaming starts. The basic viewer test checks that a tag exists somewhere, but not that the markdown rendered the expected text. These tests are too shallow to catch regressions - they'll keep passing even when functionality is broken. we should be testing actual behavior (send a message, verify response appears) and asserting on expected content rather than just element presence.

messagesArea.addClassName("chat__messages");
messagesArea.setStyle("overflowY", "auto");

viewer.setProgressiveRender(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable auto scroll

<p>A component for displaying user profile pictures or initials, with support for different sizes, shapes, and themes.</p>
</GalleryCard>

<GalleryCard header="MarkdownViewer" href="markdownviewer" image="/img/components/MarkdownViewer.png">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the screenshot after you fix the demo background to use Surface 3.


## Syntax highlighting {#syntax-highlighting}

The `MarkdownViewer` supports syntax highlighting for code blocks when Prism.js is available. Add Prism.js to your app using the `@JavaScript` and `@StyleSheet` annotations:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's link Prism.js

@hyyan
Copy link
Member

hyyan commented Feb 11, 2026

@MatthewHawkins @laurenic0l, we'll need to get this fixed before we can merge.

#738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-review The PR is ready. Waiting for team members to review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document MarkdownViewer component

3 participants