Skip to content

feat(web): HTML normalization#630

Merged
hejsztynx merged 12 commits into
mainfrom
@ksienkiewicz/feat-use-html-normalizer
Jun 18, 2026
Merged

feat(web): HTML normalization#630
hejsztynx merged 12 commits into
mainfrom
@ksienkiewicz/feat-use-html-normalizer

Conversation

@hejsztynx

@hejsztynx hejsztynx commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Web implementation was missing the HTML normalizer

  • implemented the normalizer, mirroring the one in the native code
  • tests also mirror the native ones

Test Plan

Try pasting styled text from Google Docs, MS Word or any other platform

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@hejsztynx hejsztynx force-pushed the @ksienkiewicz/feat-use-html-normalizer branch from cfdc0da to bd0bdef Compare June 9, 2026 12:32
Comment thread yarn.lock
@hejsztynx hejsztynx marked this pull request as draft June 10, 2026 13:47
@hejsztynx hejsztynx marked this pull request as ready for review June 11, 2026 09:01

Copilot AI 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.

Pull request overview

Adds a web-side HTML normalization pipeline for pasted/inserted HTML so TipTap receives canonical enriched HTML (mirroring the existing native Gumbo-based normalizer), and wires it behind the useHtmlNormalizer flag.

Changes:

  • Implemented src/web/htmlNormalizer.ts (DOM-based HTML normalizer mirroring native behavior) and hooked it into the web TipTap input pipeline.
  • Added a Jest “web” project (jsdom environment) and a web test suite ported from the native C++ normalizer tests.
  • Updated docs and the example web app to expose/enable useHtmlNormalizer.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
yarn.lock Adds jsdom/jest-environment-jsdom related dependency graph for web tests (currently pulls Jest 30 internals).
package.json Adds jsdom test dependencies and splits Jest config into native + web projects.
src/web/tiptapHtmlNormalizer.ts Adds optional call into the new normalizer before existing checkbox/
handling.
src/web/htmlNormalizer.ts New DOMParser-based HTML normalizer implementation for web.
src/web/EnrichedTextInput.tsx Enables normalization on paste via transformPastedHTML and for defaultValue/setValue.
src/web/tests/htmlNormalizer.test.ts New Jest tests ported from native GumboParser tests.
docs/WEB.md Documents that useHtmlNormalizer is supported on web.
docs/INPUT_API_REFERENCE.md Updates platform matrix for useHtmlNormalizer to include Web.
apps/example-web/src/App.tsx Enables useHtmlNormalizer in the web example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment thread src/web/normalization/htmlNormalizer.ts

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/web/normalization/tiptapHtmlNormalizer.ts:13

  • prepareHtmlForTiptap applies normalizeHtml() to all incoming HTML when useHtmlNormalizer is truthy. On native, the HTML normalizer is only intended for external HTML; internal enriched HTML (the library’s own <html>…</html> format) is parsed directly and only falls back to normalization on parse failure. Normalizing internal HTML here will drop non-canonical attributes (e.g. <mention … type="user">…</mention>), which can break existing behavior/tests that rely on those attributes being preserved when setting content programmatically.

@kacperzolkiewski kacperzolkiewski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall solid, and works fine!

Comment thread src/web/normalization/htmlNormalizer.ts
@hejsztynx hejsztynx merged commit 6723ce9 into main Jun 18, 2026
7 checks passed
@hejsztynx hejsztynx deleted the @ksienkiewicz/feat-use-html-normalizer branch June 18, 2026 18:45
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.

4 participants