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

Text API

PreviousNext

Text leaf API for marks, decorations, and text checks.

Text objects represent the nodes that contain the actual text content of a Plite document along with any formatting properties. They are always leaf nodes in the document tree as they cannot contain any children.

Interface

interface Text {
  text: string;
}
interface Text {
  text: string;
}
Node Types APIsDebug Value Scrubbing

On This Page

InterfaceOn This PageStatic methodsRetrieval methodsTextApi.matches(text: Text, props: Partial<Text>) => booleanTextApi.decorations(node: Text, decorations: DecoratedRange[]) => { leaf: Text; position?: LeafPosition }[]Check methodsTextApi.equals(text: Text, another: Text, options?) => booleanTextApi.isText(value: unknown) => value is TextTextApi.isTextList(value: unknown): value is Text[]TextApi.isTextProps(props: unknown) => props is Partial<Text>
Build your editor
Production-ready AI template and reusable components.
Get all-access

On This Page

  • Static methods
    • Retrieval methods
    • Check methods

Static methods

Retrieval methods

TextApi.matches(text: Text, props: Partial<Text>) => boolean

Check if text matches a set of props.

The way the check works is that it makes sure that (a) all the props exist in the text, and (b) if it exists, that it exactly matches the properties in the text.

If a props.text property is passed in, it will be ignored.

If there are properties in text that are not in props, those will be ignored when it comes to testing for a match.

TextApi.decorations(node: Text, decorations: DecoratedRange[]) => { leaf: Text; position?: LeafPosition }[]

Get the leaves and positions for a text node, given decorations.

Check methods

TextApi.equals(text: Text, another: Text, options?) => boolean

Check if two text nodes are equal.

Options: {loose?: boolean}

  • loose?: When true, it checks if the properties of the Text object are equal except for the text property (i.e. the String value of the Text). When false (default), checks all properties including text.

TextApi.isText(value: unknown) => value is Text

Check if a value implements the Text interface.

TextApi.isTextList(value: unknown): value is Text[]

Check if value is an Array of only Text objects.

TextApi.isTextProps(props: unknown) => props is Partial<Text>

Check if a value is an object that can be used as partial Text props.