Plate
PlateEditorsTemplates
GitHub16kGitHub
DiscordDiscord
  • Plate
  • Editor API
  • Editor Transforms
  • Node
  • Element
  • Text
  • Path
  • Point
  • Range
  • Location
  • Anchor
  • Selection
  • Document Change
  • DOM API
  • React Hooks
  • Plate Core
    • Plate Components
    • Plate Editor
    • Plate Plugin
    • Editor Context
    • Plate Controller
  • Plate Utils
  • Resizable

Text API

PreviousNext

Text leaf API for marks and text checks.

Text objects represent the nodes that contain the actual text content of a Plate 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;
ElementPath

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(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.

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.