Skip to content

Conversation

@MichaelMarner
Copy link

@MichaelMarner MichaelMarner commented Oct 23, 2025

Description

Adds support for handling web named colors.

Quill deltas often contain named colors from the standard HTML color palette. This is especially true if the delta was created using Quill on web. These named colors could not be handled by flutter_quill, and so an exception was thrown when rendering the delta.

This change adds constants for the 140 named web colors, based on the list here: https://github.com/vincevargadev/kolors_flutter/blob/main/lib/kolors.dart

I've also added values for the obsolete CSS2 system colors, such as windowtext. We have seen these show up when our users paste text from Microsoft Word into Quill on web. W3C recommends using a default value for these colors.

Finally, modifies stringToColor to check if the input is one of the named colors, and returns the value if found, and adds tests.

One thing I did notice is that the existing code in stringToColor returns a MaterialColor for common colors like red, yellow, etc. However these are not always the same value as expected in web - eg MaterialColor.yellow is not 0xffffff00. I don't think that really matters here though.

Related Issues

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

@MichaelMarner MichaelMarner force-pushed the 2586-support-html-colors branch 3 times, most recently from 3ad08d0 to 5a4449b Compare October 23, 2025 00:59
Quill deltas often contain named colors from the standard HTML color palette. This is especially true if the delta was created using Quill on web.

These named colors could not be handled by flutter_quill, and so an exception was thrown.

This change adds dart contants for the 140 named html colors. It modifies `stringToColor` to check if the input is one of the named colors, and returns the value if found. Web colors are case insensitive.
@MichaelMarner MichaelMarner force-pushed the 2586-support-html-colors branch from 5a4449b to 768f84d Compare October 23, 2025 01:01
System colors that were part of the CSS2 spec, but have since been removed. However, they show up when pasting text from Microsoft software like Word into Quill on web.
@MichaelMarner MichaelMarner force-pushed the 2586-support-html-colors branch from 124436c to 4a14878 Compare October 23, 2025 01:24
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.

Got "Unsupported operation: Color code not supported" issue when Delta using color name instead of hex

1 participant