# Typewriter
# Features
A text display component that simulates typing effects, supporting the following features:
- Configurable typing animation effects
- Markdown content rendering
- Code syntax highlighting (via Prism.js)
- Cursor fog effects
- Plugin system extensions
# Usage Examples
# Basic Usage
The simplest typing effect using default configuration.
Copy
# Custom Typing Speed and Step
Configure typing speed and characters per typing step through the typing property.
Typing Speed:
Characters per Step:
Copy
# Custom Cursor
Customize cursor characters through the typing.suffix property.
Cursor Character:
Copy
# Fog Effect
Configure cursor fog effects through the isFog property, allowing customization of fog area width and background color.
Fog Width:
Background Color: #FFFFFF
Copy
# Markdown Rendering
Enable Markdown content rendering through the isMarkdown property.
Copy
# Pause and Continue
Use interrupt() and continueTyping() methods to control pausing and continuing the typing process.
Copy
# Complete Feature Demonstration
Comprehensive demonstration of all major features of the Typewriter component.
Typing Speed:
Current Progress: 0%
Copy
# Attributes
| Parameter | Description | Type | Default |
|---|---|---|---|
| content | Content to display | String | '' |
| isMarkdown | Whether to parse Markdown content | Boolean | false |
| typing | Typing effect configuration, set to true to use default values or pass object configuration: - interval: typing interval(ms) - step: characters per typing - suffix: cursor character | Boolean/Object | false |
| isFog | Fog effect configuration, set to true to use default values or pass object configuration: - bgColor: background color - width: fog width | Boolean/Object | false |
| highlight | Custom code highlighting function, receives (code, lang) parameters | Function | - |
| mdPlugins | Markdown plugin array | Array | - |
# Methods
| Method Name | Description | Parameters | Return Value |
|---|---|---|---|
| startTyping | Start typing animation | - | - |
| finishTyping | Complete typing immediately | - | - |
| interrupt | Interrupt typing process | - | - |
| continueTyping | Continue interrupted typing | - | - |
| restart | Restart typing | - | - |
| destroy | Destroy component instance | - | - |
| getInstance | Get component instance API | - | Object containing: - interrupt/continue/restart/destroy: control methods - renderedContent: rendered content - isTyping: whether typing - progress: current progress |
# Events
| Event Name | Description | Callback Parameters |
|---|---|---|
| start | Typing start event | No parameters |
| writing | Typing progress event | Object containing: - progress: current progress - renderedContent: rendered content |
| finish | Typing complete event | Object returned by getInstance() |
| interrupt | Typing interrupt event | Object returned by getInstance() |
| continue | Typing continue event | Object returned by getInstance() |
| restart | Typing restart event | Object returned by getInstance() |