Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 263x 263x 263x 263x 263x 263x 1x 1x 2x 1x 1x 67x 1x 1x 18x 18x 18x 1x 1x 1x 1x 1x 1x 1x 1x 5x 1x 1x 2x 1x 1x 14x 1x 1x 3x 1x 1x 1x 17x 1x 1x 34x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x | import {
BLOCKS,
INLINES,
type Node,
type Document,
type Paragraph,
type Text,
type Hr,
type UnorderedList,
type OrderedList,
type ListItem,
type Hyperlink,
type Table,
type TableRow,
type TableHeaderCell,
type TableCell,
type Quote,
type AssetLinkBlock,
type AssetHyperlink,
type EntryLinkBlock,
type EntryHyperlink,
type EntryLinkInline,
} from "@contentful/rich-text-types";
import type { HeadingLevel, HeadingTypeByLevel } from "./headings";
export const isNode = (n: unknown): n is Node =>
typeof n === "object" &&
n !== null &&
"nodeType" in n &&
typeof n.nodeType === "string" &&
"data" in n &&
typeof n.data === "object";
export const isDocument = (n: unknown): n is Document =>
isNode(n) && n.nodeType === BLOCKS.DOCUMENT;
export const isParagraph = (n: unknown): n is Paragraph =>
isNode(n) && n.nodeType === BLOCKS.PARAGRAPH;
export const isHeading = <L extends HeadingLevel>(
level: L,
n: unknown,
): n is HeadingTypeByLevel<L> => isNode(n) && n.nodeType === `heading-${level}`;
export const isHr = (n: unknown): n is Hr => isNode(n) && n.nodeType === BLOCKS.HR;
export const isText = (n: unknown): n is Text => isNode(n) && n.nodeType === "text";
export const isQuote = (n: unknown): n is Quote => isNode(n) && n.nodeType === BLOCKS.QUOTE;
export const isUnorderedList = (n: unknown): n is UnorderedList =>
isNode(n) && n.nodeType === BLOCKS.UL_LIST;
export const isOrderedList = (n: unknown): n is OrderedList =>
isNode(n) && n.nodeType === BLOCKS.OL_LIST;
export const isListItem = (n: unknown): n is ListItem =>
isNode(n) && n.nodeType === BLOCKS.LIST_ITEM;
export const isHyperlink = (n: unknown): n is Hyperlink =>
isNode(n) && n.nodeType === INLINES.HYPERLINK;
export const isTable = (n: unknown): n is Table => isNode(n) && n.nodeType === BLOCKS.TABLE;
export const isTableRow = (n: unknown): n is TableRow =>
isNode(n) && n.nodeType === BLOCKS.TABLE_ROW;
export const isTableHeaderCell = (n: unknown): n is TableHeaderCell =>
isNode(n) && n.nodeType === BLOCKS.TABLE_HEADER_CELL;
export const isTableCell = (n: unknown): n is TableCell =>
isNode(n) && n.nodeType === BLOCKS.TABLE_CELL;
export const isAssetBlock = (n: unknown): n is AssetLinkBlock =>
isNode(n) && n.nodeType === BLOCKS.EMBEDDED_ASSET;
export const isEntryBlock = (n: unknown): n is EntryLinkBlock =>
isNode(n) && n.nodeType === BLOCKS.EMBEDDED_ENTRY;
export const isAssetHyperlink = (n: unknown): n is AssetHyperlink =>
isNode(n) && n.nodeType === INLINES.ASSET_HYPERLINK;
export const isEntryHyperlink = (n: unknown): n is EntryHyperlink =>
isNode(n) && n.nodeType === INLINES.ENTRY_HYPERLINK;
export const isEmbeddedEntry = (n: unknown): n is EntryLinkInline =>
isNode(n) && n.nodeType === INLINES.EMBEDDED_ENTRY;
|