Skip to content

API Reference

Import public APIs from the package root:

import {
GalleyEditor,
ErrorBoundary,
useGalley,
BUILTIN_COMMANDS,
BUILTIN_COMMAND_NAMES,
DEFAULT_KEYMAP,
BUILT_IN_PLUGINS,
makeInlinePlugin,
makeBlockPlugin,
} from '@inkyquill/galley-editor';

The main controlled editor component.

<GalleyEditor value={markdown} onChange={setMarkdown} />

Core props:

PropTypeDefault
valuestring''
onChange(value: string) => voidnone
editablebooleantrue
placeholderstring''
ariaLabelstringnone
minRowsnumber3
maxRowsnumbernone
layout'autosize' | 'fill''autosize'
horizontalScrollbooleanfalse
theme'light' | 'dark' | 'auto' | 'inherit''auto'
mode'live' | 'markdown' | 'preview''live'
toolbarboolean | GalleyToolbarOptionstrue
footerboolean | GalleyFooterOptionstrue

Extension props:

PropPurpose
classNamesOverride semantic ge-* classes.
keymapReplace or extend the default keymap.
codeHighlighterRender inactive fenced code blocks.
imageRendererRender Markdown image widgets.
missingImageRendererRender empty or failed images.
imageControlsRendererRender selected-image controls.
tableControlIconsReplace rendered table editor control icons/text.
onLinkClickIntercept Cmd/Ctrl-click links.
pluginsAdd Galley plugins.
disabledPluginsDisable built-in plugin ids.
extensionsAppend CodeMirror extensions.

Event props:

PropPurpose
onFocus, onBlurFocus lifecycle.
onSelectionChangeSelection changes.
onScrollScroll fraction from 0 to 1.
onEnter, onEscape, onSubmitKeyboard hooks.
onPasteRaw paste event.
onFiles, onFileStatus, onFileErrorPaste/drop file workflows.

React error boundary for isolating editor failures:

<ErrorBoundary fallback={<p>Editor unavailable.</p>}>
<GalleyEditor value={value} onChange={setValue} />
</ErrorBoundary>

Small convenience hook around a GalleyHandle ref and local content state.

const editor = useGalley({ initialValue: '# Draft' });
<GalleyEditor ref={editor.ref} value={editor.content} onChange={editor.setContent} />;

GalleyHandle is exposed through ref.

MethodDescription
getContent()Read current Markdown.
setContent(value)Replace the document.
insertText(text)Insert text at the selection.
focus() / blur()Control focus.
openSearch()Open and focus the built-in CodeMirror search panel. Returns false before mount.
select(anchor, head?)Set selection.
getSelection()Read selection.
execCommand(name, ...args)Execute built-in or custom commands.
registerCommand(name, fn)Register a custom command.
undo() / redo()History actions.
scrollTo(fraction)Scroll by document fraction.
scrollSelectionIntoView()Reveal current selection.
addExtension(ext)Add a CodeMirror extension at runtime.
viewThe underlying CodeMirror EditorView, or null before mount.
ExportDescription
BUILTIN_COMMANDSCommand implementation map.
BUILTIN_COMMAND_NAMESNames of all built-in commands.
DEFAULT_KEYMAPGalley’s default CodeMirror key bindings.
BUILT_IN_PLUGINSBuilt-in rendering plugin list.
ExportDescription
makeInlinePlugin(spec)Build a viewport-only inline decoration plugin.
makeBlockPlugin(spec)Build a full-document block decoration plugin.
nodeIntersectsSelection(selection, node)Selection helper for plugin specs.
HIDE_DECORATIONShared empty replacement decoration.
BLOCK_CURSOR_LINE_PROXIMITYDefault block reveal proximity.

The package also exports selected command functions directly, including line editing, table editing, image metadata, findInDocument, jumpToHash, and slugifyHeading.

Use direct command functions when you already have a CodeMirror EditorView. Use execCommand() when working through the Galley ref.