@braincrew-lab/langchain-canvas 0.1.5 → 0.1.7

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 (2) hide show
  1. package/dist/index.js +14 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1522,6 +1522,11 @@ var TEMPLATES = {
1522
1522
  }
1523
1523
  };
1524
1524
  var SLIDE_W = 1280;
1525
+ var SCROLL_FIX = "<style>html,body{overflow:auto!important;height:auto!important;min-height:100%!important}</style>";
1526
+ function withScrollableBody(html) {
1527
+ const i = html.lastIndexOf("</body>");
1528
+ return i === -1 ? html + SCROLL_FIX : html.slice(0, i) + SCROLL_FIX + html.slice(i);
1529
+ }
1525
1530
  function useSlideFit(ratio, boxRef) {
1526
1531
  const [scale, setScale] = useState(1);
1527
1532
  const [rw, rh] = (ratio ?? "16:9").split(/[:x/]/).map(Number);
@@ -1530,7 +1535,11 @@ function useSlideFit(ratio, boxRef) {
1530
1535
  if (!ratio) return;
1531
1536
  const el = boxRef.current;
1532
1537
  if (!el) return;
1533
- const fit = () => setScale(Math.min(1, (el.clientWidth - 40) / SLIDE_W));
1538
+ const fit = () => {
1539
+ const w = el.clientWidth;
1540
+ if (w <= 40) return;
1541
+ setScale(Math.min(1, (w - 40) / SLIDE_W));
1542
+ };
1534
1543
  fit();
1535
1544
  const ro = new ResizeObserver(fit);
1536
1545
  ro.observe(el);
@@ -1552,12 +1561,14 @@ function HtmlRenderer({ artifact: artifact2 }) {
1552
1561
  const [mode, setMode] = useState("design");
1553
1562
  const lastSelfHtml = useRef(null);
1554
1563
  const srcDocRef = useRef("");
1564
+ const isFixedSlide = Boolean(artifact2.meta?.ratio);
1555
1565
  const srcDoc = useMemo(() => {
1556
1566
  if (mode === "design" && artifact2.data.html === lastSelfHtml.current) return srcDocRef.current;
1557
- srcDocRef.current = withInspector(artifact2.data.html);
1567
+ const base = withInspector(artifact2.data.html);
1568
+ srcDocRef.current = isFixedSlide ? base : withScrollableBody(base);
1558
1569
  lastSelfHtml.current = null;
1559
1570
  return srcDocRef.current;
1560
- }, [artifact2.data.html, mode]);
1571
+ }, [artifact2.data.html, mode, isFixedSlide]);
1561
1572
  const selected = selections.filter((s) => s.artifactId === artifact2.id);
1562
1573
  const single = selected.length === 1 ? selected[0] : null;
1563
1574
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braincrew-lab/langchain-canvas",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A live canvas for LangChain agents — stream documents, charts, and rich artifacts into a React panel.",
5
5
  "license": "MIT",
6
6
  "type": "module",