List

Ordered and unordered lists with indent/outdent.

Try this feature →

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

CommandDescription
list.toggleUnorderedToggle UL
list.toggleOrderedToggle OL
list.indentNest list item
list.outdentUn-nest list item

State

Read plugin state with editor.getState(name). Listen to formatChange to refresh UI when the selection moves.

StateDescription
list.activeActive 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

ShortcutAction
Mod+Shift+8Toggle unordered list
Mod+Shift+7Toggle ordered list
Tab / Shift+TabIndent / outdent

Example

typescript
editor.execCommand('list.toggleUnordered');
editor.execCommand('list.indent');
editor.execCommand('list.outdent');

MIT · Halka Editor