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
2.0.15
to
3.0.0
+33
-33
dist/index.d.ts

@@ -6,4 +6,4 @@ /**

export declare type ArbitraryTypedObject = TypedObject & {
[key: string]: any
}
[key: string]: any;
};

@@ -33,3 +33,3 @@ /**

*/
_type: 'block' | string
_type: "block" | string;
/**

@@ -40,3 +40,3 @@ * A key that identifies this block uniquely within the parent array. Used to more easily address

*/
_key?: string
_key?: string;
/**

@@ -46,3 +46,3 @@ * Array of inline items for this block. Usually contain text spans, but can be

*/
children: C[]
children: C[];
/**

@@ -53,3 +53,3 @@ * Array of mark definitions used in child text spans. By having them be on the block level,

*/
markDefs?: M[]
markDefs?: M[];
/**

@@ -59,3 +59,3 @@ * Visual style of the block

*/
style?: S
style?: S;
/**

@@ -65,7 +65,7 @@ * If this block is a list item, identifies which style of list item this is

*/
listItem?: L
listItem?: L;
/**
* If this block is a list item, identifies which level of nesting it belongs within
*/
level?: number
level?: number;
}

@@ -78,11 +78,11 @@

export declare type PortableTextBlockStyle =
| 'normal'
| 'blockquote'
| 'h1'
| 'h2'
| 'h3'
| 'h4'
| 'h5'
| 'h6'
| string
| "normal"
| "blockquote"
| "h1"
| "h2"
| "h3"
| "h4"
| "h5"
| "h6"
| string;

@@ -94,4 +94,4 @@ /**

export declare interface PortableTextLink {
_type: 'link'
href: string
_type: "link";
href: string;
}

@@ -113,4 +113,4 @@

L extends string = PortableTextListItemType,
> extends Omit<PortableTextBlock<M, C, S, L>, 'listItem'> {
listItem: L
> extends Omit<PortableTextBlock<M, C, S, L>, "listItem"> {
listItem: L;
}

@@ -122,3 +122,3 @@

*/
export declare type PortableTextListItemType = 'bullet' | 'number' | string
export declare type PortableTextListItemType = "bullet" | "number" | string;

@@ -135,3 +135,3 @@ /**

*/
[key: string]: unknown
[key: string]: unknown;
/**

@@ -141,7 +141,7 @@ * Identifies the type of mark this is, and is used to pick the correct React components to use

*/
_type: string
_type: string;
/**
* Uniquely identifies this mark definition within the block
*/
_key: string
_key: string;
}

@@ -157,11 +157,11 @@

*/
_type: 'span'
_type: "span";
/**
* Unique (within parent block) key for this portable text span
*/
_key?: string
_key?: string;
/**
* The actual text value of this text span
*/
text: string
text: string;
/**

@@ -172,3 +172,3 @@ * An array of marks this text span is annotated with, identified by its `_key`.

*/
marks?: string[]
marks?: string[];
}

@@ -186,3 +186,3 @@

*/
_type: string
_type: string;
/**

@@ -192,5 +192,5 @@ * Uniquely identifies this object within its parent block.

*/
_key?: string
_key?: string;
}
export {}
export {};
{
"name": "@portabletext/types",
"version": "2.0.15",
"version": "3.0.0",
"description": "Shared TypeScript definitions for core Portable Text data structures",

@@ -23,4 +23,2 @@ "keywords": [

"source": "./src/index.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.js"

@@ -30,4 +28,3 @@ },

},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",

@@ -40,43 +37,19 @@ "files": [

"*": [
"prettier --write --cache --ignore-unknown"
"oxfmt"
]
},
"browserslist": "extends @sanity/browserslist-config",
"prettier": "@sanity/prettier-config",
"eslintConfig": {
"parserOptions": {
"ecmaFeatures": {
"modules": true
},
"ecmaVersion": 9,
"sourceType": "module"
},
"extends": [
"sanity",
"sanity/typescript",
"prettier"
],
"ignorePatterns": [
"dist/**/"
]
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.29.6",
"@changesets/cli": "^2.29.7",
"@sanity/browserslist-config": "^1.0.5",
"@sanity/pkg-utils": "^8.0.3",
"@sanity/prettier-config": "^2.0.1",
"@types/babel__core": "^7.20.5",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.2",
"eslint-config-sanity": "^7.1.4",
"npm-run-all2": "^5.0.2",
"prettier": "^3.6.2",
"typedoc": "^0.28.10",
"typescript": "5.9.2"
"@sanity/pkg-utils": "^8.1.29",
"npm-run-all2": "^8.0.4",
"oxfmt": "^0.9.0",
"oxlint": "^1.25.0",
"typedoc": "^0.28.14",
"typescript": "5.9.3"
},
"engines": {
"node": "^14.13.1 || >=16.0.0 || >=18.0.0"
"node": ">=20.19 <22 || >=22.12"
},

@@ -89,8 +62,8 @@ "publishConfig": {

"docs:build": "typedoc",
"format": "prettier --write --cache --ignore-unknown .",
"lint": "eslint . --ext .cjs,.js,.jsx,.mjs,.ts,.tsx",
"format": "oxfmt .",
"lint": "oxlint --deny-warnings --report-unused-disable-directives",
"node:test": "node test/test.js",
"release": "changeset publish",
"test": "run-s lint build node:test"
"test": "run-s build node:test"
}
}

@@ -1,2 +0,2 @@

export * from './portableText.js'
export * from './related.js'
export * from './portableText'
export * from './related'

@@ -1,2 +0,2 @@

import type {ArbitraryTypedObject, TypedObject} from './related.js'
import type {ArbitraryTypedObject, TypedObject} from './related'

@@ -3,0 +3,0 @@ /**

@@ -25,4 +25,3 @@ /**

export type ArbitraryTypedObject = TypedObject & {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any
}
"use strict";
//# sourceMappingURL=index.cjs.map
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
/**
* Any object with an `_type` that is a string. Can hold any other properties.
* @public
*/
export declare 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 {
/**
* 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
}
/**
* 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'> {
listItem: L
}
/**
* A set of _common_ (but not required/standardized) list item types
* @public
*/
export declare 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 declare 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 declare 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[]
}
/**
* 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
}
export {}