@changerawr/markdown 1.1.3 → 1.1.4
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/dist/css/index.css +123 -3
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +33 -4
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +33 -4
- package/dist/react/index.mjs.map +1 -1
- package/dist/standalone.browser.js +32 -6
- package/dist/standalone.d.mts +1 -0
- package/dist/standalone.d.ts +1 -0
- package/dist/standalone.js +33 -4
- package/dist/standalone.js.map +1 -1
- package/dist/standalone.mjs +33 -4
- package/dist/standalone.mjs.map +1 -1
- package/dist/tailwind/index.d.mts +35 -4
- package/dist/tailwind/index.d.ts +35 -4
- package/dist/tailwind/index.js +185 -120
- package/dist/tailwind/index.js.map +1 -1
- package/dist/tailwind/index.mjs +183 -119
- package/dist/tailwind/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/css/index.css
CHANGED
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
@layer components {
|
|
84
|
-
/* Alert components */
|
|
84
|
+
/* Alert components - all 6 types */
|
|
85
85
|
.changerawr-alert {
|
|
86
86
|
@apply border-l-4 p-4 mb-4 rounded-md transition-all duration-200;
|
|
87
87
|
}
|
|
@@ -114,7 +114,21 @@
|
|
|
114
114
|
border-left-color: #10b981;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
.changerawr-alert-tip {
|
|
118
|
+
background-color: color-mix(in srgb, #a855f7 10%, transparent);
|
|
119
|
+
border-color: color-mix(in srgb, #a855f7 30%, transparent);
|
|
120
|
+
color: #a855f7;
|
|
121
|
+
border-left-color: #a855f7;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.changerawr-alert-note {
|
|
125
|
+
background-color: color-mix(in srgb, #6b7280 10%, transparent);
|
|
126
|
+
border-color: color-mix(in srgb, #6b7280 30%, transparent);
|
|
127
|
+
color: #6b7280;
|
|
128
|
+
border-left-color: #6b7280;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Button base component */
|
|
118
132
|
.changerawr-button {
|
|
119
133
|
@apply inline-flex items-center justify-center px-4 py-2 rounded-lg transition-all duration-200 cursor-pointer;
|
|
120
134
|
border: 1px solid transparent;
|
|
@@ -122,13 +136,109 @@
|
|
|
122
136
|
text-decoration: none;
|
|
123
137
|
}
|
|
124
138
|
|
|
139
|
+
/* Button style variants - all 7 types */
|
|
140
|
+
.changerawr-button-default {
|
|
141
|
+
background-color: #475569;
|
|
142
|
+
color: white;
|
|
143
|
+
border-color: #64748b;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.changerawr-button-default:hover:not(:disabled) {
|
|
147
|
+
background-color: #334155;
|
|
148
|
+
border-color: #94a3b8;
|
|
149
|
+
}
|
|
150
|
+
|
|
125
151
|
.changerawr-button-primary {
|
|
126
152
|
background-color: #3b82f6;
|
|
127
153
|
color: white;
|
|
154
|
+
border-color: #60a5fa;
|
|
128
155
|
}
|
|
129
156
|
|
|
130
157
|
.changerawr-button-primary:hover:not(:disabled) {
|
|
131
|
-
background-color:
|
|
158
|
+
background-color: #2563eb;
|
|
159
|
+
border-color: #93c5fd;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.changerawr-button-secondary {
|
|
163
|
+
background-color: #4b5563;
|
|
164
|
+
color: white;
|
|
165
|
+
border-color: #6b7280;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.changerawr-button-secondary:hover:not(:disabled) {
|
|
169
|
+
background-color: #374151;
|
|
170
|
+
border-color: #9ca3af;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.changerawr-button-success {
|
|
174
|
+
background-color: #059669;
|
|
175
|
+
color: white;
|
|
176
|
+
border-color: #10b981;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.changerawr-button-success:hover:not(:disabled) {
|
|
180
|
+
background-color: #047857;
|
|
181
|
+
border-color: #34d399;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.changerawr-button-danger {
|
|
185
|
+
background-color: #dc2626;
|
|
186
|
+
color: white;
|
|
187
|
+
border-color: #ef4444;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.changerawr-button-danger:hover:not(:disabled) {
|
|
191
|
+
background-color: #b91c1c;
|
|
192
|
+
border-color: #f87171;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.changerawr-button-outline {
|
|
196
|
+
background-color: transparent;
|
|
197
|
+
color: #3b82f6;
|
|
198
|
+
border-color: #3b82f6;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.changerawr-button-outline:hover:not(:disabled) {
|
|
202
|
+
background-color: #eff6ff;
|
|
203
|
+
border-color: #1d4ed8;
|
|
204
|
+
color: #1d4ed8;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.changerawr-button-ghost {
|
|
208
|
+
background-color: transparent;
|
|
209
|
+
color: #374151;
|
|
210
|
+
border-color: transparent;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.changerawr-button-ghost:hover:not(:disabled) {
|
|
214
|
+
background-color: #f3f4f6;
|
|
215
|
+
color: #111827;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Button size variants */
|
|
219
|
+
.changerawr-button-sm {
|
|
220
|
+
padding: 0.375rem 0.75rem;
|
|
221
|
+
font-size: 0.875rem;
|
|
222
|
+
gap: 0.375rem;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.changerawr-button-md {
|
|
226
|
+
padding: 0.5rem 1rem;
|
|
227
|
+
font-size: 1rem;
|
|
228
|
+
gap: 0.5rem;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.changerawr-button-lg {
|
|
232
|
+
padding: 0.75rem 1.5rem;
|
|
233
|
+
font-size: 1.125rem;
|
|
234
|
+
gap: 0.625rem;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* Button disabled state */
|
|
238
|
+
.changerawr-button:disabled {
|
|
239
|
+
opacity: 0.5;
|
|
240
|
+
cursor: not-allowed;
|
|
241
|
+
pointer-events: none;
|
|
132
242
|
}
|
|
133
243
|
}
|
|
134
244
|
|
|
@@ -153,4 +263,14 @@
|
|
|
153
263
|
color: #34d399;
|
|
154
264
|
background-color: color-mix(in srgb, #10b981 20%, transparent);
|
|
155
265
|
}
|
|
266
|
+
|
|
267
|
+
.changerawr-alert-tip {
|
|
268
|
+
color: #c084fc;
|
|
269
|
+
background-color: color-mix(in srgb, #a855f7 20%, transparent);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.changerawr-alert-note {
|
|
273
|
+
color: #9ca3af;
|
|
274
|
+
background-color: color-mix(in srgb, #6b7280 20%, transparent);
|
|
275
|
+
}
|
|
156
276
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ interface MarkdownToken {
|
|
|
3
3
|
content: string;
|
|
4
4
|
raw: string;
|
|
5
5
|
attributes?: Record<string, string>;
|
|
6
|
+
children?: MarkdownToken[];
|
|
6
7
|
}
|
|
7
8
|
interface ParseRule {
|
|
8
9
|
name: string;
|
|
@@ -384,6 +385,7 @@ declare class MarkdownParser {
|
|
|
384
385
|
private preprocessMarkdown;
|
|
385
386
|
private validateMarkdown;
|
|
386
387
|
private postProcessTokens;
|
|
388
|
+
private recursivelyParseBlockContent;
|
|
387
389
|
}
|
|
388
390
|
|
|
389
391
|
declare class MarkdownRenderer {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ interface MarkdownToken {
|
|
|
3
3
|
content: string;
|
|
4
4
|
raw: string;
|
|
5
5
|
attributes?: Record<string, string>;
|
|
6
|
+
children?: MarkdownToken[];
|
|
6
7
|
}
|
|
7
8
|
interface ParseRule {
|
|
8
9
|
name: string;
|
|
@@ -384,6 +385,7 @@ declare class MarkdownParser {
|
|
|
384
385
|
private preprocessMarkdown;
|
|
385
386
|
private validateMarkdown;
|
|
386
387
|
private postProcessTokens;
|
|
388
|
+
private recursivelyParseBlockContent;
|
|
387
389
|
}
|
|
388
390
|
|
|
389
391
|
declare class MarkdownRenderer {
|
package/dist/index.js
CHANGED
|
@@ -295,7 +295,8 @@ var MarkdownParser = class {
|
|
|
295
295
|
}
|
|
296
296
|
i = j;
|
|
297
297
|
} else if (token) {
|
|
298
|
-
|
|
298
|
+
const processedToken = this.recursivelyParseBlockContent(token);
|
|
299
|
+
processed.push(processedToken);
|
|
299
300
|
i++;
|
|
300
301
|
} else {
|
|
301
302
|
i++;
|
|
@@ -303,6 +304,17 @@ var MarkdownParser = class {
|
|
|
303
304
|
}
|
|
304
305
|
return processed;
|
|
305
306
|
}
|
|
307
|
+
recursivelyParseBlockContent(token) {
|
|
308
|
+
const blockTypes = ["alert", "blockquote"];
|
|
309
|
+
if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
|
|
310
|
+
const children = this.parse(token.content);
|
|
311
|
+
return {
|
|
312
|
+
...token,
|
|
313
|
+
children
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
return token;
|
|
317
|
+
}
|
|
306
318
|
};
|
|
307
319
|
|
|
308
320
|
// src/utils.ts
|
|
@@ -648,7 +660,19 @@ var MarkdownRenderer = class {
|
|
|
648
660
|
const rule = this.rules.get(token.type);
|
|
649
661
|
if (rule) {
|
|
650
662
|
try {
|
|
651
|
-
|
|
663
|
+
let tokenToRender = token;
|
|
664
|
+
if (token.children && token.children.length > 0) {
|
|
665
|
+
const renderedChildren = this.render(token.children);
|
|
666
|
+
tokenToRender = {
|
|
667
|
+
...token,
|
|
668
|
+
attributes: {
|
|
669
|
+
...token.attributes,
|
|
670
|
+
renderedChildren
|
|
671
|
+
// Extensions can use this instead of re-parsing
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
return rule.render(tokenToRender);
|
|
652
676
|
} catch (error) {
|
|
653
677
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
654
678
|
this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
|
|
@@ -717,8 +741,10 @@ var BlockquoteExtension = {
|
|
|
717
741
|
{
|
|
718
742
|
type: "blockquote",
|
|
719
743
|
render: (token) => {
|
|
720
|
-
const content = escapeHtml(token.content);
|
|
721
744
|
const format = token.attributes?.format || "html";
|
|
745
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
746
|
+
const renderMarkdown2 = token.attributes?.renderMarkdown;
|
|
747
|
+
const content = renderedChildren || (renderMarkdown2 ? renderMarkdown2(token.content) : escapeHtml(token.content));
|
|
722
748
|
if (format === "html") {
|
|
723
749
|
return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
|
|
724
750
|
}
|
|
@@ -1223,6 +1249,9 @@ var AlertExtension = {
|
|
|
1223
1249
|
const config = typeConfig[type] || typeConfig.info;
|
|
1224
1250
|
const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
|
|
1225
1251
|
const classes = `${baseClasses} ${config?.classes}`;
|
|
1252
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
1253
|
+
const renderMarkdown2 = token.attributes?.renderMarkdown;
|
|
1254
|
+
const renderedContent = renderedChildren || (renderMarkdown2 ? renderMarkdown2(token.content) : token.content);
|
|
1226
1255
|
const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
|
|
1227
1256
|
<span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
|
|
1228
1257
|
<span>${title}</span>
|
|
@@ -1232,7 +1261,7 @@ var AlertExtension = {
|
|
|
1232
1261
|
</div>`;
|
|
1233
1262
|
return `<div class="${classes}" role="alert" aria-live="polite">
|
|
1234
1263
|
${titleHtml}
|
|
1235
|
-
<div class="leading-relaxed">${
|
|
1264
|
+
<div class="leading-relaxed">${renderedContent}</div>
|
|
1236
1265
|
</div>`;
|
|
1237
1266
|
}
|
|
1238
1267
|
}
|