diff options
| author | Mohamed Bassem <me@mbassem.com> | 2024-12-27 16:09:29 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2024-12-27 16:09:29 +0000 |
| commit | 86d74e3f32dd5bccc8df195b55391e206df9a1c4 (patch) | |
| tree | 0db92b5139f9ef0c8909c16db72fbef782b770b6 /packages/shared | |
| parent | a23044bb74e01c861a92417c00d293ff86384e83 (diff) | |
| download | karakeep-86d74e3f32dd5bccc8df195b55391e206df9a1c4.tar.zst | |
feat: Implement highlights support for links. Fixes #620
Diffstat (limited to 'packages/shared')
| -rw-r--r-- | packages/shared/types/highlights.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/shared/types/highlights.ts b/packages/shared/types/highlights.ts new file mode 100644 index 00000000..b766c360 --- /dev/null +++ b/packages/shared/types/highlights.ts @@ -0,0 +1,31 @@ +import { z } from "zod"; + +const zHighlightColorSchema = z.enum(["yellow", "red", "green", "blue"]); +export type ZHighlightColor = z.infer<typeof zHighlightColorSchema>; +export const SUPPORTED_HIGHLIGHT_COLORS = zHighlightColorSchema.options; + +const zHighlightBaseSchema = z.object({ + bookmarkId: z.string(), + startOffset: z.number(), + endOffset: z.number(), + color: zHighlightColorSchema.default("yellow"), + text: z.string().nullable(), + note: z.string().nullable(), +}); + +export const zHighlightSchema = zHighlightBaseSchema.merge( + z.object({ + id: z.string(), + userId: z.string(), + createdAt: z.date(), + }), +); + +export type ZHighlight = z.infer<typeof zHighlightSchema>; + +export const zNewHighlightSchema = zHighlightBaseSchema; + +export const zUpdateHighlightSchema = z.object({ + highlightId: z.string(), + color: zHighlightColorSchema.optional(), +}); |
