-
Notifications
You must be signed in to change notification settings - Fork 269
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Problem
<div contenteditable>
is now widely adopted as the way to make Rich text editors on the web. I've noticed that we cannot set the value of these elementes using .setValue
as it throws an error, and have to resort to manual workarounds.
Solution
when field.setValue
is applied and field is <div contenteditable>
element, internally VTU should override Element
s textContent
or innerHTML
prop, depending on the value of attribute value is plaintext-only
or 'true'. Since this is not widely supported, just going with innerHTML
is probably easier.
Lines 125 to 131 in 05f76b6
} else if (tagName === 'INPUT' || tagName === 'TEXTAREA') { | |
element.value = value | |
this.trigger('input') | |
// trigger `change` for `v-model.lazy` | |
return this.trigger('change') | |
} else { |
else if (this.attributes().contenteditable) {
element.innerHTML = value
this.trigger('input')
// trigger `change` for `v-model.lazy`
return this.trigger('change')
}
Additional context
- https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable
- Not sure if being to naive or not and overlooking something. Let me know!
Cheers ✌️
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers