@uniweb/kit 0.10.0 → 0.10.1
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/package.json +3 -3
- package/src/styled/Render/index.jsx +46 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/kit",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Standard component library for Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"fuse.js": "^7.0.0",
|
|
41
41
|
"shiki": "^3.0.0",
|
|
42
42
|
"tailwind-merge": "^3.6.0",
|
|
43
|
-
"@uniweb/
|
|
43
|
+
"@uniweb/scene": "0.1.2",
|
|
44
44
|
"@uniweb/core": "0.8.0",
|
|
45
|
-
"@uniweb/
|
|
45
|
+
"@uniweb/semantic-parser": "1.2.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "^19.0.0",
|
|
@@ -144,6 +144,51 @@ function renderAll(sequence, block, components) {
|
|
|
144
144
|
))
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* A table cell's contents, with a lone block UNWRAPPED.
|
|
149
|
+
*
|
|
150
|
+
* The schema declares `tableCell` as `paragraph+`, so a markdown cell is always
|
|
151
|
+
* exactly one block — and emitting its `<p>` faithfully is what a typography
|
|
152
|
+
* layer then gives paragraph margins to. Measured on a real docs site: 17.5px
|
|
153
|
+
* top and bottom inside every cell, turning a one-line reference row into 75px.
|
|
154
|
+
*
|
|
155
|
+
* TWO shapes reach a cell, which is easy to miss and was: an ordinary paragraph,
|
|
156
|
+
* and a `link` — because the parser PROMOTES a paragraph holding nothing but a
|
|
157
|
+
* link, which is what makes a link on its own line a call to action in prose.
|
|
158
|
+
* A cell whose whole content is a link is the same promotion arriving somewhere
|
|
159
|
+
* it means nothing, so it unwraps too. Fixing only the paragraph left every
|
|
160
|
+
* link-only cell tall, which is how this was found: 17 of them on one page.
|
|
161
|
+
*
|
|
162
|
+
* A cell holding genuinely several blocks still gets them, because that is what
|
|
163
|
+
* it is.
|
|
164
|
+
*/
|
|
165
|
+
function renderCell(cell, block, components) {
|
|
166
|
+
const children = cell.children || []
|
|
167
|
+
if (children.length !== 1) return renderAll(children, block, components)
|
|
168
|
+
|
|
169
|
+
const [only] = children
|
|
170
|
+
|
|
171
|
+
if (only?.type === 'paragraph') {
|
|
172
|
+
if (!only.text) return null
|
|
173
|
+
return /<uniweb-inset/.test(only.text) ? (
|
|
174
|
+
renderParagraphWithInsets(only.text, block)
|
|
175
|
+
) : (
|
|
176
|
+
<SafeHtml value={only.text} as="span" />
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (only?.type === 'link') {
|
|
181
|
+
const { href, label } = only.attrs || {}
|
|
182
|
+
return <Link to={href}>{label}</Link>
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (only?.type === 'button') {
|
|
186
|
+
return <Link to={only.attrs?.href}>{only.text}</Link>
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return renderAll(children, block, components)
|
|
190
|
+
}
|
|
191
|
+
|
|
147
192
|
/**
|
|
148
193
|
* One element of a sequence.
|
|
149
194
|
*
|
|
@@ -255,7 +300,7 @@ export function SequenceElement({ element, block, components }) {
|
|
|
255
300
|
colSpan={cell.colspan > 1 ? cell.colspan : undefined}
|
|
256
301
|
rowSpan={cell.rowspan > 1 ? cell.rowspan : undefined}
|
|
257
302
|
>
|
|
258
|
-
{
|
|
303
|
+
{renderCell(cell, block, components)}
|
|
259
304
|
</CellTag>
|
|
260
305
|
)
|
|
261
306
|
})}
|