FormBuilderTiptapEditor.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="form-builder-vueTiptaKatex"
  3. :class="customClass">
  4. <p v-text="label" />
  5. <component :is="editorComponent"
  6. v-if="!disable && !readonly"
  7. ref="tiptap"
  8. v-model="inputData"
  9. :name="name"
  10. :bubble-menu="false"
  11. :floating-menu="false"
  12. :options="options"
  13. :class="customClass"
  14. @update:model-value="change($event)"
  15. @click="onClick" />
  16. <!-- <q-editor v-if="!disable && !readonly"-->
  17. <!-- v-model="inputData"-->
  18. <!-- :class="customClass"-->
  19. <!-- :content-class="customClass"-->
  20. <!-- :name="name"-->
  21. <!-- :dense="$q.screen.lt.md"-->
  22. <!-- :toolbar="[-->
  23. <!-- [-->
  24. <!-- {-->
  25. <!-- label: $q.lang.editor.align,-->
  26. <!-- icon: $q.iconSet.editor.align,-->
  27. <!-- fixedLabel: true,-->
  28. <!-- options: ['left', 'center', 'right', 'justify'],-->
  29. <!-- },-->
  30. <!-- ],-->
  31. <!-- ['bold', 'italic', 'strike', 'underline', 'subscript', 'superscript'],-->
  32. <!-- ['token', 'hr', 'link', 'custom_btn'],-->
  33. <!-- ['print', 'fullscreen'],-->
  34. <!-- [-->
  35. <!-- {-->
  36. <!-- label: $q.lang.editor.formatting,-->
  37. <!-- icon: $q.iconSet.editor.formatting,-->
  38. <!-- list: 'no-icons',-->
  39. <!-- options: ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'code'],-->
  40. <!-- },-->
  41. <!-- {-->
  42. <!-- label: $q.lang.editor.fontSize,-->
  43. <!-- icon: $q.iconSet.editor.fontSize,-->
  44. <!-- fixedLabel: true,-->
  45. <!-- fixedIcon: true,-->
  46. <!-- list: 'no-icons',-->
  47. <!-- options: [-->
  48. <!-- 'size-1',-->
  49. <!-- 'size-2',-->
  50. <!-- 'size-3',-->
  51. <!-- 'size-4',-->
  52. <!-- 'size-5',-->
  53. <!-- 'size-6',-->
  54. <!-- 'size-7',-->
  55. <!-- ],-->
  56. <!-- },-->
  57. <!-- {-->
  58. <!-- label: $q.lang.editor.defaultFont,-->
  59. <!-- icon: $q.iconSet.editor.font,-->
  60. <!-- fixedIcon: true,-->
  61. <!-- list: 'no-icons',-->
  62. <!-- options: [-->
  63. <!-- 'default_font',-->
  64. <!-- 'arial',-->
  65. <!-- 'arial_black',-->
  66. <!-- 'comic_sans',-->
  67. <!-- 'courier_new',-->
  68. <!-- 'impact',-->
  69. <!-- 'lucida_grande',-->
  70. <!-- 'times_new_roman',-->
  71. <!-- 'verdana',-->
  72. <!-- ],-->
  73. <!-- },-->
  74. <!-- 'removeFormat',-->
  75. <!-- ],-->
  76. <!-- ['quote', 'unordered', 'ordered', 'outdent', 'indent'],-->
  77. <!-- ['undo', 'redo'],-->
  78. <!-- ['viewsource'],-->
  79. <!-- ]"-->
  80. <!-- :fonts="{-->
  81. <!-- IRANSans: 'IRANSans',-->
  82. <!-- arial: 'Arial',-->
  83. <!-- arial_black: 'Arial Black',-->
  84. <!-- comic_sans: 'Comic Sans MS',-->
  85. <!-- courier_new: 'Courier New',-->
  86. <!-- impact: 'Impact',-->
  87. <!-- lucida_grande: 'Lucida Grande',-->
  88. <!-- times_new_roman: 'Times New Roman',-->
  89. <!-- verdana: 'Verdana',-->
  90. <!-- }"-->
  91. <!-- @update:model-value="change($event)"-->
  92. <!-- @click="onClick" />-->
  93. <!--eslint-disable-next-line-->
  94. <div v-else v-html="inputData"/>
  95. </div>
  96. </template>
  97. <script>
  98. import { inputMixin } from 'quasar-form-builder'
  99. export default {
  100. name: 'FormBuilderTiptapEditor',
  101. mixins: [inputMixin],
  102. props: {
  103. name: {
  104. default: '',
  105. type: String
  106. },
  107. value: {
  108. default: '',
  109. type: [String, Number, Boolean]
  110. },
  111. options: {
  112. default: () => {
  113. return {}
  114. },
  115. type: Object
  116. }
  117. },
  118. data() {
  119. return {
  120. editorComponent: null
  121. }
  122. },
  123. watch: {
  124. value(newValue) {
  125. if (newValue === false) {
  126. this.inputData = ''
  127. }
  128. }
  129. },
  130. mounted () {
  131. if (this.inputData === false) {
  132. this.inputData = ''
  133. }
  134. import('vue3-tiptap-katex')
  135. .then((vue3TiptapKatex) => {
  136. this.editorComponent = vue3TiptapKatex.VueTiptapKatexNoSsr
  137. })
  138. .catch()
  139. },
  140. methods: {
  141. setNewContent(val) {
  142. this.$refs.tiptap.setContent(val)
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped></style>