2026-03-03 08:45:26 -06:00
|
|
|
import type { AssetImage } from "@paperclipai/shared";
|
Add MarkdownEditor component, asset image upload, and rich description editing
Introduce MarkdownEditor built on @mdxeditor/editor with headings,
lists, links, quotes, image upload with drag-and-drop, and themed CSS
integration. Add asset image upload API (routes, service, storage) and
wire image upload into InlineEditor multiline mode, NewIssueDialog,
NewProjectDialog, GoalDetail, IssueDetail, and ProjectDetail
description fields. Tighten prompt template editor styling.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 12:50:45 -06:00
|
|
|
import { api } from "./client";
|
|
|
|
|
|
|
|
|
|
export const assetsApi = {
|
2026-02-23 15:21:04 -06:00
|
|
|
uploadImage: async (companyId: string, file: File, namespace?: string) => {
|
|
|
|
|
// Read file data into memory eagerly so the fetch body is self-contained.
|
|
|
|
|
// Clipboard-paste File objects reference transient data that the browser may
|
|
|
|
|
// discard after the paste-event handler returns, causing ERR_ACCESS_DENIED
|
|
|
|
|
// when fetch() later tries to stream the FormData body.
|
|
|
|
|
const buffer = await file.arrayBuffer();
|
|
|
|
|
const safeFile = new File([buffer], file.name, { type: file.type });
|
|
|
|
|
|
Add MarkdownEditor component, asset image upload, and rich description editing
Introduce MarkdownEditor built on @mdxeditor/editor with headings,
lists, links, quotes, image upload with drag-and-drop, and themed CSS
integration. Add asset image upload API (routes, service, storage) and
wire image upload into InlineEditor multiline mode, NewIssueDialog,
NewProjectDialog, GoalDetail, IssueDetail, and ProjectDetail
description fields. Tighten prompt template editor styling.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 12:50:45 -06:00
|
|
|
const form = new FormData();
|
|
|
|
|
if (namespace && namespace.trim().length > 0) {
|
|
|
|
|
form.append("namespace", namespace.trim());
|
|
|
|
|
}
|
2026-03-16 10:05:14 -05:00
|
|
|
form.append("file", safeFile);
|
Add MarkdownEditor component, asset image upload, and rich description editing
Introduce MarkdownEditor built on @mdxeditor/editor with headings,
lists, links, quotes, image upload with drag-and-drop, and themed CSS
integration. Add asset image upload API (routes, service, storage) and
wire image upload into InlineEditor multiline mode, NewIssueDialog,
NewProjectDialog, GoalDetail, IssueDetail, and ProjectDetail
description fields. Tighten prompt template editor styling.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 12:50:45 -06:00
|
|
|
return api.postForm<AssetImage>(`/companies/${companyId}/assets/images`, form);
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-16 10:05:14 -05:00
|
|
|
uploadCompanyLogo: async (companyId: string, file: File) => {
|
|
|
|
|
const buffer = await file.arrayBuffer();
|
|
|
|
|
const safeFile = new File([buffer], file.name, { type: file.type });
|
|
|
|
|
|
|
|
|
|
const form = new FormData();
|
|
|
|
|
form.append("file", safeFile);
|
|
|
|
|
return api.postForm<AssetImage>(`/companies/${companyId}/logo`, form);
|
|
|
|
|
},
|
|
|
|
|
};
|