mirror of
https://github.com/makeplane/plane.git
synced 2025-12-25 08:09:33 +01:00
* refactor: editor file handling * refactor: asset store * refactor: space app file handlers * fix: separate webhook connection params * chore: handle undefined status * chore: add type to upload status * chore: added transition for upload status update
32 lines
903 B
TypeScript
32 lines
903 B
TypeScript
// helpers
|
|
import { getFileURL } from "@/helpers/file.helper";
|
|
|
|
type TEditorSrcArgs = {
|
|
assetId: string;
|
|
projectId?: string;
|
|
workspaceSlug: string;
|
|
};
|
|
|
|
/**
|
|
* @description generate the file source using assetId
|
|
* @param {TEditorSrcArgs} args
|
|
*/
|
|
export const getEditorAssetSrc = (args: TEditorSrcArgs): string | undefined => {
|
|
const { assetId, projectId, workspaceSlug } = args;
|
|
let url: string | undefined = "";
|
|
if (projectId) {
|
|
url = getFileURL(`/api/assets/v2/workspaces/${workspaceSlug}/projects/${projectId}/${assetId}/`);
|
|
} else {
|
|
url = getFileURL(`/api/assets/v2/workspaces/${workspaceSlug}/${assetId}/`);
|
|
}
|
|
return url;
|
|
};
|
|
|
|
export const getTextContent = (jsx: JSX.Element | React.ReactNode | null | undefined): string => {
|
|
if (!jsx) return "";
|
|
|
|
const div = document.createElement("div");
|
|
div.innerHTML = jsx.toString();
|
|
return div.textContent?.trim() ?? "";
|
|
};
|