You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

  1. <template lang="pug">
  2. extends ../annotation.pug
  3. block annotation-area
  4. div.card
  5. header.card-header
  6. div.card-header-title.has-background-royalblue
  7. div.field.is-grouped.is-grouped-multiline
  8. div.control(v-for="label in labels")
  9. div.tags.has-addons
  10. a.tag.is-medium(
  11. v-shortkey.once="[ label.shortcut ]"
  12. v-bind:style="{ \
  13. color: label.text_color, \
  14. backgroundColor: label.background_color \
  15. }"
  16. v-on:click="annotate(label.id)"
  17. v-on:shortkey="annotate(label.id)"
  18. ) {{ label.text }}
  19. span.tag.is-medium {{ label.shortcut }}
  20. div.card-content
  21. div.content(v-if="docs[pageNumber] && annotations[pageNumber]")
  22. annotator(
  23. v-bind:labels="labels"
  24. v-bind:entity-positions="annotations[pageNumber]"
  25. v-bind:text="docs[pageNumber].text"
  26. v-on:remove-label="removeLabel"
  27. v-on:add-label="addLabel"
  28. ref="annotator"
  29. )
  30. </template>
  31. <style scoped>
  32. .card-header-title {
  33. padding: 1.5rem;
  34. }
  35. </style>
  36. <script>
  37. import { demoNamedEntity } from './demo_data';
  38. import annotationMixin from './demo_mixin';
  39. import Annotator from './demo_annotator.vue';
  40. export default {
  41. components: { Annotator },
  42. mixins: [annotationMixin],
  43. data: () => ({ ...demoNamedEntity }),
  44. methods: {
  45. annotate(labelId) {
  46. this.$refs.annotator.addLabel(labelId);
  47. },
  48. addLabel(annotation) {
  49. this.annotations[this.pageNumber].push(annotation);
  50. },
  51. },
  52. };
  53. </script>