Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@portabletext/types

Package Overview
Dependencies
Maintainers
10
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@portabletext/types - npm Package Compare versions

Comparing version
3.0.0
to
3.0.1
+1
dist/index.d.ts.map
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/related.ts","../src/portableText.ts"],"sourcesContent":[],"mappings":"AAKA;AAkBA;;ACVA;;AACyC,UDTxB,WAAA,CCSwB;EAC7B;;;;EAES,KAAA,EAAA,MAAA;EAqBT;;;;EApBF,IAAA,CAAA,EAAA,MAAA;;AAwDV;;;;AAE0B,KDrDd,oBAAA,GAAuB,WCqDT,GAAA;EACL,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,GAAA;CACA;ADvDrB;;ACVA;;;;;;;;;AAgCa,UAhCI,iBAgCJ,CAMH,UArCE,0BAqCF,GArC+B,0BAqC/B,EAMG,UA1CD,WA0CC,GA1Ca,oBA0Cb,GA1CoC,gBA0CpC,EAvCH,UAAA,MAAA,GAFW,sBAEX,EAAA,UAAA,MAAA,GADW,wBACX,CAwDV,SAxDU,WAwDO,CAAA;EACL;;;;;;EAIqB,KAAA,EAAA,OAAA,GAAA,MAAA;EAAG;;;;;EAA1B,IAAA,CAAA,EAAA,MAAA;EAAA;AAQV;AAeA;AAQA;EAsBA,QAAiB,EA9FL,CA8FK,EAAA;EA4BjB;;;;;aAnHa;;;;;UAMH;;;;;aAMG;;;;;;;;;;;;;;;UAiBI,oCACL,6BAA6B,sCAC7B,cAAc,qCACL,2CACA,kCACX,KAAK,kBAAkB,GAAG,GAAG,GAAG;YAC9B;;;;;;KAOA,sBAAA;;;;;KAeA,wBAAA;;;;;;;UAQK,0BAAA;;;;;;;;;;;;;;;;;;;UAsBA,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;UA4BA,gBAAA"}
+109
-136
/**
* Any object with an `_type` that is a string. Can hold any other properties.
* @public
*/
export declare type ArbitraryTypedObject = TypedObject & {
* Any object with an `_type` property (which is required in portable text arrays),
* as well as a _potential_ `_key` (highly encouraged)
* @public
*/
interface TypedObject {
/**
* Identifies the type of object/span this is, and is used to pick the correct React components
* to use when rendering a span or inline object with this type.
*/
_type: string;
/**
* Uniquely identifies this object within its parent block.
* Not _required_, but highly encouraged.
*/
_key?: string;
}
/**
* Any object with an `_type` that is a string. Can hold any other properties.
* @public
*/
type ArbitraryTypedObject = TypedObject & {
[key: string]: any;
};
/**
* A Portable Text Block can be thought of as one paragraph, quote or list item.
* In other words, it is a container for text, that can have a visual style associated with it.
* The actual text value is stored in portable text spans inside of the `childen` array.
*
* @typeParam M - Mark types that be used for text spans
* @typeParam C - Types allowed as children of this block
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
* @public
*/
export declare interface PortableTextBlock<
M extends PortableTextMarkDefinition = PortableTextMarkDefinition,
C extends TypedObject = ArbitraryTypedObject | PortableTextSpan,
S extends string = PortableTextBlockStyle,
L extends string = PortableTextListItemType,
> extends TypedObject {
* A Portable Text Block can be thought of as one paragraph, quote or list item.
* In other words, it is a container for text, that can have a visual style associated with it.
* The actual text value is stored in portable text spans inside of the `childen` array.
*
* @typeParam M - Mark types that be used for text spans
* @typeParam C - Types allowed as children of this block
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
* @public
*/
interface PortableTextBlock<M extends PortableTextMarkDefinition = PortableTextMarkDefinition, C extends TypedObject = ArbitraryTypedObject | PortableTextSpan, S extends string = PortableTextBlockStyle, L extends string = PortableTextListItemType> extends TypedObject {
/**
* Type name identifying this as a portable text block.
* All items within a portable text array should have a `_type` property.
*
* Usually 'block', but can be customized to other values
*/
* Type name identifying this as a portable text block.
* All items within a portable text array should have a `_type` property.
*
* Usually 'block', but can be customized to other values
*/
_type: "block" | string;
/**
* A key that identifies this block uniquely within the parent array. Used to more easily address
* the block when editing collaboratively, but is also very useful for keys inside of React and
* other rendering frameworks that can use keys to optimize operations.
*/
* A key that identifies this block uniquely within the parent array. Used to more easily address
* the block when editing collaboratively, but is also very useful for keys inside of React and
* other rendering frameworks that can use keys to optimize operations.
*/
_key?: string;
/**
* Array of inline items for this block. Usually contain text spans, but can be
* configured to include inline objects of other types as well.
*/
* Array of inline items for this block. Usually contain text spans, but can be
* configured to include inline objects of other types as well.
*/
children: C[];
/**
* Array of mark definitions used in child text spans. By having them be on the block level,
* the same mark definition can be reused for multiple text spans, which is often the case
* with nested marks.
*/
* Array of mark definitions used in child text spans. By having them be on the block level,
* the same mark definition can be reused for multiple text spans, which is often the case
* with nested marks.
*/
markDefs?: M[];
/**
* Visual style of the block
* Common values: 'normal', 'blockquote', 'h1'...'h6'
*/
* Visual style of the block
* Common values: 'normal', 'blockquote', 'h1'...'h6'
*/
style?: S;
/**
* If this block is a list item, identifies which style of list item this is
* Common values: 'bullet', 'number', but can be configured
*/
* If this block is a list item, identifies which style of list item this is
* Common values: 'bullet', 'number', but can be configured
*/
listItem?: L;
/**
* If this block is a list item, identifies which level of nesting it belongs within
*/
* If this block is a list item, identifies which level of nesting it belongs within
*/
level?: number;
}
/**
* A set of _common_ (but not required/standarized) block styles
* @public
*/
export declare type PortableTextBlockStyle =
| "normal"
| "blockquote"
| "h1"
| "h2"
| "h3"
| "h4"
| "h5"
| "h6"
| string;
/**
* The simplest representation of a link
* @public
*/
export declare interface PortableTextLink {
_type: "link";
href: string;
}
/**
* Strictly speaking the same as a portable text block, but `listItem` is required
*
* @typeParam M - Mark types that be used for text spans
* @typeParam C - Types allowed as children of this block
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
* @public
*/
export declare interface PortableTextListItemBlock<
M extends PortableTextMarkDefinition = PortableTextMarkDefinition,
C extends TypedObject = PortableTextSpan,
S extends string = PortableTextBlockStyle,
L extends string = PortableTextListItemType,
> extends Omit<PortableTextBlock<M, C, S, L>, "listItem"> {
* Strictly speaking the same as a portable text block, but `listItem` is required
*
* @typeParam M - Mark types that be used for text spans
* @typeParam C - Types allowed as children of this block
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
* @public
*/
interface PortableTextListItemBlock<M extends PortableTextMarkDefinition = PortableTextMarkDefinition, C extends TypedObject = PortableTextSpan, S extends string = PortableTextBlockStyle, L extends string = PortableTextListItemType> extends Omit<PortableTextBlock<M, C, S, L>, "listItem"> {
listItem: L;
}
/**
* A set of _common_ (but not required/standardized) list item types
* @public
*/
export declare type PortableTextListItemType = "bullet" | "number" | string;
* A set of _common_ (but not required/standarized) block styles
* @public
*/
type PortableTextBlockStyle = "normal" | "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | string;
/**
* A mark definition holds information for marked text. For instance, a text span could reference
* a mark definition for a hyperlink, a geoposition, a reference to a document or anything that is
* representable as a JSON object.
* @public
*/
export declare interface PortableTextMarkDefinition {
* A set of _common_ (but not required/standardized) list item types
* @public
*/
type PortableTextListItemType = "bullet" | "number" | string;
/**
* A mark definition holds information for marked text. For instance, a text span could reference
* a mark definition for a hyperlink, a geoposition, a reference to a document or anything that is
* representable as a JSON object.
* @public
*/
interface PortableTextMarkDefinition {
/**
* Unknown properties
*/
* Unknown properties
*/
[key: string]: unknown;
/**
* Identifies the type of mark this is, and is used to pick the correct React components to use
* when rendering a text span marked with this mark type.
*/
* Identifies the type of mark this is, and is used to pick the correct React components to use
* when rendering a text span marked with this mark type.
*/
_type: string;
/**
* Uniquely identifies this mark definition within the block
*/
* Uniquely identifies this mark definition within the block
*/
_key: string;
}
/**
* A Portable Text Span holds a chunk of the actual text value of a Portable Text Block
* @public
*/
export declare interface PortableTextSpan {
* A Portable Text Span holds a chunk of the actual text value of a Portable Text Block
* @public
*/
interface PortableTextSpan {
/**
* Type is always `span` for portable text spans, as these don't vary in shape
*/
* Type is always `span` for portable text spans, as these don't vary in shape
*/
_type: "span";
/**
* Unique (within parent block) key for this portable text span
*/
* Unique (within parent block) key for this portable text span
*/
_key?: string;
/**
* The actual text value of this text span
*/
* The actual text value of this text span
*/
text: string;
/**
* An array of marks this text span is annotated with, identified by its `_key`.
* If the key cannot be found in the parent blocks mark definition, the mark is assumed to be a
* decorator (a simpler mark without any properties - for instance `strong` or `em`)
*/
* An array of marks this text span is annotated with, identified by its `_key`.
* If the key cannot be found in the parent blocks mark definition, the mark is assumed to be a
* decorator (a simpler mark without any properties - for instance `strong` or `em`)
*/
marks?: string[];
}
/**
* Any object with an `_type` property (which is required in portable text arrays),
* as well as a _potential_ `_key` (highly encouraged)
* @public
*/
export declare interface TypedObject {
/**
* Identifies the type of object/span this is, and is used to pick the correct React components
* to use when rendering a span or inline object with this type.
*/
_type: string;
/**
* Uniquely identifies this object within its parent block.
* Not _required_, but highly encouraged.
*/
_key?: string;
* The simplest representation of a link
* @public
*/
interface PortableTextLink {
_type: "link";
href: string;
}
export {};
export { ArbitraryTypedObject, PortableTextBlock, PortableTextBlockStyle, PortableTextLink, PortableTextListItemBlock, PortableTextListItemType, PortableTextMarkDefinition, PortableTextSpan, TypedObject };
//# sourceMappingURL=index.d.ts.map
{
"name": "@portabletext/types",
"version": "3.0.0",
"version": "3.0.1",
"description": "Shared TypeScript definitions for core Portable Text data structures",

@@ -21,13 +21,10 @@ "keywords": [

"exports": {
".": {
"source": "./src/index.ts",
"default": "./dist/index.js"
},
".": "./dist/index.js",
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"src"
"dist"
],

@@ -39,12 +36,11 @@ "lint-staged": {

},
"browserslist": "extends @sanity/browserslist-config",
"devDependencies": {
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.29.7",
"@sanity/browserslist-config": "^1.0.5",
"@sanity/pkg-utils": "^8.1.29",
"npm-run-all2": "^8.0.4",
"oxfmt": "^0.9.0",
"oxlint": "^1.25.0",
"typedoc": "^0.28.14",
"@changesets/changelog-github": "^0.5.2",
"@changesets/cli": "^2.29.8",
"@sanity/tsconfig": "^2.0.0",
"@sanity/tsdown-config": "^0.4.0",
"oxfmt": "^0.17.0",
"oxlint": "^1.32.0",
"tsdown": "^0.17.2",
"typedoc": "^0.28.15",
"typescript": "5.9.3"

@@ -55,7 +51,4 @@ },

},
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "pkg-utils build --strict --check --clean",
"build": "tsdown",
"docs:build": "typedoc",

@@ -66,4 +59,5 @@ "format": "oxfmt .",

"release": "changeset publish",
"test": "run-s build node:test"
"pretest": "pnpm run build",
"test": "pnpm run node:test"
}
}
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
export * from './portableText'
export * from './related'
import type {ArbitraryTypedObject, TypedObject} from './related'
/**
* A Portable Text Block can be thought of as one paragraph, quote or list item.
* In other words, it is a container for text, that can have a visual style associated with it.
* The actual text value is stored in portable text spans inside of the `childen` array.
*
* @typeParam M - Mark types that be used for text spans
* @typeParam C - Types allowed as children of this block
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
* @public
*/
export interface PortableTextBlock<
M extends PortableTextMarkDefinition = PortableTextMarkDefinition,
C extends TypedObject = ArbitraryTypedObject | PortableTextSpan,
S extends string = PortableTextBlockStyle,
L extends string = PortableTextListItemType,
> extends TypedObject {
/**
* Type name identifying this as a portable text block.
* All items within a portable text array should have a `_type` property.
*
* Usually 'block', but can be customized to other values
*/
_type: 'block' | string
/**
* A key that identifies this block uniquely within the parent array. Used to more easily address
* the block when editing collaboratively, but is also very useful for keys inside of React and
* other rendering frameworks that can use keys to optimize operations.
*/
_key?: string
/**
* Array of inline items for this block. Usually contain text spans, but can be
* configured to include inline objects of other types as well.
*/
children: C[]
/**
* Array of mark definitions used in child text spans. By having them be on the block level,
* the same mark definition can be reused for multiple text spans, which is often the case
* with nested marks.
*/
markDefs?: M[]
/**
* Visual style of the block
* Common values: 'normal', 'blockquote', 'h1'...'h6'
*/
style?: S
/**
* If this block is a list item, identifies which style of list item this is
* Common values: 'bullet', 'number', but can be configured
*/
listItem?: L
/**
* If this block is a list item, identifies which level of nesting it belongs within
*/
level?: number
}
/**
* Strictly speaking the same as a portable text block, but `listItem` is required
*
* @typeParam M - Mark types that be used for text spans
* @typeParam C - Types allowed as children of this block
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
* @public
*/
export interface PortableTextListItemBlock<
M extends PortableTextMarkDefinition = PortableTextMarkDefinition,
C extends TypedObject = PortableTextSpan,
S extends string = PortableTextBlockStyle,
L extends string = PortableTextListItemType,
> extends Omit<PortableTextBlock<M, C, S, L>, 'listItem'> {
listItem: L
}
/**
* A set of _common_ (but not required/standarized) block styles
* @public
*/
export type PortableTextBlockStyle =
| 'normal'
| 'blockquote'
| 'h1'
| 'h2'
| 'h3'
| 'h4'
| 'h5'
| 'h6'
| string
/**
* A set of _common_ (but not required/standardized) list item types
* @public
*/
export type PortableTextListItemType = 'bullet' | 'number' | string
/**
* A mark definition holds information for marked text. For instance, a text span could reference
* a mark definition for a hyperlink, a geoposition, a reference to a document or anything that is
* representable as a JSON object.
* @public
*/
export interface PortableTextMarkDefinition {
/**
* Unknown properties
*/
[key: string]: unknown
/**
* Identifies the type of mark this is, and is used to pick the correct React components to use
* when rendering a text span marked with this mark type.
*/
_type: string
/**
* Uniquely identifies this mark definition within the block
*/
_key: string
}
/**
* A Portable Text Span holds a chunk of the actual text value of a Portable Text Block
* @public
*/
export interface PortableTextSpan {
/**
* Type is always `span` for portable text spans, as these don't vary in shape
*/
_type: 'span'
/**
* Unique (within parent block) key for this portable text span
*/
_key?: string
/**
* The actual text value of this text span
*/
text: string
/**
* An array of marks this text span is annotated with, identified by its `_key`.
* If the key cannot be found in the parent blocks mark definition, the mark is assumed to be a
* decorator (a simpler mark without any properties - for instance `strong` or `em`)
*/
marks?: string[]
}
/**
* The simplest representation of a link
* @public
*/
export interface PortableTextLink {
_type: 'link'
href: string
}
/**
* Any object with an `_type` property (which is required in portable text arrays),
* as well as a _potential_ `_key` (highly encouraged)
* @public
*/
export interface TypedObject {
/**
* Identifies the type of object/span this is, and is used to pick the correct React components
* to use when rendering a span or inline object with this type.
*/
_type: string
/**
* Uniquely identifies this object within its parent block.
* Not _required_, but highly encouraged.
*/
_key?: string
}
/**
* Any object with an `_type` that is a string. Can hold any other properties.
* @public
*/
export type ArbitraryTypedObject = TypedObject & {
[key: string]: any
}