@sakura-ui/sakura-ui 0.5.5 → 0.5.7
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 +4 -4
- package/packages/forms/.turbo/turbo-build.log +2 -2
- package/packages/forms/dist/index.cjs.js +4 -4
- package/packages/forms/dist/index.es.js +4 -4
- package/packages/forms/package.json +1 -1
- package/packages/forms/src/components/FileInput.tsx +4 -4
- package/packages/helper/.turbo/turbo-build.log +2 -2
- package/packages/markdown/.turbo/turbo-build.log +4 -4
- package/packages/markdown/dist/index.cjs.js +104 -37
- package/packages/markdown/dist/index.es.js +711 -621
- package/packages/markdown/dist/types/decorate.d.ts.map +1 -1
- package/packages/markdown/package.json +1 -1
- package/packages/markdown/src/decorate.ts +5 -1
- package/packages/markdown/tests/Markdown.test.tsx +17 -0
- package/packages/markdown/tests/__snapshots__/Markdown.test.tsx.snap +7 -2
- package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorate.d.ts","sourceRoot":"","sources":["../../src/decorate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorate.d.ts","sourceRoot":"","sources":["../../src/decorate.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAoED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB,CAAA;AAID,eAAO,MAAM,QAAQ,GACnB,MAAM,gBAAgB,GAAG,OAAO,EAChC,UAAU,QAAQ,EAClB,SAAS,eAAe,KACvB,cA0EF,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { styles } from '@sakura-ui/core'
|
|
2
|
+
import { treefy } from '@sakura-ui/helper'
|
|
2
3
|
import Slugger from 'github-slugger'
|
|
3
4
|
import { classNames } from './marked/html'
|
|
4
5
|
|
|
@@ -165,7 +166,10 @@ export const decorate = (
|
|
|
165
166
|
container.appendChild(table)
|
|
166
167
|
}
|
|
167
168
|
|
|
169
|
+
// Nested, so that the table of contents can show a heading under the one it
|
|
170
|
+
// belongs to. Cut to depth before nesting: filtering the tree afterwards
|
|
171
|
+
// would only reach the headings sitting at its root.
|
|
168
172
|
return {
|
|
169
|
-
headings: flat.filter((h) => h.depth <= tocMaxDepth)
|
|
173
|
+
headings: treefy(flat.filter((h) => h.depth <= tocMaxDepth))
|
|
170
174
|
}
|
|
171
175
|
}
|
|
@@ -101,6 +101,23 @@ describe('Markdown', () => {
|
|
|
101
101
|
expect(html).toMatchSnapshot()
|
|
102
102
|
})
|
|
103
103
|
|
|
104
|
+
// The nesting is read from the DOM rather than left to the snapshot, so a
|
|
105
|
+
// return to one flat list says which shape was lost.
|
|
106
|
+
it('should put a heading under the one it belongs to', async () => {
|
|
107
|
+
render(<Markdown showToc>{'# 章1\n\n## 節1\n\n## 節2\n\n# 章2'}</Markdown>)
|
|
108
|
+
const toc = await screen.findByRole('navigation')
|
|
109
|
+
|
|
110
|
+
const chapters = toc.querySelectorAll(':scope > ul > li')
|
|
111
|
+
expect(
|
|
112
|
+
Array.from(chapters, (li) => li.querySelector('a')?.textContent)
|
|
113
|
+
).toEqual(['章1', '章2'])
|
|
114
|
+
|
|
115
|
+
const sections = chapters[0].querySelectorAll(':scope > ul > li')
|
|
116
|
+
expect(
|
|
117
|
+
Array.from(sections, (li) => li.querySelector('a')?.textContent)
|
|
118
|
+
).toEqual(['節1', '節2'])
|
|
119
|
+
})
|
|
120
|
+
|
|
104
121
|
it('should use the given title', async () => {
|
|
105
122
|
render(
|
|
106
123
|
<Markdown showToc tocTitle="もくじ">
|
|
@@ -301,7 +301,12 @@ exports[`Markdown > table of contents > should render the table of contents when
|
|
|
301
301
|
|
|
302
302
|
disabled:border-solid-gray-500
|
|
303
303
|
[overflow-wrap:anywhere]
|
|
304
|
-
" href="#章1">章1</a
|
|
304
|
+
" href="#章1">章1</a><ul class="
|
|
305
|
+
list-disc
|
|
306
|
+
[&_&]:list-circle
|
|
307
|
+
[&_&_&]:list-square
|
|
308
|
+
pl-8
|
|
309
|
+
"><li><a class="
|
|
305
310
|
cursor-pointer
|
|
306
311
|
text-blue-1000
|
|
307
312
|
active:text-orange-700
|
|
@@ -355,7 +360,7 @@ exports[`Markdown > table of contents > should render the table of contents when
|
|
|
355
360
|
|
|
356
361
|
disabled:border-solid-gray-500
|
|
357
362
|
[overflow-wrap:anywhere]
|
|
358
|
-
" href="#節2">節2</a></li><li><a class="
|
|
363
|
+
" href="#節2">節2</a></li></ul></li><li><a class="
|
|
359
364
|
cursor-pointer
|
|
360
365
|
text-blue-1000
|
|
361
366
|
active:text-orange-700
|