MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / runCode

Function runCode

src/client/ejs.mjs:214–232  ·  view source on GitHub ↗
(editor)

Source from the content-addressed store, hash-verified

212 }
213
214 function runCode(editor) {
215 let context = editor.state.facet(contextFacet)
216 context.output.clear()
217 let val = editor.state.doc.toString()
218 getSandbox(context.sandbox, context.isHTML).then(box => {
219 if (context.isHTML)
220 box.setHTML(val, context.output).then(() => {
221 if (context.orig.getAttribute("data-focus")) {
222 box.win.focus()
223 box.win.document.body.focus()
224 }
225 })
226 else
227 box.run(val, context.output).then(value => {
228 if (value != null && context.meta && /\bexpr\b/.test(context.meta) && context.output.empty)
229 box.out("log", [value])
230 })
231 })
232 }
233
234 function closeCode(editor) {
235 let context = editor.state.facet(contextFacet)

Callers 2

runFunction · 0.85
showEditorControlsFunction · 0.85

Calls 5

getSandboxFunction · 0.85
clearMethod · 0.80
setHTMLMethod · 0.80
runMethod · 0.80
outMethod · 0.45

Tested by

no test coverage detected