forked from github/plane
e1ae0d3b56
* remirror instances commented out to avoid prosemirror conflicts * styles migrated for remirror to tiptap transition * added bubblemenu support with extensions * fixed css for task lists and code with syntax highlighting * added support for slash command * fixed bubble menu to match styles and added better seperation in UI * saving with debounce logic added and it's stored in backend * added migration support by updating to html * Image uploads done * improved file structure and delete image function implemented * Integrated tiptap with Issue Modal * added additional props and Tiptap Integration with Comments * added tiptap integration with user activity feeds * added ref control support and bubble menu support for readonly editor * added tiptap support for plane pages * added tiptap support to gpt assistant modal (yet to be tested) * removed remirror instances and cleaned up code * improved code structure for extracting props in Tiptap * fixing ts errors for next build * fixing node ts error for Horizontal Rule * added ts fix for node types * temp fix * temp fix * added min height for issue description in modal * added resolutions to prosemirror-model version * trying pnpm overrides * explicitly added prosemirror deps * bugfixes * removed extra gap at the top and moved saved indicator to the bottom * fix: slash command scroll position * chore: update custom css variables * matched theme colours * fixed gpt-assistant modal * updated yarn lock * added debounced updates for the title and removed saved state after timeout * added css animations for saved state * build fixes and remove remirror instances * minor commenting fixes --------- Co-authored-by: Palanikannan1437 <73993394+Palanikannan1437@users.noreply.github.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
100 lines
2.5 KiB
TypeScript
100 lines
2.5 KiB
TypeScript
// services
|
|
import APIService from "services/api.service";
|
|
|
|
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
|
|
|
|
interface UnSplashImage {
|
|
id: string;
|
|
created_at: Date;
|
|
updated_at: Date;
|
|
promoted_at: Date;
|
|
width: number;
|
|
height: number;
|
|
color: string;
|
|
blur_hash: string;
|
|
description: null;
|
|
alt_description: string;
|
|
urls: UnSplashImageUrls;
|
|
[key: string]: any;
|
|
}
|
|
|
|
interface UnSplashImageUrls {
|
|
raw: string;
|
|
full: string;
|
|
regular: string;
|
|
small: string;
|
|
thumb: string;
|
|
small_s3: string;
|
|
}
|
|
|
|
class FileServices extends APIService {
|
|
constructor() {
|
|
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
|
|
}
|
|
|
|
async uploadFile(workspaceSlug: string, file: FormData): Promise<any> {
|
|
return this.mediaUpload(`/api/workspaces/${workspaceSlug}/file-assets/`, file)
|
|
.then((response) => response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
|
|
async deleteImage(assetUrlWithWorkspaceId: string): Promise<any> {
|
|
return this.delete(`/api/workspaces/file-assets/${assetUrlWithWorkspaceId}/`)
|
|
.then((response) => response?.status)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
|
|
async deleteFile(workspaceId: string, assetUrl: string): Promise<any> {
|
|
const lastIndex = assetUrl.lastIndexOf("/");
|
|
const assetId = assetUrl.substring(lastIndex + 1);
|
|
|
|
return this.delete(`/api/workspaces/file-assets/${workspaceId}/${assetId}/`)
|
|
.then((response) => response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
async uploadUserFile(file: FormData): Promise<any> {
|
|
return this.mediaUpload(`/api/users/file-assets/`, file)
|
|
.then((response) => response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
|
|
async deleteUserFile(assetUrl: string): Promise<any> {
|
|
const lastIndex = assetUrl.lastIndexOf("/");
|
|
const assetId = assetUrl.substring(lastIndex + 1);
|
|
|
|
return this.delete(`/api/users/file-assets/${assetId}`)
|
|
.then((response) => response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
|
|
async getUnsplashImages(page: number = 1, query?: string): Promise<UnSplashImage[]> {
|
|
const url = "/api/unsplash";
|
|
|
|
return this.request({
|
|
method: "get",
|
|
url,
|
|
params: {
|
|
page,
|
|
per_page: 20,
|
|
query,
|
|
},
|
|
})
|
|
.then((response) => response?.data?.results ?? response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
}
|
|
|
|
export default new FileServices();
|