@lemonriver/core 1.0.2 → 1.2.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-DYN-H65n.js → build-CSkdswfd.js} +1 -1
- package/dist/cli/bin.js +5 -5
- package/dist/{config-DW1wSoxa.js → config-C5-myPY6.js} +2087 -1439
- package/dist/{dev-_VDoRfAK.js → dev-DHtYH8sw.js} +2 -2
- package/dist/{mcp-CjYDzcJa.js → mcp-B2UeO1un.js} +1 -1
- package/dist/{preview-CYIGh3Z8.js → preview-C1B6-umF.js} +1 -1
- package/dist/{update-b1dSg_FW.js → update-DzL8fpcI.js} +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +5 -2
- package/release-notes.json +19 -0
- package/src/app/components/command/slide-command-menu.tsx +0 -9
- package/src/app/lemonriver/backup/client.ts +25 -1
- package/src/app/lemonriver/backup/model.ts +63 -18
- package/src/app/lemonriver/board/board-page.tsx +2 -2
- package/src/app/lemonriver/chrome/app-chrome.tsx +52 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +8 -1
- package/src/app/lemonriver/feedback/dialog.tsx +222 -0
- package/src/app/lemonriver/feedback/export.ts +21 -2
- package/src/app/lemonriver/feedback/first-success.ts +30 -0
- package/src/app/lemonriver/feedback/install.ts +18 -0
- package/src/app/lemonriver/feedback/model.ts +88 -0
- package/src/app/lemonriver/help/help-page.tsx +16 -1
- package/src/app/lemonriver/help/model.ts +1 -1
- package/src/app/lemonriver/home/drafts.ts +57 -0
- package/src/app/lemonriver/home/home-page.tsx +94 -10
- package/src/app/lemonriver/home/organize-drafts.tsx +192 -0
- package/src/app/lemonriver/links.ts +16 -0
- package/src/app/lemonriver/outline/outline-page.tsx +8 -1
- package/src/app/lemonriver/settings/backup-restore-dialog.tsx +15 -1
- package/src/app/lemonriver/settings/backup-section.tsx +159 -28
- package/src/app/lemonriver/settings/settings-page.tsx +23 -0
- package/src/app/lemonriver/settings/workspace-card.tsx +53 -0
- package/src/app/lemonriver/settings/workspace.ts +37 -0
- package/src/app/lemonriver/share/editor-share.tsx +58 -0
- package/src/app/lemonriver/share/import-dialog.tsx +14 -0
- package/src/app/lemonriver/share/naming.ts +6 -1
- package/src/app/lemonriver/share/share-dialog.tsx +2 -0
- package/src/app/lemonriver/slide-extensions.tsx +37 -53
- package/src/app/lemonriver/text/en.ts +91 -11
- package/src/app/lemonriver/text/es.ts +81 -6
- package/src/app/lemonriver/text/ja.ts +80 -6
- package/src/app/lemonriver/text/types.ts +89 -6
- package/src/app/lemonriver/text/zh-cn.ts +92 -11
- package/src/app/lemonriver/text/zh-tw.ts +92 -11
- package/src/app/lemonriver/theme/pages.ts +4 -0
- package/src/app/lemonriver/update/beta-badge.tsx +69 -0
- package/src/app/lemonriver/update/release-notes.ts +22 -0
- package/src/app/lemonriver/update/update-prompt.tsx +28 -4
- package/src/app/lib/export-html.ts +5 -3
- package/src/app/lib/export-pptx.ts +5 -4
- package/src/app/routes/slide.tsx +6 -57
- package/src/app/components/note-markdown.test.tsx +0 -42
- package/src/app/components/thumbnail-rail-scroll.test.ts +0 -60
- package/src/app/lemonriver/agent-prefs/prefs.test.ts +0 -173
- package/src/app/lemonriver/backup/guide.test.ts +0 -45
- package/src/app/lemonriver/backup/model.test.ts +0 -96
- package/src/app/lemonriver/backup/places.test.ts +0 -154
- package/src/app/lemonriver/board/blocks/classify.test.ts +0 -209
- package/src/app/lemonriver/board/layout.test.ts +0 -245
- package/src/app/lemonriver/board/model/agent-tasks.test.ts +0 -200
- package/src/app/lemonriver/board/model/apply-prompt.test.ts +0 -121
- package/src/app/lemonriver/board/model/cards.test.ts +0 -332
- package/src/app/lemonriver/board/model/changes.test.ts +0 -244
- package/src/app/lemonriver/board/model/filter.test.ts +0 -50
- package/src/app/lemonriver/board/model/history.test.ts +0 -71
- package/src/app/lemonriver/board/model/restructure.test.ts +0 -205
- package/src/app/lemonriver/board/model/self-check.test.ts +0 -329
- package/src/app/lemonriver/board/model/structure.test.ts +0 -350
- package/src/app/lemonriver/board/model/timing.test.ts +0 -113
- package/src/app/lemonriver/features.test.ts +0 -49
- package/src/app/lemonriver/feedback/pending-toast.test.ts +0 -44
- package/src/app/lemonriver/feedback/upload.test.ts +0 -26
- package/src/app/lemonriver/help/model.test.ts +0 -179
- package/src/app/lemonriver/home/brief.test.ts +0 -38
- package/src/app/lemonriver/home/sorting.test.ts +0 -24
- package/src/app/lemonriver/home/time.test.ts +0 -33
- package/src/app/lemonriver/outline/files.test.ts +0 -90
- package/src/app/lemonriver/outline/model.test.ts +0 -751
- package/src/app/lemonriver/public-links.test.ts +0 -32
- package/src/app/lemonriver/routes.test.tsx +0 -54
- package/src/app/lemonriver/share/codes.test.ts +0 -49
- package/src/app/lemonriver/share/compare.test.ts +0 -199
- package/src/app/lemonriver/share/folder.test.ts +0 -42
- package/src/app/lemonriver/share/guide.test.ts +0 -78
- package/src/app/lemonriver/share/naming.test.ts +0 -59
- package/src/app/lemonriver/share/paths.test.ts +0 -116
- package/src/app/lemonriver/share/pdf.test.ts +0 -79
- package/src/app/lemonriver/templates/knobs.test.ts +0 -62
- package/src/app/lemonriver/templates/model.test.ts +0 -175
- package/src/app/lemonriver/templates/preview-content.test.ts +0 -117
- package/src/app/lemonriver/templates/recommend.test.ts +0 -71
- package/src/app/lemonriver/text/text.test.ts +0 -90
- package/src/app/lemonriver/theme/pages.test.ts +0 -74
- package/src/app/lemonriver/theme/themes.test.ts +0 -18
- package/src/app/lemonriver/trash/api.test.ts +0 -19
- package/src/app/lemonriver/update/prompt.test.ts +0 -84
- package/src/app/lemonriver/update/version.test.ts +0 -14
- package/src/app/lib/asset-filter.test.ts +0 -176
- package/src/app/lib/inspector/fiber.test.ts +0 -154
- package/src/app/lib/inspector/geometry.test.ts +0 -324
- package/src/app/lib/inspector/text-edit-timeline.test.ts +0 -121
- package/src/app/lib/note-markdown.test.ts +0 -147
- package/src/app/lib/pptx/css.test.ts +0 -205
- package/src/app/lib/pptx/ooxml.test.ts +0 -199
- package/src/app/lib/pptx/text-lines.test.ts +0 -82
- package/src/app/lib/print-ready.test.ts +0 -32
- package/src/app/lib/sdk.test.ts +0 -13
- package/src/app/lib/transition.test.ts +0 -31
- package/src/app/lib/use-document-title.test.ts +0 -14
- package/src/app/lib/utils.test.ts +0 -49
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { Button } from '@/components/ui/button';
|
|
1
3
|
import type { Locale } from '../../../locale/types';
|
|
2
4
|
import { lrTextFor } from '../text/all';
|
|
5
|
+
import { openFeedback } from './dialog';
|
|
3
6
|
|
|
4
7
|
/** What to tell someone whose export just failed, under the official message. */
|
|
5
|
-
export function exportFailedHint(t: Locale)
|
|
6
|
-
|
|
8
|
+
export function exportFailedHint(t: Locale) {
|
|
9
|
+
const lr = lrTextFor(t.id);
|
|
10
|
+
return createElement(
|
|
11
|
+
'span',
|
|
12
|
+
{ className: 'flex flex-col items-start gap-1.5' },
|
|
13
|
+
createElement('span', null, lr.feedback.exportFailedHint),
|
|
14
|
+
createElement(
|
|
15
|
+
Button,
|
|
16
|
+
{
|
|
17
|
+
type: 'button',
|
|
18
|
+
variant: 'outline',
|
|
19
|
+
size: 'sm',
|
|
20
|
+
onClick: () => openFeedback({ category: 'issue', errorKind: 'export' }),
|
|
21
|
+
...({ 'data-lr-feedback-this': '' } as Record<string, string>),
|
|
22
|
+
},
|
|
23
|
+
lr.feedback.feedbackThis,
|
|
24
|
+
),
|
|
25
|
+
);
|
|
7
26
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const ASKED_KEY = 'lemonriver:feedback-asked';
|
|
2
|
+
|
|
3
|
+
export function feedbackAsked(): boolean {
|
|
4
|
+
try {
|
|
5
|
+
return localStorage.getItem(ASKED_KEY) === '1';
|
|
6
|
+
} catch {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function markFeedbackAsked(): void {
|
|
12
|
+
try {
|
|
13
|
+
localStorage.setItem(ASKED_KEY, '1');
|
|
14
|
+
} catch {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Listener = () => void;
|
|
18
|
+
let listener: Listener | null = null;
|
|
19
|
+
|
|
20
|
+
/** AppChrome owns the toast; everything that finishes an export just pings it. */
|
|
21
|
+
export function onFirstSuccess(notify: Listener): () => void {
|
|
22
|
+
listener = notify;
|
|
23
|
+
return () => {
|
|
24
|
+
if (listener === notify) listener = null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function noteSuccess(): void {
|
|
29
|
+
listener?.();
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { InstallKind } from './model';
|
|
2
|
+
|
|
3
|
+
export type WorkspaceSignals = { install: InstallKind; os: string | null };
|
|
4
|
+
|
|
5
|
+
/** What the dev server can tell about this machine; the browser cannot. */
|
|
6
|
+
export async function workspaceSignals(): Promise<WorkspaceSignals> {
|
|
7
|
+
try {
|
|
8
|
+
const res = await fetch('/__lr/workspace');
|
|
9
|
+
if (!res.ok) return { install: 'unknown', os: null };
|
|
10
|
+
const body = (await res.json()) as { install?: unknown; os?: unknown };
|
|
11
|
+
return {
|
|
12
|
+
install: body.install === 'app' || body.install === 'cli' ? body.install : 'unknown',
|
|
13
|
+
os: typeof body.os === 'string' && body.os !== '' ? body.os : null,
|
|
14
|
+
};
|
|
15
|
+
} catch {
|
|
16
|
+
return { install: 'unknown', os: null };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { LrPage } from '../theme/pages';
|
|
2
|
+
|
|
3
|
+
export type FeedbackCategory = 'issue' | 'idea' | 'other';
|
|
4
|
+
|
|
5
|
+
export type FeedbackErrorKind = 'export' | 'update' | 'backup';
|
|
6
|
+
|
|
7
|
+
export type InstallKind = 'app' | 'cli' | 'unknown';
|
|
8
|
+
|
|
9
|
+
export type FeedbackPageKind =
|
|
10
|
+
| 'home'
|
|
11
|
+
| 'editor'
|
|
12
|
+
| 'board'
|
|
13
|
+
| 'outline'
|
|
14
|
+
| 'settings'
|
|
15
|
+
| 'help'
|
|
16
|
+
| 'other';
|
|
17
|
+
|
|
18
|
+
export type FeedbackRequest = {
|
|
19
|
+
category?: FeedbackCategory;
|
|
20
|
+
errorKind?: FeedbackErrorKind | null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type FeedbackInput = {
|
|
24
|
+
version: string;
|
|
25
|
+
/** The macOS label read from the browser, or null when it could not be read. */
|
|
26
|
+
os: string | null;
|
|
27
|
+
install: InstallKind;
|
|
28
|
+
page: LrPage;
|
|
29
|
+
errorKind: FeedbackErrorKind | null;
|
|
30
|
+
/**
|
|
31
|
+
* Whatever the failure carried. Never written into the text: it may hold a
|
|
32
|
+
* file path or a slide title, so only the kind above reaches the copy.
|
|
33
|
+
*/
|
|
34
|
+
error?: unknown;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type FeedbackLabels = {
|
|
38
|
+
fields: { version: string; os: string; install: string; page: string; error: string };
|
|
39
|
+
separator: string;
|
|
40
|
+
unknown: string;
|
|
41
|
+
installs: Record<InstallKind, string>;
|
|
42
|
+
pages: Record<FeedbackPageKind, string>;
|
|
43
|
+
errors: Record<FeedbackErrorKind, string>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const PAGE_KINDS: Readonly<Record<string, FeedbackPageKind>> = {
|
|
47
|
+
home: 'home',
|
|
48
|
+
editor: 'editor',
|
|
49
|
+
board: 'board',
|
|
50
|
+
outline: 'outline',
|
|
51
|
+
settings: 'settings',
|
|
52
|
+
help: 'help',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export function feedbackPageKind(page: LrPage): FeedbackPageKind {
|
|
56
|
+
return PAGE_KINDS[page] ?? 'other';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The label for the version the dev server read; null drops to "unknown". */
|
|
60
|
+
export function osLabelFor(version: string | null): string | null {
|
|
61
|
+
return version === null || version === '' ? null : `macOS ${version}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The only description of a failure the feedback ever carries: which kind it
|
|
66
|
+
* was. Whatever else sits on the error (messages, paths, titles) is ignored.
|
|
67
|
+
*/
|
|
68
|
+
export function errorKindOf(errorKind: FeedbackErrorKind | null | undefined): FeedbackErrorKind {
|
|
69
|
+
return errorKind === 'update' || errorKind === 'backup' ? errorKind : 'export';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function buildFeedbackInfo(input: FeedbackInput, labels: FeedbackLabels): string {
|
|
73
|
+
const sep = labels.separator;
|
|
74
|
+
const lines = [
|
|
75
|
+
`${labels.fields.version}${sep}${input.version}`,
|
|
76
|
+
`${labels.fields.os}${sep}${input.os ?? labels.unknown}`,
|
|
77
|
+
`${labels.fields.install}${sep}${labels.installs[input.install]}`,
|
|
78
|
+
`${labels.fields.page}${sep}${labels.pages[feedbackPageKind(input.page)]}`,
|
|
79
|
+
];
|
|
80
|
+
if (input.errorKind) {
|
|
81
|
+
lines.push(`${labels.fields.error}${sep}${labels.errors[input.errorKind]}`);
|
|
82
|
+
}
|
|
83
|
+
return lines.join('\n');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function mailtoHref(email: string, subject: string, body: string): string {
|
|
87
|
+
return `mailto:${email}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
|
|
88
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Link, useLocation } from 'react-router-dom';
|
|
|
4
4
|
import { format } from '@/lib/use-locale';
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
6
|
import { markGuideSeen } from '../guide/state';
|
|
7
|
+
import { SUPPORT_URL } from '../links';
|
|
7
8
|
import { useLrText } from '../text';
|
|
8
9
|
import { useReduceMotionSetting } from '../theme/motion';
|
|
9
10
|
import {
|
|
@@ -192,6 +193,17 @@ function Index({ help }: { help: HelpContent }) {
|
|
|
192
193
|
);
|
|
193
194
|
}
|
|
194
195
|
|
|
196
|
+
/** Appends the support line to the guide's last section, only when there is somewhere to go. */
|
|
197
|
+
function withSupport(sections: HelpSection[], text: string): HelpSection[] {
|
|
198
|
+
if (SUPPORT_URL === '') return sections;
|
|
199
|
+
const lastGuide = [...sections].reverse().find((section) => section.parent === 'guide');
|
|
200
|
+
if (!lastGuide) return sections;
|
|
201
|
+
const block: HelpBlock = { kind: 'p', text: `${text} ${SUPPORT_URL}` };
|
|
202
|
+
return sections.map((section) =>
|
|
203
|
+
section === lastGuide ? { ...section, blocks: [...section.blocks, block] } : section,
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
195
207
|
export function HelpPage() {
|
|
196
208
|
const lr = useLrText();
|
|
197
209
|
const help = lr.help;
|
|
@@ -200,7 +212,10 @@ export function HelpPage() {
|
|
|
200
212
|
const [query, setQuery] = useState('');
|
|
201
213
|
const [highlight, setHighlight] = useState<string | null>(null);
|
|
202
214
|
|
|
203
|
-
const sections = useMemo(
|
|
215
|
+
const sections = useMemo(
|
|
216
|
+
() => filterHelpSections(withSupport(help.sections, lr.settings.supportText), query),
|
|
217
|
+
[help.sections, query, lr.settings.supportText],
|
|
218
|
+
);
|
|
204
219
|
const searching = query.trim() !== '';
|
|
205
220
|
|
|
206
221
|
const anchor = location.hash.replace(/^#/, '');
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Words that say what kind of thing a folder is, not which one, so they cannot
|
|
2
|
+
// be what a folder and a deck have in common.
|
|
3
|
+
const GENERIC = ['文件夹', '项目', '案例', '资料', 'project', 'projects', 'folder', 'folders'];
|
|
4
|
+
|
|
5
|
+
export function cleanedFolderName(name: string): string {
|
|
6
|
+
let out = name;
|
|
7
|
+
for (const word of GENERIC) {
|
|
8
|
+
out = out.replace(new RegExp(word, 'gi'), ' ');
|
|
9
|
+
}
|
|
10
|
+
return out.replace(/\s+/g, ' ').trim();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function chineseBigrams(text: string): string[] {
|
|
14
|
+
const runs = text.match(/[一-鿿]+/g) ?? [];
|
|
15
|
+
const grams = new Set<string>();
|
|
16
|
+
for (const run of runs) {
|
|
17
|
+
for (let i = 0; i + 2 <= run.length; i += 1) grams.add(run.slice(i, i + 2));
|
|
18
|
+
}
|
|
19
|
+
return [...grams];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function englishWords(text: string): string[] {
|
|
23
|
+
return (text.match(/[A-Za-z][A-Za-z0-9]*/g) ?? []).filter((word) => word.length >= 2);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function escapeRegExp(text: string): string {
|
|
27
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Whether the folder name and the deck title share enough to suggest the folder. */
|
|
31
|
+
export function suggestsFolder(folderName: string, deckTitle: string): boolean {
|
|
32
|
+
const cleaned = cleanedFolderName(folderName);
|
|
33
|
+
if (cleaned === '') return false;
|
|
34
|
+
const title = deckTitle.toLowerCase();
|
|
35
|
+
|
|
36
|
+
for (const gram of chineseBigrams(cleaned)) {
|
|
37
|
+
if (deckTitle.includes(gram)) return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for (const word of englishWords(cleaned)) {
|
|
41
|
+
const pattern = new RegExp(`\\b${escapeRegExp(word.toLowerCase())}\\b`);
|
|
42
|
+
if (pattern.test(title)) return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The first folder that shares a word with the deck, or "leave it in drafts". */
|
|
49
|
+
export function suggestedFolder(
|
|
50
|
+
folders: { id: string; name: string }[],
|
|
51
|
+
deckTitle: string,
|
|
52
|
+
): string | null {
|
|
53
|
+
for (const folder of folders) {
|
|
54
|
+
if (suggestsFolder(folder.name, deckTitle)) return folder.id;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChevronDown, Plus } from 'lucide-react';
|
|
2
|
-
import { type ReactNode, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Link, useNavigate, useOutletContext } from 'react-router-dom';
|
|
4
4
|
import { toast } from 'sonner';
|
|
5
5
|
import { Button } from '@/components/ui/button';
|
|
@@ -34,6 +34,7 @@ import { BriefCard } from './brief-card';
|
|
|
34
34
|
import { SearchInput, SortControl } from './controls';
|
|
35
35
|
import { DeckCard } from './deck-card';
|
|
36
36
|
import { MoveDialog, RenameDialog, TypedConfirmDialog } from './dialogs';
|
|
37
|
+
import { OrganizeDraftsDialog } from './organize-drafts';
|
|
37
38
|
import { filterDecks, sortDecks, useSortPref } from './sorting';
|
|
38
39
|
import { greetingFor } from './time';
|
|
39
40
|
import { useDeckTimes } from './use-deck-times';
|
|
@@ -77,6 +78,8 @@ export function LemonRiverHome() {
|
|
|
77
78
|
const [sharing, setSharing] = useState<{ slideId: string; title: string } | null>(null);
|
|
78
79
|
const [inspection, setInspection] = useState<InspectOk | null>(null);
|
|
79
80
|
const [inspecting, setInspecting] = useState(false);
|
|
81
|
+
const [organizing, setOrganizing] = useState(false);
|
|
82
|
+
const slidesBefore = useRef<Set<string> | null>(null);
|
|
80
83
|
|
|
81
84
|
const isAll = selectedId === ALL_SLIDES_ID;
|
|
82
85
|
const isDraft = selectedId === DRAFT_ID;
|
|
@@ -112,6 +115,44 @@ export function LemonRiverHome() {
|
|
|
112
115
|
evening: lr.home.greetingEvening,
|
|
113
116
|
}[greetingFor(new Date(now).getHours())];
|
|
114
117
|
|
|
118
|
+
const createDeckHere = async () => {
|
|
119
|
+
try {
|
|
120
|
+
const res = await fetch('/__slides', { method: 'POST' });
|
|
121
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
122
|
+
const { slideId } = (await res.json()) as { slideId?: unknown };
|
|
123
|
+
if (typeof slideId !== 'string') throw new Error('no slideId');
|
|
124
|
+
if (folder) await ctx.assign(slideId, folder.id);
|
|
125
|
+
window.location.assign(`/s/${encodeURIComponent(slideId)}`);
|
|
126
|
+
} catch {
|
|
127
|
+
toast.error(t.agent.toastCreateDeckFailed);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// A deck that first appears in the list while a folder is open (the agent
|
|
132
|
+
// just wrote it, or an import finished) belongs in that folder. A deck that
|
|
133
|
+
// was already listed and merely changed folders — moved back to drafts, say
|
|
134
|
+
// — is not new and stays where the user put it.
|
|
135
|
+
const folderId = folder?.id ?? null;
|
|
136
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new baseline per view
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
slidesBefore.current = new Set(slideIds);
|
|
139
|
+
}, [folderId]);
|
|
140
|
+
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (!folder || !slidesBefore.current) return;
|
|
143
|
+
const fresh = slideIds.filter(
|
|
144
|
+
(id) => !slidesBefore.current?.has(id) && !manifest.assignments[id],
|
|
145
|
+
);
|
|
146
|
+
if (fresh.length === 0) return;
|
|
147
|
+
for (const id of fresh) slidesBefore.current.add(id);
|
|
148
|
+
void (async () => {
|
|
149
|
+
try {
|
|
150
|
+
for (const id of fresh) await ctx.assign(id, folder.id);
|
|
151
|
+
toast.success(format(lr.home.newDeckFiled, { folder: folder.name }));
|
|
152
|
+
} catch {}
|
|
153
|
+
})();
|
|
154
|
+
}, [folder, manifest, ctx, lr.home.newDeckFiled]);
|
|
155
|
+
|
|
115
156
|
const duplicate = async (id: string) => {
|
|
116
157
|
try {
|
|
117
158
|
const copy = await ctx.duplicateSlide(id);
|
|
@@ -200,6 +241,19 @@ export function LemonRiverHome() {
|
|
|
200
241
|
</div>
|
|
201
242
|
</div>
|
|
202
243
|
|
|
244
|
+
{isDraft && (
|
|
245
|
+
<div data-lr-drafts-toolbar className="mb-4 flex flex-wrap items-center gap-3">
|
|
246
|
+
{draftSlides.length > 10 && (
|
|
247
|
+
<span data-lr-drafts-reminder className="text-[13px] text-muted-foreground">
|
|
248
|
+
{format(lr.home.draftReminder, { n: draftSlides.length })}
|
|
249
|
+
</span>
|
|
250
|
+
)}
|
|
251
|
+
<Button variant="outline" size="sm" onClick={() => setOrganizing(true)}>
|
|
252
|
+
{lr.home.organizeDrafts}
|
|
253
|
+
</Button>
|
|
254
|
+
</div>
|
|
255
|
+
)}
|
|
256
|
+
|
|
203
257
|
{!loading && library?.available === true && presentOccasions.length > 0 && (
|
|
204
258
|
<div
|
|
205
259
|
role="radiogroup"
|
|
@@ -228,7 +282,7 @@ export function LemonRiverHome() {
|
|
|
228
282
|
<GridSkeleton />
|
|
229
283
|
) : null
|
|
230
284
|
) : visible.length === 0 ? (
|
|
231
|
-
<EmptyHome isDraft={isAll || isDraft} folderName={folder?.name} />
|
|
285
|
+
<EmptyHome isDraft={isAll || isDraft} folderName={folder?.name} onCreate={createDeckHere} />
|
|
232
286
|
) : shown.length === 0 ? (
|
|
233
287
|
<LemonEmpty
|
|
234
288
|
state="thinking"
|
|
@@ -251,7 +305,9 @@ export function LemonRiverHome() {
|
|
|
251
305
|
</LemonEmpty>
|
|
252
306
|
) : (
|
|
253
307
|
<ul className="grid grid-cols-[repeat(auto-fill,minmax(230px,1fr))] gap-5">
|
|
254
|
-
{import.meta.env.DEV &&
|
|
308
|
+
{import.meta.env.DEV && !searching && (isAll || folder) && (
|
|
309
|
+
<NewDeckCard inFolder={folder !== null} onCreate={createDeckHere} />
|
|
310
|
+
)}
|
|
255
311
|
{sorted.map((id, i) => (
|
|
256
312
|
<li
|
|
257
313
|
key={id}
|
|
@@ -311,6 +367,14 @@ export function LemonRiverHome() {
|
|
|
311
367
|
setDialog(null);
|
|
312
368
|
}}
|
|
313
369
|
/>
|
|
370
|
+
<OrganizeDraftsDialog
|
|
371
|
+
open={organizing}
|
|
372
|
+
drafts={draftSlides}
|
|
373
|
+
titleOf={titleOf}
|
|
374
|
+
folders={manifest.folders}
|
|
375
|
+
onClose={() => setOrganizing(false)}
|
|
376
|
+
onAssign={ctx.assign}
|
|
377
|
+
/>
|
|
314
378
|
{shareOn && (
|
|
315
379
|
<>
|
|
316
380
|
<ShareDialog
|
|
@@ -322,7 +386,11 @@ export function LemonRiverHome() {
|
|
|
322
386
|
}}
|
|
323
387
|
/>
|
|
324
388
|
{inspection && (
|
|
325
|
-
<ImportDialog
|
|
389
|
+
<ImportDialog
|
|
390
|
+
inspection={inspection}
|
|
391
|
+
folderId={folder?.id ?? null}
|
|
392
|
+
onClose={() => setInspection(null)}
|
|
393
|
+
/>
|
|
326
394
|
)}
|
|
327
395
|
</>
|
|
328
396
|
)}
|
|
@@ -330,17 +398,18 @@ export function LemonRiverHome() {
|
|
|
330
398
|
);
|
|
331
399
|
}
|
|
332
400
|
|
|
333
|
-
function NewDeckCard() {
|
|
401
|
+
function NewDeckCard({ inFolder, onCreate }: { inFolder: boolean; onCreate: () => Promise<void> }) {
|
|
334
402
|
const lr = useLrText();
|
|
335
403
|
const navigate = useNavigate();
|
|
336
|
-
const createDeck = useCreateDeck();
|
|
337
404
|
const guide = useGuideFlags();
|
|
338
|
-
|
|
405
|
+
// The guided builder starts from the all-slides view; inside a folder the
|
|
406
|
+
// new deck goes straight into that folder instead.
|
|
407
|
+
const guided = !inFolder && guide?.guided === true && isFeatureEnabled('outline');
|
|
339
408
|
return (
|
|
340
409
|
<li>
|
|
341
410
|
<button
|
|
342
411
|
type="button"
|
|
343
|
-
onClick={() => (guided ? navigate('/new') : void
|
|
412
|
+
onClick={() => (guided ? navigate('/new') : void onCreate())}
|
|
344
413
|
className={cn(
|
|
345
414
|
'flex h-full min-h-[190px] w-full flex-col items-center justify-center gap-2 rounded-[16px]',
|
|
346
415
|
'border-[1.5px] border-dashed border-border text-[14px] font-semibold text-muted-foreground outline-none',
|
|
@@ -368,7 +437,15 @@ function GridSkeleton() {
|
|
|
368
437
|
);
|
|
369
438
|
}
|
|
370
439
|
|
|
371
|
-
function EmptyHome({
|
|
440
|
+
function EmptyHome({
|
|
441
|
+
isDraft,
|
|
442
|
+
folderName,
|
|
443
|
+
onCreate,
|
|
444
|
+
}: {
|
|
445
|
+
isDraft: boolean;
|
|
446
|
+
folderName?: string;
|
|
447
|
+
onCreate: () => Promise<void>;
|
|
448
|
+
}) {
|
|
372
449
|
const t = useLocale();
|
|
373
450
|
const lr = useLrText();
|
|
374
451
|
const { enabled, provider } = useAgentStatus();
|
|
@@ -376,7 +453,14 @@ function EmptyHome({ isDraft, folderName }: { isDraft: boolean; folderName?: str
|
|
|
376
453
|
const guide = useGuideFlags();
|
|
377
454
|
if (!isDraft) {
|
|
378
455
|
return (
|
|
379
|
-
<LemonEmpty
|
|
456
|
+
<LemonEmpty
|
|
457
|
+
title={t.home.folderEmptyTitle.replace('{name}', folderName ?? '')}
|
|
458
|
+
actions={
|
|
459
|
+
import.meta.env.DEV && (
|
|
460
|
+
<Button onClick={() => void onCreate()}>{lr.shell.newDeckCard}</Button>
|
|
461
|
+
)
|
|
462
|
+
}
|
|
463
|
+
>
|
|
380
464
|
{t.home.folderEmptyHint}
|
|
381
465
|
</LemonEmpty>
|
|
382
466
|
);
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { toast } from 'sonner';
|
|
3
|
+
import { Button } from '@/components/ui/button';
|
|
4
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
|
5
|
+
import { Input } from '@/components/ui/input';
|
|
6
|
+
import {
|
|
7
|
+
Select,
|
|
8
|
+
SelectContent,
|
|
9
|
+
SelectItem,
|
|
10
|
+
SelectTrigger,
|
|
11
|
+
SelectValue,
|
|
12
|
+
} from '@/components/ui/select';
|
|
13
|
+
import { format, plural } from '@/lib/use-locale';
|
|
14
|
+
import { useSlideModule } from '@/lib/use-slide-module';
|
|
15
|
+
import { useLrText } from '../text';
|
|
16
|
+
import { suggestedFolder } from './drafts';
|
|
17
|
+
|
|
18
|
+
const STAY = '__stay__';
|
|
19
|
+
const NEW_FOLDER = '__new__';
|
|
20
|
+
|
|
21
|
+
type Choice = string | null;
|
|
22
|
+
|
|
23
|
+
async function createFolder(name: string): Promise<{ id: string }> {
|
|
24
|
+
const res = await fetch('/__folders', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: { 'content-type': 'application/json' },
|
|
27
|
+
body: JSON.stringify({ name, icon: { type: 'color', value: '#9bc929' } }),
|
|
28
|
+
});
|
|
29
|
+
if (!res.ok) throw new Error(`POST /__folders ${res.status}`);
|
|
30
|
+
const folder = (await res.json()) as { id?: unknown };
|
|
31
|
+
if (typeof folder.id !== 'string') throw new Error('no folder id');
|
|
32
|
+
return { id: folder.id };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function DraftRow({
|
|
36
|
+
slideId,
|
|
37
|
+
title,
|
|
38
|
+
folders,
|
|
39
|
+
choice,
|
|
40
|
+
newName,
|
|
41
|
+
onChoice,
|
|
42
|
+
onNewName,
|
|
43
|
+
}: {
|
|
44
|
+
slideId: string;
|
|
45
|
+
title: string;
|
|
46
|
+
folders: { id: string; name: string }[];
|
|
47
|
+
choice: Choice;
|
|
48
|
+
newName: string;
|
|
49
|
+
onChoice: (next: string | null) => void;
|
|
50
|
+
onNewName: (next: string) => void;
|
|
51
|
+
}) {
|
|
52
|
+
const lr = useLrText();
|
|
53
|
+
const { slide } = useSlideModule(slideId);
|
|
54
|
+
const pages = slide?.default.length ?? 0;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
data-lr-organize-row
|
|
59
|
+
className="flex flex-wrap items-center gap-2 border-b border-hairline py-2.5 last:border-b-0"
|
|
60
|
+
>
|
|
61
|
+
<div className="min-w-0 flex-1">
|
|
62
|
+
<p className="truncate text-[13.5px] font-medium text-foreground">{title}</p>
|
|
63
|
+
<p className="text-[11.5px] text-muted-foreground">
|
|
64
|
+
{format(plural(pages, lr.home.pages), { n: pages })}
|
|
65
|
+
</p>
|
|
66
|
+
</div>
|
|
67
|
+
<Select
|
|
68
|
+
value={choice === null ? STAY : choice === NEW_FOLDER ? NEW_FOLDER : choice}
|
|
69
|
+
items={{
|
|
70
|
+
[STAY]: lr.home.organizeStay,
|
|
71
|
+
...Object.fromEntries(folders.map((folder) => [folder.id, folder.name])),
|
|
72
|
+
[NEW_FOLDER]: lr.home.organizeNew,
|
|
73
|
+
}}
|
|
74
|
+
onValueChange={onChoice}
|
|
75
|
+
>
|
|
76
|
+
<SelectTrigger className="w-[190px]" aria-label={title}>
|
|
77
|
+
<SelectValue />
|
|
78
|
+
</SelectTrigger>
|
|
79
|
+
<SelectContent>
|
|
80
|
+
<SelectItem value={STAY}>{lr.home.organizeStay}</SelectItem>
|
|
81
|
+
{folders.map((folder) => (
|
|
82
|
+
<SelectItem key={folder.id} value={folder.id}>
|
|
83
|
+
{folder.name}
|
|
84
|
+
</SelectItem>
|
|
85
|
+
))}
|
|
86
|
+
<SelectItem value={NEW_FOLDER}>{lr.home.organizeNew}</SelectItem>
|
|
87
|
+
</SelectContent>
|
|
88
|
+
</Select>
|
|
89
|
+
{choice === NEW_FOLDER && (
|
|
90
|
+
<Input
|
|
91
|
+
className="w-[190px]"
|
|
92
|
+
value={newName}
|
|
93
|
+
placeholder={lr.home.organizeNamePlaceholder}
|
|
94
|
+
aria-label={lr.home.organizeNamePlaceholder}
|
|
95
|
+
onChange={(event) => onNewName(event.target.value)}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function OrganizeDraftsDialog({
|
|
103
|
+
open,
|
|
104
|
+
drafts,
|
|
105
|
+
titleOf,
|
|
106
|
+
folders,
|
|
107
|
+
onClose,
|
|
108
|
+
onAssign,
|
|
109
|
+
}: {
|
|
110
|
+
open: boolean;
|
|
111
|
+
drafts: string[];
|
|
112
|
+
titleOf: (id: string) => string;
|
|
113
|
+
folders: { id: string; name: string }[];
|
|
114
|
+
onClose: () => void;
|
|
115
|
+
onAssign: (slideId: string, folderId: string | null) => Promise<void>;
|
|
116
|
+
}) {
|
|
117
|
+
const lr = useLrText();
|
|
118
|
+
const [choices, setChoices] = useState<Record<string, Choice>>({});
|
|
119
|
+
const [names, setNames] = useState<Record<string, string>>({});
|
|
120
|
+
const [busy, setBusy] = useState(false);
|
|
121
|
+
|
|
122
|
+
// Suggestions are a starting point for one visit, not something to keep
|
|
123
|
+
// refreshing while the user edits the rows.
|
|
124
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: reset on open
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!open) return;
|
|
127
|
+
setChoices(
|
|
128
|
+
Object.fromEntries(drafts.map((id) => [id, suggestedFolder(folders, titleOf(id))] as const)),
|
|
129
|
+
);
|
|
130
|
+
setNames({});
|
|
131
|
+
setBusy(false);
|
|
132
|
+
}, [open]);
|
|
133
|
+
|
|
134
|
+
const moving = drafts.filter((id) => choices[id] !== null && choices[id] !== undefined);
|
|
135
|
+
|
|
136
|
+
const move = async () => {
|
|
137
|
+
if (busy || moving.length === 0) return;
|
|
138
|
+
setBusy(true);
|
|
139
|
+
try {
|
|
140
|
+
const created = new Map<string, string>();
|
|
141
|
+
for (const id of moving) {
|
|
142
|
+
let target = choices[id] as string;
|
|
143
|
+
if (target === NEW_FOLDER) {
|
|
144
|
+
const name = (names[id] ?? '').trim() || titleOf(id);
|
|
145
|
+
const known = created.get(name) ?? folders.find((f) => f.name === name)?.id;
|
|
146
|
+
target = known ?? (await createFolder(name)).id;
|
|
147
|
+
created.set(name, target);
|
|
148
|
+
}
|
|
149
|
+
if (target !== STAY) await onAssign(id, target);
|
|
150
|
+
}
|
|
151
|
+
onClose();
|
|
152
|
+
} catch {
|
|
153
|
+
toast.error(lr.home.organizeFailed);
|
|
154
|
+
} finally {
|
|
155
|
+
setBusy(false);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<Dialog open={open} onOpenChange={(next) => !next && onClose()}>
|
|
161
|
+
<DialogContent className="sm:max-w-[560px]" data-lr-organize-dialog>
|
|
162
|
+
<DialogHeader>
|
|
163
|
+
<DialogTitle>{lr.home.organizeTitle}</DialogTitle>
|
|
164
|
+
</DialogHeader>
|
|
165
|
+
<div className="max-h-[50vh] overflow-y-auto">
|
|
166
|
+
{drafts.map((id) => (
|
|
167
|
+
<DraftRow
|
|
168
|
+
key={id}
|
|
169
|
+
slideId={id}
|
|
170
|
+
title={titleOf(id)}
|
|
171
|
+
folders={folders}
|
|
172
|
+
choice={choices[id] ?? null}
|
|
173
|
+
newName={names[id] ?? ''}
|
|
174
|
+
onChoice={(next) =>
|
|
175
|
+
setChoices((prev) => ({
|
|
176
|
+
...prev,
|
|
177
|
+
[id]: next === STAY ? null : next,
|
|
178
|
+
}))
|
|
179
|
+
}
|
|
180
|
+
onNewName={(next) => setNames((prev) => ({ ...prev, [id]: next }))}
|
|
181
|
+
/>
|
|
182
|
+
))}
|
|
183
|
+
</div>
|
|
184
|
+
<div className="flex justify-end">
|
|
185
|
+
<Button disabled={busy || moving.length === 0} onClick={() => void move()}>
|
|
186
|
+
{format(lr.home.organizeMove, { n: moving.length })}
|
|
187
|
+
</Button>
|
|
188
|
+
</div>
|
|
189
|
+
</DialogContent>
|
|
190
|
+
</Dialog>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The only place the feedback and support destinations live. Empty means the
|
|
3
|
+
* matching control stays hidden; filling it in needs no other change.
|
|
4
|
+
*
|
|
5
|
+
* Dev builds also read `window.__lrLinks` so the browser tests can try both the
|
|
6
|
+
* set and the empty state without a rebuild. Production ignores it.
|
|
7
|
+
*/
|
|
8
|
+
function link(key: 'form' | 'email' | 'support', fallback: string): string {
|
|
9
|
+
if (!import.meta.env.DEV) return fallback;
|
|
10
|
+
const overrides = (globalThis as { __lrLinks?: Record<string, string | undefined> }).__lrLinks;
|
|
11
|
+
return overrides?.[key] ?? fallback;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const FEEDBACK_FORM_URL = link('form', 'https://wj.qq.com/s2/28661011/5ixj');
|
|
15
|
+
export const FEEDBACK_EMAIL = link('email', 'lemonriver.slide@gmail.com');
|
|
16
|
+
export const SUPPORT_URL = link('support', '');
|