| 195 | } |
| 196 | |
| 197 | function openMenu(editor, node) { |
| 198 | let menu = elt("div", {"class": "sandbox-open-menu"}) |
| 199 | let context = editor.state.facet(contextFacet) |
| 200 | function click(e) { |
| 201 | let target = e.target |
| 202 | if (e.target.parentNode == menu) { |
| 203 | for (let i = 0; i < menu.childNodes.length; ++i) |
| 204 | if (target == menu.childNodes[i]) |
| 205 | items[i][1]() |
| 206 | } |
| 207 | menu.parentNode.removeChild(menu) |
| 208 | window.removeEventListener("click", click) |
| 209 | } |
| 210 | setTimeout(() => window.addEventListener("click", click), 20) |
| 211 | node.offsetParent.appendChild(menu) |
| 212 | } |
| 213 | |
| 214 | function runCode(editor) { |
| 215 | let context = editor.state.facet(contextFacet) |