@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 CHANGED
@@ -205,7 +205,7 @@ var import_sdk3 = require("@akropolys/sdk");
205
205
  // src/utils/markdown.tsx
206
206
  var import_jsx_runtime2 = require("react/jsx-runtime");
207
207
  var parseInline = (text, keyPrefix) => {
208
- const tokenRegex = /(\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|`[^`]+`)/g;
208
+ const tokenRegex = /(!\[[^\]]*\]\([^)]+\)|\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|`[^`]+`)/g;
209
209
  const parts = text.split(tokenRegex);
210
210
  return parts.map((part, index) => {
211
211
  if (!part) return null;
@@ -216,6 +216,28 @@ var parseInline = (text, keyPrefix) => {
216
216
  if (part.startsWith("**") && part.endsWith("**")) {
217
217
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: parseInline(part.slice(2, -2), key) }, key);
218
218
  }
219
+ const imageMatch = part.match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
220
+ if (imageMatch) {
221
+ const alt = imageMatch[1];
222
+ const url = imageMatch[2];
223
+ const isSafeUrl = /^(https?|data:image):/i.test(url);
224
+ if (isSafeUrl) {
225
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
226
+ "img",
227
+ {
228
+ src: url,
229
+ alt: alt || "Product image",
230
+ className: "hsk-markdown-img",
231
+ loading: "lazy",
232
+ onError: (e) => {
233
+ e.target.style.display = "none";
234
+ }
235
+ },
236
+ key
237
+ );
238
+ }
239
+ return null;
240
+ }
219
241
  const linkMatch = part.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
220
242
  if (linkMatch) {
221
243
  const url = linkMatch[2];
@@ -239,6 +261,30 @@ function renderMarkdown(content) {
239
261
  i++;
240
262
  continue;
241
263
  }
264
+ const standaloneImageMatch = line.trim().match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
265
+ if (standaloneImageMatch) {
266
+ const alt = standaloneImageMatch[1];
267
+ const url = standaloneImageMatch[2];
268
+ const isSafeUrl = /^(https?|data:image):/i.test(url);
269
+ if (isSafeUrl) {
270
+ elements.push(
271
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "hsk-markdown-img-block", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
272
+ "img",
273
+ {
274
+ src: url,
275
+ alt: alt || "Product image",
276
+ className: "hsk-markdown-img",
277
+ loading: "lazy",
278
+ onError: (e) => {
279
+ e.target.style.display = "none";
280
+ }
281
+ }
282
+ ) }, key)
283
+ );
284
+ }
285
+ i++;
286
+ continue;
287
+ }
242
288
  const headerMatch = line.match(/^(#{1,3})\s+(.*)/);
243
289
  if (headerMatch) {
244
290
  const level = headerMatch[1].length;