Skip to content

Commit 4074a9f

Browse files
committed
chore: core files changes
1 parent cbf167a commit 4074a9f

File tree

7 files changed

+71
-1
lines changed

7 files changed

+71
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export type TExtendedEditorConfigArgs = {
2+
projectId?: string;
3+
workspaceSlug: string;
4+
};
5+
6+
export type TExtendedEditorConfig = object;
7+
export const extendedEditorConfig = (_args: TExtendedEditorConfigArgs): TExtendedEditorConfig => ({});

apps/web/core/hooks/editor/use-editor-config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useEditorAsset } from "@/hooks/store/use-editor-asset";
88
import { useFileSize } from "@/plane-web/hooks/use-file-size";
99
// services
1010
import { FileService } from "@/services/file.service";
11+
import { extendedEditorConfig } from "@/plane-web/hooks/editor/use-editor-config";
1112
const fileService = new FileService();
1213

1314
type TArgs = {
@@ -86,6 +87,10 @@ export const useEditorConfig = () => {
8687
validation: {
8788
maxFileSize,
8889
},
90+
...extendedEditorConfig({
91+
projectId,
92+
workspaceSlug,
93+
}),
8994
};
9095
},
9196
[assetsUploadPercentage, maxFileSize]

apps/web/core/services/file.service.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,61 @@ export class FileService extends APIService {
273273
throw err?.response?.data;
274274
});
275275
}
276+
async reuploadWorkspaceAsset(
277+
workspaceSlug: string,
278+
assetId: string,
279+
file: File,
280+
uploadProgressHandler?: AxiosRequestConfig["onUploadProgress"]
281+
): Promise<TFileSignedURLResponse> {
282+
const fileMetaData = getFileMetaDataForUpload(file);
283+
return this.post(`/api/assets/v2/workspaces/${workspaceSlug}/reupload/${assetId}/`, {
284+
type: fileMetaData.type,
285+
size: fileMetaData.size,
286+
})
287+
.then(async (response) => {
288+
const signedURLResponse: TFileSignedURLResponse = response?.data;
289+
const fileUploadPayload = generateFileUploadPayload(signedURLResponse, file);
290+
await this.fileUploadService.uploadFile(
291+
signedURLResponse.upload_data.url,
292+
fileUploadPayload,
293+
uploadProgressHandler
294+
);
295+
await this.updateWorkspaceAssetUploadStatus(workspaceSlug, signedURLResponse.asset_id);
296+
return signedURLResponse;
297+
})
298+
.catch((error) => {
299+
throw error?.response?.data;
300+
});
301+
}
276302

303+
async reuploadProjectAsset(
304+
workspaceSlug: string,
305+
projectId: string,
306+
assetId: string,
307+
file: File,
308+
uploadProgressHandler?: AxiosRequestConfig["onUploadProgress"]
309+
): Promise<TFileSignedURLResponse> {
310+
const fileMetaData = getFileMetaDataForUpload(file);
311+
312+
return this.post(`/api/assets/v2/workspaces/${workspaceSlug}/projects/${projectId}/reupload/${assetId}/`, {
313+
type: fileMetaData.type,
314+
size: fileMetaData.size,
315+
})
316+
.then(async (response) => {
317+
const signedURLResponse: TFileSignedURLResponse = response?.data;
318+
const fileUploadPayload = generateFileUploadPayload(signedURLResponse, file);
319+
await this.fileUploadService.uploadFile(
320+
signedURLResponse.upload_data.url,
321+
fileUploadPayload,
322+
uploadProgressHandler
323+
);
324+
await this.updateProjectAssetUploadStatus(workspaceSlug, projectId, signedURLResponse.asset_id);
325+
return signedURLResponse;
326+
})
327+
.catch((error) => {
328+
throw error?.response?.data;
329+
});
330+
}
277331
async getProjectCoverImages(): Promise<string[]> {
278332
return this.get(`/api/project-covers/`)
279333
.then((res) => res?.data)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type TExtendedFileHandler = null;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./issue-embed";
22
export * from "./editor-extended";
3+
export * from "./config";

packages/editor/src/core/plugins/drag-handle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const generalSelectors = [
2222
".image-upload-component",
2323
".editor-callout-component",
2424
".editor-embed-component",
25+
".editor-drawio-component",
2526
].join(", ");
2627

2728
const maxScrollSpeed = 20;

packages/editor/src/core/types/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// plane imports
22
import { TWebhookConnectionQueryParams } from "@plane/types";
3+
import { TExtendedFileHandler } from "@/plane-editor/types/config";
34

45
export type TFileHandler = {
56
assetsUploadStatus: Record<string, number>; // blockId => progress percentage
@@ -16,7 +17,7 @@ export type TFileHandler = {
1617
* @example enter 5242880(5 * 1024 * 1024) for 5MB
1718
*/
1819
maxFileSize: number;
19-
};
20+
} & TExtendedFileHandler;
2021
};
2122

2223
export type TEditorFontStyle = "sans-serif" | "serif" | "monospace";

0 commit comments

Comments
 (0)