@valkyrianlabs/payload-markdown 1.3.3 → 1.4.0

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 (99) hide show
  1. package/README.md +63 -14
  2. package/dist/components/MarkdownRenderer/index.css +150 -0
  3. package/dist/components/MarkdownRenderer/index.scss +158 -0
  4. package/dist/core/plugins/rehypeResolveIcons.d.ts +4 -0
  5. package/dist/core/plugins/rehypeResolveIcons.js +27 -0
  6. package/dist/core/plugins/rehypeResolveIcons.js.map +1 -0
  7. package/dist/core/plugins/remarkButtonDirectives.d.ts +4 -0
  8. package/dist/core/plugins/remarkButtonDirectives.js +237 -0
  9. package/dist/core/plugins/remarkButtonDirectives.js.map +1 -0
  10. package/dist/core/plugins/remarkCompileLayouts.js +6 -5
  11. package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
  12. package/dist/core/plugins/remarkLayoutDirectives.js +17 -7
  13. package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
  14. package/dist/core/plugins/remarkLiftLayoutDirectives.js +42 -4
  15. package/dist/core/plugins/remarkLiftLayoutDirectives.js.map +1 -1
  16. package/dist/core/renderMarkdown.js +27 -2
  17. package/dist/core/renderMarkdown.js.map +1 -1
  18. package/dist/directives/attributeDiagnostics.d.ts +2 -0
  19. package/dist/directives/attributeDiagnostics.js +35 -0
  20. package/dist/directives/attributeDiagnostics.js.map +1 -0
  21. package/dist/directives/attributes.d.ts +8 -0
  22. package/dist/directives/attributes.js +56 -5
  23. package/dist/directives/attributes.js.map +1 -1
  24. package/dist/directives/buttonSyntax.d.ts +7 -0
  25. package/dist/directives/buttonSyntax.js +26 -0
  26. package/dist/directives/buttonSyntax.js.map +1 -0
  27. package/dist/directives/closeLabels.d.ts +8 -0
  28. package/dist/directives/closeLabels.js +76 -0
  29. package/dist/directives/closeLabels.js.map +1 -0
  30. package/dist/directives/definitions/button.d.ts +15 -0
  31. package/dist/directives/definitions/button.js +96 -0
  32. package/dist/directives/definitions/button.js.map +1 -0
  33. package/dist/directives/definitions/buttons.d.ts +8 -0
  34. package/dist/directives/definitions/buttons.js +82 -0
  35. package/dist/directives/definitions/buttons.js.map +1 -0
  36. package/dist/directives/definitions/callout.js +20 -9
  37. package/dist/directives/definitions/callout.js.map +1 -1
  38. package/dist/directives/definitions/card.d.ts +4 -0
  39. package/dist/directives/definitions/card.js +90 -9
  40. package/dist/directives/definitions/card.js.map +1 -1
  41. package/dist/directives/definitions/cards.d.ts +4 -0
  42. package/dist/directives/definitions/cards.js +119 -4
  43. package/dist/directives/definitions/cards.js.map +1 -1
  44. package/dist/directives/definitions/details.js +4 -3
  45. package/dist/directives/definitions/details.js.map +1 -1
  46. package/dist/directives/definitions/tab.d.ts +1 -0
  47. package/dist/directives/definitions/tab.js +10 -3
  48. package/dist/directives/definitions/tab.js.map +1 -1
  49. package/dist/directives/definitions/tabs.js +3 -3
  50. package/dist/directives/definitions/tabs.js.map +1 -1
  51. package/dist/directives/definitions/toc.js +4 -3
  52. package/dist/directives/definitions/toc.js.map +1 -1
  53. package/dist/directives/diagnostics.js +97 -7
  54. package/dist/directives/diagnostics.js.map +1 -1
  55. package/dist/directives/iconPlaceholder.d.ts +12 -0
  56. package/dist/directives/iconPlaceholder.js +19 -0
  57. package/dist/directives/iconPlaceholder.js.map +1 -0
  58. package/dist/directives/labels.d.ts +3 -0
  59. package/dist/directives/labels.js +12 -0
  60. package/dist/directives/labels.js.map +1 -0
  61. package/dist/directives/registry.d.ts +1 -1
  62. package/dist/directives/registry.js +46 -6
  63. package/dist/directives/registry.js.map +1 -1
  64. package/dist/directives/renderData.d.ts +2 -2
  65. package/dist/directives/renderData.js.map +1 -1
  66. package/dist/directives/types.d.ts +6 -4
  67. package/dist/directives/types.js.map +1 -1
  68. package/dist/editor/MarkdownCodeMirror/Component.client.js +2 -0
  69. package/dist/editor/MarkdownCodeMirror/Component.client.js.map +1 -1
  70. package/dist/editor/directives/closeLabels.d.ts +2 -0
  71. package/dist/editor/directives/closeLabels.js +75 -0
  72. package/dist/editor/directives/closeLabels.js.map +1 -0
  73. package/dist/editor/directives/completions.js +49 -7
  74. package/dist/editor/directives/completions.js.map +1 -1
  75. package/dist/editor/themes/payload.js +197 -9
  76. package/dist/editor/themes/payload.js.map +1 -1
  77. package/dist/exports/advanced.d.ts +1 -0
  78. package/dist/exports/advanced.js +1 -0
  79. package/dist/exports/advanced.js.map +1 -1
  80. package/dist/icons/generateRegistry.d.ts +8 -0
  81. package/dist/icons/generateRegistry.js +36 -0
  82. package/dist/icons/generateRegistry.js.map +1 -0
  83. package/dist/icons/refs.d.ts +10 -0
  84. package/dist/icons/refs.js +42 -0
  85. package/dist/icons/refs.js.map +1 -0
  86. package/dist/icons/resolve.d.ts +9 -0
  87. package/dist/icons/resolve.js +95 -0
  88. package/dist/icons/resolve.js.map +1 -0
  89. package/dist/index.d.ts +1 -1
  90. package/dist/index.js.map +1 -1
  91. package/dist/runtime/index.d.ts +1 -0
  92. package/dist/runtime/index.js +8 -1
  93. package/dist/runtime/index.js.map +1 -1
  94. package/dist/types/core.d.ts +9 -0
  95. package/dist/types/core.js.map +1 -1
  96. package/dist/types/mdast.d.js.map +1 -1
  97. package/dist/types.d.ts +5 -1
  98. package/dist/types.js.map +1 -1
  99. package/package.json +1 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  Structured Markdown editing and rendering for Payload CMS.
14
14
 
15
- `@valkyrianlabs/payload-markdown` gives Payload a Markdown-first authoring system with a CodeMirror editor, Shiki-powered code blocks, registry-backed directives, named themes, tabs, cards, table-of-contents generation, autocomplete, diagnostics, and server-first rendering.
15
+ `@valkyrianlabs/payload-markdown` gives Payload a Markdown-first authoring system with a CodeMirror editor, Shiki-powered code blocks, registry-backed directives, local SVG icon packs, buttons, cards, table-of-contents generation, autocomplete, diagnostics, and server-first rendering.
16
16
 
17
17
  No bloated rich text editor.
18
18
  No JSON-shaped content prison.
@@ -20,6 +20,8 @@ No MDX ceremony for common docs/blog layouts.
20
20
 
21
21
  Just portable Markdown that renders like a real system.
22
22
 
23
+ Payload Markdown now feels much closer to a Markdown-native design system: readable `[Title]` directive labels, expanded multiline args, local icon packs, button primitives, smarter autocomplete, richer card linking, and editor readability aids without giving up portable Markdown.
24
+
23
25
  ---
24
26
 
25
27
  ## Install
@@ -46,9 +48,9 @@ This plugin takes the third path:
46
48
  - Markdown stays the source of truth
47
49
  - structure lives directly in the content
48
50
  - rendering is production-ready by default
49
- - directives provide layout without turning content into a page-builder blob
51
+ - directives provide layout, buttons, cards, and common calls to action without turning content into a page-builder blob
50
52
  - themes provide clean visual control without runtime Tailwind roulette
51
- - autocomplete and diagnostics make authoring fast instead of fussy
53
+ - autocomplete, syntax highlighting, closing labels, and diagnostics make authoring fast instead of fussy
52
54
 
53
55
  **Write fast. Render clean. Stay in control.**
54
56
 
@@ -61,18 +63,61 @@ This plugin takes the third path:
61
63
  - **Editor UX** — CodeMirror-powered editing
62
64
  - **Code rendering** — Shiki-powered highlighting
63
65
  - **Server-first output** — clean rendering without client ceremony
64
- - **Structured directives** — callouts, details, TOCs, steps, cards, tabs, and layouts
65
- - **Autocomplete** — directive snippets and placeholders
66
+ - **Structured directives** — callouts, details, TOCs, steps, cards, buttons, tabs, and layouts
67
+ - **Buttons** — `::button` leaf directives and `:::buttons` groups
68
+ - **Icon packs** — local SVG packs referenced as `@pack/name`
69
+ - **Autocomplete** — directive snippets, placeholders, and editor-only snippet variants
66
70
  - **Diagnostics** — lightweight authoring warnings
67
71
  - **Heading anchors** — automatic IDs and table-of-contents support
68
72
  - **Themes** — themeable directive output with stable hooks
73
+ - **Card links** — `linkScope` and `newTab` controls for card and cards layouts
69
74
  - **Scoped config** — global and collection-level overrides
70
75
  - **Portable storage** — clean Markdown source
71
76
  - **AI-friendly workflow** — content that agents and humans can edit sanely
72
77
 
73
- ![Payload Markdown v1.3 directive preview](https://docs-media.valkyrianlabs.com/payload-markdown_v1.3_new_directives_example_1.png)
78
+ ![Payload Markdown directive preview](https://docs-media.valkyrianlabs.com/payload-markdown_v1.3_new_directives_example_1.png)
79
+
80
+ `payload-markdown` renders structured Markdown directly inside the Payload admin preview, including callouts, details, TOCs, steps, cards, buttons, tabs, themes, icons, and code blocks — without turning your content into JSON-shaped sludge.
81
+
82
+ ---
83
+
84
+ ## v1.4 authoring primitives
85
+
86
+ New examples prefer labels for visible titles and expanded attrs for anything non-trivial:
87
+
88
+ ```md
89
+ :::card[Fast Setup]{
90
+ href="/getting-started/installation"
91
+ linkScope="title"
92
+ icon="@fa-duotone/bolt"
93
+ }
94
+ Install, configure, ship.
95
+
96
+ :::buttons{
97
+ align="center"
98
+ stack="mobile"
99
+ gap="md"
100
+ }
101
+ ::button[Read Docs]{
102
+ href="/docs"
103
+ variant="primary"
104
+ icon="@fa-duotone/book-open"
105
+ }
106
+
107
+ ::button[GitHub]{
108
+ href="https://github.com/valkyrianlabs/payload-markdown"
109
+ variant="secondary"
110
+ icon="@brand/github"
111
+ newTab=true
112
+ }
113
+ :::
114
+
115
+ :::
116
+ ```
117
+
118
+ The older `title=""` form remains compatible, but `[Title]` keeps visible content out of the argument list. Card and cards directives support scoped linking through `linkScope`; use `linkScope="title"` when a card body contains buttons or links.
74
119
 
75
- `payload-markdown` renders structured Markdown directly inside the Payload admin preview, including callouts, details, TOCs, steps, cards, tabs, themes, and code blocks without turning your content into JSON-shaped sludge.
120
+ Editor completion can expose shortcuts such as `::button`, `::button_icon`, and `::button_full`, but generated Markdown always uses the canonical `::button` directive. Syntax highlighting now distinguishes directive names, labels, arg names, arg values, and leaf-vs-container directives, while closing labels make nested `:::` blocks easier to scan.
76
121
 
77
122
  ---
78
123
 
@@ -86,6 +131,8 @@ Payload Markdown supports structured directives for real content layouts:
86
131
  - `:::steps`
87
132
  - `:::cards`
88
133
  - `:::card`
134
+ - `::button`
135
+ - `:::buttons`
89
136
  - `:::tabs`
90
137
  - `:::tab`
91
138
  - `:::section`
@@ -113,7 +160,7 @@ Themes can be configured globally or scoped per collection, then selected direct
113
160
 
114
161
  Stable classes and data attributes are emitted for overrides, including `data-directive`, `data-theme`, and `vl-md-*` hook classes.
115
162
 
116
- [Theme documentation →](https://docs.valkyrianlabs.com/plugins/payload-markdown/configuration/themes)
163
+ [Theme documentation →](https://docs.valkyrianlabs.com/plugins/payload-markdown/configuration/directive-themes)
117
164
 
118
165
  ---
119
166
 
@@ -133,7 +180,7 @@ Migration mapping:
133
180
  - `config.options.enhancedCodeBlocks` → `code.enhanced`
134
181
  - `config.fullBleedCode` → `code.fullBleed`
135
182
 
136
- [Code block documentation →](https://docs.valkyrianlabs.com/plugins/payload-markdown/configuration/code)
183
+ [Code block documentation →](https://docs.valkyrianlabs.com/plugins/payload-markdown/configuration/code-blocks)
137
184
 
138
185
  ---
139
186
 
@@ -152,7 +199,7 @@ The full setup guide covers:
152
199
  - themes
153
200
  - code block options
154
201
 
155
- [Quick start →](https://docs.valkyrianlabs.com/plugins/payload-markdown/getting-started)
202
+ [Quick start →](https://docs.valkyrianlabs.com/plugins/payload-markdown/getting-started/installation)
156
203
 
157
204
  ---
158
205
 
@@ -161,16 +208,18 @@ The full setup guide covers:
161
208
  The editor is built on CodeMirror and includes:
162
209
 
163
210
  - Markdown syntax highlighting
164
- - directive autocomplete
165
- - directive snippets
211
+ - directive autocomplete, including snippet variants such as `::button_icon`
212
+ - directive snippets with canonical Markdown output
166
213
  - snippet placeholders/tabstops
167
214
  - theme-aware attribute suggestions
215
+ - highlighting for directive labels and expanded arg blocks
216
+ - visual closing labels for nested directive blocks
168
217
  - lightweight diagnostics for malformed directives
169
218
  - warnings for unknown directives, invalid variants, invalid themes, malformed attrs, and common structural issues
170
219
 
171
220
  The goal is simple: author Markdown like text, but get enough tooling that complex docs stay pleasant.
172
221
 
173
- [Editor documentation →](https://docs.valkyrianlabs.com/plugins/payload-markdown/editor)
222
+ [Editor documentation →](https://docs.valkyrianlabs.com/plugins/payload-markdown/authoring/editor)
174
223
 
175
224
  ---
176
225
 
@@ -188,7 +237,7 @@ Theme class strings defined in your app config should also live in scanned sourc
188
237
 
189
238
  Runtime arbitrary Tailwind classes inside CMS-authored Markdown are not the recommended styling path. Use directive `theme="..."` values and configure named themes in source.
190
239
 
191
- [Tailwind setup →](https://docs.valkyrianlabs.com/plugins/payload-markdown/getting-started/tailwind)
240
+ [Tailwind setup →](https://docs.valkyrianlabs.com/plugins/payload-markdown/configuration/styling)
192
241
 
193
242
  ---
194
243
 
@@ -66,4 +66,154 @@ pre.shiki.md-code-enhanced code span.md-line .md-empty-line {
66
66
  pointer-events: none;
67
67
  }
68
68
 
69
+ .pmd-button {
70
+ --pmd-button-bg: rgb(8 145 178);
71
+ --pmd-button-border: rgb(8 145 178);
72
+ --pmd-button-color: rgb(255 255 255);
73
+ --pmd-button-hover-bg: rgb(6 182 212);
74
+ --pmd-button-hover-border: rgb(6 182 212);
75
+ display: inline-flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ gap: 0.5rem;
79
+ border: 1px solid var(--pmd-button-border);
80
+ border-radius: 0.5rem;
81
+ background: var(--pmd-button-bg);
82
+ color: var(--pmd-button-color);
83
+ font-weight: 600;
84
+ line-height: 1;
85
+ text-decoration: none;
86
+ transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
87
+ }
88
+ .pmd-button:hover {
89
+ background: var(--pmd-button-hover-bg);
90
+ border-color: var(--pmd-button-hover-border);
91
+ color: var(--pmd-button-color);
92
+ }
93
+ .pmd-button:focus-visible {
94
+ outline: 2px solid rgb(103, 232, 249);
95
+ outline-offset: 2px;
96
+ }
97
+
98
+ .pmd-button--secondary {
99
+ --pmd-button-bg: rgb(255 255 255 / 0.08);
100
+ --pmd-button-border: rgb(255 255 255 / 0.14);
101
+ --pmd-button-color: rgb(244 244 245);
102
+ --pmd-button-hover-bg: rgb(255 255 255 / 0.12);
103
+ --pmd-button-hover-border: rgb(255 255 255 / 0.2);
104
+ }
105
+
106
+ .pmd-button--outline {
107
+ --pmd-button-bg: transparent;
108
+ --pmd-button-border: rgb(8 145 178 / 0.65);
109
+ --pmd-button-color: rgb(103 232 249);
110
+ --pmd-button-hover-bg: rgb(8 145 178 / 0.12);
111
+ --pmd-button-hover-border: rgb(6 182 212);
112
+ }
113
+
114
+ .pmd-button--ghost {
115
+ --pmd-button-bg: transparent;
116
+ --pmd-button-border: transparent;
117
+ --pmd-button-color: rgb(103 232 249);
118
+ --pmd-button-hover-bg: rgb(255 255 255 / 0.08);
119
+ --pmd-button-hover-border: transparent;
120
+ }
121
+
122
+ .pmd-button--link {
123
+ --pmd-button-bg: transparent;
124
+ --pmd-button-border: transparent;
125
+ --pmd-button-color: rgb(103 232 249);
126
+ --pmd-button-hover-bg: transparent;
127
+ --pmd-button-hover-border: transparent;
128
+ padding-right: 0;
129
+ padding-left: 0;
130
+ text-decoration: underline;
131
+ text-underline-offset: 0.22em;
132
+ }
133
+
134
+ .pmd-button--sm {
135
+ min-height: 2rem;
136
+ padding: 0.45rem 0.75rem;
137
+ font-size: 0.875rem;
138
+ }
139
+
140
+ .pmd-button--md {
141
+ min-height: 2.5rem;
142
+ padding: 0.6rem 0.95rem;
143
+ font-size: 0.9375rem;
144
+ }
145
+
146
+ .pmd-button--lg {
147
+ min-height: 3rem;
148
+ padding: 0.75rem 1.15rem;
149
+ font-size: 1rem;
150
+ }
151
+
152
+ .pmd-button__icon {
153
+ display: inline-flex;
154
+ width: 1em;
155
+ height: 1em;
156
+ flex: 0 0 auto;
157
+ align-items: center;
158
+ justify-content: center;
159
+ }
160
+ .pmd-button__icon svg,
161
+ .pmd-button__icon path {
162
+ vector-effect: non-scaling-stroke;
163
+ }
164
+
165
+ .pmd-button__icon--right {
166
+ order: 2;
167
+ }
168
+
169
+ .pmd-buttons {
170
+ display: flex;
171
+ flex-wrap: wrap;
172
+ align-items: center;
173
+ }
174
+
175
+ .pmd-buttons--align-left {
176
+ justify-content: flex-start;
177
+ }
178
+
179
+ .pmd-buttons--align-center {
180
+ justify-content: center;
181
+ }
182
+
183
+ .pmd-buttons--align-right {
184
+ justify-content: flex-end;
185
+ }
186
+
187
+ .pmd-buttons--stack-mobile {
188
+ flex-direction: column;
189
+ align-items: stretch;
190
+ }
191
+ @media (min-width: 640px) {
192
+ .pmd-buttons--stack-mobile {
193
+ flex-direction: row;
194
+ align-items: center;
195
+ }
196
+ }
197
+
198
+ .pmd-buttons--stack-always {
199
+ flex-direction: column;
200
+ align-items: stretch;
201
+ }
202
+
203
+ .pmd-buttons--stack-never {
204
+ flex-direction: row;
205
+ }
206
+
207
+ .pmd-buttons--gap-sm {
208
+ gap: 0.5rem;
209
+ }
210
+
211
+ .pmd-buttons--gap-md {
212
+ gap: 0.75rem;
213
+ }
214
+
215
+ .pmd-buttons--gap-lg {
216
+ gap: 1rem;
217
+ }
218
+
69
219
  /*# sourceMappingURL=index.css.map */
@@ -81,3 +81,161 @@ pre.shiki.md-code-enhanced {
81
81
  }
82
82
  }
83
83
  }
84
+
85
+ .pmd-button {
86
+ --pmd-button-bg: rgb(8 145 178);
87
+ --pmd-button-border: rgb(8 145 178);
88
+ --pmd-button-color: rgb(255 255 255);
89
+ --pmd-button-hover-bg: rgb(6 182 212);
90
+ --pmd-button-hover-border: rgb(6 182 212);
91
+
92
+ display: inline-flex;
93
+ align-items: center;
94
+ justify-content: center;
95
+ gap: 0.5rem;
96
+ border: 1px solid var(--pmd-button-border);
97
+ border-radius: 0.5rem;
98
+ background: var(--pmd-button-bg);
99
+ color: var(--pmd-button-color);
100
+ font-weight: 600;
101
+ line-height: 1;
102
+ text-decoration: none;
103
+ transition:
104
+ background-color 160ms ease,
105
+ border-color 160ms ease,
106
+ color 160ms ease,
107
+ opacity 160ms ease;
108
+
109
+ &:hover {
110
+ background: var(--pmd-button-hover-bg);
111
+ border-color: var(--pmd-button-hover-border);
112
+ color: var(--pmd-button-color);
113
+ }
114
+
115
+ &:focus-visible {
116
+ outline: 2px solid rgb(103 232 249);
117
+ outline-offset: 2px;
118
+ }
119
+ }
120
+
121
+ .pmd-button--secondary {
122
+ --pmd-button-bg: rgb(255 255 255 / 0.08);
123
+ --pmd-button-border: rgb(255 255 255 / 0.14);
124
+ --pmd-button-color: rgb(244 244 245);
125
+ --pmd-button-hover-bg: rgb(255 255 255 / 0.12);
126
+ --pmd-button-hover-border: rgb(255 255 255 / 0.2);
127
+ }
128
+
129
+ .pmd-button--outline {
130
+ --pmd-button-bg: transparent;
131
+ --pmd-button-border: rgb(8 145 178 / 0.65);
132
+ --pmd-button-color: rgb(103 232 249);
133
+ --pmd-button-hover-bg: rgb(8 145 178 / 0.12);
134
+ --pmd-button-hover-border: rgb(6 182 212);
135
+ }
136
+
137
+ .pmd-button--ghost {
138
+ --pmd-button-bg: transparent;
139
+ --pmd-button-border: transparent;
140
+ --pmd-button-color: rgb(103 232 249);
141
+ --pmd-button-hover-bg: rgb(255 255 255 / 0.08);
142
+ --pmd-button-hover-border: transparent;
143
+ }
144
+
145
+ .pmd-button--link {
146
+ --pmd-button-bg: transparent;
147
+ --pmd-button-border: transparent;
148
+ --pmd-button-color: rgb(103 232 249);
149
+ --pmd-button-hover-bg: transparent;
150
+ --pmd-button-hover-border: transparent;
151
+
152
+ padding-right: 0;
153
+ padding-left: 0;
154
+ text-decoration: underline;
155
+ text-underline-offset: 0.22em;
156
+ }
157
+
158
+ .pmd-button--sm {
159
+ min-height: 2rem;
160
+ padding: 0.45rem 0.75rem;
161
+ font-size: 0.875rem;
162
+ }
163
+
164
+ .pmd-button--md {
165
+ min-height: 2.5rem;
166
+ padding: 0.6rem 0.95rem;
167
+ font-size: 0.9375rem;
168
+ }
169
+
170
+ .pmd-button--lg {
171
+ min-height: 3rem;
172
+ padding: 0.75rem 1.15rem;
173
+ font-size: 1rem;
174
+ }
175
+
176
+ .pmd-button__icon {
177
+ display: inline-flex;
178
+ width: 1em;
179
+ height: 1em;
180
+ flex: 0 0 auto;
181
+ align-items: center;
182
+ justify-content: center;
183
+
184
+ svg,
185
+ path {
186
+ vector-effect: non-scaling-stroke;
187
+ }
188
+ }
189
+
190
+ .pmd-button__icon--right {
191
+ order: 2;
192
+ }
193
+
194
+ .pmd-buttons {
195
+ display: flex;
196
+ flex-wrap: wrap;
197
+ align-items: center;
198
+ }
199
+
200
+ .pmd-buttons--align-left {
201
+ justify-content: flex-start;
202
+ }
203
+
204
+ .pmd-buttons--align-center {
205
+ justify-content: center;
206
+ }
207
+
208
+ .pmd-buttons--align-right {
209
+ justify-content: flex-end;
210
+ }
211
+
212
+ .pmd-buttons--stack-mobile {
213
+ flex-direction: column;
214
+ align-items: stretch;
215
+
216
+ @media (min-width: 640px) {
217
+ flex-direction: row;
218
+ align-items: center;
219
+ }
220
+ }
221
+
222
+ .pmd-buttons--stack-always {
223
+ flex-direction: column;
224
+ align-items: stretch;
225
+ }
226
+
227
+ .pmd-buttons--stack-never {
228
+ flex-direction: row;
229
+ }
230
+
231
+ .pmd-buttons--gap-sm {
232
+ gap: 0.5rem;
233
+ }
234
+
235
+ .pmd-buttons--gap-md {
236
+ gap: 0.75rem;
237
+ }
238
+
239
+ .pmd-buttons--gap-lg {
240
+ gap: 1rem;
241
+ }
@@ -0,0 +1,4 @@
1
+ import type { Root } from 'hast';
2
+ import type { Plugin } from 'unified';
3
+ import type { MarkdownRenderConfig } from '../../types/core.js';
4
+ export declare const rehypeResolveIcons: Plugin<[MarkdownRenderConfig?], Root>;
@@ -0,0 +1,27 @@
1
+ import { visit } from 'unist-util-visit';
2
+ import { resolvePayloadMarkdownIcon, validatePayloadMarkdownIconsConfig } from '../../icons/resolve.js';
3
+ function isElement(node) {
4
+ return Boolean(node && typeof node === 'object' && 'type' in node && node.type === 'element');
5
+ }
6
+ function getStringProperty(node, name) {
7
+ const value = node.properties?.[name];
8
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
9
+ }
10
+ export const rehypeResolveIcons = (config = {})=>{
11
+ return (tree, file)=>{
12
+ for (const warning of validatePayloadMarkdownIconsConfig(config.icons))file.message(warning);
13
+ visit(tree, 'element', (node, index, parent)=>{
14
+ if (!isElement(node)) return;
15
+ if (node.tagName !== 'span') return;
16
+ const iconRef = getStringProperty(node, 'dataPmdIconRef');
17
+ if (!iconRef) return;
18
+ const className = Array.isArray(node.properties.className) ? node.properties.className.join(' ') : typeof node.properties.className === 'string' ? node.properties.className : 'pmd-icon';
19
+ const resolved = resolvePayloadMarkdownIcon(iconRef, config.icons, className);
20
+ for (const warning of resolved.warnings)file.message(warning);
21
+ if (!parent || typeof index !== 'number') return;
22
+ parent.children.splice(index, 1, ...resolved.nodes);
23
+ });
24
+ };
25
+ };
26
+
27
+ //# sourceMappingURL=rehypeResolveIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/plugins/rehypeResolveIcons.ts"],"sourcesContent":["import type { Element, Root } from 'hast'\nimport type { Plugin } from 'unified'\n\nimport { visit } from 'unist-util-visit'\n\nimport type { MarkdownRenderConfig } from '../../types/core.js'\n\nimport {\n resolvePayloadMarkdownIcon,\n validatePayloadMarkdownIconsConfig,\n} from '../../icons/resolve.js'\n\nfunction isElement(node: unknown): node is Element {\n return Boolean(\n node && typeof node === 'object' && 'type' in node && (node as Element).type === 'element',\n )\n}\n\nfunction getStringProperty(node: Element, name: string): string | undefined {\n const value = node.properties?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nexport const rehypeResolveIcons: Plugin<[MarkdownRenderConfig?], Root> = (\n config: MarkdownRenderConfig = {},\n) => {\n return (tree, file) => {\n for (const warning of validatePayloadMarkdownIconsConfig(config.icons)) file.message(warning)\n\n visit(tree, 'element', (node, index, parent) => {\n if (!isElement(node)) return\n if (node.tagName !== 'span') return\n\n const iconRef = getStringProperty(node, 'dataPmdIconRef')\n if (!iconRef) return\n\n const className = Array.isArray(node.properties.className)\n ? node.properties.className.join(' ')\n : typeof node.properties.className === 'string'\n ? node.properties.className\n : 'pmd-icon'\n const resolved = resolvePayloadMarkdownIcon(iconRef, config.icons, className)\n\n for (const warning of resolved.warnings) file.message(warning)\n\n if (!parent || typeof index !== 'number') return\n\n parent.children.splice(index, 1, ...resolved.nodes)\n })\n }\n}\n"],"names":["visit","resolvePayloadMarkdownIcon","validatePayloadMarkdownIconsConfig","isElement","node","Boolean","type","getStringProperty","name","value","properties","trim","undefined","rehypeResolveIcons","config","tree","file","warning","icons","message","index","parent","tagName","iconRef","className","Array","isArray","join","resolved","warnings","children","splice","nodes"],"mappings":"AAGA,SAASA,KAAK,QAAQ,mBAAkB;AAIxC,SACEC,0BAA0B,EAC1BC,kCAAkC,QAC7B,yBAAwB;AAE/B,SAASC,UAAUC,IAAa;IAC9B,OAAOC,QACLD,QAAQ,OAAOA,SAAS,YAAY,UAAUA,QAAQ,AAACA,KAAiBE,IAAI,KAAK;AAErF;AAEA,SAASC,kBAAkBH,IAAa,EAAEI,IAAY;IACpD,MAAMC,QAAQL,KAAKM,UAAU,EAAE,CAACF,KAAK;IAErC,OAAO,OAAOC,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAKC;AACpE;AAEA,OAAO,MAAMC,qBAA4D,CACvEC,SAA+B,CAAC,CAAC;IAEjC,OAAO,CAACC,MAAMC;QACZ,KAAK,MAAMC,WAAWf,mCAAmCY,OAAOI,KAAK,EAAGF,KAAKG,OAAO,CAACF;QAErFjB,MAAMe,MAAM,WAAW,CAACX,MAAMgB,OAAOC;YACnC,IAAI,CAAClB,UAAUC,OAAO;YACtB,IAAIA,KAAKkB,OAAO,KAAK,QAAQ;YAE7B,MAAMC,UAAUhB,kBAAkBH,MAAM;YACxC,IAAI,CAACmB,SAAS;YAEd,MAAMC,YAAYC,MAAMC,OAAO,CAACtB,KAAKM,UAAU,CAACc,SAAS,IACrDpB,KAAKM,UAAU,CAACc,SAAS,CAACG,IAAI,CAAC,OAC/B,OAAOvB,KAAKM,UAAU,CAACc,SAAS,KAAK,WACnCpB,KAAKM,UAAU,CAACc,SAAS,GACzB;YACN,MAAMI,WAAW3B,2BAA2BsB,SAAST,OAAOI,KAAK,EAAEM;YAEnE,KAAK,MAAMP,WAAWW,SAASC,QAAQ,CAAEb,KAAKG,OAAO,CAACF;YAEtD,IAAI,CAACI,UAAU,OAAOD,UAAU,UAAU;YAE1CC,OAAOS,QAAQ,CAACC,MAAM,CAACX,OAAO,MAAMQ,SAASI,KAAK;QACpD;IACF;AACF,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Root } from 'mdast';
2
+ import type { Plugin } from 'unified';
3
+ import type { MarkdownRenderConfig } from '../../types/core.js';
4
+ export declare const remarkButtonDirectives: Plugin<[MarkdownRenderConfig?], Root>;