-
Hi guys, I want to implement drag and drop for the TextArea component. <TextArea
onDragOver={ev => {
ev.preventDefault();
}}
onDrop={ev => {
ev.preventDefault();
const data = ev.dataTransfer.getData("text/plain");
//...how to continue her? How to place 'data' into the textarea at the wished position (carret)?
}}
onDragEnd={ev => {
ev.preventDefault();
}}
/> I get the data but how can i set the caret position or let the TextArea insert the dropped text? Please excuse the bad formatting. I tried dfferent ways to format the source code in a good way. How can I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Hi @pop1989bb I'm not entirely sure what you're trying to achieve. Could you please create an example using this stackblitz template? This way it's easier for us to assist you.
You can use a single backtick for code formatting inside a text, or three backticks for a code-block. You can find out more about this here. |
Beta Was this translation helpful? Give feedback.
-
Hi @Lukas742, |
Beta Was this translation helpful? Give feedback.
-
Hi @pop1989bb inserting a text at the current cursor position via drag and drop is not easily achievable. Most probably you'll need some calculations based on cursor position, fontSize, lineHeight, etc. The same goes for native The Since the |
Beta Was this translation helpful? Give feedback.
-
Hi @Lukas742 , |
Beta Was this translation helpful? Give feedback.
-
Hi @Lukas742 , did work as expected. Thank you for the solution. Will create a feature request. |
Beta Was this translation helpful? Give feedback.
Hi @pop1989bb
inserting a text at the current cursor position via drag and drop is not easily achievable. Most probably you'll need some calculations based on cursor position, fontSize, lineHeight, etc. The same goes for native
textarea
elements.The
ui5-textarea
component doesn't expose theselectionStart
property, so if you feel like this should be possible, please open a feature request in the ui5-webcomponents repo, since the component is developed there.Since the
ui5-textarea
uses atextarea
internally, it's still possible to read theselectionStart
property, although you'll have to access theshadowRoot
for this. I've created an example of an implementation that inserts the text at …