refactor: parser functions

This commit is contained in:
Aaryan Khandelwal
2025-08-07 14:32:59 +05:30
parent a986068e9f
commit a89bee8975
3 changed files with 11 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
// helpers
import { getAllDocumentFormatsFromBinaryData, getBinaryDataFromHTMLString } from "@/core/helpers/page.js";
import { getAllDocumentFormatsFromBinaryData, getBinaryDataFromHTMLString } from "@plane/editor/lib";
// services
import { PageService } from "@/core/services/page.service.js";
import { manualLogger } from "../helpers/logger.js";
@@ -19,7 +19,9 @@ export const updatePageDescription = async (
const projectId = params.get("projectId")?.toString();
if (!workspaceSlug || !projectId || !cookie) return;
const { contentBinaryEncoded, contentHTML, contentJSON } = getAllDocumentFormatsFromBinaryData(updatedDescription);
const { contentBinaryEncoded, contentHTML, contentJSON } = getAllDocumentFormatsFromBinaryData({
descriptionBinary: updatedDescription,
});
try {
const payload = {
description_binary: contentBinaryEncoded,
@@ -44,7 +46,9 @@ const fetchDescriptionHTMLAndTransform = async (
try {
const pageDetails = await pageService.fetchDetails(workspaceSlug, projectId, pageId, cookie);
const { contentBinary } = getBinaryDataFromHTMLString(pageDetails.description_html ?? "<p></p>");
const contentBinary = getBinaryDataFromHTMLString({
descriptionHTML: pageDetails.description_html ?? "<p></p>",
});
return contentBinary;
} catch (error) {
manualLogger.error("Error while transforming from HTML to Uint8Array", error);

View File

@@ -73,7 +73,7 @@ export class Server {
return;
}
const { description, description_binary } = getAllDocumentFormatsFromHTMLString({
document_html: description_html,
descriptionHTML: description_html,
});
res.status(200).json({
description,

View File

@@ -27,7 +27,9 @@ export const usePageFallback = (args: TArgs) => {
if (latestEncodedDescription && latestEncodedDescription.byteLength > 0) {
latestDecodedDescription = new Uint8Array(latestEncodedDescription);
} else {
latestDecodedDescription = getBinaryDataFromHTMLString("<p></p>");
latestDecodedDescription = getBinaryDataFromHTMLString({
descriptionHTML: "<p></p>",
});
}
editor.setProviderDocument(latestDecodedDescription);