@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.
- package/LICENSE.md +21 -0
- package/README.md +230 -0
- package/old/prompts.js +44 -0
- package/old/uninstall.js +9 -0
- package/package.json +60 -0
- package/scripts/build.js +33 -0
- package/src/index.js +63 -0
- package/src/install.js +49 -0
- package/src/templates/.gitkeep +0 -0
- package/src/templates/init/src/_q-press/.gitkeep +0 -0
- package/src/templates/init/src/_q-press/api/components/DarkModeToggle.json +37 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownApi.json +67 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCardLink.json +28 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCode.json +37 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCodepen.json +21 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownExample.json +22 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeader.json +28 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownInstallation.json +33 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownLayout.json +52 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownLink.json +23 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPage.json +71 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPageToc.json +17 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPrerender.json +25 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownTree.json +27 -0
- package/src/templates/init/src/_q-press/api/composables/dark.json +29 -0
- package/src/templates/init/src/_q-press/api/composables/scroll.json +34 -0
- package/src/templates/init/src/_q-press/assets/get-meta.ts +29 -0
- package/src/templates/init/src/_q-press/components/DarkModeToggle.vue +105 -0
- package/src/templates/init/src/_q-press/components/MarkdownApi.vue +588 -0
- package/src/templates/init/src/_q-press/components/MarkdownApiEntry.ts +594 -0
- package/src/templates/init/src/_q-press/components/MarkdownCardLink.vue +25 -0
- package/src/templates/init/src/_q-press/components/MarkdownCardTitle.vue +21 -0
- package/src/templates/init/src/_q-press/components/MarkdownCode.vue +25 -0
- package/src/templates/init/src/_q-press/components/MarkdownCodePrism.ts +36 -0
- package/src/templates/init/src/_q-press/components/MarkdownCodepen.vue +183 -0
- package/src/templates/init/src/_q-press/components/MarkdownCopyButton.vue +104 -0
- package/src/templates/init/src/_q-press/components/MarkdownExample.vue +221 -0
- package/src/templates/init/src/_q-press/components/MarkdownInstallation.vue +166 -0
- package/src/templates/init/src/_q-press/components/MarkdownLink.vue +38 -0
- package/src/templates/init/src/_q-press/components/MarkdownPrerender.ts +82 -0
- package/src/templates/init/src/_q-press/components/MarkdownTree.vue +105 -0
- package/src/templates/init/src/_q-press/components/markdown-utils.ts +105 -0
- package/src/templates/init/src/_q-press/composables/dark.ts +39 -0
- package/src/templates/init/src/_q-press/composables/scroll.ts +115 -0
- package/src/templates/init/src/_q-press/css/app.scss +662 -0
- package/src/templates/init/src/_q-press/css/fonts.scss +100 -0
- package/src/templates/init/src/_q-press/css/prism-theme.scss +298 -0
- package/src/templates/init/src/_q-press/css/themes/default.scss +68 -0
- package/src/templates/init/src/_q-press/css/themes/newspaper.scss +69 -0
- package/src/templates/init/src/_q-press/css/themes/sunrise.scss +67 -0
- package/src/templates/init/src/_q-press/css/themes/tawny.scss +69 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeader.vue +412 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownLayout.vue +239 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPage.vue +307 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownSearch.vue +449 -0
- package/src/templates/init/src/_q-press/stores/markdown.ts +101 -0
- package/src/templates/init/src/components/LandingPage/LandingPage.vue +341 -0
- package/src/templates/init/src/components/Releases/PackageReleases.vue +164 -0
- package/src/templates/init/src/components/Releases/PublicReleases.vue +149 -0
- package/src/templates/init/src/components/Releases/ReleasesAvailable.vue +74 -0
- package/src/templates/init/src/examples/QAvatar/BasicExample.vue +11 -0
- package/src/templates/init/src/markdown/__elements.md +548 -0
- package/src/templates/init/src/markdown/__elements2.md +347 -0
- package/src/templates/init/src/markdown/faq/best-practices.md +0 -0
- package/src/templates/init/src/markdown/faq/general.md +0 -0
- package/src/templates/init/src/markdown/faq/troubleshooting.md +0 -0
- package/src/templates/init/src/markdown/getting-started/introduction.md +67 -0
- package/src/templates/init/src/markdown/guides/contributing.md +101 -0
- package/src/templates/init/src/markdown/guides/faq.md +115 -0
- package/src/templates/init/src/markdown/guides/release-notes.md +0 -0
- package/src/templates/init/src/markdown/guides/style-guide.md +0 -0
- package/src/templates/init/src/markdown/landing-page.md +11 -0
- package/src/templates/init/src/markdown/listing.ts +3 -0
- package/src/templates/init/src/markdown/md-plugins/blockquote/advanced.md +83 -0
- package/src/templates/init/src/markdown/md-plugins/blockquote/overview.md +183 -0
- package/src/templates/init/src/markdown/md-plugins/codeblocks/advanced.md +210 -0
- package/src/templates/init/src/markdown/md-plugins/codeblocks/overview.md +616 -0
- package/src/templates/init/src/markdown/md-plugins/containers/advanced.md +301 -0
- package/src/templates/init/src/markdown/md-plugins/containers/overview.md +206 -0
- package/src/templates/init/src/markdown/md-plugins/frontmatter/advanced.md +164 -0
- package/src/templates/init/src/markdown/md-plugins/frontmatter/overview.md +131 -0
- package/src/templates/init/src/markdown/md-plugins/headers/advanced.md +236 -0
- package/src/templates/init/src/markdown/md-plugins/headers/overview.md +134 -0
- package/src/templates/init/src/markdown/md-plugins/image/advanced.md +114 -0
- package/src/templates/init/src/markdown/md-plugins/image/overview.md +124 -0
- package/src/templates/init/src/markdown/md-plugins/imports/advanced.md +105 -0
- package/src/templates/init/src/markdown/md-plugins/imports/overview.md +80 -0
- package/src/templates/init/src/markdown/md-plugins/inline-code/advanced.md +133 -0
- package/src/templates/init/src/markdown/md-plugins/inline-code/overview.md +101 -0
- package/src/templates/init/src/markdown/md-plugins/link/advanced.md +157 -0
- package/src/templates/init/src/markdown/md-plugins/link/overview.md +126 -0
- package/src/templates/init/src/markdown/md-plugins/shared/overview.md +175 -0
- package/src/templates/init/src/markdown/md-plugins/table/advanced.md +190 -0
- package/src/templates/init/src/markdown/md-plugins/table/overview.md +186 -0
- package/src/templates/init/src/markdown/md-plugins/title/advanced.md +88 -0
- package/src/templates/init/src/markdown/md-plugins/title/overview.md +99 -0
- package/src/templates/init/src/markdown/other/release-notes.md +12 -0
- package/src/templates/init/src/markdown/privacy-policy.md +12 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/advanced.md +101 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/components.md +69 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/overview.md +254 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/themes.md +4 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/advanced.md +4 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/overview.md +103 -0
- package/src/templates/init/src/markdown/vite-plugins/index.md +6 -0
- package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/advanced.md +138 -0
- package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/overview.md +88 -0
- package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/advanced.md +226 -0
- package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/index.md +6 -0
- package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/overview.md +166 -0
- package/src/templates/init/src/q-press.globals.d.ts +36 -0
- package/src/templates/init/src/siteConfig/index.ts +440 -0
- package/src/templates/update/src/_q-press/.gitkeep +0 -0
- package/src/templates/update/src/_q-press/api/components/DarkModeToggle.json +37 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownApi.json +67 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCardLink.json +28 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCode.json +37 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCodepen.json +21 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownExample.json +22 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeader.json +28 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownInstallation.json +33 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownLayout.json +52 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownLink.json +23 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPage.json +71 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPageToc.json +17 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPrerender.json +25 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownTree.json +27 -0
- package/src/templates/update/src/_q-press/api/composables/dark.json +29 -0
- package/src/templates/update/src/_q-press/api/composables/scroll.json +34 -0
- package/src/templates/update/src/_q-press/assets/get-meta.ts +29 -0
- package/src/templates/update/src/_q-press/components/DarkModeToggle.vue +105 -0
- package/src/templates/update/src/_q-press/components/MarkdownApi.vue +588 -0
- package/src/templates/update/src/_q-press/components/MarkdownApiEntry.ts +594 -0
- package/src/templates/update/src/_q-press/components/MarkdownCardLink.vue +25 -0
- package/src/templates/update/src/_q-press/components/MarkdownCardTitle.vue +21 -0
- package/src/templates/update/src/_q-press/components/MarkdownCode.vue +25 -0
- package/src/templates/update/src/_q-press/components/MarkdownCodePrism.ts +36 -0
- package/src/templates/update/src/_q-press/components/MarkdownCodepen.vue +183 -0
- package/src/templates/update/src/_q-press/components/MarkdownCopyButton.vue +104 -0
- package/src/templates/update/src/_q-press/components/MarkdownExample.vue +221 -0
- package/src/templates/update/src/_q-press/components/MarkdownInstallation.vue +166 -0
- package/src/templates/update/src/_q-press/components/MarkdownLink.vue +38 -0
- package/src/templates/update/src/_q-press/components/MarkdownPrerender.ts +82 -0
- package/src/templates/update/src/_q-press/components/MarkdownTree.vue +105 -0
- package/src/templates/update/src/_q-press/components/markdown-utils.ts +105 -0
- package/src/templates/update/src/_q-press/composables/dark.ts +39 -0
- package/src/templates/update/src/_q-press/composables/scroll.ts +115 -0
- package/src/templates/update/src/_q-press/css/app.scss +662 -0
- package/src/templates/update/src/_q-press/css/fonts.scss +100 -0
- package/src/templates/update/src/_q-press/css/prism-theme.scss +298 -0
- package/src/templates/update/src/_q-press/css/themes/default.scss +68 -0
- package/src/templates/update/src/_q-press/css/themes/newspaper.scss +69 -0
- package/src/templates/update/src/_q-press/css/themes/sunrise.scss +67 -0
- package/src/templates/update/src/_q-press/css/themes/tawny.scss +69 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeader.vue +412 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownLayout.vue +239 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPage.vue +307 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownSearch.vue +449 -0
- package/src/templates/update/src/_q-press/stores/markdown.ts +101 -0
- package/src/templates/update/src/q-press.globals.d.ts +36 -0
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
import { h, ref, type Ref, type PropType, type VNode, defineComponent } from 'vue'
|
|
2
|
+
import { QBadge, QBtn, Notify, QBtnToggle } from 'quasar'
|
|
3
|
+
import { copyToClipboard } from './markdown-utils'
|
|
4
|
+
import { mdiMinusBox, mdiPlusBox } from '@quasar/extras/mdi-v7'
|
|
5
|
+
|
|
6
|
+
function copyPropName(propName: string): void {
|
|
7
|
+
copyToClipboard(propName)
|
|
8
|
+
|
|
9
|
+
Notify.create({
|
|
10
|
+
message: `"${propName}" has been copied to clipboard.`,
|
|
11
|
+
position: 'top',
|
|
12
|
+
actions: [{ icon: 'cancel', color: 'white', dense: true, round: true }],
|
|
13
|
+
timeout: 2000,
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getEventParams(event: { params?: Record<string, any> | null }): string {
|
|
18
|
+
const params =
|
|
19
|
+
event.params === void 0 || event.params === null || event.params.length === 0
|
|
20
|
+
? ''
|
|
21
|
+
: Object.keys(event.params).join(', ')
|
|
22
|
+
|
|
23
|
+
return `(${params}) => void`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getMethodParams(
|
|
27
|
+
method: { params?: Record<string, any> | null },
|
|
28
|
+
noRequired?: boolean,
|
|
29
|
+
): string {
|
|
30
|
+
if (method.params === void 0 || method.params === null || method.params.length === 0) {
|
|
31
|
+
return ' ()'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (noRequired === true) {
|
|
35
|
+
return ` (${Object.keys(method.params).join(', ')})`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const params = Object.keys(method.params)
|
|
39
|
+
const optionalIndex = params.findIndex(
|
|
40
|
+
(param) => method.params && method.params[param]?.required !== true,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
const str =
|
|
44
|
+
optionalIndex !== -1
|
|
45
|
+
? params.slice(0, optionalIndex).join(', ') +
|
|
46
|
+
(optionalIndex < params.length
|
|
47
|
+
? (optionalIndex > 0 ? ', ' : '') + params.slice(optionalIndex).join('?, ') + '?'
|
|
48
|
+
: '')
|
|
49
|
+
: params.join(', ')
|
|
50
|
+
|
|
51
|
+
return ' (' + str + ')'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getMethodReturnValue(method: { returns?: { type: any } | null }): string {
|
|
55
|
+
return (
|
|
56
|
+
' => ' +
|
|
57
|
+
(method.returns === void 0 || method.returns === null
|
|
58
|
+
? 'void'
|
|
59
|
+
: getStringType(method.returns.type))
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getStringType(type: any): string {
|
|
64
|
+
return Array.isArray(type) ? type.join(' | ') : type
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const NAME_PROP_COLOR = ['orange-8', 'brand-primary', 'green-5', 'purple-5']
|
|
68
|
+
const NAME_PROP_COLOR_LEN = NAME_PROP_COLOR.length
|
|
69
|
+
|
|
70
|
+
function getDiv(col: number, propName: string, propValue?: string, slot?: any): VNode {
|
|
71
|
+
return h('div', { class: `markdown-api-entry__item col-xs-12 col-sm-${col}` }, [
|
|
72
|
+
h('div', { class: 'markdown-api-entry__type' }, propName),
|
|
73
|
+
propValue !== void 0 ? h('div', { class: 'markdown-api-entry__value' }, propValue) : slot,
|
|
74
|
+
])
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getNameDiv(
|
|
78
|
+
prop: any,
|
|
79
|
+
label: string,
|
|
80
|
+
level: number,
|
|
81
|
+
suffix?: string,
|
|
82
|
+
prefix?: string,
|
|
83
|
+
): VNode {
|
|
84
|
+
const child: VNode[] = []
|
|
85
|
+
|
|
86
|
+
if (prefix !== void 0) {
|
|
87
|
+
child.push(h('div', { class: 'markdown-api-entry__type q-mr-xs' }, prefix))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
child.push(
|
|
91
|
+
h(QBadge, {
|
|
92
|
+
class: 'markdown-api-entry__pill cursor-pointer',
|
|
93
|
+
label,
|
|
94
|
+
color: NAME_PROP_COLOR[level % NAME_PROP_COLOR_LEN],
|
|
95
|
+
onClick: () => {
|
|
96
|
+
copyPropName(label)
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
const suffixLabel = `${suffix ? ` : ${suffix}` : ''}${prop.required ? ' - required!' : ''}`
|
|
102
|
+
if (suffixLabel !== '') {
|
|
103
|
+
child.push(h('div', { class: 'markdown-api-entry__type q-ml-xs' }, suffixLabel))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (prop.addedIn !== void 0) {
|
|
107
|
+
child.push(
|
|
108
|
+
h(QBadge, {
|
|
109
|
+
class: 'q-ml-sm markdown-api-entry__added-in',
|
|
110
|
+
outline: true,
|
|
111
|
+
label: prop.addedIn + '+',
|
|
112
|
+
}),
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return h('div', { class: 'markdown-api-entry__item col-xs-12 col-sm-12 row items-center' }, child)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getExpandable(
|
|
120
|
+
openState: Ref<Record<string, boolean>>,
|
|
121
|
+
desc: string,
|
|
122
|
+
isExpandable: boolean,
|
|
123
|
+
key: string,
|
|
124
|
+
getDetails: () => any[],
|
|
125
|
+
): VNode[] {
|
|
126
|
+
if (isExpandable === true) {
|
|
127
|
+
const expanded = openState.value[key] === true
|
|
128
|
+
const child = [
|
|
129
|
+
h('div', { class: 'markdown-api-entry__item col-xs-12 col-sm-12' }, [
|
|
130
|
+
h('div', { class: 'markdown-api-entry__type row items-center no-wrap' }, [
|
|
131
|
+
h('span', 'Description'),
|
|
132
|
+
h(QBtn, {
|
|
133
|
+
class: 'markdown-api-entry__expand-btn header-btn',
|
|
134
|
+
flat: true,
|
|
135
|
+
size: '11px',
|
|
136
|
+
padding: '1px',
|
|
137
|
+
icon: expanded === true ? mdiMinusBox : mdiPlusBox,
|
|
138
|
+
onClick: () => {
|
|
139
|
+
openState.value[key] = expanded === false
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
]),
|
|
143
|
+
h('div', { class: 'markdown-api-entry__value' }, desc),
|
|
144
|
+
]),
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
return expanded === true ? child.concat(getDetails()) : child
|
|
148
|
+
} else {
|
|
149
|
+
return [getDiv(12, 'Description', desc)]
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getPropDetails(
|
|
154
|
+
openState: Ref<Record<string, boolean>>,
|
|
155
|
+
masterKey: string,
|
|
156
|
+
prop: any,
|
|
157
|
+
level: number,
|
|
158
|
+
): VNode[] {
|
|
159
|
+
const details: VNode[] = []
|
|
160
|
+
|
|
161
|
+
if (prop.sync === true) {
|
|
162
|
+
details.push(getDiv(3, 'Note', 'Required to be used with v-model!'))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (prop.default !== void 0) {
|
|
166
|
+
details.push(
|
|
167
|
+
getDiv(
|
|
168
|
+
3,
|
|
169
|
+
'Default value',
|
|
170
|
+
void 0,
|
|
171
|
+
h(
|
|
172
|
+
'div',
|
|
173
|
+
{ class: 'markdown-api-entry--indent markdown-api-entry__value' },
|
|
174
|
+
h('div', { class: 'markdown-token' }, '' + prop.default),
|
|
175
|
+
),
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (prop.link === true) {
|
|
181
|
+
details.push(getDiv(6, 'External link', prop.link))
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (prop.values !== void 0) {
|
|
185
|
+
details.push(
|
|
186
|
+
getDiv(
|
|
187
|
+
12,
|
|
188
|
+
'Accepted values',
|
|
189
|
+
void 0,
|
|
190
|
+
h(
|
|
191
|
+
'div',
|
|
192
|
+
{ class: 'markdown-api-entry--indent markdown-api-entry__value' },
|
|
193
|
+
prop.values.map((val: any) => h('div', { class: 'markdown-token' }, '' + val)),
|
|
194
|
+
),
|
|
195
|
+
),
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (prop.definition !== void 0) {
|
|
200
|
+
const nodes: VNode[] = []
|
|
201
|
+
for (const propName in prop.definition) {
|
|
202
|
+
nodes.push(...getProp(openState, masterKey, prop.definition[propName], propName, level))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
details.push(
|
|
206
|
+
getDiv(12, 'Props', void 0, h('div', { class: 'markdown-api-entry__subitem' }, nodes)),
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (prop.params !== void 0 && prop.params !== null) {
|
|
211
|
+
const nodes: VNode[] = []
|
|
212
|
+
|
|
213
|
+
for (const propName in prop.params) {
|
|
214
|
+
nodes.push(...getProp(openState, masterKey, prop.params[propName], propName, level))
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
details.push(
|
|
218
|
+
getDiv(12, 'Params', void 0, h('div', { class: 'markdown-api-entry__subitem' }, nodes)),
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (prop.returns !== void 0 && prop.returns !== null) {
|
|
223
|
+
details.push(
|
|
224
|
+
getDiv(
|
|
225
|
+
12,
|
|
226
|
+
`Return type: ${getStringType(prop.returns.type)}`,
|
|
227
|
+
void 0,
|
|
228
|
+
h('div', { class: 'markdown-api-entry__subitem' }, [
|
|
229
|
+
getProp(openState, masterKey, prop.returns, void 0, level),
|
|
230
|
+
]),
|
|
231
|
+
),
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (prop.scope !== void 0) {
|
|
236
|
+
const nodes: VNode[] = []
|
|
237
|
+
for (const propName in prop.scope) {
|
|
238
|
+
nodes.push(...getProp(openState, masterKey, prop.scope[propName], propName, level))
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
details.push(
|
|
242
|
+
getDiv(12, 'Scope', void 0, h('div', { class: 'markdown-api-entry__subitem' }, nodes)),
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (prop.examples !== void 0) {
|
|
247
|
+
details.push(
|
|
248
|
+
getDiv(
|
|
249
|
+
12,
|
|
250
|
+
`Example${prop.examples.length > 1 ? 's' : ''}`,
|
|
251
|
+
void 0,
|
|
252
|
+
h(
|
|
253
|
+
'div',
|
|
254
|
+
{ class: 'markdown-api-entry--indent markdown-api-entry__value' },
|
|
255
|
+
prop.examples.map((example: any) => h('div', { class: 'markdown-token' }, '' + example)),
|
|
256
|
+
),
|
|
257
|
+
),
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return details
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function getProp(
|
|
265
|
+
openState: Ref<Record<string, boolean>>,
|
|
266
|
+
masterKey: string,
|
|
267
|
+
prop: any,
|
|
268
|
+
propName: string | undefined,
|
|
269
|
+
level: number,
|
|
270
|
+
onlyChildren?: boolean,
|
|
271
|
+
): VNode[] {
|
|
272
|
+
const configToggle = useConfigToggle(openState)
|
|
273
|
+
if (configToggle.enabled && configToggle.type === 'configFile' && prop.configFileType === null) {
|
|
274
|
+
return [] // empty array
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const rawType = configToggle.enabled
|
|
278
|
+
? configToggle.type === 'configFile'
|
|
279
|
+
? prop.configFileType || prop.type
|
|
280
|
+
: prop.type
|
|
281
|
+
: prop.type
|
|
282
|
+
const type = getStringType(rawType)
|
|
283
|
+
const child: VNode[] = []
|
|
284
|
+
|
|
285
|
+
if (propName !== void 0) {
|
|
286
|
+
const suffix =
|
|
287
|
+
type === 'Function' ? `${getMethodParams(prop, true)}${getMethodReturnValue(prop)}` : type
|
|
288
|
+
|
|
289
|
+
child.push(getNameDiv(prop, propName, level, suffix))
|
|
290
|
+
|
|
291
|
+
if (prop.reactive === true) {
|
|
292
|
+
child.push(getDiv(3, 'Reactive', 'yes'))
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const isExpandable =
|
|
297
|
+
prop.sync === true ||
|
|
298
|
+
prop.default !== void 0 ||
|
|
299
|
+
prop.link === true ||
|
|
300
|
+
prop.values !== void 0 ||
|
|
301
|
+
prop.definition !== void 0 ||
|
|
302
|
+
(prop.params !== void 0 && prop.params !== null) ||
|
|
303
|
+
(prop.returns !== void 0 && prop.returns !== null) ||
|
|
304
|
+
prop.scope !== void 0 ||
|
|
305
|
+
prop.examples !== void 0
|
|
306
|
+
|
|
307
|
+
const childKey = `${masterKey}|||prop|${prop.type}|${propName}|${level}`
|
|
308
|
+
|
|
309
|
+
child.push(
|
|
310
|
+
...getExpandable(openState, prop.desc, isExpandable, childKey, () =>
|
|
311
|
+
getPropDetails(openState, childKey, prop, level + 1),
|
|
312
|
+
),
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
return onlyChildren !== true ? [h('div', { class: 'markdown-api-entry row' }, child)] : child
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const describe: Record<string, any> = {}
|
|
319
|
+
|
|
320
|
+
const describePropsLike =
|
|
321
|
+
(masterKey: string) => (openState: Ref<Record<string, boolean>>, props: any) => {
|
|
322
|
+
const child: VNode[] = []
|
|
323
|
+
|
|
324
|
+
for (const propName in props) {
|
|
325
|
+
child.push(...getProp(openState, masterKey, props[propName], propName, 0))
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return child
|
|
329
|
+
}
|
|
330
|
+
describe.props = describePropsLike('props')
|
|
331
|
+
describe.computedProps = describePropsLike('computedProps')
|
|
332
|
+
describe.slots = describePropsLike('slots')
|
|
333
|
+
|
|
334
|
+
describe.events = (openState: Ref<Record<string, boolean>>, events: any): VNode[] => {
|
|
335
|
+
const child: VNode[] = []
|
|
336
|
+
|
|
337
|
+
if (events === void 0) {
|
|
338
|
+
return child
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
for (const eventName in events) {
|
|
342
|
+
const event = events[eventName]
|
|
343
|
+
const masterKey = `event|${eventName}`
|
|
344
|
+
|
|
345
|
+
child.push(
|
|
346
|
+
h('div', { class: 'markdown-api-entry row' }, [
|
|
347
|
+
getNameDiv(event, `@${eventName}`, 0, getEventParams(event)),
|
|
348
|
+
|
|
349
|
+
...getExpandable(
|
|
350
|
+
openState,
|
|
351
|
+
event.desc,
|
|
352
|
+
event.params !== void 0 && event.params !== null,
|
|
353
|
+
masterKey,
|
|
354
|
+
() => {
|
|
355
|
+
const params: VNode[] = []
|
|
356
|
+
|
|
357
|
+
for (const paramName in event.params) {
|
|
358
|
+
params.push(...getProp(openState, masterKey, event.params[paramName], paramName, 1))
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return [
|
|
362
|
+
getDiv(
|
|
363
|
+
12,
|
|
364
|
+
'Parameters',
|
|
365
|
+
void 0,
|
|
366
|
+
h('div', { class: 'markdown-api-entry__subitem' }, params),
|
|
367
|
+
),
|
|
368
|
+
]
|
|
369
|
+
},
|
|
370
|
+
),
|
|
371
|
+
]),
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return child
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
describe.methods = (openState: Ref<Record<string, boolean>>, methods: any) => {
|
|
379
|
+
const child: VNode[] = []
|
|
380
|
+
|
|
381
|
+
for (const methodName in methods) {
|
|
382
|
+
const method = methods[methodName]
|
|
383
|
+
const masterKey = `method|${methodName}`
|
|
384
|
+
|
|
385
|
+
const alias = method.alias ? `Alias: "${method.alias}"; ` : ''
|
|
386
|
+
const desc = `${alias}${method.desc}`
|
|
387
|
+
|
|
388
|
+
const methodNode = h('div', { class: 'markdown-api-entry row' }, [
|
|
389
|
+
getNameDiv(
|
|
390
|
+
method,
|
|
391
|
+
methodName,
|
|
392
|
+
0,
|
|
393
|
+
`${getMethodParams(method)}${getMethodReturnValue(method)}`,
|
|
394
|
+
),
|
|
395
|
+
|
|
396
|
+
...getExpandable(
|
|
397
|
+
openState,
|
|
398
|
+
desc,
|
|
399
|
+
method.params !== void 0 || method.returns !== void 0,
|
|
400
|
+
masterKey,
|
|
401
|
+
() => {
|
|
402
|
+
const nodes: VNode[] = []
|
|
403
|
+
|
|
404
|
+
if (method.params !== void 0 && method.params !== null) {
|
|
405
|
+
const props: VNode[] = []
|
|
406
|
+
for (const paramName in method.params) {
|
|
407
|
+
props.push(...getProp(openState, masterKey, method.params[paramName], paramName, 1))
|
|
408
|
+
}
|
|
409
|
+
nodes.push(
|
|
410
|
+
getDiv(
|
|
411
|
+
12,
|
|
412
|
+
'Parameters',
|
|
413
|
+
void 0,
|
|
414
|
+
h('div', { class: 'markdown-api-entry__subitem' }, props),
|
|
415
|
+
),
|
|
416
|
+
)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (method.returns !== void 0 && method.returns !== null) {
|
|
420
|
+
nodes.push(
|
|
421
|
+
getDiv(
|
|
422
|
+
12,
|
|
423
|
+
`Return type: ${getStringType(method.returns.type)}`,
|
|
424
|
+
void 0,
|
|
425
|
+
h('div', { class: 'markdown-api-entry__subitem' }, [
|
|
426
|
+
getProp(openState, masterKey, method.returns, void 0, 1),
|
|
427
|
+
]),
|
|
428
|
+
),
|
|
429
|
+
)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return nodes
|
|
433
|
+
},
|
|
434
|
+
),
|
|
435
|
+
])
|
|
436
|
+
|
|
437
|
+
child.push(methodNode)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
return child
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
describe.value = (openState: Ref<Record<string, boolean>>, value: any): VNode[] => {
|
|
444
|
+
return [
|
|
445
|
+
h(
|
|
446
|
+
'div',
|
|
447
|
+
{ class: 'markdown-api-entry row' },
|
|
448
|
+
[getDiv(12, 'Type', getStringType(value.type))].concat(
|
|
449
|
+
...(getProp(openState, 'value', value, void 0, -1, true) || []),
|
|
450
|
+
),
|
|
451
|
+
),
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
describe.arg = (openState: Ref<Record<string, boolean>>, arg: any): VNode[] => {
|
|
456
|
+
return [
|
|
457
|
+
h(
|
|
458
|
+
'div',
|
|
459
|
+
{ class: 'markdown-api-entry row' },
|
|
460
|
+
[getDiv(12, 'Type', getStringType(arg.type))].concat(
|
|
461
|
+
getProp(openState, 'arg', arg, void 0, -1, true),
|
|
462
|
+
),
|
|
463
|
+
),
|
|
464
|
+
]
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
describe.modifiers = (openState: Ref<Record<string, boolean>>, modifiers: any): VNode[] => {
|
|
468
|
+
const child: VNode[] = []
|
|
469
|
+
|
|
470
|
+
for (const modifierName in modifiers) {
|
|
471
|
+
const modifier = modifiers[modifierName]
|
|
472
|
+
|
|
473
|
+
child.push(
|
|
474
|
+
h(
|
|
475
|
+
'div',
|
|
476
|
+
{ class: 'markdown-api-entry row' },
|
|
477
|
+
getProp(openState, 'modifiers', modifier, modifierName, 0, true),
|
|
478
|
+
),
|
|
479
|
+
)
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return child
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
describe.injection = (_: Ref<Record<string, boolean>>, injection: any): VNode[] => {
|
|
486
|
+
return [h('div', { class: 'markdown-api-entry row' }, [getNameDiv(injection, injection, 0)])]
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function useConfigToggle(openState: Ref<Record<string, boolean>>) {
|
|
490
|
+
return {
|
|
491
|
+
enabled: openState.value.quasarConfOptions !== undefined,
|
|
492
|
+
type: openState.value.quasarConfOptions ? 'uiConfig' : 'configFile',
|
|
493
|
+
setType: (type: string) => {
|
|
494
|
+
openState.value.quasarConfOptions = type === 'uiConfig'
|
|
495
|
+
},
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
describe.quasarConfOptions = (openState: Ref<Record<string, boolean>>, conf: any): VNode[] => {
|
|
500
|
+
const configToggle = useConfigToggle(openState)
|
|
501
|
+
|
|
502
|
+
if (configToggle.enabled === false) {
|
|
503
|
+
const needsConfigToggle =
|
|
504
|
+
conf.definition &&
|
|
505
|
+
Object.values(conf.definition).some(
|
|
506
|
+
(value) => (value as { configFileType: any }).configFileType !== undefined,
|
|
507
|
+
)
|
|
508
|
+
if (needsConfigToggle) {
|
|
509
|
+
openState.value.quasarConfOptions = false
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const configFileName = () =>
|
|
514
|
+
getNameDiv(conf, conf.propName, 0, 'quasar.config file > framework > config > ')
|
|
515
|
+
const uiConfigName = () =>
|
|
516
|
+
getNameDiv(conf, conf.propName, 0, '... }})', 'app.use(Quasar, { config: { ')
|
|
517
|
+
|
|
518
|
+
const entry = configToggle.enabled
|
|
519
|
+
? [
|
|
520
|
+
configToggle.type === 'configFile' ? configFileName() : uiConfigName(),
|
|
521
|
+
getDiv(8, 'Type', getStringType(conf.configFileType || conf.type || 'Object')),
|
|
522
|
+
h('div', { class: 'markdown-api-entry__item col row justify-end items-center' }, [
|
|
523
|
+
h(QBtnToggle, {
|
|
524
|
+
modelValue: configToggle.type,
|
|
525
|
+
'onUpdate:modelValue': configToggle.setType,
|
|
526
|
+
options: [
|
|
527
|
+
{ label: 'quasar.config file', value: 'configFile' },
|
|
528
|
+
{ label: 'UI config', value: 'uiConfig' },
|
|
529
|
+
],
|
|
530
|
+
noCaps: true,
|
|
531
|
+
rounded: true,
|
|
532
|
+
outline: true,
|
|
533
|
+
toggleColor: 'orange-8',
|
|
534
|
+
}),
|
|
535
|
+
]),
|
|
536
|
+
]
|
|
537
|
+
: [configFileName(), uiConfigName(), getDiv(12, 'Type', getStringType(conf.type || 'Object'))]
|
|
538
|
+
|
|
539
|
+
if (conf.desc) {
|
|
540
|
+
entry.push(getDiv(12, 'Description', conf.desc))
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
entry.push(getPropDetails(openState, 'quasarConfOptions', conf, 0) as unknown as VNode)
|
|
544
|
+
|
|
545
|
+
if (conf.definition && Object.keys(conf.definition).length === 0) {
|
|
546
|
+
entry.push(
|
|
547
|
+
h('div', { class: 'q-pa-md markdown-api__nothing-to-show' }, [
|
|
548
|
+
h('div', 'No matching props found.'),
|
|
549
|
+
h(
|
|
550
|
+
'div',
|
|
551
|
+
'Please check the other tabs/subtabs with a number badge on their label or refine the filter.',
|
|
552
|
+
),
|
|
553
|
+
]),
|
|
554
|
+
)
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return [h('div', { class: 'markdown-api-entry row' }, entry)]
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export default defineComponent({
|
|
561
|
+
name: 'DocApiEntry',
|
|
562
|
+
|
|
563
|
+
props: {
|
|
564
|
+
type: {
|
|
565
|
+
type: String as PropType<string>,
|
|
566
|
+
required: true,
|
|
567
|
+
},
|
|
568
|
+
definition: {
|
|
569
|
+
type: [Object, String] as PropType<Record<string, any> | string>,
|
|
570
|
+
required: true,
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
|
|
574
|
+
setup(props) {
|
|
575
|
+
const openState = ref<Record<string, any>>({})
|
|
576
|
+
|
|
577
|
+
return () => {
|
|
578
|
+
const content =
|
|
579
|
+
Object.keys(props.definition).length !== 0
|
|
580
|
+
? describe[props.type](openState, props.definition)
|
|
581
|
+
: [
|
|
582
|
+
h('div', { class: 'q-pa-md markdown-api__nothing-to-show' }, [
|
|
583
|
+
h('div', 'No matching entries found on this tab.'),
|
|
584
|
+
h(
|
|
585
|
+
'div',
|
|
586
|
+
'Please check the other tabs/subtabs with a number badge on their label or refine the filter.',
|
|
587
|
+
),
|
|
588
|
+
]),
|
|
589
|
+
]
|
|
590
|
+
|
|
591
|
+
return h('div', { class: 'markdown-api-entrys' }, content)
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a v-if="props.external" :href="props.to" target="_blank" class="card-link">
|
|
3
|
+
<slot />
|
|
4
|
+
</a>
|
|
5
|
+
<router-link v-else :to="props.to" class="card-link">
|
|
6
|
+
<slot />
|
|
7
|
+
</router-link>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup>
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
to: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
external: Boolean,
|
|
18
|
+
})
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style lang="scss">
|
|
22
|
+
.card-link {
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="markdown-card-title q-my-xs q-mr-sm cursor-pointer" :id="id" @click="onClick">
|
|
3
|
+
{{ props.title }}
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { computed } from 'vue'
|
|
9
|
+
import { copyHeading, slugify } from './markdown-utils'
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
title: String,
|
|
13
|
+
prefix: String,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const id = computed(() => (props.prefix || '') + slugify(props.title))
|
|
17
|
+
|
|
18
|
+
function onClick() {
|
|
19
|
+
copyHeading(id.value)
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative-position markdown-copybtn-hover">
|
|
3
|
+
<MarkdownCodePrism :lang="props.lang" :code="props.code" :style="style" />
|
|
4
|
+
<MarkdownCopyButton />
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
import { computed } from 'vue'
|
|
10
|
+
|
|
11
|
+
import MarkdownCodePrism from './MarkdownCodePrism'
|
|
12
|
+
import MarkdownCopyButton from './MarkdownCopyButton.vue'
|
|
13
|
+
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
code: String,
|
|
16
|
+
maxHeight: String,
|
|
17
|
+
|
|
18
|
+
lang: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: 'js',
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const style = computed(() => (props.maxHeight !== void 0 ? { maxHeight: props.maxHeight } : null))
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Prism from 'prismjs'
|
|
2
|
+
import { h, computed, defineComponent, type PropType } from 'vue'
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
name: 'MarkdownCodePrism',
|
|
6
|
+
|
|
7
|
+
props: {
|
|
8
|
+
code: {
|
|
9
|
+
type: String as PropType<string>,
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
lang: {
|
|
13
|
+
type: String as PropType<string>,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
setup(props) {
|
|
19
|
+
const html = computed(() => {
|
|
20
|
+
if (!props.code || !props.lang) {
|
|
21
|
+
return ''
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return Prism.highlight(props.code, Prism.languages[props.lang] as Prism.Grammar, props.lang)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return () =>
|
|
28
|
+
h(
|
|
29
|
+
'pre',
|
|
30
|
+
{
|
|
31
|
+
class: `markdown-code language-${props.lang}`,
|
|
32
|
+
},
|
|
33
|
+
[h('code', { innerHTML: html.value })],
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
})
|