Codemirror-CSS-color-picker icon indicating copy to clipboard operation
Codemirror-CSS-color-picker copied to clipboard

Update extensible `makeColorPicker` factory and CSS parsers

Open krassowski opened this issue 1 year ago • 0 comments

Why

I created a JupyterLab extension which enables to use a color picker in languages other than CSS: https://github.com/krassowski/jupyterlab-color-picker

Instead of shipping a customized version of this package, I would love to depend on a new, more extensible version proposed by this changset.

Closes https://github.com/replit/Codemirror-CSS-color-picker/issues/22

What changed

No user-facing changes

  • a new makeColorPicker function allows to customise the discovery of colors from the syntax tree
  • the logic for parsing CSS colors from strings was decoupled from tree traversal logic and placed in three exported functions: parseCallExpression, parseColorLiteral and parseNamedColor, enabling re-use of these parsing functions
  • parseColorLiteral now includes a regex check to validate that correct hex color was passed
  • finally, I added a language argument to expose this information downstream.

Test plan

There should be no user-facing changes.

krassowski avatar Apr 13 '24 18:04 krassowski