@md-plugins/quasar-app-extension-q-press 0.1.0-beta.2 → 0.1.0-beta.21

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 (253) hide show
  1. package/README.md +20 -15
  2. package/dist/index.js +41 -7
  3. package/dist/install.js +7 -5
  4. package/dist/q-press-globals.d.ts +49 -0
  5. package/dist/templates/init/src/_q-press/api/components/MarkdownCode.json +2 -2
  6. package/dist/templates/init/src/_q-press/api/components/MarkdownCodepen.json +6 -9
  7. package/dist/templates/init/src/_q-press/api/components/MarkdownExample.json +27 -2
  8. package/dist/templates/init/src/_q-press/components/MarkdownApi.vue +129 -84
  9. package/dist/templates/init/src/_q-press/components/MarkdownCardLink.vue +1 -1
  10. package/dist/templates/init/src/_q-press/components/MarkdownCardTitle.vue +1 -1
  11. package/dist/templates/init/src/_q-press/components/MarkdownCode.vue +71 -3
  12. package/dist/templates/init/src/_q-press/components/MarkdownCodepen.vue +316 -59
  13. package/dist/templates/init/src/_q-press/components/MarkdownCopyButton.vue +1 -1
  14. package/dist/templates/init/src/_q-press/components/MarkdownExample.vue +54 -19
  15. package/dist/templates/init/src/_q-press/components/MarkdownLink.vue +5 -5
  16. package/dist/templates/init/src/_q-press/components/MarkdownMermaid.vue +123 -0
  17. package/dist/templates/init/src/_q-press/components/MarkdownTree.vue +2 -2
  18. package/dist/templates/init/src/_q-press/components/markdown-utils.ts +27 -3
  19. package/dist/templates/init/src/_q-press/css/app.scss +38 -26
  20. package/dist/templates/init/src/_q-press/css/code-theme.scss +634 -0
  21. package/dist/templates/init/src/_q-press/css/themes/default.scss +1 -1
  22. package/dist/templates/init/src/_q-press/css/themes/evergreen.scss +69 -0
  23. package/dist/templates/init/src/_q-press/css/themes/mystic.scss +1 -1
  24. package/dist/templates/init/src/_q-press/css/themes/newspaper.scss +1 -1
  25. package/dist/templates/init/src/_q-press/css/themes/sunrise.scss +1 -1
  26. package/dist/templates/init/src/_q-press/css/themes/tawny.scss +1 -1
  27. package/dist/templates/init/src/_q-press/layouts/MarkdownDrawerSidebar.vue +1 -1
  28. package/dist/templates/init/src/_q-press/layouts/MarkdownDrawerToc.vue +1 -1
  29. package/dist/templates/init/src/_q-press/layouts/MarkdownHeader.vue +1 -1
  30. package/dist/templates/init/src/_q-press/layouts/MarkdownLayout.vue +2 -2
  31. package/dist/templates/init/src/_q-press/layouts/MarkdownPage.vue +4 -3
  32. package/dist/templates/init/src/_q-press/layouts/MarkdownSearch.vue +1 -1
  33. package/dist/templates/init/src/_q-press/stores/markdown.ts +1 -2
  34. package/dist/templates/init/src/components/LandingPage/LandingPage.vue +15 -1
  35. package/dist/templates/init/src/components/QPressThemeGallery.vue +336 -0
  36. package/dist/templates/init/src/components/page-parts/releases/GitHubReleases.vue +121 -0
  37. package/dist/templates/init/src/components/page-parts/releases/PackageReleases.vue +191 -0
  38. package/dist/templates/init/src/components/page-parts/releases/md-table-parser.ts +52 -0
  39. package/dist/templates/init/src/components/page-parts/releases/sanitize.ts +132 -0
  40. package/dist/templates/init/src/markdown/__elements.md +8 -8
  41. package/dist/templates/init/src/markdown/__elements2.md +4 -4
  42. package/dist/templates/init/src/markdown/faq/best-practices.md +27 -0
  43. package/dist/templates/init/src/markdown/faq/general.md +27 -0
  44. package/dist/templates/init/src/markdown/faq/troubleshooting.md +27 -0
  45. package/dist/templates/init/src/markdown/getting-started/introduction.md +7 -5
  46. package/dist/templates/init/src/markdown/md-plugins/blockquote/overview.md +3 -1
  47. package/dist/templates/init/src/markdown/md-plugins/codeblocks/advanced.md +19 -15
  48. package/dist/templates/init/src/markdown/md-plugins/codeblocks/overview.md +45 -8
  49. package/dist/templates/init/src/markdown/md-plugins/containers/overview.md +3 -1
  50. package/dist/templates/init/src/markdown/md-plugins/frontmatter/overview.md +3 -1
  51. package/dist/templates/init/src/markdown/md-plugins/headers/overview.md +3 -1
  52. package/dist/templates/init/src/markdown/md-plugins/image/overview.md +3 -1
  53. package/dist/templates/init/src/markdown/md-plugins/imports/overview.md +3 -1
  54. package/dist/templates/init/src/markdown/md-plugins/inline-code/overview.md +3 -1
  55. package/dist/templates/init/src/markdown/md-plugins/link/advanced.md +2 -2
  56. package/dist/templates/init/src/markdown/md-plugins/link/overview.md +6 -4
  57. package/dist/templates/init/src/markdown/md-plugins/mermaid/advanced.md +69 -0
  58. package/dist/templates/init/src/markdown/md-plugins/mermaid/overview.md +73 -0
  59. package/dist/templates/init/src/markdown/md-plugins/shared/overview.md +28 -13
  60. package/dist/templates/init/src/markdown/md-plugins/table/overview.md +3 -1
  61. package/dist/templates/init/src/markdown/md-plugins/title/overview.md +3 -1
  62. package/dist/templates/init/src/markdown/other/contact.md +37 -0
  63. package/dist/templates/init/src/markdown/other/contributing/bugs-and-feature-requests.md +33 -0
  64. package/dist/templates/init/src/markdown/other/contributing/call-to-action.md +25 -0
  65. package/dist/templates/init/src/markdown/other/contributing/documentation.md +31 -0
  66. package/dist/templates/init/src/markdown/other/contributing/overview.md +41 -0
  67. package/dist/templates/init/src/markdown/other/contributing/packages.md +28 -0
  68. package/dist/templates/init/src/markdown/other/contributing/sponsor.md +23 -0
  69. package/dist/templates/init/src/markdown/other/faq.md +179 -0
  70. package/dist/templates/init/src/markdown/other/releases.md +11 -0
  71. package/dist/templates/init/src/markdown/other/upgrade-guide.md +165 -0
  72. package/dist/templates/init/src/markdown/quasar-app-extensions/qpress/advanced.md +11 -3
  73. package/dist/templates/init/src/markdown/quasar-app-extensions/qpress/components.md +25 -29
  74. package/dist/templates/init/src/markdown/quasar-app-extensions/qpress/overview.md +20 -20
  75. package/dist/templates/init/src/markdown/quasar-app-extensions/qpress/site-config.md +17 -3
  76. package/dist/templates/init/src/markdown/quasar-app-extensions/qpress/themes.md +101 -9
  77. package/dist/templates/init/src/markdown/quasar-app-extensions/vite-md-plugin-app-ext/advanced.md +158 -0
  78. package/dist/templates/init/src/markdown/quasar-app-extensions/vite-md-plugin-app-ext/overview.md +1 -1
  79. package/dist/templates/init/src/markdown/vite-plugins/vite-examples-plugin/advanced.md +8 -3
  80. package/dist/templates/init/src/markdown/vite-plugins/vite-examples-plugin/overview.md +19 -5
  81. package/dist/templates/init/src/markdown/vite-plugins/vite-md-plugin/advanced.md +84 -54
  82. package/dist/templates/init/src/markdown/vite-plugins/vite-md-plugin/overview.md +19 -3
  83. package/dist/templates/init/src/siteConfig/index.ts +52 -23
  84. package/dist/templates/update/src/_q-press/api/components/MarkdownCode.json +2 -2
  85. package/dist/templates/update/src/_q-press/api/components/MarkdownCodepen.json +6 -9
  86. package/dist/templates/update/src/_q-press/api/components/MarkdownExample.json +27 -2
  87. package/dist/templates/update/src/_q-press/components/MarkdownApi.vue +129 -84
  88. package/dist/templates/update/src/_q-press/components/MarkdownCardLink.vue +1 -1
  89. package/dist/templates/update/src/_q-press/components/MarkdownCardTitle.vue +1 -1
  90. package/dist/templates/update/src/_q-press/components/MarkdownCode.vue +71 -3
  91. package/dist/templates/update/src/_q-press/components/MarkdownCodepen.vue +316 -59
  92. package/dist/templates/update/src/_q-press/components/MarkdownCopyButton.vue +1 -1
  93. package/dist/templates/update/src/_q-press/components/MarkdownExample.vue +54 -19
  94. package/dist/templates/update/src/_q-press/components/MarkdownLink.vue +5 -5
  95. package/dist/templates/update/src/_q-press/components/MarkdownMermaid.vue +123 -0
  96. package/dist/templates/update/src/_q-press/components/MarkdownTree.vue +2 -2
  97. package/dist/templates/update/src/_q-press/components/markdown-utils.ts +27 -3
  98. package/dist/templates/update/src/_q-press/css/app.scss +38 -26
  99. package/dist/templates/update/src/_q-press/css/code-theme.scss +634 -0
  100. package/dist/templates/update/src/_q-press/css/themes/default.scss +1 -1
  101. package/dist/templates/update/src/_q-press/css/themes/evergreen.scss +69 -0
  102. package/dist/templates/update/src/_q-press/css/themes/mystic.scss +1 -1
  103. package/dist/templates/update/src/_q-press/css/themes/newspaper.scss +1 -1
  104. package/dist/templates/update/src/_q-press/css/themes/sunrise.scss +1 -1
  105. package/dist/templates/update/src/_q-press/css/themes/tawny.scss +1 -1
  106. package/dist/templates/update/src/_q-press/layouts/MarkdownDrawerSidebar.vue +1 -1
  107. package/dist/templates/update/src/_q-press/layouts/MarkdownDrawerToc.vue +1 -1
  108. package/dist/templates/update/src/_q-press/layouts/MarkdownHeader.vue +1 -1
  109. package/dist/templates/update/src/_q-press/layouts/MarkdownLayout.vue +2 -2
  110. package/dist/templates/update/src/_q-press/layouts/MarkdownPage.vue +4 -3
  111. package/dist/templates/update/src/_q-press/layouts/MarkdownSearch.vue +1 -1
  112. package/dist/templates/update/src/_q-press/stores/markdown.ts +1 -2
  113. package/package.json +22 -21
  114. package/src/index.ts +80 -11
  115. package/src/install.ts +10 -9
  116. package/src/q-press-globals.d.ts +49 -0
  117. package/src/templates/init/src/_q-press/api/components/MarkdownCode.json +2 -2
  118. package/src/templates/init/src/_q-press/api/components/MarkdownCodepen.json +6 -9
  119. package/src/templates/init/src/_q-press/api/components/MarkdownExample.json +27 -2
  120. package/src/templates/init/src/_q-press/components/MarkdownApi.vue +129 -84
  121. package/src/templates/init/src/_q-press/components/MarkdownCardLink.vue +1 -1
  122. package/src/templates/init/src/_q-press/components/MarkdownCardTitle.vue +1 -1
  123. package/src/templates/init/src/_q-press/components/MarkdownCode.vue +71 -3
  124. package/src/templates/init/src/_q-press/components/MarkdownCodepen.vue +316 -59
  125. package/src/templates/init/src/_q-press/components/MarkdownCopyButton.vue +1 -1
  126. package/src/templates/init/src/_q-press/components/MarkdownExample.vue +54 -19
  127. package/src/templates/init/src/_q-press/components/MarkdownLink.vue +5 -5
  128. package/src/templates/init/src/_q-press/components/MarkdownMermaid.vue +123 -0
  129. package/src/templates/init/src/_q-press/components/MarkdownTree.vue +2 -2
  130. package/src/templates/init/src/_q-press/components/markdown-utils.ts +27 -3
  131. package/src/templates/init/src/_q-press/css/app.scss +38 -26
  132. package/src/templates/init/src/_q-press/css/code-theme.scss +634 -0
  133. package/src/templates/init/src/_q-press/css/themes/default.scss +1 -1
  134. package/src/templates/init/src/_q-press/css/themes/evergreen.scss +69 -0
  135. package/src/templates/init/src/_q-press/css/themes/mystic.scss +1 -1
  136. package/src/templates/init/src/_q-press/css/themes/newspaper.scss +1 -1
  137. package/src/templates/init/src/_q-press/css/themes/sunrise.scss +1 -1
  138. package/src/templates/init/src/_q-press/css/themes/tawny.scss +1 -1
  139. package/src/templates/init/src/_q-press/layouts/MarkdownDrawerSidebar.vue +1 -1
  140. package/src/templates/init/src/_q-press/layouts/MarkdownDrawerToc.vue +1 -1
  141. package/src/templates/init/src/_q-press/layouts/MarkdownHeader.vue +1 -1
  142. package/src/templates/init/src/_q-press/layouts/MarkdownLayout.vue +2 -2
  143. package/src/templates/init/src/_q-press/layouts/MarkdownPage.vue +4 -3
  144. package/src/templates/init/src/_q-press/layouts/MarkdownSearch.vue +1 -1
  145. package/src/templates/init/src/_q-press/stores/markdown.ts +1 -2
  146. package/src/templates/init/src/components/LandingPage/LandingPage.vue +15 -1
  147. package/src/templates/init/src/components/QPressThemeGallery.vue +336 -0
  148. package/src/templates/init/src/components/page-parts/releases/GitHubReleases.vue +121 -0
  149. package/src/templates/init/src/components/page-parts/releases/PackageReleases.vue +191 -0
  150. package/src/templates/init/src/components/page-parts/releases/md-table-parser.ts +52 -0
  151. package/src/templates/init/src/components/page-parts/releases/sanitize.ts +132 -0
  152. package/src/templates/init/src/markdown/__elements.md +8 -8
  153. package/src/templates/init/src/markdown/__elements2.md +4 -4
  154. package/src/templates/init/src/markdown/faq/best-practices.md +27 -0
  155. package/src/templates/init/src/markdown/faq/general.md +27 -0
  156. package/src/templates/init/src/markdown/faq/troubleshooting.md +27 -0
  157. package/src/templates/init/src/markdown/getting-started/introduction.md +7 -5
  158. package/src/templates/init/src/markdown/md-plugins/blockquote/overview.md +3 -1
  159. package/src/templates/init/src/markdown/md-plugins/codeblocks/advanced.md +19 -15
  160. package/src/templates/init/src/markdown/md-plugins/codeblocks/overview.md +45 -8
  161. package/src/templates/init/src/markdown/md-plugins/containers/overview.md +3 -1
  162. package/src/templates/init/src/markdown/md-plugins/frontmatter/overview.md +3 -1
  163. package/src/templates/init/src/markdown/md-plugins/headers/overview.md +3 -1
  164. package/src/templates/init/src/markdown/md-plugins/image/overview.md +3 -1
  165. package/src/templates/init/src/markdown/md-plugins/imports/overview.md +3 -1
  166. package/src/templates/init/src/markdown/md-plugins/inline-code/overview.md +3 -1
  167. package/src/templates/init/src/markdown/md-plugins/link/advanced.md +2 -2
  168. package/src/templates/init/src/markdown/md-plugins/link/overview.md +6 -4
  169. package/src/templates/init/src/markdown/md-plugins/mermaid/advanced.md +69 -0
  170. package/src/templates/init/src/markdown/md-plugins/mermaid/overview.md +73 -0
  171. package/src/templates/init/src/markdown/md-plugins/shared/overview.md +28 -13
  172. package/src/templates/init/src/markdown/md-plugins/table/overview.md +3 -1
  173. package/src/templates/init/src/markdown/md-plugins/title/overview.md +3 -1
  174. package/src/templates/init/src/markdown/other/contact.md +37 -0
  175. package/src/templates/init/src/markdown/other/contributing/bugs-and-feature-requests.md +33 -0
  176. package/src/templates/init/src/markdown/other/contributing/call-to-action.md +25 -0
  177. package/src/templates/init/src/markdown/other/contributing/documentation.md +31 -0
  178. package/src/templates/init/src/markdown/other/contributing/overview.md +41 -0
  179. package/src/templates/init/src/markdown/other/contributing/packages.md +28 -0
  180. package/src/templates/init/src/markdown/other/contributing/sponsor.md +23 -0
  181. package/src/templates/init/src/markdown/other/faq.md +179 -0
  182. package/src/templates/init/src/markdown/other/releases.md +11 -0
  183. package/src/templates/init/src/markdown/other/upgrade-guide.md +165 -0
  184. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/advanced.md +11 -3
  185. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/components.md +25 -29
  186. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/overview.md +20 -20
  187. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/site-config.md +17 -3
  188. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/themes.md +101 -9
  189. package/src/templates/init/src/markdown/quasar-app-extensions/vite-md-plugin-app-ext/advanced.md +158 -0
  190. package/src/templates/init/src/markdown/quasar-app-extensions/vite-md-plugin-app-ext/overview.md +1 -1
  191. package/src/templates/init/src/markdown/vite-plugins/vite-examples-plugin/advanced.md +8 -3
  192. package/src/templates/init/src/markdown/vite-plugins/vite-examples-plugin/overview.md +19 -5
  193. package/src/templates/init/src/markdown/vite-plugins/vite-md-plugin/advanced.md +84 -54
  194. package/src/templates/init/src/markdown/vite-plugins/vite-md-plugin/overview.md +19 -3
  195. package/src/templates/init/src/siteConfig/index.ts +52 -23
  196. package/src/templates/update/src/_q-press/api/components/MarkdownCode.json +2 -2
  197. package/src/templates/update/src/_q-press/api/components/MarkdownCodepen.json +6 -9
  198. package/src/templates/update/src/_q-press/api/components/MarkdownExample.json +27 -2
  199. package/src/templates/update/src/_q-press/components/MarkdownApi.vue +129 -84
  200. package/src/templates/update/src/_q-press/components/MarkdownCardLink.vue +1 -1
  201. package/src/templates/update/src/_q-press/components/MarkdownCardTitle.vue +1 -1
  202. package/src/templates/update/src/_q-press/components/MarkdownCode.vue +71 -3
  203. package/src/templates/update/src/_q-press/components/MarkdownCodepen.vue +316 -59
  204. package/src/templates/update/src/_q-press/components/MarkdownCopyButton.vue +1 -1
  205. package/src/templates/update/src/_q-press/components/MarkdownExample.vue +54 -19
  206. package/src/templates/update/src/_q-press/components/MarkdownLink.vue +5 -5
  207. package/src/templates/update/src/_q-press/components/MarkdownMermaid.vue +123 -0
  208. package/src/templates/update/src/_q-press/components/MarkdownTree.vue +2 -2
  209. package/src/templates/update/src/_q-press/components/markdown-utils.ts +27 -3
  210. package/src/templates/update/src/_q-press/css/app.scss +38 -26
  211. package/src/templates/update/src/_q-press/css/code-theme.scss +634 -0
  212. package/src/templates/update/src/_q-press/css/themes/default.scss +1 -1
  213. package/src/templates/update/src/_q-press/css/themes/evergreen.scss +69 -0
  214. package/src/templates/update/src/_q-press/css/themes/mystic.scss +1 -1
  215. package/src/templates/update/src/_q-press/css/themes/newspaper.scss +1 -1
  216. package/src/templates/update/src/_q-press/css/themes/sunrise.scss +1 -1
  217. package/src/templates/update/src/_q-press/css/themes/tawny.scss +1 -1
  218. package/src/templates/update/src/_q-press/layouts/MarkdownDrawerSidebar.vue +1 -1
  219. package/src/templates/update/src/_q-press/layouts/MarkdownDrawerToc.vue +1 -1
  220. package/src/templates/update/src/_q-press/layouts/MarkdownHeader.vue +1 -1
  221. package/src/templates/update/src/_q-press/layouts/MarkdownLayout.vue +2 -2
  222. package/src/templates/update/src/_q-press/layouts/MarkdownPage.vue +4 -3
  223. package/src/templates/update/src/_q-press/layouts/MarkdownSearch.vue +1 -1
  224. package/src/templates/update/src/_q-press/stores/markdown.ts +1 -2
  225. package/tsconfig.json +1 -1
  226. package/dist/templates/init/src/_q-press/api/components/MarkdownCodePrism.json +0 -29
  227. package/dist/templates/init/src/_q-press/components/MarkdownCodePrism.ts +0 -36
  228. package/dist/templates/init/src/_q-press/css/prism-theme.scss +0 -298
  229. package/dist/templates/init/src/markdown/guides/contributing.md +0 -101
  230. package/dist/templates/init/src/markdown/guides/faq.md +0 -115
  231. package/dist/templates/init/src/markdown/guides/release-notes.md +0 -0
  232. package/dist/templates/init/src/markdown/guides/style-guide.md +0 -0
  233. package/dist/templates/init/src/markdown/guides/upgrade-guide.md +0 -92
  234. package/dist/templates/init/src/markdown/other/release-notes.md +0 -8
  235. package/dist/templates/init/src/q-press.globals.d.ts +0 -36
  236. package/dist/templates/update/src/_q-press/api/components/MarkdownCodePrism.json +0 -29
  237. package/dist/templates/update/src/_q-press/components/MarkdownCodePrism.ts +0 -36
  238. package/dist/templates/update/src/_q-press/css/prism-theme.scss +0 -298
  239. package/dist/templates/update/src/q-press.globals.d.ts +0 -36
  240. package/src/templates/init/src/_q-press/api/components/MarkdownCodePrism.json +0 -29
  241. package/src/templates/init/src/_q-press/components/MarkdownCodePrism.ts +0 -36
  242. package/src/templates/init/src/_q-press/css/prism-theme.scss +0 -298
  243. package/src/templates/init/src/markdown/guides/contributing.md +0 -101
  244. package/src/templates/init/src/markdown/guides/faq.md +0 -115
  245. package/src/templates/init/src/markdown/guides/release-notes.md +0 -0
  246. package/src/templates/init/src/markdown/guides/style-guide.md +0 -0
  247. package/src/templates/init/src/markdown/guides/upgrade-guide.md +0 -92
  248. package/src/templates/init/src/markdown/other/release-notes.md +0 -8
  249. package/src/templates/init/src/q-press.globals.d.ts +0 -36
  250. package/src/templates/update/src/_q-press/api/components/MarkdownCodePrism.json +0 -29
  251. package/src/templates/update/src/_q-press/components/MarkdownCodePrism.ts +0 -36
  252. package/src/templates/update/src/_q-press/css/prism-theme.scss +0 -298
  253. package/src/templates/update/src/q-press.globals.d.ts +0 -36
@@ -11,48 +11,308 @@
11
11
  </form>
12
12
  </template>
13
13
 
14
- <script setup>
14
+ <script setup lang="ts">
15
15
  import { Quasar } from 'quasar'
16
16
  import { ref, reactive, computed, nextTick } from 'vue'
17
17
 
18
- import { slugify } from '@md-plugins/shared'
18
+ import siteConfig from '../../siteConfig'
19
+ import { slugify } from './markdown-utils'
19
20
 
20
- const cssResources = [
21
+ type CodepenParts = {
22
+ Template?: string
23
+ Script?: string
24
+ Style?: string
25
+ [key: string]: string | undefined
26
+ }
27
+
28
+ type CodepenGlobalPackage = {
29
+ packageName: string
30
+ globalName: string
31
+ }
32
+
33
+ const defaultCssResources = [
21
34
  'https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons',
22
35
  `https://cdn.jsdelivr.net/npm/quasar@${Quasar.version}/dist/quasar.min.css`,
23
- ].join(';')
36
+ ]
24
37
 
25
- const jsResources = [
38
+ const defaultJsResources = [
26
39
  'https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js',
27
40
  `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)
41
+ ]
42
+
43
+ function getAbsolutePublicUrl(path: string) {
44
+ const normalizedPath = path.startsWith('/') ? path : `/${path}`
45
+
46
+ return typeof location === 'undefined' ? normalizedPath : `${location.origin}${normalizedPath}`
47
+ }
48
+
49
+ function rewriteRootRelativeUrls(content: string) {
50
+ return content
51
+ .replace(
52
+ /\b(src|href|poster)=("|')\/(?!\/)([^"']*)\2/g,
53
+ (_match: string, attr: string, quote: string, path: string) =>
54
+ `${attr}=${quote}${getAbsolutePublicUrl(path)}${quote}`,
55
+ )
56
+ .replace(
57
+ /url\(\s*(["']?)\/(?!\/)([^"')]+)\1\s*\)/g,
58
+ (_match: string, quote: string, path: string) =>
59
+ `url(${quote}${getAbsolutePublicUrl(path)}${quote})`,
60
+ )
61
+ }
62
+
63
+ function indent(code: string, spaces = 2) {
64
+ const padding = ' '.repeat(spaces)
65
+ let isInsideTemplateLiteral = false
66
+
67
+ return code
68
+ .split('\n')
69
+ .map((line) => {
70
+ const shouldIndent = line.trim().length > 0 && isInsideTemplateLiteral === false
71
+
72
+ for (let index = 0; index < line.length; index++) {
73
+ if (line[index] !== '`') {
74
+ continue
75
+ }
76
+
77
+ let escapeCount = 0
78
+
79
+ for (let escapeIndex = index - 1; escapeIndex >= 0 && line[escapeIndex] === '\\'; escapeIndex--) {
80
+ escapeCount++
81
+ }
82
+
83
+ if (escapeCount % 2 === 0) {
84
+ isInsideTemplateLiteral = !isInsideTemplateLiteral
85
+ }
86
+ }
87
+
88
+ return shouldIndent ? padding + line : line
89
+ })
90
+ .join('\n')
91
+ }
92
+
93
+ function getImportParts(content: string, packageName: string) {
94
+ const parts: { importName: string; bindingName: string }[] = []
95
+ const escapedPackageName = packageName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
96
+ const importRe = new RegExp(
97
+ `import\\s+(?!type\\b){([^}]*)}\\s+from\\s+['"]${escapedPackageName}['"];?`,
98
+ 'g',
99
+ )
100
+ let match: RegExpExecArray | null
101
+
102
+ while ((match = importRe.exec(content)) !== null) {
103
+ for (const part of (match[1] ?? '').split(',')) {
104
+ const rawName = part.trim()
105
+
106
+ if (rawName.length === 0 || rawName.startsWith('type ')) {
107
+ continue
108
+ }
109
+
110
+ const [importName, bindingName = importName] = rawName.split(/\s+as\s+/)
111
+
112
+ if (importName !== undefined && importName.length > 0) {
113
+ parts.push({
114
+ importName,
115
+ bindingName,
116
+ })
117
+ }
118
+ }
119
+ }
120
+
121
+ return parts
122
+ }
123
+
124
+ function getImportNames(content: string, packageName: string) {
125
+ return [
126
+ ...new Set(
127
+ getImportParts(content, packageName).map(({ importName, bindingName }) =>
128
+ importName === bindingName ? importName : `${importName}: ${bindingName}`,
129
+ ),
130
+ ),
131
+ ]
132
+ }
133
+
134
+ function getImportBindingNames(content: string, packageName: string) {
135
+ return [...new Set(getImportParts(content, packageName).map(({ bindingName }) => bindingName))]
136
+ }
137
+
138
+ function getGlobalPackageImportLines(content: string) {
139
+ return (siteConfig.codepen?.globalPackages ?? [])
140
+ .map(({ packageName, globalName }: CodepenGlobalPackage) => {
141
+ const imports = getImportNames(content, packageName)
142
+
143
+ return imports.length > 0 ? `const { ${imports.join(', ')} } = ${globalName}` : ''
144
+ })
145
+ .filter((line) => line.length > 0)
146
+ }
147
+
148
+ function getGlobalImportLines(content: string) {
149
+ const vueImports = getImportNames(content, 'vue')
150
+ const quasarImports = getImportNames(content, 'quasar')
151
+
152
+ return [
153
+ vueImports.length > 0 ? `const { ${vueImports.join(', ')} } = Vue` : '',
154
+ quasarImports.length > 0 ? `const { ${quasarImports.join(', ')} } = Quasar` : '',
155
+ ...getGlobalPackageImportLines(content),
156
+ ].filter((line) => line.length > 0)
157
+ }
158
+
159
+ function getGlobalImportBindingNames(content: string) {
160
+ return [
161
+ ...getImportBindingNames(content, 'vue'),
162
+ ...getImportBindingNames(content, 'quasar'),
163
+ ...(siteConfig.codepen?.globalPackages ?? []).flatMap(({ packageName }: CodepenGlobalPackage) =>
164
+ getImportBindingNames(content, packageName),
165
+ ),
166
+ ]
167
+ }
168
+
169
+ function stripImports(content: string) {
170
+ return content
171
+ .replace(/^\s*import\s+type\s+[\s\S]*?\s+from\s+['"][^'"]+['"];?\s*$/gm, '')
172
+ .replace(/^\s*import\s+[\s\S]*?\s+from\s+['"][^'"]+['"];?\s*$/gm, '')
173
+ .replace(/^\s*import\s+['"][^'"]+['"];?\s*$/gm, '')
174
+ .trim()
175
+ }
176
+
177
+ function stripCompilerMacros(content: string) {
178
+ return content
179
+ .replace(/^\s*defineOptions\(\s*\{[\s\S]*?\}\s*\)\s*;?\s*$/gm, '')
180
+ .replace(/^\s*defineExpose\(\s*\{[\s\S]*?\}\s*\)\s*;?\s*$/gm, '')
181
+ .trim()
182
+ }
183
+
184
+ function getScriptBlock(script: string, setup: boolean) {
185
+ const re = setup
186
+ ? /<script\s+setup([^>]*)>([\s\S]*?)<\/script>/
187
+ : /<script(?!\s+setup)([^>]*)>([\s\S]*?)<\/script>/
188
+ const match = re.exec(script)
189
+
190
+ return {
191
+ attrs: match?.[1] ?? '',
192
+ content: match?.[2] ?? '',
193
+ }
194
+ }
195
+
196
+ function getSetupReturnNames(content: string) {
197
+ const names = new Set<string>()
198
+ const topLevelContent = getTopLevelContent(content)
199
+ const declarationRe =
200
+ /(?:^|\n)\s*(?:const|let|var)\s+([\s\S]*?)(?=\n\s*(?:const|let|var|function|interface|type|class)\s+|\s*$)/g
201
+ const variableNameRe = /(?:^|\n)\s*([A-Za-z_$][\w$]*)\s*(?:[:=,]|$)/g
202
+ const functionRe = /(?:^|\n)\s*(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g
203
+ let match: RegExpExecArray | null
204
+
205
+ while ((match = declarationRe.exec(topLevelContent)) !== null) {
206
+ let variableMatch: RegExpExecArray | null
207
+
208
+ while ((variableMatch = variableNameRe.exec(match[1] ?? '')) !== null) {
209
+ if (variableMatch[1] !== undefined) {
210
+ names.add(variableMatch[1])
211
+ }
212
+ }
213
+ }
214
+
215
+ while ((match = functionRe.exec(topLevelContent)) !== null) {
216
+ if (match[1] !== undefined) {
217
+ names.add(match[1])
44
218
  }
45
- return text.join('\n')
46
219
  }
47
220
 
221
+ return [...names]
222
+ }
223
+
224
+ function getTopLevelContent(content: string) {
225
+ let depth = 0
226
+ let output = ''
227
+
228
+ for (const char of content) {
229
+ if (depth === 0 || char === '\n') {
230
+ output += char
231
+ } else {
232
+ output += ' '
233
+ }
234
+
235
+ if (char === '{') {
236
+ depth++
237
+ } else if (char === '}') {
238
+ depth = Math.max(0, depth - 1)
239
+ }
240
+ }
241
+
242
+ return output
243
+ }
244
+
245
+ function getAppSetup() {
246
+ return ['app.use(Quasar, { config: {} })', siteConfig.codepen?.jsSetup ?? '']
247
+ .map((line) => line.trim())
248
+ .filter((line) => line.length > 0)
249
+ .join('\n')
250
+ }
251
+
252
+ function createSetupScript(script: string) {
253
+ const { content } = getScriptBlock(script, true)
254
+ const globalImports = getGlobalImportLines(content)
255
+ const setupContent = stripCompilerMacros(stripImports(content))
256
+ const returnNames = [
257
+ ...new Set([...getGlobalImportBindingNames(content), ...getSetupReturnNames(setupContent)]),
258
+ ]
259
+ const setupBody = [
260
+ setupContent.length > 0 ? indent(setupContent, 4) : '',
261
+ returnNames.length > 0 ? ` return { ${returnNames.join(', ')} }` : '',
262
+ ]
263
+ .filter((line) => line.length > 0)
264
+ .join('\n\n')
265
+
266
+ return [
267
+ ...globalImports,
268
+ `const app = Vue.createApp({
269
+ setup () {
270
+ ${setupBody}
271
+ }
272
+ })`,
273
+ getAppSetup(),
274
+ "app.mount('#q-app')",
275
+ ].join('\n\n')
276
+ }
277
+
278
+ function createOptionsScript(script: string) {
279
+ const { content } = getScriptBlock(script, false)
280
+ const globalImports = getGlobalImportLines(content)
281
+ const match = /export\s+default\s+{([\s\S]*)}/.exec(content)
282
+ const beforeDefault = match === null ? stripImports(content) : stripImports(content.slice(0, match.index))
283
+ let component = match?.[1]?.trim() ?? ''
284
+
285
+ if (component.length > 0) {
286
+ component = '\n ' + component + '\n'
287
+ }
288
+
289
+ return [
290
+ ...globalImports,
291
+ beforeDefault,
292
+ `const app = Vue.createApp({${component}})`,
293
+ getAppSetup(),
294
+ "app.mount('#q-app')",
295
+ ]
296
+ .filter((line) => line.length > 0)
297
+ .join('\n\n')
298
+ }
299
+
48
300
  const props = defineProps({ title: { type: String, required: true } })
49
301
 
50
302
  const active = ref(false)
51
- const formRef = ref(null)
52
- const def = reactive({ parts: {} })
303
+ const formRef = ref<HTMLFormElement | null>(null)
304
+ const def = reactive<{ parts: CodepenParts }>({ parts: {} })
305
+
306
+ const cssResources = computed(() => {
307
+ return [...defaultCssResources, ...(siteConfig.codepen?.cssExternal ?? [])].join(';')
308
+ })
309
+
310
+ const jsResources = computed(() => {
311
+ return [...defaultJsResources, ...(siteConfig.codepen?.jsExternal ?? [])].join(';')
312
+ })
53
313
 
54
314
  const css = computed(() => {
55
- return (def.parts.Style || '').replace(/(<style.*?>|<\/style>)/g, '').trim()
315
+ return rewriteRootRelativeUrls((def.parts.Style || '').replace(/(<style.*?>|<\/style>)/g, '').trim())
56
316
  })
57
317
 
58
318
  const cssPreprocessor = computed(() => {
@@ -62,42 +322,32 @@ const cssPreprocessor = computed(() => {
62
322
  })
63
323
 
64
324
  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 || '')
325
+ const script = def.parts.Script ?? ''
69
326
 
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()
327
+ return script.includes('<script setup') === true
328
+ ? createSetupScript(script)
329
+ : createOptionsScript(script)
330
+ })
81
331
 
82
- script += script ? '\n\n' : ''
83
- return (
84
- script +
85
- `const app = Vue.createApp({${component}})
332
+ const jsPreProcessor = computed(() => {
333
+ const setupBlock = getScriptBlock(def.parts.Script ?? '', true)
334
+ const optionsBlock = getScriptBlock(def.parts.Script ?? '', false)
335
+ const attrs = setupBlock.content.length > 0 ? setupBlock.attrs : optionsBlock.attrs
86
336
 
87
- app.use(Quasar, { config: {} })
88
- app.mount('#q-app')
89
- `
90
- )
337
+ return siteConfig.codepen?.jsPreProcessor ?? (/lang=["']ts["']/.test(attrs) ? 'typescript' : 'babel')
91
338
  })
92
339
 
93
340
  const html = computed(() => {
94
- return (def.parts.Template || '')
341
+ const content = (def.parts.Template || '')
95
342
  .replace(/(<template>|<\/template>$)/g, '')
96
343
  .replace(/\n/g, '\n ')
97
344
  .replace(/([\w]+=")([^"]*?)(")/g, function (match, p1, p2, p3) {
98
345
  return p1 + p2.replace(/>/g, '___TEMP_REPLACEMENT___') + p3
99
346
  })
100
- .replace(/<(q-[\w-]+|div)([^>]*?)\s*?([\n\r][\t ]+)?\/>/gs, '<$1$2$3></$1>')
347
+ .replace(
348
+ /<([A-Z][\w-]*|[a-z][\w]*-[\w-]+|div)([^>]*?)\s*?([\n\r][\t ]+)?\/>/gs,
349
+ '<$1$2$3></$1>',
350
+ )
101
351
  .replace(
102
352
  /(<template[^>]*>)(\s*?(?:[\n\r][\t ]+)?)<(thead|tbody|tfoot)/gs,
103
353
  '$1$2<___PREVENT_TEMPLATE___$3',
@@ -122,18 +372,25 @@ const html = computed(() => {
122
372
  .replace(/___TEMP_REPLACEMENT___/g, '>')
123
373
  .replace(/^\s{2}/gm, '')
124
374
  .trim()
375
+
376
+ return rewriteRootRelativeUrls(content)
125
377
  })
126
378
 
127
379
  const editors = computed(() => {
128
- const flag = (html.value && 0b100) | (css.value && 0b010) | (js.value && 0b001)
380
+ const flag =
381
+ (html.value.length > 0 ? 0b100 : 0) |
382
+ (css.value.length > 0 ? 0b010 : 0) |
383
+ (js.value.length > 0 ? 0b001 : 0)
129
384
  return flag.toString(2)
130
385
  })
131
386
 
132
387
  const computedTitle = computed(() => {
388
+ const titleSuffix = siteConfig.codepen?.titleSuffix ?? `Quasar v${Quasar.version}`
389
+
133
390
  return (
134
391
  (typeof document !== 'undefined' ? document.title.split(' | ')[0] + ': ' : '') +
135
392
  (props.title ? props.title + ' - ' : '') +
136
- `Quasar v${Quasar.version}`
393
+ titleSuffix
137
394
  )
138
395
  })
139
396
 
@@ -157,14 +414,14 @@ ${location.origin + location.pathname}#${slugifiedTitle.value}
157
414
  <div id="q-app" style="min-height: 100vh;">
158
415
  ${html.value}
159
416
  </div>`,
160
- head: '',
161
417
  html_pre_processor: 'none',
162
418
  css: css.value,
163
419
  css_pre_processor: cssPreprocessor.value,
164
- css_external: cssResources,
420
+ css_external: cssResources.value,
165
421
  js: js.value,
166
- js_pre_processor: 'babel',
167
- js_external: jsResources,
422
+ js_pre_processor: jsPreProcessor.value,
423
+ js_external: jsResources.value,
424
+ head: siteConfig.codepen?.head ?? '',
168
425
  editors: editors.value,
169
426
  }
170
427
  return JSON.stringify(data)
@@ -175,18 +432,18 @@ ${html.value}
175
432
  *
176
433
  * @param {string} whichParts - The parts of the application to open.
177
434
  */
178
- function open(whichParts) {
435
+ function open(whichParts: CodepenParts) {
179
436
  def.parts = whichParts
180
437
 
181
438
  if (active.value) {
182
- formRef.value.submit()
439
+ formRef.value?.submit()
183
440
  return
184
441
  }
185
442
 
186
443
  active.value = true
187
444
 
188
445
  nextTick(() => {
189
- formRef.value.submit()
446
+ formRef.value?.submit()
190
447
  })
191
448
  }
192
449
 
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
  </template>
10
10
 
11
- <script setup>
11
+ <script setup lang="ts">
12
12
  import { ref, getCurrentInstance } from 'vue'
13
13
  import { copyToClipboard } from './markdown-utils'
14
14
  import { mdiClipboardOutline } from '@quasar/extras/mdi-v7'
@@ -92,11 +92,11 @@
92
92
  </q-card>
93
93
  </template>
94
94
 
95
- <script setup>
96
- import { computed, inject, markRaw, ref, reactive, onMounted } from 'vue'
95
+ <script setup lang="ts">
96
+ import { computed, inject, markRaw, ref, reactive, onBeforeUnmount, onMounted } from 'vue'
97
97
  import { openURL } from 'quasar'
98
98
 
99
- import { fabGithub, fabCodepen } from '@quasar/extras/fontawesome-v6'
99
+ import { fabGithub, fabCodepen } from '@quasar/extras/fontawesome-v7'
100
100
  // import { mdiCompare } from '@quasar/extras/mdi-v7'
101
101
 
102
102
  import MarkdownCode from './MarkdownCode.vue'
@@ -134,6 +134,7 @@ const def = reactive({
134
134
  })
135
135
  const currentTab = ref('Template')
136
136
  const expanded = ref(false)
137
+ let removeHmrListener = () => {}
137
138
 
138
139
  /**
139
140
  * A computed property that returns the CSS class for the component.
@@ -186,7 +187,8 @@ function parseComponent(comp) {
186
187
  }
187
188
 
188
189
  function openGitHub() {
189
- openURL(`${siteConfig.githubEditRootSrc}/examples/${examples.name}/${props.file}.vue`)
190
+ const root = siteConfig.githubSourceRootSrc ?? siteConfig.githubEditRootSrc.replace('/edit/', '/tree/')
191
+ openURL(`${root}/examples/${examples.name}/${props.file}.vue`)
190
192
  }
191
193
 
192
194
  function openCodepen() {
@@ -197,23 +199,56 @@ function toggleExpand() {
197
199
  expanded.value = expanded.value === false
198
200
  }
199
201
 
202
+ async function loadExample() {
203
+ const list = await examples.list
204
+ const devFile = `/src/examples/${examples.name}/${props.file}.vue`
205
+
206
+ if (import.meta.env.QUASAR_DEV) {
207
+ const loadComponent = list.code[devFile]
208
+ const loadSource = list.source[devFile]
209
+
210
+ if (loadComponent === void 0 || loadSource === void 0) {
211
+ throw new Error(`Markdown example not found: ${devFile}`)
212
+ }
213
+
214
+ const componentModule = await loadComponent()
215
+ const source = await loadSource()
216
+
217
+ component.value = markRaw(componentModule.default)
218
+ parseComponent(source)
219
+ } else {
220
+ component.value = markRaw(list[props.file])
221
+ parseComponent(list[`Raw${props.file}`])
222
+ }
223
+
224
+ isBusy.value = false
225
+ }
226
+
200
227
  if (import.meta.env.QUASAR_CLIENT) {
201
228
  onMounted(() => {
202
- examples.list.then((list) => {
203
- component.value = markRaw(
204
- import.meta.env.QUASAR_DEV
205
- ? list.code[`/src/examples/${examples.name}/${props.file}.vue`].default
206
- : list[props.file],
207
- )
208
-
209
- parseComponent(
210
- import.meta.env.QUASAR_DEV
211
- ? list.source[`/src/examples/${examples.name}/${props.file}.vue`]
212
- : list[`Raw${props.file}`],
213
- )
214
-
215
- isBusy.value = false
216
- })
229
+ void loadExample()
230
+
231
+ if (import.meta.hot) {
232
+ const examplePath = `/src/examples/${examples.name}/${props.file}.vue`
233
+ const onAfterUpdate = (payload) => {
234
+ const shouldReload = payload.updates.some(
235
+ (update) => update.path === examplePath || update.acceptedPath === examplePath,
236
+ )
237
+
238
+ if (shouldReload === true) {
239
+ void loadExample()
240
+ }
241
+ }
242
+
243
+ import.meta.hot.on('vite:afterUpdate', onAfterUpdate)
244
+ removeHmrListener = () => {
245
+ import.meta.hot?.off('vite:afterUpdate', onAfterUpdate)
246
+ }
247
+ }
248
+ })
249
+
250
+ onBeforeUnmount(() => {
251
+ removeHmrListener()
217
252
  })
218
253
  }
219
254
  </script>
@@ -8,9 +8,9 @@
8
8
  </a>
9
9
  </template>
10
10
 
11
- <script setup>
11
+ <script setup lang="ts">
12
12
  import { computed } from 'vue'
13
- import { mdiLaunch } from '@quasar/extras/mdi-v6'
13
+ import { mdiLaunch } from '@quasar/extras/mdi-v7'
14
14
 
15
15
  const props = defineProps({ to: { type: String, required: true } })
16
16
  const internal = computed(
@@ -20,14 +20,14 @@ const internal = computed(
20
20
 
21
21
  <style lang="scss">
22
22
  .markdown-link {
23
- color: scale-color($brand-primary, $lightness: -35%);
23
+ color: $brand-light-text;
24
24
  text-decoration: none;
25
- border-bottom: 1px dotted currentColor;
25
+ border-bottom: 1px dotted rgba($brand-primary, 0.78);
26
26
  outline: 0;
27
27
  transition: color $header-quick-transition;
28
28
 
29
29
  body.body--dark & {
30
- color: $brand-primary;
30
+ color: $brand-dark-text;
31
31
  }
32
32
 
33
33
  &:hover {