d-i-t-a / R2D2BC

https://d-i-t-a.github.io/R2D2BC/
Apache License 2.0
52 stars 34 forks source link

Possibility to customize highlighter color via API #855

Open MooDySmiles opened 7 months ago

MooDySmiles commented 7 months ago

Hi, I would like to customize the color of the highlighter via an API in the D2Reader instance, something akin to a changeHighlighterColor function.

Upon reviewing the code, I didn’t find anything that would allow me to choose a set of colours for text highlighting besides the one that’s hardcoded: the highlight-toolbox-mode-colors div accessible via the colorIcon icon in the toolbox.

My suggestion would be (and I would gladly open a MR myself) to add something like the following in the reader.ts file

const changeHighlighterColor = (color: string) => {
    this.highlighter?.setColor(color);
};

This would address my specific use case. However, further work in the TextHighlighter.ts file could be done to reflect the change of the highlighter color, and subsequently, the color which the highlightIcon, underlineIcon and noteIcon in the TextHighlighter.ts file are painted.

aferditamuriqi commented 6 months ago

@MooDySmiles you can already change the highlighter color to other options. Please run the samples and you should see how that is done. if further questions, please provide more details why the extisting options do not work for you

MooDySmiles commented 6 months ago

@aferditamuriqi what I see from the examples is that I can change the highlight color among a predefined set of colors (shown in the image attached and defined in the initializeToolbox function in the TextHighlighter.ts file), which I would like to override with a set of colors decided by me

Screenshot 2024-04-29 alle 14 43 49

I looked for an API which would allow me to reach my goal but didn't find one

MooDySmiles commented 6 months ago

Any more follow ups?