Skip to content

Conversation

@nicobytes
Copy link
Contributor

@nicobytes nicobytes commented Jan 16, 2026

This pull request updates the Open Graph preview and text count components to improve user experience and maintain consistency across legacy and new edit modes. It introduces a new text counter for the old editor, ensures fallback images for OG previews, and applies minor style enhancements.

Text Counter Improvements:

  • Added a new version of the text counter for the old editor, with improved layout, live character counting, and color feedback when exceeding the recommended maximum (text-count_old.vtl).
  • Updated the main text count template to conditionally load either the new or old version based on the edit mode, ensuring compatibility and consistent behavior (text_count.vtl).

Open Graph Preview Enhancements:

  • Changed the OG image preview logic to display a placeholder image if no image is set, improving the visual feedback for users (og_preview_new.vtl).
  • Added a text color style to the OG preview description for better readability in the old preview template (og_preview_old.vtl).

This PR fixes: #34029

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the Open Graph preview and text count components for dotCMS's content editor by introducing a new text counter for the legacy editor and improving the OG preview fallback behavior.

Changes:

  • Added a routing template (text_count.vtl) that conditionally loads either the new or old text counter based on edit mode
  • Created new text counter implementations for both new (text_count_new.vtl) and legacy (text-count_old.vtl) editors with live character counting and color feedback
  • Updated OG preview to show a placeholder image when no image is set (og_preview_new.vtl)
  • Added text color styling to the OG preview for better readability (og_preview_old.vtl)

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
text_count.vtl Router template that conditionally includes the appropriate text counter based on edit mode
text_count_new.vtl New text counter implementation using modern DotCustomFieldApi with module script
text-count_old.vtl Legacy text counter implementation using legacy DotCustomFieldApi methods
og_preview_new.vtl Updated to use external placeholder image when no OG image is set
og_preview_old.vtl Added color styling to the preview host element

#if( $structures.isNewEditModeEnabled() )
#parse('/static/htmlpage_assets/text_count_new.vtl')
#else
#parse('/static/htmlpage_assets/text_count_old.vtl')
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

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

The file path references 'text_count_old.vtl' but the actual filename is 'text-count_old.vtl' (with a hyphen instead of an underscore). This will cause the template parsing to fail. The filename should be renamed to 'text_count_old.vtl' to match the naming convention used by other similar files in this directory (e.g., og_preview_old.vtl, cachettl_custom_field_old.vtl).

Suggested change
#parse('/static/htmlpage_assets/text_count_old.vtl')
#parse('/static/htmlpage_assets/text-count_old.vtl')

Copilot uses AI. Check for mistakes.
// Get image from ogImage field container
const imgInode = ogImageField.getValue() || '';
const imgUrl = imgInode ? `/dA/${imgInode}/asset/500w/50q/` : '';
const imgUrl = imgInode ? `/dA/${imgInode}/asset/500w/50q/` : "https://placehold.co/600x400";
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

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

Using an external URL (https://placehold.co/600x400) as a placeholder introduces a dependency on an external service. If the external service is unavailable or slow, it will impact the user experience. Consider using a local placeholder image from the dotCMS assets or a data URI instead. Additionally, the hardcoded external URL could be blocked by Content Security Policy (CSP) configurations.

Suggested change
const imgUrl = imgInode ? `/dA/${imgInode}/asset/500w/50q/` : "https://placehold.co/600x400";
const imgUrl = imgInode
? `/dA/${imgInode}/asset/500w/50q/`
: "data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='600'%20height='400'%3E%3Crect%20width='100%25'%20height='100%25'%20fill='%23cccccc'/%3E%3C/svg%3E";

Copilot uses AI. Check for mistakes.
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #606770;
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

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

The color property is being added as a duplicate. The #cardHost selector already has 'color: #606770;' defined on line 61, making this addition on line 67 redundant. Additionally, the PR description states this change is for the "OG preview description", but this style rule applies to #cardHost, not #cardDescription. Either the duplicate should be removed or if the intent was to style #cardDescription, the wrong selector is being modified.

Suggested change
color: #606770;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[TASK] Migrate "Pages" VTLs to new API

3 participants