From 6c7cbf30c65160d5f97fbf77d1050cd0d7b71ab8 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Sun, 7 Apr 2024 23:31:35 +0800 Subject: [PATCH] feat: log when click type label --- src/data-types.tsx | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/data-types.tsx b/src/data-types.tsx index 2ae0ce0..41c1428 100644 --- a/src/data-types.tsx +++ b/src/data-types.tsx @@ -1,6 +1,7 @@ import { defineDataType, objectType, stringType } from "@textea/json-viewer"; import * as Y from "yjs"; import { Badge } from "./components/ui/badge"; +import { useToast } from "./components/ui/use-toast"; /** * Guess AbstractType @@ -21,8 +22,31 @@ function guessType(abstractType: Y.AbstractType) { return Y.AbstractType; } -const TypeLabel = ({ children }: { children: string }) => { - return {children}; +const TypeLabel = ({ + value, + children, +}: { + value: unknown; + children: string; +}) => { + const { toast } = useToast(); + + return ( + { + e.stopPropagation(); + console.log(value); + toast({ + duration: 2000, + description: "Check the console for the value", + }); + }} + > + {children} + + ); }; const yDocType = defineDataType({ @@ -34,7 +58,7 @@ const yDocType = defineDataType({ const ObjPreComponent = objectType.PreComponent!; return ( - YDoc  + YDoc  ); @@ -69,7 +93,7 @@ const yMapType = defineDataType({ const ObjPreComponent = objectType.PreComponent!; return ( - YMap  + YMap  ); @@ -102,7 +126,7 @@ const yArrayType = defineDataType({ const ObjPreComponent = objectType.PreComponent!; return ( - YArray  + YArray  ); @@ -129,7 +153,7 @@ const yTextType = defineDataType({ const ObjPreComponent = objectType.PreComponent!; return ( - YText  + YText  ); @@ -156,7 +180,7 @@ export const yTextStringType = defineDataType({ const ObjPreComponent = objectType.PreComponent!; return ( - YText  + YText  );