Skip to content

feat: add StyledPlainText and StyledRichText#1257

Merged
jwartofsky-yext merged 20 commits into
2026-custom-components-templatesfrom
styledTextFields
Jul 8, 2026
Merged

feat: add StyledPlainText and StyledRichText#1257
jwartofsky-yext merged 20 commits into
2026-custom-components-templatesfrom
styledTextFields

Conversation

@jwartofsky-yext

@jwartofsky-yext jwartofsky-yext commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Styled Text API Updates

Summary

This PR updates the styled text API documentation to match the current public surface area.

  • createStyledTextConfig remains the entry point for building styled text field configs
  • StyledTextComponent is now the shared renderer for both plain text and rich text
  • StyledPlainText and StyledRichText are no longer exported render components
  • StyledPlainTextProps and StyledRichTextProps are still exported for typing
  • tagOptions only applies to kind: "plain"
  • includeColor and includeAlignment are still supported

Updated Usage

Create config

import {
  createStyledTextConfig,
  StyledTextComponent,
} from "@yext/visual-editor";

const headingConfig = createStyledTextConfig({
  kind: "plain", // use "richText" for rich text
  label: "Heading",
  includeColor: true,
  includeAlignment: true,
  tagOptions: ["h2", "h3", "div"], // if empty, this option doesn't appear
});

Plain text

Render one plain-text instance. It owns its own data.text.

fields: {
  heading: headingConfig.fields,
},

defaultProps: {
  heading: {
    ...headingConfig.defaultProps,
    data: {
      text: {
        field: "",
        constantValue: { defaultValue: "Section Heading" },
        constantValueEnabled: true,
      },
    },
  },
},

render: ({ heading }) => (
  <StyledTextComponent {...heading} kind="plain" />
);

Shared plain-text styling across repeated items

fields: {
  cardTitleStyles: headingConfig.fields,
  cards: {
    type: "array",
    arrayFields: {
      title: {
        type: "entityField",
        filter: { types: ["type.string"] },
      },
    },
  },
},

render: ({ cardTitleStyles, cards }) => (
  <>
    {cards.map((card, index) => (
      <StyledTextComponent
        key={index}
        {...cardTitleStyles}
        kind="plain"
        data={{ text: card.title }}
      />
    ))}
  </>
);

Rich text

const bodyConfig = createStyledTextConfig({
  kind: "richText",
  label: "Body",
  includeColor: true,
  includeAlignment: true,
});
fields: {
  body: bodyConfig.fields,
},

defaultProps: {
  body: {
    ...bodyConfig.defaultProps,
    data: {
      text: {
        field: "",
        constantValue: { defaultValue: "<p>Body copy</p>" },
        constantValueEnabled: true,
      },
    },
  },
},

render: ({ body }) => (
  <StyledTextComponent {...body} kind="richText" />
);

Shared rich-text styling across repeated items

fields: {
  cardBodyStyles: bodyConfig.fields,
  cards: {
    type: "array",
    arrayFields: {
      description: {
        type: "entityField",
        filter: { types: ["type.string", "type.rich_text_v2"] },
      },
    },
  },
},

render: ({ cardBodyStyles, cards }) => (
  <>
    {cards.map((card, index) => (
      <StyledTextComponent
        key={index}
        {...cardBodyStyles}
        kind="richText"
        data={{ text: card.description }}
      />
    ))}
  </>
);

StyledPlainTextProps

Use this when you want to type a prop or local variable representing one plain-text instance.

import {
  StyledTextComponent,
  type StyledPlainTextProps,
} from "@yext/visual-editor";

type Props = {
  heading: StyledPlainTextProps;
};

function Section({ heading }: Props) {
  return <StyledTextComponent {...heading} kind="plain" />;
}

StyledRichTextProps

Same for rich text.

import {
  StyledTextComponent,
  type StyledRichTextProps,
} from "@yext/visual-editor";

type Props = {
  body: StyledRichTextProps;
};

function Section({ body }: Props) {
  return <StyledTextComponent {...body} kind="richText" />;
}

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information.

@jwartofsky-yext jwartofsky-yext changed the base branch from main to 2026-custom-components-templates July 6, 2026 13:30

@benlife5 benlife5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General idea LGTM! I do think will help make template generation more straightforward.

I'd tend towards using the YextFields json syntax for defining the fields in the components rather than using createStyledTextConfig => headingConfig.fields. We were originally trying to move away from using functions/variable references in the fields for some of the Puck-in-Storm stuff, but I suppose that doesn't matter anymore. I still prefer the fields to be more explicit and understandable, but I get that createStyledTextConfig makes it simpler... so I'm good either way.

My only other note is that the more stuff we move into the library, the more we need to handle visual-editor versioning and backwards compatibility, but that was going to be important anyway

@jwartofsky-yext jwartofsky-yext changed the title WIP: add StyledPlainText and StyledRichText WIP: feat: add StyledPlainText and StyledRichText Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

This PR adds shared styled-text rendering helpers, a new getRichTextStyle utility, and a createStyledTextConfig factory for plain and rich-text content blocks, with barrel exports and tests. It also extends StyledTextField to support grouped { text, color } values with an optional font-color selector. Separately, getSurfaceColorStyle now accepts fallback background and text colors, and its tests cover the new resolution behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Puck
  participant StyledTextComponent
  participant resolveComponentData
  participant StyledTextElement
  participant renderStyledRichText

  Puck->>StyledTextComponent: render kind and entity props
  StyledTextComponent->>resolveComponentData: resolve document fields
  resolveComponentData-->>StyledTextComponent: resolved content or empty result
  alt plain text
    StyledTextComponent->>StyledTextElement: render plain text
  else rich text
    StyledTextComponent->>renderStyledRichText: render resolved rich content
  end
Loading

Possibly related PRs

  • yext/visual-editor#1197: Extends the same StyledTextField/StyledTextValue foundation with the grouped { text, color } shape and includeColor behavior introduced here.
  • yext/visual-editor#1231: Implements the rich-text/typography color override plumbing (MaybeRTF, richTextStyleOverrides, theme color resolution) that this PR builds directly upon.
  • yext/visual-editor#1041: Related rich-text rendering changes in the same visual-editor area that also touch color handling and MaybeRTF behavior.

Suggested labels: create-dev-release

Suggested reviewers: asanehisa, benlife5, mkilpatrick, briantstephan

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions StyledPlainText and StyledRichText, but the PR adds createStyledTextConfig, StyledTextComponent, and related props/types instead. Rename it to reflect the actual change, e.g. "Add createStyledTextConfig and shared StyledTextComponent for plain and rich text".
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description is about the styled text API update and matches the files and exported types added in the PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch styledTextFields

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
packages/visual-editor/src/components/contentBlocks/styledText.tsx (1)

98-133: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider deduplicating getStyledRichTextStyle against getStyledTextStyle.

The five if (text && text.xxx !== "default") blocks mirror the logic already in getStyledTextStyle (lines 39-53), just mapping to CSS-variable keys instead of standard style props. A small key-mapping table iterated once would avoid maintaining two parallel copies of the same "skip default" logic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/components/contentBlocks/styledText.tsx` around
lines 98 - 133, getStyledRichTextStyle duplicates the same “skip default” checks
already implemented in getStyledTextStyle, so refactor it to reuse that logic
via a small key-mapping table or shared helper. Update the
getStyledRichTextStyle function to iterate over the text style fields once and
assign the corresponding CSS variable keys instead of keeping five separate if
blocks. Keep the existing behavior for color handling and default-value
skipping, but make the mapping between StyledTextValue properties and the CSS
custom properties explicit and centralized.
packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx (1)

47-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

tagOptions is accepted for richText kind but silently ignored.

CreateStyledTextConfigOptions.tagOptions isn't restricted to kind: "plain", so callers of the richText overload can pass tagOptions and it will be silently dropped by buildFields (line 118: kind === "plain" && tagOptions?.length). A discriminated union keyed on kind would surface this at the type level instead of failing silently.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx`
around lines 47 - 58, The CreateStyledTextConfigOptions type currently allows
tagOptions on both plain and richText, but buildFields only uses it for plain
and silently drops it for richText. Refactor the options type into a
discriminated union keyed on kind so tagOptions is only valid when kind is
plain, and update CreateStyledTextConfig/buildFields to rely on that narrowed
shape. This should make callers of the richText path fail at compile time
instead of passing ignored tagOptions.
packages/visual-editor/src/fields/styledFields/StyledTextField.tsx (1)

91-106: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Color selector uses derived currentTextValue instead of the raw grouped text.

getGroupedStyledTextValue(value, currentTextValue) rebuilds the text payload from the normalized currentTextValue (which merges in defaultBaseTextStyles for any missing key) rather than reusing value.text directly. Since StyledTextValue requires all BaseTextStyles keys, this is a no-op today, but it's worth being aware of as a subtle behavior difference if the type ever gains optional fields.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/fields/styledFields/StyledTextField.tsx` around
lines 91 - 106, The color selector in StyledTextField is rebuilding the grouped
value from currentTextValue, which can subtly normalize the text payload instead
of preserving the original grouped text. Update the onChange path in
StyledTextField so the color update reuses the raw grouped text from value.text
(or otherwise preserves the existing grouped text object) rather than passing
currentTextValue into getGroupedStyledTextValue, keeping the selector behavior
aligned with the existing StyledTextValue shape.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/visual-editor/src/components/contentBlocks/styledText.tsx`:
- Around line 174-196: The rich-text typography styles are being applied to
content.props.children instead of the actual wrapper rendered by MaybeRTF, so
the .rtf-wrapper div never receives the font custom properties. Update
styledText’s cloneElement flow to apply richTextStyle to the cloned content
wrapper itself (or thread it through MaybeRTF) and keep the inner content
handling only for nested elements. Use the styledText block and MaybeRTF as the
key references when adjusting where className and style are merged.

In `@packages/visual-editor/src/utils/i18n/distance.ts`:
- Around line 59-73: The validation in toCoordinate currently accepts NaN and
Infinity because it only checks typeof on latitude and longitude. Update
toCoordinate in the distance utility to also require finite numeric values
before returning a GeoCoordinate, and otherwise return undefined so malformed
coordinates are treated like missing data. Keep the fix localized to
toCoordinate and ensure the downstream getDistance and NearbyLocations sorting
logic only receives valid finite coordinates.

---

Nitpick comments:
In
`@packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx`:
- Around line 47-58: The CreateStyledTextConfigOptions type currently allows
tagOptions on both plain and richText, but buildFields only uses it for plain
and silently drops it for richText. Refactor the options type into a
discriminated union keyed on kind so tagOptions is only valid when kind is
plain, and update CreateStyledTextConfig/buildFields to rely on that narrowed
shape. This should make callers of the richText path fail at compile time
instead of passing ignored tagOptions.

In `@packages/visual-editor/src/components/contentBlocks/styledText.tsx`:
- Around line 98-133: getStyledRichTextStyle duplicates the same “skip default”
checks already implemented in getStyledTextStyle, so refactor it to reuse that
logic via a small key-mapping table or shared helper. Update the
getStyledRichTextStyle function to iterate over the text style fields once and
assign the corresponding CSS variable keys instead of keeping five separate if
blocks. Keep the existing behavior for color handling and default-value
skipping, but make the mapping between StyledTextValue properties and the CSS
custom properties explicit and centralized.

In `@packages/visual-editor/src/fields/styledFields/StyledTextField.tsx`:
- Around line 91-106: The color selector in StyledTextField is rebuilding the
grouped value from currentTextValue, which can subtly normalize the text payload
instead of preserving the original grouped text. Update the onChange path in
StyledTextField so the color update reuses the raw grouped text from value.text
(or otherwise preserves the existing grouped text object) rather than passing
currentTextValue into getGroupedStyledTextValue, keeping the selector behavior
aligned with the existing StyledTextValue shape.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c6f84532-0c23-4642-a8b8-a6ae77fe7cec

📥 Commits

Reviewing files that changed from the base of the PR and between bd27fe9 and 7a708bd.

⛔ Files ignored due to path filters (1)
  • packages/visual-editor/src/components/testing/screenshots/PhotoGallerySection/[desktop] version 59 with showSectionHeading false.png is excluded by !**/*.png, !packages/visual-editor/src/components/testing/screenshots/**
📒 Files selected for processing (15)
  • packages/visual-editor/src/components/contentBlocks/StyledPlainText.tsx
  • packages/visual-editor/src/components/contentBlocks/StyledRichText.tsx
  • packages/visual-editor/src/components/contentBlocks/StyledText.test.tsx
  • packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx
  • packages/visual-editor/src/components/contentBlocks/index.ts
  • packages/visual-editor/src/components/contentBlocks/styledText.tsx
  • packages/visual-editor/src/components/pageSections/NearbyLocations/utils.ts
  • packages/visual-editor/src/fields/styledFields/StyledTextField.test.tsx
  • packages/visual-editor/src/fields/styledFields/StyledTextField.tsx
  • packages/visual-editor/src/utils/colors.test.ts
  • packages/visual-editor/src/utils/colors.ts
  • packages/visual-editor/src/utils/i18n/distance.test.ts
  • packages/visual-editor/src/utils/i18n/distance.ts
  • packages/visual-editor/src/utils/i18n/index.ts
  • packages/visual-editor/src/utils/index.ts

Comment thread packages/visual-editor/src/components/contentBlocks/styledText.tsx
Comment thread packages/visual-editor/src/utils/i18n/distance.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/visual-editor/src/utils/colors.ts (1)

597-634: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate fallback-merging logic between the two branches.

The per-key fallback merge (backgroundColor/color) is written twice — once inside the "resolved present" branch and once inside the "resolved absent" branch. These can be unified into a single expression guarded by one early-return check, reducing duplication.

♻️ Suggested consolidation
-  if (backgroundColor || foregroundColor) {
-    return {
-      ...(backgroundColor
-        ? { backgroundColor }
-        : options?.fallbackBackgroundColor
-          ? { backgroundColor: options.fallbackBackgroundColor }
-          : {}),
-      ...(foregroundColor
-        ? { color: foregroundColor }
-        : options?.fallbackTextColor
-          ? { color: options.fallbackTextColor }
-          : {}),
-    };
-  }
-
-  if (!options?.fallbackBackgroundColor && !options?.fallbackTextColor) {
-    return undefined;
-  }
-
-  return {
-    ...(options?.fallbackBackgroundColor
-      ? { backgroundColor: options.fallbackBackgroundColor }
-      : {}),
-    ...(options?.fallbackTextColor ? { color: options.fallbackTextColor } : {}),
-  };
+  if (
+    !backgroundColor &&
+    !foregroundColor &&
+    !options?.fallbackBackgroundColor &&
+    !options?.fallbackTextColor
+  ) {
+    return undefined;
+  }
+
+  return {
+    ...(backgroundColor
+      ? { backgroundColor }
+      : options?.fallbackBackgroundColor
+        ? { backgroundColor: options.fallbackBackgroundColor }
+        : {}),
+    ...(foregroundColor
+      ? { color: foregroundColor }
+      : options?.fallbackTextColor
+        ? { color: options.fallbackTextColor }
+        : {}),
+  };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/utils/colors.ts` around lines 597 - 634, The
getSurfaceColorStyle function repeats the same fallback merge for
backgroundColor and color in both branches, so consolidate it into one shared
return path. Keep the initial resolution of backgroundColor and foregroundColor
via getThemeColorCssValue and getDefaultForegroundColor, then use a single early
return for the no-style/no-fallback case and one unified object build that
applies resolved values first and falls back to options.fallbackBackgroundColor
and options.fallbackTextColor when needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/visual-editor/src/utils/colors.ts`:
- Around line 597-634: The getSurfaceColorStyle function repeats the same
fallback merge for backgroundColor and color in both branches, so consolidate it
into one shared return path. Keep the initial resolution of backgroundColor and
foregroundColor via getThemeColorCssValue and getDefaultForegroundColor, then
use a single early return for the no-style/no-fallback case and one unified
object build that applies resolved values first and falls back to
options.fallbackBackgroundColor and options.fallbackTextColor when needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 00a32ea6-c92c-488d-bf5d-3a6d3b17cb94

📥 Commits

Reviewing files that changed from the base of the PR and between 7a708bd and 86bb341.

📒 Files selected for processing (2)
  • packages/visual-editor/src/utils/colors.test.ts
  • packages/visual-editor/src/utils/colors.ts

@jwartofsky-yext jwartofsky-yext changed the title WIP: feat: add StyledPlainText and StyledRichText feat: add StyledPlainText and StyledRichText Jul 7, 2026
@jwartofsky-yext jwartofsky-yext self-assigned this Jul 7, 2026
@jwartofsky-yext jwartofsky-yext marked this pull request as ready for review July 7, 2026 15:33
Comment thread packages/visual-editor/src/components/contentBlocks/StyledPlainText.tsx Outdated
Comment thread packages/visual-editor/src/utils/i18n/index.ts Outdated
Comment thread packages/visual-editor/src/components/contentBlocks/styledText.tsx
Comment thread packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx Outdated
Comment thread packages/visual-editor/src/fields/styledFields/StyledTextField.tsx Outdated
Comment thread packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx Outdated
Comment thread packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/visual-editor/src/components/contentBlocks/styledText.tsx (1)

194-199: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Dead no-op clone: innerContent doesn't change anything.

React.cloneElement(content.props.children, { className: themeManagerCn(content.props.children.props.className), style: content.props.children.props.style }) passes through the exact same className/style values it already had — this clone has no effect and can be simplified to just content.props.children.

♻️ Proposed simplification
-  const innerContent = React.isValidElement(content.props.children)
-    ? React.cloneElement(content.props.children, {
-        className: themeManagerCn(content.props.children.props.className),
-        style: content.props.children.props.style,
-      })
-    : content.props.children;
-
-  return React.cloneElement(content, {
+  return React.cloneElement(content, {
     className: themeManagerCn(content.props.className, richTextClassName),
     style: {
       ...content.props.style,
       ...richTextStyle,
     },
-    children: innerContent,
   });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/components/contentBlocks/styledText.tsx` around
lines 194 - 199, The innerContent branch in styledText.tsx is a no-op because
the React.cloneElement call in the content.props.children path only reuses the
existing className and style without changing them. Simplify the
React.isValidElement(content.props.children) logic by removing the clone and
using content.props.children directly, keeping the surrounding themeManagerCn
and styledText content handling intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/visual-editor/src/components/contentBlocks/styledText.tsx`:
- Around line 194-199: The innerContent branch in styledText.tsx is a no-op
because the React.cloneElement call in the content.props.children path only
reuses the existing className and style without changing them. Simplify the
React.isValidElement(content.props.children) logic by removing the clone and
using content.props.children directly, keeping the surrounding themeManagerCn
and styledText content handling intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6738358e-7d04-49c3-ab02-e0acfd78ebe4

📥 Commits

Reviewing files that changed from the base of the PR and between a106ac4 and b53036f.

📒 Files selected for processing (4)
  • packages/visual-editor/src/components/atoms/maybeRTF.tsx
  • packages/visual-editor/src/components/contentBlocks/StyledText.test.tsx
  • packages/visual-editor/src/components/contentBlocks/styledText.tsx
  • packages/visual-editor/src/utils/richTextStyles.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/visual-editor/src/components/contentBlocks/StyledText.test.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx (1)

130-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Unused puck prop typing left over after removing editing-placeholder logic.

StyledTextComponent types puck?: { isEditing: boolean } (Lines 135-137) but never destructures or references it in the body (130-195). The two render wrappers (Line 232, Line 255) still intersect their prop types with { puck: { isEditing: boolean } } for the same unused purpose. Per the library context, the puck.isEditing-gated editing placeholder was intentionally removed, so this typing is now dead weight that could mislead future readers into thinking editing-mode behavior is still handled here. Puck injects puck into render automatically regardless of the declared type, so dropping it here is safe.

♻️ Proposed cleanup
 export const StyledTextComponent = <
   TText extends TranslatableString | TranslatableRichText,
 >(
   props: StyledTextConfigProps<TText> & {
     kind: CreateStyledTextConfigOptions["kind"];
-    puck?: {
-      isEditing: boolean;
-    };
   }
 ) => {
   const { data, alignment, fontOptions, kind } = props;
-      render: (
-        props: StyledPlainTextProps & { puck: { isEditing: boolean } }
-      ) => <StyledTextComponent {...props} kind="plain" />,
+      render: (props: StyledPlainTextProps) => (
+        <StyledTextComponent {...props} kind="plain" />
+      ),
-    render: (props: StyledRichTextProps & { puck: { isEditing: boolean } }) => (
-      <StyledTextComponent {...props} kind="richText" />
-    ),
+    render: (props: StyledRichTextProps) => (
+      <StyledTextComponent {...props} kind="richText" />
+    ),

Also applies to: 232-232, 232-232, 255-255, 255-255

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx`
around lines 130 - 140, Remove the leftover editing-mode typing from
StyledTextComponent: the local props type still declares puck?: { isEditing:
boolean }, but StyledTextComponent never uses it after the placeholder logic was
removed. Update the StyledTextComponent prop signature and the two render
wrappers that intersect their props with { puck: { isEditing: boolean } } so
they no longer mention puck at all, while keeping the component logic in
StyledTextComponent and the render call sites otherwise unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx`:
- Around line 130-140: Remove the leftover editing-mode typing from
StyledTextComponent: the local props type still declares puck?: { isEditing:
boolean }, but StyledTextComponent never uses it after the placeholder logic was
removed. Update the StyledTextComponent prop signature and the two render
wrappers that intersect their props with { puck: { isEditing: boolean } } so
they no longer mention puck at all, while keeping the component logic in
StyledTextComponent and the render call sites otherwise unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e6e8ed24-f98a-4210-ae3a-d8c5cc70f19a

📥 Commits

Reviewing files that changed from the base of the PR and between b53036f and 0de2996.

📒 Files selected for processing (3)
  • packages/visual-editor/src/components/contentBlocks/StyledText.test.tsx
  • packages/visual-editor/src/components/contentBlocks/createStyledTextConfig.tsx
  • packages/visual-editor/src/components/contentBlocks/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/visual-editor/src/components/contentBlocks/StyledText.test.tsx

Comment thread packages/visual-editor/src/utils/richTextStyles.ts Outdated
Comment thread packages/visual-editor/src/components/contentBlocks/styledText.tsx
@jwartofsky-yext jwartofsky-yext requested review from benlife5 and mkilpatrick and removed request for mkilpatrick July 7, 2026 19:51
@jwartofsky-yext jwartofsky-yext merged commit ccbb6a9 into 2026-custom-components-templates Jul 8, 2026
17 checks passed
@jwartofsky-yext jwartofsky-yext deleted the styledTextFields branch July 8, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants