I have a div
with contenteditable=true
and bind:textContent={value}
so it behaves pretty much like a textarea.
The only issue I have with it is that I want to override the content of the div
by processing the value
, but seems like it is not possible.
To test I wrote this
<div contenteditable="true" bind:textContent={value}>testVal</div>
where value
is an exported property of the component.
I kind of expected value
to be set to testVal
, but instead the div contains the value
property.
I sort of understand why this is happening and that what I am doing is sort of an edge case, but is it at all possible to change this behaviour to kind of get a one way binding to value
?
and I have tried my "normal" way of creating a one way binding (with some hacks to demonstrate issues):
<div contenteditable="true" on:input={e => value = e.target.textContent}>
{#each (value || "").split("") as part}
{part}
{/each}
</div>
this looks fine, but whenever I change type in the div my input gets multiplied, i.e. if I type e
the div gets updated with ee
. If I add another e
I get eeee