Comments (1)
I tried this workaround and it seems to work.
<wysiwyg
v-model="value"
v-model="editorContent"
:class="{
'editr--toolbarless': !showToolbar,
'editr--wraptoolbar': wrapToolbar,
}"
:placeholder="placeholder"
@change="onUpdate"
/>
data() {
return {
content: this.value,
editorContent: '',
};
},
watch: {
value() {
// on value change, update the content
this.content = this.getDocumentFromHTMLString(this.value);
this.editorContent = this.content.body.innerHTML;
},
},
mounted() {
this.content = this.value;
// Parse initial content to a dom document
this.content = this.getDocumentFromHTMLString(this.value);
// Set initial editor's content to only it's body innet html
this.editorContent = this.content.body.innerHTML;
this.$nextTick(() => {
if (this.type) {
const element = this.$el.querySelector('.editr--content');
element.dataset.type = this.type;
}
});
},
methods: {
onUpdate(value) {
this.$emit('input', value);
onUpdate(newValue) {
// Update the reference body innerHTML
this.content.body.innerHTML = newValue;
// Emmit the entire HTML
this.$emit('input', this.content.documentElement.outerHTML);
},
getDocumentFromHTMLString(string) {
const parser = new DOMParser();
return parser.parseFromString(string, 'text/html');
},
},
};
</script>
from vue-wysiwyg.
Related Issues (20)
- Localization: missing translations HOT 1
- wysiwig editor can't handle :value HOT 2
- Locales not working HOT 4
- Bug Fixes on The Master/Release HOT 1
- Add header token to request
- Using wysiwyg component locally HOT 1
- Clear format does not work HOT 3
- Open Link in new Tab HOT 2
- Compatibility with vuejs3 ?
- Moving the project forward HOT 2
- New table form rows and cols inputs doesn't work HOT 1
- How to test the build local
- I would like to be able to pass tabindex in
- Editor Doesn't Get Focus Back After Clicking Button
- Nuxt support HOT 1
- Cannot add a rows and cols table
- restrict tags
- Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '_c') HOT 2
- Disable/Readonly Textarea
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-wysiwyg.