logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

emoji_picker.vue (5439B)


  1. <template>
  2. <Popover
  3. ref="popover"
  4. trigger="click"
  5. popover-class="emoji-picker popover-default"
  6. :trigger-attrs="{ 'aria-hidden': true, tabindex: -1 }"
  7. @show="onPopoverShown"
  8. @close="onPopoverClosed"
  9. >
  10. <template #content>
  11. <div class="heading">
  12. <!--
  13. Body scroll lock needs to be on every scrollable element on safari iOS.
  14. Here we tell it to enable scrolling for this element.
  15. See https://github.com/willmcpo/body-scroll-lock#vanilla-js
  16. -->
  17. <span
  18. ref="header"
  19. v-body-scroll-lock="isInModal"
  20. class="emoji-tabs"
  21. >
  22. <span
  23. v-for="group in filteredEmojiGroups"
  24. :ref="setGroupRef('group-header-' + group.id)"
  25. :key="group.id"
  26. class="button-unstyled emoji-tabs-item"
  27. :class="{
  28. toggled: activeGroupView === group.id
  29. }"
  30. :title="group.text"
  31. role="button"
  32. @click.prevent="highlight(group.id)"
  33. >
  34. <span
  35. v-if="group.image"
  36. class="emoji-picker-header-image"
  37. >
  38. <still-image
  39. :alt="group.text"
  40. :src="group.image"
  41. />
  42. </span>
  43. <FAIcon
  44. v-else
  45. :icon="group.icon"
  46. fixed-width
  47. />
  48. </span>
  49. </span>
  50. <span
  51. v-if="stickerPickerEnabled"
  52. class="additional-tabs"
  53. >
  54. <span
  55. class="button-unstyled stickers-tab-icon additional-tabs-item"
  56. :class="{toggled: showingStickers}"
  57. :title="$t('emoji.stickers')"
  58. @click.prevent="toggleStickers"
  59. >
  60. <FAIcon
  61. icon="sticky-note"
  62. fixed-width
  63. />
  64. </span>
  65. </span>
  66. </div>
  67. <div
  68. v-if="contentLoaded"
  69. class="content"
  70. >
  71. <div
  72. class="emoji-content"
  73. :class="{hidden: showingStickers}"
  74. >
  75. <div class="emoji-search">
  76. <input
  77. ref="search"
  78. v-model="keyword"
  79. type="text"
  80. class="input form-control"
  81. :placeholder="$t('emoji.search_emoji')"
  82. @input="$event.target.composing = false"
  83. >
  84. </div>
  85. <!-- Enables scrolling for this element on safari iOS. See comments for header. -->
  86. <DynamicScroller
  87. ref="emoji-groups"
  88. v-body-scroll-lock="isInModal"
  89. class="emoji-groups"
  90. :class="groupsScrolledClass"
  91. :min-item-size="minItemSize"
  92. :buffer="minItemSize"
  93. :items="emojiItems"
  94. :emit-update="true"
  95. @update="onScroll"
  96. @visible="recalculateItemPerRow"
  97. @resize="recalculateItemPerRow"
  98. >
  99. <template #default="{ item: group, index, active }">
  100. <DynamicScrollerItem
  101. :ref="setGroupRef('group-' + group.id)"
  102. :item="group"
  103. :active="active"
  104. :data-index="index"
  105. :size-dependencies="[group.emojis.length]"
  106. >
  107. <div
  108. class="emoji-group"
  109. >
  110. <h6
  111. v-if="group.isFirstRow"
  112. class="emoji-group-title"
  113. >
  114. {{ group.text }}
  115. </h6>
  116. <span
  117. v-for="emoji in group.emojis"
  118. :key="group.id + emoji.displayText"
  119. :title="maybeLocalizedEmojiName(emoji)"
  120. class="emoji-item"
  121. role="button"
  122. @click.stop.prevent="onEmoji(emoji)"
  123. >
  124. <span
  125. v-if="!emoji.imageUrl"
  126. class="emoji-picker-emoji -unicode"
  127. >{{ emoji.replacement }}</span>
  128. <still-image
  129. v-else
  130. class="emoji-picker-emoji -custom"
  131. loading="lazy"
  132. :alt="maybeLocalizedEmojiName(emoji)"
  133. :src="emoji.imageUrl"
  134. :data-emoji-name="group.id + emoji.displayText"
  135. />
  136. </span>
  137. </div>
  138. </DynamicScrollerItem>
  139. </template>
  140. </DynamicScroller>
  141. <div class="keep-open">
  142. <Checkbox v-model="keepOpen">
  143. {{ $t('emoji.keep_open') }}
  144. </Checkbox>
  145. </div>
  146. <div
  147. v-if="!hideCustomEmoji"
  148. class="hide-custom-emoji"
  149. >
  150. <Checkbox
  151. v-model="hideCustomEmojiInPicker"
  152. @change="onShowing"
  153. >
  154. {{ $t('emoji.hide_custom_emoji') }}
  155. </Checkbox>
  156. </div>
  157. </div>
  158. <div
  159. v-if="showingStickers"
  160. class="stickers-content"
  161. >
  162. <sticker-picker
  163. @uploaded="onStickerUploaded"
  164. @upload-failed="onStickerUploadFailed"
  165. />
  166. </div>
  167. </div>
  168. </template>
  169. </Popover>
  170. </template>
  171. <script src="./emoji_picker.js"></script>
  172. <style lang="scss" src="./emoji_picker.scss"></style>