@nextgensoftwares/folio-plugin-header-footer
Headers and footers stored in the document, with fields, variants, sections and in-place editing. Guide: Headers and footers. The data model and layout pieces are in @nextgensoftwares/folio-layout.
Plugin
| Export | Signature | Description |
|---|---|---|
headerFooterPlugin | (options?: HeaderFooterPluginOptions) => HeaderFooterPlugin | schema (hfField, doc/section attrs), edit layer + painters, toolbar/slash items, overlay edit bar, settings section |
type HeaderFooterPluginOptions | seed?, editable?, variables? (host variables for the picker), labels?, fieldLabels?, settings?: boolean | { slot?, order?, label? } | |
type HeaderFooterPlugin | FolioPlugin plus controller, edit(editor, zone, page?), close() | |
headerFooterSchema | Partial<SchemaSpec> | the hfField node, headerFooter/chapters doc attrs, hfSection/sectionBreak on paragraphs and headings |
FIELD_KINDS | readonly string[] | page, numpages, sectionpages, date, title, heading, var |
Settings and commands
| Export | Signature | Description |
|---|---|---|
settingsOf | (doc) => HeaderFooterSettings | null | the stored settings |
sectionOf | (s, key) => SectionSettings | undefined | a section's own settings ('' = document level) |
withSection, withPart | immutable updates | replace a section's settings / one part (undefined = link to previous) |
newSectionId | () => string | a fresh hfSection id |
EMPTY_PARAGRAPH | HFContent | editable content of an empty part |
updateHeaderFooter | (fn) => Command | one setDocAttribute step |
setHeaderFooter, removeHeaderFooter | Commands | merge / remove document-level settings |
setSectionOptions, setPageNumbering, setPart | Commands | by section key |
setChapters | (c: ChapterSettings) => Command | chapters on/off, level |
insertSectionBreak, removeSectionBreak | (kind?: boolean | 'nextPage' | 'continuous' | 'oddPage' | 'evenPage') => Command, () => Command | at the caret's top-level paragraph/heading (odd/even page starts insert a blank page when needed) |
ensureSection | (tr, block, asBreak, fresh?) => string | null | the section id at a block (assigns one) |
blockPos | (doc, index) => number | position before a top-level block |
setLinkToPrevious | (info: PageChromeInfo, zone, linked) => Command | Word's Link to previous |
setPageSectionOptions | (info, patch) => Command | first page / numbering of the page's section |
differentOnPage | (info, { header, footer }) => Command | section breaks around one page |
resolvedSections | (state) => ResolvedSection[] | what every section shows |
settingsFromConfig | (config?: HeaderFooterConfig) => HeaderFooterSettings | back-compat: legacy zones as settings |
templateNodes | (template) => FolioNode[] | {{page}}/{{total}}/{{name}} → fields |
PRESETS | { id, label, settings() }[] | starting points in settings |
Fields and labels
| Export | Signature | Description |
|---|---|---|
insertField | (attrs: FieldAttrs) => Command | inserts an hfField (run it on the editor while a header is edited) |
fieldChoices | (settings, o?) => FieldChoice[] | picker entries: title, page, total, date, current heading, pages in section (with sections), variables |
fieldLabel | (attrs, labels?) => string | a field's display name |
DEFAULT_FIELD_LABELS, type FieldLabels, type FieldChoice | renamable names ("Current heading"…) | |
zoneLabel | (state, info, zone, labels?) => string | "First page header — Section 2" |
sectionName | (state, info, labels?) => string | the section start's heading text, else "Section N" |
DEFAULT_ZONE_LABELS, type ZoneLabels | translatable band labels |
In-place editing
| Export | Signature | Description |
|---|---|---|
HeaderFooterController | class | attach(editor) (double-click hook), enter(editor, { page, zone }), exit(), active, sessionOf(editor), subscribe(fn) |
type ControllerOptions | seed?, editable? | |
bandAt | (editor, page, y) => 'header' | 'footer' | null | the band under a point |
HeaderFooterSession | class (implements EditorDelegate) | the nested editor of one variant; sub, target, variant, info() |
type SessionTarget | { page, zone } | |
zoneAt | (page, y) => HFZone | null | band of a laid-out page |
editLayer | (controller, labels?) => PageLayer | dimmed body, band outlines and labels (screen only) |
DIM_TYPE, ZONE_TYPE, type ZoneFragmentAttrs | its custom fragment types |
React
| Export | Description |
|---|---|
headerFooterPainters, DimPainter, ZonePainter | painters of the edit layer |
createEditBar(controller, options?), type EditBarOptions, type OverlayProps | the overlay slot bar |
createSettingsPanel(controller, options?), type SettingsPanelOptions | the settings slot section |
VariablesEditor, type VariablesEditorProps | add/rename/delete user variables |
FORMAT_OPTIONS | page number format choices |