@onderwijsin/nuxt-markdown-renderer 0.0.0-stage → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +332 -2
  3. package/dist/metadata/runtime/app/components/renderer/MarkdownButton.vue +67 -0
  4. package/dist/metadata/runtime/app/components/renderer/MarkdownCallout.vue +115 -0
  5. package/dist/metadata/runtime/app/components/renderer/MarkdownReference.vue +33 -0
  6. package/dist/metadata/runtime/app/utils/define-editor-component-schema.ts +12 -0
  7. package/dist/metadata/schema/editor-component-schema.ts +262 -0
  8. package/dist/module.d.mts +22 -0
  9. package/dist/module.json +12 -0
  10. package/dist/module.mjs +268 -0
  11. package/dist/runtime/app/comark-plugins/video-source.d.ts +8 -0
  12. package/dist/runtime/app/comark-plugins/video-source.js +31 -0
  13. package/dist/runtime/app/components/MarkdownRenderer.d.vue.ts +12 -0
  14. package/dist/runtime/app/components/MarkdownRenderer.vue +41 -0
  15. package/dist/runtime/app/components/MarkdownRenderer.vue.d.ts +12 -0
  16. package/dist/runtime/app/components/renderer/MarkdownButton.d.vue.ts +26 -0
  17. package/dist/runtime/app/components/renderer/MarkdownButton.vue +47 -0
  18. package/dist/runtime/app/components/renderer/MarkdownButton.vue.d.ts +26 -0
  19. package/dist/runtime/app/components/renderer/MarkdownCallout.d.vue.ts +49 -0
  20. package/dist/runtime/app/components/renderer/MarkdownCallout.vue +80 -0
  21. package/dist/runtime/app/components/renderer/MarkdownCallout.vue.d.ts +49 -0
  22. package/dist/runtime/app/components/renderer/MarkdownReference.d.vue.ts +17 -0
  23. package/dist/runtime/app/components/renderer/MarkdownReference.vue +24 -0
  24. package/dist/runtime/app/components/renderer/MarkdownReference.vue.d.ts +17 -0
  25. package/dist/runtime/app/utils/component-manifest.d.ts +13 -0
  26. package/dist/runtime/app/utils/component-manifest.js +17 -0
  27. package/dist/runtime/app/utils/define-editor-component-schema.d.ts +9 -0
  28. package/dist/runtime/app/utils/define-editor-component-schema.js +3 -0
  29. package/dist/runtime/app/utils/resolve-reference-path.d.ts +7 -0
  30. package/dist/runtime/app/utils/resolve-reference-path.js +2 -0
  31. package/dist/runtime/index.css +1 -0
  32. package/dist/runtime/index.d.ts +1 -0
  33. package/dist/runtime/index.js +0 -0
  34. package/dist/runtime/server/utils/component-metadata-handler.d.ts +61 -0
  35. package/dist/runtime/server/utils/component-metadata-handler.js +17 -0
  36. package/dist/runtime/server/utils/metadata.d.ts +22 -0
  37. package/dist/runtime/server/utils/metadata.js +186 -0
  38. package/dist/runtime/shared/types.d.ts +1 -0
  39. package/dist/runtime/shared/types.js +0 -0
  40. package/dist/runtime/types/markdown-renderer.d.ts +20 -0
  41. package/dist/schema/editor-component-schema.d.ts +223 -0
  42. package/dist/schema/editor-component-schema.js +151 -0
  43. package/dist/types.d.mts +7 -0
  44. package/package.json +78 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stichting Onderwijs in
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,333 @@
1
- # Temporary Holding Version
1
+ # @onderwijsin/nuxt-markdown-renderer
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Nuxt 4 module for rendering Markdown and MDC with Comark, Nuxt UI Prose, lazy application
4
+ components, and component metadata for the Directus Markdown editor.
5
+
6
+ ## Features
7
+
8
+ - Renders Markdown and MDC through the global `MarkdownRenderer` component.
9
+ - Includes `MarkdownButton`, `MarkdownCallout`, and the persisted `Reference` node.
10
+ - Discovers application renderer components through Nuxt's component registry.
11
+ - Lazily imports custom components and optionally restricts them with named component sets.
12
+ - Exposes Directus-compatible component metadata, including CORS preflight handling.
13
+ - Provides a typed compiler macro for editor labels, node types, choices, input controls, and
14
+ deprecation hints.
15
+
16
+ ## Requirements
17
+
18
+ - Nuxt `^4.0.0`
19
+ - Node.js 24 or newer
20
+ - Vue `^3.5.0`, Nuxt UI `^4.0.0`, and `@comark/nuxt`, `@comark/vue`, and `comark` `>=0.6.2` are peer
21
+ dependencies.
22
+
23
+ The renderer can be used alongside `@onderwijsin/nuxt-webmanifest` and Schema.org components without
24
+ installing `@unhead/schema-org` separately. Renderer component metadata remains available.
25
+
26
+ Use the application's Vue runtime and keep all three Comark packages on the same version. Separate
27
+ Vue copies can cause missing Prose styles and SSR hydration mismatches.
28
+
29
+ ## Installation
30
+
31
+ ```sh
32
+ pnpm add @onderwijsin/nuxt-markdown-renderer @nuxt/ui @comark/nuxt @comark/vue comark
33
+ ```
34
+
35
+ Register the module:
36
+
37
+ ```ts
38
+ export default defineNuxtConfig({
39
+ modules: ["@onderwijsin/nuxt-markdown-renderer"]
40
+ });
41
+ ```
42
+
43
+ Import the module stylesheet in the consuming application's main CSS file after `@nuxt/ui`:
44
+
45
+ ```css
46
+ @import "tailwindcss";
47
+ @import "@nuxt/ui";
48
+ @import "@onderwijsin/nuxt-markdown-renderer";
49
+ ```
50
+
51
+ ## Render Markdown
52
+
53
+ `MarkdownRenderer` accepts the Markdown source and an optional named component set:
54
+
55
+ ```vue
56
+ <template>
57
+ <MarkdownRenderer :value="article.content" component-set="article" />
58
+ </template>
59
+ ```
60
+
61
+ | Prop | Type | Default | Description |
62
+ | -------------- | ---------------- | ----------- | ----------------------------------------------- |
63
+ | `value` | `string` | `undefined` | Markdown or MDC source. |
64
+ | `plugins` | `ComarkPlugin[]` | `undefined` | Additional initialized Comark plugins. |
65
+ | `componentSet` | `string` | `undefined` | Optional configured custom-component allowlist. |
66
+
67
+ The built-in MDC nodes are:
68
+
69
+ | Markdown node | Vue implementation | Editor label | Behavior |
70
+ | ----------------- | ------------------- | ------------ | -------------------------------------------- |
71
+ | `MarkdownButton` | `MarkdownButton` | Button | Inline Nuxt UI button or link. |
72
+ | `MarkdownCallout` | `MarkdownCallout` | Callout | Block Nuxt UI alert with editable content. |
73
+ | `Reference` | `MarkdownReference` | — | Directus item reference; excluded from menu. |
74
+
75
+ The built-in button's icon editor metadata uses the `lucide` collection by default. To offer other
76
+ icon collections in component metadata, override the relevant renderer component and define its own
77
+ `defineEditorComponentSchema` with the desired `collections` for each icon input.
78
+
79
+ For example:
80
+
81
+ ```md
82
+ ::MarkdownCallout{title="Before you continue" color="warning"} Read the
83
+ :MarkdownButton{label="documentation" to="/docs" variant="soft"}. ::
84
+ ```
85
+
86
+ ## Configuration
87
+
88
+ ```ts
89
+ export default defineNuxtConfig({
90
+ markdownRenderer: {
91
+ enabled: true,
92
+ scopeComponentMeta: true,
93
+ componentsDir: "renderer",
94
+ componentSets: {
95
+ article: ["MarkdownButton", "MarkdownCallout", "MarkdownHero"],
96
+ landing: ["MarkdownButton", "MarkdownHero"]
97
+ },
98
+ resolveReferencePath: "~/utils/resolveReferencePath",
99
+ videoBaseUrl: "https://media.example.com/assets/",
100
+ corsOrigin: "https://directus.example.com"
101
+ }
102
+ });
103
+ ```
104
+
105
+ | Option | Type | Default | Description |
106
+ | ---------------------- | -------------------------- | ------------ | ----------------------------------------------------------------- |
107
+ | `enabled` | `boolean` | `true` | Enables component, manifest, and metadata endpoint registration. |
108
+ | `scopeComponentMeta` | `boolean` | `true` | Limits global component metadata extraction to renderer sources. |
109
+ | `componentsDir` | `string` | `"renderer"` | Directory below `app/components/` containing renderer components. |
110
+ | `componentSets` | `Record<string, string[]>` | `{}` | Named allowlists used by rendering and metadata endpoints. |
111
+ | `resolveReferencePath` | `string` | unset | Nuxt-resolvable path to a default-exported Reference resolver. |
112
+ | `videoBaseUrl` | `string` | unset | Absolute base URL for relative video sources. |
113
+ | `corsOrigin` | `string \| string[]` | `"*"` | Origins allowed to call the metadata endpoint from a browser. |
114
+
115
+ A single `corsOrigin` string is accepted and normalized to an allowlist. Use `"null"` only when a
116
+ sandboxed or local client intentionally sends an opaque origin.
117
+
118
+ ## Video sources and plugins
119
+
120
+ Set `markdownRenderer.videoBaseUrl` to an absolute URL to prefix relative `video` sources:
121
+
122
+ ```md
123
+ :video{src="clip.mp4" controls}
124
+ ```
125
+
126
+ With `videoBaseUrl: "https://media.example.com/assets/"`, both `clip.mp4` and `/clip.mp4` resolve to
127
+ `https://media.example.com/assets/clip.mp4`. URLs with a protocol (including `blob:` and `data:`)
128
+ and protocol-relative URLs (`//...`) remain unchanged. The transformation only affects a `video`
129
+ node's string `src`; nested `source` elements are unchanged. Omit the option to preserve video
130
+ sources and leave the built-in plugin unloaded.
131
+
132
+ `MarkdownRenderer` also accepts `plugins?: ComarkPlugin[]` through its `plugins` prop. Pass
133
+ initialized Comark plugins; they run before the built-in video-source plugin. The renderer does not
134
+ mutate the supplied array. Built-in plugin selection and the video base URL are captured when the
135
+ renderer is created; remount it after changing the video configuration.
136
+
137
+ ## Custom renderer components
138
+
139
+ Place Vue files directly in `app/components/<componentsDir>/`. Nested files are not discovered. Nuxt
140
+ owns filename resolution and extension support; a consumer file with the same registered name
141
+ replaces a built-in component.
142
+
143
+ This `MarkdownHero.vue` example uses the typed `defineEditorComponentSchema` compiler macro:
144
+
145
+ ```vue
146
+ <script setup lang="ts">
147
+ import { defineEditorComponentSchema } from "#imports";
148
+
149
+ defineEditorComponentSchema({
150
+ label: "Hero",
151
+ description: "A prominent page introduction.",
152
+ type: "block",
153
+ properties: {
154
+ actionTo: { input: "url" },
155
+ image: { properties: { src: { input: "image" } } },
156
+ actions: {
157
+ items: {
158
+ properties: {
159
+ to: { input: "url" },
160
+ icon: { input: { type: "icon", collections: ["lucide"] } }
161
+ }
162
+ }
163
+ },
164
+ legacyTone: { deprecated: { text: "Use tone instead." } }
165
+ }
166
+ });
167
+
168
+ defineProps<{
169
+ /** Main hero heading. */
170
+ title: string;
171
+ /** Horizontal content alignment. */
172
+ align?: "left" | "center";
173
+ /** Call-to-action destination. */
174
+ actionTo?: string;
175
+ image?: { src: string; alt?: string };
176
+ actions?: { label: string; to: string; icon?: string }[];
177
+ /** Legacy color name. */
178
+ legacyTone?: string;
179
+ }>();
180
+ </script>
181
+
182
+ <template>
183
+ <section>
184
+ <h1>{{ title }}</h1>
185
+ <slot />
186
+ </section>
187
+ </template>
188
+ ```
189
+
190
+ Use the registered component name in Markdown and component sets:
191
+
192
+ ```md
193
+ ::MarkdownHero{title="Build with Markdown" align="center" action-to="https://example.com"} Editable
194
+ **Markdown** in the default slot. ::
195
+ ```
196
+
197
+ `nuxt-component-meta` infers prop types, nested object fields, array items, descriptions,
198
+ required/default state, literal unions, and JSDoc tags. The macro enriches these inferred fields
199
+ without repeating their TypeScript types:
200
+
201
+ For the module's built-in components, metadata inference reads the packaged typed Vue source. This
202
+ preserves JSDoc, defaults, slots, nested prop structure, and macro tags in installed applications as
203
+ well as the module playground.
204
+
205
+ | Field | Purpose |
206
+ | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
207
+ | `label` | Human-facing label, distinct from the Markdown node name. |
208
+ | `description` | Help text shown while choosing a component. |
209
+ | `type` | Required insertion behavior: `"block"` or `"inline"`. |
210
+ | `deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
211
+ | `properties.<name>.values` | Explicit choices, particularly for imported union types. |
212
+ | `properties.<name>.input` | `"image"`/`{ type: "image" }`, `"url"`/`{ type: "url" }`, or `{ type: "icon", collections: [...] }` for a string prop. |
213
+ | `properties.<name>.properties` | Overrides for fields of an inferred object prop. |
214
+ | `properties.<name>.items` | Overrides for the inferred item of an array prop. |
215
+ | `properties.<name>.deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
216
+ | `properties.<name>.type` | Explicit `string`, `number`, `boolean`, `object`, or `array` editor type. |
217
+ | `properties.<name>.description/default/required` | Overrides the corresponding inferred metadata. |
218
+
219
+ The macro translates `input` and `deprecated` to the standard tags consumed by the Directus
220
+ extension. Special inputs use a `specialInputType` tag; icon collections appear as
221
+ `config.collections` on that tag. The string and object forms are equivalent when an input requires
222
+ no options. Only fields declared by the input's Zod config schema are accepted and carried to the
223
+ tag's `config` object. The lower-level `extendComponentMeta` macro remains available for metadata
224
+ not covered by this convenience API. Invalid macro fields, including misspelled nested fields or
225
+ unsupported input controls, produce a build warning with the failing property path; that component's
226
+ editor overrides are ignored until the schema is corrected. The `image`, `url`, and `icon` inputs
227
+ require an inferred string prop, including at nested paths. An incompatible inferred type causes the
228
+ metadata endpoint to report the component and property path as a validation error.
229
+
230
+ Use `properties` at the top level of `defineEditorComponentSchema` and for nested object fields. The
231
+ generated metadata and Directus endpoint response continue to expose component fields as `props`.
232
+
233
+ ### Component sets
234
+
235
+ Component-set values use the public Markdown node names. Passing `component-set="article"` to
236
+ `MarkdownRenderer` prevents components outside that set from resolving. The corresponding metadata
237
+ URL returns only that set. An unknown set prevents custom component resolution and its metadata URL
238
+ returns HTTP 404.
239
+
240
+ The reserved `Reference` node always resolves regardless of the selected set, including empty or
241
+ unknown sets. It remains excluded from all metadata endpoints and does not need a set entry.
242
+
243
+ Omit `component-set` to allow every discovered renderer component.
244
+
245
+ ## Directus metadata endpoint
246
+
247
+ Configure the Directus Markdown editor with a browser-accessible URL:
248
+
249
+ ```text
250
+ https://website.example.com/api/markdown-renderer/components/article
251
+ ```
252
+
253
+ The endpoint returns a bare component array. Omit the final set name to return all discovered
254
+ components. `Reference` is deliberately omitted because the Directus editor owns that reserved node.
255
+ Both `GET` and browser `OPTIONS` preflight requests are handled.
256
+
257
+ The endpoint is public and sends no authentication challenge. CORS controls which browser origins
258
+ may read it; it is not an authorization mechanism. The default `corsOrigin: "*"` supports separate
259
+ local and production Directus installations. Configure explicit HTTPS origins when deployment policy
260
+ requires a narrower allowlist.
261
+
262
+ ## References
263
+
264
+ The built-in `MarkdownReference` renders the persisted Directus syntax `:Reference`. It displays
265
+ `text ?? label` and remains plain text unless the application supplies a route resolver:
266
+
267
+ ```ts
268
+ // app/utils/resolveReferencePath.ts
269
+ import type { ResolveReferencePath } from "@onderwijsin/nuxt-markdown-renderer/runtime";
270
+
271
+ const resolveReferencePath: ResolveReferencePath = (collection, item, _label, _text, data) => {
272
+ if (collection === "articles") return `/articles/${String(data?.slug ?? item)}`;
273
+ };
274
+
275
+ export default resolveReferencePath;
276
+ ```
277
+
278
+ The resolver receives `collection`, `item`, optional `label`, optional author-controlled `text`, and
279
+ the optional Directus source snapshot `data`. Returning a string renders a Nuxt link; returning
280
+ `undefined` keeps the display text unlinked. The module never guesses application routes.
281
+
282
+ An application can replace the built-in behavior with
283
+ `app/components/<componentsDir>/MarkdownReference.vue`. It is still exposed to Markdown as
284
+ `Reference`, preserving existing stored content.
285
+
286
+ ## Disable the module
287
+
288
+ ```ts
289
+ export default defineNuxtConfig({
290
+ markdownRenderer: { enabled: false }
291
+ });
292
+ ```
293
+
294
+ The static type declaration remains available during `nuxt prepare`, but runtime components,
295
+ auto-imports, templates, and routes are not registered.
296
+
297
+ ## Troubleshooting
298
+
299
+ | Symptom | Check |
300
+ | ------------------------------------ | --------------------------------------------------------------------------- |
301
+ | Custom component renders as Markdown | Put it directly in `app/components/<componentsDir>/` and use its Nuxt name. |
302
+ | Component is missing for one field | Include its public name in the selected `componentSets` entry. |
303
+ | Metadata URL returns 404 | The requested component-set name is not configured. |
304
+ | Directus reports a CORS failure | Add the exact Directus origin to `corsOrigin`, including scheme and port. |
305
+ | Metadata omits a custom component | Ensure the SFC is discoverable and exposes parseable component metadata. |
306
+ | Reference is not linked | Configure `resolveReferencePath` and return a route for that collection. |
307
+
308
+ ## Development
309
+
310
+ ```sh
311
+ pnpm --filter markdown-renderer-playground dev
312
+ pnpm --filter markdown-renderer-playground typecheck
313
+ pnpm --filter markdown-renderer-playground build
314
+ ```
315
+
316
+ ## Component metadata scope
317
+
318
+ `markdownRenderer.scopeComponentMeta` defaults to `true`. The application's global
319
+ `nuxt-component-meta` parser processes only built-in renderer components and direct children of
320
+ `app/components/<componentsDir>/`, using packaged typed sources for built-in metadata.
321
+
322
+ If your application uses `nuxt-component-meta` for unrelated components, retain its normal global
323
+ behavior with:
324
+
325
+ ```ts
326
+ export default defineNuxtConfig({
327
+ markdownRenderer: { scopeComponentMeta: false }
328
+ });
329
+ ```
330
+
331
+ Disabling scoping preserves your component-meta component and directory configuration while keeping
332
+ built-in renderer source enrichment. Global metadata extraction can have significantly higher build
333
+ time and memory costs.
@@ -0,0 +1,67 @@
1
+ <script setup lang="ts">
2
+ import type { ButtonProps } from "@nuxt/ui";
3
+ import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
4
+
5
+ defineEditorComponentSchema({
6
+ label: "Button",
7
+ description: "A clickable button component.",
8
+ type: "block",
9
+ properties: {
10
+ color: {
11
+ values: [
12
+ "primary",
13
+ "secondary",
14
+ "success",
15
+ "info",
16
+ "warning",
17
+ "error",
18
+ "neutral"
19
+ ] satisfies Array<ButtonProps["color"]>
20
+ },
21
+ variant: {
22
+ values: ["solid", "outline", "soft", "subtle", "ghost", "link"] satisfies Array<
23
+ ButtonProps["variant"]
24
+ >
25
+ },
26
+ size: {
27
+ values: ["xs", "sm", "md", "lg", "xl"] satisfies Array<ButtonProps["size"]>
28
+ },
29
+ icon: {
30
+ input: {
31
+ type: "icon",
32
+ collections: ["lucide"]
33
+ }
34
+ }
35
+ }
36
+ });
37
+
38
+ withDefaults(
39
+ defineProps<{
40
+ /** Label displayed inside the button. */
41
+ label: string;
42
+ /** Link destination. Use either full URL or internal route path. */
43
+ to: string;
44
+ /** The color tone of the button. */
45
+ color?: ButtonProps["color"];
46
+ /** The visual style variant of the button. */
47
+ variant?: ButtonProps["variant"];
48
+ /** The size of the button. */
49
+ size?: ButtonProps["size"];
50
+ /** The icon displayed inside the button. */
51
+ icon?: string;
52
+ /** Whether the icon should be displayed after the label. */
53
+ trailing?: boolean;
54
+ /** Whether the button should trigger a download of the linked resource. */
55
+ download?: boolean;
56
+ }>(),
57
+ {
58
+ color: "primary",
59
+ variant: "soft",
60
+ size: "md"
61
+ }
62
+ );
63
+ </script>
64
+
65
+ <template>
66
+ <UButton v-bind="$props" />
67
+ </template>
@@ -0,0 +1,115 @@
1
+ <script setup lang="ts">
2
+ import type { AlertProps, ButtonProps } from "@nuxt/ui";
3
+ import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
4
+
5
+ defineEditorComponentSchema({
6
+ label: "Callout",
7
+ description: "A component used to highlight important information.",
8
+ type: "block",
9
+ properties: {
10
+ color: {
11
+ values: [
12
+ "primary",
13
+ "secondary",
14
+ "success",
15
+ "info",
16
+ "warning",
17
+ "error",
18
+ "neutral"
19
+ ] satisfies Array<AlertProps["color"]>
20
+ },
21
+ variant: {
22
+ values: ["solid", "outline", "soft", "subtle"] satisfies Array<AlertProps["variant"]>
23
+ },
24
+ icon: {
25
+ input: {
26
+ type: "icon",
27
+ collections: ["lucide"]
28
+ }
29
+ },
30
+ orientation: {
31
+ values: ["horizontal", "vertical"] satisfies Array<AlertProps["orientation"]>
32
+ },
33
+ actions: {
34
+ type: "array",
35
+ items: {
36
+ type: "object",
37
+ properties: {
38
+ color: {
39
+ values: [
40
+ "primary",
41
+ "secondary",
42
+ "success",
43
+ "info",
44
+ "warning",
45
+ "error",
46
+ "neutral"
47
+ ] satisfies Array<ButtonProps["color"]>
48
+ },
49
+ variant: {
50
+ values: ["solid", "outline", "soft", "subtle", "ghost", "link"] satisfies Array<
51
+ ButtonProps["variant"]
52
+ >
53
+ },
54
+ size: {
55
+ values: ["xs", "sm", "md", "lg", "xl"] satisfies Array<ButtonProps["size"]>
56
+ },
57
+ icon: {
58
+ input: {
59
+ type: "icon",
60
+ collections: ["lucide"]
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ });
68
+
69
+ withDefaults(
70
+ defineProps<{
71
+ /** Callout title. */
72
+ title?: string;
73
+ /** The color tone of the callout. */
74
+ color?: AlertProps["color"];
75
+ /** The visual style variant of the callout. */
76
+ variant?: AlertProps["variant"];
77
+ /** Optional Iconify icon name. */
78
+ icon?: string;
79
+ /** The orientation of the callout. Determines the position of the actions. */
80
+ orientation?: AlertProps["orientation"];
81
+ /** Optional call-to-action buttons. */
82
+ actions?: {
83
+ /** Label displayed inside the button. */
84
+ label: string;
85
+ /** Link destination. Use either full URL or internal route path. */
86
+ to: string;
87
+ /** The color tone of the button. */
88
+ color?: ButtonProps["color"];
89
+ /** The visual style variant of the button. */
90
+ variant?: ButtonProps["variant"];
91
+ /** The size of the button. */
92
+ size?: ButtonProps["size"];
93
+ /** The icon displayed inside the button. */
94
+ icon?: string;
95
+ /** Whether the icon should be displayed after the label. */
96
+ trailing?: boolean;
97
+ /** Whether the button should trigger a download of the linked resource. */
98
+ download?: boolean;
99
+ }[];
100
+ }>(),
101
+ {
102
+ color: "primary",
103
+ variant: "soft",
104
+ orientation: "vertical"
105
+ }
106
+ );
107
+ </script>
108
+
109
+ <template>
110
+ <UAlert v-bind="$props">
111
+ <template v-if="$slots.description" #description>
112
+ <slot name="description" />
113
+ </template>
114
+ </UAlert>
115
+ </template>
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+
4
+ import resolveReferencePath from "#markdown-renderer/reference-resolver";
5
+
6
+ const props = defineProps<{
7
+ /** Directus collection name. */
8
+ collection: string;
9
+ /** Referenced Directus item primary key. */
10
+ item: string;
11
+ /** Source display label. */
12
+ label?: string;
13
+ /** Author-controlled display text. */
14
+ text?: string;
15
+ /** Iconify icon as collection:name. */
16
+ icon?: string;
17
+ /** Reference source snapshot. */
18
+ data?: Record<string, unknown>;
19
+ }>();
20
+
21
+ const displayText = computed(() => props.text ?? props.label ?? "");
22
+ const path = computed(() =>
23
+ resolveReferencePath(props.collection, props.item, props.label, props.text, props.data)
24
+ );
25
+ </script>
26
+
27
+ <template>
28
+ <ULink v-if="path" variant="link" :to="path" :icon="icon" class="text-primary underline">
29
+ <UIcon v-if="icon" :name="icon" class="mr-1 align-[-0.125em]" />
30
+ <span>{{ displayText }}</span>
31
+ </ULink>
32
+ <span v-else>{{ displayText }}</span>
33
+ </template>
@@ -0,0 +1,12 @@
1
+ import type { EditorComponentInput } from "../../../schema/editor-component-schema";
2
+
3
+ /**
4
+ * Defines editor metadata for a Markdown component.
5
+ *
6
+ * This is a compiler macro registered with `nuxt-component-meta`; its call is extracted at build
7
+ * time. The implementation is intentionally inert in case tooling evaluates the module directly.
8
+ * @param metadata Markdown editor metadata extracted during the Nuxt build.
9
+ */
10
+ export function defineEditorComponentSchema(metadata: EditorComponentInput): void {
11
+ void metadata;
12
+ }