🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@portabletext/react

Package Overview
Dependencies
Maintainers
10
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@portabletext/react - npm Package Compare versions

Comparing version
4.0.3
to
5.0.0
+96
-80
dist/index.d.ts

@@ -1,18 +0,18 @@

import type {ArbitraryTypedObject} from '@portabletext/types'
import type {ComponentType} from 'react'
import {JSX} from 'react'
import {ToolkitListNestMode as ListNestMode} from '@portabletext/toolkit'
import {PortableTextBlock} from '@portabletext/types'
import type {PortableTextBlockStyle} from '@portabletext/types'
import type {PortableTextListItemBlock} from '@portabletext/types'
import type {PortableTextListItemType} from '@portabletext/types'
import type {ReactNode} from 'react'
import type {ToolkitPortableTextList} from '@portabletext/toolkit'
import type {ToolkitPortableTextListItem} from '@portabletext/toolkit'
import {toPlainText} from '@portabletext/toolkit'
import type {TypedObject} from '@portabletext/types'
import type { ArbitraryTypedObject } from "@portabletext/types";
import type { ComponentType } from "react";
import { JSX } from "react";
import { ToolkitListNestMode as ListNestMode } from "@portabletext/toolkit";
import { PortableTextBlock } from "@portabletext/types";
import type { PortableTextBlockStyle } from "@portabletext/types";
import type { PortableTextListItemBlock } from "@portabletext/types";
import type { PortableTextListItemType } from "@portabletext/types";
import type { ReactNode } from "react";
import type { ToolkitPortableTextList } from "@portabletext/toolkit";
import type { ToolkitPortableTextListItem } from "@portabletext/toolkit";
import { toPlainText } from "@portabletext/toolkit";
import type { TypedObject } from "@portabletext/types";
export declare const defaultComponents: PortableTextReactComponents
export declare const defaultComponents: PortableTextReactComponents;
export {ListNestMode}
export { ListNestMode };

@@ -22,3 +22,3 @@ export declare function mergeComponents(

overrides: PortableTextComponents,
): PortableTextReactComponents
): PortableTextReactComponents;

@@ -28,6 +28,6 @@ export declare type MissingComponentHandler = (

options: {
type: string
nodeType: NodeType
type: string;
nodeType: NodeType;
},
) => void
) => void;

@@ -38,7 +38,16 @@ /**

*/
export declare type NodeRenderer = <T extends TypedObject>(options: Serializable<T>) => ReactNode
export declare type NodeRenderer = <T extends TypedObject>(
options: Serializable<T>,
) => ReactNode;
export declare type NodeType = 'block' | 'mark' | 'blockStyle' | 'listStyle' | 'listItemStyle'
export declare type NodeType =
| "block"
| "mark"
| "blockStyle"
| "listStyle"
| "listItemStyle";
export declare function PortableText<B extends TypedObject = PortableTextBlock>({
export declare function PortableText<
B extends TypedObject = PortableTextBlock,
>({
value: input,

@@ -48,5 +57,5 @@ components: componentOverrides,

onMissingComponent: missingComponentHandler,
}: PortableTextProps<B>): JSX.Element
}: PortableTextProps<B>): JSX.Element;
export {PortableTextBlock}
export { PortableTextBlock };

@@ -56,3 +65,4 @@ /**

*/
export declare type PortableTextBlockComponent = PortableTextComponent<PortableTextBlock>
export declare type PortableTextBlockComponent =
PortableTextComponent<PortableTextBlock>;

@@ -64,3 +74,5 @@ /**

*/
export declare type PortableTextComponent<N> = ComponentType<PortableTextComponentProps<N>>
export declare type PortableTextComponent<N> = ComponentType<
PortableTextComponentProps<N>
>;

@@ -76,7 +88,7 @@ /**

*/
value: T
value: T;
/**
* Index within its parent
*/
index: number
index: number;
/**

@@ -86,7 +98,7 @@ * Whether or not this node is "inline" - ie as a child of a text block,

*/
isInline: boolean
isInline: boolean;
/**
* React child nodes of this block/component
*/
children?: ReactNode
children?: ReactNode;
/**

@@ -97,3 +109,3 @@ * Function used to render any node that might appear in a portable text array or block,

*/
renderNode: NodeRenderer
renderNode: NodeRenderer;
}

@@ -105,3 +117,4 @@

*/
export declare type PortableTextComponents = Partial<PortableTextReactComponents>
export declare type PortableTextComponents =
Partial<PortableTextReactComponents>;

@@ -111,3 +124,4 @@ /**

*/
export declare type PortableTextListComponent = PortableTextComponent<ReactPortableTextList>
export declare type PortableTextListComponent =
PortableTextComponent<ReactPortableTextList>;

@@ -117,3 +131,4 @@ /**

*/
export declare type PortableTextListItemComponent = PortableTextComponent<PortableTextListItemBlock>
export declare type PortableTextListItemComponent =
PortableTextComponent<PortableTextListItemBlock>;

@@ -125,5 +140,4 @@ /**

*/
export declare type PortableTextMarkComponent<M extends TypedObject = any> = ComponentType<
PortableTextMarkComponentProps<M>
>
export declare type PortableTextMarkComponent<M extends TypedObject = any> =
ComponentType<PortableTextMarkComponentProps<M>>;

@@ -141,19 +155,19 @@ /**

*/
value?: M
value?: M;
/**
* Text content of this mark
*/
text: string
text: string;
/**
* Key for this mark. The same key can be used amongst multiple text spans within the same block, so don't rely on this for React keys.
*/
markKey?: string
markKey?: string;
/**
* Type of mark - ie value of `_type` in the case of annotations, or the name of the decorator otherwise - eg `em`, `italic`.
*/
markType: string
markType: string;
/**
* React child nodes of this mark
*/
children: ReactNode
children: ReactNode;
/**

@@ -164,3 +178,3 @@ * Function used to render any node that might appear in a portable text array or block,

*/
renderNode: NodeRenderer
renderNode: NodeRenderer;
}

@@ -179,7 +193,7 @@

*/
value: B | B[]
value: B | B[];
/**
* React components to use for rendering
*/
components?: Partial<PortableTextReactComponents>
components?: Partial<PortableTextReactComponents>;
/**

@@ -192,3 +206,3 @@ * Function to call when encountering unknown unknown types, eg blocks, marks,

*/
onMissingComponent?: MissingComponentHandler | false
onMissingComponent?: MissingComponentHandler | false;
/**

@@ -200,3 +214,3 @@ * Determines whether or not lists are nested inside of list items (`html`)

*/
listNestingMode?: ListNestMode
listNestingMode?: ListNestMode;
}

@@ -219,3 +233,3 @@

*/
types: Record<string, PortableTextTypeComponent | undefined>
types: Record<string, PortableTextTypeComponent | undefined>;
/**

@@ -227,3 +241,3 @@ * Object of React components that renders different types of marks that might appear in spans.

*/
marks: Record<string, PortableTextMarkComponent | undefined>
marks: Record<string, PortableTextMarkComponent | undefined>;
/**

@@ -239,3 +253,3 @@ * Object of React components that renders blocks with different `style` properties.

| Record<PortableTextBlockStyle, PortableTextBlockComponent | undefined>
| PortableTextBlockComponent
| PortableTextBlockComponent;
/**

@@ -253,3 +267,3 @@ * Object of React components used to render lists of different types (bulleted vs numbered,

| Record<PortableTextListItemType, PortableTextListComponent | undefined>
| PortableTextListComponent
| PortableTextListComponent;
/**

@@ -264,4 +278,7 @@ * Object of React components used to render different list item styles.

listItem:
| Record<PortableTextListItemType, PortableTextListItemComponent | undefined>
| PortableTextListItemComponent
| Record<
PortableTextListItemType,
PortableTextListItemComponent | undefined
>
| PortableTextListItemComponent;
/**

@@ -271,3 +288,3 @@ * Component to use for rendering "hard breaks", eg `\n` inside of text spans

*/
hardBreak: ComponentType<{}> | false
hardBreak: ComponentType | false;
/**

@@ -277,3 +294,3 @@ * React component used when encountering a mark type there is no registered component for

*/
unknownMark: PortableTextMarkComponent
unknownMark: PortableTextMarkComponent;
/**

@@ -283,3 +300,3 @@ * React component used when encountering an object type there is no registered component for

*/
unknownType: PortableTextComponent<UnknownNodeType>
unknownType: PortableTextComponent<UnknownNodeType>;
/**

@@ -289,3 +306,3 @@ * React component used when encountering a block style there is no registered component for

*/
unknownBlockStyle: PortableTextComponent<PortableTextBlock>
unknownBlockStyle: PortableTextComponent<PortableTextBlock>;
/**

@@ -295,3 +312,3 @@ * React component used when encountering a list style there is no registered component for

*/
unknownList: PortableTextComponent<ReactPortableTextList>
unknownList: PortableTextComponent<ReactPortableTextList>;
/**

@@ -301,8 +318,7 @@ * React component used when encountering a list item style there is no registered component for

*/
unknownListItem: PortableTextComponent<PortableTextListItemBlock>
unknownListItem: PortableTextComponent<PortableTextListItemBlock>;
}
export declare type PortableTextTypeComponent<V extends TypedObject = any> = ComponentType<
PortableTextTypeComponentProps<V>
>
export declare type PortableTextTypeComponent<V extends TypedObject = any> =
ComponentType<PortableTextTypeComponentProps<V>>;

@@ -316,4 +332,4 @@ /**

PortableTextComponentProps<T>,
'children'
>
"children"
>;

@@ -324,3 +340,3 @@ /**

*/
export declare type ReactPortableTextList = ToolkitPortableTextList
export declare type ReactPortableTextList = ToolkitPortableTextList;

@@ -331,20 +347,20 @@ /**

*/
export declare type ReactPortableTextListItem = ToolkitPortableTextListItem
export declare type ReactPortableTextListItem = ToolkitPortableTextListItem;
export declare interface Serializable<T> {
node: T
index: number
isInline: boolean
renderNode: NodeRenderer
node: T;
index: number;
isInline: boolean;
renderNode: NodeRenderer;
}
export declare interface SerializedBlock {
_key: string
children: ReactNode
index: number
isInline: boolean
node: PortableTextBlock | PortableTextListItemBlock
_key: string;
children: ReactNode;
index: number;
isInline: boolean;
node: PortableTextBlock | PortableTextListItemBlock;
}
export {toPlainText}
export { toPlainText };

@@ -357,7 +373,7 @@ /**

| {
[key: string]: unknown
_type: string
[key: string]: unknown;
_type: string;
}
| TypedObject
| TypedObject;
export {}
export {};

@@ -8,3 +8,3 @@ import { jsx, Fragment } from "react/jsx-runtime";

bullet: ({ children }) => /* @__PURE__ */ jsx("ul", { children })
}, DefaultListItem = ({ children }) => /* @__PURE__ */ jsx("li", { children }), link = ({ children, value }) => /* @__PURE__ */ jsx("a", { href: value == null ? void 0 : value.href, children }), underlineStyle = { textDecoration: "underline" }, defaultMarks = {
}, DefaultListItem = ({ children }) => /* @__PURE__ */ jsx("li", { children }), link = ({ children, value }) => /* @__PURE__ */ jsx("a", { href: value?.href, children }), underlineStyle = { textDecoration: "underline" }, defaultMarks = {
em: ({ children }) => /* @__PURE__ */ jsx("em", { children }),

@@ -56,3 +56,10 @@ strong: ({ children }) => /* @__PURE__ */ jsx("strong", { children }),

function mergeComponents(parent, overrides) {
const { block, list, listItem, marks, types, ...rest } = overrides;
const {
block: _block,
list: _list,
listItem: _listItem,
marks: _marks,
types: _types,
...rest
} = overrides;
return {

@@ -105,4 +112,8 @@ ...parent,

if (node.style && node.style !== "normal") {
const { listItem, ...blockNode } = node;
children = renderNode({ node: blockNode, index, isInline: !1 });
const { listItem: _listItem, ...blockNode } = node;
children = renderNode({
node: blockNode,
index,
isInline: !1
});
}

@@ -121,3 +132,6 @@ return /* @__PURE__ */ jsx(Li, { value: node, index, isInline: !1, renderNode, children }, key);

const style = node.listItem || "bullet";
handleMissingComponent(unknownListStyleWarning(style), { nodeType: "listStyle", type: style });
handleMissingComponent(unknownListStyleWarning(style), {
nodeType: "listStyle",
type: style
});
}

@@ -128,5 +142,12 @@ return /* @__PURE__ */ jsx(List, { value: node, index, isInline: !1, renderNode, children }, key);

const { markDef, markType, markKey } = node, Span = components.marks[markType] || components.unknownMark, children = node.children.map(
(child, childIndex) => renderNode({ node: child, index: childIndex, isInline: !0 })
(child, childIndex) => renderNode({
node: child,
index: childIndex,
isInline: !0
})
);
return Span === components.unknownMark && handleMissingComponent(unknownMarkWarning(markType), { nodeType: "mark", type: markType }), /* @__PURE__ */ jsx(
return Span === components.unknownMark && handleMissingComponent(unknownMarkWarning(markType), {
nodeType: "mark",
type: markType
}), /* @__PURE__ */ jsx(
Span,

@@ -145,3 +166,8 @@ {

function renderBlock(node, index, key, isInline) {
const { _key, ...props } = serializeBlock({ node, index, isInline, renderNode }), style = props.node.style || "normal", Block = (typeof components.block == "function" ? components.block : components.block[style]) || components.unknownBlockStyle;
const { _key, ...props } = serializeBlock({
node,
index,
isInline,
renderNode
}), style = props.node.style || "normal", Block = (typeof components.block == "function" ? components.block : components.block[style]) || components.unknownBlockStyle;
return Block === components.unknownBlockStyle && handleMissingComponent(unknownBlockStyleWarning(style), {

@@ -168,3 +194,6 @@ nodeType: "blockStyle",

};
handleMissingComponent(unknownTypeWarning(node._type), { nodeType: "block", type: node._type });
handleMissingComponent(unknownTypeWarning(node._type), {
nodeType: "block",
type: node._type
});
const UnknownType = components.unknownType;

@@ -171,0 +200,0 @@ return /* @__PURE__ */ jsx(UnknownType, { ...nodeOptions }, key);

{
"name": "@portabletext/react",
"version": "4.0.3",
"version": "5.0.0",
"description": "Render Portable Text with React",

@@ -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",

@@ -41,68 +38,32 @@ "files": [

"*": [
"prettier --write --cache --ignore-unknown"
"oxfmt"
]
},
"browserslist": [
"extends @sanity/browserslist-config",
"node 14"
],
"prettier": "@sanity/prettier-config",
"eslintConfig": {
"parserOptions": {
"ecmaFeatures": {
"modules": true
},
"ecmaVersion": 9,
"sourceType": "module"
},
"plugins": [
"react-compiler"
],
"extends": [
"sanity",
"sanity/react",
"sanity/typescript",
"prettier"
],
"rules": {
"react-compiler/react-compiler": "error",
"react/prop-types": "off"
},
"ignorePatterns": [
"dist/**/"
]
},
"browserslist": "extends @sanity/browserslist-config",
"dependencies": {
"@portabletext/toolkit": "^3.0.1",
"@portabletext/types": "^2.0.15"
"@portabletext/toolkit": "^4.0.0",
"@portabletext/types": "^3.0.0"
},
"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.1.4",
"@sanity/prettier-config": "^2.0.1",
"@sanity/ui": "^3.0.8",
"@types/leaflet": "^1.9.20",
"@types/react": "^19.1.12",
"@types/react-dom": "^19.1.9",
"@sanity/pkg-utils": "^9.0.1",
"@sanity/ui": "^3.1.11",
"@types/leaflet": "^1.9.21",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@types/ws": "^8.18.1",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitejs/plugin-react": "^5.0.2",
"babel-plugin-react-compiler": "19.1.0-rc.3",
"esbuild": "^0.25.9",
"@vitejs/plugin-react": "^5.1.0",
"babel-plugin-react-compiler": "1.0.0",
"esbuild": "^0.25.12",
"esbuild-register": "^3.6.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.8",
"eslint-config-sanity": "^7.1.4",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-compiler": "19.1.0-rc.2",
"eslint-plugin-react-hooks": "^5.2.0",
"leaflet": "^1.9.4",
"npm-run-all2": "^8.0.4",
"prettier": "^3.6.2",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-is": "^19.1.1",
"oxfmt": "^0.9.0",
"oxlint": "^1.25.0",
"oxlint-tsgolint": "^0.5.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-is": "^19.2.0",
"react-leaflet": "^5.0.0",

@@ -112,7 +73,7 @@ "react-refractor": "^4.0.0",

"rimraf": "^5.0.1",
"rollup-plugin-visualizer": "^6.0.3",
"styled-components": "npm:@sanity/css-in-js@6.1.21",
"typescript": "5.9.2",
"vite": "^7.1.4",
"vitest": "^3.2.4"
"rollup-plugin-visualizer": "^6.0.5",
"styled-components": "npm:@sanity/css-in-js@6.1.25",
"typescript": "5.9.3",
"vite": "^7.1.12",
"vitest": "^4.0.7"
},

@@ -123,3 +84,3 @@ "peerDependencies": {

"engines": {
"node": "^14.13.1 || >=16.0.0"
"node": ">=20.19 <22 || >=22.12"
},

@@ -134,4 +95,4 @@ "publishConfig": {

"dev": "vite demo --config=./vite.config.demo.ts",
"format": "prettier --write --cache --ignore-unknown .",
"lint": "eslint .",
"format": "oxfmt .",
"lint": "oxlint --deny-warnings --report-unused-disable-directives --type-aware",
"release": "changeset publish",

@@ -138,0 +99,0 @@ "start": "pnpm dev",

@@ -182,2 +182,3 @@ # @portabletext/react

// Ex. 1: customizing common block types
normal: ({children}) => <p className="text-sm">{children}</p>,
h1: ({children}) => <h1 className="text-2xl">{children}</h1>,

@@ -184,0 +185,0 @@ blockquote: ({children}) => <blockquote className="border-l-purple-500">{children}</blockquote>,

@@ -17,8 +17,8 @@ import type {TypedObject} from '@portabletext/types'

export const defaultMarks: Record<string, PortableTextMarkComponent | undefined> = {
'em': ({children}) => <em>{children}</em>,
'strong': ({children}) => <strong>{children}</strong>,
'code': ({children}) => <code>{children}</code>,
'underline': ({children}) => <span style={underlineStyle}>{children}</span>,
em: ({children}) => <em>{children}</em>,
strong: ({children}) => <strong>{children}</strong>,
code: ({children}) => <code>{children}</code>,
underline: ({children}) => <span style={underlineStyle}>{children}</span>,
'strike-through': ({children}) => <del>{children}</del>,
link,
}

@@ -7,4 +7,10 @@ import type {PortableTextComponents, PortableTextReactComponents} from '../types'

): PortableTextReactComponents {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {block, list, listItem, marks, types, ...rest} = overrides
const {
block: _block,
list: _list,
listItem: _listItem,
marks: _marks,
types: _types,
...rest
} = overrides
// @todo figure out how to not `as ...` these

@@ -11,0 +17,0 @@ return {

@@ -13,9 +13,3 @@ import type {ToolkitNestedPortableTextSpan, ToolkitTextNode} from '@portabletext/toolkit'

} from '@portabletext/toolkit'
import type {
PortableTextBlock,
PortableTextListItemBlock,
PortableTextMarkDefinition,
PortableTextSpan,
TypedObject,
} from '@portabletext/types'
import type {PortableTextBlock, PortableTextListItemBlock, TypedObject} from '@portabletext/types'
import {type JSX, type ReactNode, useMemo} from 'react'

@@ -109,8 +103,3 @@

/* eslint-disable react/jsx-no-bind */
function renderListItem(
node: PortableTextListItemBlock<PortableTextMarkDefinition, PortableTextSpan>,
index: number,
key: string,
) {
function renderListItem(node: PortableTextListItemBlock, index: number, key: string) {
const tree = serializeBlock({node, index, isInline: false, renderNode})

@@ -132,5 +121,9 @@ const renderer = components.listItem

// Wrap any other style in whatever the block serializer says to use
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {listItem, ...blockNode} = node
children = renderNode({node: blockNode, index, isInline: false, renderNode})
const {listItem: _listItem, ...blockNode} = node
children = renderNode({
node: blockNode,
index,
isInline: false,
renderNode,
})
}

@@ -161,3 +154,6 @@

const style = node.listItem || 'bullet'
handleMissingComponent(unknownListStyleWarning(style), {nodeType: 'listStyle', type: style})
handleMissingComponent(unknownListStyleWarning(style), {
nodeType: 'listStyle',
type: style,
})
}

@@ -176,7 +172,15 @@

const children = node.children.map((child, childIndex) =>
renderNode({node: child, index: childIndex, isInline: true, renderNode}),
renderNode({
node: child,
index: childIndex,
isInline: true,
renderNode,
}),
)
if (Span === components.unknownMark) {
handleMissingComponent(unknownMarkWarning(markType), {nodeType: 'mark', type: markType})
handleMissingComponent(unknownMarkWarning(markType), {
nodeType: 'mark',
type: markType,
})
}

@@ -199,4 +203,8 @@

function renderBlock(node: PortableTextBlock, index: number, key: string, isInline: boolean) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {_key, ...props} = serializeBlock({node, index, isInline, renderNode})
const {_key, ...props} = serializeBlock({
node,
index,
isInline,
renderNode,
})
const style = props.node.style || 'normal'

@@ -234,3 +242,6 @@ const handler =

handleMissingComponent(unknownTypeWarning(node._type), {nodeType: 'block', type: node._type})
handleMissingComponent(unknownTypeWarning(node._type), {
nodeType: 'block',
type: node._type,
})

@@ -252,3 +263,2 @@ const UnknownType = components.unknownType

}
/* eslint-enable react/jsx-no-bind */

@@ -255,0 +265,0 @@ return renderNode

@@ -79,11 +79,9 @@ import type {

*/
export type PortableTextMarkComponent<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
M extends TypedObject = any,
> = ComponentType<PortableTextMarkComponentProps<M>>
export type PortableTextMarkComponent<M extends TypedObject = any> = ComponentType<
PortableTextMarkComponentProps<M>
>
export type PortableTextTypeComponent<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
V extends TypedObject = any,
> = ComponentType<PortableTextTypeComponentProps<V>>
export type PortableTextTypeComponent<V extends TypedObject = any> = ComponentType<
PortableTextTypeComponentProps<V>
>

@@ -163,5 +161,3 @@ /**

*/
// @TODO find a better way to handle this
// eslint-disable-next-line @typescript-eslint/ban-types
hardBreak: ComponentType<{}> | false
hardBreak: ComponentType | false

@@ -168,0 +164,0 @@ /**

@@ -20,3 +20,4 @@ const getTemplate = (type: string, prop: string): string =>

export function printWarning(message: string): void {
// oxlint-disable-next-line no-console
console.warn(message)
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
var jsxRuntime = require("react/jsx-runtime"), toolkit = require("@portabletext/toolkit"), react = require("react");
const defaultLists = {
number: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("ol", { children }),
bullet: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { children })
}, DefaultListItem = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children }), link = ({ children, value }) => /* @__PURE__ */ jsxRuntime.jsx("a", { href: value == null ? void 0 : value.href, children }), underlineStyle = { textDecoration: "underline" }, defaultMarks = {
em: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("em", { children }),
strong: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("strong", { children }),
code: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("code", { children }),
underline: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { style: underlineStyle, children }),
"strike-through": ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("del", { children }),
link
}, getTemplate = (type, prop) => `[@portabletext/react] Unknown ${type}, specify a component for it in the \`components.${prop}\` prop`, unknownTypeWarning = (typeName) => getTemplate(`block type "${typeName}"`, "types"), unknownMarkWarning = (markType) => getTemplate(`mark type "${markType}"`, "marks"), unknownBlockStyleWarning = (blockStyle) => getTemplate(`block style "${blockStyle}"`, "block"), unknownListStyleWarning = (listStyle) => getTemplate(`list style "${listStyle}"`, "list"), unknownListItemStyleWarning = (listStyle) => getTemplate(`list item style "${listStyle}"`, "listItem");
function printWarning(message) {
console.warn(message);
}
const hidden = { display: "none" }, DefaultUnknownType = ({
value,
isInline
}) => {
const warning = unknownTypeWarning(value._type);
return isInline ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: hidden, children: warning }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: hidden, children: warning });
}, DefaultUnknownMark = ({
markType,
children
}) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: `unknown__pt__mark__${markType}`, children }), DefaultUnknownBlockStyle = ({
children
}) => /* @__PURE__ */ jsxRuntime.jsx("p", { children }), DefaultUnknownList = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { children }), DefaultUnknownListItem = ({
children
}) => /* @__PURE__ */ jsxRuntime.jsx("li", { children }), DefaultHardBreak = () => /* @__PURE__ */ jsxRuntime.jsx("br", {}), defaultBlockStyles = {
normal: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("p", { children }),
blockquote: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { children }),
h1: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h1", { children }),
h2: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h2", { children }),
h3: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { children }),
h4: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h4", { children }),
h5: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h5", { children }),
h6: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h6", { children })
}, defaultComponents = {
types: {},
block: defaultBlockStyles,
marks: defaultMarks,
list: defaultLists,
listItem: DefaultListItem,
hardBreak: DefaultHardBreak,
unknownType: DefaultUnknownType,
unknownMark: DefaultUnknownMark,
unknownList: DefaultUnknownList,
unknownListItem: DefaultUnknownListItem,
unknownBlockStyle: DefaultUnknownBlockStyle
};
function mergeComponents(parent, overrides) {
const { block, list, listItem, marks, types, ...rest } = overrides;
return {
...parent,
block: mergeDeeply(parent, overrides, "block"),
list: mergeDeeply(parent, overrides, "list"),
listItem: mergeDeeply(parent, overrides, "listItem"),
marks: mergeDeeply(parent, overrides, "marks"),
types: mergeDeeply(parent, overrides, "types"),
...rest
};
}
function mergeDeeply(parent, overrides, key) {
const override = overrides[key], parentVal = parent[key];
return typeof override == "function" || override && typeof parentVal == "function" ? override : override ? { ...parentVal, ...override } : parentVal;
}
function PortableText({
value: input,
components: componentOverrides,
listNestingMode,
onMissingComponent: missingComponentHandler = printWarning
}) {
const handleMissingComponent = missingComponentHandler || noop, blocks = Array.isArray(input) ? input : [input], nested = toolkit.nestLists(blocks, listNestingMode || toolkit.LIST_NEST_MODE_HTML), components = react.useMemo(() => componentOverrides ? mergeComponents(defaultComponents, componentOverrides) : defaultComponents, [componentOverrides]), renderNode = react.useMemo(
() => getNodeRenderer(components, handleMissingComponent),
[components, handleMissingComponent]
), rendered = nested.map(
(node, index) => renderNode({ node, index, isInline: !1, renderNode })
);
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: rendered });
}
const getNodeRenderer = (components, handleMissingComponent) => {
function renderNode(options) {
const { node, index, isInline } = options, key = node._key || `node-${index}`;
return toolkit.isPortableTextToolkitList(node) ? renderList(node, index, key) : toolkit.isPortableTextListItemBlock(node) ? renderListItem(node, index, key) : toolkit.isPortableTextToolkitSpan(node) ? renderSpan(node, index, key) : hasCustomComponentForNode(node) ? renderCustomBlock(node, index, key, isInline) : toolkit.isPortableTextBlock(node) ? renderBlock(node, index, key, isInline) : toolkit.isPortableTextToolkitTextNode(node) ? renderText(node, key) : renderUnknownType(node, index, key, isInline);
}
function hasCustomComponentForNode(node) {
return node._type in components.types;
}
function renderListItem(node, index, key) {
const tree = serializeBlock({ node, index, isInline: !1, renderNode }), renderer = components.listItem, Li = (typeof renderer == "function" ? renderer : renderer[node.listItem]) || components.unknownListItem;
if (Li === components.unknownListItem) {
const style = node.listItem || "bullet";
handleMissingComponent(unknownListItemStyleWarning(style), {
type: style,
nodeType: "listItemStyle"
});
}
let children = tree.children;
if (node.style && node.style !== "normal") {
const { listItem, ...blockNode } = node;
children = renderNode({ node: blockNode, index, isInline: !1 });
}
return /* @__PURE__ */ jsxRuntime.jsx(Li, { value: node, index, isInline: !1, renderNode, children }, key);
}
function renderList(node, index, key) {
const children = node.children.map(
(child, childIndex) => renderNode({
node: child._key ? child : { ...child, _key: `li-${index}-${childIndex}` },
index: childIndex,
isInline: !1
})
), component = components.list, List = (typeof component == "function" ? component : component[node.listItem]) || components.unknownList;
if (List === components.unknownList) {
const style = node.listItem || "bullet";
handleMissingComponent(unknownListStyleWarning(style), { nodeType: "listStyle", type: style });
}
return /* @__PURE__ */ jsxRuntime.jsx(List, { value: node, index, isInline: !1, renderNode, children }, key);
}
function renderSpan(node, _index, key) {
const { markDef, markType, markKey } = node, Span = components.marks[markType] || components.unknownMark, children = node.children.map(
(child, childIndex) => renderNode({ node: child, index: childIndex, isInline: !0 })
);
return Span === components.unknownMark && handleMissingComponent(unknownMarkWarning(markType), { nodeType: "mark", type: markType }), /* @__PURE__ */ jsxRuntime.jsx(
Span,
{
text: toolkit.spanToPlainText(node),
value: markDef,
markType,
markKey,
renderNode,
children
},
key
);
}
function renderBlock(node, index, key, isInline) {
const { _key, ...props } = serializeBlock({ node, index, isInline, renderNode }), style = props.node.style || "normal", Block = (typeof components.block == "function" ? components.block : components.block[style]) || components.unknownBlockStyle;
return Block === components.unknownBlockStyle && handleMissingComponent(unknownBlockStyleWarning(style), {
nodeType: "blockStyle",
type: style
}), /* @__PURE__ */ jsxRuntime.jsx(Block, { ...props, value: props.node, renderNode }, key);
}
function renderText(node, key) {
if (node.text === `
`) {
const HardBreak = components.hardBreak;
return HardBreak ? /* @__PURE__ */ jsxRuntime.jsx(HardBreak, {}, key) : `
`;
}
return node.text;
}
function renderUnknownType(node, index, key, isInline) {
const nodeOptions = {
value: node,
isInline,
index,
renderNode
};
handleMissingComponent(unknownTypeWarning(node._type), { nodeType: "block", type: node._type });
const UnknownType = components.unknownType;
return /* @__PURE__ */ jsxRuntime.jsx(UnknownType, { ...nodeOptions }, key);
}
function renderCustomBlock(node, index, key, isInline) {
const nodeOptions = {
value: node,
isInline,
index,
renderNode
}, Node = components.types[node._type];
return Node ? /* @__PURE__ */ jsxRuntime.jsx(Node, { ...nodeOptions }, key) : null;
}
return renderNode;
};
function serializeBlock(options) {
const { node, index, isInline, renderNode } = options, children = toolkit.buildMarksTree(node).map(
(child, i) => renderNode({ node: child, isInline: !0, index: i, renderNode })
);
return {
_key: node._key || `block-${index}`,
children,
index,
isInline,
node
};
}
function noop() {
}
Object.defineProperty(exports, "toPlainText", {
enumerable: !0,
get: function() {
return toolkit.toPlainText;
}
});
exports.PortableText = PortableText;
exports.defaultComponents = defaultComponents;
exports.mergeComponents = mergeComponents;
//# sourceMappingURL=index.cjs.map
{"version":3,"file":"index.cjs","sources":["../src/components/list.tsx","../src/components/marks.tsx","../src/warnings.ts","../src/components/unknown.tsx","../src/components/defaults.tsx","../src/components/merge.ts","../src/react-portable-text.tsx"],"sourcesContent":["import type {PortableTextListComponent, PortableTextListItemComponent} from '../types'\n\nexport const defaultLists: Record<'number' | 'bullet', PortableTextListComponent> = {\n number: ({children}) => <ol>{children}</ol>,\n bullet: ({children}) => <ul>{children}</ul>,\n}\n\nexport const DefaultListItem: PortableTextListItemComponent = ({children}) => <li>{children}</li>\n","import type {TypedObject} from '@portabletext/types'\n\nimport type {PortableTextMarkComponent} from '../types'\n\ninterface DefaultLink extends TypedObject {\n _type: 'link'\n href: string\n}\n\nconst link: PortableTextMarkComponent<DefaultLink> = ({children, value}) => (\n <a href={value?.href}>{children}</a>\n)\n\nconst underlineStyle = {textDecoration: 'underline'}\n\nexport const defaultMarks: Record<string, PortableTextMarkComponent | undefined> = {\n 'em': ({children}) => <em>{children}</em>,\n 'strong': ({children}) => <strong>{children}</strong>,\n 'code': ({children}) => <code>{children}</code>,\n 'underline': ({children}) => <span style={underlineStyle}>{children}</span>,\n 'strike-through': ({children}) => <del>{children}</del>,\n link,\n}\n","const getTemplate = (type: string, prop: string): string =>\n `[@portabletext/react] Unknown ${type}, specify a component for it in the \\`components.${prop}\\` prop`\n\nexport const unknownTypeWarning = (typeName: string): string =>\n getTemplate(`block type \"${typeName}\"`, 'types')\n\nexport const unknownMarkWarning = (markType: string): string =>\n getTemplate(`mark type \"${markType}\"`, 'marks')\n\nexport const unknownBlockStyleWarning = (blockStyle: string): string =>\n getTemplate(`block style \"${blockStyle}\"`, 'block')\n\nexport const unknownListStyleWarning = (listStyle: string): string =>\n getTemplate(`list style \"${listStyle}\"`, 'list')\n\nexport const unknownListItemStyleWarning = (listStyle: string): string =>\n getTemplate(`list item style \"${listStyle}\"`, 'listItem')\n\nexport function printWarning(message: string): void {\n console.warn(message)\n}\n","import type {PortableTextReactComponents} from '../types'\nimport {unknownTypeWarning} from '../warnings'\n\nconst hidden = {display: 'none'}\n\nexport const DefaultUnknownType: PortableTextReactComponents['unknownType'] = ({\n value,\n isInline,\n}) => {\n const warning = unknownTypeWarning(value._type)\n return isInline ? <span style={hidden}>{warning}</span> : <div style={hidden}>{warning}</div>\n}\n\nexport const DefaultUnknownMark: PortableTextReactComponents['unknownMark'] = ({\n markType,\n children,\n}) => {\n return <span className={`unknown__pt__mark__${markType}`}>{children}</span>\n}\n\nexport const DefaultUnknownBlockStyle: PortableTextReactComponents['unknownBlockStyle'] = ({\n children,\n}) => {\n return <p>{children}</p>\n}\n\nexport const DefaultUnknownList: PortableTextReactComponents['unknownList'] = ({children}) => {\n return <ul>{children}</ul>\n}\n\nexport const DefaultUnknownListItem: PortableTextReactComponents['unknownListItem'] = ({\n children,\n}) => {\n return <li>{children}</li>\n}\n","import type {PortableTextBlockStyle} from '@portabletext/types'\nimport type {JSX} from 'react'\n\nimport type {PortableTextBlockComponent, PortableTextReactComponents} from '../types'\nimport {DefaultListItem, defaultLists} from './list'\nimport {defaultMarks} from './marks'\nimport {\n DefaultUnknownBlockStyle,\n DefaultUnknownList,\n DefaultUnknownListItem,\n DefaultUnknownMark,\n DefaultUnknownType,\n} from './unknown'\n\nexport const DefaultHardBreak = (): JSX.Element => <br />\n\nexport const defaultBlockStyles: Record<\n PortableTextBlockStyle,\n PortableTextBlockComponent | undefined\n> = {\n normal: ({children}) => <p>{children}</p>,\n blockquote: ({children}) => <blockquote>{children}</blockquote>,\n h1: ({children}) => <h1>{children}</h1>,\n h2: ({children}) => <h2>{children}</h2>,\n h3: ({children}) => <h3>{children}</h3>,\n h4: ({children}) => <h4>{children}</h4>,\n h5: ({children}) => <h5>{children}</h5>,\n h6: ({children}) => <h6>{children}</h6>,\n}\n\nexport const defaultComponents: PortableTextReactComponents = {\n types: {},\n\n block: defaultBlockStyles,\n marks: defaultMarks,\n list: defaultLists,\n listItem: DefaultListItem,\n hardBreak: DefaultHardBreak,\n\n unknownType: DefaultUnknownType,\n unknownMark: DefaultUnknownMark,\n unknownList: DefaultUnknownList,\n unknownListItem: DefaultUnknownListItem,\n unknownBlockStyle: DefaultUnknownBlockStyle,\n}\n","import type {PortableTextComponents, PortableTextReactComponents} from '../types'\n\nexport function mergeComponents(\n parent: PortableTextReactComponents,\n overrides: PortableTextComponents,\n): PortableTextReactComponents {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {block, list, listItem, marks, types, ...rest} = overrides\n // @todo figure out how to not `as ...` these\n return {\n ...parent,\n block: mergeDeeply(parent, overrides, 'block') as PortableTextReactComponents['block'],\n list: mergeDeeply(parent, overrides, 'list') as PortableTextReactComponents['list'],\n listItem: mergeDeeply(parent, overrides, 'listItem') as PortableTextReactComponents['listItem'],\n marks: mergeDeeply(parent, overrides, 'marks') as PortableTextReactComponents['marks'],\n types: mergeDeeply(parent, overrides, 'types') as PortableTextReactComponents['types'],\n ...rest,\n }\n}\n\nfunction mergeDeeply(\n parent: PortableTextReactComponents,\n overrides: PortableTextComponents,\n key: 'block' | 'list' | 'listItem' | 'marks' | 'types',\n): PortableTextReactComponents[typeof key] {\n const override = overrides[key]\n const parentVal = parent[key]\n\n if (typeof override === 'function') {\n return override\n }\n\n if (override && typeof parentVal === 'function') {\n return override\n }\n\n if (override) {\n return {...parentVal, ...override} as PortableTextReactComponents[typeof key]\n }\n\n return parentVal\n}\n","import type {ToolkitNestedPortableTextSpan, ToolkitTextNode} from '@portabletext/toolkit'\nimport {\n buildMarksTree,\n isPortableTextBlock,\n isPortableTextListItemBlock,\n isPortableTextToolkitList,\n isPortableTextToolkitSpan,\n isPortableTextToolkitTextNode,\n LIST_NEST_MODE_HTML,\n nestLists,\n spanToPlainText,\n} from '@portabletext/toolkit'\nimport type {\n PortableTextBlock,\n PortableTextListItemBlock,\n PortableTextMarkDefinition,\n PortableTextSpan,\n TypedObject,\n} from '@portabletext/types'\nimport {type JSX, type ReactNode, useMemo} from 'react'\n\nimport {defaultComponents} from './components/defaults'\nimport {mergeComponents} from './components/merge'\nimport type {\n MissingComponentHandler,\n NodeRenderer,\n PortableTextProps,\n PortableTextReactComponents,\n ReactPortableTextList,\n Serializable,\n SerializedBlock,\n} from './types'\nimport {\n printWarning,\n unknownBlockStyleWarning,\n unknownListItemStyleWarning,\n unknownListStyleWarning,\n unknownMarkWarning,\n unknownTypeWarning,\n} from './warnings'\n\nexport function PortableText<B extends TypedObject = PortableTextBlock>({\n value: input,\n components: componentOverrides,\n listNestingMode,\n onMissingComponent: missingComponentHandler = printWarning,\n}: PortableTextProps<B>): JSX.Element {\n const handleMissingComponent = missingComponentHandler || noop\n const blocks = Array.isArray(input) ? input : [input]\n const nested = nestLists(blocks, listNestingMode || LIST_NEST_MODE_HTML)\n\n const components = useMemo(() => {\n return componentOverrides\n ? mergeComponents(defaultComponents, componentOverrides)\n : defaultComponents\n }, [componentOverrides])\n\n const renderNode = useMemo(\n () => getNodeRenderer(components, handleMissingComponent),\n [components, handleMissingComponent],\n )\n const rendered = nested.map((node, index) =>\n renderNode({node: node, index, isInline: false, renderNode}),\n )\n\n return <>{rendered}</>\n}\n\nconst getNodeRenderer = (\n components: PortableTextReactComponents,\n handleMissingComponent: MissingComponentHandler,\n): NodeRenderer => {\n function renderNode<N extends TypedObject>(options: Serializable<N>): ReactNode {\n const {node, index, isInline} = options\n const key = node._key || `node-${index}`\n\n if (isPortableTextToolkitList(node)) {\n return renderList(node, index, key)\n }\n\n if (isPortableTextListItemBlock(node)) {\n return renderListItem(node, index, key)\n }\n\n if (isPortableTextToolkitSpan(node)) {\n return renderSpan(node, index, key)\n }\n\n if (hasCustomComponentForNode(node)) {\n return renderCustomBlock(node, index, key, isInline)\n }\n\n if (isPortableTextBlock(node)) {\n return renderBlock(node, index, key, isInline)\n }\n\n if (isPortableTextToolkitTextNode(node)) {\n return renderText(node, key)\n }\n\n return renderUnknownType(node, index, key, isInline)\n }\n\n function hasCustomComponentForNode(node: TypedObject): boolean {\n return node._type in components.types\n }\n\n /* eslint-disable react/jsx-no-bind */\n function renderListItem(\n node: PortableTextListItemBlock<PortableTextMarkDefinition, PortableTextSpan>,\n index: number,\n key: string,\n ) {\n const tree = serializeBlock({node, index, isInline: false, renderNode})\n const renderer = components.listItem\n const handler = typeof renderer === 'function' ? renderer : renderer[node.listItem]\n const Li = handler || components.unknownListItem\n\n if (Li === components.unknownListItem) {\n const style = node.listItem || 'bullet'\n handleMissingComponent(unknownListItemStyleWarning(style), {\n type: style,\n nodeType: 'listItemStyle',\n })\n }\n\n let children = tree.children\n if (node.style && node.style !== 'normal') {\n // Wrap any other style in whatever the block serializer says to use\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {listItem, ...blockNode} = node\n children = renderNode({node: blockNode, index, isInline: false, renderNode})\n }\n\n return (\n <Li key={key} value={node} index={index} isInline={false} renderNode={renderNode}>\n {children}\n </Li>\n )\n }\n\n function renderList(node: ReactPortableTextList, index: number, key: string) {\n const children = node.children.map((child, childIndex) =>\n renderNode({\n node: child._key ? child : {...child, _key: `li-${index}-${childIndex}`},\n index: childIndex,\n isInline: false,\n renderNode,\n }),\n )\n\n const component = components.list\n const handler = typeof component === 'function' ? component : component[node.listItem]\n const List = handler || components.unknownList\n\n if (List === components.unknownList) {\n const style = node.listItem || 'bullet'\n handleMissingComponent(unknownListStyleWarning(style), {nodeType: 'listStyle', type: style})\n }\n\n return (\n <List key={key} value={node} index={index} isInline={false} renderNode={renderNode}>\n {children}\n </List>\n )\n }\n\n function renderSpan(node: ToolkitNestedPortableTextSpan, _index: number, key: string) {\n const {markDef, markType, markKey} = node\n const Span = components.marks[markType] || components.unknownMark\n const children = node.children.map((child, childIndex) =>\n renderNode({node: child, index: childIndex, isInline: true, renderNode}),\n )\n\n if (Span === components.unknownMark) {\n handleMissingComponent(unknownMarkWarning(markType), {nodeType: 'mark', type: markType})\n }\n\n return (\n <Span\n key={key}\n text={spanToPlainText(node)}\n value={markDef}\n markType={markType}\n markKey={markKey}\n renderNode={renderNode}\n >\n {children}\n </Span>\n )\n }\n\n function renderBlock(node: PortableTextBlock, index: number, key: string, isInline: boolean) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {_key, ...props} = serializeBlock({node, index, isInline, renderNode})\n const style = props.node.style || 'normal'\n const handler =\n typeof components.block === 'function' ? components.block : components.block[style]\n const Block = handler || components.unknownBlockStyle\n\n if (Block === components.unknownBlockStyle) {\n handleMissingComponent(unknownBlockStyleWarning(style), {\n nodeType: 'blockStyle',\n type: style,\n })\n }\n\n return <Block key={key} {...props} value={props.node} renderNode={renderNode} />\n }\n\n function renderText(node: ToolkitTextNode, key: string) {\n if (node.text === '\\n') {\n const HardBreak = components.hardBreak\n return HardBreak ? <HardBreak key={key} /> : '\\n'\n }\n\n return node.text\n }\n\n function renderUnknownType(node: TypedObject, index: number, key: string, isInline: boolean) {\n const nodeOptions = {\n value: node,\n isInline,\n index,\n renderNode,\n }\n\n handleMissingComponent(unknownTypeWarning(node._type), {nodeType: 'block', type: node._type})\n\n const UnknownType = components.unknownType\n return <UnknownType key={key} {...nodeOptions} />\n }\n\n function renderCustomBlock(node: TypedObject, index: number, key: string, isInline: boolean) {\n const nodeOptions = {\n value: node,\n isInline,\n index,\n renderNode,\n }\n\n const Node = components.types[node._type]\n return Node ? <Node key={key} {...nodeOptions} /> : null\n }\n /* eslint-enable react/jsx-no-bind */\n\n return renderNode\n}\n\nfunction serializeBlock(options: Serializable<PortableTextBlock>): SerializedBlock {\n const {node, index, isInline, renderNode} = options\n const tree = buildMarksTree(node)\n const children = tree.map((child, i) =>\n renderNode({node: child, isInline: true, index: i, renderNode}),\n )\n\n return {\n _key: node._key || `block-${index}`,\n children,\n index,\n isInline,\n node,\n }\n}\n\nfunction noop() {\n // Intentional noop\n}\n"],"names":["jsx","nestLists","LIST_NEST_MODE_HTML","useMemo","isPortableTextToolkitList","isPortableTextListItemBlock","isPortableTextToolkitSpan","isPortableTextBlock","isPort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K;AAAA,EACtD;AAGA,SAAO;AACT;AAEA,SAAS,eAAe,SAA2D;AACjF,QAAM,EAAC,MAAM,OAAO,UAAU,WAAA,IAAc,SAEtC,WADOU,QAAAA,eAAe,IAAI,EACV;AAAA,IAAI,CAAC,OAAO,MAChC,WAAW,EAAC,MAAM,OAAO,UAAU,IAAM,OAAO,GAAG,WAAA,CAAW;AAAA,EAAA;AAGhE,SAAO;AAAA,IACL,MAAM,KAAK,QAAQ,SAAS,KAAK;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAAS,OAAO;AAEhB;;;;;;;;;;"}
import type {ArbitraryTypedObject} from '@portabletext/types'
import type {ComponentType} from 'react'
import {JSX} from 'react'
import {ToolkitListNestMode as ListNestMode} from '@portabletext/toolkit'
import {PortableTextBlock} from '@portabletext/types'
import type {PortableTextBlockStyle} from '@portabletext/types'
import type {PortableTextListItemBlock} from '@portabletext/types'
import type {PortableTextListItemType} from '@portabletext/types'
import type {ReactNode} from 'react'
import type {ToolkitPortableTextList} from '@portabletext/toolkit'
import type {ToolkitPortableTextListItem} from '@portabletext/toolkit'
import {toPlainText} from '@portabletext/toolkit'
import type {TypedObject} from '@portabletext/types'
export declare const defaultComponents: PortableTextReactComponents
export {ListNestMode}
export declare function mergeComponents(
parent: PortableTextReactComponents,
overrides: PortableTextComponents,
): PortableTextReactComponents
export declare type MissingComponentHandler = (
message: string,
options: {
type: string
nodeType: NodeType
},
) => void
/**
* Function that renders any node that might appear in a portable text array or block,
* including virtual "toolkit"-nodes like lists and nested spans
*/
export declare type NodeRenderer = <T extends TypedObject>(options: Serializable<T>) => ReactNode
export declare type NodeType = 'block' | 'mark' | 'blockStyle' | 'listStyle' | 'listItemStyle'
export declare function PortableText<B extends TypedObject = PortableTextBlock>({
value: input,
components: componentOverrides,
listNestingMode,
onMissingComponent: missingComponentHandler,
}: PortableTextProps<B>): JSX.Element
export {PortableTextBlock}
/**
* React component type for rendering portable text blocks (paragraphs, headings, blockquotes etc)
*/
export declare type PortableTextBlockComponent = PortableTextComponent<PortableTextBlock>
/**
* Generic type for portable text rendering components that takes blocks/inline blocks
*
* @template N Node types we expect to be rendering (`PortableTextBlock` should usually be part of this)
*/
export declare type PortableTextComponent<N> = ComponentType<PortableTextComponentProps<N>>
/**
* Props received by most Portable Text components
*
* @template T Type of data this component will receive in its `value` property
*/
export declare interface PortableTextComponentProps<T> {
/**
* Data associated with this portable text node, eg the raw JSON value of a block/type
*/
value: T
/**
* Index within its parent
*/
index: number
/**
* Whether or not this node is "inline" - ie as a child of a text block,
* alongside text spans, or a block in and of itself.
*/
isInline: boolean
/**
* React child nodes of this block/component
*/
children?: ReactNode
/**
* Function used to render any node that might appear in a portable text array or block,
* including virtual "toolkit"-nodes like lists and nested spans. You will rarely need
* to use this.
*/
renderNode: NodeRenderer
}
/**
* Object defining the different React components to use for rendering various aspects
* of Portable Text and user-provided types, where only the overrides needs to be provided.
*/
export declare type PortableTextComponents = Partial<PortableTextReactComponents>
/**
* React component type for rendering (virtual, not part of the spec) portable text lists
*/
export declare type PortableTextListComponent = PortableTextComponent<ReactPortableTextList>
/**
* React component type for rendering portable text list items
*/
export declare type PortableTextListItemComponent = PortableTextComponent<PortableTextListItemBlock>
/**
* React component type for rendering portable text marks and/or decorators
*
* @template M The mark type we expect
*/
export declare type PortableTextMarkComponent<M extends TypedObject = any> = ComponentType<
PortableTextMarkComponentProps<M>
>
/**
* Props received by Portable Text mark rendering components
*
* @template M Shape describing the data associated with this mark, if it is an annotation
*/
export declare interface PortableTextMarkComponentProps<
M extends TypedObject = ArbitraryTypedObject,
> {
/**
* Mark definition, eg the actual data of the annotation. If the mark is a simple decorator, this will be `undefined`
*/
value?: M
/**
* Text content of this mark
*/
text: string
/**
* Key for this mark. The same key can be used amongst multiple text spans within the same block, so don't rely on this for React keys.
*/
markKey?: string
/**
* Type of mark - ie value of `_type` in the case of annotations, or the name of the decorator otherwise - eg `em`, `italic`.
*/
markType: string
/**
* React child nodes of this mark
*/
children: ReactNode
/**
* Function used to render any node that might appear in a portable text array or block,
* including virtual "toolkit"-nodes like lists and nested spans. You will rarely need
* to use this.
*/
renderNode: NodeRenderer
}
/**
* Properties for the Portable Text react component
*
* @template B Types that can appear in the array of blocks
*/
export declare interface PortableTextProps<
B extends TypedObject = PortableTextBlock | ArbitraryTypedObject,
> {
/**
* One or more blocks to render
*/
value: B | B[]
/**
* React components to use for rendering
*/
components?: Partial<PortableTextReactComponents>
/**
* Function to call when encountering unknown unknown types, eg blocks, marks,
* block style, list styles without an associated React component.
*
* Will print a warning message to the console by default.
* Pass `false` to disable.
*/
onMissingComponent?: MissingComponentHandler | false
/**
* Determines whether or not lists are nested inside of list items (`html`)
* or as a direct child of another list (`direct` - for React Native)
*
* You rarely (if ever) need/want to customize this
*/
listNestingMode?: ListNestMode
}
/**
* Object definining the different React components to use for rendering various aspects
* of Portable Text and user-provided types.
*/
export declare interface PortableTextReactComponents {
/**
* Object of React components that renders different types of objects that might appear
* both as part of the blocks array, or as inline objects _inside_ of a block,
* alongside text spans.
*
* Use the `isInline` property to check whether or not this is an inline object or a block
*
* The object has the shape `{typeName: ReactComponent}`, where `typeName` is the value set
* in individual `_type` attributes.
*/
types: Record<string, PortableTextTypeComponent | undefined>
/**
* Object of React components that renders different types of marks that might appear in spans.
*
* The object has the shape `{markName: ReactComponent}`, where `markName` is the value set
* in individual `_type` attributes, values being stored in the parent blocks `markDefs`.
*/
marks: Record<string, PortableTextMarkComponent | undefined>
/**
* Object of React components that renders blocks with different `style` properties.
*
* The object has the shape `{styleName: ReactComponent}`, where `styleName` is the value set
* in individual `style` attributes on blocks.
*
* Can also be set to a single React component, which would handle block styles of _any_ type.
*/
block:
| Record<PortableTextBlockStyle, PortableTextBlockComponent | undefined>
| PortableTextBlockComponent
/**
* Object of React components used to render lists of different types (bulleted vs numbered,
* for instance, which by default is `<ul>` and `<ol>`, respectively)
*
* There is no actual "list" node type in the Portable Text specification, but a series of
* list item blocks with the same `level` and `listItem` properties will be grouped into a
* virtual one inside of this library.
*
* Can also be set to a single React component, which would handle lists of _any_ type.
*/
list:
| Record<PortableTextListItemType, PortableTextListComponent | undefined>
| PortableTextListComponent
/**
* Object of React components used to render different list item styles.
*
* The object has the shape `{listItemType: ReactComponent}`, where `listItemType` is the value
* set in individual `listItem` attributes on blocks.
*
* Can also be set to a single React component, which would handle list items of _any_ type.
*/
listItem:
| Record<PortableTextListItemType, PortableTextListItemComponent | undefined>
| PortableTextListItemComponent
/**
* Component to use for rendering "hard breaks", eg `\n` inside of text spans
* Will by default render a `<br />`. Pass `false` to render as-is (`\n`)
*/
hardBreak: ComponentType<{}> | false
/**
* React component used when encountering a mark type there is no registered component for
* in the `components.marks` prop.
*/
unknownMark: PortableTextMarkComponent
/**
* React component used when encountering an object type there is no registered component for
* in the `components.types` prop.
*/
unknownType: PortableTextComponent<UnknownNodeType>
/**
* React component used when encountering a block style there is no registered component for
* in the `components.block` prop. Only used if `components.block` is an object.
*/
unknownBlockStyle: PortableTextComponent<PortableTextBlock>
/**
* React component used when encountering a list style there is no registered component for
* in the `components.list` prop. Only used if `components.list` is an object.
*/
unknownList: PortableTextComponent<ReactPortableTextList>
/**
* React component used when encountering a list item style there is no registered component for
* in the `components.listItem` prop. Only used if `components.listItem` is an object.
*/
unknownListItem: PortableTextComponent<PortableTextListItemBlock>
}
export declare type PortableTextTypeComponent<V extends TypedObject = any> = ComponentType<
PortableTextTypeComponentProps<V>
>
/**
* Props received by any user-defined type in the input array that is not a text block
*
* @template T Type of data this component will receive in its `value` property
*/
export declare type PortableTextTypeComponentProps<T> = Omit<
PortableTextComponentProps<T>,
'children'
>
/**
* A virtual "list" node for Portable Text - not strictly part of Portable Text,
* but generated by this library to ease the rendering of lists in HTML etc
*/
export declare type ReactPortableTextList = ToolkitPortableTextList
/**
* A virtual "list item" node for Portable Text - not strictly any different from a
* regular Portable Text Block, but we can guarantee that it has a `listItem` property.
*/
export declare type ReactPortableTextListItem = ToolkitPortableTextListItem
export declare interface Serializable<T> {
node: T
index: number
isInline: boolean
renderNode: NodeRenderer
}
export declare interface SerializedBlock {
_key: string
children: ReactNode
index: number
isInline: boolean
node: PortableTextBlock | PortableTextListItemBlock
}
export {toPlainText}
/**
* Any node type that we can't identify - eg it has an `_type`,
* but we don't know anything about its other properties
*/
export declare type UnknownNodeType =
| {
[key: string]: unknown
_type: string
}
| TypedObject
export {}

Sorry, the diff of this file is not supported yet