[WIKI-699] refactor: editor config (#7850)
This commit is contained in:
parent
a69c6f1b9c
commit
b37e453b32
7 changed files with 32 additions and 3 deletions
23
apps/web/ce/hooks/editor/use-extended-editor-config.ts
Normal file
23
apps/web/ce/hooks/editor/use-extended-editor-config.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { useCallback } from "react";
|
||||||
|
// plane imports
|
||||||
|
import type { TExtendedFileHandler } from "@plane/editor";
|
||||||
|
|
||||||
|
export type TExtendedEditorFileHandlersArgs = {
|
||||||
|
projectId?: string;
|
||||||
|
workspaceSlug: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TExtendedEditorConfig = {
|
||||||
|
getExtendedEditorFileHandlers: (args: TExtendedEditorFileHandlersArgs) => TExtendedFileHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useExtendedEditorConfig = (): TExtendedEditorConfig => {
|
||||||
|
const getExtendedEditorFileHandlers: TExtendedEditorConfig["getExtendedEditorFileHandlers"] = useCallback(
|
||||||
|
() => ({}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
getExtendedEditorFileHandlers,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -5,6 +5,7 @@ import { getEditorAssetDownloadSrc, getEditorAssetSrc } from "@plane/utils";
|
||||||
// hooks
|
// hooks
|
||||||
import { useEditorAsset } from "@/hooks/store/use-editor-asset";
|
import { useEditorAsset } from "@/hooks/store/use-editor-asset";
|
||||||
// plane web hooks
|
// plane web hooks
|
||||||
|
import { useExtendedEditorConfig } from "@/plane-web/hooks/editor/use-extended-editor-config";
|
||||||
import { useFileSize } from "@/plane-web/hooks/use-file-size";
|
import { useFileSize } from "@/plane-web/hooks/use-file-size";
|
||||||
// services
|
// services
|
||||||
import { FileService } from "@/services/file.service";
|
import { FileService } from "@/services/file.service";
|
||||||
|
|
@ -22,6 +23,7 @@ export const useEditorConfig = () => {
|
||||||
const { assetsUploadPercentage } = useEditorAsset();
|
const { assetsUploadPercentage } = useEditorAsset();
|
||||||
// file size
|
// file size
|
||||||
const { maxFileSize } = useFileSize();
|
const { maxFileSize } = useFileSize();
|
||||||
|
const { getExtendedEditorFileHandlers } = useExtendedEditorConfig();
|
||||||
|
|
||||||
const getEditorFileHandlers = useCallback(
|
const getEditorFileHandlers = useCallback(
|
||||||
(args: TArgs): TFileHandler => {
|
(args: TArgs): TFileHandler => {
|
||||||
|
|
@ -86,9 +88,10 @@ export const useEditorConfig = () => {
|
||||||
validation: {
|
validation: {
|
||||||
maxFileSize,
|
maxFileSize,
|
||||||
},
|
},
|
||||||
|
...getExtendedEditorFileHandlers({ projectId, workspaceSlug }),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[assetsUploadPercentage, maxFileSize]
|
[assetsUploadPercentage, getExtendedEditorFileHandlers, maxFileSize]
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,6 @@ export class FileService extends APIService {
|
||||||
throw err?.response?.data;
|
throw err?.response?.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProjectCoverImages(): Promise<string[]> {
|
async getProjectCoverImages(): Promise<string[]> {
|
||||||
return this.get(`/api/project-covers/`)
|
return this.get(`/api/project-covers/`)
|
||||||
.then((res) => res?.data)
|
.then((res) => res?.data)
|
||||||
|
|
|
||||||
1
packages/editor/src/ce/types/config.ts
Normal file
1
packages/editor/src/ce/types/config.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export type TExtendedFileHandler = object;
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
export * from "./issue-embed";
|
export * from "./issue-embed";
|
||||||
export * from "./editor-extended";
|
export * from "./editor-extended";
|
||||||
|
export * from "./config";
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ const generalSelectors = [
|
||||||
".image-upload-component",
|
".image-upload-component",
|
||||||
".editor-callout-component",
|
".editor-callout-component",
|
||||||
".editor-embed-component",
|
".editor-embed-component",
|
||||||
|
".editor-drawio-component",
|
||||||
].join(", ");
|
].join(", ");
|
||||||
|
|
||||||
const maxScrollSpeed = 20;
|
const maxScrollSpeed = 20;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// plane imports
|
// plane imports
|
||||||
import { TWebhookConnectionQueryParams } from "@plane/types";
|
import { TWebhookConnectionQueryParams } from "@plane/types";
|
||||||
|
import { TExtendedFileHandler } from "@/plane-editor/types/config";
|
||||||
|
|
||||||
export type TFileHandler = {
|
export type TFileHandler = {
|
||||||
assetsUploadStatus: Record<string, number>; // blockId => progress percentage
|
assetsUploadStatus: Record<string, number>; // blockId => progress percentage
|
||||||
|
|
@ -16,7 +17,7 @@ export type TFileHandler = {
|
||||||
* @example enter 5242880(5 * 1024 * 1024) for 5MB
|
* @example enter 5242880(5 * 1024 * 1024) for 5MB
|
||||||
*/
|
*/
|
||||||
maxFileSize: number;
|
maxFileSize: number;
|
||||||
};
|
} & TExtendedFileHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TEditorFontStyle = "sans-serif" | "serif" | "monospace";
|
export type TEditorFontStyle = "sans-serif" | "serif" | "monospace";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue