@lexion-rte/extensions
v0.1.4
Published
Feature extensions 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/extensions
Feature extension bundle for Lexion.
Overview
@lexion-rte/extensions ships:
- starter-kit schema and commands
- AI extension primitives (
AIService,aiExtension) - collaboration extension primitives (
createCollaborationExtension)
Install
pnpm add @lexion-rte/extensions @lexion-rte/coreFor collaboration features:
pnpm add yjs y-protocols y-prosemirrorExports
starterKitExtensionstarterKitSchemacreateStarterKitSchema()createStarterKitCommands()starterKitCommandNamesaiExtension,aiCommandNames,AIService,createAIService()createCollaborationExtension(),collaborationCommandNames
Starter Kit Commands
starterKitCommandNames includes:
setParagraphtoggleHeadingtoggleBoldtoggleItalicwrapBulletListwrapOrderedListliftListItemsinkListItemsetLinkunsetLinkundoredo
Starter Kit Example
import { LexionEditor } from "@lexion-rte/core";
import { starterKitExtension, starterKitCommandNames } from "@lexion-rte/extensions";
const editor = new LexionEditor({ extensions: [starterKitExtension] });
editor.execute(starterKitCommandNames.toggleHeading, { level: 2 });
editor.execute(starterKitCommandNames.toggleBold);
editor.execute(starterKitCommandNames.setLink, {
href: "https://example.com",
title: "Example"
});AI Service Example
import { LexionEditor } from "@lexion-rte/core";
import { AIService, aiExtension, starterKitExtension } from "@lexion-rte/extensions";
const editor = new LexionEditor({
extensions: [starterKitExtension, aiExtension]
});
const service = new AIService({
async generate({ prompt, selection }) {
return `Prompt: ${prompt}\nSelection: ${selection}`;
}
});
await service.generateAndApply(editor, "Rewrite this paragraph clearly");Collaboration Example
import { LexionEditor } from "@lexion-rte/core";
import {
createCollaborationExtension,
collaborationCommandNames,
starterKitExtension
} from "@lexion-rte/extensions";
import * as Y from "yjs";
import { Awareness } from "y-protocols/awareness";
const ydoc = new Y.Doc();
const awareness = new Awareness(ydoc);
const fragment = ydoc.getXmlFragment("lexion");
const editor = new LexionEditor({
extensions: [starterKitExtension, createCollaborationExtension({ fragment, awareness })]
});
editor.execute(collaborationCommandNames.undo);