Scrivr
Getting Started

Editor Options

Configuration reference for the headless Editor class and PageConfig.

This page covers the headless new Editor(options) API. If you are using a framework binding, the hook options live in the package page for your framework.


new Editor(options)

import { Editor, StarterKit } from '@scrivr/core';

const editor = new Editor({
  extensions: [StarterKit],
  onChange: (state) => console.log('changed', state),
});

editor.mount(document.getElementById('editor')!);
OptionTypeDefaultDescription
extensionsExtension[][StarterKit]Extensions to load.
pageConfigPageConfigA4, ¾-inch marginsPage dimensions and margins.
onChange(state: EditorState) => voidFired on every document or selection change.
onFocusChange(focused: boolean) => voidFired when the editor textarea gains or loses focus.
onCursorTick(isVisible: boolean) => voidFired on every cursor blink tick. Only needed when building a custom rendering adapter.
startReadybooleantrueAdvanced. Suppresses layout flushes until the editor is marked ready internally. Managed automatically by the Collaboration extension — you do not need to set this manually.

PageConfig

Controls the physical dimensions and margins of every page. All values are in pixels at 96 dpi.

interface PageConfig {
  pageWidth: number;
  pageHeight: number;
  margins: { top: number; right: number; bottom: number; left: number };
  fontFamily?: string;
}
PropertyDefaultDescription
pageWidth794Page width in px. 794 ≈ A4 width (210 mm).
pageHeight1123Page height in px. 1123 ≈ A4 height (297 mm).
margins.top72Top margin in px. 72 px = ¾ inch.
margins.right72Right margin in px.
margins.bottom72Bottom margin in px.
margins.left72Left margin in px.
fontFamilyDocument-level default font family.

Common page sizes:

FormatpageWidthpageHeight
A4 portrait7941123
US Letter portrait8161056
A4 landscape1123794

Common margin presets:

Presetpx
¾ inch (default)72
1 inch96
½ inch (narrow)48

On this page