From bc4f637845df67ae8c238aca8149ec1e714bf815 Mon Sep 17 00:00:00 2001 From: Nar -- <28705606+finnar-bin@users.noreply.github.com> Date: Thu, 10 Oct 2024 08:33:24 +0800 Subject: [PATCH] Chore/resolve stage conflict (#3006) Co-authored-by: Andres Galindo Co-authored-by: Stuart Runyan Co-authored-by: Allen Pigar <50983144+allenpigar@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../src/app/components/Editor/Editor.js | 20 +++++++++++-------- .../src/app/views/ItemEdit/Meta/index.tsx | 17 +++++++++++++++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/apps/content-editor/src/app/components/Editor/Editor.js b/src/apps/content-editor/src/app/components/Editor/Editor.js index 085d999727..defa5c92a5 100644 --- a/src/apps/content-editor/src/app/components/Editor/Editor.js +++ b/src/apps/content-editor/src/app/components/Editor/Editor.js @@ -11,6 +11,7 @@ import cx from "classnames"; import { AppLink } from "@zesty-io/core/AppLink"; import { ThemeProvider } from "@mui/material"; import { theme } from "@zesty-io/material"; +import { unescape } from "lodash"; import { Breadcrumbs } from "shell/components/global-tabs/components/Breadcrumbs"; import { Field } from "./Field"; import { FieldError } from "./FieldError"; @@ -276,14 +277,17 @@ export default memo(function Editor({ if (firstContentField && firstContentField.name === name) { // Remove tags and replace MS smart quotes with regular quotes - const cleanedValue = value - ?.replace(/<[^>]*>/g, "") - ?.replaceAll(/[\u2018\u2019\u201A]/gm, "'") - ?.replaceAll("’", "'") - ?.replaceAll(/[\u201C\u201D\u201E]/gm, '"') - ?.replaceAll("“", '"') - ?.replaceAll("”", '"') - ?.slice(0, 160); + const cleanedValue = unescape( + value + ?.replace(/<[^>]*>/g, "") + ?.replaceAll(/[\u2018\u2019\u201A]/gm, "'") + ?.replaceAll("’", "'") + ?.replaceAll(/[\u201C\u201D\u201E]/gm, '"') + ?.replaceAll("“", '"') + ?.replaceAll("”", '"') + ?.replaceAll(" ", " ") + ?.slice(0, 160) || "" + ); dispatch({ type: "SET_ITEM_WEB", diff --git a/src/apps/content-editor/src/app/views/ItemEdit/Meta/index.tsx b/src/apps/content-editor/src/app/views/ItemEdit/Meta/index.tsx index 38525faa07..81cf7d68f9 100644 --- a/src/apps/content-editor/src/app/views/ItemEdit/Meta/index.tsx +++ b/src/apps/content-editor/src/app/views/ItemEdit/Meta/index.tsx @@ -316,9 +316,24 @@ export const Meta = forwardRef( if (!isCreateItemPage) return; if (flowType === FlowType.AIGenerated) { + // Immediately clear out the existing values for the meta title and description + dispatch({ + type: "SET_ITEM_WEB", + itemZUID: meta?.ZUID, + key: "metaTitle", + value: "", + }); + dispatch({ + type: "SET_ITEM_WEB", + itemZUID: meta?.ZUID, + key: "metaDescription", + value: "", + }); + + // Then trigger the AI assistant popup metaTitleButtonRef.current?.triggerAIButton?.(); } - }, [flowType, isCreateItemPage]); + }, [flowType, isCreateItemPage, meta?.ZUID]); if (isCreateItemPage && flowType === null) { return (