Skip to content

Commit

Permalink
[Content] AI Assistant VQA updates round 2 (#3001)
Browse files Browse the repository at this point in the history
Resolves comments on
#2981 (comment)
  • Loading branch information
finnar-bin authored Oct 9, 2024
1 parent 4526643 commit c59f2ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/apps/content-editor/src/app/components/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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("&rsquo;", "'")
?.replaceAll(/[\u201C\u201D\u201E]/gm, '"')
?.replaceAll("&ldquo;", '"')
?.replaceAll("&rdquo;", '"')
?.slice(0, 160);
const cleanedValue = unescape(
value
?.replace(/<[^>]*>/g, "")
?.replaceAll(/[\u2018\u2019\u201A]/gm, "'")
?.replaceAll("&rsquo;", "'")
?.replaceAll(/[\u201C\u201D\u201E]/gm, '"')
?.replaceAll("&ldquo;", '"')
?.replaceAll("&rdquo;", '"')
?.replaceAll("&nbsp;", " ")
?.slice(0, 160) || ""
);

dispatch({
type: "SET_ITEM_WEB",
Expand Down
17 changes: 16 additions & 1 deletion src/apps/content-editor/src/app/views/ItemEdit/Meta/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit c59f2ab

Please sign in to comment.