feat(collab): add shared links, chat images, and plugin fullscreen

Adds a Collab Links panel (add/pin/delete) with translations in every locale so tab and button labels are not raw i18n keys, chat image attachments (up to 4), and native fullscreen on plugin iframes. Includes Zod request DTOs and CollabPanel coverage for the Links tab.
This commit is contained in:
Godric Hood
2026-09-06 18:21:18 +01:00
committed by Maurice
parent 59a1756529
commit 9543fdc3f2
47 changed files with 743 additions and 76 deletions
+22 -2
View File
@@ -3,6 +3,8 @@ import {
collabNoteUpdateRequestSchema,
collabPollCreateRequestSchema,
collabPollVoteRequestSchema,
collabLinkCreateRequestSchema,
collabLinkUpdateRequestSchema,
collabMessageCreateRequestSchema,
collabReactionRequestSchema,
} from './collab.schema';
@@ -71,11 +73,29 @@ describe('collabPollVoteRequestSchema', () => {
});
});
describe('collabLinkCreateRequestSchema', () => {
it('requires a title and an http(s) URL', () => {
expect(collabLinkCreateRequestSchema.safeParse({ title: 'Docs', url: 'https://example.com' }).success).toBe(true);
expect(collabLinkCreateRequestSchema.safeParse({ title: 'Docs', url: 'ftp://example.com' }).success).toBe(false);
expect(collabLinkCreateRequestSchema.safeParse({ title: ' ', url: 'https://example.com' }).success).toBe(false);
expect(collabLinkCreateRequestSchema.safeParse({ title: 'Docs', url: 'not-a-url' }).success).toBe(false);
});
});
describe('collabLinkUpdateRequestSchema', () => {
it('allows partial updates and still rejects non-http URLs', () => {
expect(collabLinkUpdateRequestSchema.safeParse({ pinned: true }).success).toBe(true);
expect(collabLinkUpdateRequestSchema.safeParse({ url: 'https://example.com/x' }).success).toBe(true);
expect(collabLinkUpdateRequestSchema.safeParse({ url: 'javascript:alert(1)' }).success).toBe(false);
});
});
describe('collabMessageCreateRequestSchema', () => {
it('requires text, caps it at 5000, allows a nullable reply_to', () => {
it('caps text at 5000, allows empty text for image-only messages, and accepts multipart reply_to strings', () => {
expect(collabMessageCreateRequestSchema.safeParse({ text: 'hi', reply_to: null }).success).toBe(true);
expect(collabMessageCreateRequestSchema.safeParse({ text: 'hi', reply_to: 4 }).success).toBe(true);
expect(collabMessageCreateRequestSchema.safeParse({ text: '' }).success).toBe(false);
expect(collabMessageCreateRequestSchema.safeParse({ text: '', reply_to: '4' }).success).toBe(true);
expect(collabMessageCreateRequestSchema.safeParse({}).success).toBe(true);
expect(collabMessageCreateRequestSchema.safeParse({ text: 'x'.repeat(5001) }).success).toBe(false);
});
});
+28 -2
View File
@@ -48,9 +48,35 @@ export const collabPollVoteRequestSchema = z.object({
});
export type CollabPollVoteRequest = z.infer<typeof collabPollVoteRequestSchema>;
const httpUrl = z.string().trim().min(1).refine((value) => {
try {
const parsed = new URL(value);
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
} catch {
return false;
}
}, 'A valid http(s) URL is required');
export const collabLinkCreateRequestSchema = z.object({
title: z.string().trim().min(1),
url: httpUrl,
pinned: z.union([z.boolean(), z.number()]).optional(),
});
export type CollabLinkCreateRequest = z.infer<typeof collabLinkCreateRequestSchema>;
export const collabLinkUpdateRequestSchema = z.object({
title: z.string().trim().min(1).optional(),
url: httpUrl.optional(),
pinned: z.union([z.boolean(), z.number()]).optional(),
});
export type CollabLinkUpdateRequest = z.infer<typeof collabLinkUpdateRequestSchema>;
// text may be empty when the chat message is image-only (multipart). The
// controller still rejects a request with neither text nor files.
export const collabMessageCreateRequestSchema = z.object({
text: z.string().min(1).max(5000),
reply_to: z.number().nullable().optional(),
text: z.string().max(5000).optional(),
// Multipart fields arrive as strings; JSON chat still sends a number/null.
reply_to: z.union([z.number(), z.string(), z.null()]).optional(),
});
export type CollabMessageCreateRequest = z.infer<typeof collabMessageCreateRequestSchema>;