AnnotationContent.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="annotation-view">
  3. <template v-if="annotationsContainers.annotationsCount > 0">
  4. <div v-for="(pageAnnotations, pageNumber) in annotationsContainers.annotations">
  5. <template v-if="pageAnnotations.pageAnnotationsCount > 0">
  6. <div class="page-title">
  7. <span>{{ $t('leftPanel.page') }} {{ pageNumber * 1 + 1 }}</span>
  8. <span>{{ pageAnnotations.pageAnnotationsCount }}</span>
  9. </div>
  10. <template v-for="(item) in pageAnnotations.annotations">
  11. <div v-if="!item.isDelete && item.type !== 'link'" class="annotation-item" @click="goToPage(item.pageIndex)">
  12. <div class="item-header">
  13. <Highlight v-if="item.type === 'highlight'" />
  14. <Squiggle v-else-if="item.type === 'squiggly'" />
  15. <Strikeout v-else-if="item.type === 'strikeout'" />
  16. <Underline v-else-if="item.type === 'underline'" />
  17. <Ink v-else-if="item.type === 'ink'" />
  18. <LineTool v-else-if="item.type === 'line' && (((item.tail === 'None' || item.tail === 'Unknown') && (item.head === 'None' || item.head === 'Unknown')) || (!item.tail && !item.head))" />
  19. <ArrowTool v-else-if="item.type === 'line' && (item.tail === 'OpenArrow' || item.head === 'OpenArrow' || item.arrow)" />
  20. <RectangleTool v-else-if="item.type === 'square'" />
  21. <EllipseTool v-else-if="item.type === 'circle'" />
  22. <Text v-else-if="item.type === 'freetext'" />
  23. <Note v-else-if="item.type === 'text'" />
  24. <Stamp v-else-if="item.type === 'image' || item.type === 'stamp'" />
  25. <span>{{ dayjs(item.createDate).format('DD/MM/YYYY HH:mm:ss') }}</span>
  26. </div>
  27. <div v-if="item.contents || item.content" class="item-content">{{ item.contents || item.content }}</div>
  28. </div>
  29. </template>
  30. </template>
  31. </div>
  32. </template>
  33. <div v-else class="no-annotations">{{ $t('leftPanel.noAnnotations') }}</div>
  34. </div>
  35. </template>
  36. <script setup>
  37. import { computed, ref, getCurrentInstance } from 'vue';
  38. import dayjs from 'dayjs'
  39. import core from '@/core'
  40. import { useDocumentStore } from '@/stores/modules/document'
  41. const useDocument = useDocumentStore()
  42. let annotationsContainers = computed(() => useDocument.getAllAnnotations)
  43. const markup = ['highlight', 'underline', 'squiggly', 'strikeout']
  44. const setAnnotationList = ({ annotations }) => {
  45. useDocument.initAnnotations(annotations)
  46. const instance = getCurrentInstance();
  47. instance?.proxy?.$forceUpdate();
  48. }
  49. core.addEvent('annotationChanged', setAnnotationList)
  50. const goToPage = (page) => {
  51. core.pageNumberChanged({
  52. value: (page * 1 + 1).toString()
  53. })
  54. }
  55. </script>
  56. <style lang="scss">
  57. .annotation-view {
  58. position: relative;
  59. height: calc(100% - 95px);
  60. overflow: auto;
  61. .page-title {
  62. display: flex;
  63. justify-content: space-between;
  64. padding: 6px 16px;
  65. color: var(--c-side-title);
  66. background-color: var(--c-side-annotation-bg);
  67. span {
  68. font-size: 14px;
  69. line-height: 20px;
  70. }
  71. }
  72. .annotation-item {
  73. padding: 4px 16px 12px;
  74. .item-header {
  75. display: flex;
  76. align-items: center;
  77. padding: 6px 0;
  78. color: var(--c-side-text);
  79. span {
  80. margin-left: 8px;
  81. font-size: 14px;
  82. line-height: 20px;
  83. }
  84. }
  85. .item-content {
  86. font-size: 14px;
  87. line-height: 20px;
  88. text-overflow: ellipsis;
  89. display: -webkit-box;
  90. -webkit-box-orient: vertical;
  91. -webkit-line-clamp: 2;
  92. overflow: hidden;
  93. color: var(--c-side-annotation-text);
  94. word-break: break-all;
  95. }
  96. }
  97. .no-annotations {
  98. position: absolute;
  99. top: 50%;
  100. left: 50%;
  101. transform: translate(-50%, 50%);
  102. color: var(--c-side-text);
  103. text-align: center;
  104. font-weight: 700;
  105. font-size: 14px;
  106. line-height: 16px;
  107. }
  108. }
  109. </style>