openui / open-ui

Maintain an open standard for UI and promote its adherence and adoption.
https://open-ui.org
Other
3.52k stars 191 forks source link

[invokers] setRangeText for textarea and inputs #1062

Open johannesodland opened 3 months ago

johannesodland commented 3 months ago

Similar to stepUp and stepDown it would be helpful to be able to invoke setRangeText to insert a string into a textarea or an input. This would require being able to pass an argument, perhaps through the value attribute.

Example:

<button invoketarget=textarea invokeaction=setRangeText value="«">«</button>
<button invoketarget=textarea invokeaction=setRangeText value="»">»</button>
<label for=textarea>Enter your text here:</label>
<textarea id=textarea>
  It was a dark and stormy night...
</textarea>
Original text Similar to [`stepUp` and `stepDown`](https://github.com/openui/open-ui/issues/968) it would be helpful to be able to invoke setRangeText to insert a string into a textarea or an input. This would require being able to pass an argument, perhaps through a separate attribute such as `invokeargument`. Example: ```html ```

Motivation

Some UTF characters are incredibly hard to enter. If and how the user can input them depend on the users operating system, user agent and input device.

In example: As a Norwegian publisher we strive to use the correct punctuation marks. Some of the punctuation marks such as the guillemet («») quotation marks are not even available on the Norwegian keyboard. Entering the correct characters requires using keyboard combinations that are difficult to remember. Being able to provide shorthand buttons to input these characters without JS would be very helpful.

lukewarlow commented 3 months ago

Instead of invokeargument we could use the value attribute from the button?

I'm hesitant to overload invokers too much but this could be a nice addition, worth considering at least.

johannesodland commented 6 days ago

Instead of invokeargument we could use the value attribute from the button?

That sounds like a much better idea. I've updated the issue text to use the value attribute.

🙏