@brillout/docpress 0.16.40 → 0.16.42
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/code-blocks/components/ChoiceGroup.tsx +1 -1
- package/code-blocks/remarkChoiceGroup.ts +4 -1
- package/code-blocks/utils/generateChoiceGroupCode.ts +7 -0
- package/dist/code-blocks/remarkChoiceGroup.js +4 -1
- package/dist/code-blocks/utils/generateChoiceGroupCode.js +8 -1
- package/package.json +1 -1
|
@@ -41,7 +41,7 @@ function ChoiceGroup({ children, choiceGroup }: { children: React.ReactNode; cho
|
|
|
41
41
|
{children}
|
|
42
42
|
{lvl === 0 && !choiceGroup.hidden && (
|
|
43
43
|
<div className={`choice-group__selects`}>
|
|
44
|
-
{choiceGroupAll.map((choiceGroup) => (
|
|
44
|
+
{(choiceGroupAll ?? []).map((choiceGroup) => (
|
|
45
45
|
<CustomSelect key={choiceGroup.name} choiceGroup={choiceGroup} />
|
|
46
46
|
))}
|
|
47
47
|
</div>
|
|
@@ -83,7 +83,10 @@ const remarkChoiceGroup: Plugin<[], Root> = (): Transformer<Root> => {
|
|
|
83
83
|
remarkPkgManager.call(this)(tree, file)
|
|
84
84
|
|
|
85
85
|
visit(tree, 'mdxJsxFlowElement', (node) => {
|
|
86
|
-
|
|
86
|
+
// Descend into non-container nodes so that a `CustomSelectsContainer` nested inside another JSX
|
|
87
|
+
// element (e.g. react-tabs `<Tabs>`/`<TabPanel>`, or a `<div>`) still gets visited and its
|
|
88
|
+
// `choiceGroupAll` attribute injected. (Returning 'skip' here would stop the descent.)
|
|
89
|
+
if (node.name !== 'CustomSelectsContainer') return
|
|
87
90
|
|
|
88
91
|
const choiceGroupAll: ChoiceGroupWithParent[] = []
|
|
89
92
|
|
|
@@ -68,7 +68,14 @@ function generateChoiceGroupCode(choiceNodes: ChoiceNode[], parent: Parent, hide
|
|
|
68
68
|
lvl = parentLvl + 1
|
|
69
69
|
|
|
70
70
|
data.customDataParentChoiceGroup = parent.data.customDataParentChoiceGroup
|
|
71
|
+
/*
|
|
72
|
+
// Keep the marker on the parent: a single choice can contain several toggleable code blocks
|
|
73
|
+
// (e.g. two TypeScript blocks, or a TypeScript block + an `npm` command). Each of them spawns
|
|
74
|
+
// its own nested choice group and must inherit the same parent level. Clearing the marker here
|
|
75
|
+
// would make every group after the first resolve to `lvl: 0`, wrapping it in its own
|
|
76
|
+
// `CustomSelectsContainer` — which then renders without `choiceGroupAll` and crashes.
|
|
71
77
|
parent.data = undefined
|
|
78
|
+
*/
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
for (const choiceNode of mergedChoiceNodes) {
|
|
@@ -67,8 +67,11 @@ const remarkChoiceGroup = () => {
|
|
|
67
67
|
await remarkDetype.call(this)(tree, file);
|
|
68
68
|
remarkPkgManager.call(this)(tree, file);
|
|
69
69
|
visit(tree, 'mdxJsxFlowElement', (node) => {
|
|
70
|
+
// Descend into non-container nodes so that a `CustomSelectsContainer` nested inside another JSX
|
|
71
|
+
// element (e.g. react-tabs `<Tabs>`/`<TabPanel>`, or a `<div>`) still gets visited and its
|
|
72
|
+
// `choiceGroupAll` attribute injected. (Returning 'skip' here would stop the descent.)
|
|
70
73
|
if (node.name !== 'CustomSelectsContainer')
|
|
71
|
-
return
|
|
74
|
+
return;
|
|
72
75
|
const choiceGroupAll = [];
|
|
73
76
|
visit(node, 'mdxJsxFlowElement', (child) => {
|
|
74
77
|
if (child.name !== 'ChoiceGroup')
|
|
@@ -50,7 +50,14 @@ function generateChoiceGroupCode(choiceNodes, parent, hide = false) {
|
|
|
50
50
|
const { lvl: parentLvl } = parent.data.customDataParentChoiceGroup;
|
|
51
51
|
lvl = parentLvl + 1;
|
|
52
52
|
data.customDataParentChoiceGroup = parent.data.customDataParentChoiceGroup;
|
|
53
|
-
|
|
53
|
+
/*
|
|
54
|
+
// Keep the marker on the parent: a single choice can contain several toggleable code blocks
|
|
55
|
+
// (e.g. two TypeScript blocks, or a TypeScript block + an `npm` command). Each of them spawns
|
|
56
|
+
// its own nested choice group and must inherit the same parent level. Clearing the marker here
|
|
57
|
+
// would make every group after the first resolve to `lvl: 0`, wrapping it in its own
|
|
58
|
+
// `CustomSelectsContainer` — which then renders without `choiceGroupAll` and crashes.
|
|
59
|
+
parent.data = undefined
|
|
60
|
+
*/
|
|
54
61
|
}
|
|
55
62
|
for (const choiceNode of mergedChoiceNodes) {
|
|
56
63
|
const choiceChildren = [];
|