Skip to content

fix: clean pasted Google Docs formatting in CFP editors - #1168

Open
ako3131 wants to merge 8 commits into
masterfrom
fix/rich-text-paste
Open

ako3131 wants to merge 8 commits into
masterfrom
fix/rich-text-paste

Conversation

@ako3131

@ako3131 ako3131 commented Nov 20, 2026 •

Copy link
Copy Markdown

ref: https://app.clickup.com/t/9014802374/1k5eh57927p

  • Pasting from Google Docs into CFP rich-text fields now keeps bullets, bold, italic, underline and links, and drops the hidden styling that pushed descriptions over the API length limit (category description, category group description, submission disclaimer, CFP settings message)
  • Word pastes use Jodit's built-in cleaner
  • Category description now warns before saving when it's over 1500 characters, and says the count includes formatting

Up next (follow-up PRs)

  • Keep table boundaries when pasting (alignment is kept in this PR)
  • Word bullet and numbered lists: they paste as plain paragraphs with a "·" marker for now. Check whether Jodit Pro's Word paste handles them before writing our own conversion

@ako3131
ako3131 requested a lite review from Copilot November 20, 2026 23:53
@ako3131 ako3131 self-assigned this Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f5b444b-79fb-4235-bfb5-13b02eb56670
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A critical active-content injection issue remains in src/utils/methods.js because unsanitized href and src URLs can preserve javascript: payloads that execute when the cleaned HTML is rendered.

1 open issue
What changed in this PR

This PR adds shared paste-cleaning behavior for CFP rich-text editors, preserving useful formatting from Google Docs and delegating Word cleanup to Jodit while removing excess markup. It also adds a 1,500-character validation message for event category descriptions.

Changes:

  • Added HTML cleanup utilities and shared Jodit paste options.
  • Applied paste cleaning to category, category-group, submission disclaimer, and CFP message editors.
  • Added the category description length constant, validation message, and utility tests.
File Description
src/​utils/​methods.js Implements Google Docs HTML cleanup and shared Jodit paste options.
src/​utils/​constants.js Defines the category description length limit and bold-font threshold constants.
src/​utils/​__tests__/​methods.test.js Tests list cleanup, formatting conversion, and link preservation.
src/​i18n/​en.json Adds the category description HTML length validation message.
src/​components/​forms/​selection-plan-form/​main-tab.js Enables paste cleaning for the submission disclaimer editor.
src/​components/​forms/​selection-plan-form/​cfp-settings-tab.js Enables paste cleaning for the CFP settings message editor.
src/​components/​forms/​event-category-group-form.js Enables paste cleaning for category-group descriptions.
src/​components/​forms/​event-category-form.js Enables paste cleaning and 1,500-character validation for category descriptions.

Review effort: Lite

Comment thread src/utils/methods.js Resolved
Comment thread src/utils/methods.js Resolved
Comment thread src/utils/methods.js Resolved
@ako3131
ako3131 marked this pull request as ready for review November 24, 2026 18:50
@ako3131
ako3131 force-pushed the fix/rich-text-paste branch from da450c8 to 5d9811a Compare November 25, 2026 04:55
Comment thread src/utils/methods.js Resolved
Comment thread src/utils/methods.js Outdated
});
doc.body.querySelectorAll("li > p:only-child").forEach(unwrap);
doc.body.querySelectorAll("p").forEach((p) => {
if (!p.textContent.trim() && !p.querySelector("img, br")) p.remove();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This drops the blank lines from Word pastes. Word sends an empty line as <p class=MsoNormal><o:p>&nbsp;</o:p></p>, and .trim() strips the &nbsp;, so the paragraph gets removed and the spacing the author added between blocks is lost. Only the Google Docs form (<p><br></p>) survives, which is the only case the "keeps blank lines" test covers. Checking for &nbsp; before trimming (or turning those paragraphs into <p><br></p>) would keep them; a test with a Word blank line would cover it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok, made this change. I also noticed that word bullets/numbered lists get replaced by a fake bullet. I will look at this in a follow up since usually Mark pastes from google docs.

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