Plate
PlateEditorsTemplates
GitHub16kGitHub
DiscordDiscord
    • Overview
    • Why This Fork
    • Examples
    • Installing Plite
    • Adding Event Handlers
    • Defining Custom Elements
    • Applying Custom Formatting
    • Executing Commands
    • Saving to a Database
    • Canonical Change Substrate
    • Improving Performance
    • Interfaces
    • Nodes
    • Locations
    • Transforms
    • Document Changes
    • Commands
    • Editor
    • Plugins
    • Rendering
    • Serializing
    • Normalizing
    • Using TypeScript
    • Roots
    • Document State
    • Editing Behavior
    • Selection And DOM
    • Clipboard And Paste
    • Decorations, annotations, and widgets
    • Schema
    • 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
    • Plite DOM
    • History Editor API
    • History Plugin Setup
    • History
    • Plite History
    • Plite Hyperscript
    • Plite PaginationExperimental
    • Annotations
    • DOM Coverage Boundaries
    • Editable Component
    • External Text Views
    • Plite React Event Handling
    • Virtualized Rendering
    • Plite React Hooks
    • React Editor Setup
    • React Editor
    • Plite React
    • Plite Component
    • Plite Yjs
    • Plite
    • Migration
    • Contributing
    • FAQ
    • Resources

Text API

PreviousNext

Text leaf API for marks 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 {
  readonly text: string;
  readonly [key: string]: unknown;
}
interface Text {
  readonly text: string;
  readonly [key: string]: unknown;
}

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.

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<N extends Text = Text>(value: unknown): value is readonly N[]

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.

Node Types APIsDebug Value Scrubbing

On This Page

InterfaceOn this pageStatic methodsRetrieval methodsTextApi.matches(text: Text, props: Partial<Text>) => booleanCheck methodsTextApi.equals(text: Text, another: Text, options?) => booleanTextApi.isText(value: unknown) => value is TextTextApi.isTextList<N extends Text = Text>(value: unknown): value is readonly N[]TextApi.isTextProps(props: unknown) => props is Partial<Text>
Build your editor
Production-ready AI template and reusable components.
Get all-access