Skip to content

Configuration

The editor is configured entirely through the EzynotaConfig object passed to the constructor:

ts
const editor = new Ezynota(config);

Full option reference

OptionTypeDefaultDescription
targetstring | ElementElement (or selector) the editor mounts into. Required.
dataEzynotaDocumentInitial document. In workspace mode this opens as a new note instead.
toolsRecord<string, BlockToolConstructor | ToolDefinition>built-insCustom/extra block tools, keyed by block type. Built-ins remain registered.
inlineTools(InlineToolConstructor | InlineToolDefinition)[]built-insInline formatting tools for the floating toolbar.
tunes(BlockTuneConstructor | TuneDefinition)[][AlignmentTune]Per-block tunes (e.g. alignment).
defaultBlockstring"paragraph"Block type inserted by Enter, the slash menu fallback, and empty docs.
readOnlybooleanfalseStart in read-only mode (toggle later with setReadOnly).
autofocusbooleanfalseFocus the editor after mount.
placeholderstringPlaceholder for the first/empty block.
minHeightnumber | stringMinimum height of the editing surface.
localestringBCP-47 locale. RTL is applied automatically for he, ar, fa, ur.
i18n{ messages }Overrides for UI strings (namespaced). See i18n.
idGenerator() => stringcrypto UUID / ez_*Custom block id generator.
uibooleantrueSet false for a headless editor.
modeEzynotaModeauto"workspace" | "document" | "embedded" | "headless". See Modes.
workspaceobjectWorkspace options (note title, initial folder, etc.).
storageStorageAdapter | factoryIndexedDbStoragePersistence backend for workspace mode.
theme"light" | "dark" | "system"Editor theme; system follows prefers-color-scheme.
onReady(editor) => voidCalled once the editor (and workspace, if any) is ready.
onChange(batch: ChangeBatch) => voidCalled on every committed change batch.

Minimal examples

Embedded editor

ts
const editor = new Ezynota({
  target: "#comment-box",
  mode: "embedded",
  placeholder: "Write a comment…",
  minHeight: 120,
});

Workspace app

ts
const editor = new Ezynota({
  target: "#app",
  mode: "workspace",
  theme: "system",
  storage: myCustomAdapter, // optional
  onReady: (ed) => {
    console.log("Workspace ready:", ed.workspace);
  },
});

Read-only renderer

ts
const viewer = new Ezynota({
  target: "#article",
  readOnly: true,
  data: fetchedDocument,
});

Editing lock

Until the initial workspace load completes (editor.ready resolves), all mutations throw EZ_EDITING_LOCKED. Wrap early API calls:

ts
await editor.ready;
editor.insertBlock("paragraph", { content: [] });

Custom block ids

Block ids must be unique strings. Provide idGenerator if you need a specific format (e.g. ULIDs that sort by time):

ts
const editor = new Ezynota({
  target: "#app",
  idGenerator: () => ulid(),
});

See also

Released under the MIT License. Zero runtime dependencies.