Skip to content
Snippets Groups Projects
Commit 673eac03 authored by Max Guichard's avatar Max Guichard
Browse files

Read-only cell tag

parent ab1ed1af
No related branches found
No related tags found
No related merge requests found
Pipeline #225592 passed
......@@ -499,6 +499,7 @@ parts:
- file: cookbook/benchmarks/benchmark_load.ipynb
- file: cookbook/benchmarks/benchmark_noexec.ipynb
- file: cookbook/benchmarks/benchmark_figures.ipynb
- file: cookbook/benchmarks/benchmark_readonly.ipynb
# Coding
- caption: Coding (Last Year)
......
%% Cell type:markdown id: tags:
# Benchmarks: read only
This page includes benchmarks for the read-only tag. This tag allows you to make code cells read only.
%% Cell type:code id: tags:read-only
``` python
print("You can run me, but you can't touch me!")
```
......@@ -386,6 +386,15 @@ function setupSpecialTaggedElements() {
break;
}
case "read-only": {
const codemirror = taggedElement.element.querySelector(".CodeMirror");
codemirror.style.filter = "brightness(90%)";
const textarea = taggedElement.element.querySelector("textarea");
textarea.setAttribute("disabled", "true");
break;
}
default: {
console.error(`Unrecognized special tag: ${taggedElement.tag}`);
}
......@@ -424,6 +433,8 @@ var initThebe = async () => {
modifyDOMForThebe();
await thebelab.bootstrap(thebeLiteConfig);
setupSpecialTaggedElements();
document.querySelectorAll(".keep").forEach((kept, _) => {
//console.log(Object.valueskept.previousClasses);
Object.values(kept.previousClasses).forEach((clas, _) =>
......@@ -468,7 +479,6 @@ var initThebe = async () => {
code: `import ipykernel; ipykernel.version_info = (0,0); import micropip; await micropip.install("ipywidgets")`,
}).done;
updateThebeButtonStatus("Running pre-intialized cells...");
setupSpecialTaggedElements();
await runInitCells();
......@@ -498,6 +508,13 @@ function handleThebeRemoveInputTag(element) {
element.classList.add("tag_thebe-init");
}
function handleReadOnlyTag(element) {
window.specialTaggedElements.push({
tag: "read-only",
element: element
});
}
function handleDisableExecutionTag(element) {
$(".dropdown-launch-buttons").remove();
}
......@@ -545,6 +562,7 @@ function consumeSpecialTags() {
{ tag: "auto-execute-page", handler: handleAutoExecuteTag },
{ tag: "disable-execution-cell", handler: handleDisableExecutionCellTag },
{ tag: "thebe-remove-input-init", handler: handleThebeRemoveInputTag },
{ tag: "read-only", handler: handleReadOnlyTag }
];
window.specialTaggedElements = [];
......@@ -572,3 +590,4 @@ Promise.all(styleLoading).then(() => {
});
}
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment