Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(web): optimize table form collection copy, icon, and public form layout

tianma-ifd6fab260117c
diff --git a/apps/mobile/src/screens/WorkspaceRevisionHistory.tsx b/apps/mobile/src/screens/WorkspaceRevisionHistory.tsx
index 2174a030..e6a8e3ab 100644
--- a/apps/mobile/src/screens/WorkspaceRevisionHistory.tsx
+++ b/apps/mobile/src/screens/WorkspaceRevisionHistory.tsx
@@ -178,7 +178,7 @@ export const RevisionHistoryModal = ({
>
<Text style={[styles.revisionPillTitle, selectedRevision?.id === revision.id && styles.revisionPillTitleActive]}>{`版本 ${revision.revision}`}</Text>
<Text style={[styles.revisionPillMeta, selectedRevision?.id === revision.id && styles.revisionPillTitleActive]}>
- {formatDate(revision.createdAt, localePreference)} · {revision.createdBy === "table-form" ? "表单录入" : formatRevisionActor(revision.createdBy)}
+ {formatDate(revision.createdAt, localePreference)} · {revision.createdBy === "table-form" ? "表单提交" : formatRevisionActor(revision.createdBy)}
</Text>
</Pressable>
))}
diff --git a/apps/web/src/components/PublicTableFormPage.tsx b/apps/web/src/components/PublicTableFormPage.tsx
index 4d6e9328..5a00bcf0 100644
--- a/apps/web/src/components/PublicTableFormPage.tsx
+++ b/apps/web/src/components/PublicTableFormPage.tsx
@@ -1,5 +1,5 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
-import { LoaderCircle } from "lucide-react";
+import { Check, LoaderCircle } from "lucide-react";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useParams } from "react-router";
@@ -101,103 +101,136 @@ export const PublicTableFormPage = () => {
}
if (form.passwordRequired) {
return (
- <main className="mx-auto flex min-h-screen w-full max-w-md flex-col justify-center gap-4 px-6">
- <h1 className="text-xl font-semibold">{t("structuredTable.form.passwordRequired")}</h1>
- <Input
- type="password"
- value={password}
- autoComplete="off"
- aria-label={t("structuredTable.form.password")}
- onChange={(event) => setPassword(event.target.value)}
- />
- {error ? <p className="text-sm text-rose-600">{error}</p> : null}
- <Button type="button" disabled={!password || unlockMutation.isPending} onClick={() => unlockMutation.mutate()}>
- {t("structuredTable.form.unlock")}
- </Button>
- </main>
+ <div className="flex min-h-[100dvh] items-center justify-center bg-slate-50/60 px-4">
+ <main className="w-full max-w-md rounded-2xl border border-slate-200/80 bg-card p-8 shadow-sm space-y-4">
+ <h1 className="text-xl font-semibold text-slate-900">{t("structuredTable.form.passwordRequired")}</h1>
+ <Input
+ type="password"
+ value={password}
+ autoComplete="off"
+ aria-label={t("structuredTable.form.password")}
+ onChange={(event) => setPassword(event.target.value)}
+ />
+ {error ? <p className="text-sm text-rose-600">{error}</p> : null}
+ <Button
+ type="button"
+ variant="solid"
+ className="w-full font-medium shadow-sm"
+ disabled={!password || unlockMutation.isPending}
+ onClick={() => unlockMutation.mutate()}
+ >
+ {t("structuredTable.form.unlock")}
+ </Button>
+ </main>
+ </div>
);
}
if (done) {
return (
- <main className="mx-auto flex min-h-screen w-full max-w-md flex-col justify-center gap-4 px-6">
- <h1 className="text-xl font-semibold">{t("structuredTable.form.submitted")}</h1>
- <Button type="button" variant="outline" onClick={() => { setDone(false); setValues(Object.fromEntries(form.fields.map((field) => [field.id, emptyValue(field)]))); }}>
- {t("structuredTable.form.submitAnother")}
- </Button>
- </main>
+ <div className="flex min-h-[100dvh] items-center justify-center bg-slate-50/60 px-4">
+ <main className="w-full max-w-md rounded-2xl border border-slate-200/80 bg-card p-8 shadow-sm space-y-5 text-center">
+ <div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-emerald-50 text-emerald-600">
+ <Check className="h-6 w-6" />
+ </div>
+ <h1 className="text-xl font-semibold text-slate-900">{t("structuredTable.form.submitted")}</h1>
+ <Button
+ type="button"
+ variant="outline"
+ className="w-full sm:w-auto"
+ onClick={() => {
+ setDone(false);
+ setValues(Object.fromEntries(form.fields.map((field) => [field.id, emptyValue(field)])));
+ }}
+ >
+ {t("structuredTable.form.submitAnother")}
+ </Button>
+ </main>
+ </div>
);
}
return (
- <main className="mx-auto flex min-h-screen w-full max-w-lg flex-col gap-5 px-6 py-10">
- <header className="space-y-2">
- <h1 className="text-2xl font-semibold text-slate-950">{form.title || t("structuredTable.form.title")}</h1>
- {form.description ? <p className="text-sm text-slate-600">{form.description}</p> : null}
- </header>
- {form.full ? <p className="text-sm text-slate-600">{t("structuredTable.form.full")}</p> : null}
- <form
- className="space-y-4"
- onSubmit={(event) => {
- event.preventDefault();
- if (!form.full) submitMutation.mutate(submissionCells(form, values));
- }}
- >
- {form.fields.map((field) => {
- const value = values[field.id] ?? emptyValue(field);
- const label = field.required ? `${field.name} *` : field.name;
- return (
- <label key={field.id} className="block space-y-1 text-sm">
- <span className="font-medium text-slate-800">{label}</span>
- {field.type === "checkbox" ? (
- <input
- type="checkbox"
- className="h-4 w-4"
- checked={value === true}
- aria-label={field.name}
- onChange={(event) => setValues((current) => ({ ...current, [field.id]: event.target.checked }))}
- />
- ) : field.type === "select" ? (
- <select
- className="h-10 w-full rounded-md border border-slate-200 px-3"
- value={typeof value === "string" ? value : ""}
- required={field.required}
- aria-label={field.name}
- onChange={(event) => setValues((current) => ({ ...current, [field.id]: event.target.value }))}
- >
- <option value="" />
- {(field.options ?? []).map((option) => <option key={option} value={option}>{option}</option>)}
- </select>
- ) : field.type === "attachment" ? (
- <div className="space-y-1">
- {Array.isArray(value) ? value.map((file) => (
- <p key={file.id} className="truncate text-slate-600">{file.filename}</p>
- )) : null}
- <input
- type="file"
- multiple
+ <div className="min-h-screen bg-slate-50/60 py-8 px-4 sm:px-6">
+ <main className="mx-auto w-full max-w-xl rounded-2xl border border-slate-200/80 bg-card p-6 sm:p-8 shadow-sm">
+ <header className="space-y-2 pb-5 border-b border-slate-100">
+ <h1 className="text-2xl font-semibold text-slate-950">{form.title || t("structuredTable.form.title")}</h1>
+ {form.description ? <p className="text-sm text-slate-600 leading-relaxed">{form.description}</p> : null}
+ </header>
+ {form.full ? <p className="mt-4 text-sm font-medium text-amber-600">{t("structuredTable.form.full")}</p> : null}
+ <form
+ className="mt-6 space-y-4"
+ onSubmit={(event) => {
+ event.preventDefault();
+ if (!form.full) submitMutation.mutate(submissionCells(form, values));
+ }}
+ >
+ {form.fields.map((field) => {
+ const value = values[field.id] ?? emptyValue(field);
+ const label = field.required ? `${field.name} *` : field.name;
+ return (
+ <label key={field.id} className="block space-y-1.5 text-sm">
+ <span className="font-medium text-slate-800">{label}</span>
+ {field.type === "checkbox" ? (
+ <div className="pt-0.5">
+ <input
+ type="checkbox"
+ className="h-4 w-4 rounded border-slate-300 text-emerald-600 focus:ring-emerald-500/70"
+ checked={value === true}
+ aria-label={field.name}
+ onChange={(event) => setValues((current) => ({ ...current, [field.id]: event.target.checked }))}
+ />
+ </div>
+ ) : field.type === "select" ? (
+ <select
+ className="h-10 w-full rounded-md border border-slate-200 bg-card px-3 text-slate-900 outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/70"
+ value={typeof value === "string" ? value : ""}
+ required={field.required}
aria-label={field.name}
- disabled={uploading === field.id}
- onChange={(event) => { void upload(field.id, event.target.files); event.target.value = ""; }}
+ onChange={(event) => setValues((current) => ({ ...current, [field.id]: event.target.value }))}
+ >
+ <option value="" />
+ {(field.options ?? []).map((option) => <option key={option} value={option}>{option}</option>)}
+ </select>
+ ) : field.type === "attachment" ? (
+ <div className="space-y-1">
+ {Array.isArray(value) ? value.map((file) => (
+ <p key={file.id} className="truncate text-slate-600">{file.filename}</p>
+ )) : null}
+ <input
+ type="file"
+ multiple
+ aria-label={field.name}
+ disabled={uploading === field.id}
+ onChange={(event) => { void upload(field.id, event.target.files); event.target.value = ""; }}
+ />
+ <p className="text-xs text-slate-500">{uploading === field.id ? t("structuredTable.uploading") : t("structuredTable.form.uploadLimit")}</p>
+ </div>
+ ) : (
+ <Input
+ type={field.type === "number" ? "number" : field.type === "date" ? "date" : field.type === "url" ? "url" : "text"}
+ value={typeof value === "string" || typeof value === "number" ? String(value) : ""}
+ required={field.required}
+ aria-label={field.name}
+ onChange={(event) => setValues((current) => ({ ...current, [field.id]: field.type === "number" ? event.target.value : event.target.value }))}
/>
- <p className="text-xs text-slate-500">{uploading === field.id ? t("structuredTable.uploading") : t("structuredTable.form.uploadLimit")}</p>
- </div>
- ) : (
- <Input
- type={field.type === "number" ? "number" : field.type === "date" ? "date" : field.type === "url" ? "url" : "text"}
- value={typeof value === "string" || typeof value === "number" ? String(value) : ""}
- required={field.required}
- aria-label={field.name}
- onChange={(event) => setValues((current) => ({ ...current, [field.id]: field.type === "number" ? event.target.value : event.target.value }))}
- />
- )}
- </label>
- );
- })}
- {error ? <p className="text-sm text-rose-600">{error}</p> : null}
- <Button type="submit" disabled={form.full || submitMutation.isPending || Boolean(uploading)}>
- {submitMutation.isPending ? t("structuredTable.form.saving") : form.submitLabel || t("structuredTable.form.submitDefault")}
- </Button>
- </form>
- </main>
+ )}
+ </label>
+ );
+ })}
+ {error ? <p className="text-sm text-rose-600">{error}</p> : null}
+ <div className="pt-2">
+ <Button
+ type="submit"
+ variant="solid"
+ size="default"
+ className="w-full sm:w-auto min-w-[120px] font-medium shadow-sm"
+ disabled={form.full || submitMutation.isPending || Boolean(uploading)}
+ >
+ {submitMutation.isPending ? t("structuredTable.form.saving") : form.submitLabel || t("structuredTable.form.submitDefault")}
+ </Button>
+ </div>
+ </form>
+ </main>
+ </div>
);
};
diff --git a/apps/web/src/components/TableEditorPane.tsx b/apps/web/src/components/TableEditorPane.tsx
index 5d586e87..ce9bd6fc 100644
--- a/apps/web/src/components/TableEditorPane.tsx
+++ b/apps/web/src/components/TableEditorPane.tsx
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { flexRender, getCoreRowModel, useReactTable, type ColumnDef } from "@tanstack/react-table";
-import { ChevronLeft, ClipboardList, Download, Paperclip, Plus, TableProperties, Trash2, X } from "lucide-react";
+import { ChevronLeft, Download, Form, Paperclip, Plus, TableProperties, Trash2, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import {
addTableField,
@@ -638,10 +638,15 @@ export const TableEditorPane = ({
</div>
<span className="text-xs text-slate-500">{countLabel}</span>
{saveLabel ? <span className={saveError ? "text-xs text-rose-600" : "text-xs text-slate-400"}>{saveLabel}</span> : null}
- <Button type="button" variant="outline" size="sm" disabled={readOnly} onClick={() => setFormOpen(true)}>
- <ClipboardList className="h-4 w-4" />
- {t("structuredTable.openForm")}
- </Button>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button type="button" variant="outline" size="sm" disabled={readOnly} onClick={() => setFormOpen(true)}>
+ <Form className="h-4 w-4" />
+ {t("structuredTable.openForm")}
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>{t("structuredTable.openFormTooltip")}</TooltipContent>
+ </Tooltip>
<Button type="button" variant="outline" size="sm" onClick={exportCsv}>
<Download className="h-4 w-4" />
{t("structuredTable.exportCsv")}
diff --git a/apps/web/src/components/dialogs/TableFormDialog.tsx b/apps/web/src/components/dialogs/TableFormDialog.tsx
index c3597f82..61c9ebd8 100644
--- a/apps/web/src/components/dialogs/TableFormDialog.tsx
+++ b/apps/web/src/components/dialogs/TableFormDialog.tsx
@@ -1,5 +1,5 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
-import { Check, ClipboardList, Copy } from "lucide-react";
+import { Check, Copy, Form } from "lucide-react";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import type { TableField, TableFormFieldSetting, TableFormUpdateInput } from "@edgeever/shared";
@@ -225,7 +225,7 @@ export const TableFormDialog = ({
{error ? <p className="text-sm text-rose-600">{error}</p> : null}
{saveMutation.isSuccess && !error ? <p className="text-sm text-emerald-700">{t("structuredTable.form.saved")}</p> : null}
<Button type="button" onClick={() => save(false)} disabled={saveMutation.isPending || formQuery.isLoading}>
- <ClipboardList className="h-4 w-4" />
+ <Form className="h-4 w-4" />
{saveMutation.isPending ? t("structuredTable.form.saving") : t("structuredTable.form.save")}
</Button>
</DialogContent>
diff --git a/apps/web/src/components/ui/button.tsx b/apps/web/src/components/ui/button.tsx
index 7b86db83..ff947b37 100644
--- a/apps/web/src/components/ui/button.tsx
+++ b/apps/web/src/components/ui/button.tsx
@@ -13,7 +13,7 @@ const buttonVariants = cva(
variants: {
variant: {
solid: "bg-emerald-500 text-white hover:bg-emerald-600 border-emerald-500",
- soft: "bg-slate-50 text-slate-700 hover:bg-slate-100 border-slate-200",
+ soft: "bg-slate-50 text-slate-700 hover:bg-slate-100 border border-slate-200",
ghost: "bg-transparent text-slate-600 hover:bg-slate-50 hover:text-slate-900 border-transparent",
outline: "bg-card text-slate-700 hover:bg-slate-50 border border-slate-200",
danger: "bg-rose-50 text-rose-700 hover:bg-rose-100 border border-rose-100",
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 0deaf17e..9271d62f 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -311,10 +311,11 @@ export const enUS = {
unsaved: "Unsaved changes",
back: "Back to note list",
editField: "Edit field {{name}}",
- openForm: "Form",
+ openForm: "Form Collection",
+ openFormTooltip: "Share a form link to collect responses as table records.",
form: {
- title: "Form",
- description: "Share this link so someone can add one row. They cannot see existing rows.",
+ title: "Form Collection",
+ description: "Share a form link for others to fill out. Submissions are added as new table records, and respondents cannot view existing rows.",
enabled: "Accept responses",
link: "Form link",
copy: "Copy link",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index 36f723f0..66a1d1ec 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -311,10 +311,11 @@ export const ja = {
unsaved: "未保存の変更",
back: "ノート一覧に戻る",
editField: "フィールド {{name}} を編集",
- openForm: "フォーム",
+ openForm: "フォーム収集",
+ openFormTooltip: "フォームのリンクを共有して回答を収集し、自動的にテーブルレコードとして追加します。",
form: {
- title: "フォーム入力",
- description: "このリンクを共有すると、相手は1行だけ追加できます。既存の行は見えません。",
+ title: "フォーム収集",
+ description: "フォームのリンクを共有して回答してもらうと、提出内容が新しい行として自動追加されます。回答者は既存のデータを閲覧できません。",
enabled: "回答を受け付ける",
link: "フォームのリンク",
copy: "リンクをコピー",
@@ -1705,7 +1706,7 @@ export const ja = {
restoreConfirmTitle: "この履歴の版を復元",
restoreConfirmDescription: "現在の内容はこの履歴の版で置き換えられます。復元後も新しい版は作成されます。",
restoreConfirmLabel: "復元",
- formActor: "フォーム入力",
+ formActor: "フォーム送信",
},
pdfViewer: {
loading: "PDF を読み込み中…",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 960f4aad..1c3b4efb 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -311,10 +311,11 @@ export const zhCN = {
unsaved: "有未保存的修改",
back: "返回笔记列表",
editField: "编辑字段 {{name}}",
- openForm: "表单录入",
+ openForm: "表单收集",
+ openFormTooltip: "分享表单链接收集填写,提交后自动沉淀为表格记录",
form: {
- title: "表单录入",
- description: "把链接发给别人,对方只能填写并提交一行,看不到表里已有的记录。",
+ title: "表单收集",
+ description: "分享表单链接给他人填写,提交内容会自动追加为一条新记录,填写人无法查看已有数据。",
enabled: "接受填写",
link: "表单链接",
copy: "复制链接",
@@ -1705,7 +1706,7 @@ export const zhCN = {
restoreConfirmTitle: "恢复到这个历史版本",
restoreConfirmDescription: "当前内容会被这个历史版本替换,恢复后仍会产生新的历史记录。",
restoreConfirmLabel: "恢复",
- formActor: "表单录入",
+ formActor: "表单提交",
},
pdfViewer: {
loading: "正在加载 PDF…",