Files
plane/web/helpers/editor.helper.ts
Prateek Shourya 6d216f2607 [WEB-3482] refactor: platform components and mobx stores (#6713)
* improvement: platform componenents and mobx stores

* minor improvements
2025-03-06 15:47:46 +05:30

38 lines
1.1 KiB
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() ?? "";
};
export const isEditorEmpty = (description: string | undefined): boolean =>
!description ||
description === "<p></p>" ||
description === `<p class="editor-paragraph-block"></p>` ||
description.trim() === "";