Skip to content

Commit 3dbc3c9

Browse files
checkpoint
1 parent 6fea7ff commit 3dbc3c9

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

examples/vite_basic/src/App.tsx

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AVAILABLE_FILES } from "./constants/files";
99
const App = () => {
1010
const [theme, setTheme] = useState<"light" | "dark">("dark");
1111
const [devMode, setDevMode] = useState(false);
12+
const [showBackrefs, setShowBackrefs] = useState(false);
1213
const {
1314
selectedFile,
1415
data: testPage,
@@ -17,6 +18,45 @@ const App = () => {
1718
handleFileChange,
1819
} = useFileLoader(AVAILABLE_FILES[0]);
1920

21+
// Sample backrefs for real_document.json
22+
const sampleBackrefs = [
23+
{
24+
end_idx: 82,
25+
block_id: "bk_01jxyv2pekf4bs9a82ayxsewga",
26+
start_idx: 0,
27+
},
28+
{
29+
end_idx: 125,
30+
block_id: "bk_01jxyv2pemfj3848ncdbap6xsa",
31+
start_idx: 8,
32+
},
33+
{
34+
end_idx: 100,
35+
block_id: "bk_01jxyv2pg6f8hbvmc960g8k58m",
36+
start_idx: 0,
37+
},
38+
{
39+
end_idx: 30,
40+
block_id: "bk_01jxyv2pepepaam6k48t1s5c1q",
41+
start_idx: 6,
42+
},
43+
{
44+
end_idx: 20,
45+
block_id: "bk_01jxyv2peqfx1vv7xa8zq4ajfx",
46+
start_idx: 0,
47+
},
48+
{
49+
end_idx: 200,
50+
block_id: "bk_01jxyv2ppcf6xvxsh278d4e2je",
51+
start_idx: 30,
52+
},
53+
{
54+
end_idx: 11,
55+
block_id: "bk_01jxyv2pesedv9dfz1e6ekbsj8",
56+
start_idx: 1,
57+
},
58+
];
59+
2060
if (error) {
2161
return (
2262
<div
@@ -54,6 +94,8 @@ const App = () => {
5494
);
5595
}
5696

97+
console.log("showBackrefs ", sampleBackrefs);
98+
5799
return (
58100
<div
59101
style={{
@@ -74,6 +116,8 @@ const App = () => {
74116
setDevMode={setDevMode}
75117
theme={theme}
76118
setTheme={setTheme}
119+
showBackrefs={showBackrefs}
120+
setShowBackrefs={setShowBackrefs}
77121
/>
78122

79123
<div
@@ -92,7 +136,7 @@ const App = () => {
92136
page={testPage}
93137
theme={theme}
94138
devMode={devMode}
95-
backrefs={[]}
139+
backrefs={showBackrefs ? sampleBackrefs : []}
96140
components={{
97141
page_delimiter: (props) => {
98142
return <PageDelimiter {...props} />;

examples/vite_basic/src/components/DevPanel.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ interface DevPanelProps {
66
setDevMode: (mode: boolean) => void;
77
theme: "light" | "dark";
88
setTheme: (theme: "light" | "dark") => void;
9+
showBackrefs: boolean;
10+
setShowBackrefs: (show: boolean) => void;
911
}
1012

1113
const DevPanel: React.FC<DevPanelProps> = ({
1214
devMode,
1315
setDevMode,
1416
theme,
1517
setTheme,
18+
showBackrefs,
19+
setShowBackrefs,
1620
}) => {
1721
return (
1822
<>
@@ -35,6 +39,15 @@ const DevPanel: React.FC<DevPanelProps> = ({
3539
>
3640
{theme === "dark" ? "☀️ Light" : "🌙 Dark"} Mode
3741
</FloatingButton>
42+
43+
{/* Floating Backrefs Toggle Button */}
44+
<FloatingButton
45+
onClick={() => setShowBackrefs(!showBackrefs)}
46+
backgroundColor={showBackrefs ? "oklch(60% 0.2 120)" : "oklch(40% 0.2 120)"}
47+
offset={{ x: 380, y: 20 }}
48+
>
49+
{showBackrefs ? "Hide" : "Show"} Backrefs
50+
</FloatingButton>
3851
</>
3952
);
4053
};

0 commit comments

Comments
 (0)