@open-slide/core 2.2.0 → 2.3.1
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-DTmKJyjX.js → build-8lRsgsO4.js} +1 -1
- package/dist/cli/bin.js +4 -4
- package/dist/{config-CpmGqpQi.d.ts → config-CDrYgaEj.d.ts} +6 -2
- package/dist/{config-Ces2X_3T.js → config-D2Mq1vSW.js} +2059 -354
- package/dist/{dev-ldYag-pR.js → dev-BvefEp1Q.js} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-GYMbZvvk.js → preview-D8ognobz.js} +1 -1
- package/dist/{types-CvAqFqsY.d.ts → types-DFK02XVv.d.ts} +110 -0
- package/dist/{update-CPBitJQq.js → update-BivdNgL3.js} +128 -7
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-B7_Oqv2q.js → zh-tw-B1pkKQsc.js} +535 -0
- package/package.json +12 -5
- package/src/agent/prompt.ts +141 -0
- package/src/agent/provider.ts +123 -0
- package/src/agent/types.ts +151 -0
- package/src/app/components/agent/agent-dock.tsx +35 -0
- package/src/app/components/agent/agent-markdown.tsx +45 -0
- package/src/app/components/agent/agent-panel.tsx +692 -0
- package/src/app/components/agent/agent-presence.tsx +74 -0
- package/src/app/components/agent/composer.tsx +120 -0
- package/src/app/components/agent/connect-view.tsx +184 -0
- package/src/app/components/agent/history-view.tsx +135 -0
- package/src/app/components/agent/provider-logo.tsx +34 -0
- package/src/app/components/agent/transcript.tsx +609 -0
- package/src/app/components/command/slide-command-menu.tsx +10 -0
- package/src/app/components/inspector/comment-layer.tsx +20 -1
- package/src/app/components/inspector/image-crop-dialog.tsx +1 -5
- package/src/app/components/inspector/inspector-panel.tsx +1 -1
- package/src/app/components/panel/editor-sidebar.tsx +85 -16
- package/src/app/components/panel/panel-shell.tsx +2 -2
- package/src/app/components/panel/resize-handle.tsx +129 -0
- package/src/app/components/player.tsx +0 -1
- package/src/app/lib/agent/use-agent.ts +543 -0
- package/src/app/lib/use-auto-grow.ts +15 -0
- package/src/app/lib/utils.ts +4 -0
- package/src/app/routes/home.tsx +43 -7
- package/src/app/routes/slide.tsx +103 -104
- package/src/app/styles.css +170 -0
- package/src/editing/placeholder-id.ts +1 -0
- package/src/locale/en.ts +106 -0
- package/src/locale/es.ts +108 -0
- package/src/locale/ja.ts +99 -0
- package/src/locale/types.ts +109 -0
- package/src/locale/zh-cn.ts +96 -0
- package/src/locale/zh-tw.ts +96 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SyntheticEvent, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import ReactCrop, { type Crop, type PercentCrop } from 'react-image-crop';
|
|
3
|
-
import { round2 } from '@/lib/utils';
|
|
3
|
+
import { clamp, round2 } from '@/lib/utils';
|
|
4
4
|
import 'react-image-crop/dist/ReactCrop.css';
|
|
5
5
|
import { Button } from '@/components/ui/button';
|
|
6
6
|
import {
|
|
@@ -209,7 +209,3 @@ function roundRect(crop: PercentCrop): ImageCropRect {
|
|
|
209
209
|
height: round2(crop.height),
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
function clamp(v: number, lo: number, hi: number) {
|
|
214
|
-
return v < lo ? lo : v > hi ? hi : v;
|
|
215
|
-
}
|
|
@@ -272,7 +272,7 @@ export function InspectorPanel({
|
|
|
272
272
|
if (value === 'arrange') stopInlineEdit();
|
|
273
273
|
if (value === 'format' || value === 'arrange') onTabChange(value);
|
|
274
274
|
}}
|
|
275
|
-
className="h-full shrink-0 gap-0"
|
|
275
|
+
className="h-full w-full min-w-0 shrink-0 gap-0"
|
|
276
276
|
onPointerDownCapture={(event) => {
|
|
277
277
|
if (!inlineEdit || !(event.target instanceof Element)) return;
|
|
278
278
|
const button = event.target.closest('button');
|
|
@@ -1,49 +1,118 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { type ReactNode, useState } from 'react';
|
|
2
|
+
import { AGENT_DOCK_W } from '@/components/agent/agent-dock';
|
|
2
3
|
import { InspectorPanel } from '@/components/inspector/inspector-panel';
|
|
3
4
|
import { useInspector } from '@/components/inspector/inspector-provider';
|
|
4
5
|
import { useDesignPanelState } from '@/components/style-panel/design-provider';
|
|
5
6
|
import { DesignPanel } from '@/components/style-panel/style-panel';
|
|
7
|
+
import { useLocale } from '@/lib/use-locale';
|
|
6
8
|
import { PANEL_TRANSITION_MS, PANEL_W, usePanelMount } from './panel-shell';
|
|
9
|
+
import { ResizeHandle, useStoredWidth } from './resize-handle';
|
|
7
10
|
|
|
11
|
+
type Mode = 'format' | 'design' | 'agent';
|
|
12
|
+
|
|
13
|
+
const AGENT_MIN_W = 300;
|
|
14
|
+
const EDITOR_MAX_W = 480;
|
|
15
|
+
const AGENT_MAX_W = 720;
|
|
16
|
+
|
|
17
|
+
// The agent shares this container with Format and Design so switching between
|
|
18
|
+
// them only retargets one width transition instead of collapsing one column
|
|
19
|
+
// while another grows.
|
|
8
20
|
export function EditorSidebar({
|
|
9
21
|
designOpen,
|
|
10
22
|
onCloseDesign,
|
|
23
|
+
agentOpen = false,
|
|
24
|
+
agent,
|
|
11
25
|
}: {
|
|
12
26
|
designOpen: boolean;
|
|
13
27
|
onCloseDesign: () => void;
|
|
28
|
+
agentOpen?: boolean;
|
|
29
|
+
agent?: ReactNode;
|
|
14
30
|
}) {
|
|
31
|
+
const t = useLocale();
|
|
15
32
|
const { active, panelOpen } = useInspector();
|
|
33
|
+
const [editorWidth, setEditorWidth] = useStoredWidth(
|
|
34
|
+
'open-slide:editor-panel-width',
|
|
35
|
+
PANEL_W,
|
|
36
|
+
PANEL_W,
|
|
37
|
+
EDITOR_MAX_W,
|
|
38
|
+
);
|
|
39
|
+
const [agentWidth, setAgentWidth] = useStoredWidth(
|
|
40
|
+
'open-slide:agent-panel-width',
|
|
41
|
+
AGENT_DOCK_W,
|
|
42
|
+
AGENT_MIN_W,
|
|
43
|
+
AGENT_MAX_W,
|
|
44
|
+
);
|
|
45
|
+
const [resizing, setResizing] = useState(false);
|
|
16
46
|
const { loaded, draft } = useDesignPanelState();
|
|
17
47
|
const [preferredTab, setPreferredTab] = useState<'format' | 'arrange'>('format');
|
|
18
|
-
const mode =
|
|
19
|
-
|
|
20
|
-
? '
|
|
21
|
-
:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
48
|
+
const mode: Mode | null =
|
|
49
|
+
agentOpen && agent
|
|
50
|
+
? 'agent'
|
|
51
|
+
: designOpen
|
|
52
|
+
? loaded && draft
|
|
53
|
+
? 'design'
|
|
54
|
+
: null
|
|
55
|
+
: active && panelOpen
|
|
56
|
+
? 'format'
|
|
57
|
+
: null;
|
|
58
|
+
const [lastMode, setLastMode] = useState<Mode>('format');
|
|
26
59
|
if (mode && mode !== lastMode) setLastMode(mode);
|
|
60
|
+
const shown = mode ?? lastMode;
|
|
61
|
+
const isAgent = shown === 'agent';
|
|
62
|
+
const [lastEditor, setLastEditor] = useState<'format' | 'design'>('format');
|
|
63
|
+
if (!isAgent && shown !== lastEditor) setLastEditor(shown);
|
|
64
|
+
const [agentMounted, setAgentMounted] = useState(false);
|
|
65
|
+
if (isAgent && !agentMounted) setAgentMounted(true);
|
|
27
66
|
const open = mode !== null;
|
|
28
67
|
const { mounted, animVisible } = usePanelMount(open);
|
|
29
68
|
|
|
30
69
|
if (!mounted) return null;
|
|
31
70
|
|
|
71
|
+
const width = isAgent ? agentWidth : editorWidth;
|
|
72
|
+
|
|
32
73
|
return (
|
|
33
74
|
<div
|
|
34
75
|
data-editor-sidebar
|
|
76
|
+
data-agent-dock={isAgent ? '' : undefined}
|
|
35
77
|
inert={!open}
|
|
36
78
|
aria-hidden={!open}
|
|
37
|
-
className="flex h-full max-h-1/2 shrink-0 justify-end overflow-hidden bg-sidebar transition-[width] ease-swift motion-reduce:transition-none md:max-h-none"
|
|
79
|
+
className="relative flex h-full max-h-1/2 shrink-0 justify-end overflow-hidden bg-sidebar transition-[width] ease-swift motion-reduce:transition-none md:max-h-none"
|
|
38
80
|
style={{
|
|
39
|
-
width: animVisible ?
|
|
40
|
-
transitionDuration: `${PANEL_TRANSITION_MS}ms`,
|
|
81
|
+
width: animVisible ? width : 0,
|
|
82
|
+
transitionDuration: resizing ? '0ms' : `${PANEL_TRANSITION_MS}ms`,
|
|
41
83
|
}}
|
|
42
84
|
>
|
|
43
|
-
{
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
85
|
+
{open && (
|
|
86
|
+
<ResizeHandle
|
|
87
|
+
key={isAgent ? 'agent' : 'editor'}
|
|
88
|
+
width={width}
|
|
89
|
+
min={isAgent ? AGENT_MIN_W : PANEL_W}
|
|
90
|
+
max={isAgent ? AGENT_MAX_W : EDITOR_MAX_W}
|
|
91
|
+
defaultWidth={isAgent ? AGENT_DOCK_W : PANEL_W}
|
|
92
|
+
edge="left"
|
|
93
|
+
label={t.slide.resizeSidePanel}
|
|
94
|
+
onResize={isAgent ? setAgentWidth : setEditorWidth}
|
|
95
|
+
onResizingChange={setResizing}
|
|
96
|
+
className="left-0 hidden md:block"
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
{agentMounted && (
|
|
100
|
+
<div
|
|
101
|
+
className="sidebar-swap h-full shrink-0"
|
|
102
|
+
style={{ width: agentWidth }}
|
|
103
|
+
hidden={!isAgent}
|
|
104
|
+
>
|
|
105
|
+
{agent}
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
{!isAgent && (
|
|
109
|
+
<div className="sidebar-swap flex h-full shrink-0" style={{ width: editorWidth }}>
|
|
110
|
+
{lastEditor === 'design' ? (
|
|
111
|
+
<DesignPanel onClose={onCloseDesign} />
|
|
112
|
+
) : (
|
|
113
|
+
<InspectorPanel preferredTab={preferredTab} onTabChange={setPreferredTab} />
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
47
116
|
)}
|
|
48
117
|
</div>
|
|
49
118
|
);
|
|
@@ -45,8 +45,8 @@ type PanelShellProps = {
|
|
|
45
45
|
export function PanelShell({ uiAttr, header, banner, footer, children }: PanelShellProps) {
|
|
46
46
|
const dataAttrs = uiAttr === 'inspector' ? { 'data-inspector-ui': '' } : { 'data-design-ui': '' };
|
|
47
47
|
return (
|
|
48
|
-
<aside {...dataAttrs} className="flex h-full
|
|
49
|
-
<div
|
|
48
|
+
<aside {...dataAttrs} className="flex h-full w-full min-w-0 bg-sidebar">
|
|
49
|
+
<div className="flex h-full w-full min-w-0 flex-col">
|
|
50
50
|
<header className="flex h-9 shrink-0 items-center justify-between gap-2 border-b border-hairline px-3">
|
|
51
51
|
{header}
|
|
52
52
|
</header>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { clamp, cn } from '@/lib/utils';
|
|
3
|
+
|
|
4
|
+
export function useStoredWidth(key: string, fallback: number, min: number, max: number) {
|
|
5
|
+
const [width, setWidth] = useState<number>(() => {
|
|
6
|
+
try {
|
|
7
|
+
const parsed = Number(window.localStorage.getItem(key) ?? Number.NaN);
|
|
8
|
+
return Number.isFinite(parsed) ? clamp(parsed, min, max) : fallback;
|
|
9
|
+
} catch {
|
|
10
|
+
return fallback;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
try {
|
|
15
|
+
window.localStorage.setItem(key, String(width));
|
|
16
|
+
} catch {}
|
|
17
|
+
}, [key, width]);
|
|
18
|
+
return [width, setWidth] as const;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// A vertical splitter on one edge of a panel. `edge` is the side of the panel
|
|
22
|
+
// it sits on, so dragging away from the panel always makes it wider.
|
|
23
|
+
export function ResizeHandle({
|
|
24
|
+
width,
|
|
25
|
+
min,
|
|
26
|
+
max,
|
|
27
|
+
defaultWidth,
|
|
28
|
+
edge,
|
|
29
|
+
label,
|
|
30
|
+
onResize,
|
|
31
|
+
onResizingChange,
|
|
32
|
+
className,
|
|
33
|
+
}: {
|
|
34
|
+
width: number;
|
|
35
|
+
min: number;
|
|
36
|
+
max: number;
|
|
37
|
+
defaultWidth: number;
|
|
38
|
+
edge: 'left' | 'right';
|
|
39
|
+
label: string;
|
|
40
|
+
onResize: (width: number) => void;
|
|
41
|
+
onResizingChange?: (resizing: boolean) => void;
|
|
42
|
+
className?: string;
|
|
43
|
+
}) {
|
|
44
|
+
const [resizing, setResizing] = useState(false);
|
|
45
|
+
const dragRef = useRef<{ startX: number; startWidth: number } | null>(null);
|
|
46
|
+
const direction = edge === 'right' ? 1 : -1;
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
onResizingChange?.(resizing);
|
|
50
|
+
if (!resizing) return;
|
|
51
|
+
const prev = {
|
|
52
|
+
cursor: document.body.style.cursor,
|
|
53
|
+
userSelect: document.body.style.userSelect,
|
|
54
|
+
};
|
|
55
|
+
document.body.style.cursor = 'col-resize';
|
|
56
|
+
document.body.style.userSelect = 'none';
|
|
57
|
+
return () => {
|
|
58
|
+
document.body.style.cursor = prev.cursor;
|
|
59
|
+
document.body.style.userSelect = prev.userSelect;
|
|
60
|
+
};
|
|
61
|
+
}, [resizing, onResizingChange]);
|
|
62
|
+
|
|
63
|
+
const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
66
|
+
dragRef.current = { startX: e.clientX, startWidth: width };
|
|
67
|
+
setResizing(true);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
71
|
+
if (!dragRef.current) return;
|
|
72
|
+
const delta = (e.clientX - dragRef.current.startX) * direction;
|
|
73
|
+
onResize(clamp(dragRef.current.startWidth + delta, min, max));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const onPointerUp = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
77
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
78
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
79
|
+
}
|
|
80
|
+
dragRef.current = null;
|
|
81
|
+
setResizing(false);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
85
|
+
const step = (e.shiftKey ? 32 : 8) * direction;
|
|
86
|
+
let next: number | null = null;
|
|
87
|
+
if (e.key === 'ArrowLeft') next = width - step;
|
|
88
|
+
else if (e.key === 'ArrowRight') next = width + step;
|
|
89
|
+
else if (e.key === 'Home') next = defaultWidth;
|
|
90
|
+
if (next === null) return;
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
onResize(clamp(next, min, max));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
// biome-ignore lint/a11y/useSemanticElements: focusable resize handle (splitter pattern), not a static <hr>
|
|
98
|
+
<div
|
|
99
|
+
role="separator"
|
|
100
|
+
aria-orientation="vertical"
|
|
101
|
+
aria-label={label}
|
|
102
|
+
aria-valuenow={width}
|
|
103
|
+
aria-valuemin={min}
|
|
104
|
+
aria-valuemax={max}
|
|
105
|
+
tabIndex={0}
|
|
106
|
+
onPointerDown={onPointerDown}
|
|
107
|
+
onPointerMove={onPointerMove}
|
|
108
|
+
onPointerUp={onPointerUp}
|
|
109
|
+
onPointerCancel={onPointerUp}
|
|
110
|
+
onKeyDown={onKeyDown}
|
|
111
|
+
onDoubleClick={() => onResize(defaultWidth)}
|
|
112
|
+
className={cn(
|
|
113
|
+
'group/resize absolute inset-y-0 z-20 w-1.5 cursor-col-resize touch-none outline-none',
|
|
114
|
+
'focus-visible:bg-brand/20',
|
|
115
|
+
className,
|
|
116
|
+
)}
|
|
117
|
+
>
|
|
118
|
+
<span
|
|
119
|
+
aria-hidden
|
|
120
|
+
className={cn(
|
|
121
|
+
'pointer-events-none absolute inset-y-0 w-px bg-brand opacity-0 transition-opacity duration-150',
|
|
122
|
+
edge === 'right' ? 'left-1/2 -translate-x-1/2' : 'left-0',
|
|
123
|
+
'group-hover/resize:opacity-100 group-focus-visible/resize:opacity-100',
|
|
124
|
+
resizing && 'opacity-100',
|
|
125
|
+
)}
|
|
126
|
+
/>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
@@ -402,7 +402,6 @@ export function Player({
|
|
|
402
402
|
controls && 'select-none',
|
|
403
403
|
controls && (hideCursor ? 'cursor-none' : 'cursor-default'),
|
|
404
404
|
)}
|
|
405
|
-
style={design ? { background: design.palette.bg } : undefined}
|
|
406
405
|
>
|
|
407
406
|
<SlideCanvas flat design={design}>
|
|
408
407
|
{/* Keyed per deck so a presenter-driven deck switch cuts instead of
|