diff --git a/apps/api/plane/bgtasks/page_version_task.py b/apps/api/plane/bgtasks/page_version_task.py index 7a5f94c9e..ec1f6c3ca 100644 --- a/apps/api/plane/bgtasks/page_version_task.py +++ b/apps/api/plane/bgtasks/page_version_task.py @@ -30,6 +30,8 @@ def page_version(page_id, existing_instance, user_id): description_binary=page.description_binary, owned_by_id=user_id, last_saved_at=page.updated_at, + description_json=page.description, + description_stripped=page.description_stripped, ) # If page versions are greater than 20 delete the oldest one diff --git a/apps/web/core/components/pages/version/editor.tsx b/apps/web/core/components/pages/version/editor.tsx index 412b80c0c..d001072db 100644 --- a/apps/web/core/components/pages/version/editor.tsx +++ b/apps/web/core/components/pages/version/editor.tsx @@ -2,7 +2,8 @@ import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // plane imports import type { TDisplayConfig } from "@plane/editor"; -import { TPageVersion } from "@plane/types"; +import type { JSONContent, TPageVersion } from "@plane/types"; +import { isJSONContentEmpty } from "@plane/utils"; import { Loader } from "@plane/ui"; // components import { DocumentEditor } from "@/components/editor/document/editor"; @@ -77,7 +78,10 @@ export const PagesVersionEditor: React.FC = observer((props ); - const description = versionDetails?.description_json; + const description = isJSONContentEmpty(versionDetails?.description_json as JSONContent) + ? versionDetails?.description_html + : versionDetails?.description_json; + if (!description) return null; return ( diff --git a/packages/utils/src/string.ts b/packages/utils/src/string.ts index 773501151..7dfd28daa 100644 --- a/packages/utils/src/string.ts +++ b/packages/utils/src/string.ts @@ -167,8 +167,11 @@ export const isEmptyHtmlString = (htmlString: string, allowedHTMLTags: string[] * @param {JSONContent} content * @returns {boolean} */ -const isJSONContentEmpty = (content: JSONContent): boolean => { +export const isJSONContentEmpty = (content: JSONContent | undefined): boolean => { // If it has text, check if text is meaningful + if (!content) { + return true; + } if (content.text !== undefined) { return !content.text || content.text.trim() === ""; }