Skip to content

Commit

Permalink
Fix WebR chunks not working with Safari browser #21 by re-arranging t…
Browse files Browse the repository at this point in the history
…he load steps for MonacoEditor

The `loader.js` and `require.config()` initialization is set to happen at the top of the document's <body> instead of the <head>.
  • Loading branch information
coatless committed Sep 14, 2023
1 parent d51fbd5 commit 46314aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 10 additions & 0 deletions _extensions/webr/monaco-editor-init.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script src="https://cdn.jsdelivr.net/npm/[email protected]/min/vs/loader.js"></script>
<script type="module">

// Configure the Monaco Editor's loader
require.config({
paths: {
'vs': 'https://cdn.jsdelivr.net/npm/[email protected]/min/vs'
}
});
</script>
1 change: 1 addition & 0 deletions _extensions/webr/webr-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
// Add a keydown event listener for Shift+Enter using the addCommand method
editor.addCommand(monaco.KeyMod.Shift | monaco.KeyCode.Enter, function () {
// Code to run when Shift+Enter is pressed
console.log(editor.getValue().length)
executeCode(editor.getValue());
});

Expand Down
8 changes: 0 additions & 8 deletions _extensions/webr/webr-init.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,8 @@
}
</style>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/min/vs/loader.js"></script>
<script type="module">

// Configure the Monaco Editor's loader
require.config({
paths: {
'vs': 'https://cdn.jsdelivr.net/npm/[email protected]/min/vs'
}
});

// Start a timer
const initializeWebRTimerStart = performance.now();

Expand Down
3 changes: 3 additions & 0 deletions _extensions/webr/webr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ function ensureWebRSetup()
-- https://quarto.org/docs/extensions/lua-api.html#includes
quarto.doc.include_text("in-header", initializedConfigurationWebR)

-- Insert the monaco editor initialization
quarto.doc.include_file("before-body", "monaco-editor-init.html")

-- Copy the two web workers into the directory
-- https://quarto.org/docs/extensions/lua-api.html#dependencies

Expand Down

0 comments on commit 46314aa

Please sign in to comment.