aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-29 20:57:31 +0000
committerMohamedBassem <me@mbassem.com>2024-03-30 02:14:59 +0000
commit177e827bf7cd74008ed73973dda5a8d4f11291cf (patch)
tree9090589906b1705f15662f03c2d5f5e0d5328830 /apps/web/components/dashboard
parent7b35e8caa313466608244f5f3f309d97bcc46dcc (diff)
downloadkarakeep-177e827bf7cd74008ed73973dda5a8d4f11291cf.tar.zst
fix(web): Disable keyboard shortcut submissions in demoMode
Diffstat (limited to 'apps/web/components/dashboard')
-rw-r--r--apps/web/components/dashboard/bookmarks/EditorCard.tsx11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsx
index 202b69ed..adada927 100644
--- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx
+++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx
@@ -4,6 +4,7 @@ import { Form, FormControl, FormField, FormItem } from "@/components/ui/form";
import { Separator } from "@/components/ui/separator";
import { Textarea } from "@/components/ui/textarea";
import { toast } from "@/components/ui/use-toast";
+import { useClientConfig } from "@/lib/clientConfig";
import { api } from "@/lib/trpc";
import { cn } from "@/lib/utils";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -11,6 +12,7 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
export default function EditorCard({ className }: { className?: string }) {
+ const demoMode = !!useClientConfig().demoMode;
const formSchema = z.object({
text: z.string(),
});
@@ -76,6 +78,9 @@ export default function EditorCard({ className }: { className?: string }) {
"Paste a link, write a note or drag and drop an image in here ..."
}
onKeyDown={(e) => {
+ if (demoMode) {
+ return;
+ }
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
form.handleSubmit(onSubmit, onError)();
}
@@ -88,7 +93,11 @@ export default function EditorCard({ className }: { className?: string }) {
}}
/>
<ActionButton loading={isPending} type="submit" variant="default">
- {form.formState.dirtyFields.text ? "Press ⌘ + Enter to Save" : "Save"}
+ {form.formState.dirtyFields.text
+ ? demoMode
+ ? "Submissions are disabled"
+ : "Press ⌘ + Enter to Save"
+ : "Save"}
</ActionButton>
</form>
</Form>