Typix LogoTypix
Core

Overview

The v2 surface — useTypixEditor, EditorContent, TypixEditorContext, and the editor instance

The Typix v2 core is a small surface — one hook, one context, one content component, and the TypixEditor instance they give you. Everything else ships as vendorable components you copy into your repo with typix ui add — toolbar buttons, floating menus, mention pickers, slash command palette, and more.

import {
  EditorContent,
  TypixEditorContext,
  defaultTheme,
  useTypixEditor,
} from "@typix-editor/react";

The four public APIs

Canonical structure

Every Typix editor follows this same shape:

"use client";

const extensions = [StarterKit(), /* …more extensions */];

export function Editor() {
  const editor = useTypixEditor({
    extensions,
    theme: defaultTheme,
    namespace: "my-editor",
  });

  return (
    <TypixEditorContext.Provider value={{ editor }}>
      <Toolbar />          {/* uses useCurrentTypixEditor via context */}
      <EditorContent editor={editor} placeholder="…" />
      <FloatingLinkUI />   {/* optional UI overlay */}
    </TypixEditorContext.Provider>
  );
}

The TypixEditor instance

useTypixEditor returns a TypixEditor — a thin, typed wrapper around Lexical. The most useful members:

MethodReturnsNotes
editor.chain()ChainBuilder<R>Fluent command builder. Each extension augments the type.
editor.can()CanChainBuilder<R>editor.can().toggleBold() — check before executing.
editor.lexicalLexicalEditorDirect access for raw Lexical commands.
editor.getJSON()SerializedContentSerializable content state.
editor.getHTML()stringRendered HTML.
editor.getText()stringPlain text.
editor.setContent(state)voidLoad serialized content.
editor.isEmpty()booleanTrue for empty editor.
editor.isEditable()booleanCurrent read/write state.
editor.setEditable(v)voidToggle read/write.
editor.emitterTypixEventEmitterSubscribe to events (contentChange, selectionChange, etc.).
editor.namespacestringThe namespace from options.
editor.idstringAuto-generated unique id.

Full API →

Hooks shipped from @typix-editor/react

HookPurpose
useTypixEditor(options)Create + manage the editor (top-level only).
useCurrentTypixEditor()Get the editor from context (descendant components).
useTypixEditorState()Subscribe to Typix-managed state.
useEditorState(selector)Subscribe to a Lexical selector; re-renders only when value changes.
useSelectionStyle()Selection-aware styling info.
useSignal(signal)Subscribe to a Typix signal primitive.
useRange()Current selection's DOMRange.
useMouseListener(handler)Listen for editor mouse events.

Floating UI primitives

Shipped for building bubble menus, slash menus, mention pickers:

ExportPurpose
<EditorBubbleMenu> / <EditorBubbleItem>Selection-triggered floating menu.
<EditorCommand> / <EditorCommandItem> / <EditorCommandList> / <EditorCommandEmpty>Command-palette pattern.
<SuggestionMenu> + useSuggestionItems + filterSuggestionItemsTypeahead pattern (mentions, @-pickers).
<FloatingElement> + useFloatingElementGeneric floating UI helper.
<RootContext> + useRootContextFloating-anchor element registry.

What v2 dropped from v1

If you're porting from v1, the following symbols are gone — search and replace:

v1v2
<EditorRoot extension={ext}>useTypixEditor({ extensions }) + <TypixEditorContext.Provider>
useTypixEditor() (no args, from context)useCurrentTypixEditor()
useActiveFormats({ formats })useEditorState((state) => …) + editor.chain().can().toggleBold()
useBlockType()useEditorState((state) => state.blockType)
editor.toggleBold()editor.chain().toggleBold().run()
defineExtension(...) from @typix-editor/reactdefineExtension(...) from lexical (or build via @typix-editor/core helpers)
defaultExtensionNodes(removed — extensions register their own nodes)

Next

On this page