List
Ordered and unordered lists with indent/outdent.
Import
typescript
import { listPlugin } from 'halka/plugins/list';Usage
- Toggle bullet or numbered list from your toolbar
- Tab indents nested list items, Shift+Tab outdents
- Combine with markdown-shortcuts plugin: type "- " or "1. " + Space
- Read list.active on formatChange to highlight list toolbar buttons
Commands
| Command | Description |
|---|---|
list.toggleUnordered | Toggle UL |
list.toggleOrdered | Toggle OL |
list.indent | Nest list item |
list.outdent | Un-nest list item |
State
Read plugin state with editor.getState(name). Listen to formatChange to refresh UI when the selection moves.
| State | Description |
|---|---|
list.active | Active list type at caret, or null |
typescript
const listActive = editor.getState('list.active') as {
type: 'ul' | 'ol';
} | null;
const isBulletList = listActive?.type === 'ul';
const isOrderedList = listActive?.type === 'ol';
editor.on('formatChange', () => {
const activeList = editor.getState('list.active');
});Shortcuts
| Shortcut | Action |
|---|---|
Mod+Shift+8 | Toggle unordered list |
Mod+Shift+7 | Toggle ordered list |
Tab / Shift+Tab | Indent / outdent |
Example
typescript
editor.execCommand('list.toggleUnordered');
editor.execCommand('list.indent');
editor.execCommand('list.outdent');