Skip to content

Commit 21ef59e

Browse files
committed
I bypassed the compressa!
1 parent 5a0bb0d commit 21ef59e

8 files changed

Lines changed: 1102 additions & 147 deletions

File tree

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/guide.tsx

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,38 @@
11
import { Step } from "../common/data";
22

3-
export function createGuide(step: Step, showBack: boolean) {
4-
return (
5-
<webframe
6-
source={{
7-
url: "https://wolvenkit.github.io/gitbook-debug-guide/",
8-
}}
9-
data={{
10-
data: JSON.stringify({ step, showBack }),
11-
}}
12-
aspectRatio={16 / 9}
13-
/>
14-
);
15-
16-
// const options = step.options;
17-
// if (options && showBack) {
18-
// options.push({
19-
// label: "Go back",
20-
// target: "_back",
21-
// });
22-
// }
3+
export function createGuide(step: Step, showBack: boolean, stepName) {
4+
const options = step.options;
5+
if (options && showBack) {
6+
options.push({
7+
label: "Go back",
8+
target: "_back",
9+
});
10+
}
2311

24-
// if (!options) {
25-
// options.push({
26-
// label: "Restart...",
27-
// target: "_restart",
28-
// });
29-
// }
12+
if (!options) {
13+
options.push({
14+
label: "Restart...",
15+
target: "_restart",
16+
});
17+
}
3018

31-
// return (
32-
// <vstack align="center">
33-
// <markdown content={"## " + step.title} />
19+
return (
20+
<vstack align="center">
21+
<markdown content={"## " + step.title} />
3422

35-
// {step.description ? <markdown content={step.description} /> : null}
23+
{step.description ? <markdown content={step.description} /> : null}
3624

37-
// <vstack>
38-
// {options.map((button) => (
39-
// <button
40-
// label={button.label}
41-
// onPress={{
42-
// action: "click",
43-
// step: button.target,
44-
// }}
45-
// />
46-
// ))}
47-
// </vstack>
48-
// </vstack>
49-
// );
25+
<vstack>
26+
{options.map((button) => (
27+
<button
28+
label={button.label}
29+
onPress={{
30+
action: "click",
31+
step: button.target,
32+
}}
33+
/>
34+
))}
35+
</vstack>
36+
</vstack>
37+
);
5038
}

src/index.tsx

Lines changed: 87 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -43,86 +43,97 @@ const guideBlock = createComponent<
4343
}
4444
},
4545
async render(element, { environment }) {
46-
if (element.context.type !== "document") {
47-
throw new Error("Invalid context");
48-
}
49-
const { context, state } = element;
50-
const { editable } = context;
46+
return (
47+
<block>
48+
<webframe
49+
source={{
50+
url: "https://wolvenkit.github.io/gitbook-debug-guide/",
51+
}}
52+
aspectRatio={16 / 9}
53+
/>
54+
</block>
55+
);
5156

52-
let parsedContent: Content | null = null;
53-
let error: string | null = null;
57+
// if (element.context.type !== "document") {
58+
// throw new Error("Invalid context");
59+
// }
60+
// const { context, state } = element;
61+
// const { editable } = context;
5462

55-
const result = loadContent(state.content);
56-
if (typeof result === "string") {
57-
error = result;
58-
} else {
59-
parsedContent = result;
60-
}
63+
// let parsedContent: Content | null = null;
64+
// let error: string | null = null;
6165

62-
const historyLength = state.stepHistory.length;
63-
const currentStepName = state.stepHistory[historyLength - 1];
64-
const step = parsedContent?.[currentStepName];
65-
66-
const showBack = !step.hide_back && historyLength > 1;
67-
68-
element.setCache({
69-
maxAge: 0,
70-
});
71-
72-
/// EDITOR
73-
const getEditor = () => (
74-
<codeblock
75-
state="content"
76-
content={state.content}
77-
header={[<markdown content="## Debug Guide" />]}
78-
syntax="yaml"
79-
onContentChange={{
80-
action: "@editor.node.updateProps",
81-
props: {
82-
content: element.dynamicState("content"),
83-
},
84-
}}
85-
footer={[
86-
<divider />,
87-
error ? (
88-
<vstack align="center">
89-
<text style="code">{error}</text>
90-
</vstack>
91-
) : (
92-
createGuide(step, showBack)
93-
),
94-
]}
95-
/>
96-
);
66+
// const result = loadContent(state.content);
67+
// if (typeof result === "string") {
68+
// error = result;
69+
// } else {
70+
// parsedContent = result;
71+
// }
72+
73+
// const historyLength = state.stepHistory.length;
74+
// const currentStepName = state.stepHistory[historyLength - 1];
75+
// const step = parsedContent?.[currentStepName];
76+
77+
// const showBack = !step.hide_back && historyLength > 1;
78+
79+
// element.setCache({
80+
// maxAge: 0,
81+
// });
82+
83+
// /// EDITOR
84+
// const getEditor = () => (
85+
// <codeblock
86+
// state="content"
87+
// content={state.content}
88+
// header={[<markdown content="## Debug Guide" />]}
89+
// syntax="yaml"
90+
// onContentChange={{
91+
// action: "@editor.node.updateProps",
92+
// props: {
93+
// content: element.dynamicState("content"),
94+
// },
95+
// }}
96+
// footer={[
97+
// <divider />,
98+
// error ? (
99+
// <vstack align="center">
100+
// <text style="code">{error}</text>
101+
// </vstack>
102+
// ) : (
103+
// createGuide(step, showBack, element.dynamicState("content"))
104+
// ),
105+
// ]}
106+
// />
107+
// );
108+
109+
// // FRONTEND
110+
111+
// // Make sure there is a way to get out of non-existing step (for whatever reason)
112+
// const getGuide = () =>
113+
// step ? (
114+
// createGuide(step, showBack, element.dynamicState("content"))
115+
// ) : (
116+
// <vstack>
117+
// <markdown content="## An error has occurred, please press the button bellow." />
118+
// <button
119+
// label="Reset / Try again"
120+
// onPress={{
121+
// action: "click",
122+
// step: "start",
123+
// }}
124+
// />
125+
// </vstack>
126+
// );
127+
128+
// const getFrontend = () =>
129+
// error ? (
130+
// // Don't show errors to users
131+
// <markdown content="# Error!\nDebug Guide is misconfigured.\nPlease contact authors of this wiki!" />
132+
// ) : (
133+
// getGuide()
134+
// );
97135

98-
// FRONTEND
99-
100-
// Make sure there is a way to get out of non-existing step (for whatever reason)
101-
const getGuide = () =>
102-
step ? (
103-
createGuide(step, showBack)
104-
) : (
105-
<vstack>
106-
<markdown content="## An error has occurred, please press the button bellow." />
107-
<button
108-
label="Reset / Try again"
109-
onPress={{
110-
action: "click",
111-
step: "start",
112-
}}
113-
/>
114-
</vstack>
115-
);
116-
117-
const getFrontend = () =>
118-
error ? (
119-
// Don't show errors to users
120-
<markdown content="# Error!\nDebug Guide is misconfigured.\nPlease contact authors of this wiki!" />
121-
) : (
122-
getGuide()
123-
);
124-
125-
return <block>{editable ? getEditor() : getFrontend()}</block>;
136+
// return <block>{editable ? getEditor() : getFrontend()}</block>;
126137
},
127138
});
128139

0 commit comments

Comments
 (0)