Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 29, 2025

  • Initial analysis of Rich Text widget for character count feature
  • Add character count options to Rich Text widget status bar
  • Add comprehensive unit tests for character count functionality
  • Add unreleased changelog description for character count feature
  • Fix lint error by updating onTextChange callback to include calculateCounts in dependencies
  • Rebase onto master and resolve merge conflicts

The Rich Text widget now provides character count options in addition to the existing word count, addressing the validation mismatch between user input and HTML storage.

Problem Solved

Previously, users experienced confusing validation failures when Rich Text content exceeded database attribute limits:

User types: "Hello" (5 characters)
Rich Text stores: "<p>Hello</p>" (12 characters)
Database limit: 10 characters → Validation fails!

This left users puzzled why their short text was rejected.

Solution

Added a new statusBarContent property with four display options:

  • wordCount - Original word count (default, maintains backward compatibility)
  • characterCount - Character count of visible text only
  • characterCountHtml - Character count including HTML markup (matches database storage)
  • both - Both word count and character count

Implementation Details

The feature calculates counts using:

  • Word count: quill.getText().trim().split(/\s+/).length
  • Character count (text): quill.getText().length
  • Character count (HTML): quill.getSemanticHTML().length

Status bar displays are conditionally rendered based on the selected option, with proper pluralization and clear labeling.

Benefits

  • Transparency: Users can see HTML character count to understand why validation might fail
  • Flexibility: Developers can choose appropriate display for their use case
  • User Experience: Clear feedback about content length in different contexts
  • Backward Compatible: Default behavior unchanged

This resolves the core issue where users couldn't understand validation failures due to the invisible HTML markup added by the rich text editor.

Fixes #1863.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Rich Text Widget (TinyMCE) – Need Character Count Option & Consistent Validation with Max Length Rich Text Widget: Add character count option and fix validation mismatch Aug 29, 2025
@Copilot Copilot AI requested a review from gjulivan August 29, 2025 10:00
Copilot finished work on behalf of gjulivan August 29, 2025 10:00
@gjulivan
Copy link
Collaborator

@copilot please add unreleased changelog description

Copy link
Contributor Author

Copilot AI commented Aug 29, 2025

@copilot please add unreleased changelog description

Added unreleased changelog entry for the character count feature in commit ab72a73. The entry describes how the new status bar content options help users understand content length requirements and avoid validation failures.

Copilot finished work on behalf of gjulivan August 29, 2025 11:16
@gjulivan
Copy link
Collaborator

@copilot please fix lint error that is shown on the check.

Copy link
Contributor Author

Copilot AI commented Aug 29, 2025

@copilot please fix lint error that is shown on the check.

Fixed the lint error in commit 7314aa1. The issue was in the onTextChange callback where I added the calculateCounts function call but forgot to include it in the dependency array, causing a React hooks exhaustive deps warning. I've updated the dependency array to include calculateCounts which resolves the linting issue.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.sheetjs.com
    • Triggering command: node /usr/local/bin/pnpm install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of gjulivan August 29, 2025 12:11
@gjulivan
Copy link
Collaborator

gjulivan commented Sep 7, 2025

@copilot please rebase and resolve conflict

Copy link
Contributor Author

Copilot AI commented Sep 7, 2025

@copilot please rebase and resolve conflict

I've successfully rebased the branch onto master and resolved the merge conflicts that were encountered:

  1. Resolved conflict in RichTextProps.d.ts: Merged the new StatusBarContentEnum type with the existing FormOrientationEnum type from master
  2. Resolved conflict in CHANGELOG.md: Properly organized the unreleased character count feature entry above the existing 4.9.0 release

The rebase was completed in commit b8242ae. The branch is now ready but will need a force push to update the remote branch since the commit history has been rewritten during the rebase process.

Copilot finished work on behalf of gjulivan September 7, 2025 15:03
@gjulivan gjulivan changed the title Rich Text Widget: Add character count option and fix validation mismatch [WC-3094] character count on status bar, file upload bug fix, and default fonts Sep 10, 2025
@gjulivan gjulivan marked this pull request as ready for review September 10, 2025 12:45
@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 12:45
@gjulivan gjulivan requested a review from a team as a code owner September 10, 2025 12:45
Copy link

@Copilot 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 PR adds character count functionality to the Rich Text widget's status bar, fixes an image upload bug, and adds default font configuration options. The changes address validation mismatches between user-visible content and HTML storage by providing multiple display options for content length tracking.

Key changes:

  • Added character count options to status bar (text-only, HTML-inclusive, and combined views)
  • Fixed image dialog prop passing to resolve upload functionality issues
  • Added default font family and size configuration properties

Reviewed Changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
mxTheme.ts Refactored font constants to instance properties and added methods to update default fonts
package.xml Version bump to 4.10.0
ImageDialog.tsx Modified props interface to make enableDefaultUpload optional
Dialog.tsx Updated props interface and fixed prop passing to ImageDialog component
EditorWrapper.tsx Added character count calculation logic and default font handling
Editor.tsx Fixed missing props passed to Dialog component
useEmbedModal.ts Removed image-related props from hook parameters
RichText.spec.tsx Added unit tests for character count functionality
RichText.xml Added new XML properties for status bar content and default fonts
package.json Version bump and added new dependency
CHANGELOG.md Added unreleased section documenting new features and fixes
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WC-3094] character count on status bar
2 participants