Public
Edited
Oct 14, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// import { CodeMirror } from "@andy0130tw/codemirror"
Insert cell
Insert cell
CodeMirror = require("https://unpkg.com/codemirror@5.32.0/lib/codemirror").then(
(CodeMirror) => {
// this is a bit tricky: we don't just require('codemirror') above, because
// the sparql mode requires a slightly different path (codemirror instead of codemirror.js)
// and we need the mode to modify the right instance
return require("https://unpkg.com/codemirror@5.32.0/mode/python/python.js").then(
() => CodeMirror
);
}
)
Insert cell
editor = {
while (div.firstChild) {
div.removeChild(div.firstChild);
}
let editor = CodeMirror(div, {
mode: "python",
lineNumbers: true, // Optional: add line numbers,
fontSize: 12 // Set the desired font size (in pixels)
});
editor.setValue(`def length_of_longest_substring(s):`);
editor.setSize(width - 20, 600);
return Generators.observe((change) => {
change(editor.getValue());
editor.on("change", (cm, val) => {
change(editor.getValue());
});
});
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more