TiddlyWiki5 icon indicating copy to clipboard operation
TiddlyWiki5 copied to clipboard

[BUG] Colour-input should show a default if colour is defined by a <<colour macro

Open pmario opened this issue 2 years ago • 3 comments

Describe the bug

Try this code:

<$edit-text tiddler=test-colour index=colour-1 type="color" tag="input" class="tc-palette-manager-colour-input" default="#ff0000"/>     
  • If tiddler "test" doesn't exist the colour input shows the default colour. -> OK
  • If the the "colour-1" index doesn't exist it shows the default colour. -> OK
  • If "colour-1" is an empty value it shows "black" -> OK
  • If "colour-1" is <<colour xxx>> .. it also shows balck. -> should be fixed

Expected behavior

Instead of "black" if a macro call is used, it should try to resolve the colour macro, if there is <<colour yy>>

There should be a new parameter eg: "valueFilter" that allows us to overwrite the the used value. eg:

<$edit-text tiddler=test-colour index=colour-1 type="color" tag="input" class="tc-palette-manager-colour-input" default="#ff0000" valueFilter="[prefix[<<colour ]then<default>]"/>     

So if it would read <<colour something it would use the provided "default" parameter.

If there is no "default" parameter, the "valueFilter" should be ignored.

TiddlyWiki Configuration

v5.2.3-pre

Additional context

The problem is probably related to my comment: https://github.com/Jermolene/TiddlyWiki5/pull/6377#issuecomment-1055575225 at: Extend the EditTextWidget and fields to allow Date-Pickers and other tags #6377

So we may create a new color-input widget, which only serves this 1 purpose

pmario avatar Sep 09 '22 12:09 pmario

Fixing this problem will be a huge win for the $:/PaletteManager, which I try to improve atm

pmario avatar Sep 09 '22 12:09 pmario

Hi @pmario the correct way to resolve the existing value of a colour that has been set via the <<colour x>> macro would be to wikify the macro to obtain a CSS colour. Matching the specific <<colour call is unduly restrictive; our architecture allows for colours to be set via user defined macros, not just the <<colour> macro.

Jermolene avatar Sep 09 '22 15:09 Jermolene

Hi @pmario the correct way to resolve the existing value of a colour that has been set via the <> macro would be to wikify the macro to obtain a CSS colour.

Yea, but that's not possible, because the edit widgets gets the "tiddler" and "index" parameter and only uses the "default" value if one of them is missing. So there is no way to feed the wikified colour.

Matching the specific <<colour call is unduly restrictive; our architecture allows for colours to be set via user defined macros, not just the < macro.

The parameter is a filter and <<colour is just an example. The filter input will define the condition, when the "default" parameter will be used. So it's 100% user definable.

pmario avatar Sep 09 '22 18:09 pmario

Close this one in favour of: https://wikilabs.github.io/editions/palette-manager/

pmario avatar Nov 23 '22 13:11 pmario