From zbeyens. The source code is available on GitHub.

Plate
PlatePliteEditorsTemplates
GitHub16kGitHub
DiscordDiscord
UNPUBLISHED
  • Overview
  • Why This Fork
  • Examples
Walkthroughs
  • Installing Plite
  • Adding Event Handlers
  • Defining Custom Elements
  • Applying Custom Formatting
  • Executing Commands
  • Saving to a Database
  • Canonical Change Substrate
  • Improving Performance
Concepts
  • Interfaces
  • Nodes
  • Locations
  • Transforms
  • Document Changes
  • Commands
  • Editor
  • Extensions
  • Rendering
  • Serializing
  • Normalizing
  • Using TypeScript
  • Roots
  • Document State
  • Editing Behavior
  • Selection And DOM
  • Clipboard And Paste
  • Projection And Overlays
  • Schema
API
  • Anchor API
  • Location API
  • Path API
  • PointEntry API
  • Point API
  • Range API
  • Selection API
  • Location Types APIs
  • Span API
  • Editor
  • Element API
  • NodeEntry API
  • Node API
  • Node Types APIs
  • Text API
  • Debug Value Scrubbing
  • Transforms API
Libraries
  • Plite DOM
  • History Editor API
  • History Extension Setup
  • History
  • Plite History
  • Plite Hyperscript
  • Plite Layout
  • Annotations
  • DOM Coverage Boundaries
  • Editable Component
  • Plite React Event Handling
  • Virtualized Rendering
  • Plite React Hooks
  • React Editor Setup
  • React Editor
  • Plite React
  • Plite Component
  • Plite Yjs
  • Plite
General
  • Migration
  • Contributing
  • Docs Proof Map
  • FAQ
  • Resources

Plite Hyperscript

PreviousNext

Write Plite test fixtures as JSX when nested editor state is clearer as markup.

@platejs/plite-hyperscript creates Plite test fixtures with JSX. Use it when nested editor state is easier to read as markup than as raw JSON.

JSX Fixtures

/** @jsx jsx */
import { jsx } from "@platejs/plite-hyperscript";
 
const editor = (
  <editor>
    <element type="paragraph">
      alpha
      <cursor />
    </element>
  </editor>
);
/** @jsx jsx */
import { jsx } from "@platejs/plite-hyperscript"








The built-in tags create normal Plite objects:

  • <editor> creates an editor seeded with document and selection state.
  • <fragment> creates a Descendant[].
  • <element> creates an element with resolved children.
  • <text> creates one text node.
  • <cursor /> creates a collapsed selection point.
  • <anchor /> and <focus /> create an expanded selection.
  • <selection> creates a standalone Range from child anchor/focus tags.

Define domain tags with createHyperscript.

import { createHyperscript } from "@platejs/plite-hyperscript";
 
const h = createHyperscript({
  elements: {
    paragraph: { type: "paragraph" },
  },
});
 
const paragraph = h("paragraph", {}, "hello");
import { createHyperscript } from "@platejs/plite-hyperscript";
 
const h = createHyperscript({
  elements: {




Creator Helpers

jsx is the default fixture factory. createHyperscript builds a custom factory. createEditor and createText are low-level creators for custom factories and fixture helpers. HyperscriptCreators and HyperscriptShorthands are TypeScript helper types for custom factories.

Keep hyperscript in tests and fixtures. Runtime editor code should use normal Plite node values.

Plite HistoryPlite Layout

On This Page

JSX FixturesCreator Helpers
Build your editor
Production-ready AI template and reusable components.
Get all-access
;
const editor = (
<editor>
<element type="paragraph">
alpha
<cursor />
</element>
</editor>
);
paragraph: { type: "paragraph" },
},
});
const paragraph = h("paragraph", {}, "hello");