@lexion-rte/core
v0.1.4
Published
Headless core runtime for the Lexion editor platform.
Maintainers
Readme

This package is part of the Lexion framework-agnostic rich text editor.
Lexion is a framework-agnostic, headless rich text editor platform built on ProseMirror, designed to provide a shared core, reusable extensions, and framework-specific adapters.
@lexion-rte/core
Headless editor runtime for the Lexion platform.
Overview
@lexion-rte/core provides:
- editor state and schema management
- command registration/execution
- extension lifecycle hooks (
onCreate,onDestroy) - JSON document input/output
This package does not render UI by itself. Pair it with @lexion-rte/extensions and optionally an adapter package.
Install
pnpm add @lexion-rte/coreTypical pairing:
pnpm add @lexion-rte/core @lexion-rte/extensionsQuick Start
import { LexionEditor } from "@lexion-rte/core";
import { starterKitExtension, starterKitCommandNames } from "@lexion-rte/extensions";
const editor = new LexionEditor({
extensions: [starterKitExtension]
});
editor.execute(starterKitCommandNames.toggleBold);
console.log(editor.getJSON());Editor Options
LexionEditor accepts:
schema?: Schemadoc?: JSONDocumentextensions?: LexionExtension[]plugins?: LexionPlugin[](alias for extensions)commands?: CommandMap
Core API
Main instance members:
schemastatedocgetJSON()setJSON(document)dispatchTransaction(transaction)execute(command, ...args)registerCommand(name, handler)unregisterCommand(name)use(extension)removePlugin(key)destroy()
Custom Command Example
import { LexionEditor } from "@lexion-rte/core";
import { starterKitExtension } from "@lexion-rte/extensions";
const editor = new LexionEditor({ extensions: [starterKitExtension] });
editor.registerCommand("insertTimestamp", ({ state, dispatch }) => {
const { from, to } = state.selection;
dispatch(state.tr.insertText(new Date().toISOString(), from, to));
return true;
});
editor.execute("insertTimestamp");Extension Lifecycle Example
import type { LexionExtension } from "@lexion-rte/core";
const auditExtension: LexionExtension = {
key: "audit",
onCreate: ({ editor }) => {
console.log("created", editor.getJSON());
},
onDestroy: () => {
console.log("destroyed");
}
};Error Behavior
- Executing an unknown command throws
Unknown command: <name>. - Using an editor after
destroy()throws an error. - Registering duplicate command names throws.
Related Packages
@lexion-rte/extensionsfor starter-kit, AI, and collaboration features@lexion-rte/toolsfor HTML/text conversions- adapter packages (
web,react,vue, etc.) for UI integration
