@graphcommerce/graphcms-ui 9.0.0-canary.89 → 9.0.0-canary.93
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 +12 -0
- package/components/RichText/RichText.tsx +21 -4
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.93
|
|
4
|
+
|
|
5
|
+
## 9.0.0-canary.92
|
|
6
|
+
|
|
7
|
+
## 9.0.0-canary.91
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#2384](https://github.com/graphcommerce-org/graphcommerce/pull/2384) [`d7c293a`](https://github.com/graphcommerce-org/graphcommerce/commit/d7c293aa49be39f499b46ea57bfda4dbdf67ebe6) - feat(GCOM-1494: Add support for linebreaks in Hygraph content ) ([@FrankHarland](https://github.com/FrankHarland))
|
|
12
|
+
|
|
13
|
+
## 9.0.0-canary.90
|
|
14
|
+
|
|
3
15
|
## 9.0.0-canary.89
|
|
4
16
|
|
|
5
17
|
## 9.0.0-canary.88
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
2
|
import { SxProps, Theme } from '@mui/material'
|
|
3
|
+
import React from 'react'
|
|
3
4
|
import { defaultRenderers } from './defaultRenderers'
|
|
4
5
|
import { defaultSxRenderer } from './defaultSxRenderer'
|
|
5
6
|
import {
|
|
@@ -33,6 +34,20 @@ function useRenderProps(
|
|
|
33
34
|
]
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
function LineBreakToBr(props: { text: string }) {
|
|
38
|
+
const { text } = props
|
|
39
|
+
|
|
40
|
+
const textA = text.split('\n')
|
|
41
|
+
const textArray: React.ReactNode[] = []
|
|
42
|
+
textA.forEach((val, index) => {
|
|
43
|
+
textArray.push(val)
|
|
44
|
+
if (index < textA.length - 1) textArray.push(<br />)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
48
|
+
return textArray.map((val, idx) => <React.Fragment key={idx}>{val}</React.Fragment>)
|
|
49
|
+
}
|
|
50
|
+
|
|
36
51
|
function RenderText({
|
|
37
52
|
text,
|
|
38
53
|
renderers,
|
|
@@ -49,11 +64,13 @@ function RenderText({
|
|
|
49
64
|
|
|
50
65
|
const sx = useRenderProps({ first, last, sxRenderer }, type)
|
|
51
66
|
|
|
52
|
-
if (!type) return
|
|
53
|
-
|
|
67
|
+
if (!type) return <LineBreakToBr text={text} />
|
|
54
68
|
const Component: Renderer<SimpleElement> = renderers[type]
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
return (
|
|
70
|
+
<Component sx={sx}>
|
|
71
|
+
<LineBreakToBr text={text} />
|
|
72
|
+
</Component>
|
|
73
|
+
)
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
export function isTextNode(node: ElementOrTextNode): node is TextNode {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/graphcms-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.93",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.
|
|
17
|
-
"@graphcommerce/graphql": "^9.0.0-canary.
|
|
18
|
-
"@graphcommerce/image": "^9.0.0-canary.
|
|
19
|
-
"@graphcommerce/next-ui": "^9.0.0-canary.
|
|
20
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.
|
|
21
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.93",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.93",
|
|
17
|
+
"@graphcommerce/graphql": "^9.0.0-canary.93",
|
|
18
|
+
"@graphcommerce/image": "^9.0.0-canary.93",
|
|
19
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.93",
|
|
20
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.93",
|
|
21
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.93",
|
|
22
22
|
"@mui/material": "^5.10.16",
|
|
23
23
|
"next": "*",
|
|
24
24
|
"react": "^18.2.0",
|