Simple text editor based on tiptap. HTML format.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

84 řádky
2.6 KiB

  1. <template>
  2. <div @hide="hideLinkMenu" class="menubar char-menubar">
  3. <div v-bind:key="opt.label" v-for="opt in environment.getCharacterOptions()" class="dropdown">
  4. <button class="dropbtn border-left">{{opt.label|capitalize}}</button>
  5. <div class="dropdown-content">
  6. <a v-for="style in opt.styles" v-bind:key="style.label">
  7. <button
  8. class="menubar__button"
  9. :class="{ 'is-active': slots.isActive.customstyle({ type: style.class }) }"
  10. @click="slots.commands.customstyle({ type: style.class })">
  11. {{style.label | capitalize}}
  12. </button>
  13. </a>
  14. </div>
  15. </div>
  16. <form class="menububble__form" v-if="linkMenuIsActive"
  17. @submit.prevent="setLinkUrl(slots.commands.link, linkUrl)">
  18. <input class="menububble__input" type="text" v-model="linkUrl" placeholder="https://"
  19. ref="linkInput" @keydown.esc="hideLinkMenu"/>
  20. <button class="menububble__button" @click="setLinkUrl(slots.commands.link, null)" type="button">
  21. Supprimer le lien
  22. </button>
  23. </form>
  24. <template v-else>
  25. <button id="link__button"
  26. class="menububble__button"
  27. @click="showLinkMenu(slots.getMarkAttrs('link'))"
  28. :class="{ 'is-active': slots.isActive.link() }"
  29. >
  30. <span>{{ slots.isActive.link() ? 'Modifier le lien' : 'Lien'}}</span>
  31. </button>
  32. </template>
  33. </div>
  34. </template>
  35. <script>
  36. export default {
  37. props: ["slots","environment"],
  38. components: {},
  39. data() {
  40. return {
  41. linkUrl: null,
  42. linkMenuIsActive: false,
  43. }
  44. },
  45. beforeDestroy() {
  46. },
  47. mounted() {
  48. },
  49. methods: {
  50. showLinkMenu(attrs) {
  51. this.linkUrl = attrs.href
  52. this.linkMenuIsActive = true
  53. this.$nextTick(() => {
  54. this.$refs.linkInput.focus()
  55. })
  56. },
  57. hideLinkMenu() {
  58. this.linkUrl = null
  59. this.linkMenuIsActive = false
  60. },
  61. setLinkUrl(command, url) {
  62. command({href: url})
  63. this.hideLinkMenu()
  64. },
  65. }
  66. }
  67. </script>