Skip to content

Font Size Plugin

The FontSizePlugin provides a font size selector with preset sizes, custom input, and keyboard shortcuts for stepping through sizes.

Font size selector

import { FontSizePlugin } from '@notectl/core';
new FontSizePlugin()
// or with custom config:
new FontSizePlugin({
sizes: [12, 14, 16, 20, 24, 32, 48],
defaultSize: 16,
})
interface FontSizeConfig {
/** Preset sizes shown in the dropdown. Sorted and deduplicated automatically. */
readonly sizes?: number[];
/** Base font size (no mark applied). Default: 16 */
readonly defaultSize?: number;
/** Render separator after toolbar item. */
readonly separatorAfter?: boolean;
}

When sizes is not specified:

8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96
CommandDescriptionReturns
setFontSizeReserved — font size is applied via the toolbar popupfalse
removeFontSizeRemove font size mark (reset to default)boolean
increaseFontSizeStep up to next preset sizeboolean
decreaseFontSizeStep down to previous preset sizeboolean
editor.executeCommand('increaseFontSize');
editor.executeCommand('decreaseFontSize');
editor.executeCommand('removeFontSize');
ShortcutAction
Ctrl+Shift++ / Cmd+Shift++Increase font size
Ctrl+Shift+_ / Cmd+Shift+_Decrease font size

The font size plugin renders as a combobox showing the current size. The dropdown includes:

  1. A number input for custom sizes (1-400)
  2. A scrollable list of preset sizes
  3. Full keyboard navigation (arrow keys, Enter, Escape)

The currently active size is highlighted in the list. If the cursor is on text with no font size mark, the default size is shown.

MarkAttributesRenders As
fontSizesize: string (e.g., "24px")<span style="font-size: 24px">

When the user selects the defaultSize, the font size mark is removed rather than applied. This keeps the document clean — text at the default size has no unnecessary marks.

The increaseFontSize and decreaseFontSize commands find the current font size at the cursor, locate it in the sorted preset list, and move to the next/previous entry. If the current size is not in the preset list, the commands snap to the nearest preset.