Socket
Socket
Sign inDemoInstall

@portabletext/types

Package Overview
Dependencies
Maintainers
8
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@portabletext/types

Shared TypeScript definitions for core Portable Text data structures


Version published
Weekly downloads
210K
increased by1.23%
Maintainers
8
Weekly downloads
 
Created

What is @portabletext/types?

@portabletext/types is a TypeScript library that provides type definitions for Portable Text, a JSON-based rich text format. It helps developers to work with Portable Text data structures in a type-safe manner.

What are @portabletext/types's main functionalities?

Type Definitions for Portable Text

This feature provides type definitions for Portable Text blocks, ensuring that the data structure adheres to the expected format. The code sample demonstrates how to define a Portable Text block with a single span child.

import { PortableTextBlock } from '@portabletext/types';

const exampleBlock: PortableTextBlock = {
  _type: 'block',
  _key: 'a1b2c3',
  children: [
    {
      _type: 'span',
      _key: 'd4e5f6',
      text: 'Hello, world!',
      marks: []
    }
  ],
  markDefs: [],
  style: 'normal'
};

Type Definitions for Annotations and Marks

This feature provides type definitions for annotations and marks within Portable Text. The code sample shows how to define a link annotation with a URL.

import { PortableTextMarkDefinition } from '@portabletext/types';

const exampleMarkDef: PortableTextMarkDefinition = {
  _type: 'link',
  _key: 'g7h8i9',
  href: 'https://example.com'
};

Type Definitions for Custom Portable Text Objects

This feature allows developers to define custom Portable Text objects with specific properties. The code sample demonstrates how to define a custom image object with a URL and alt text.

import { PortableTextObject } from '@portabletext/types';

const exampleCustomObject: PortableTextObject = {
  _type: 'image',
  _key: 'j1k2l3',
  url: 'https://example.com/image.jpg',
  alt: 'An example image'
};

Other packages similar to @portabletext/types

Keywords

FAQs

Package last updated on 10 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc