-
Notifications
You must be signed in to change notification settings - Fork 3
Update editor to use modelValue for Vue 3 #4
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
Conversation
| ); | ||
| this.editor.onDidChangeModelContent(() => { | ||
| this.$emit("update:modelValue", this.editor.getValue()); | ||
| this.$emit("input", this.editor.getValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A solution for the double input event call would be to remove it in favor of just using the modeValue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To skip the double update, just keep the last sent value in a local var and just skip the emit if same as before.
this.editor.onDidChangeModelContent(() => {
const newValue = this.editor.getValue();
if (this.lastValue === newValue) {
return;
}
this.lastValue = newValue;
this.$emit("update:modelValue", newValue);
this.$emit("input", newValue);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to occur...
I set input="console.log($event)", and in the console it first prints the contents then and InputEvent.
|
Thanks for the PR but now you are removing vue2 compatibility with v-model. Can you keep both |
Closes #3
Fixes value not being 2-way bound, does not fix
inputbeing triggered twice.Tested here.
chrome_IO5KxNLy4e.mp4