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 085d99972..defa5c92a 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 38525faa0..81cf7d68f 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 (