JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › General Discussions › Smart.Editor
Tagged: gems
- This topic has 5 replies, 3 voices, and was last updated 1 year ago by milywills.
-
AuthorPosts
-
July 17, 2023 at 9:21 pm #107481CatdokenParticipant
I am looking into using the Smart.Editor component as a potential replacement for our text editor. Is there a way to programmatically set the following?
- Enter key writes newline (br) to the editor rather than a paragraph (p). Shift+Break works as expected, but it will be easier on our users to use Enter.
- Text characters typed are uppercase; never lowercase.
Before looking at ways to programmatically (or use CSS) handle this on our own I’d like to check here first. Are there any options I may have missed in setting up the Editor or established ways to accomplish this that are built into the code base?
Thanks!
July 18, 2023 at 11:53 am #107490ivanpeevskiParticipantHi Catdoken,
Thanks for the interest in our products!
At the moment, we do not have built-in properties to achieve these, however they can also be implemented programmatically with some additional code:
- You can overwrite the default behavior of theĀ editor by handling the ‘keydown’ event and calling event.preventDefault()
- The text-transform: uppercase CSS rule will automatically transform all characters to uppercase. However the change is only visual, so when you receive the Editor value you should also add a toUpperCase call to change its value
Here is an example with both functionalities implemented: codepen
Best Regards,
Ivan Peevski
Smart UI Team
https://www.htmlelements.com/</span>July 18, 2023 at 1:58 pm #107494CatdokenParticipantHi Ivan,
Thanks for the response.
For keydown I did try stopping the event and instead sending a new one that was Shift+Enter via dispatchEvent, but that did not work. I got a response from the editor (onChanging) but with no actual change to the text when looking at oldValue/newValue. I did not try your implementation of creating the text node manually. I’ll give that a shot.
Thanks!
July 20, 2023 at 8:08 pm #107502CatdokenParticipantIvan,
A quick question if you have time – is it possible to paste text copied from a primitive editor, such as notepad, into the editor and have it retain its format instead of all one line?
For example:
FIRST LINE
SECOND LINEI tried setting editmode to markdown which addresses the Enter key question earlier as well as handles the paste as we were hoping. It does handle styling differently which was expected. It may be it is not possible to have the best of both – styling ability + paste like markdown.
Thanks!
July 21, 2023 at 5:50 am #107504CatdokenParticipantAs an update I am hijacking the paste event and inserting text into the editor manually. Was hoping to not have to do that, but its no problem. There are a few ways the editor can handle paste events and was not sure if there is a setting to use for this looking at the examples provided.
Thanks for your time.
November 4, 2023 at 11:27 am #109117milywillsParticipantgood
-
AuthorPosts
- You must be logged in to reply to this topic.