@financial-times/cp-content-pipeline-ui 6.15.1 → 6.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/lib/components/Clip/client/index.js +34 -15
- package/lib/components/Clip/client/index.js.map +1 -1
- package/lib/components/Clip/components/VideoDescription.js +30 -7
- package/lib/components/Clip/components/VideoDescription.js.map +1 -1
- package/lib/components/Clip/test/fixtures.d.ts +1 -0
- package/lib/components/Clip/test/fixtures.js +20 -1
- package/lib/components/Clip/test/fixtures.js.map +1 -1
- package/lib/components/Clip/test/index.spec.js +41 -29
- package/lib/components/Clip/test/index.spec.js.map +1 -1
- package/lib/components/LiveBlogWrapper/index.js +0 -1
- package/lib/components/LiveBlogWrapper/index.js.map +1 -1
- package/lib/components/RichText/context.d.ts +4 -0
- package/lib/components/RichText/context.js +31 -0
- package/lib/components/RichText/context.js.map +1 -0
- package/lib/components/RichText/index.d.ts +1 -1
- package/lib/components/RichText/index.js +8 -2
- package/lib/components/RichText/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Clip/client/index.ts +41 -18
- package/src/components/Clip/components/VideoDescription.tsx +11 -12
- package/src/components/Clip/test/fixtures.ts +21 -0
- package/src/components/Clip/test/index.spec.ts +50 -35
- package/src/components/LiveBlogWrapper/index.tsx +0 -1
- package/src/components/RichText/context.tsx +9 -0
- package/src/components/RichText/index.tsx +20 -10
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -47,6 +47,8 @@ import {
|
|
|
47
47
|
import { ScrollyImage } from '../Scrollytelling/ScrollyImage'
|
|
48
48
|
import YoutubeVideo from '../YoutubeVideo'
|
|
49
49
|
|
|
50
|
+
import RichTextContext from './context'
|
|
51
|
+
|
|
50
52
|
export type RichTextComponentMapRecord = Partial<
|
|
51
53
|
Record<
|
|
52
54
|
ContentTreeWorkarounds.AnyNode['type'] | 'fallback',
|
|
@@ -63,7 +65,7 @@ export const ComponentsContext = createContext<
|
|
|
63
65
|
type WithOptionalProperty<T, K extends keyof T> = Pick<Partial<T>, K> &
|
|
64
66
|
Omit<T, K>
|
|
65
67
|
|
|
66
|
-
type RichTextProps = {
|
|
68
|
+
export type RichTextProps = {
|
|
67
69
|
// the component using RichText might not have queried for references, so make it optional
|
|
68
70
|
structuredContent: WithOptionalProperty<
|
|
69
71
|
StructuredContentFragment,
|
|
@@ -140,7 +142,13 @@ const RichTextChild: React.FC<RichTextChildProps> = ({
|
|
|
140
142
|
return <>{node.value}</>
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
let Component = components[node.type]
|
|
146
|
+
if (!Component) {
|
|
147
|
+
console.warn(
|
|
148
|
+
`couldn't find component for Content Tree node ${node.type}, using fallback component instead (by default will render the node's children)`
|
|
149
|
+
)
|
|
150
|
+
Component = components.fallback
|
|
151
|
+
}
|
|
144
152
|
|
|
145
153
|
if (Component) {
|
|
146
154
|
const children: ReactNode[] = isParentNode(node)
|
|
@@ -163,14 +171,16 @@ const RichTextChild: React.FC<RichTextChildProps> = ({
|
|
|
163
171
|
: {}
|
|
164
172
|
|
|
165
173
|
return (
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
<RichTextContext.Provider value={RichText}>
|
|
175
|
+
<Component
|
|
176
|
+
{...node}
|
|
177
|
+
{...reference}
|
|
178
|
+
key={parentIndex}
|
|
179
|
+
parentIndex={parentIndex}
|
|
180
|
+
>
|
|
181
|
+
{children}
|
|
182
|
+
</Component>
|
|
183
|
+
</RichTextContext.Provider>
|
|
174
184
|
)
|
|
175
185
|
}
|
|
176
186
|
|