@lexion-rte/svelte
v0.1.4
Published
Svelte action adapter for the Lexion editor.
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/svelte
Svelte action adapter for Lexion.
Overview
@lexion-rte/svelte exports the lexion action for declarative editor mounting.
Action options:
editor?: LexionEditorvalue?: JSONDocumentdefaultValue?: JSONDocumentreadOnly?: booleanonChange?: (value, editor) => voidonReady?: (editor) => void
Install
pnpm add @lexion-rte/svelte svelteBasic Usage
<script lang="ts">
import type { JSONDocument } from "@lexion-rte/core";
import { lexion } from "@lexion-rte/svelte";
let value: JSONDocument | undefined = undefined;
</script>
<div
use:lexion={{
value,
onChange: (nextValue) => {
value = nextValue;
}
}}
></div>Read-only Toggle Example
<script lang="ts">
import { lexion } from "@lexion-rte/svelte";
let readOnly = false;
</script>
<button on:click={() => (readOnly = !readOnly)}>Toggle read-only</button>
<div use:lexion={{ readOnly }}></div>Notes
- The action returns
update()anddestroy()automatically handled by Svelte. - If the
editorinstance changes, the adapter recreates the web editor.
