Skip to content

Commit 7b5f095

Browse files
committed
chore: fix build
1 parent 61b5064 commit 7b5f095

13 files changed

+73
-61
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Sanity.io <hello@sanity.io>
3+
Copyright (c) 2024 Sanity.io <hello@sanity.io>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/components/defaults.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import type {PortableTextBlockComponent, PortableTextHtmlComponents} from '../types'
21
import type {PortableTextBlockStyle} from '@portabletext/types'
2+
3+
import type {PortableTextBlockComponent, PortableTextHtmlComponents} from '../types'
4+
import {DefaultListItem,defaultLists} from './list'
35
import {defaultMarks} from './marks'
4-
import {defaultLists, DefaultListItem} from './list'
56
import {
6-
DefaultUnknownType,
7-
DefaultUnknownMark,
7+
DefaultUnknownBlockStyle,
88
DefaultUnknownList,
99
DefaultUnknownListItem,
10-
DefaultUnknownBlockStyle,
10+
DefaultUnknownMark,
11+
DefaultUnknownType,
1112
} from './unknown'
1213

1314
export const DefaultHardBreak = (): string => '<br/>'

src/components/marks.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type {PortableTextMarkComponent} from '../types'
21
import type {TypedObject} from '@portabletext/types'
2+
33
import {escapeHTML, uriLooksSafe} from '../escape'
4+
import type {PortableTextMarkComponent} from '../types'
45

56
interface DefaultLink extends TypedObject {
67
_type: 'link'

src/components/merge.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import type {PortableTextHtmlComponents, PortableTextComponents} from '../types'
1+
import type {PortableTextComponents, PortableTextHtmlComponents} from '../types'
22

33
export function mergeComponents(
44
parent: PortableTextHtmlComponents,
55
overrides: PortableTextComponents,
66
): PortableTextHtmlComponents {
7+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
78
const {block, list, listItem, marks, types, ...rest} = overrides
89
// @todo figure out how to not `as ...` these
910
return {

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from './types'
2-
export {toHTML} from './to-html'
3-
export {mergeComponents} from './components/merge'
41
export {defaultComponents} from './components/defaults'
2+
export {mergeComponents} from './components/merge'
53
export {escapeHTML, uriLooksSafe} from './escape'
4+
export {toHTML} from './to-html'
5+
export * from './types'

src/to-html.ts

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
import {
2+
buildMarksTree,
3+
isPortableTextBlock,
4+
isPortableTextListItemBlock,
5+
isPortableTextToolkitList,
6+
isPortableTextToolkitSpan,
7+
isPortableTextToolkitTextNode,
8+
nestLists,
9+
spanToPlainText,
10+
type ToolkitNestedPortableTextSpan,
11+
type ToolkitTextNode,
12+
} from '@portabletext/toolkit'
113
import type {
214
ArbitraryTypedObject,
315
PortableTextBlock,
@@ -6,30 +18,19 @@ import type {
618
PortableTextSpan,
719
TypedObject,
820
} from '@portabletext/types'
21+
22+
import {defaultComponents} from './components/defaults'
23+
import {mergeComponents} from './components/merge'
24+
import {escapeHTML} from './escape'
925
import type {
26+
HtmlPortableTextList,
1027
MissingComponentHandler,
1128
NodeRenderer,
1229
PortableTextHtmlComponents,
1330
PortableTextOptions,
14-
HtmlPortableTextList,
1531
Serializable,
1632
SerializedBlock,
1733
} from './types'
18-
import {
19-
buildMarksTree,
20-
isPortableTextBlock,
21-
isPortableTextListItemBlock,
22-
isPortableTextToolkitList,
23-
isPortableTextToolkitSpan,
24-
isPortableTextToolkitTextNode,
25-
nestLists,
26-
spanToPlainText,
27-
ToolkitNestedPortableTextSpan,
28-
ToolkitTextNode,
29-
} from '@portabletext/toolkit'
30-
import {defaultComponents} from './components/defaults'
31-
import {mergeComponents} from './components/merge'
32-
import {escapeHTML} from './escape'
3334
import {
3435
printWarning,
3536
unknownBlockStyleWarning,
@@ -113,6 +114,7 @@ const getNodeRenderer = (
113114
let children = tree.children
114115
if (node.style && node.style !== 'normal') {
115116
// Wrap any other style in whatever the block component says to use
117+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
116118
const {listItem, ...blockNode} = node
117119
children = renderNode({node: blockNode, index, isInline: false, renderNode})
118120
}
@@ -164,6 +166,7 @@ const getNodeRenderer = (
164166
}
165167

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

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import type {ToolkitPortableTextList, ToolkitPortableTextListItem} from '@portabletext/toolkit'
23
import type {
34
ArbitraryTypedObject,

test/escaping.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import tap from 'tap'
21
import type {ArbitraryTypedObject} from '@portabletext/types'
2+
import tap from 'tap'
3+
34
import type {PortableTextOptions} from '../src'
45
import {toHTML} from '../src/to-html'
56
import * as fixtures from './fixtures'

test/fixtures/013-materialized-image-support.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {PortableTextBlock, ArbitraryTypedObject} from '@portabletext/types'
1+
import type {ArbitraryTypedObject,PortableTextBlock} from '@portabletext/types'
22

33
const input: (PortableTextBlock | ArbitraryTypedObject)[] = [
44
{

test/fixtures/index.ts

+25-25
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,39 @@ import listIssue from './060-list-issue'
3535
import missingMarkComponent from './061-missing-mark-serializer'
3636

3737
export {
38-
emptyBlock,
39-
singleSpan,
40-
multipleSpans,
41-
basicMarkSingleSpan,
38+
allBasicMarks,
39+
allDefaultBlockStyles,
40+
basicBulletList,
4241
basicMarkMultipleAdjacentSpans,
4342
basicMarkNestedMarks,
44-
linkMarkDef,
45-
plainHeaderBlock,
46-
messyLinkText,
47-
basicBulletList,
43+
basicMarkSingleSpan,
4844
basicNumberedList,
49-
imageSupport,
50-
materializedImageSupport,
51-
nestedLists,
52-
allBasicMarks,
45+
customBlockType,
46+
customListItemType,
47+
customMarks,
5348
deepWeirdLists,
54-
allDefaultBlockStyles,
55-
marksAllTheWayDown,
56-
keyless,
5749
emptyArray,
58-
listWithoutLevel,
59-
inlineNodes,
50+
emptyBlock,
6051
hardBreaks,
61-
inlineImages,
52+
imageSupport,
6253
imageWithHotspot,
63-
inlineBlockWithText,
64-
styledListItems,
65-
customListItemType,
6654
injectionLinkHref,
67-
customBlockType,
68-
overrideDefaults,
69-
customMarks,
70-
overrideDefaultMarks,
55+
inlineBlockWithText,
56+
inlineImages,
57+
inlineNodes,
58+
keyless,
59+
linkMarkDef,
7160
listIssue,
61+
listWithoutLevel,
62+
marksAllTheWayDown,
63+
materializedImageSupport,
64+
messyLinkText,
7265
missingMarkComponent,
66+
multipleSpans,
67+
nestedLists,
68+
overrideDefaultMarks,
69+
overrideDefaults,
70+
plainHeaderBlock,
71+
singleSpan,
72+
styledListItems,
7373
}

test/mutations.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import tap from 'tap'
21
import type {ArbitraryTypedObject} from '@portabletext/types'
3-
import type {PortableTextHtmlComponents, PortableTextOptions} from '../src/types'
2+
import tap from 'tap'
3+
44
import {toHTML} from '../src/to-html'
5+
import type {PortableTextHtmlComponents, PortableTextOptions} from '../src/types'
56
import * as fixtures from './fixtures'
67

78
const render = (

test/portable-text.test.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import tap from 'tap'
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
22
import type {ArbitraryTypedObject} from '@portabletext/types'
3+
import tap from 'tap'
4+
5+
import {escapeHTML} from '../src'
6+
import {toHTML} from '../src/to-html'
37
import type {
8+
MissingComponentHandler,
49
PortableTextHtmlComponents,
510
PortableTextMarkComponent,
611
PortableTextOptions,
7-
MissingComponentHandler,
812
} from '../src/types'
9-
import {escapeHTML} from '../src'
10-
import {toHTML} from '../src/to-html'
1113
import * as fixtures from './fixtures'
1214

1315
const render = (

test/serializers.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {ArbitraryTypedObject} from '@portabletext/types'
2-
import type {PortableTextOptions} from '../src'
32
import tap from 'tap'
3+
4+
import type {PortableTextOptions} from '../src'
45
import {toHTML} from '../src/to-html'
56

67
const render = (value: ArbitraryTypedObject, options: PortableTextOptions) =>

0 commit comments

Comments
 (0)