@md-plugins/quasar-app-extension-q-press 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +230 -0
  3. package/old/prompts.js +44 -0
  4. package/old/uninstall.js +9 -0
  5. package/package.json +60 -0
  6. package/scripts/build.js +33 -0
  7. package/src/index.js +63 -0
  8. package/src/install.js +49 -0
  9. package/src/templates/.gitkeep +0 -0
  10. package/src/templates/init/src/_q-press/.gitkeep +0 -0
  11. package/src/templates/init/src/_q-press/api/components/DarkModeToggle.json +37 -0
  12. package/src/templates/init/src/_q-press/api/components/MarkdownApi.json +67 -0
  13. package/src/templates/init/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
  14. package/src/templates/init/src/_q-press/api/components/MarkdownCardLink.json +28 -0
  15. package/src/templates/init/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
  16. package/src/templates/init/src/_q-press/api/components/MarkdownCode.json +37 -0
  17. package/src/templates/init/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
  18. package/src/templates/init/src/_q-press/api/components/MarkdownCodepen.json +21 -0
  19. package/src/templates/init/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
  20. package/src/templates/init/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
  21. package/src/templates/init/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
  22. package/src/templates/init/src/_q-press/api/components/MarkdownExample.json +22 -0
  23. package/src/templates/init/src/_q-press/api/components/MarkdownHeader.json +28 -0
  24. package/src/templates/init/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
  25. package/src/templates/init/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
  26. package/src/templates/init/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
  27. package/src/templates/init/src/_q-press/api/components/MarkdownInstallation.json +33 -0
  28. package/src/templates/init/src/_q-press/api/components/MarkdownLayout.json +52 -0
  29. package/src/templates/init/src/_q-press/api/components/MarkdownLink.json +23 -0
  30. package/src/templates/init/src/_q-press/api/components/MarkdownPage.json +71 -0
  31. package/src/templates/init/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
  32. package/src/templates/init/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
  33. package/src/templates/init/src/_q-press/api/components/MarkdownPageToc.json +17 -0
  34. package/src/templates/init/src/_q-press/api/components/MarkdownPrerender.json +25 -0
  35. package/src/templates/init/src/_q-press/api/components/MarkdownTree.json +27 -0
  36. package/src/templates/init/src/_q-press/api/composables/dark.json +29 -0
  37. package/src/templates/init/src/_q-press/api/composables/scroll.json +34 -0
  38. package/src/templates/init/src/_q-press/assets/get-meta.ts +29 -0
  39. package/src/templates/init/src/_q-press/components/DarkModeToggle.vue +105 -0
  40. package/src/templates/init/src/_q-press/components/MarkdownApi.vue +588 -0
  41. package/src/templates/init/src/_q-press/components/MarkdownApiEntry.ts +594 -0
  42. package/src/templates/init/src/_q-press/components/MarkdownCardLink.vue +25 -0
  43. package/src/templates/init/src/_q-press/components/MarkdownCardTitle.vue +21 -0
  44. package/src/templates/init/src/_q-press/components/MarkdownCode.vue +25 -0
  45. package/src/templates/init/src/_q-press/components/MarkdownCodePrism.ts +36 -0
  46. package/src/templates/init/src/_q-press/components/MarkdownCodepen.vue +183 -0
  47. package/src/templates/init/src/_q-press/components/MarkdownCopyButton.vue +104 -0
  48. package/src/templates/init/src/_q-press/components/MarkdownExample.vue +221 -0
  49. package/src/templates/init/src/_q-press/components/MarkdownInstallation.vue +166 -0
  50. package/src/templates/init/src/_q-press/components/MarkdownLink.vue +38 -0
  51. package/src/templates/init/src/_q-press/components/MarkdownPrerender.ts +82 -0
  52. package/src/templates/init/src/_q-press/components/MarkdownTree.vue +105 -0
  53. package/src/templates/init/src/_q-press/components/markdown-utils.ts +105 -0
  54. package/src/templates/init/src/_q-press/composables/dark.ts +39 -0
  55. package/src/templates/init/src/_q-press/composables/scroll.ts +115 -0
  56. package/src/templates/init/src/_q-press/css/app.scss +662 -0
  57. package/src/templates/init/src/_q-press/css/fonts.scss +100 -0
  58. package/src/templates/init/src/_q-press/css/prism-theme.scss +298 -0
  59. package/src/templates/init/src/_q-press/css/themes/default.scss +68 -0
  60. package/src/templates/init/src/_q-press/css/themes/newspaper.scss +69 -0
  61. package/src/templates/init/src/_q-press/css/themes/sunrise.scss +67 -0
  62. package/src/templates/init/src/_q-press/css/themes/tawny.scss +69 -0
  63. package/src/templates/init/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
  64. package/src/templates/init/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
  65. package/src/templates/init/src/_q-press/layouts/MarkdownHeader.vue +412 -0
  66. package/src/templates/init/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
  67. package/src/templates/init/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
  68. package/src/templates/init/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
  69. package/src/templates/init/src/_q-press/layouts/MarkdownLayout.vue +239 -0
  70. package/src/templates/init/src/_q-press/layouts/MarkdownPage.vue +307 -0
  71. package/src/templates/init/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
  72. package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
  73. package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
  74. package/src/templates/init/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
  75. package/src/templates/init/src/_q-press/layouts/MarkdownSearch.vue +449 -0
  76. package/src/templates/init/src/_q-press/stores/markdown.ts +101 -0
  77. package/src/templates/init/src/components/LandingPage/LandingPage.vue +341 -0
  78. package/src/templates/init/src/components/Releases/PackageReleases.vue +164 -0
  79. package/src/templates/init/src/components/Releases/PublicReleases.vue +149 -0
  80. package/src/templates/init/src/components/Releases/ReleasesAvailable.vue +74 -0
  81. package/src/templates/init/src/examples/QAvatar/BasicExample.vue +11 -0
  82. package/src/templates/init/src/markdown/__elements.md +548 -0
  83. package/src/templates/init/src/markdown/__elements2.md +347 -0
  84. package/src/templates/init/src/markdown/faq/best-practices.md +0 -0
  85. package/src/templates/init/src/markdown/faq/general.md +0 -0
  86. package/src/templates/init/src/markdown/faq/troubleshooting.md +0 -0
  87. package/src/templates/init/src/markdown/getting-started/introduction.md +67 -0
  88. package/src/templates/init/src/markdown/guides/contributing.md +101 -0
  89. package/src/templates/init/src/markdown/guides/faq.md +115 -0
  90. package/src/templates/init/src/markdown/guides/release-notes.md +0 -0
  91. package/src/templates/init/src/markdown/guides/style-guide.md +0 -0
  92. package/src/templates/init/src/markdown/landing-page.md +11 -0
  93. package/src/templates/init/src/markdown/listing.ts +3 -0
  94. package/src/templates/init/src/markdown/md-plugins/blockquote/advanced.md +83 -0
  95. package/src/templates/init/src/markdown/md-plugins/blockquote/overview.md +183 -0
  96. package/src/templates/init/src/markdown/md-plugins/codeblocks/advanced.md +210 -0
  97. package/src/templates/init/src/markdown/md-plugins/codeblocks/overview.md +616 -0
  98. package/src/templates/init/src/markdown/md-plugins/containers/advanced.md +301 -0
  99. package/src/templates/init/src/markdown/md-plugins/containers/overview.md +206 -0
  100. package/src/templates/init/src/markdown/md-plugins/frontmatter/advanced.md +164 -0
  101. package/src/templates/init/src/markdown/md-plugins/frontmatter/overview.md +131 -0
  102. package/src/templates/init/src/markdown/md-plugins/headers/advanced.md +236 -0
  103. package/src/templates/init/src/markdown/md-plugins/headers/overview.md +134 -0
  104. package/src/templates/init/src/markdown/md-plugins/image/advanced.md +114 -0
  105. package/src/templates/init/src/markdown/md-plugins/image/overview.md +124 -0
  106. package/src/templates/init/src/markdown/md-plugins/imports/advanced.md +105 -0
  107. package/src/templates/init/src/markdown/md-plugins/imports/overview.md +80 -0
  108. package/src/templates/init/src/markdown/md-plugins/inline-code/advanced.md +133 -0
  109. package/src/templates/init/src/markdown/md-plugins/inline-code/overview.md +101 -0
  110. package/src/templates/init/src/markdown/md-plugins/link/advanced.md +157 -0
  111. package/src/templates/init/src/markdown/md-plugins/link/overview.md +126 -0
  112. package/src/templates/init/src/markdown/md-plugins/shared/overview.md +175 -0
  113. package/src/templates/init/src/markdown/md-plugins/table/advanced.md +190 -0
  114. package/src/templates/init/src/markdown/md-plugins/table/overview.md +186 -0
  115. package/src/templates/init/src/markdown/md-plugins/title/advanced.md +88 -0
  116. package/src/templates/init/src/markdown/md-plugins/title/overview.md +99 -0
  117. package/src/templates/init/src/markdown/other/release-notes.md +12 -0
  118. package/src/templates/init/src/markdown/privacy-policy.md +12 -0
  119. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/advanced.md +101 -0
  120. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/components.md +69 -0
  121. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/overview.md +254 -0
  122. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/themes.md +4 -0
  123. package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/advanced.md +4 -0
  124. package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/overview.md +103 -0
  125. package/src/templates/init/src/markdown/vite-plugins/index.md +6 -0
  126. package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/advanced.md +138 -0
  127. package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/overview.md +88 -0
  128. package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/advanced.md +226 -0
  129. package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/index.md +6 -0
  130. package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/overview.md +166 -0
  131. package/src/templates/init/src/q-press.globals.d.ts +36 -0
  132. package/src/templates/init/src/siteConfig/index.ts +440 -0
  133. package/src/templates/update/src/_q-press/.gitkeep +0 -0
  134. package/src/templates/update/src/_q-press/api/components/DarkModeToggle.json +37 -0
  135. package/src/templates/update/src/_q-press/api/components/MarkdownApi.json +67 -0
  136. package/src/templates/update/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
  137. package/src/templates/update/src/_q-press/api/components/MarkdownCardLink.json +28 -0
  138. package/src/templates/update/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
  139. package/src/templates/update/src/_q-press/api/components/MarkdownCode.json +37 -0
  140. package/src/templates/update/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
  141. package/src/templates/update/src/_q-press/api/components/MarkdownCodepen.json +21 -0
  142. package/src/templates/update/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
  143. package/src/templates/update/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
  144. package/src/templates/update/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
  145. package/src/templates/update/src/_q-press/api/components/MarkdownExample.json +22 -0
  146. package/src/templates/update/src/_q-press/api/components/MarkdownHeader.json +28 -0
  147. package/src/templates/update/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
  148. package/src/templates/update/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
  149. package/src/templates/update/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
  150. package/src/templates/update/src/_q-press/api/components/MarkdownInstallation.json +33 -0
  151. package/src/templates/update/src/_q-press/api/components/MarkdownLayout.json +52 -0
  152. package/src/templates/update/src/_q-press/api/components/MarkdownLink.json +23 -0
  153. package/src/templates/update/src/_q-press/api/components/MarkdownPage.json +71 -0
  154. package/src/templates/update/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
  155. package/src/templates/update/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
  156. package/src/templates/update/src/_q-press/api/components/MarkdownPageToc.json +17 -0
  157. package/src/templates/update/src/_q-press/api/components/MarkdownPrerender.json +25 -0
  158. package/src/templates/update/src/_q-press/api/components/MarkdownTree.json +27 -0
  159. package/src/templates/update/src/_q-press/api/composables/dark.json +29 -0
  160. package/src/templates/update/src/_q-press/api/composables/scroll.json +34 -0
  161. package/src/templates/update/src/_q-press/assets/get-meta.ts +29 -0
  162. package/src/templates/update/src/_q-press/components/DarkModeToggle.vue +105 -0
  163. package/src/templates/update/src/_q-press/components/MarkdownApi.vue +588 -0
  164. package/src/templates/update/src/_q-press/components/MarkdownApiEntry.ts +594 -0
  165. package/src/templates/update/src/_q-press/components/MarkdownCardLink.vue +25 -0
  166. package/src/templates/update/src/_q-press/components/MarkdownCardTitle.vue +21 -0
  167. package/src/templates/update/src/_q-press/components/MarkdownCode.vue +25 -0
  168. package/src/templates/update/src/_q-press/components/MarkdownCodePrism.ts +36 -0
  169. package/src/templates/update/src/_q-press/components/MarkdownCodepen.vue +183 -0
  170. package/src/templates/update/src/_q-press/components/MarkdownCopyButton.vue +104 -0
  171. package/src/templates/update/src/_q-press/components/MarkdownExample.vue +221 -0
  172. package/src/templates/update/src/_q-press/components/MarkdownInstallation.vue +166 -0
  173. package/src/templates/update/src/_q-press/components/MarkdownLink.vue +38 -0
  174. package/src/templates/update/src/_q-press/components/MarkdownPrerender.ts +82 -0
  175. package/src/templates/update/src/_q-press/components/MarkdownTree.vue +105 -0
  176. package/src/templates/update/src/_q-press/components/markdown-utils.ts +105 -0
  177. package/src/templates/update/src/_q-press/composables/dark.ts +39 -0
  178. package/src/templates/update/src/_q-press/composables/scroll.ts +115 -0
  179. package/src/templates/update/src/_q-press/css/app.scss +662 -0
  180. package/src/templates/update/src/_q-press/css/fonts.scss +100 -0
  181. package/src/templates/update/src/_q-press/css/prism-theme.scss +298 -0
  182. package/src/templates/update/src/_q-press/css/themes/default.scss +68 -0
  183. package/src/templates/update/src/_q-press/css/themes/newspaper.scss +69 -0
  184. package/src/templates/update/src/_q-press/css/themes/sunrise.scss +67 -0
  185. package/src/templates/update/src/_q-press/css/themes/tawny.scss +69 -0
  186. package/src/templates/update/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
  187. package/src/templates/update/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
  188. package/src/templates/update/src/_q-press/layouts/MarkdownHeader.vue +412 -0
  189. package/src/templates/update/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
  190. package/src/templates/update/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
  191. package/src/templates/update/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
  192. package/src/templates/update/src/_q-press/layouts/MarkdownLayout.vue +239 -0
  193. package/src/templates/update/src/_q-press/layouts/MarkdownPage.vue +307 -0
  194. package/src/templates/update/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
  195. package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
  196. package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
  197. package/src/templates/update/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
  198. package/src/templates/update/src/_q-press/layouts/MarkdownSearch.vue +449 -0
  199. package/src/templates/update/src/_q-press/stores/markdown.ts +101 -0
  200. package/src/templates/update/src/q-press.globals.d.ts +36 -0
@@ -0,0 +1,183 @@
1
+ <template>
2
+ <form
3
+ ref="formRef"
4
+ method="post"
5
+ action="https://codepen.io/pen/define/"
6
+ target="_blank"
7
+ rel="noopener"
8
+ class="hidden"
9
+ >
10
+ <input v-if="active" type="hidden" name="data" :value="options" />
11
+ </form>
12
+ </template>
13
+
14
+ <script setup>
15
+ import { Quasar } from 'quasar'
16
+ import { ref, reactive, computed, nextTick } from 'vue'
17
+
18
+ import { slugify } from '@md-plugins/shared'
19
+
20
+ const cssResources = [
21
+ 'https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons',
22
+ `https://cdn.jsdelivr.net/npm/quasar@${Quasar.version}/dist/quasar.min.css`,
23
+ ].join(';')
24
+
25
+ const jsResources = [
26
+ 'https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js',
27
+ `https://cdn.jsdelivr.net/npm/quasar@${Quasar.version}/dist/quasar.umd.prod.js`,
28
+ ].join(';')
29
+
30
+ const replace = (name) =>
31
+ function (_, p1) {
32
+ const parts = p1
33
+ .split(',')
34
+ .map((p) => p.trim())
35
+ .filter((p) => p.length > 0)
36
+ .reduce((acc, p) => {
37
+ acc.push(p)
38
+ return acc
39
+ }, [])
40
+
41
+ const text = []
42
+ if (parts.length > 0) {
43
+ text.push('const { ' + parts.join(', ') + ' } = ' + name)
44
+ }
45
+ return text.join('\n')
46
+ }
47
+
48
+ const props = defineProps({ title: String })
49
+
50
+ const active = ref(false)
51
+ const formRef = ref(null)
52
+ const def = reactive({ parts: {} })
53
+
54
+ const css = computed(() => {
55
+ return (def.parts.Style || '').replace(/(<style.*?>|<\/style>)/g, '').trim()
56
+ })
57
+
58
+ const cssPreprocessor = computed(() => {
59
+ const lang = /<style.*lang=["'](.*)["'].*>/.exec(def.parts.Style || '')
60
+
61
+ return lang ? lang[1] : 'none'
62
+ })
63
+
64
+ const js = computed(() => {
65
+ const quasarImports = /import\s+{([^}'\n]+)}\s+from\s+'quasar'/g
66
+ const vueImports = /import\s+{([^}'\n]+)}\s+from\s+'vue'/g
67
+ const otherImports = /import ([^'\n]*) from ([^\n]*)/g
68
+ let component = /export default {([\s\S]*)}/g.exec(def.parts.Script || '')
69
+
70
+ component = ((component && component[1]) || '').trim()
71
+ if (component.length > 0) {
72
+ component = '\n ' + component + '\n'
73
+ }
74
+
75
+ let script = /<script>([\s\S]*)export default {/g.exec(def.parts.Script || '')
76
+ script = ((script && script[1]) || '')
77
+ .replace(quasarImports, replace('Quasar'))
78
+ .replace(vueImports, replace('Vue'))
79
+ .replace(otherImports, '')
80
+ .trim()
81
+
82
+ script += script ? '\n\n' : ''
83
+ return (
84
+ script +
85
+ `const app = Vue.createApp({${component}})
86
+
87
+ app.use(Quasar, { config: {} })
88
+ app.mount('#q-app')
89
+ `
90
+ )
91
+ })
92
+
93
+ const html = computed(() => {
94
+ return (def.parts.Template || '')
95
+ .replace(/(<template>|<\/template>$)/g, '')
96
+ .replace(/\n/g, '\n ')
97
+ .replace(/([\w]+=")([^"]*?)(")/g, function (match, p1, p2, p3) {
98
+ return p1 + p2.replace(/>/g, '___TEMP_REPLACEMENT___') + p3
99
+ })
100
+ .replace(/<(q-[\w-]+|div)([^>]*?)\s*?([\n\r][\t ]+)?\/>/gs, '<$1$2$3></$1>')
101
+ .replace(
102
+ /(<template[^>]*>)(\s*?(?:[\n\r][\t ]+)?)<(thead|tbody|tfoot)/gs,
103
+ '$1$2<___PREVENT_TEMPLATE___$3',
104
+ )
105
+ .replace(/<(thead|tbody|tfoot)(.*?)[\n\r]?(\s*)<\/\1>/gs, function (match, p1, p2, p3) {
106
+ return (
107
+ '<template>\n' +
108
+ p3 +
109
+ ' <' +
110
+ p1 +
111
+ p2.split(/[\n\r]+/g).join('\n ') +
112
+ '\n' +
113
+ p3 +
114
+ ' </' +
115
+ p1 +
116
+ '>\n' +
117
+ p3 +
118
+ '</template>'
119
+ )
120
+ })
121
+ .replace(/___PREVENT_TEMPLATE___/g, '')
122
+ .replace(/___TEMP_REPLACEMENT___/g, '>')
123
+ .replace(/^\s{2}/gm, '')
124
+ .trim()
125
+ })
126
+
127
+ const editors = computed(() => {
128
+ const flag = (html.value && 0b100) | (css.value && 0b010) | (js.value && 0b001)
129
+ return flag.toString(2)
130
+ })
131
+
132
+ const computedTitle = computed(() => {
133
+ return (
134
+ (typeof document !== 'undefined' ? document.title.split(' | ')[0] + ': ' : '') +
135
+ (props.title ? props.title + ' - ' : '') +
136
+ `Quasar v${Quasar.version}`
137
+ )
138
+ })
139
+
140
+ const slugifiedTitle = computed(() => {
141
+ return 'example--' + slugify(props.title)
142
+ })
143
+
144
+ const options = computed(() => {
145
+ const data = {
146
+ title: computedTitle.value,
147
+ html: `<!--
148
+ Forked from:
149
+ ${location.origin + location.pathname}#${slugifiedTitle.value}
150
+ -->
151
+ <div id="q-app" style="min-height: 100vh;">
152
+ ${html.value}
153
+ </div>`,
154
+ head: '',
155
+ html_pre_processor: 'none',
156
+ css: css.value,
157
+ css_pre_processor: cssPreprocessor.value,
158
+ css_external: cssResources,
159
+ js: js.value,
160
+ js_pre_processor: 'babel',
161
+ js_external: jsResources,
162
+ editors: editors.value,
163
+ }
164
+ return JSON.stringify(data)
165
+ })
166
+
167
+ function open(whichParts) {
168
+ def.parts = whichParts
169
+
170
+ if (active.value) {
171
+ formRef.value.submit()
172
+ return
173
+ }
174
+
175
+ active.value = true
176
+
177
+ nextTick(() => {
178
+ formRef.value.submit()
179
+ })
180
+ }
181
+
182
+ defineExpose({ open })
183
+ </script>
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <div class="markdown-copy-btn">
3
+ <q-icon :name="mdiClipboardOutline" color="brand-primary" @click="copy" />
4
+
5
+ <transition enter-active-class="animated fadeIn" leave-active-class="animated fadeOut">
6
+ <q-badge class="absolute header-badge" v-show="copied" label="Copied to clipboard" />
7
+ </transition>
8
+ </div>
9
+ </template>
10
+
11
+ <script setup>
12
+ import { ref, getCurrentInstance } from 'vue'
13
+ import { copyToClipboard } from './markdown-utils'
14
+ import { mdiClipboardOutline } from '@quasar/extras/mdi-v7'
15
+
16
+ const props = defineProps({
17
+ lang: String,
18
+ })
19
+
20
+ const { proxy } = getCurrentInstance()
21
+
22
+ let timer
23
+ const copied = ref(false)
24
+
25
+ function copy() {
26
+ const target = proxy.$el.previousSibling
27
+
28
+ // We need to remove artifacts (like line numbers)
29
+ // before we copy the content.
30
+ // The markdown-code--copying class will do that for us
31
+ target.classList.add('markdown-code--copying')
32
+ let text = target.innerText
33
+ target.classList.remove('markdown-code--copying')
34
+
35
+ if (props.lang === 'bash') {
36
+ const bashStartRE = /^\$ /
37
+ text = text
38
+ .split('\n')
39
+ .map((line) => line.replace(bashStartRE, ''))
40
+ .join('\n')
41
+ }
42
+
43
+ copyToClipboard(text)
44
+ .then(() => {
45
+ copied.value = true
46
+ clearTimeout(timer)
47
+ timer = setTimeout(() => {
48
+ copied.value = false
49
+ timer = null
50
+ }, 2000)
51
+ })
52
+ .catch(() => {})
53
+ }
54
+ </script>
55
+
56
+ <style lang="scss">
57
+ .markdown-copy-btn {
58
+ position: absolute;
59
+ top: 8px;
60
+ right: 16px; // account for scrollbar
61
+
62
+ .q-icon {
63
+ cursor: pointer;
64
+ color: $brand-primary;
65
+ font-size: 20px;
66
+ padding: 4px;
67
+ border-radius: $generic-border-radius;
68
+ border: 1px solid $brand-primary;
69
+ opacity: 0;
70
+ transition: opacity 0.28s;
71
+ }
72
+
73
+ .q-badge {
74
+ top: 4px;
75
+ right: 34px;
76
+ }
77
+ }
78
+
79
+ body.body--light {
80
+ .markdown-copy-btn .q-icon {
81
+ background-color: $light-pill;
82
+
83
+ &:hover {
84
+ background-color: #fff;
85
+ }
86
+ }
87
+ }
88
+
89
+ body.body--dark {
90
+ .markdown-copy-btn .q-icon {
91
+ background-color: $dark-pill;
92
+
93
+ &:hover {
94
+ background-color: #000;
95
+ }
96
+ }
97
+ }
98
+
99
+ .markdown-copybtn-hover:hover {
100
+ .markdown-copy-btn .q-icon {
101
+ opacity: 1;
102
+ }
103
+ }
104
+ </style>
@@ -0,0 +1,221 @@
1
+ <template>
2
+ <q-card class="markdown-example q-my-lg" flat bordered>
3
+ <div class="header-toolbar row items-center q-pr-sm">
4
+ <MarkdownCardTitle :title="props.title" prefix="example--" />
5
+
6
+ <q-space />
7
+
8
+ <div class="markdown-example__actions row no-wrap items-center">
9
+ <!-- <q-btn
10
+ class="header-btn"
11
+ dense
12
+ flat
13
+ round
14
+ :icon="mdiCompare"
15
+ @click="markdownStore.toggleDark"
16
+ >
17
+ <q-tooltip>Toggle dark mode</q-tooltip>
18
+ </q-btn> -->
19
+
20
+ <q-separator class="q-mx-xs" vertical inset />
21
+
22
+ <q-btn
23
+ v-if="props.noGithub !== true"
24
+ class="header-btn"
25
+ dense
26
+ flat
27
+ round
28
+ :icon="fabGithub"
29
+ @click="openGitHub"
30
+ >
31
+ <q-tooltip>View on GitHub</q-tooltip>
32
+ </q-btn>
33
+ <q-btn
34
+ class="header-btn q-ml-xs"
35
+ v-if="props.noEdit !== true"
36
+ dense
37
+ flat
38
+ round
39
+ :icon="fabCodepen"
40
+ @click="openCodepen"
41
+ :disable="isBusy"
42
+ >
43
+ <q-tooltip>Edit in Codepen</q-tooltip>
44
+ </q-btn>
45
+ <q-btn
46
+ class="header-btn q-ml-xs"
47
+ dense
48
+ flat
49
+ round
50
+ icon="code"
51
+ @click="toggleExpand"
52
+ :disable="isBusy"
53
+ >
54
+ <q-tooltip>View Source</q-tooltip>
55
+ </q-btn>
56
+ </div>
57
+ </div>
58
+
59
+ <q-slide-transition>
60
+ <div v-show="expanded">
61
+ <q-tabs
62
+ class="header-tabs"
63
+ v-model="currentTab"
64
+ align="left"
65
+ no-caps
66
+ active-color="brand-primary"
67
+ indicator-color="brand-primary"
68
+ dense
69
+ :breakpoint="0"
70
+ >
71
+ <q-tab v-for="tab in def.tabs" :key="`tab-${tab}`" :name="tab" class="header-btn">
72
+ {{ tab }}
73
+ </q-tab>
74
+ </q-tabs>
75
+
76
+ <q-separator />
77
+
78
+ <q-tab-panels class="text-grey-3 text-weight-regular" v-model="currentTab" animated>
79
+ <q-tab-panel class="q-pa-none" v-for="tab in def.tabs" :key="`pane-${tab}`" :name="tab">
80
+ <MarkdownCode lang="markup" :code="def.parts[tab]" max-height="70vh" />
81
+ </q-tab-panel>
82
+ </q-tab-panels>
83
+ </div>
84
+ </q-slide-transition>
85
+
86
+ <MarkdownCodepen v-if="!isBusy" ref="codepenRef" :title="props.title" />
87
+
88
+ <q-separator />
89
+
90
+ <div class="row overflow-hidden">
91
+ <q-linear-progress v-if="isBusy" color="brand-primary" indeterminate />
92
+ <component
93
+ class="col markdown-example__content markdown-example-typography"
94
+ v-else
95
+ :is="component"
96
+ :class="componentClass"
97
+ />
98
+ </div>
99
+ </q-card>
100
+ </template>
101
+
102
+ <script setup>
103
+ import { computed, inject, markRaw, ref, reactive, onMounted } from 'vue'
104
+ import { openURL } from 'quasar'
105
+
106
+ import { fabGithub, fabCodepen } from '@quasar/extras/fontawesome-v6'
107
+ // import { mdiCompare } from '@quasar/extras/mdi-v7'
108
+
109
+ import MarkdownCode from './MarkdownCode.vue'
110
+ import MarkdownCodepen from './MarkdownCodepen.vue'
111
+ import MarkdownCardTitle from './MarkdownCardTitle.vue'
112
+
113
+ const props = defineProps({
114
+ title: String,
115
+ file: String,
116
+ noEdit: Boolean, // no codepen edit
117
+ scrollable: Boolean,
118
+ overflow: Boolean,
119
+ noGithub: Boolean,
120
+ })
121
+
122
+ const examples = inject('_markdown_examples_')
123
+
124
+ const codepenRef = ref(null)
125
+ const isBusy = ref(true)
126
+
127
+ const component = ref(null)
128
+ const def = reactive({
129
+ tabs: [],
130
+ parts: {},
131
+ })
132
+ const currentTab = ref('Template')
133
+ const expanded = ref(false)
134
+
135
+ const componentClass = computed(() => {
136
+ return props.scrollable === true
137
+ ? 'markdown-example__content--scrollable scroll-y'
138
+ : props.overflow === true
139
+ ? 'overflow-auto'
140
+ : ''
141
+ })
142
+
143
+ function parseTemplate(target, template) {
144
+ const string = `(<${target}(.*)?>[\\w\\W]*<\\/${target}>)`,
145
+ regex = new RegExp(string, 'g'),
146
+ parsed = regex.exec(template) || []
147
+
148
+ return parsed[1] || ''
149
+ }
150
+
151
+ function parseComponent(comp) {
152
+ def.parts = {
153
+ Template: parseTemplate('template', comp),
154
+ Script: parseTemplate('script', comp),
155
+ Style: parseTemplate('style', comp),
156
+ }
157
+
158
+ const tabs = ['Template', 'Script', 'Style'].filter((type) => def.parts[type])
159
+
160
+ if (tabs.length > 1) {
161
+ def.parts.All = comp
162
+ tabs.push('All')
163
+ }
164
+
165
+ def.tabs = tabs
166
+ }
167
+
168
+ function openGitHub() {
169
+ openURL(
170
+ `https://github.com/quasarframework/quasar/tree/${process.env.DOCS_BRANCH}/docs/src/examples/${examples.name}/${props.file}.vue`,
171
+ )
172
+ }
173
+
174
+ function openCodepen() {
175
+ codepenRef.value.open(def.parts)
176
+ }
177
+
178
+ function toggleExpand() {
179
+ expanded.value = expanded.value === false
180
+ }
181
+
182
+ if (process.env.CLIENT) {
183
+ onMounted(() => {
184
+ examples.list.then((list) => {
185
+ component.value = markRaw(
186
+ process.env.DEV
187
+ ? list.code[`/src/examples/${examples.name}/${props.file}.vue`].default
188
+ : list[props.file],
189
+ )
190
+
191
+ parseComponent(
192
+ process.env.DEV
193
+ ? list.source[`/src/examples/${examples.name}/${props.file}.vue`]
194
+ : list[`Raw${props.file}`],
195
+ )
196
+
197
+ isBusy.value = false
198
+ })
199
+ })
200
+ }
201
+ </script>
202
+
203
+ <style lang="scss">
204
+ .markdown-example {
205
+ &__actions {
206
+ padding: 3px 0 3px 7px;
207
+ }
208
+
209
+ &__content {
210
+ position: relative;
211
+
212
+ // reset markdown style
213
+ font-weight: 400;
214
+ font-family: $font-family-examples;
215
+
216
+ &--scrollable {
217
+ height: 500px;
218
+ }
219
+ }
220
+ }
221
+ </style>
@@ -0,0 +1,166 @@
1
+ <template>
2
+ <q-card :id="id" class="markdown-installation q-my-xl" flat bordered>
3
+ <div class="header-toolbar row items-center">
4
+ <MarkdownCardTitle :title="props.title" />
5
+ </div>
6
+
7
+ <q-tabs
8
+ class="header-tabs"
9
+ v-model="currentTab"
10
+ align="left"
11
+ active-color="brand-primary"
12
+ indicator-color="brand-primary"
13
+ dense
14
+ :breakpoint="0"
15
+ shrink
16
+ >
17
+ <q-tab
18
+ v-for="tab in tabList"
19
+ :key="`installation-${tab}`"
20
+ :name="tab"
21
+ class="header-btn"
22
+ no-caps
23
+ >
24
+ {{ tab }}
25
+ </q-tab>
26
+ </q-tabs>
27
+
28
+ <q-separator />
29
+
30
+ <q-tab-panels v-model="currentTab" animated>
31
+ <q-tab-panel class="q-pa-none" name="Quasar CLI">
32
+ <MarkdownCode :code="QuasarCli" />
33
+ </q-tab-panel>
34
+
35
+ <q-tab-panel class="q-pa-none" name="Vite plugin / Vue CLI">
36
+ <MarkdownCode :code="ExternalCli" />
37
+ </q-tab-panel>
38
+
39
+ <q-tab-panel class="q-pa-none" name="UMD">
40
+ <MarkdownCode :code="UMD" />
41
+ </q-tab-panel>
42
+ </q-tab-panels>
43
+ </q-card>
44
+ </template>
45
+
46
+ <script setup>
47
+ import { ref, computed } from 'vue'
48
+
49
+ import MarkdownCode from './MarkdownCode.vue'
50
+ import MarkdownCardTitle from './MarkdownCardTitle.vue'
51
+
52
+ import { slugify } from '@md-plugins/shared'
53
+
54
+ const props = defineProps({
55
+ components: [Array, String],
56
+ directives: [Array, String],
57
+ plugins: [Array, String],
58
+ config: String,
59
+ title: {
60
+ type: String,
61
+ default: 'Installation',
62
+ },
63
+ })
64
+
65
+ const tabList = ['Quasar CLI', 'Vite plugin / Vue CLI', 'UMD']
66
+ const currentTab = ref('Quasar CLI')
67
+
68
+ const id = computed(() => slugify(props.title))
69
+
70
+ function nameAsString(name, indent, quotes = true) {
71
+ const wrapper = quotes ? (str) => `'${str}'` : (str) => str
72
+
73
+ return Array.isArray(name)
74
+ ? name.map(wrapper).join(',\n' + ''.padStart(indent, ' '))
75
+ : wrapper(name)
76
+ }
77
+
78
+ const quasarConf = computed(() => {
79
+ return props.config !== void 0
80
+ ? `${props.config}: /* look at QuasarConfOptions from the API card */`
81
+ : null
82
+ })
83
+
84
+ const QuasarCli = computed(() => {
85
+ if (props.plugins === void 0 && quasarConf.value === null) {
86
+ return `/*
87
+ * No installation step is necessary.
88
+ * It gets installed by default by @quasar/app-vite or @quasar/app-webpack.
89
+ */`
90
+ }
91
+
92
+ const parts = []
93
+
94
+ if (props.plugins !== void 0) {
95
+ parts.push(`plugins: [
96
+ ${nameAsString(props.plugins, 6)}
97
+ ]`)
98
+ }
99
+
100
+ if (quasarConf.value !== null) {
101
+ parts.push(`config: {
102
+ ${quasarConf.value}
103
+ }`)
104
+ }
105
+
106
+ return `// quasar.config file
107
+
108
+ return {
109
+ framework: {
110
+ ${parts.join(',\n ')}
111
+ }
112
+ }`
113
+ })
114
+
115
+ const UMD = computed(() => {
116
+ const config =
117
+ quasarConf.value !== null
118
+ ? `
119
+
120
+ // Optional;
121
+ // Place the global quasarConfig Object in a script tag BEFORE your Quasar script tag
122
+ app.use(Quasar, {
123
+ config: {
124
+ ${quasarConf.value}
125
+ }
126
+ }`
127
+ : ''
128
+
129
+ const content = `/*
130
+ * No installation step is necessary.
131
+ * It gets installed by default.
132
+ */`
133
+
134
+ return content + config
135
+ })
136
+
137
+ const ExternalCli = computed(() => {
138
+ const types = []
139
+ const imports = ['Quasar']
140
+
141
+ ;['components', 'directives', 'plugins'].forEach((type) => {
142
+ if (props[type] !== void 0) {
143
+ imports.push(nameAsString(props[type], 2, false))
144
+ types.push(`${type}: {
145
+ ${nameAsString(props[type], 4, false)}
146
+ }`)
147
+ }
148
+ })
149
+
150
+ if (quasarConf.value !== null) {
151
+ types.push(`config: {
152
+ ${quasarConf.value}
153
+ }`)
154
+ }
155
+
156
+ return `// main.js
157
+
158
+ import {
159
+ ${imports.join(',\n ')}
160
+ } from 'quasar'
161
+
162
+ app.use(Quasar, {
163
+ ${types.join(',\n ')}
164
+ })`
165
+ })
166
+ </script>
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <router-link v-if="internal === true" v-bind="$attrs" class="markdown-link" :to="to">
3
+ <slot />
4
+ </router-link>
5
+ <a v-else v-bind="$attrs" class="markdown-link" :href="props.to" target="_blank" rel="noopener">
6
+ <slot />
7
+ <q-icon :name="mdiLaunch" />
8
+ </a>
9
+ </template>
10
+
11
+ <script setup>
12
+ import { computed } from 'vue'
13
+ import { mdiLaunch } from '@quasar/extras/mdi-v6'
14
+
15
+ const props = defineProps({ to: String })
16
+ const internal = computed(
17
+ () => props.to.charAt(0) === '/' || props.to.charAt(0) === '.' || props.to.charAt(0) === '#',
18
+ )
19
+ </script>
20
+
21
+ <style lang="scss">
22
+ .markdown-link {
23
+ color: $brand-primary;
24
+ text-decoration: none;
25
+ border-bottom: 1px dotted currentColor;
26
+ outline: 0;
27
+ transition: color $header-quick-transition;
28
+
29
+ &:hover {
30
+ color: inherit !important;
31
+ }
32
+
33
+ .q-icon {
34
+ margin-top: -2px;
35
+ margin-left: 4px;
36
+ }
37
+ }
38
+ </style>