FluidMarkdown for HarmonyOS is a component compliant with the @ComponentV2 specification. It supports three main modes:
1. Normal Rendering
Import Markdown and bind content via the content parameter. Use the mode parameter set to EMarkdownMode.Normal.
2. Streaming Output (Typing Mode)
Set mode to EMarkdownMode.Typing. You must provide a MarkdownController instance to the controller parameter.
Important: Control methods like update() should only be called within the onMarkdownTypingReady event callback to ensure reliability. In this mode, the content parameter is ignored.
3. Theme Customization
Pass a BaseEngine instance to the engine parameter. You can modify theme properties (like fontColor) through the engine's theme service during the component lifecycle (e.g., in aboutToAppear).
// Normal Mode Example
import { Markdown, EMarkdownMode } from 'fluid-markdown';
Markdown({
content: this.content,
mode: EMarkdownMode.Normal,
onMarkdownAreaChange: () => {},
onMarkdownNodeClick: data => {},
})
// Streaming Mode Example
import { Markdown, EMarkdownMode, MarkdownController, ETypingMode } from 'fluid-markdown';
private markdownController: MarkdownController = new MarkdownController();
Markdown({
controller: this.markdownController,
mode: EMarkdownMode.Typing,
onMarkdownTypingReady: () => {
this.markdownController.typing.update('Hello FluidMarkdown', ETypingMode.Begin);
},
})