@cube-drone/marquee-react-renderer 0.9.2 → 0.9.3

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/render.js CHANGED
@@ -182,7 +182,7 @@ export function renderNode(node, ctx, key) {
182
182
  case "link": {
183
183
  const inner = renderChildren(node.children, ctx);
184
184
  return ctx.profile.linkAllowed(node.target)
185
- ? h("a", nodeProps(node, ctx, { key, href: node.target }), ...inner)
185
+ ? h("a", nodeProps(node, ctx, { key, href: href(node.target, ctx) }), ...inner)
186
186
  : h("span", nodeProps(node, ctx, { key, className: "mq-blocked" }), ...inner);
187
187
  }
188
188
  case "embed":
@@ -261,6 +261,10 @@ function embed(node, ctx, key) {
261
261
  return h("video", nodeProps(node, ctx, { ...common, ...label, src: media.url, controls: true }));
262
262
  }
263
263
  const TURBOLINK_LEVELS = new Set(["full", "title", "bare"]);
264
+ /** Where an allowed link points: the profile's rewrite, or the target. */
265
+ function href(target, ctx) {
266
+ return ctx.profile.linkTarget?.(target) ?? target;
267
+ }
264
268
  function turbolink(node, target, levelAttr, ctx, key) {
265
269
  if (!ctx.profile.linkAllowed(target)) {
266
270
  return h("p", nodeProps(node, ctx, { key, className: "mq-turbolink" }), target);
@@ -274,10 +278,10 @@ function turbolink(node, target, levelAttr, ctx, key) {
274
278
  if (react !== null || html !== null) {
275
279
  // Enrichment augments, never replaces: the wrapper carries the
276
280
  // original link, so no plugin can eat it - not even by accident.
277
- return h("div", nodeProps(node, ctx, { key, className: "mq-turbolink mq-turbolink-rich" }), react ?? trustedHtml("span", html, "rich"), h("a", { key: "src", className: "mq-turbolink-source", href: target }, target));
281
+ return h("div", nodeProps(node, ctx, { key, className: "mq-turbolink mq-turbolink-rich" }), react ?? trustedHtml("span", html, "rich"), h("a", { key: "src", className: "mq-turbolink-source", href: href(target, ctx) }, target));
278
282
  }
279
283
  }
280
- return h("p", nodeProps(node, ctx, { key, className: "mq-turbolink" }), h("a", { href: target }, target));
284
+ return h("p", nodeProps(node, ctx, { key, className: "mq-turbolink" }), h("a", { href: href(target, ctx) }, target));
281
285
  }
282
286
  function directive(node, ctx, key) {
283
287
  const { name, attrs } = node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cube-drone/marquee-react-renderer",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Interactive React renderer for the Marquee markup language: the JS halves of the animation contract (start-on-visible, tap-to-skip) plus source-position scroll sync for side-by-side editors",
5
5
  "license": "MPL-2.0",
6
6
  "repository": {
@@ -34,8 +34,8 @@
34
34
  "demo": "node --conditions=marquee-src scripts/demo.ts"
35
35
  },
36
36
  "dependencies": {
37
- "@cube-drone/marquee-html-renderer": "^0.9.2",
38
- "@cube-drone/marquee-parser": "^0.9.2"
37
+ "@cube-drone/marquee-html-renderer": "^0.9.3",
38
+ "@cube-drone/marquee-parser": "^0.9.3"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=18"
@@ -48,9 +48,9 @@
48
48
  "react": "^19.0.0",
49
49
  "react-dom": "^19.0.0",
50
50
  "typescript": "^5.9.0",
51
- "@cube-drone/marquee-css": "^0.9.2",
52
- "@cube-drone/marquee-fonts": "^0.9.2",
53
- "@cube-drone/marquee-emoji": "^0.9.2",
54
- "@cube-drone/marquee-turbolink": "^0.9.2"
51
+ "@cube-drone/marquee-css": "^0.9.3",
52
+ "@cube-drone/marquee-fonts": "^0.9.3",
53
+ "@cube-drone/marquee-emoji": "^0.9.3",
54
+ "@cube-drone/marquee-turbolink": "^0.9.3"
55
55
  }
56
56
  }
package/src/render.ts CHANGED
@@ -254,7 +254,7 @@ export function renderNode(node: Node, ctx: Ctx, key: string): ReactNode {
254
254
  case "link": {
255
255
  const inner = renderChildren(node.children, ctx);
256
256
  return ctx.profile.linkAllowed(node.target)
257
- ? h("a", nodeProps(node, ctx, { key, href: node.target }), ...inner)
257
+ ? h("a", nodeProps(node, ctx, { key, href: href(node.target, ctx) }), ...inner)
258
258
  : h("span", nodeProps(node, ctx, { key, className: "mq-blocked" }), ...inner);
259
259
  }
260
260
  case "embed":
@@ -353,6 +353,11 @@ function embed(node: Node & { type: "embed" }, ctx: Ctx, key: string): ReactNode
353
353
 
354
354
  const TURBOLINK_LEVELS = new Set<TurbolinkLevel>(["full", "title", "bare"]);
355
355
 
356
+ /** Where an allowed link points: the profile's rewrite, or the target. */
357
+ function href(target: string, ctx: Ctx): string {
358
+ return ctx.profile.linkTarget?.(target) ?? target;
359
+ }
360
+
356
361
  function turbolink(
357
362
  node: Node,
358
363
  target: string,
@@ -377,14 +382,14 @@ function turbolink(
377
382
  "div",
378
383
  nodeProps(node, ctx, { key, className: "mq-turbolink mq-turbolink-rich" }),
379
384
  react ?? trustedHtml("span", html!, "rich"),
380
- h("a", { key: "src", className: "mq-turbolink-source", href: target }, target),
385
+ h("a", { key: "src", className: "mq-turbolink-source", href: href(target, ctx) }, target),
381
386
  );
382
387
  }
383
388
  }
384
389
  return h(
385
390
  "p",
386
391
  nodeProps(node, ctx, { key, className: "mq-turbolink" }),
387
- h("a", { href: target }, target),
392
+ h("a", { href: href(target, ctx) }, target),
388
393
  );
389
394
  }
390
395