Skip to content
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

Fix rich-contenteditor default value init and small code cleanup #1570

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/components/RichContenteditable/RichContenteditable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ export default {
const html = this.$refs.contenteditable.innerHTML
// Compare trimmed versions to be safe
if (this.value.trim() !== this.parseContent(html).trim()) {
const renderedContent = this.renderContent(this.value)
this.$refs.contenteditable.innerHTML = renderedContent
this.localValue = this.value
this.updateContent(this.value)
}
},
},
Expand All @@ -280,8 +278,7 @@ export default {
this.tribute.attach(this.$el)

// Update default value
const renderedContent = this.renderContent(this.value)
this.$refs.contenteditable.innerHTML = renderedContent
this.updateContent(this.value)

},
beforeDestroy() {
Expand Down Expand Up @@ -354,6 +351,16 @@ export default {
this.$emit('update:value', text)
},

/**
* Update content and local value
* @param {string} value the message value
*/
updateContent(value) {
const renderedContent = this.renderContent(this.value)
this.$refs.contenteditable.innerHTML = renderedContent
this.localValue = this.value
},

/**
* Because FF have a decade old bug preventing contenteditable=false
* to properly be deleted on backspace, we have to hack 👀
Expand Down