Footnote
Academic-style footnotes with citations.
Import
typescript
import { footnotePlugin } from 'halka/plugins/footnote';Usage
- Add footnote bodies with footnote.addItem
- Insert citation at cursor โ auto-numbered superscript
- Read footnote.items state to build a footnote manager UI
- See /docs/svelte-ui for the in-repo FootnoteManager component
Commands
| Command | Description |
|---|---|
footnote.addItem | Add footnote HTML |
footnote.insertCitation | Insert citation at cursor |
footnote.editItem / footnote.removeItem | Edit or remove |
State
Read plugin state with editor.getState(name). Listen to formatChange to refresh UI when the selection moves.
| State | Description |
|---|---|
footnote.items | Array of { id, content } |
typescript
const items = editor.getState('footnote.items') as {
id: string;
content: string;
}[];
// Build a footnote manager UI from items
for (const item of items) {
console.log(item.id, item.content);
}
editor.on('formatChange', () => {
const footnotes = editor.getState('footnote.items');
});Example
typescript
editor.execCommand('footnote.addItem', '<p>Source note.</p>');
const items = editor.getState('footnote.items');
editor.execCommand('footnote.insertCitation', items[0].id);