Skip to content

Commit b37e453

Browse files
authored
[WIKI-699] refactor: editor config (#7850)
1 parent a69c6f1 commit b37e453

7 files changed

Lines changed: 32 additions & 3 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { useCallback } from "react";
2+
// plane imports
3+
import type { TExtendedFileHandler } from "@plane/editor";
4+
5+
export type TExtendedEditorFileHandlersArgs = {
6+
projectId?: string;
7+
workspaceSlug: string;
8+
};
9+
10+
export type TExtendedEditorConfig = {
11+
getExtendedEditorFileHandlers: (args: TExtendedEditorFileHandlersArgs) => TExtendedFileHandler;
12+
};
13+
14+
export const useExtendedEditorConfig = (): TExtendedEditorConfig => {
15+
const getExtendedEditorFileHandlers: TExtendedEditorConfig["getExtendedEditorFileHandlers"] = useCallback(
16+
() => ({}),
17+
[]
18+
);
19+
20+
return {
21+
getExtendedEditorFileHandlers,
22+
};
23+
};

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getEditorAssetDownloadSrc, getEditorAssetSrc } from "@plane/utils";
55
// hooks
66
import { useEditorAsset } from "@/hooks/store/use-editor-asset";
77
// plane web hooks
8+
import { useExtendedEditorConfig } from "@/plane-web/hooks/editor/use-extended-editor-config";
89
import { useFileSize } from "@/plane-web/hooks/use-file-size";
910
// services
1011
import { FileService } from "@/services/file.service";
@@ -22,6 +23,7 @@ export const useEditorConfig = () => {
2223
const { assetsUploadPercentage } = useEditorAsset();
2324
// file size
2425
const { maxFileSize } = useFileSize();
26+
const { getExtendedEditorFileHandlers } = useExtendedEditorConfig();
2527

2628
const getEditorFileHandlers = useCallback(
2729
(args: TArgs): TFileHandler => {
@@ -86,9 +88,10 @@ export const useEditorConfig = () => {
8688
validation: {
8789
maxFileSize,
8890
},
91+
...getExtendedEditorFileHandlers({ projectId, workspaceSlug }),
8992
};
9093
},
91-
[assetsUploadPercentage, maxFileSize]
94+
[assetsUploadPercentage, getExtendedEditorFileHandlers, maxFileSize]
9295
);
9396

9497
return {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ export class FileService extends APIService {
273273
throw err?.response?.data;
274274
});
275275
}
276-
277276
async getProjectCoverImages(): Promise<string[]> {
278277
return this.get(`/api/project-covers/`)
279278
.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 = object;
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)