Skip to content

Commit ca186f0

Browse files
committed
fix #5258 -- jupyter: ipywidgets/Output markdown links aren't processed properly to work with cocalc
- this will potentially automatically fix anything else that might use certain context info when rendering in an output widget, so that's a bonus. I.e., this is the "right" fix.
1 parent 3991dc6 commit ca186f0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/packages/frontend/jupyter/widgets/manager.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import ReactDOM from "react-dom/client";
2525
import type { JupyterActions } from "@cocalc/frontend/jupyter/browser-actions";
2626
import { FileContext } from "@cocalc/frontend/lib/file-context";
2727
import { FrameContext } from "@cocalc/frontend/frame-editors/frame-tree/frame-context";
28+
import getAnchorTagComponent from "@cocalc/frontend/project/page/anchor-tag-component";
2829

2930
import { delay } from "awaiting";
3031

@@ -715,7 +716,7 @@ class Environment implements WidgetEnvironment {
715716
const myDiv = document.createElement("div");
716717
destination.appendChild(myDiv);
717718
const { actions } = this.manager;
718-
const { project_id } = actions;
719+
const { project_id, path } = actions;
719720
// NOTE: we are NOT caching iframes here, so iframes in output
720721
// widgets will refresh if you scroll them off the screen and back.
721722
const trust = actions.store.get("trust");
@@ -725,12 +726,18 @@ class Environment implements WidgetEnvironment {
725726
// @ts-ignore -- we aren't filling in all the standard stuff
726727
// also we just always put isVisible true, since the output widget itself
727728
// (which has proper context) gets not rendered and that contains this.
728-
value: { isVisible: true },
729+
value: { isVisible: true, project_id, path },
729730
},
730731
React.createElement(
731732
FileContext.Provider,
732733
{
733-
value: { noSanitize: trust, project_id },
734+
value: {
735+
noSanitize: trust,
736+
project_id,
737+
path,
738+
// see https://github.com/sagemathinc/cocalc/issues/5258
739+
AnchorTagComponent: getAnchorTagComponent({ project_id, path }),
740+
},
734741
},
735742
React.createElement(
736743
CellOutputMessage,

0 commit comments

Comments
 (0)