@open-slide/core 1.19.0 → 2.0.0-beta.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/{build-CaV_vhIw.js → build-CfAxF6Dm.js} +2 -5
- package/dist/cli/bin.d.ts +1 -1
- package/dist/cli/bin.js +139 -13
- package/dist/{config-CDHB8Oow.d.ts → config-AtA2Bqtn.d.ts} +4 -4
- package/dist/{config-GA6NMgs_.js → config-C_VI2EpT.js} +545 -776
- package/dist/{design-cpzS8aud.js → design-Cpqx7SJs.js} +1 -2
- package/dist/{dev-D57ui2yV.js → dev-BChELmc-.js} +4 -7
- package/dist/index.d.ts +7 -37
- package/dist/index.js +51 -54
- package/dist/locale/index.d.ts +2 -8
- package/dist/locale/index.js +13 -3
- package/dist/{preview-D40Zw_o0.js → preview-CcCQa268.js} +3 -7
- package/dist/{types-8HghULIe.d.ts → types-BzPSOxe-.d.ts} +5 -9
- package/dist/vite/index.d.ts +1 -4
- package/dist/vite/index.js +2 -4
- package/dist/{format-74A3B6zu.js → zh-tw-BxZ_pYqe.js} +13 -49
- package/package.json +12 -12
- package/skills/create-slide/SKILL.md +4 -1
- package/skills/slide-authoring/SKILL.md +25 -2
- package/src/app/app.tsx +18 -15
- package/src/app/assets/open-slide.png +0 -0
- package/src/app/components/asset-view.tsx +46 -39
- package/src/app/components/command/command-menu.tsx +5 -1
- package/src/app/components/command/command.tsx +4 -2
- package/src/app/components/command/home-command-menu.tsx +6 -6
- package/src/app/components/export-progress-toast.tsx +80 -0
- package/src/app/components/history-provider.tsx +1 -5
- package/src/app/components/icon-tooltip.tsx +24 -15
- package/src/app/components/image-placeholder.tsx +4 -12
- package/src/app/components/inspector/asset-picker-dialog.tsx +24 -32
- package/src/app/components/inspector/comment-widget.tsx +33 -7
- package/src/app/components/inspector/image-crop-dialog.tsx +9 -6
- package/src/app/components/inspector/inline-text-editor.tsx +798 -0
- package/src/app/components/inspector/inspect-overlay.tsx +35 -76
- package/src/app/components/inspector/inspector-panel.tsx +31 -53
- package/src/app/components/inspector/inspector-provider.tsx +53 -36
- package/src/app/components/language-toggle.tsx +2 -3
- package/src/app/components/notes-drawer.tsx +4 -7
- package/src/app/components/overview-grid.tsx +15 -8
- package/src/app/components/panel/panel-shell.tsx +1 -3
- package/src/app/components/panel/save-card.tsx +12 -3
- package/src/app/components/player.tsx +5 -6
- package/src/app/components/present/blackout-overlay.tsx +16 -3
- package/src/app/components/present/control-bar.tsx +21 -13
- package/src/app/components/present/jump-input.tsx +27 -5
- package/src/app/components/present/laser-pointer.tsx +34 -11
- package/src/app/components/present/progress-bar.tsx +1 -1
- package/src/app/components/present/use-presenter-channel.ts +0 -1
- package/src/app/components/present/use-touch-swipe.ts +9 -2
- package/src/app/components/sidebar/folder-item.tsx +48 -21
- package/src/app/components/sidebar/icon-picker.tsx +1 -1
- package/src/app/components/sidebar/sidebar-footer.tsx +20 -7
- package/src/app/components/sidebar/sidebar.tsx +91 -64
- package/src/app/components/slide-canvas.tsx +2 -6
- package/src/app/components/slide-transition-layer.tsx +48 -76
- package/src/app/components/style-panel/design-provider.tsx +1 -14
- package/src/app/components/style-panel/style-panel.tsx +16 -12
- package/src/app/components/style-panel/use-design.ts +1 -28
- package/src/app/components/theme-toggle.tsx +4 -5
- package/src/app/components/themes/theme-detail.tsx +11 -8
- package/src/app/components/themes/themes-gallery.tsx +13 -8
- package/src/app/components/thumbnail-rail.tsx +14 -15
- package/src/app/index.html +21 -0
- package/src/app/lib/assets.ts +6 -7
- package/src/app/lib/dom.ts +42 -0
- package/src/app/lib/export-html.ts +10 -25
- package/src/app/lib/export-pdf.ts +11 -28
- package/src/app/lib/export-pptx.ts +6 -36
- package/src/app/lib/folders.ts +51 -46
- package/src/app/lib/inspector/inline-text.ts +31 -0
- package/src/app/lib/inspector/pick-target.ts +38 -0
- package/src/app/lib/inspector/use-comments.ts +1 -1
- package/src/app/lib/keys.ts +18 -0
- package/src/app/lib/last-home-location.ts +18 -0
- package/src/app/lib/print-ready.ts +2 -4
- package/src/app/lib/slides.ts +7 -4
- package/src/app/lib/text-diff.ts +19 -0
- package/src/app/lib/use-click-page-navigation.ts +2 -6
- package/src/app/lib/use-is-mobile.ts +2 -14
- package/src/app/lib/use-media-query.ts +20 -0
- package/src/app/lib/use-prefers-reduced-motion.ts +5 -13
- package/src/app/lib/use-slide-module.ts +1 -1
- package/src/app/lib/use-wheel-page-navigation.ts +1 -1
- package/src/app/lib/utils.test.ts +25 -1
- package/src/app/lib/utils.ts +8 -0
- package/src/app/routes/home-shell.tsx +71 -64
- package/src/app/routes/home.tsx +50 -58
- package/src/app/routes/presenter.tsx +14 -23
- package/src/app/routes/slide.tsx +90 -77
- package/src/app/routes/themes.tsx +7 -8
- package/src/app/styles.css +40 -44
- package/src/locale/en.ts +2 -7
- package/src/locale/ja.ts +2 -7
- package/src/locale/types.ts +2 -7
- package/src/locale/zh-cn.ts +2 -7
- package/src/locale/zh-tw.ts +2 -7
- package/dist/sync-BCJDRIqo.js +0 -139
- package/dist/sync-j9_QPovT.js +0 -3
- package/src/app/components/pdf-progress-toast.tsx +0 -32
- package/src/app/components/pptx-progress-toast.tsx +0 -32
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Monitor, Moon, Sun } from 'lucide-react';
|
|
2
2
|
import { useTheme } from 'next-themes';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
|
-
import { IconTooltip } from '@/components/icon-tooltip';
|
|
4
|
+
import { IconTooltip, MenuTooltipTrigger } from '@/components/icon-tooltip';
|
|
5
5
|
import { buttonVariants } from '@/components/ui/button';
|
|
6
6
|
import {
|
|
7
7
|
DropdownMenu,
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
DropdownMenuItem,
|
|
10
10
|
DropdownMenuTrigger,
|
|
11
11
|
} from '@/components/ui/dropdown-menu';
|
|
12
|
-
import { TooltipTrigger } from '@/components/ui/tooltip';
|
|
13
12
|
import { useLocale } from '@/lib/use-locale';
|
|
14
13
|
import { cn } from '@/lib/utils';
|
|
15
14
|
|
|
@@ -27,15 +26,15 @@ export function ThemeToggle() {
|
|
|
27
26
|
<IconTooltip label={t.themeToggle.title}>
|
|
28
27
|
<DropdownMenuTrigger
|
|
29
28
|
render={
|
|
30
|
-
<
|
|
29
|
+
<MenuTooltipTrigger
|
|
31
30
|
type="button"
|
|
32
31
|
aria-label={t.themeToggle.toggleAria}
|
|
33
32
|
className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }), 'relative')}
|
|
34
33
|
/>
|
|
35
34
|
}
|
|
36
35
|
>
|
|
37
|
-
<Sun className="size-3.5 scale-100 rotate-0 transition-
|
|
38
|
-
<Moon className="absolute size-3.5 scale-
|
|
36
|
+
<Sun className="size-3.5 scale-100 rotate-0 opacity-100 ease-swift motion-safe:transition-[opacity,scale,rotate] motion-safe:duration-200 dark:scale-75 dark:-rotate-90 dark:opacity-0" />
|
|
37
|
+
<Moon className="absolute size-3.5 scale-75 rotate-90 opacity-0 ease-swift motion-safe:transition-[opacity,scale,rotate] motion-safe:duration-200 dark:scale-100 dark:rotate-0 dark:opacity-100" />
|
|
39
38
|
</DropdownMenuTrigger>
|
|
40
39
|
</IconTooltip>
|
|
41
40
|
<DropdownMenuContent align="end" className="min-w-[140px]">
|
|
@@ -3,7 +3,7 @@ import { Fragment, type ReactNode, useEffect, useMemo, useRef, useState } from '
|
|
|
3
3
|
import { Link } from 'react-router-dom';
|
|
4
4
|
import { Button } from '@/components/ui/button';
|
|
5
5
|
import { format, useLocale } from '@/lib/use-locale';
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
6
|
+
import { cn, pad2 } from '@/lib/utils';
|
|
7
7
|
import { SlidePageProvider } from '../../lib/page-context';
|
|
8
8
|
import type { SlideModule } from '../../lib/sdk';
|
|
9
9
|
import { loadSlide, slidesByTheme } from '../../lib/slides';
|
|
@@ -85,7 +85,7 @@ export function ThemeDetail({ themeId, onBack }: { themeId: string; onBack: () =
|
|
|
85
85
|
</div>
|
|
86
86
|
|
|
87
87
|
<header className="flex flex-wrap items-baseline gap-3">
|
|
88
|
-
<h2 className="font-heading text-[
|
|
88
|
+
<h2 className="font-heading text-[19px] font-semibold leading-none tracking-[-0.015em] md:text-[21px]">
|
|
89
89
|
{theme.name}
|
|
90
90
|
</h2>
|
|
91
91
|
{theme.description ? (
|
|
@@ -121,7 +121,7 @@ export function ThemeDetail({ themeId, onBack }: { themeId: string; onBack: () =
|
|
|
121
121
|
aria-label={t.themes.prevPageAria}
|
|
122
122
|
disabled={pageIndex === 0}
|
|
123
123
|
onClick={() => setPageIndex((i) => Math.max(0, i - 1))}
|
|
124
|
-
className="flex size-8 items-center justify-center rounded-[6px] border border-border bg-card text-foreground transition-
|
|
124
|
+
className="flex size-8 items-center justify-center rounded-[6px] border border-border bg-card text-foreground outline-none transition-[background-color,opacity,scale] duration-100 hover:bg-muted active:scale-95 focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-40"
|
|
125
125
|
>
|
|
126
126
|
<ChevronLeft className="size-4" />
|
|
127
127
|
</button>
|
|
@@ -133,7 +133,7 @@ export function ThemeDetail({ themeId, onBack }: { themeId: string; onBack: () =
|
|
|
133
133
|
aria-label={t.themes.nextPageAria}
|
|
134
134
|
disabled={pageIndex === totalPages - 1}
|
|
135
135
|
onClick={() => setPageIndex((i) => Math.min(totalPages - 1, i + 1))}
|
|
136
|
-
className="flex size-8 items-center justify-center rounded-[6px] border border-border bg-card text-foreground transition-
|
|
136
|
+
className="flex size-8 items-center justify-center rounded-[6px] border border-border bg-card text-foreground outline-none transition-[background-color,opacity,scale] duration-100 hover:bg-muted active:scale-95 focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-40"
|
|
137
137
|
>
|
|
138
138
|
<ChevronRight className="size-4" />
|
|
139
139
|
</button>
|
|
@@ -183,7 +183,7 @@ export function ThemeDetail({ themeId, onBack }: { themeId: string; onBack: () =
|
|
|
183
183
|
<div className="flex flex-wrap items-baseline gap-3">
|
|
184
184
|
<span className="eyebrow">{t.themes.usedBy}</span>
|
|
185
185
|
{usedBySlideIds.length > 0 ? (
|
|
186
|
-
<span className="folio">{usedBySlideIds.length
|
|
186
|
+
<span className="folio">{pad2(usedBySlideIds.length)}</span>
|
|
187
187
|
) : null}
|
|
188
188
|
</div>
|
|
189
189
|
{usedBySlideIds.length === 0 ? (
|
|
@@ -225,10 +225,13 @@ function ThemeSlideCard({ id }: { id: string }) {
|
|
|
225
225
|
const displayTitle = slide?.meta?.title ?? id;
|
|
226
226
|
|
|
227
227
|
return (
|
|
228
|
-
<Link
|
|
229
|
-
|
|
228
|
+
<Link
|
|
229
|
+
to={`/s/${id}`}
|
|
230
|
+
className="group block rounded-[6px] outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
231
|
+
>
|
|
232
|
+
<div className="relative aspect-video overflow-hidden rounded-[6px] border border-hairline bg-card shadow-edge ring-1 ring-foreground/[0.04] group-hover:shadow-floating group-hover:ring-foreground/20 group-active:scale-[0.99] motion-safe:transition-[box-shadow,--tw-ring-color,scale] motion-safe:duration-200">
|
|
230
233
|
{FirstPage ? (
|
|
231
|
-
<div className="h-full w-full
|
|
234
|
+
<div className="h-full w-full">
|
|
232
235
|
<SlideCanvas flat freezeMotion design={slide?.design}>
|
|
233
236
|
<SlidePageProvider index={0} total={slide?.default.length ?? 1}>
|
|
234
237
|
<FirstPage />
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Palette } from 'lucide-react';
|
|
1
2
|
import { useEffect, useState } from 'react';
|
|
2
3
|
import { format, useLocale } from '@/lib/use-locale';
|
|
3
4
|
import { SlidePageProvider } from '../../lib/page-context';
|
|
@@ -13,8 +14,12 @@ export function ThemesGallery({ onOpen }: { onOpen: (id: string) => void }) {
|
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
16
|
<ul className="grid grid-cols-[repeat(auto-fill,minmax(min(240px,100%),1fr))] gap-x-6 gap-y-9 md:grid-cols-[repeat(auto-fill,minmax(340px,1fr))]">
|
|
16
|
-
{themes.map((theme) => (
|
|
17
|
-
<li
|
|
17
|
+
{themes.map((theme, i) => (
|
|
18
|
+
<li
|
|
19
|
+
key={theme.id}
|
|
20
|
+
className="rise-in"
|
|
21
|
+
style={{ animationDelay: `${Math.min(i, 11) * 30}ms` }}
|
|
22
|
+
>
|
|
18
23
|
<ThemeCard
|
|
19
24
|
theme={theme}
|
|
20
25
|
onOpen={() => onOpen(theme.id)}
|
|
@@ -40,9 +45,9 @@ function ThemeCard({
|
|
|
40
45
|
type="button"
|
|
41
46
|
onClick={onOpen}
|
|
42
47
|
aria-label={ariaLabel}
|
|
43
|
-
className="group block w-full text-left focus-visible:
|
|
48
|
+
className="group block w-full rounded-[6px] text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
44
49
|
>
|
|
45
|
-
<div className="relative aspect-video overflow-hidden rounded-[6px] border border-hairline bg-card shadow-edge ring-1 ring-foreground/[0.04] group-hover:shadow-floating group-hover:ring-foreground/20 motion-safe:transition-[box-shadow,--tw-ring-color] motion-safe:duration-200">
|
|
50
|
+
<div className="relative aspect-video overflow-hidden rounded-[6px] border border-hairline bg-card shadow-edge ring-1 ring-foreground/[0.04] group-hover:shadow-floating group-hover:ring-foreground/20 group-active:scale-[0.99] motion-safe:transition-[box-shadow,--tw-ring-color,scale] motion-safe:duration-200">
|
|
46
51
|
<ThemePreview theme={theme} />
|
|
47
52
|
</div>
|
|
48
53
|
<div className="mt-3">
|
|
@@ -77,7 +82,7 @@ function ThemePreview({ theme }: { theme: Theme }) {
|
|
|
77
82
|
if (!FirstPage) return <NoDemoState />;
|
|
78
83
|
|
|
79
84
|
return (
|
|
80
|
-
<div className="h-full w-full
|
|
85
|
+
<div className="h-full w-full">
|
|
81
86
|
<SlideCanvas flat freezeMotion design={demo.design}>
|
|
82
87
|
<SlidePageProvider index={0} total={demo.default.length}>
|
|
83
88
|
<FirstPage />
|
|
@@ -110,10 +115,10 @@ function NoDemoState() {
|
|
|
110
115
|
function ThemesEmptyState() {
|
|
111
116
|
const t = useLocale();
|
|
112
117
|
return (
|
|
113
|
-
<div className="rounded-[
|
|
118
|
+
<div className="rounded-[8px] border border-dashed border-border px-8 py-20">
|
|
114
119
|
<div className="mx-auto flex max-w-md flex-col items-center text-center">
|
|
115
|
-
<
|
|
116
|
-
<p className="mt-
|
|
120
|
+
<Palette className="size-5 text-muted-foreground/60" aria-hidden />
|
|
121
|
+
<p className="mt-4 font-heading text-[14px] font-semibold tracking-tight">
|
|
117
122
|
{t.themes.noThemesTitle}
|
|
118
123
|
</p>
|
|
119
124
|
<p className="mt-1.5 text-[13px] leading-relaxed text-muted-foreground">
|
|
@@ -37,12 +37,13 @@ import {
|
|
|
37
37
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
|
38
38
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
|
39
39
|
import { format, useLocale } from '@/lib/use-locale';
|
|
40
|
-
import { cn } from '@/lib/utils';
|
|
40
|
+
import { cn, pad2 } from '@/lib/utils';
|
|
41
41
|
import type { DesignSystem } from '../lib/design';
|
|
42
42
|
import { SlidePageProvider } from '../lib/page-context';
|
|
43
43
|
import type { Page } from '../lib/sdk';
|
|
44
44
|
import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../lib/sdk';
|
|
45
45
|
import type { SlideTransition } from '../lib/transition';
|
|
46
|
+
import { prefersReducedMotion } from '../lib/use-prefers-reduced-motion';
|
|
46
47
|
import { SlideCanvas } from './slide-canvas';
|
|
47
48
|
import {
|
|
48
49
|
getCenteredThumbnailScrollTop,
|
|
@@ -269,7 +270,7 @@ export function ThumbnailRail({
|
|
|
269
270
|
<div className="flex items-center justify-between gap-2">
|
|
270
271
|
<span className="eyebrow">{t.thumbnailRail.pages}</span>
|
|
271
272
|
<div className="flex items-center gap-1.5">
|
|
272
|
-
<span className="folio">{pages.length
|
|
273
|
+
<span className="folio">{pad2(pages.length)}</span>
|
|
273
274
|
{onOverview && (
|
|
274
275
|
<Tooltip>
|
|
275
276
|
<TooltipTrigger
|
|
@@ -320,7 +321,7 @@ export function ThumbnailRail({
|
|
|
320
321
|
return (
|
|
321
322
|
<TooltipProvider delay={200}>
|
|
322
323
|
<div className="relative h-full">
|
|
323
|
-
<ScrollArea className="h-full
|
|
324
|
+
<ScrollArea className="h-full bg-sidebar [&_[data-slot=scroll-area-scrollbar]]:z-20">
|
|
324
325
|
{scrollAreaContents}
|
|
325
326
|
</ScrollArea>
|
|
326
327
|
{currentPosition && (
|
|
@@ -396,8 +397,8 @@ function CurrentThumbnailButton({
|
|
|
396
397
|
|
|
397
398
|
function thumbButtonClass(active: boolean): string {
|
|
398
399
|
return cn(
|
|
399
|
-
'group/thumb flex w-full items-start gap-2.5 rounded-[6px] p-1.5 text-left outline-none motion-safe:transition-
|
|
400
|
-
'hover:bg-muted/60',
|
|
400
|
+
'group/thumb flex w-full items-start gap-2.5 rounded-[6px] p-1.5 text-left outline-none motion-safe:transition-[background-color,scale] motion-safe:duration-100',
|
|
401
|
+
'hover:bg-muted/60 active:scale-[0.985]',
|
|
401
402
|
'focus-visible:ring-1 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-sidebar',
|
|
402
403
|
active && 'bg-muted',
|
|
403
404
|
);
|
|
@@ -499,7 +500,10 @@ function HorizontalVirtualThumbList({
|
|
|
499
500
|
onClick={() => onSelect(i)}
|
|
500
501
|
aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
|
|
501
502
|
aria-current={active ? 'page' : undefined}
|
|
502
|
-
className={cn(
|
|
503
|
+
className={cn(
|
|
504
|
+
'group/thumb relative flex shrink-0 flex-col items-center gap-1.5 rounded-[6px] outline-none motion-safe:transition-[scale] motion-safe:duration-100 active:scale-[0.985]',
|
|
505
|
+
'focus-visible:ring-1 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-sidebar',
|
|
506
|
+
)}
|
|
503
507
|
>
|
|
504
508
|
<span
|
|
505
509
|
className={cn(
|
|
@@ -507,7 +511,7 @@ function HorizontalVirtualThumbList({
|
|
|
507
511
|
active ? 'text-brand' : 'text-muted-foreground/70',
|
|
508
512
|
)}
|
|
509
513
|
>
|
|
510
|
-
{(i + 1)
|
|
514
|
+
{pad2(i + 1)}
|
|
511
515
|
</span>
|
|
512
516
|
<div
|
|
513
517
|
className={cn(
|
|
@@ -724,7 +728,7 @@ function getInitialVisibleRange(current: number, count: number): VisibleRange {
|
|
|
724
728
|
}
|
|
725
729
|
|
|
726
730
|
function scrollBehavior(): ScrollBehavior {
|
|
727
|
-
return
|
|
731
|
+
return prefersReducedMotion() ? 'auto' : 'smooth';
|
|
728
732
|
}
|
|
729
733
|
|
|
730
734
|
function ThumbContents({
|
|
@@ -770,7 +774,7 @@ function ThumbContents({
|
|
|
770
774
|
active ? 'text-brand' : 'text-muted-foreground/70',
|
|
771
775
|
)}
|
|
772
776
|
>
|
|
773
|
-
{(index + 1)
|
|
777
|
+
{pad2(index + 1)}
|
|
774
778
|
</span>
|
|
775
779
|
{(hasTransition || hasSteps) && (
|
|
776
780
|
<div className="flex flex-col items-end gap-0.5">
|
|
@@ -798,12 +802,6 @@ function ThumbContents({
|
|
|
798
802
|
<PageComp />
|
|
799
803
|
</SlidePageProvider>
|
|
800
804
|
</SlideCanvas>
|
|
801
|
-
{active && (
|
|
802
|
-
<span
|
|
803
|
-
aria-hidden
|
|
804
|
-
className="pointer-events-none absolute inset-y-0 left-0 w-[2px] bg-brand"
|
|
805
|
-
/>
|
|
806
|
-
)}
|
|
807
805
|
</div>
|
|
808
806
|
</>
|
|
809
807
|
);
|
|
@@ -939,6 +937,7 @@ function SortableThumb({
|
|
|
939
937
|
>) {
|
|
940
938
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
941
939
|
id: index + 1,
|
|
940
|
+
transition: { duration: 180, easing: 'var(--ease-swift)' },
|
|
942
941
|
});
|
|
943
942
|
|
|
944
943
|
const setRef = (node: HTMLButtonElement | null) => {
|
package/src/app/index.html
CHANGED
|
@@ -5,6 +5,27 @@
|
|
|
5
5
|
<link rel="icon" href="./favicon.ico" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>open-slide</title>
|
|
8
|
+
<style>
|
|
9
|
+
html {
|
|
10
|
+
background-color: oklch(0.99 0 0);
|
|
11
|
+
}
|
|
12
|
+
html.dark {
|
|
13
|
+
background-color: oklch(0.145 0 0);
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
<script>
|
|
17
|
+
// Apply the stored theme before first paint; next-themes only runs
|
|
18
|
+
// after the bundle loads, which flashes white for dark-mode users.
|
|
19
|
+
let stored = null;
|
|
20
|
+
try {
|
|
21
|
+
stored = localStorage.getItem('theme');
|
|
22
|
+
} catch (_) {}
|
|
23
|
+
const dark =
|
|
24
|
+
stored === 'dark' ||
|
|
25
|
+
(stored !== 'light' && matchMedia('(prefers-color-scheme: dark)').matches);
|
|
26
|
+
document.documentElement.classList.toggle('dark', dark);
|
|
27
|
+
document.documentElement.style.colorScheme = dark ? 'dark' : 'light';
|
|
28
|
+
</script>
|
|
8
29
|
</head>
|
|
9
30
|
<body>
|
|
10
31
|
<div id="root"></div>
|
package/src/app/lib/assets.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { changedSlideIds } from './slides';
|
|
3
|
+
|
|
4
|
+
export const GLOBAL_ASSET_SCOPE = '@global';
|
|
2
5
|
|
|
3
6
|
export type AssetEntry = {
|
|
4
7
|
name: string;
|
|
@@ -205,13 +208,9 @@ export function useAssets(slideId: string): UseAssetsResult {
|
|
|
205
208
|
refresh().catch(() => {});
|
|
206
209
|
}
|
|
207
210
|
};
|
|
208
|
-
const slideHandler = (data:
|
|
209
|
-
const changedIds =
|
|
210
|
-
|
|
211
|
-
: typeof data?.slideId === 'string'
|
|
212
|
-
? [data.slideId]
|
|
213
|
-
: [];
|
|
214
|
-
if (slideId === '@global' ? changedIds.length > 0 : changedIds.includes(slideId)) {
|
|
211
|
+
const slideHandler = (data: unknown) => {
|
|
212
|
+
const changedIds = changedSlideIds(data);
|
|
213
|
+
if (slideId === GLOBAL_ASSET_SCOPE ? changedIds.length > 0 : changedIds.includes(slideId)) {
|
|
215
214
|
refresh().catch(() => {});
|
|
216
215
|
}
|
|
217
216
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function sleep(ms: number): Promise<void> {
|
|
2
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function nextFrame(): Promise<void> {
|
|
6
|
+
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// rAF in real tabs; setTimeout fallback for hidden/throttled headless tabs.
|
|
10
|
+
export function nextPaint(): Promise<void> {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
let settled = false;
|
|
13
|
+
const settle = () => {
|
|
14
|
+
if (settled) return;
|
|
15
|
+
settled = true;
|
|
16
|
+
resolve();
|
|
17
|
+
};
|
|
18
|
+
requestAnimationFrame(settle);
|
|
19
|
+
setTimeout(settle, 50);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function downloadBlob(blob: Blob, filename: string): void {
|
|
24
|
+
const url = URL.createObjectURL(blob);
|
|
25
|
+
const a = document.createElement('a');
|
|
26
|
+
a.href = url;
|
|
27
|
+
a.download = filename;
|
|
28
|
+
a.rel = 'noopener';
|
|
29
|
+
document.body.appendChild(a);
|
|
30
|
+
a.click();
|
|
31
|
+
a.remove();
|
|
32
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function dragHasFiles(e: { dataTransfer: DataTransfer | null }): boolean {
|
|
36
|
+
const types = e.dataTransfer?.types;
|
|
37
|
+
if (!types) return false;
|
|
38
|
+
for (let i = 0; i < types.length; i++) {
|
|
39
|
+
if (types[i] === 'Files') return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { designToCssVars } from './design';
|
|
4
|
+
import { downloadBlob, nextFrame } from './dom';
|
|
4
5
|
import { SlidePageProvider } from './page-context';
|
|
5
|
-
import type
|
|
6
|
+
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from './sdk';
|
|
6
7
|
|
|
7
8
|
type AssetEntry = { name: string; bytes: Uint8Array };
|
|
8
9
|
|
|
@@ -75,8 +76,8 @@ async function renderPagesToHtml(pages: NonNullable<SlideModule['default']>): Pr
|
|
|
75
76
|
position: 'fixed',
|
|
76
77
|
left: '-99999px',
|
|
77
78
|
top: '0',
|
|
78
|
-
width:
|
|
79
|
-
height:
|
|
79
|
+
width: `${CANVAS_WIDTH}px`,
|
|
80
|
+
height: `${CANVAS_HEIGHT}px`,
|
|
80
81
|
pointerEvents: 'none',
|
|
81
82
|
});
|
|
82
83
|
document.body.appendChild(container);
|
|
@@ -87,15 +88,15 @@ async function renderPagesToHtml(pages: NonNullable<SlideModule['default']>): Pr
|
|
|
87
88
|
const Page = pages[i];
|
|
88
89
|
if (!Page) continue;
|
|
89
90
|
const host = document.createElement('div');
|
|
90
|
-
host.style.width =
|
|
91
|
-
host.style.height =
|
|
91
|
+
host.style.width = `${CANVAS_WIDTH}px`;
|
|
92
|
+
host.style.height = `${CANVAS_HEIGHT}px`;
|
|
92
93
|
container.appendChild(host);
|
|
93
94
|
const root = createRoot(host);
|
|
94
95
|
root.render(
|
|
95
96
|
createElement(SlidePageProvider, { index: i, total: pages.length }, createElement(Page)),
|
|
96
97
|
);
|
|
97
|
-
await
|
|
98
|
-
await
|
|
98
|
+
await nextFrame();
|
|
99
|
+
await nextFrame();
|
|
99
100
|
for (const video of host.querySelectorAll('video')) {
|
|
100
101
|
video.defaultMuted = video.muted;
|
|
101
102
|
}
|
|
@@ -109,10 +110,6 @@ async function renderPagesToHtml(pages: NonNullable<SlideModule['default']>): Pr
|
|
|
109
110
|
return result;
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
function nextPaint(): Promise<void> {
|
|
113
|
-
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
113
|
function collectCss(): string {
|
|
117
114
|
const chunks: string[] = [];
|
|
118
115
|
for (const sheet of Array.from(document.styleSheets)) {
|
|
@@ -263,7 +260,7 @@ ${opts.externalLinks}
|
|
|
263
260
|
<style>
|
|
264
261
|
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; font-family: system-ui, sans-serif; }
|
|
265
262
|
.os-stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
|
|
266
|
-
.os-frame { width:
|
|
263
|
+
.os-frame { width: ${CANVAS_WIDTH}px; height: ${CANVAS_HEIGHT}px; flex-shrink: 0; background: #fff; color: #000; transform-origin: center center; overflow: hidden; position: relative; }
|
|
267
264
|
.os-page { position: absolute; inset: 0; }
|
|
268
265
|
.os-page[hidden] { display: none !important; }
|
|
269
266
|
.os-counter { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); color: #fff; background: rgba(0,0,0,.5); padding: 2px 10px; border-radius: 999px; font-size: 12px; z-index: 10; font-variant-numeric: tabular-nums; }
|
|
@@ -280,7 +277,7 @@ html, body { margin: 0; height: 100%; background: #000; overflow: hidden; font-f
|
|
|
280
277
|
var frame = document.getElementById('os-frame');
|
|
281
278
|
var cur = document.getElementById('os-cur');
|
|
282
279
|
function fit() {
|
|
283
|
-
var s = Math.min(window.innerWidth /
|
|
280
|
+
var s = Math.min(window.innerWidth / ${CANVAS_WIDTH}, window.innerHeight / ${CANVAS_HEIGHT});
|
|
284
281
|
frame.style.transform = 'scale(' + s + ')';
|
|
285
282
|
}
|
|
286
283
|
function go(i) {
|
|
@@ -325,15 +322,3 @@ function escapeHtml(s: string): string {
|
|
|
325
322
|
function escapeAttr(s: string): string {
|
|
326
323
|
return s.replace(/&/g, '&').replace(/"/g, '"');
|
|
327
324
|
}
|
|
328
|
-
|
|
329
|
-
function downloadBlob(blob: Blob, filename: string): void {
|
|
330
|
-
const url = URL.createObjectURL(blob);
|
|
331
|
-
const a = document.createElement('a');
|
|
332
|
-
a.href = url;
|
|
333
|
-
a.download = filename;
|
|
334
|
-
a.rel = 'noopener';
|
|
335
|
-
document.body.appendChild(a);
|
|
336
|
-
a.click();
|
|
337
|
-
a.remove();
|
|
338
|
-
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
339
|
-
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createRoot, type Root } from 'react-dom/client';
|
|
3
3
|
import { designToCssVars } from './design';
|
|
4
|
+
import { nextPaint, sleep } from './dom';
|
|
4
5
|
import { SlidePageProvider } from './page-context';
|
|
5
6
|
import { isFrameAnimationSettled, waitForDataWaitfor, waitForFonts } from './print-ready';
|
|
6
|
-
import type
|
|
7
|
+
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from './sdk';
|
|
7
8
|
|
|
8
9
|
const PRINT_ROOT_ID = 'os-print-root';
|
|
9
10
|
const PRINT_STYLE_ID = 'os-print-style';
|
|
10
11
|
|
|
11
12
|
const PRINT_STYLES = `
|
|
12
|
-
@page { size:
|
|
13
|
+
@page { size: ${CANVAS_WIDTH}px ${CANVAS_HEIGHT}px; margin: 0; }
|
|
13
14
|
|
|
14
15
|
@media screen {
|
|
15
16
|
#${PRINT_ROOT_ID} {
|
|
@@ -36,8 +37,8 @@ const PRINT_STYLES = `
|
|
|
36
37
|
background: #fff !important;
|
|
37
38
|
}
|
|
38
39
|
#${PRINT_ROOT_ID} .os-print-frame {
|
|
39
|
-
width:
|
|
40
|
-
height:
|
|
40
|
+
width: ${CANVAS_WIDTH}px !important;
|
|
41
|
+
height: ${CANVAS_HEIGHT}px !important;
|
|
41
42
|
background: #fff;
|
|
42
43
|
color: #000;
|
|
43
44
|
overflow: hidden;
|
|
@@ -57,8 +58,8 @@ const PRINT_STYLES = `
|
|
|
57
58
|
composites it back to 1920×1080. Vector content (text, plain CSS
|
|
58
59
|
gradients, SVG) stays vector through both transforms. */
|
|
59
60
|
#${PRINT_ROOT_ID} .os-print-supersample {
|
|
60
|
-
width:
|
|
61
|
-
height:
|
|
61
|
+
width: ${CANVAS_WIDTH}px !important;
|
|
62
|
+
height: ${CANVAS_HEIGHT}px !important;
|
|
62
63
|
zoom: 2;
|
|
63
64
|
transform: scale(0.5);
|
|
64
65
|
transform-origin: top left;
|
|
@@ -130,15 +131,15 @@ export async function exportSlideAsPdf(
|
|
|
130
131
|
const host = document.createElement('div');
|
|
131
132
|
host.className = 'os-print-frame';
|
|
132
133
|
host.setAttribute('data-osd-canvas', '');
|
|
133
|
-
host.style.width =
|
|
134
|
-
host.style.height =
|
|
134
|
+
host.style.width = `${CANVAS_WIDTH}px`;
|
|
135
|
+
host.style.height = `${CANVAS_HEIGHT}px`;
|
|
135
136
|
if (designVars) {
|
|
136
137
|
for (const [k, v] of Object.entries(designVars)) host.style.setProperty(k, v);
|
|
137
138
|
}
|
|
138
139
|
const inner = document.createElement('div');
|
|
139
140
|
inner.className = 'os-print-supersample';
|
|
140
|
-
inner.style.width =
|
|
141
|
-
inner.style.height =
|
|
141
|
+
inner.style.width = `${CANVAS_WIDTH}px`;
|
|
142
|
+
inner.style.height = `${CANVAS_HEIGHT}px`;
|
|
142
143
|
host.appendChild(inner);
|
|
143
144
|
root.appendChild(host);
|
|
144
145
|
frames.push(host);
|
|
@@ -266,24 +267,6 @@ function splitBackgroundImageLayers(backgroundImage: string): string[] {
|
|
|
266
267
|
return layers;
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
function sleep(ms: number): Promise<void> {
|
|
270
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function nextPaint(): Promise<void> {
|
|
274
|
-
// rAF in real tabs; setTimeout fallback for hidden/throttled headless tabs.
|
|
275
|
-
return new Promise((resolve) => {
|
|
276
|
-
let settled = false;
|
|
277
|
-
const settle = () => {
|
|
278
|
-
if (settled) return;
|
|
279
|
-
settled = true;
|
|
280
|
-
resolve();
|
|
281
|
-
};
|
|
282
|
-
requestAnimationFrame(settle);
|
|
283
|
-
setTimeout(settle, 50);
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
270
|
function waitForAfterPrint(timeoutMs = 60_000): Promise<void> {
|
|
288
271
|
return new Promise((resolve) => {
|
|
289
272
|
const cleanup = () => {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createRoot, type Root } from 'react-dom/client';
|
|
3
3
|
import { designToCssVars } from './design';
|
|
4
|
+
import { downloadBlob, nextPaint, sleep } from './dom';
|
|
4
5
|
import { SlidePageProvider } from './page-context';
|
|
5
6
|
import { isFrameAnimationSettled, waitForDataWaitfor, waitForFonts } from './print-ready';
|
|
6
|
-
import type
|
|
7
|
+
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from './sdk';
|
|
7
8
|
|
|
8
|
-
const SLIDE_W = 1920;
|
|
9
|
-
const SLIDE_H = 1080;
|
|
10
9
|
// 16:9 widescreen in English Metric Units (914400 EMU per inch → 13.333in × 7.5in).
|
|
11
10
|
const EMU_W = 12192000;
|
|
12
11
|
const EMU_H = 6858000;
|
|
@@ -78,8 +77,8 @@ export async function exportSlideAsImagePptx(
|
|
|
78
77
|
if (!Page) continue;
|
|
79
78
|
const host = document.createElement('div');
|
|
80
79
|
host.setAttribute('data-osd-canvas', '');
|
|
81
|
-
host.style.width = `${
|
|
82
|
-
host.style.height = `${
|
|
80
|
+
host.style.width = `${CANVAS_WIDTH}px`;
|
|
81
|
+
host.style.height = `${CANVAS_HEIGHT}px`;
|
|
83
82
|
host.style.overflow = 'hidden';
|
|
84
83
|
host.style.background = '#fff';
|
|
85
84
|
if (designVars) {
|
|
@@ -112,8 +111,8 @@ export async function exportSlideAsImagePptx(
|
|
|
112
111
|
for (let i = 0; i < frames.length; i++) {
|
|
113
112
|
freezeForCapture(frames[i]);
|
|
114
113
|
const blob = await toBlob(frames[i], {
|
|
115
|
-
width:
|
|
116
|
-
height:
|
|
114
|
+
width: CANVAS_WIDTH,
|
|
115
|
+
height: CANVAS_HEIGHT,
|
|
117
116
|
pixelRatio: CAPTURE_PIXEL_RATIO,
|
|
118
117
|
backgroundColor: '#ffffff',
|
|
119
118
|
cacheBust: true,
|
|
@@ -253,32 +252,3 @@ function slideRelsXml(idx: number): string {
|
|
|
253
252
|
function themeXml(): string {
|
|
254
253
|
return `${XML_DECL}<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="44546A"/></a:dk2><a:lt2><a:srgbClr val="E7E6E6"/></a:lt2><a:accent1><a:srgbClr val="4472C4"/></a:accent1><a:accent2><a:srgbClr val="ED7D31"/></a:accent2><a:accent3><a:srgbClr val="A5A5A5"/></a:accent3><a:accent4><a:srgbClr val="FFC000"/></a:accent4><a:accent5><a:srgbClr val="5B9BD5"/></a:accent5><a:accent6><a:srgbClr val="70AD47"/></a:accent6><a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Calibri Light"/><a:ea typeface=""/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements></a:theme>`;
|
|
255
254
|
}
|
|
256
|
-
|
|
257
|
-
function sleep(ms: number): Promise<void> {
|
|
258
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function nextPaint(): Promise<void> {
|
|
262
|
-
return new Promise((resolve) => {
|
|
263
|
-
let settled = false;
|
|
264
|
-
const settle = () => {
|
|
265
|
-
if (settled) return;
|
|
266
|
-
settled = true;
|
|
267
|
-
resolve();
|
|
268
|
-
};
|
|
269
|
-
requestAnimationFrame(settle);
|
|
270
|
-
setTimeout(settle, 50);
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function downloadBlob(blob: Blob, filename: string): void {
|
|
275
|
-
const url = URL.createObjectURL(blob);
|
|
276
|
-
const a = document.createElement('a');
|
|
277
|
-
a.href = url;
|
|
278
|
-
a.download = filename;
|
|
279
|
-
a.rel = 'noopener';
|
|
280
|
-
document.body.appendChild(a);
|
|
281
|
-
a.click();
|
|
282
|
-
a.remove();
|
|
283
|
-
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
284
|
-
}
|