OptionPanel.vue 2.7 KB

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