AppEditor.vue 814B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <script setup>
  2. import { computed } from 'vue'
  3. const props = defineProps({
  4. label: {
  5. type: String,
  6. required: true,
  7. },
  8. error: {
  9. type: String,
  10. default: null,
  11. },
  12. })
  13. const isError = computed(() => (props.error ? true : false))
  14. const ariaDescribedbyLabel = computed(
  15. () => props.label.toLowerCase().replace(/\s+/g, '-') + '-error'
  16. )
  17. </script>
  18. <template>
  19. <div class="field">
  20. <label v-if="label">{{ label }}</label>
  21. <Editor
  22. v-bind="$attrs"
  23. @text-change="$emit('update:modelValue', $event.htmlValue)"
  24. >
  25. <template #toolbar>
  26. <slot name="toolbar" />
  27. </template>
  28. </Editor>
  29. <small
  30. v-if="error"
  31. :aria-describedby="ariaDescribedbyLabel"
  32. :class="{ 'p-error': isError }"
  33. >
  34. {{ error }}
  35. </small>
  36. </div>
  37. </template>