FeaturesMarks
Subscript
Make text subscript with `toggleSubscript`.
Type: Mark · Category: Marks
Subscript renders text smaller and below the baseline. Useful for footnotes and chemical formulas. Renders as <sub> in HTML output.
Demo
Installation
import { Subscript } from "@arkpad/extension-subscript";Commands
The extension registers three commands for managing subscript styling:
// Toggles subscript styling on and off for the active selection
editor.runCommand("toggleSubscript");
// Explicitly applies subscript styling to the selection
editor.runCommand("setSubscript");
// Explicitly removes subscript styling from the selection
editor.runCommand("unsetSubscript");Chaining Commands
You can chain commands to toggle subscript styling and immediately focus the editor:
editor.chain().focus().toggleSubscript().run();Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Mod-, (Cmd/Ctrl + Comma) | Toggles subscript styling |
Active State
const isActive = editor.isActive("subscript");Configuration
Options
| Name | Type | Default | Description |
|---|---|---|---|
HTMLAttributes | Record<string, any> | {} | Key-value pairs of attributes to render on the <sub> DOM element. |
Subscript.configure({
HTMLAttributes: {
class: "custom-sub-styling",
},
});