@md-plugins/quasar-app-extension-q-press 0.1.0-alpha.23 → 0.1.0-alpha.24
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/package.json +15 -15
- package/src/templates/init/src/_q-press/api/components/MarkdownPage.json +2 -2
- package/src/templates/init/src/_q-press/components/MarkdownApi.vue +70 -0
- package/src/templates/init/src/_q-press/components/MarkdownApiEntry.ts +244 -2
- package/src/templates/init/src/_q-press/components/MarkdownExample.vue +24 -14
- package/src/templates/init/src/siteConfig/index.ts +2 -2
- package/src/templates/update/src/_q-press/api/components/MarkdownPage.json +2 -2
- package/src/templates/update/src/_q-press/components/MarkdownApi.vue +70 -0
- package/src/templates/update/src/_q-press/components/MarkdownApiEntry.ts +244 -2
- package/src/templates/update/src/_q-press/components/MarkdownExample.vue +24 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/quasar-app-extension-q-press",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.24",
|
|
4
4
|
"description": "QPress - The Ultimate Markdown Solution for Quasar Framework",
|
|
5
5
|
"author": "hawkeye64 <galbraith64@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -29,24 +29,24 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@types/markdown-it": "^14.1.2",
|
|
31
31
|
"markdown-it": "^14.1.0",
|
|
32
|
-
"@md-plugins/md-plugin-
|
|
33
|
-
"@md-plugins/md-plugin-
|
|
34
|
-
"@md-plugins/md-plugin-
|
|
35
|
-
"@md-plugins/md-plugin-
|
|
36
|
-
"@md-plugins/md-plugin-
|
|
37
|
-
"@md-plugins/md-plugin-
|
|
38
|
-
"@md-plugins/md-plugin-imports": "0.1.0-alpha.
|
|
39
|
-
"@md-plugins/md-plugin-
|
|
40
|
-
"@md-plugins/
|
|
41
|
-
"@md-plugins/
|
|
42
|
-
"@md-plugins/md-plugin-
|
|
43
|
-
"@md-plugins/
|
|
44
|
-
"@md-plugins/md-plugin
|
|
32
|
+
"@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.24",
|
|
33
|
+
"@md-plugins/md-plugin-blockquote": "0.1.0-alpha.24",
|
|
34
|
+
"@md-plugins/md-plugin-containers": "0.1.0-alpha.24",
|
|
35
|
+
"@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.24",
|
|
36
|
+
"@md-plugins/md-plugin-headers": "0.1.0-alpha.24",
|
|
37
|
+
"@md-plugins/md-plugin-image": "0.1.0-alpha.24",
|
|
38
|
+
"@md-plugins/md-plugin-imports": "0.1.0-alpha.24",
|
|
39
|
+
"@md-plugins/md-plugin-link": "0.1.0-alpha.24",
|
|
40
|
+
"@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.24",
|
|
41
|
+
"@md-plugins/md-plugin-table": "0.1.0-alpha.24",
|
|
42
|
+
"@md-plugins/md-plugin-title": "0.1.0-alpha.24",
|
|
43
|
+
"@md-plugins/shared": "0.1.0-alpha.24",
|
|
44
|
+
"@md-plugins/vite-md-plugin": "0.1.0-alpha.24"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/markdown-it": "^14.1.2",
|
|
48
48
|
"fs-extra": "^11.3.0",
|
|
49
|
-
"vite": "^6.0.
|
|
49
|
+
"vite": "^6.0.11"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"markdown-it": "^14.1.0"
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"props": {
|
|
7
7
|
"overline": {
|
|
8
8
|
"type": "String",
|
|
9
|
-
"desc": "Text to display as an overline above the title",
|
|
9
|
+
"desc": "Text to display as an `overline` above the title",
|
|
10
10
|
"examples": [
|
|
11
11
|
"'Introduction'",
|
|
12
12
|
"'Chapter 1'"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"isFullscreen": {
|
|
43
43
|
"type": "Boolean",
|
|
44
|
-
"desc": "Flag to indicate if the page is in fullscreen mode",
|
|
44
|
+
"desc": "Flag to indicate if the page is in `fullscreen` mode",
|
|
45
45
|
"category": "state"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
@@ -131,6 +131,12 @@ import MarkdownApiEntry from './MarkdownApiEntry'
|
|
|
131
131
|
|
|
132
132
|
const defaultInnerTabName = '__default'
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Extracts and categorizes properties based on their categories.
|
|
136
|
+
*
|
|
137
|
+
* @param {Object} props - The properties object where each key is a property name and each value is an object containing a `category` string.
|
|
138
|
+
* @returns {Array<string>} - An array of unique category names sorted alphabetically. If there is only one unique category, returns an array with a default inner tab name.
|
|
139
|
+
*/
|
|
134
140
|
function getPropsCategories(props) {
|
|
135
141
|
const acc = new Set()
|
|
136
142
|
|
|
@@ -147,6 +153,14 @@ function getPropsCategories(props) {
|
|
|
147
153
|
return acc.size === 1 ? [defaultInnerTabName] : Array.from(acc).sort()
|
|
148
154
|
}
|
|
149
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves the inner tabs for a given API.
|
|
158
|
+
*
|
|
159
|
+
* @param {Object} api - The API object containing the data.
|
|
160
|
+
* @param {Array} tabs - The array of tabs to be populated.
|
|
161
|
+
* @param {string} apiType - The type of the API.
|
|
162
|
+
* @returns {Array} - The array of inner tabs.
|
|
163
|
+
*/
|
|
150
164
|
function getInnerTabs(api, tabs, apiType) {
|
|
151
165
|
const acc = {}
|
|
152
166
|
|
|
@@ -160,6 +174,13 @@ function getInnerTabs(api, tabs, apiType) {
|
|
|
160
174
|
return acc
|
|
161
175
|
}
|
|
162
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Parses the given API data and organizes it into tabs and inner tabs.
|
|
179
|
+
*
|
|
180
|
+
* @param {Object} api - The API data to be parsed.
|
|
181
|
+
* @param {Array} tabs - The array to store the main tabs.
|
|
182
|
+
* @param {Array} innerTabs - The array to store the inner tabs.
|
|
183
|
+
*/
|
|
163
184
|
function parseApi(api, tabs, innerTabs) {
|
|
164
185
|
const acc = {}
|
|
165
186
|
|
|
@@ -193,6 +214,14 @@ function parseApi(api, tabs, innerTabs) {
|
|
|
193
214
|
return acc
|
|
194
215
|
}
|
|
195
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Checks if a given item passes the specified filter criteria.
|
|
219
|
+
*
|
|
220
|
+
* @param {string} filter - The filter criteria to apply.
|
|
221
|
+
* @param {string} name - The name of the item to check.
|
|
222
|
+
* @param {string} desc - The description of the item to check.
|
|
223
|
+
* @returns {boolean} - Returns true if the item passes the filter, otherwise false.
|
|
224
|
+
*/
|
|
196
225
|
function passesFilter(filter, name, desc) {
|
|
197
226
|
return (
|
|
198
227
|
name.toLowerCase().indexOf(filter) > -1 ||
|
|
@@ -200,6 +229,15 @@ function passesFilter(filter, name, desc) {
|
|
|
200
229
|
)
|
|
201
230
|
}
|
|
202
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Filters the parsed API data based on the provided filter, tabs, and innerTabs.
|
|
234
|
+
*
|
|
235
|
+
* @param {Object} parsedApi - The parsed API data to be filtered.
|
|
236
|
+
* @param {string} filter - The filter criteria to apply to the parsed API data.
|
|
237
|
+
* @param {Array} tabs - The list of tabs to consider while filtering.
|
|
238
|
+
* @param {Array} innerTabs - The list of inner tabs to consider while filtering.
|
|
239
|
+
* @returns {Object} - The filtered API data.
|
|
240
|
+
*/
|
|
203
241
|
function getFilteredApi(parsedApi, filter, tabs, innerTabs) {
|
|
204
242
|
if (filter === '') {
|
|
205
243
|
return parsedApi
|
|
@@ -263,6 +301,14 @@ function getFilteredApi(parsedApi, filter, tabs, innerTabs) {
|
|
|
263
301
|
return acc
|
|
264
302
|
}
|
|
265
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Calculates the count of API entries based on the provided parsed API data and tab configurations.
|
|
306
|
+
*
|
|
307
|
+
* @param {Object} parsedApi - The parsed API data.
|
|
308
|
+
* @param {Array} tabs - The array of main tab configurations.
|
|
309
|
+
* @param {Array} innerTabs - The array of inner tab configurations.
|
|
310
|
+
* @returns {number} - The count of API entries.
|
|
311
|
+
*/
|
|
266
312
|
function getApiCount(parsedApi, tabs, innerTabs) {
|
|
267
313
|
const acc = {}
|
|
268
314
|
|
|
@@ -354,13 +400,37 @@ watch(currentTab, (val) => {
|
|
|
354
400
|
})
|
|
355
401
|
|
|
356
402
|
const inputIcon = computed(() => (filter.value !== '' ? mdiClose : mdiMagnify))
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* A computed property that filters the API data based on certain criteria.
|
|
406
|
+
* The filtering logic is defined within the computed function.
|
|
407
|
+
*
|
|
408
|
+
* @returns {Array} The filtered API data.
|
|
409
|
+
*/
|
|
357
410
|
const filteredApi = computed(() =>
|
|
358
411
|
getFilteredApi(apiDef.value, filter.value.toLowerCase(), tabsList.value, innerTabsList.value),
|
|
359
412
|
)
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* A computed property that returns the count of filtered API items.
|
|
416
|
+
* This property is reactive and will update whenever the dependencies change.
|
|
417
|
+
*/
|
|
360
418
|
const filteredApiCount = computed(() =>
|
|
361
419
|
getApiCount(filteredApi.value, tabsList.value, innerTabsList.value),
|
|
362
420
|
)
|
|
363
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Parses the API file and extracts relevant information.
|
|
424
|
+
*
|
|
425
|
+
* @param {string} name - The name of the API file.
|
|
426
|
+
* @param {Object} options - The options object containing various properties.
|
|
427
|
+
* @param {string} options.type - The type of the API.
|
|
428
|
+
* @param {string} options.behavior - The behavior of the API.
|
|
429
|
+
* @param {Object} options.meta - Metadata associated with the API.
|
|
430
|
+
* @param {string} options.addedIn - The version in which the API was added.
|
|
431
|
+
* @param {Object} api - Additional API properties.
|
|
432
|
+
* @returns {Object} The parsed API information.
|
|
433
|
+
*/
|
|
364
434
|
function parseApiFile(name, { type, behavior, meta, addedIn, ...api }) {
|
|
365
435
|
nameBanner.value = `${name} API`
|
|
366
436
|
apiPath.value = meta.docsUrl
|
|
@@ -3,6 +3,13 @@ import { QBadge, QBtn, Notify, QBtnToggle } from 'quasar'
|
|
|
3
3
|
import { copyToClipboard } from './markdown-utils'
|
|
4
4
|
import { mdiMinusBox, mdiPlusBox } from '@quasar/extras/mdi-v7'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* This function copies a given property name to the clipboard.
|
|
8
|
+
* It also displays a notification to the user confirming the successful copy.
|
|
9
|
+
*
|
|
10
|
+
* @param propName - The name of the property to be copied.
|
|
11
|
+
* @returns {void} - This function does not return any value.
|
|
12
|
+
*/
|
|
6
13
|
function copyPropName(propName: string): void {
|
|
7
14
|
copyToClipboard(propName)
|
|
8
15
|
|
|
@@ -14,6 +21,16 @@ function copyPropName(propName: string): void {
|
|
|
14
21
|
})
|
|
15
22
|
}
|
|
16
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Generates a string representation of event parameters for a given event object.
|
|
26
|
+
*
|
|
27
|
+
* @param event - An object containing event information.
|
|
28
|
+
* @param event.params - An optional record of parameter names and their corresponding types.
|
|
29
|
+
* If undefined, null, or empty, an empty string is used for parameters.
|
|
30
|
+
*
|
|
31
|
+
* @returns A string representation of the event parameters in the format "(param1, param2, ...) => void".
|
|
32
|
+
* If no parameters are present, it returns "() => void".
|
|
33
|
+
*/
|
|
17
34
|
function getEventParams(event: { params?: Record<string, any> | null }): string {
|
|
18
35
|
const params =
|
|
19
36
|
event.params === void 0 || event.params === null || event.params.length === 0
|
|
@@ -23,6 +40,21 @@ function getEventParams(event: { params?: Record<string, any> | null }): string
|
|
|
23
40
|
return `(${params}) => void`
|
|
24
41
|
}
|
|
25
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Generates a string representation of method parameters.
|
|
45
|
+
*
|
|
46
|
+
* This function takes a method object and an optional flag to determine how to format the parameters.
|
|
47
|
+
* It handles cases where there are no parameters, all parameters are required, or there's a mix of required and optional parameters.
|
|
48
|
+
*
|
|
49
|
+
* @param method - An object containing information about the method.
|
|
50
|
+
* @param method.params - A record of parameter names and their corresponding details. Can be undefined, null, or empty.
|
|
51
|
+
* @param noRequired - A boolean flag. If true, all parameters are treated as required. If false or undefined, the function distinguishes between required and optional parameters.
|
|
52
|
+
*
|
|
53
|
+
* @returns A string representation of the method parameters enclosed in parentheses.
|
|
54
|
+
* - Returns " ()" if there are no parameters.
|
|
55
|
+
* - If noRequired is true, returns all parameters joined by commas.
|
|
56
|
+
* - If noRequired is false or undefined, optional parameters are suffixed with "?".
|
|
57
|
+
*/
|
|
26
58
|
function getMethodParams(
|
|
27
59
|
method: { params?: Record<string, any> | null },
|
|
28
60
|
noRequired?: boolean,
|
|
@@ -51,6 +83,18 @@ function getMethodParams(
|
|
|
51
83
|
return ' (' + str + ')'
|
|
52
84
|
}
|
|
53
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Generates a string representation of a method's return value.
|
|
88
|
+
*
|
|
89
|
+
* @param method - An object containing information about the method.
|
|
90
|
+
* @param method.returns - An optional object containing the return type information.
|
|
91
|
+
* If undefined or null, the method is considered to return void.
|
|
92
|
+
* @param method.returns.type - The type of the return value.
|
|
93
|
+
*
|
|
94
|
+
* @returns A string representation of the method's return value,
|
|
95
|
+
* prefixed with " => ". If no return value is specified,
|
|
96
|
+
* it returns " => void".
|
|
97
|
+
*/
|
|
54
98
|
function getMethodReturnValue(method: { returns?: { type: any } | null }): string {
|
|
55
99
|
return (
|
|
56
100
|
' => ' +
|
|
@@ -60,6 +104,12 @@ function getMethodReturnValue(method: { returns?: { type: any } | null }): strin
|
|
|
60
104
|
)
|
|
61
105
|
}
|
|
62
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Converts a type value to its string representation.
|
|
109
|
+
*
|
|
110
|
+
* @param type - The type value to convert. Can be an array of types or a single type.
|
|
111
|
+
* @returns A string representation of the type. If the input is an array, it joins the types with ' | '.
|
|
112
|
+
*/
|
|
63
113
|
function getStringType(type: any): string {
|
|
64
114
|
return Array.isArray(type) ? type.join(' | ') : type
|
|
65
115
|
}
|
|
@@ -67,13 +117,35 @@ function getStringType(type: any): string {
|
|
|
67
117
|
const NAME_PROP_COLOR = ['orange-8', 'brand-primary', 'green-5', 'purple-5']
|
|
68
118
|
const NAME_PROP_COLOR_LEN = NAME_PROP_COLOR.length
|
|
69
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Creates a div element with specific classes and content for use in a markdown API entry.
|
|
122
|
+
*
|
|
123
|
+
* @param col - The number of columns the div should span on small screens and above.
|
|
124
|
+
* @param propName - The name of the property to be displayed in the div.
|
|
125
|
+
* @param propValue - Optional. The value of the property to be displayed. If undefined, the slot will be used instead.
|
|
126
|
+
* @param slot - Optional. A slot to be used for custom content when propValue is undefined.
|
|
127
|
+
* @returns A VNode representing the created div element.
|
|
128
|
+
*/
|
|
70
129
|
function getDiv(col: number, propName: string, propValue?: string, slot?: any): VNode {
|
|
71
130
|
return h('div', { class: `markdown-api-entry__item col-xs-12 col-sm-${col}` }, [
|
|
72
131
|
h('div', { class: 'markdown-api-entry__type' }, propName),
|
|
73
|
-
propValue !== void 0
|
|
132
|
+
propValue !== void 0
|
|
133
|
+
? h('div', { class: 'markdown-api-entry__value' }, parseForInlineCode(propValue))
|
|
134
|
+
: slot,
|
|
74
135
|
])
|
|
75
136
|
}
|
|
76
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Creates a div element representing a name entry in the markdown API documentation.
|
|
140
|
+
* This function generates a complex div structure with badges and labels for API properties.
|
|
141
|
+
*
|
|
142
|
+
* @param prop - An object containing property information. It may include 'required' and 'addedIn' fields.
|
|
143
|
+
* @param label - The main text label for the property.
|
|
144
|
+
* @param level - A number indicating the nesting level of the property, used for color selection.
|
|
145
|
+
* @param suffix - Optional. Additional text to be appended after the main label.
|
|
146
|
+
* @param prefix - Optional. Text to be prepended before the main label.
|
|
147
|
+
* @returns A VNode representing the constructed div element for the name entry.
|
|
148
|
+
*/
|
|
77
149
|
function getNameDiv(
|
|
78
150
|
prop: any,
|
|
79
151
|
label: string,
|
|
@@ -116,6 +188,20 @@ function getNameDiv(
|
|
|
116
188
|
return h('div', { class: 'markdown-api-entry__item col-xs-12 col-sm-12 row items-center' }, child)
|
|
117
189
|
}
|
|
118
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Creates an expandable section for API documentation.
|
|
193
|
+
*
|
|
194
|
+
* This function generates a VNode array representing an expandable section
|
|
195
|
+
* in the API documentation. It includes a description and, if expandable,
|
|
196
|
+
* a toggle button to show/hide additional details.
|
|
197
|
+
*
|
|
198
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
199
|
+
* @param desc - The description text to be displayed.
|
|
200
|
+
* @param isExpandable - A boolean indicating whether the section should be expandable.
|
|
201
|
+
* @param key - A unique key for this expandable section, used to track its open state.
|
|
202
|
+
* @param getDetails - A function that returns an array of additional details to be shown when expanded.
|
|
203
|
+
* @returns An array of VNodes representing the expandable section.
|
|
204
|
+
*/
|
|
119
205
|
function getExpandable(
|
|
120
206
|
openState: Ref<Record<string, boolean>>,
|
|
121
207
|
desc: string,
|
|
@@ -140,7 +226,7 @@ function getExpandable(
|
|
|
140
226
|
},
|
|
141
227
|
}),
|
|
142
228
|
]),
|
|
143
|
-
h('div', { class: 'markdown-api-entry__value' }, desc),
|
|
229
|
+
h('div', { class: 'markdown-api-entry__value' }, parseForInlineCode(desc)),
|
|
144
230
|
]),
|
|
145
231
|
]
|
|
146
232
|
|
|
@@ -150,6 +236,39 @@ function getExpandable(
|
|
|
150
236
|
}
|
|
151
237
|
}
|
|
152
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Parses a string for inline code segments and converts them into VNodes with special styling.
|
|
241
|
+
*
|
|
242
|
+
* This function splits the input string by backticks and creates VNodes for code segments.
|
|
243
|
+
* Text outside of backticks is left as plain strings.
|
|
244
|
+
*
|
|
245
|
+
* @param code - The input string containing potential inline code segments delimited by backticks.
|
|
246
|
+
* @returns An array of VNodes and strings, where code segments are wrapped in styled span elements.
|
|
247
|
+
*/
|
|
248
|
+
function parseForInlineCode(code: string) {
|
|
249
|
+
const parts = code.split(/(`[^`]+`)/g)
|
|
250
|
+
return parts.map((part) => {
|
|
251
|
+
if (part.startsWith('`') && part.endsWith('`')) {
|
|
252
|
+
return h('span', { class: 'markdown-token' }, part.slice(1, -1))
|
|
253
|
+
} else {
|
|
254
|
+
return part
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Generates detailed property information for API documentation.
|
|
261
|
+
*
|
|
262
|
+
* This function creates a series of VNodes that represent various aspects of a property,
|
|
263
|
+
* including its synchronization status, default value, external links, accepted values,
|
|
264
|
+
* nested properties, parameters, return types, scope, and examples.
|
|
265
|
+
*
|
|
266
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
267
|
+
* @param masterKey - A unique identifier for the property, used in generating child keys.
|
|
268
|
+
* @param prop - The property object containing all the details to be displayed.
|
|
269
|
+
* @param level - The nesting level of the property, used for styling and indentation.
|
|
270
|
+
* @returns An array of VNodes representing the detailed property information.
|
|
271
|
+
*/
|
|
153
272
|
function getPropDetails(
|
|
154
273
|
openState: Ref<Record<string, boolean>>,
|
|
155
274
|
masterKey: string,
|
|
@@ -261,6 +380,21 @@ function getPropDetails(
|
|
|
261
380
|
return details
|
|
262
381
|
}
|
|
263
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Generates VNodes for a property in the API documentation.
|
|
385
|
+
*
|
|
386
|
+
* This function creates a detailed representation of a property, including its name,
|
|
387
|
+
* type, description, and any additional details. It handles configuration toggles,
|
|
388
|
+
* expandable sections, and nested properties.
|
|
389
|
+
*
|
|
390
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
391
|
+
* @param masterKey - A unique identifier for the property, used in generating child keys.
|
|
392
|
+
* @param prop - The property object containing all the details to be displayed.
|
|
393
|
+
* @param propName - The name of the property. If undefined, the property is treated as a nested or unnamed property.
|
|
394
|
+
* @param level - The nesting level of the property, used for styling and indentation.
|
|
395
|
+
* @param onlyChildren - If true, only child elements are returned without wrapping them in a container.
|
|
396
|
+
* @returns An array of VNodes representing the property and its details.
|
|
397
|
+
*/
|
|
264
398
|
function getProp(
|
|
265
399
|
openState: Ref<Record<string, boolean>>,
|
|
266
400
|
masterKey: string,
|
|
@@ -331,6 +465,18 @@ describe.props = describePropsLike('props')
|
|
|
331
465
|
describe.computedProps = describePropsLike('computedProps')
|
|
332
466
|
describe.slots = describePropsLike('slots')
|
|
333
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Generates VNodes for event descriptions in the API documentation.
|
|
470
|
+
*
|
|
471
|
+
* This function creates a detailed representation of events, including their names,
|
|
472
|
+
* parameters, and descriptions. It handles expandable sections for each event
|
|
473
|
+
* and generates child elements for event parameters.
|
|
474
|
+
*
|
|
475
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
476
|
+
* @param events - An object containing event definitions. Each key is an event name,
|
|
477
|
+
* and the value is an object describing the event.
|
|
478
|
+
* @returns An array of VNodes representing the events and their details.
|
|
479
|
+
*/
|
|
334
480
|
describe.events = (openState: Ref<Record<string, boolean>>, events: any): VNode[] => {
|
|
335
481
|
const child: VNode[] = []
|
|
336
482
|
|
|
@@ -375,6 +521,18 @@ describe.events = (openState: Ref<Record<string, boolean>>, events: any): VNode[
|
|
|
375
521
|
return child
|
|
376
522
|
}
|
|
377
523
|
|
|
524
|
+
/**
|
|
525
|
+
* Generates VNodes for method descriptions in the API documentation.
|
|
526
|
+
*
|
|
527
|
+
* This function creates a detailed representation of methods, including their names,
|
|
528
|
+
* parameters, return types, and descriptions. It handles expandable sections for each method
|
|
529
|
+
* and generates child elements for method parameters and return values.
|
|
530
|
+
*
|
|
531
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
532
|
+
* @param methods - An object containing method definitions. Each key is a method name,
|
|
533
|
+
* and the value is an object describing the method.
|
|
534
|
+
* @returns An array of VNodes representing the methods and their details.
|
|
535
|
+
*/
|
|
378
536
|
describe.methods = (openState: Ref<Record<string, boolean>>, methods: any) => {
|
|
379
537
|
const child: VNode[] = []
|
|
380
538
|
|
|
@@ -440,6 +598,20 @@ describe.methods = (openState: Ref<Record<string, boolean>>, methods: any) => {
|
|
|
440
598
|
return child
|
|
441
599
|
}
|
|
442
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Generates VNodes for describing a value in the API documentation.
|
|
603
|
+
*
|
|
604
|
+
* This function creates a detailed representation of a value, including its type
|
|
605
|
+
* and any additional properties. It uses the 'getDiv' and 'getProp' helper functions
|
|
606
|
+
* to generate the necessary VNodes.
|
|
607
|
+
*
|
|
608
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
609
|
+
* This is used to manage the state of collapsible content.
|
|
610
|
+
* @param value - An object containing the details of the value to be described.
|
|
611
|
+
* It should include at least a 'type' property.
|
|
612
|
+
* @returns An array of VNodes representing the value description, wrapped in a div
|
|
613
|
+
* with the class 'markdown-api-entry row'.
|
|
614
|
+
*/
|
|
443
615
|
describe.value = (openState: Ref<Record<string, boolean>>, value: any): VNode[] => {
|
|
444
616
|
return [
|
|
445
617
|
h(
|
|
@@ -452,6 +624,20 @@ describe.value = (openState: Ref<Record<string, boolean>>, value: any): VNode[]
|
|
|
452
624
|
]
|
|
453
625
|
}
|
|
454
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Generates VNodes for describing an argument in the API documentation.
|
|
629
|
+
*
|
|
630
|
+
* This function creates a detailed representation of an argument, including its type
|
|
631
|
+
* and any additional properties. It uses the 'getDiv' and 'getProp' helper functions
|
|
632
|
+
* to generate the necessary VNodes.
|
|
633
|
+
*
|
|
634
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
635
|
+
* This is used to manage the state of collapsible content.
|
|
636
|
+
* @param arg - An object containing the details of the argument to be described.
|
|
637
|
+
* It should include at least a 'type' property.
|
|
638
|
+
* @returns An array containing a single VNode representing the argument description,
|
|
639
|
+
* wrapped in a div with the class 'markdown-api-entry row'.
|
|
640
|
+
*/
|
|
455
641
|
describe.arg = (openState: Ref<Record<string, boolean>>, arg: any): VNode[] => {
|
|
456
642
|
return [
|
|
457
643
|
h(
|
|
@@ -464,6 +650,20 @@ describe.arg = (openState: Ref<Record<string, boolean>>, arg: any): VNode[] => {
|
|
|
464
650
|
]
|
|
465
651
|
}
|
|
466
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Generates VNodes for describing modifiers in the API documentation.
|
|
655
|
+
*
|
|
656
|
+
* This function creates a detailed representation of modifiers, including their names
|
|
657
|
+
* and properties. It iterates through the provided modifiers and generates
|
|
658
|
+
* a VNode for each one using the 'getProp' helper function.
|
|
659
|
+
*
|
|
660
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
661
|
+
* This is used to manage the state of collapsible content.
|
|
662
|
+
* @param modifiers - An object containing modifier definitions. Each key is a modifier name,
|
|
663
|
+
* and the value is an object describing the modifier.
|
|
664
|
+
* @returns An array of VNodes representing the modifiers and their details,
|
|
665
|
+
* each wrapped in a div with the class 'markdown-api-entry row'.
|
|
666
|
+
*/
|
|
467
667
|
describe.modifiers = (openState: Ref<Record<string, boolean>>, modifiers: any): VNode[] => {
|
|
468
668
|
const child: VNode[] = []
|
|
469
669
|
|
|
@@ -482,10 +682,37 @@ describe.modifiers = (openState: Ref<Record<string, boolean>>, modifiers: any):
|
|
|
482
682
|
return child
|
|
483
683
|
}
|
|
484
684
|
|
|
685
|
+
/**
|
|
686
|
+
* Generates a VNode array for describing an injection in the API documentation.
|
|
687
|
+
*
|
|
688
|
+
* This function creates a single div element containing the injection's name and details.
|
|
689
|
+
*
|
|
690
|
+
* @param _ - A Ref object containing a record of boolean values. This parameter is not used in the function.
|
|
691
|
+
* @param injection - An object containing the details of the injection to be described.
|
|
692
|
+
* @returns An array containing a single VNode representing the injection description,
|
|
693
|
+
* wrapped in a div with the class 'markdown-api-entry row'.
|
|
694
|
+
*/
|
|
485
695
|
describe.injection = (_: Ref<Record<string, boolean>>, injection: any): VNode[] => {
|
|
486
696
|
return [h('div', { class: 'markdown-api-entry row' }, [getNameDiv(injection, injection, 0)])]
|
|
487
697
|
}
|
|
488
698
|
|
|
699
|
+
/**
|
|
700
|
+
* Creates a configuration toggle object for managing UI and config file options.
|
|
701
|
+
*
|
|
702
|
+
* This function generates an object with properties and methods to handle
|
|
703
|
+
* the state of configuration options, allowing toggling between UI config
|
|
704
|
+
* and config file modes.
|
|
705
|
+
*
|
|
706
|
+
* @param openState - A reactive reference to an object containing boolean values
|
|
707
|
+
* representing the open state of various UI elements.
|
|
708
|
+
* The `quasarConfOptions` property is used to determine
|
|
709
|
+
* the current configuration mode.
|
|
710
|
+
*
|
|
711
|
+
* @returns An object with the following properties:
|
|
712
|
+
* - enabled: A boolean indicating whether configuration options are available.
|
|
713
|
+
* - type: A string representing the current configuration mode ('uiConfig' or 'configFile').
|
|
714
|
+
* - setType: A function to update the configuration mode.
|
|
715
|
+
*/
|
|
489
716
|
function useConfigToggle(openState: Ref<Record<string, boolean>>) {
|
|
490
717
|
return {
|
|
491
718
|
enabled: openState.value.quasarConfOptions !== undefined,
|
|
@@ -496,6 +723,21 @@ function useConfigToggle(openState: Ref<Record<string, boolean>>) {
|
|
|
496
723
|
}
|
|
497
724
|
}
|
|
498
725
|
|
|
726
|
+
/**
|
|
727
|
+
* Generates VNodes for describing Quasar configuration options in the API documentation.
|
|
728
|
+
*
|
|
729
|
+
* This function creates a detailed representation of Quasar configuration options,
|
|
730
|
+
* including their names, types, and descriptions. It handles both UI config and
|
|
731
|
+
* config file modes, and generates appropriate UI elements for each.
|
|
732
|
+
*
|
|
733
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
734
|
+
* It also contains information about the current configuration mode.
|
|
735
|
+
* @param conf - An object containing the configuration options to be described.
|
|
736
|
+
* It should include properties like 'propName', 'type', 'desc', and 'definition'.
|
|
737
|
+
*
|
|
738
|
+
* @returns An array containing a single VNode representing the configuration options description,
|
|
739
|
+
* wrapped in a div with the class 'markdown-api-entry row'.
|
|
740
|
+
*/
|
|
499
741
|
describe.quasarConfOptions = (openState: Ref<Record<string, boolean>>, conf: any): VNode[] => {
|
|
500
742
|
const configToggle = useConfigToggle(openState)
|
|
501
743
|
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<q-card class="markdown-example q-my-lg" flat bordered>
|
|
3
3
|
<div class="header-toolbar row items-center q-pr-sm">
|
|
4
|
-
<MarkdownCardTitle :title="props.title" prefix="example
|
|
4
|
+
<MarkdownCardTitle :title="props.title" prefix="example-" />
|
|
5
5
|
|
|
6
6
|
<q-space />
|
|
7
7
|
|
|
8
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
|
-
>
|
|
9
|
+
<!-- <q-btn class="header-btn" dense flat round :icon="mdiCompare" @click="dark.toggleDark">
|
|
17
10
|
<q-tooltip>Toggle dark mode</q-tooltip>
|
|
18
11
|
</q-btn> -->
|
|
19
12
|
|
|
20
|
-
<q-separator class="q-mx-xs" vertical inset />
|
|
13
|
+
<!-- <q-separator class="q-mx-xs" vertical inset /> -->
|
|
21
14
|
|
|
22
15
|
<q-btn
|
|
23
16
|
v-if="props.noGithub !== true"
|
|
@@ -109,6 +102,7 @@ import { fabGithub, fabCodepen } from '@quasar/extras/fontawesome-v6'
|
|
|
109
102
|
import MarkdownCode from './MarkdownCode.vue'
|
|
110
103
|
import MarkdownCodepen from './MarkdownCodepen.vue'
|
|
111
104
|
import MarkdownCardTitle from './MarkdownCardTitle.vue'
|
|
105
|
+
// import { useDark } from '../composables/dark'
|
|
112
106
|
|
|
113
107
|
import siteConfig from '../../siteConfig'
|
|
114
108
|
|
|
@@ -118,11 +112,12 @@ const props = defineProps({
|
|
|
118
112
|
noEdit: Boolean, // no codepen edit
|
|
119
113
|
scrollable: Boolean,
|
|
120
114
|
overflow: Boolean,
|
|
121
|
-
noGithub: Boolean,
|
|
115
|
+
noGithub: Boolean, // no GitHub link
|
|
122
116
|
})
|
|
123
117
|
|
|
124
118
|
const examples = inject('_markdown_examples_')
|
|
125
119
|
|
|
120
|
+
// const dark = useDark()
|
|
126
121
|
const codepenRef = ref(null)
|
|
127
122
|
const isBusy = ref(true)
|
|
128
123
|
|
|
@@ -134,6 +129,10 @@ const def = reactive({
|
|
|
134
129
|
const currentTab = ref('Template')
|
|
135
130
|
const expanded = ref(false)
|
|
136
131
|
|
|
132
|
+
/**
|
|
133
|
+
* A computed property that returns the CSS class for the component.
|
|
134
|
+
* This class is dynamically generated based on the component's state or props.
|
|
135
|
+
*/
|
|
137
136
|
const componentClass = computed(() => {
|
|
138
137
|
return props.scrollable === true
|
|
139
138
|
? 'markdown-example__content--scrollable scroll-y'
|
|
@@ -142,6 +141,13 @@ const componentClass = computed(() => {
|
|
|
142
141
|
: ''
|
|
143
142
|
})
|
|
144
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Parses a given template and applies it to the target.
|
|
146
|
+
*
|
|
147
|
+
* @param {Object} target - The target object to which the template will be applied.
|
|
148
|
+
* @param {string} template - The template string to be parsed and applied.
|
|
149
|
+
* @returns {void}
|
|
150
|
+
*/
|
|
145
151
|
function parseTemplate(target, template) {
|
|
146
152
|
const string = `(<${target}(.*)?>[\\w\\W]*<\\/${target}>)`,
|
|
147
153
|
regex = new RegExp(string, 'g'),
|
|
@@ -150,6 +156,12 @@ function parseTemplate(target, template) {
|
|
|
150
156
|
return parsed[1] || ''
|
|
151
157
|
}
|
|
152
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Parses a given component.
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} comp - The component to be parsed.
|
|
163
|
+
* @returns {Object} The parsed component.
|
|
164
|
+
*/
|
|
153
165
|
function parseComponent(comp) {
|
|
154
166
|
def.parts = {
|
|
155
167
|
Template: parseTemplate('template', comp),
|
|
@@ -168,9 +180,7 @@ function parseComponent(comp) {
|
|
|
168
180
|
}
|
|
169
181
|
|
|
170
182
|
function openGitHub() {
|
|
171
|
-
openURL(
|
|
172
|
-
`${siteConfig.githubEditRootSrc}/examples/${examples.name}/${props.file}.vue`,
|
|
173
|
-
)
|
|
183
|
+
openURL(`${siteConfig.githubEditRootSrc}/examples/${examples.name}/${props.file}.vue`)
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
function openCodepen() {
|
|
@@ -208,8 +208,8 @@ const mdPluginsMenu: SiteMenuItem = {
|
|
|
208
208
|
{
|
|
209
209
|
name: 'Inline Code',
|
|
210
210
|
children: [
|
|
211
|
-
{ name: 'Overview', path: '/md-plugins/
|
|
212
|
-
{ name: 'Advanced', path: '/md-plugins/
|
|
211
|
+
{ name: 'Overview', path: '/md-plugins/inline-code/overview' },
|
|
212
|
+
{ name: 'Advanced', path: '/md-plugins/inline-code/advanced' },
|
|
213
213
|
],
|
|
214
214
|
},
|
|
215
215
|
{
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"props": {
|
|
7
7
|
"overline": {
|
|
8
8
|
"type": "String",
|
|
9
|
-
"desc": "Text to display as an overline above the title",
|
|
9
|
+
"desc": "Text to display as an `overline` above the title",
|
|
10
10
|
"examples": [
|
|
11
11
|
"'Introduction'",
|
|
12
12
|
"'Chapter 1'"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"isFullscreen": {
|
|
43
43
|
"type": "Boolean",
|
|
44
|
-
"desc": "Flag to indicate if the page is in fullscreen mode",
|
|
44
|
+
"desc": "Flag to indicate if the page is in `fullscreen` mode",
|
|
45
45
|
"category": "state"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
@@ -131,6 +131,12 @@ import MarkdownApiEntry from './MarkdownApiEntry'
|
|
|
131
131
|
|
|
132
132
|
const defaultInnerTabName = '__default'
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Extracts and categorizes properties based on their categories.
|
|
136
|
+
*
|
|
137
|
+
* @param {Object} props - The properties object where each key is a property name and each value is an object containing a `category` string.
|
|
138
|
+
* @returns {Array<string>} - An array of unique category names sorted alphabetically. If there is only one unique category, returns an array with a default inner tab name.
|
|
139
|
+
*/
|
|
134
140
|
function getPropsCategories(props) {
|
|
135
141
|
const acc = new Set()
|
|
136
142
|
|
|
@@ -147,6 +153,14 @@ function getPropsCategories(props) {
|
|
|
147
153
|
return acc.size === 1 ? [defaultInnerTabName] : Array.from(acc).sort()
|
|
148
154
|
}
|
|
149
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves the inner tabs for a given API.
|
|
158
|
+
*
|
|
159
|
+
* @param {Object} api - The API object containing the data.
|
|
160
|
+
* @param {Array} tabs - The array of tabs to be populated.
|
|
161
|
+
* @param {string} apiType - The type of the API.
|
|
162
|
+
* @returns {Array} - The array of inner tabs.
|
|
163
|
+
*/
|
|
150
164
|
function getInnerTabs(api, tabs, apiType) {
|
|
151
165
|
const acc = {}
|
|
152
166
|
|
|
@@ -160,6 +174,13 @@ function getInnerTabs(api, tabs, apiType) {
|
|
|
160
174
|
return acc
|
|
161
175
|
}
|
|
162
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Parses the given API data and organizes it into tabs and inner tabs.
|
|
179
|
+
*
|
|
180
|
+
* @param {Object} api - The API data to be parsed.
|
|
181
|
+
* @param {Array} tabs - The array to store the main tabs.
|
|
182
|
+
* @param {Array} innerTabs - The array to store the inner tabs.
|
|
183
|
+
*/
|
|
163
184
|
function parseApi(api, tabs, innerTabs) {
|
|
164
185
|
const acc = {}
|
|
165
186
|
|
|
@@ -193,6 +214,14 @@ function parseApi(api, tabs, innerTabs) {
|
|
|
193
214
|
return acc
|
|
194
215
|
}
|
|
195
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Checks if a given item passes the specified filter criteria.
|
|
219
|
+
*
|
|
220
|
+
* @param {string} filter - The filter criteria to apply.
|
|
221
|
+
* @param {string} name - The name of the item to check.
|
|
222
|
+
* @param {string} desc - The description of the item to check.
|
|
223
|
+
* @returns {boolean} - Returns true if the item passes the filter, otherwise false.
|
|
224
|
+
*/
|
|
196
225
|
function passesFilter(filter, name, desc) {
|
|
197
226
|
return (
|
|
198
227
|
name.toLowerCase().indexOf(filter) > -1 ||
|
|
@@ -200,6 +229,15 @@ function passesFilter(filter, name, desc) {
|
|
|
200
229
|
)
|
|
201
230
|
}
|
|
202
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Filters the parsed API data based on the provided filter, tabs, and innerTabs.
|
|
234
|
+
*
|
|
235
|
+
* @param {Object} parsedApi - The parsed API data to be filtered.
|
|
236
|
+
* @param {string} filter - The filter criteria to apply to the parsed API data.
|
|
237
|
+
* @param {Array} tabs - The list of tabs to consider while filtering.
|
|
238
|
+
* @param {Array} innerTabs - The list of inner tabs to consider while filtering.
|
|
239
|
+
* @returns {Object} - The filtered API data.
|
|
240
|
+
*/
|
|
203
241
|
function getFilteredApi(parsedApi, filter, tabs, innerTabs) {
|
|
204
242
|
if (filter === '') {
|
|
205
243
|
return parsedApi
|
|
@@ -263,6 +301,14 @@ function getFilteredApi(parsedApi, filter, tabs, innerTabs) {
|
|
|
263
301
|
return acc
|
|
264
302
|
}
|
|
265
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Calculates the count of API entries based on the provided parsed API data and tab configurations.
|
|
306
|
+
*
|
|
307
|
+
* @param {Object} parsedApi - The parsed API data.
|
|
308
|
+
* @param {Array} tabs - The array of main tab configurations.
|
|
309
|
+
* @param {Array} innerTabs - The array of inner tab configurations.
|
|
310
|
+
* @returns {number} - The count of API entries.
|
|
311
|
+
*/
|
|
266
312
|
function getApiCount(parsedApi, tabs, innerTabs) {
|
|
267
313
|
const acc = {}
|
|
268
314
|
|
|
@@ -354,13 +400,37 @@ watch(currentTab, (val) => {
|
|
|
354
400
|
})
|
|
355
401
|
|
|
356
402
|
const inputIcon = computed(() => (filter.value !== '' ? mdiClose : mdiMagnify))
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* A computed property that filters the API data based on certain criteria.
|
|
406
|
+
* The filtering logic is defined within the computed function.
|
|
407
|
+
*
|
|
408
|
+
* @returns {Array} The filtered API data.
|
|
409
|
+
*/
|
|
357
410
|
const filteredApi = computed(() =>
|
|
358
411
|
getFilteredApi(apiDef.value, filter.value.toLowerCase(), tabsList.value, innerTabsList.value),
|
|
359
412
|
)
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* A computed property that returns the count of filtered API items.
|
|
416
|
+
* This property is reactive and will update whenever the dependencies change.
|
|
417
|
+
*/
|
|
360
418
|
const filteredApiCount = computed(() =>
|
|
361
419
|
getApiCount(filteredApi.value, tabsList.value, innerTabsList.value),
|
|
362
420
|
)
|
|
363
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Parses the API file and extracts relevant information.
|
|
424
|
+
*
|
|
425
|
+
* @param {string} name - The name of the API file.
|
|
426
|
+
* @param {Object} options - The options object containing various properties.
|
|
427
|
+
* @param {string} options.type - The type of the API.
|
|
428
|
+
* @param {string} options.behavior - The behavior of the API.
|
|
429
|
+
* @param {Object} options.meta - Metadata associated with the API.
|
|
430
|
+
* @param {string} options.addedIn - The version in which the API was added.
|
|
431
|
+
* @param {Object} api - Additional API properties.
|
|
432
|
+
* @returns {Object} The parsed API information.
|
|
433
|
+
*/
|
|
364
434
|
function parseApiFile(name, { type, behavior, meta, addedIn, ...api }) {
|
|
365
435
|
nameBanner.value = `${name} API`
|
|
366
436
|
apiPath.value = meta.docsUrl
|
|
@@ -3,6 +3,13 @@ import { QBadge, QBtn, Notify, QBtnToggle } from 'quasar'
|
|
|
3
3
|
import { copyToClipboard } from './markdown-utils'
|
|
4
4
|
import { mdiMinusBox, mdiPlusBox } from '@quasar/extras/mdi-v7'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* This function copies a given property name to the clipboard.
|
|
8
|
+
* It also displays a notification to the user confirming the successful copy.
|
|
9
|
+
*
|
|
10
|
+
* @param propName - The name of the property to be copied.
|
|
11
|
+
* @returns {void} - This function does not return any value.
|
|
12
|
+
*/
|
|
6
13
|
function copyPropName(propName: string): void {
|
|
7
14
|
copyToClipboard(propName)
|
|
8
15
|
|
|
@@ -14,6 +21,16 @@ function copyPropName(propName: string): void {
|
|
|
14
21
|
})
|
|
15
22
|
}
|
|
16
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Generates a string representation of event parameters for a given event object.
|
|
26
|
+
*
|
|
27
|
+
* @param event - An object containing event information.
|
|
28
|
+
* @param event.params - An optional record of parameter names and their corresponding types.
|
|
29
|
+
* If undefined, null, or empty, an empty string is used for parameters.
|
|
30
|
+
*
|
|
31
|
+
* @returns A string representation of the event parameters in the format "(param1, param2, ...) => void".
|
|
32
|
+
* If no parameters are present, it returns "() => void".
|
|
33
|
+
*/
|
|
17
34
|
function getEventParams(event: { params?: Record<string, any> | null }): string {
|
|
18
35
|
const params =
|
|
19
36
|
event.params === void 0 || event.params === null || event.params.length === 0
|
|
@@ -23,6 +40,21 @@ function getEventParams(event: { params?: Record<string, any> | null }): string
|
|
|
23
40
|
return `(${params}) => void`
|
|
24
41
|
}
|
|
25
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Generates a string representation of method parameters.
|
|
45
|
+
*
|
|
46
|
+
* This function takes a method object and an optional flag to determine how to format the parameters.
|
|
47
|
+
* It handles cases where there are no parameters, all parameters are required, or there's a mix of required and optional parameters.
|
|
48
|
+
*
|
|
49
|
+
* @param method - An object containing information about the method.
|
|
50
|
+
* @param method.params - A record of parameter names and their corresponding details. Can be undefined, null, or empty.
|
|
51
|
+
* @param noRequired - A boolean flag. If true, all parameters are treated as required. If false or undefined, the function distinguishes between required and optional parameters.
|
|
52
|
+
*
|
|
53
|
+
* @returns A string representation of the method parameters enclosed in parentheses.
|
|
54
|
+
* - Returns " ()" if there are no parameters.
|
|
55
|
+
* - If noRequired is true, returns all parameters joined by commas.
|
|
56
|
+
* - If noRequired is false or undefined, optional parameters are suffixed with "?".
|
|
57
|
+
*/
|
|
26
58
|
function getMethodParams(
|
|
27
59
|
method: { params?: Record<string, any> | null },
|
|
28
60
|
noRequired?: boolean,
|
|
@@ -51,6 +83,18 @@ function getMethodParams(
|
|
|
51
83
|
return ' (' + str + ')'
|
|
52
84
|
}
|
|
53
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Generates a string representation of a method's return value.
|
|
88
|
+
*
|
|
89
|
+
* @param method - An object containing information about the method.
|
|
90
|
+
* @param method.returns - An optional object containing the return type information.
|
|
91
|
+
* If undefined or null, the method is considered to return void.
|
|
92
|
+
* @param method.returns.type - The type of the return value.
|
|
93
|
+
*
|
|
94
|
+
* @returns A string representation of the method's return value,
|
|
95
|
+
* prefixed with " => ". If no return value is specified,
|
|
96
|
+
* it returns " => void".
|
|
97
|
+
*/
|
|
54
98
|
function getMethodReturnValue(method: { returns?: { type: any } | null }): string {
|
|
55
99
|
return (
|
|
56
100
|
' => ' +
|
|
@@ -60,6 +104,12 @@ function getMethodReturnValue(method: { returns?: { type: any } | null }): strin
|
|
|
60
104
|
)
|
|
61
105
|
}
|
|
62
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Converts a type value to its string representation.
|
|
109
|
+
*
|
|
110
|
+
* @param type - The type value to convert. Can be an array of types or a single type.
|
|
111
|
+
* @returns A string representation of the type. If the input is an array, it joins the types with ' | '.
|
|
112
|
+
*/
|
|
63
113
|
function getStringType(type: any): string {
|
|
64
114
|
return Array.isArray(type) ? type.join(' | ') : type
|
|
65
115
|
}
|
|
@@ -67,13 +117,35 @@ function getStringType(type: any): string {
|
|
|
67
117
|
const NAME_PROP_COLOR = ['orange-8', 'brand-primary', 'green-5', 'purple-5']
|
|
68
118
|
const NAME_PROP_COLOR_LEN = NAME_PROP_COLOR.length
|
|
69
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Creates a div element with specific classes and content for use in a markdown API entry.
|
|
122
|
+
*
|
|
123
|
+
* @param col - The number of columns the div should span on small screens and above.
|
|
124
|
+
* @param propName - The name of the property to be displayed in the div.
|
|
125
|
+
* @param propValue - Optional. The value of the property to be displayed. If undefined, the slot will be used instead.
|
|
126
|
+
* @param slot - Optional. A slot to be used for custom content when propValue is undefined.
|
|
127
|
+
* @returns A VNode representing the created div element.
|
|
128
|
+
*/
|
|
70
129
|
function getDiv(col: number, propName: string, propValue?: string, slot?: any): VNode {
|
|
71
130
|
return h('div', { class: `markdown-api-entry__item col-xs-12 col-sm-${col}` }, [
|
|
72
131
|
h('div', { class: 'markdown-api-entry__type' }, propName),
|
|
73
|
-
propValue !== void 0
|
|
132
|
+
propValue !== void 0
|
|
133
|
+
? h('div', { class: 'markdown-api-entry__value' }, parseForInlineCode(propValue))
|
|
134
|
+
: slot,
|
|
74
135
|
])
|
|
75
136
|
}
|
|
76
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Creates a div element representing a name entry in the markdown API documentation.
|
|
140
|
+
* This function generates a complex div structure with badges and labels for API properties.
|
|
141
|
+
*
|
|
142
|
+
* @param prop - An object containing property information. It may include 'required' and 'addedIn' fields.
|
|
143
|
+
* @param label - The main text label for the property.
|
|
144
|
+
* @param level - A number indicating the nesting level of the property, used for color selection.
|
|
145
|
+
* @param suffix - Optional. Additional text to be appended after the main label.
|
|
146
|
+
* @param prefix - Optional. Text to be prepended before the main label.
|
|
147
|
+
* @returns A VNode representing the constructed div element for the name entry.
|
|
148
|
+
*/
|
|
77
149
|
function getNameDiv(
|
|
78
150
|
prop: any,
|
|
79
151
|
label: string,
|
|
@@ -116,6 +188,20 @@ function getNameDiv(
|
|
|
116
188
|
return h('div', { class: 'markdown-api-entry__item col-xs-12 col-sm-12 row items-center' }, child)
|
|
117
189
|
}
|
|
118
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Creates an expandable section for API documentation.
|
|
193
|
+
*
|
|
194
|
+
* This function generates a VNode array representing an expandable section
|
|
195
|
+
* in the API documentation. It includes a description and, if expandable,
|
|
196
|
+
* a toggle button to show/hide additional details.
|
|
197
|
+
*
|
|
198
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
199
|
+
* @param desc - The description text to be displayed.
|
|
200
|
+
* @param isExpandable - A boolean indicating whether the section should be expandable.
|
|
201
|
+
* @param key - A unique key for this expandable section, used to track its open state.
|
|
202
|
+
* @param getDetails - A function that returns an array of additional details to be shown when expanded.
|
|
203
|
+
* @returns An array of VNodes representing the expandable section.
|
|
204
|
+
*/
|
|
119
205
|
function getExpandable(
|
|
120
206
|
openState: Ref<Record<string, boolean>>,
|
|
121
207
|
desc: string,
|
|
@@ -140,7 +226,7 @@ function getExpandable(
|
|
|
140
226
|
},
|
|
141
227
|
}),
|
|
142
228
|
]),
|
|
143
|
-
h('div', { class: 'markdown-api-entry__value' }, desc),
|
|
229
|
+
h('div', { class: 'markdown-api-entry__value' }, parseForInlineCode(desc)),
|
|
144
230
|
]),
|
|
145
231
|
]
|
|
146
232
|
|
|
@@ -150,6 +236,39 @@ function getExpandable(
|
|
|
150
236
|
}
|
|
151
237
|
}
|
|
152
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Parses a string for inline code segments and converts them into VNodes with special styling.
|
|
241
|
+
*
|
|
242
|
+
* This function splits the input string by backticks and creates VNodes for code segments.
|
|
243
|
+
* Text outside of backticks is left as plain strings.
|
|
244
|
+
*
|
|
245
|
+
* @param code - The input string containing potential inline code segments delimited by backticks.
|
|
246
|
+
* @returns An array of VNodes and strings, where code segments are wrapped in styled span elements.
|
|
247
|
+
*/
|
|
248
|
+
function parseForInlineCode(code: string) {
|
|
249
|
+
const parts = code.split(/(`[^`]+`)/g)
|
|
250
|
+
return parts.map((part) => {
|
|
251
|
+
if (part.startsWith('`') && part.endsWith('`')) {
|
|
252
|
+
return h('span', { class: 'markdown-token' }, part.slice(1, -1))
|
|
253
|
+
} else {
|
|
254
|
+
return part
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Generates detailed property information for API documentation.
|
|
261
|
+
*
|
|
262
|
+
* This function creates a series of VNodes that represent various aspects of a property,
|
|
263
|
+
* including its synchronization status, default value, external links, accepted values,
|
|
264
|
+
* nested properties, parameters, return types, scope, and examples.
|
|
265
|
+
*
|
|
266
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
267
|
+
* @param masterKey - A unique identifier for the property, used in generating child keys.
|
|
268
|
+
* @param prop - The property object containing all the details to be displayed.
|
|
269
|
+
* @param level - The nesting level of the property, used for styling and indentation.
|
|
270
|
+
* @returns An array of VNodes representing the detailed property information.
|
|
271
|
+
*/
|
|
153
272
|
function getPropDetails(
|
|
154
273
|
openState: Ref<Record<string, boolean>>,
|
|
155
274
|
masterKey: string,
|
|
@@ -261,6 +380,21 @@ function getPropDetails(
|
|
|
261
380
|
return details
|
|
262
381
|
}
|
|
263
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Generates VNodes for a property in the API documentation.
|
|
385
|
+
*
|
|
386
|
+
* This function creates a detailed representation of a property, including its name,
|
|
387
|
+
* type, description, and any additional details. It handles configuration toggles,
|
|
388
|
+
* expandable sections, and nested properties.
|
|
389
|
+
*
|
|
390
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
391
|
+
* @param masterKey - A unique identifier for the property, used in generating child keys.
|
|
392
|
+
* @param prop - The property object containing all the details to be displayed.
|
|
393
|
+
* @param propName - The name of the property. If undefined, the property is treated as a nested or unnamed property.
|
|
394
|
+
* @param level - The nesting level of the property, used for styling and indentation.
|
|
395
|
+
* @param onlyChildren - If true, only child elements are returned without wrapping them in a container.
|
|
396
|
+
* @returns An array of VNodes representing the property and its details.
|
|
397
|
+
*/
|
|
264
398
|
function getProp(
|
|
265
399
|
openState: Ref<Record<string, boolean>>,
|
|
266
400
|
masterKey: string,
|
|
@@ -331,6 +465,18 @@ describe.props = describePropsLike('props')
|
|
|
331
465
|
describe.computedProps = describePropsLike('computedProps')
|
|
332
466
|
describe.slots = describePropsLike('slots')
|
|
333
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Generates VNodes for event descriptions in the API documentation.
|
|
470
|
+
*
|
|
471
|
+
* This function creates a detailed representation of events, including their names,
|
|
472
|
+
* parameters, and descriptions. It handles expandable sections for each event
|
|
473
|
+
* and generates child elements for event parameters.
|
|
474
|
+
*
|
|
475
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
476
|
+
* @param events - An object containing event definitions. Each key is an event name,
|
|
477
|
+
* and the value is an object describing the event.
|
|
478
|
+
* @returns An array of VNodes representing the events and their details.
|
|
479
|
+
*/
|
|
334
480
|
describe.events = (openState: Ref<Record<string, boolean>>, events: any): VNode[] => {
|
|
335
481
|
const child: VNode[] = []
|
|
336
482
|
|
|
@@ -375,6 +521,18 @@ describe.events = (openState: Ref<Record<string, boolean>>, events: any): VNode[
|
|
|
375
521
|
return child
|
|
376
522
|
}
|
|
377
523
|
|
|
524
|
+
/**
|
|
525
|
+
* Generates VNodes for method descriptions in the API documentation.
|
|
526
|
+
*
|
|
527
|
+
* This function creates a detailed representation of methods, including their names,
|
|
528
|
+
* parameters, return types, and descriptions. It handles expandable sections for each method
|
|
529
|
+
* and generates child elements for method parameters and return values.
|
|
530
|
+
*
|
|
531
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
532
|
+
* @param methods - An object containing method definitions. Each key is a method name,
|
|
533
|
+
* and the value is an object describing the method.
|
|
534
|
+
* @returns An array of VNodes representing the methods and their details.
|
|
535
|
+
*/
|
|
378
536
|
describe.methods = (openState: Ref<Record<string, boolean>>, methods: any) => {
|
|
379
537
|
const child: VNode[] = []
|
|
380
538
|
|
|
@@ -440,6 +598,20 @@ describe.methods = (openState: Ref<Record<string, boolean>>, methods: any) => {
|
|
|
440
598
|
return child
|
|
441
599
|
}
|
|
442
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Generates VNodes for describing a value in the API documentation.
|
|
603
|
+
*
|
|
604
|
+
* This function creates a detailed representation of a value, including its type
|
|
605
|
+
* and any additional properties. It uses the 'getDiv' and 'getProp' helper functions
|
|
606
|
+
* to generate the necessary VNodes.
|
|
607
|
+
*
|
|
608
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
609
|
+
* This is used to manage the state of collapsible content.
|
|
610
|
+
* @param value - An object containing the details of the value to be described.
|
|
611
|
+
* It should include at least a 'type' property.
|
|
612
|
+
* @returns An array of VNodes representing the value description, wrapped in a div
|
|
613
|
+
* with the class 'markdown-api-entry row'.
|
|
614
|
+
*/
|
|
443
615
|
describe.value = (openState: Ref<Record<string, boolean>>, value: any): VNode[] => {
|
|
444
616
|
return [
|
|
445
617
|
h(
|
|
@@ -452,6 +624,20 @@ describe.value = (openState: Ref<Record<string, boolean>>, value: any): VNode[]
|
|
|
452
624
|
]
|
|
453
625
|
}
|
|
454
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Generates VNodes for describing an argument in the API documentation.
|
|
629
|
+
*
|
|
630
|
+
* This function creates a detailed representation of an argument, including its type
|
|
631
|
+
* and any additional properties. It uses the 'getDiv' and 'getProp' helper functions
|
|
632
|
+
* to generate the necessary VNodes.
|
|
633
|
+
*
|
|
634
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
635
|
+
* This is used to manage the state of collapsible content.
|
|
636
|
+
* @param arg - An object containing the details of the argument to be described.
|
|
637
|
+
* It should include at least a 'type' property.
|
|
638
|
+
* @returns An array containing a single VNode representing the argument description,
|
|
639
|
+
* wrapped in a div with the class 'markdown-api-entry row'.
|
|
640
|
+
*/
|
|
455
641
|
describe.arg = (openState: Ref<Record<string, boolean>>, arg: any): VNode[] => {
|
|
456
642
|
return [
|
|
457
643
|
h(
|
|
@@ -464,6 +650,20 @@ describe.arg = (openState: Ref<Record<string, boolean>>, arg: any): VNode[] => {
|
|
|
464
650
|
]
|
|
465
651
|
}
|
|
466
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Generates VNodes for describing modifiers in the API documentation.
|
|
655
|
+
*
|
|
656
|
+
* This function creates a detailed representation of modifiers, including their names
|
|
657
|
+
* and properties. It iterates through the provided modifiers and generates
|
|
658
|
+
* a VNode for each one using the 'getProp' helper function.
|
|
659
|
+
*
|
|
660
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
661
|
+
* This is used to manage the state of collapsible content.
|
|
662
|
+
* @param modifiers - An object containing modifier definitions. Each key is a modifier name,
|
|
663
|
+
* and the value is an object describing the modifier.
|
|
664
|
+
* @returns An array of VNodes representing the modifiers and their details,
|
|
665
|
+
* each wrapped in a div with the class 'markdown-api-entry row'.
|
|
666
|
+
*/
|
|
467
667
|
describe.modifiers = (openState: Ref<Record<string, boolean>>, modifiers: any): VNode[] => {
|
|
468
668
|
const child: VNode[] = []
|
|
469
669
|
|
|
@@ -482,10 +682,37 @@ describe.modifiers = (openState: Ref<Record<string, boolean>>, modifiers: any):
|
|
|
482
682
|
return child
|
|
483
683
|
}
|
|
484
684
|
|
|
685
|
+
/**
|
|
686
|
+
* Generates a VNode array for describing an injection in the API documentation.
|
|
687
|
+
*
|
|
688
|
+
* This function creates a single div element containing the injection's name and details.
|
|
689
|
+
*
|
|
690
|
+
* @param _ - A Ref object containing a record of boolean values. This parameter is not used in the function.
|
|
691
|
+
* @param injection - An object containing the details of the injection to be described.
|
|
692
|
+
* @returns An array containing a single VNode representing the injection description,
|
|
693
|
+
* wrapped in a div with the class 'markdown-api-entry row'.
|
|
694
|
+
*/
|
|
485
695
|
describe.injection = (_: Ref<Record<string, boolean>>, injection: any): VNode[] => {
|
|
486
696
|
return [h('div', { class: 'markdown-api-entry row' }, [getNameDiv(injection, injection, 0)])]
|
|
487
697
|
}
|
|
488
698
|
|
|
699
|
+
/**
|
|
700
|
+
* Creates a configuration toggle object for managing UI and config file options.
|
|
701
|
+
*
|
|
702
|
+
* This function generates an object with properties and methods to handle
|
|
703
|
+
* the state of configuration options, allowing toggling between UI config
|
|
704
|
+
* and config file modes.
|
|
705
|
+
*
|
|
706
|
+
* @param openState - A reactive reference to an object containing boolean values
|
|
707
|
+
* representing the open state of various UI elements.
|
|
708
|
+
* The `quasarConfOptions` property is used to determine
|
|
709
|
+
* the current configuration mode.
|
|
710
|
+
*
|
|
711
|
+
* @returns An object with the following properties:
|
|
712
|
+
* - enabled: A boolean indicating whether configuration options are available.
|
|
713
|
+
* - type: A string representing the current configuration mode ('uiConfig' or 'configFile').
|
|
714
|
+
* - setType: A function to update the configuration mode.
|
|
715
|
+
*/
|
|
489
716
|
function useConfigToggle(openState: Ref<Record<string, boolean>>) {
|
|
490
717
|
return {
|
|
491
718
|
enabled: openState.value.quasarConfOptions !== undefined,
|
|
@@ -496,6 +723,21 @@ function useConfigToggle(openState: Ref<Record<string, boolean>>) {
|
|
|
496
723
|
}
|
|
497
724
|
}
|
|
498
725
|
|
|
726
|
+
/**
|
|
727
|
+
* Generates VNodes for describing Quasar configuration options in the API documentation.
|
|
728
|
+
*
|
|
729
|
+
* This function creates a detailed representation of Quasar configuration options,
|
|
730
|
+
* including their names, types, and descriptions. It handles both UI config and
|
|
731
|
+
* config file modes, and generates appropriate UI elements for each.
|
|
732
|
+
*
|
|
733
|
+
* @param openState - A reactive reference to an object tracking the open state of expandable sections.
|
|
734
|
+
* It also contains information about the current configuration mode.
|
|
735
|
+
* @param conf - An object containing the configuration options to be described.
|
|
736
|
+
* It should include properties like 'propName', 'type', 'desc', and 'definition'.
|
|
737
|
+
*
|
|
738
|
+
* @returns An array containing a single VNode representing the configuration options description,
|
|
739
|
+
* wrapped in a div with the class 'markdown-api-entry row'.
|
|
740
|
+
*/
|
|
499
741
|
describe.quasarConfOptions = (openState: Ref<Record<string, boolean>>, conf: any): VNode[] => {
|
|
500
742
|
const configToggle = useConfigToggle(openState)
|
|
501
743
|
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<q-card class="markdown-example q-my-lg" flat bordered>
|
|
3
3
|
<div class="header-toolbar row items-center q-pr-sm">
|
|
4
|
-
<MarkdownCardTitle :title="props.title" prefix="example
|
|
4
|
+
<MarkdownCardTitle :title="props.title" prefix="example-" />
|
|
5
5
|
|
|
6
6
|
<q-space />
|
|
7
7
|
|
|
8
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
|
-
>
|
|
9
|
+
<!-- <q-btn class="header-btn" dense flat round :icon="mdiCompare" @click="dark.toggleDark">
|
|
17
10
|
<q-tooltip>Toggle dark mode</q-tooltip>
|
|
18
11
|
</q-btn> -->
|
|
19
12
|
|
|
20
|
-
<q-separator class="q-mx-xs" vertical inset />
|
|
13
|
+
<!-- <q-separator class="q-mx-xs" vertical inset /> -->
|
|
21
14
|
|
|
22
15
|
<q-btn
|
|
23
16
|
v-if="props.noGithub !== true"
|
|
@@ -109,6 +102,7 @@ import { fabGithub, fabCodepen } from '@quasar/extras/fontawesome-v6'
|
|
|
109
102
|
import MarkdownCode from './MarkdownCode.vue'
|
|
110
103
|
import MarkdownCodepen from './MarkdownCodepen.vue'
|
|
111
104
|
import MarkdownCardTitle from './MarkdownCardTitle.vue'
|
|
105
|
+
// import { useDark } from '../composables/dark'
|
|
112
106
|
|
|
113
107
|
import siteConfig from '../../siteConfig'
|
|
114
108
|
|
|
@@ -118,11 +112,12 @@ const props = defineProps({
|
|
|
118
112
|
noEdit: Boolean, // no codepen edit
|
|
119
113
|
scrollable: Boolean,
|
|
120
114
|
overflow: Boolean,
|
|
121
|
-
noGithub: Boolean,
|
|
115
|
+
noGithub: Boolean, // no GitHub link
|
|
122
116
|
})
|
|
123
117
|
|
|
124
118
|
const examples = inject('_markdown_examples_')
|
|
125
119
|
|
|
120
|
+
// const dark = useDark()
|
|
126
121
|
const codepenRef = ref(null)
|
|
127
122
|
const isBusy = ref(true)
|
|
128
123
|
|
|
@@ -134,6 +129,10 @@ const def = reactive({
|
|
|
134
129
|
const currentTab = ref('Template')
|
|
135
130
|
const expanded = ref(false)
|
|
136
131
|
|
|
132
|
+
/**
|
|
133
|
+
* A computed property that returns the CSS class for the component.
|
|
134
|
+
* This class is dynamically generated based on the component's state or props.
|
|
135
|
+
*/
|
|
137
136
|
const componentClass = computed(() => {
|
|
138
137
|
return props.scrollable === true
|
|
139
138
|
? 'markdown-example__content--scrollable scroll-y'
|
|
@@ -142,6 +141,13 @@ const componentClass = computed(() => {
|
|
|
142
141
|
: ''
|
|
143
142
|
})
|
|
144
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Parses a given template and applies it to the target.
|
|
146
|
+
*
|
|
147
|
+
* @param {Object} target - The target object to which the template will be applied.
|
|
148
|
+
* @param {string} template - The template string to be parsed and applied.
|
|
149
|
+
* @returns {void}
|
|
150
|
+
*/
|
|
145
151
|
function parseTemplate(target, template) {
|
|
146
152
|
const string = `(<${target}(.*)?>[\\w\\W]*<\\/${target}>)`,
|
|
147
153
|
regex = new RegExp(string, 'g'),
|
|
@@ -150,6 +156,12 @@ function parseTemplate(target, template) {
|
|
|
150
156
|
return parsed[1] || ''
|
|
151
157
|
}
|
|
152
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Parses a given component.
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} comp - The component to be parsed.
|
|
163
|
+
* @returns {Object} The parsed component.
|
|
164
|
+
*/
|
|
153
165
|
function parseComponent(comp) {
|
|
154
166
|
def.parts = {
|
|
155
167
|
Template: parseTemplate('template', comp),
|
|
@@ -168,9 +180,7 @@ function parseComponent(comp) {
|
|
|
168
180
|
}
|
|
169
181
|
|
|
170
182
|
function openGitHub() {
|
|
171
|
-
openURL(
|
|
172
|
-
`${siteConfig.githubEditRootSrc}/examples/${examples.name}/${props.file}.vue`,
|
|
173
|
-
)
|
|
183
|
+
openURL(`${siteConfig.githubEditRootSrc}/examples/${examples.name}/${props.file}.vue`)
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
function openCodepen() {
|