@textcortex/slidewise 1.6.0 → 1.8.0
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/dist/index.mjs +5378 -5314
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SlidewiseEditor.tsx +11 -1
- package/src/SlidewiseFileEditor.tsx +8 -0
- package/src/components/editor/Canvas.tsx +15 -8
- package/src/components/editor/SlideView.tsx +6 -1
- package/src/compound/CanvasContext.tsx +176 -0
- package/src/compound/SlidewiseRoot.tsx +34 -11
- package/src/compound/index.ts +21 -1
- package/src/compound/parts.tsx +4 -11
- package/src/compound/sliderail/AddButton.tsx +76 -0
- package/src/compound/sliderail/Header.tsx +84 -0
- package/src/compound/sliderail/Item.tsx +82 -0
- package/src/compound/sliderail/ItemContext.tsx +42 -0
- package/src/compound/sliderail/List.tsx +67 -0
- package/src/compound/sliderail/Number.tsx +57 -0
- package/src/compound/sliderail/Root.tsx +54 -0
- package/src/compound/sliderail/Thumbnail.tsx +58 -0
- package/src/compound/sliderail/index.tsx +74 -0
- package/src/index.ts +15 -0
- package/src/components/editor/SlideRail.tsx +0 -285
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { Plus, LayoutGrid, Trash2 } from "lucide-react";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { useEditor } from "@/lib/StoreProvider";
|
|
4
|
-
import { SlideView } from "./SlideView";
|
|
5
|
-
import { SLIDE_W, type Slide } from "@/lib/types";
|
|
6
|
-
|
|
7
|
-
const RAIL_W = 168;
|
|
8
|
-
const THUMB_W = 132;
|
|
9
|
-
const THUMB_SCALE = THUMB_W / SLIDE_W;
|
|
10
|
-
|
|
11
|
-
export function SlideRail() {
|
|
12
|
-
const slides = useEditor((s) => s.deck.slides);
|
|
13
|
-
const currentId = useEditor((s) => s.currentSlideId);
|
|
14
|
-
const selectSlide = useEditor((s) => s.selectSlide);
|
|
15
|
-
const addSlide = useEditor((s) => s.addSlide);
|
|
16
|
-
const deleteSlide = useEditor((s) => s.deleteSlide);
|
|
17
|
-
const setView = useEditor((s) => s.setView);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<div
|
|
21
|
-
style={{
|
|
22
|
-
width: RAIL_W,
|
|
23
|
-
flexShrink: 0,
|
|
24
|
-
background: "var(--rail-bg)",
|
|
25
|
-
borderRight: "1px solid var(--border)",
|
|
26
|
-
boxShadow: "var(--rail-shadow)",
|
|
27
|
-
display: "flex",
|
|
28
|
-
flexDirection: "column",
|
|
29
|
-
fontFamily: "Inter, system-ui, sans-serif",
|
|
30
|
-
overflow: "hidden",
|
|
31
|
-
zIndex: 5,
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
35
|
-
style={{
|
|
36
|
-
height: 36,
|
|
37
|
-
display: "flex",
|
|
38
|
-
alignItems: "center",
|
|
39
|
-
justifyContent: "space-between",
|
|
40
|
-
padding: "0 12px",
|
|
41
|
-
fontSize: 12,
|
|
42
|
-
color: "var(--ink-muted)",
|
|
43
|
-
borderBottom: "1px solid var(--border)",
|
|
44
|
-
}}
|
|
45
|
-
>
|
|
46
|
-
<button
|
|
47
|
-
title="Slide overview"
|
|
48
|
-
aria-label="Open slide overview"
|
|
49
|
-
onClick={() => setView("grid")}
|
|
50
|
-
style={{
|
|
51
|
-
width: 28,
|
|
52
|
-
height: 28,
|
|
53
|
-
border: "none",
|
|
54
|
-
borderRadius: 6,
|
|
55
|
-
background: "transparent",
|
|
56
|
-
display: "flex",
|
|
57
|
-
alignItems: "center",
|
|
58
|
-
justifyContent: "center",
|
|
59
|
-
color: "var(--ink)",
|
|
60
|
-
cursor: "pointer",
|
|
61
|
-
}}
|
|
62
|
-
onMouseEnter={(e) =>
|
|
63
|
-
(e.currentTarget.style.background = "var(--hover-strong)")
|
|
64
|
-
}
|
|
65
|
-
onMouseLeave={(e) => (e.currentTarget.style.background = "transparent")}
|
|
66
|
-
>
|
|
67
|
-
<LayoutGrid size={14} />
|
|
68
|
-
</button>
|
|
69
|
-
<span>
|
|
70
|
-
{slides.findIndex((s) => s.id === currentId) + 1} / {slides.length}
|
|
71
|
-
</span>
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
<div
|
|
75
|
-
style={{
|
|
76
|
-
flex: 1,
|
|
77
|
-
overflowY: "auto",
|
|
78
|
-
padding: "12px 0",
|
|
79
|
-
}}
|
|
80
|
-
>
|
|
81
|
-
{slides.map((s, i) => (
|
|
82
|
-
<ThumbRow
|
|
83
|
-
key={s.id}
|
|
84
|
-
index={i}
|
|
85
|
-
isCurrent={s.id === currentId}
|
|
86
|
-
slide={s}
|
|
87
|
-
onSelect={() => selectSlide(s.id)}
|
|
88
|
-
onInsertAfter={() => addSlide(s.id)}
|
|
89
|
-
onDelete={() => deleteSlide(s.id)}
|
|
90
|
-
isLast={i === slides.length - 1}
|
|
91
|
-
/>
|
|
92
|
-
))}
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
<button
|
|
96
|
-
onClick={() => addSlide()}
|
|
97
|
-
style={{
|
|
98
|
-
height: 44,
|
|
99
|
-
margin: 12,
|
|
100
|
-
display: "flex",
|
|
101
|
-
alignItems: "center",
|
|
102
|
-
justifyContent: "center",
|
|
103
|
-
gap: 6,
|
|
104
|
-
background: "var(--app-bg)",
|
|
105
|
-
border: "1px dashed var(--border-dashed)",
|
|
106
|
-
borderRadius: 10,
|
|
107
|
-
color: "var(--ink)",
|
|
108
|
-
fontSize: 13,
|
|
109
|
-
fontWeight: 500,
|
|
110
|
-
cursor: "pointer",
|
|
111
|
-
transition:
|
|
112
|
-
"background 120ms, border-color 120ms, color 120ms",
|
|
113
|
-
}}
|
|
114
|
-
onMouseEnter={(e) => {
|
|
115
|
-
e.currentTarget.style.borderColor = "var(--accent)";
|
|
116
|
-
e.currentTarget.style.color = "var(--accent)";
|
|
117
|
-
}}
|
|
118
|
-
onMouseLeave={(e) => {
|
|
119
|
-
e.currentTarget.style.borderColor = "var(--border-dashed)";
|
|
120
|
-
e.currentTarget.style.color = "var(--ink)";
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
<Plus size={14} />
|
|
124
|
-
New Slide
|
|
125
|
-
</button>
|
|
126
|
-
</div>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function ThumbRow({
|
|
131
|
-
index,
|
|
132
|
-
isCurrent,
|
|
133
|
-
slide,
|
|
134
|
-
onSelect,
|
|
135
|
-
onInsertAfter,
|
|
136
|
-
onDelete,
|
|
137
|
-
isLast,
|
|
138
|
-
}: {
|
|
139
|
-
index: number;
|
|
140
|
-
isCurrent: boolean;
|
|
141
|
-
slide: Slide;
|
|
142
|
-
onSelect: () => void;
|
|
143
|
-
onInsertAfter: () => void;
|
|
144
|
-
onDelete: () => void;
|
|
145
|
-
isLast: boolean;
|
|
146
|
-
}) {
|
|
147
|
-
const [hover, setHover] = useState(false);
|
|
148
|
-
return (
|
|
149
|
-
<div
|
|
150
|
-
onMouseEnter={() => setHover(true)}
|
|
151
|
-
onMouseLeave={() => setHover(false)}
|
|
152
|
-
style={{
|
|
153
|
-
position: "relative",
|
|
154
|
-
padding: "0 12px",
|
|
155
|
-
marginBottom: 14,
|
|
156
|
-
}}
|
|
157
|
-
>
|
|
158
|
-
<div style={{ position: "relative" }}>
|
|
159
|
-
<span
|
|
160
|
-
aria-hidden="true"
|
|
161
|
-
style={{
|
|
162
|
-
position: "absolute",
|
|
163
|
-
left: 8,
|
|
164
|
-
top: 6,
|
|
165
|
-
zIndex: 2,
|
|
166
|
-
width: 22,
|
|
167
|
-
height: 22,
|
|
168
|
-
borderRadius: 5,
|
|
169
|
-
background: isCurrent ? "var(--ink)" : "#6B7280",
|
|
170
|
-
color: isCurrent ? "var(--app-bg)" : "#fff",
|
|
171
|
-
display: "flex",
|
|
172
|
-
alignItems: "center",
|
|
173
|
-
justifyContent: "center",
|
|
174
|
-
fontSize: 11,
|
|
175
|
-
fontWeight: 700,
|
|
176
|
-
fontFamily: "Inter, system-ui, sans-serif",
|
|
177
|
-
pointerEvents: "none",
|
|
178
|
-
}}
|
|
179
|
-
>
|
|
180
|
-
{String(index + 1).padStart(2, "0")}
|
|
181
|
-
</span>
|
|
182
|
-
<button
|
|
183
|
-
aria-label={`Open slide ${index + 1}`}
|
|
184
|
-
aria-current={isCurrent ? "true" : undefined}
|
|
185
|
-
onClick={onSelect}
|
|
186
|
-
style={{
|
|
187
|
-
display: "block",
|
|
188
|
-
width: THUMB_W,
|
|
189
|
-
border: isCurrent
|
|
190
|
-
? "2px solid var(--accent)"
|
|
191
|
-
: "2px solid transparent",
|
|
192
|
-
borderRadius: 8,
|
|
193
|
-
padding: 0,
|
|
194
|
-
background: "transparent",
|
|
195
|
-
cursor: "pointer",
|
|
196
|
-
overflow: "hidden",
|
|
197
|
-
transition: "border-color 120ms",
|
|
198
|
-
}}
|
|
199
|
-
>
|
|
200
|
-
<div style={{ pointerEvents: "none" }}>
|
|
201
|
-
<SlideView slide={slide} scale={THUMB_SCALE} />
|
|
202
|
-
</div>
|
|
203
|
-
</button>
|
|
204
|
-
|
|
205
|
-
{hover && (
|
|
206
|
-
<button
|
|
207
|
-
onClick={(e) => {
|
|
208
|
-
e.stopPropagation();
|
|
209
|
-
onDelete();
|
|
210
|
-
}}
|
|
211
|
-
title="Delete slide"
|
|
212
|
-
aria-label={`Delete slide ${index + 1}`}
|
|
213
|
-
style={{
|
|
214
|
-
position: "absolute",
|
|
215
|
-
right: 6,
|
|
216
|
-
top: 6,
|
|
217
|
-
width: 22,
|
|
218
|
-
height: 22,
|
|
219
|
-
borderRadius: 6,
|
|
220
|
-
background: "var(--toolbar-bg)",
|
|
221
|
-
backdropFilter: "blur(10px)",
|
|
222
|
-
WebkitBackdropFilter: "blur(10px)",
|
|
223
|
-
border: "1px solid var(--border-strong)",
|
|
224
|
-
cursor: "pointer",
|
|
225
|
-
display: "flex",
|
|
226
|
-
alignItems: "center",
|
|
227
|
-
justifyContent: "center",
|
|
228
|
-
color: "var(--ink)",
|
|
229
|
-
}}
|
|
230
|
-
>
|
|
231
|
-
<Trash2 size={11} />
|
|
232
|
-
</button>
|
|
233
|
-
)}
|
|
234
|
-
</div>
|
|
235
|
-
|
|
236
|
-
{!isLast && <InsertGap onInsert={onInsertAfter} />}
|
|
237
|
-
</div>
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function InsertGap({ onInsert }: { onInsert: () => void }) {
|
|
242
|
-
const [hover, setHover] = useState(false);
|
|
243
|
-
return (
|
|
244
|
-
<div
|
|
245
|
-
onMouseEnter={() => setHover(true)}
|
|
246
|
-
onMouseLeave={() => setHover(false)}
|
|
247
|
-
style={{
|
|
248
|
-
position: "absolute",
|
|
249
|
-
left: 0,
|
|
250
|
-
right: 0,
|
|
251
|
-
bottom: -14,
|
|
252
|
-
height: 28,
|
|
253
|
-
display: "flex",
|
|
254
|
-
alignItems: "center",
|
|
255
|
-
justifyContent: "center",
|
|
256
|
-
zIndex: 5,
|
|
257
|
-
}}
|
|
258
|
-
>
|
|
259
|
-
<button
|
|
260
|
-
onClick={onInsert}
|
|
261
|
-
aria-label="Insert slide here"
|
|
262
|
-
title="Insert slide"
|
|
263
|
-
style={{
|
|
264
|
-
width: hover ? 30 : 22,
|
|
265
|
-
height: hover ? 30 : 22,
|
|
266
|
-
borderRadius: 999,
|
|
267
|
-
background: "var(--gap-icon-bg)",
|
|
268
|
-
border: "1px solid var(--border-strong)",
|
|
269
|
-
cursor: "pointer",
|
|
270
|
-
display: "flex",
|
|
271
|
-
alignItems: "center",
|
|
272
|
-
justifyContent: "center",
|
|
273
|
-
color: "var(--ink)",
|
|
274
|
-
opacity: hover ? 1 : 0,
|
|
275
|
-
transform: hover ? "scale(1)" : "scale(0.85)",
|
|
276
|
-
transition:
|
|
277
|
-
"opacity 140ms, transform 140ms, width 140ms, height 140ms",
|
|
278
|
-
boxShadow: hover ? "var(--toolbar-shadow)" : "var(--thumb-shadow)",
|
|
279
|
-
}}
|
|
280
|
-
>
|
|
281
|
-
<Plus size={hover ? 16 : 12} />
|
|
282
|
-
</button>
|
|
283
|
-
</div>
|
|
284
|
-
);
|
|
285
|
-
}
|