I got a notebook where when clicking on a specific element in the graph it is supposed to open a new tab with a calculated url. Works fine in the notebook. When embedding this notebook in a react app on a SAAS platform, I run into the issue that the SAAS platform does not allow this behaviour directly with the browser, but offers their own function.
I followed the example of overriding a cell value without the desired result.
The function in the nodebook looks something like this:
searchInGoogle = (word) => {
let tab = window
.open(
`https://google.com/search/q?${word}`,
word,
"width=400,height=250"
)
.focus();
}
And the react code looks something like this:
import React, {useRef, useEffect} from "react";
import {Runtime, Inspector} from "@observablehq/runtime";
import notebook from "@user/wordmap";
function WordMap() {
const mapRef = useRef();
const alternativeFunction = (word) => {
console.log("Catched the event of clicking on :"+word);
}
useEffect(() => {
const runtime = new Runtime();
const module = runtime.module(notebook, name => {
if (name === "map") return new Inspector(mapRef.current);
});
module.redefine("searchInGoogle", alternativeFunction);
return () => runtime.dispose();
}, []);
return (
<>
<div ref={mapRef} />
</>
);
}
export default FlowExplorer;
What am I missing?