aboutsummaryrefslogtreecommitdiff
path: root/apps/web/app/components/plate-ui/code-syntax-leaf.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/app/components/plate-ui/code-syntax-leaf.tsx')
-rw-r--r--apps/web/app/components/plate-ui/code-syntax-leaf.tsx20
1 files changed, 20 insertions, 0 deletions
diff --git a/apps/web/app/components/plate-ui/code-syntax-leaf.tsx b/apps/web/app/components/plate-ui/code-syntax-leaf.tsx
new file mode 100644
index 00000000..5698f0b7
--- /dev/null
+++ b/apps/web/app/components/plate-ui/code-syntax-leaf.tsx
@@ -0,0 +1,20 @@
+'use client';
+
+
+import { withRef } from '@udecode/cn';
+import { useCodeSyntaxLeaf } from '@udecode/plate-code-block/react';
+import { PlateLeaf } from '@udecode/plate-common/react';
+
+export const CodeSyntaxLeaf = withRef<typeof PlateLeaf>(
+ ({ children, ...props }, ref) => {
+ const { leaf } = props;
+
+ const { tokenProps } = useCodeSyntaxLeaf({ leaf });
+
+ return (
+ <PlateLeaf ref={ref} {...props}>
+ <span {...tokenProps}>{children}</span>
+ </PlateLeaf>
+ );
+ }
+);