Search code examples
textareablazorblazor-webassembly

Blazor get selected text from textarea and make it bold/italic/hyperlink


Is there any way to get selected text from textarea and make it bold/italic/hyperlink in Blazor WebAssembly? Or it should be done using javascript?


Solution

  • You can't have HTML content in a textarea element which means you can't do what you want even with JavaScript. The rich editors you see in forums and sites use different elements and quite a bit of JavaScript.

    You'll have to use such a text editor, either directly through JavaScript or a wrapper like Blazored TextEditor which works on top of Quil.js. All commercial component vendors have their own rich text editor components as well.

    Check the Awesome Blazor page for a list of components, component bundles and tutorials.