-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bind:innerText for contenteditable #3311
Comments
I would love to take on this issue! If possible, could someone direct me to where I would need to look to get started here? |
I think this binding would apply to non |
@himynameisdave I think it makes no sense to bind to non contenteditable elements. The idea is to have user input inside contenteditable elements synced with the local state. That's what bind is for. Please check the docs (https://svelte.dev/docs#bind_element_property). |
@khorpy yep fair point, I'll be sure to only apply it to |
@khorpy I'm having some slight issues testing this, would you mind providing some examples of the expected values you'd be getting from |
I can't wait to be able to use this new feature Is there any known workaround for the time being? |
@josdejong not sure about workarounds, but if you could provide some test cases with |
Just to explain a bit about my use case: I'm currently working on a proof-of-concept of svelte-jsoneditor written in Svelte (my way to learn Svelte). In this editor, I need input fields which automatically fit their contents. For that reason, I'm using contenteditable divs and not a textarea for example. Unfortunately there is no simple way to keep multiline plain text in sync with the contents of an contenteditable div. What comes closest is I hope this new feature Here is a small test playground I was using a few days ago to debug issues with |
Beyond the missing binding, I have the impression that there are some bugs with I tried to isolate a minimal example here: In this demo, a single store containing markdown is used in 3 editors (one HTML, two instances of markdown). Editing the HTML view does trigger updates to the other editors, but editing the markdown only updates the other markdown. This is despite logs showing proper updates to the store. Also, when rapidly editing text, some substrings get copied erroneously (probably what you mention @josdejong). I tried some other bindings methods (in other branches) to no avail. Edit: I updated the repo with a simpler example (without immer and multiple editors), which shows the two different problems: 1. updating the store does not re-render the rich text editor and 2. editing the markdown adds extra characters (using |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I would like to give it a try if this issue is still unresolved. |
There's a open PR for this: #4291 . You could test that one out and provide feedback. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
closes #3311 --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
This is now supported in 3.58.0. |
There is already bind:innerHTML and bind:textContent implemented for elements with contenteditable="true". But there is also a third property that is also would nice to have: bind:innerText.
InnerText approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard
The text was updated successfully, but these errors were encountered: