@akropolys/kiku 1.4.0 → 1.5.1
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/index.js +47 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +14 -0
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -170,7 +170,7 @@ import { useKiku } from "@akropolys/sdk";
|
|
|
170
170
|
// src/utils/markdown.tsx
|
|
171
171
|
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
172
172
|
var parseInline = (text, keyPrefix) => {
|
|
173
|
-
const tokenRegex = /(\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
173
|
+
const tokenRegex = /(!\[[^\]]*\]\([^)]+\)|\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
174
174
|
const parts = text.split(tokenRegex);
|
|
175
175
|
return parts.map((part, index) => {
|
|
176
176
|
if (!part) return null;
|
|
@@ -181,6 +181,28 @@ var parseInline = (text, keyPrefix) => {
|
|
|
181
181
|
if (part.startsWith("**") && part.endsWith("**")) {
|
|
182
182
|
return /* @__PURE__ */ jsx2("strong", { children: parseInline(part.slice(2, -2), key) }, key);
|
|
183
183
|
}
|
|
184
|
+
const imageMatch = part.match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
|
|
185
|
+
if (imageMatch) {
|
|
186
|
+
const alt = imageMatch[1];
|
|
187
|
+
const url = imageMatch[2];
|
|
188
|
+
const isSafeUrl = /^(https?|data:image):/i.test(url);
|
|
189
|
+
if (isSafeUrl) {
|
|
190
|
+
return /* @__PURE__ */ jsx2(
|
|
191
|
+
"img",
|
|
192
|
+
{
|
|
193
|
+
src: url,
|
|
194
|
+
alt: alt || "Product image",
|
|
195
|
+
className: "hsk-markdown-img",
|
|
196
|
+
loading: "lazy",
|
|
197
|
+
onError: (e) => {
|
|
198
|
+
e.target.style.display = "none";
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
key
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
184
206
|
const linkMatch = part.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
185
207
|
if (linkMatch) {
|
|
186
208
|
const url = linkMatch[2];
|
|
@@ -204,6 +226,30 @@ function renderMarkdown(content) {
|
|
|
204
226
|
i++;
|
|
205
227
|
continue;
|
|
206
228
|
}
|
|
229
|
+
const standaloneImageMatch = line.trim().match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
|
|
230
|
+
if (standaloneImageMatch) {
|
|
231
|
+
const alt = standaloneImageMatch[1];
|
|
232
|
+
const url = standaloneImageMatch[2];
|
|
233
|
+
const isSafeUrl = /^(https?|data:image):/i.test(url);
|
|
234
|
+
if (isSafeUrl) {
|
|
235
|
+
elements.push(
|
|
236
|
+
/* @__PURE__ */ jsx2("div", { className: "hsk-markdown-img-block", children: /* @__PURE__ */ jsx2(
|
|
237
|
+
"img",
|
|
238
|
+
{
|
|
239
|
+
src: url,
|
|
240
|
+
alt: alt || "Product image",
|
|
241
|
+
className: "hsk-markdown-img",
|
|
242
|
+
loading: "lazy",
|
|
243
|
+
onError: (e) => {
|
|
244
|
+
e.target.style.display = "none";
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
) }, key)
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
i++;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
207
253
|
const headerMatch = line.match(/^(#{1,3})\s+(.*)/);
|
|
208
254
|
if (headerMatch) {
|
|
209
255
|
const level = headerMatch[1].length;
|