What to do with "unknown colors" showing up from external HTML

Open
#2,181 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Reproduce the initialContent example and trace the block property validation path, including the Zod props parsing introduced by PR #2096 and the external HTML path from PR #2179. Add a focused regression test for unsupported textColor and backgroundColor values; the issue is done when the chosen validation behavior is consistent for both input paths.

Written by the indexing model from the issue text.

Description

bug:P4

Describe the bug

When pasting in external HTML (or setting it via an initial document JSON). There can be textColor or backgroundColor which is a value other than the color names which we already support (e.g. red, blue, etc).

This is originally found to be an issue with this PR: https://github.com/TypeCellOS/BlockNote/pull/2179

To Reproduce

initialContent={ [ { type: "paragraph", props: { textColor: "rgba(0, 0, 0, 0.5)" } } ] }

By explicitly setting the textColor to an invalid value, it is preserved in the document when it should likely be stripped as invalid? Perhaps the zod props parsing introduced by https://github.com/TypeCellOS/BlockNote/pull/2096 will resolve this issue?

Misc

  • Node version: N/A
  • Package manager: N/A
  • Browser: N/A
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖
Dominant language
TypeScript
Stars
10.2k
Forks
772
Avg merge
3d 11h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TypeCellOS/BlockNote

All issues in TypeCellOS/BlockNote

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.