editor.js 760 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. export default {
  2. template: `
  3. <q-editor
  4. ref="qRef"
  5. v-bind="$attrs"
  6. v-model="inputValue"
  7. >
  8. <template v-for="(_, slot) in $slots" v-slot:[slot]="slotProps">
  9. <slot :name="slot" v-bind="slotProps || {}" />
  10. </template>
  11. </q-input>
  12. `,
  13. props: {
  14. value: String,
  15. },
  16. data() {
  17. return {
  18. inputValue: this.value,
  19. emitting: true,
  20. };
  21. },
  22. watch: {
  23. value(newValue) {
  24. this.emitting = false;
  25. this.inputValue = newValue;
  26. this.$nextTick(() => (this.emitting = true));
  27. },
  28. inputValue(newValue) {
  29. if (!this.emitting) return;
  30. this.$emit("update:value", newValue);
  31. },
  32. },
  33. methods: {
  34. updateValue() {
  35. this.inputValue = this.value;
  36. },
  37. },
  38. };