stylus icon indicating copy to clipboard operation
stylus copied to clipboard

Textarea @var config type

Open Xuerian opened this issue 2 years ago • 4 comments

Use case:

  • Entering a list of items

For example, https://userstyles.world/style/9719 provides a 'text' var to generate a set of title match rules. Using 'text' means that list looks like 'Game Name 1, Game Name 2, Game Name 3' in a small single line entry.

From what I could tell, supporting a textarea type would be the most expedient way to improve this situation.

I tried to do it myself and got some of the way there, but could not wrap my head around the parser rules and how to handle an unquoted list with newlines. I might be able to finish it if there was some reference for that I could read or explanation of the surrounding system.

Side note, I didn't even know style var/configs existed before now, that's cool.

Xuerian avatar Aug 03 '23 20:08 Xuerian

I think a more universal/compatible solution is to always show a textarea in the config and a button nearby that opens it in a new bigger modal. It'll support and preserve linebreaks, which in other userstyle extensions would be converted into normal whitespace by the <input> element automatically.

@eight04?

tophf avatar Dec 27 '24 18:12 tophf

It'll support and preserve linebreaks

This may break the compiler. The compiler probably won't work with variables containing \n.

eight04 avatar Dec 28 '24 08:12 eight04

Well, then we'll save them in an escaped form or by replacing with some special character so that it doesn't break other tools/extensions.

tophf avatar Dec 28 '24 12:12 tophf

OTOH this seems to be already handled correctly in usercss-meta: parseStringToEnd calls unquote() that unescapes as well.

tophf avatar Dec 28 '24 12:12 tophf