OptionPanel.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <option-panel-tabs v-model:options="localOptions">
  3. <template #main-tab>
  4. <div class="option-panel-container">
  5. <div class="row q-mt-sm">
  6. <div class="col-md-12">
  7. <editor v-model:value="localOptions.text" />
  8. </div>
  9. <editor-options v-model:options="localOptions" />
  10. </div>
  11. </div>
  12. </template>
  13. </option-panel-tabs>
  14. </template>
  15. <script>
  16. import { defineComponent } from 'vue'
  17. import { mixinOptionPanel } from 'quasar-ui-q-page-builder'
  18. import OptionPanelTabs from 'quasar-ui-q-page-builder/src/components/OptionPanelComponents/OptionPanelTabs.vue'
  19. import Editor from 'components/Utils/Editor.vue'
  20. import EditorOptions from 'components/EditorOptions.vue'
  21. export default defineComponent({
  22. name: 'OptionPanel',
  23. components: { Editor, OptionPanelTabs, EditorOptions },
  24. mixins: [mixinOptionPanel],
  25. props: {
  26. options: {
  27. type: Object,
  28. default() {
  29. return {}
  30. }
  31. }
  32. },
  33. data() {
  34. return {
  35. fontStyle: ['inherit', 'normal', 'italic'],
  36. foreColor: '#000000',
  37. token: null,
  38. responsiveOpts: ['xs', 'sm', 'md', 'lg', 'xl'],
  39. responsive: 'xs',
  40. defaultOptions: {
  41. fontFamily: null,
  42. color: null,
  43. fontSize: null,
  44. fontWeight: null,
  45. fontStyle: null,
  46. xs: {
  47. fontSize: null,
  48. fontWeight: null,
  49. fontStyle: null,
  50. lineHeight: null
  51. },
  52. sm: {
  53. fontSize: null,
  54. fontWeight: null,
  55. fontStyle: null,
  56. lineHeight: null
  57. },
  58. md: {
  59. fontSize: null,
  60. fontWeight: null,
  61. fontStyle: null,
  62. lineHeight: null
  63. },
  64. lg: {
  65. fontSize: null,
  66. fontWeight: null,
  67. fontStyle: null,
  68. lineHeight: null
  69. },
  70. xl: {
  71. fontSize: null,
  72. fontWeight: null,
  73. fontStyle: null,
  74. lineHeight: null
  75. }
  76. }
  77. }
  78. },
  79. watch: {
  80. localOptions: {
  81. handler(newVal) {
  82. this.$emit('update:options', newVal)
  83. },
  84. deep: true
  85. }
  86. },
  87. mounted() {
  88. const windowWidth = window.innerWidth
  89. if (windowWidth > 1920) {
  90. this.responsive = 'xl'
  91. } else if (windowWidth > 1440 < 1920) {
  92. this.responsive = 'lg'
  93. } else if (windowWidth > 1024 < 1440) {
  94. this.responsive = 'md'
  95. } else if (windowWidth > 600 < 1024) {
  96. this.responsive = 'sm'
  97. } else if (windowWidth < 600) {
  98. this.responsive = 'xs'
  99. }
  100. },
  101. methods: {
  102. color(cmd, name) {
  103. const edit = this.$refs.editor
  104. this.$refs.token.hide()
  105. edit.caret.restore()
  106. edit.runCmd(cmd, name)
  107. edit.focus()
  108. }
  109. }
  110. })
  111. </script>