Update Monaco Editor Example (#13369)

Changed the URLs inside the Monaco Editor Example: https://github.com/zeit/next.js/tree/canary/examples/with-monaco-editor

Converted the worker URL to start with the base URL.

The reason is if you use the Monaco example anywhere but in the main `pages` folder, it won't work since it uses a relative URL instead.

For example if we'll move the code to `pages/room/index.js` it won't work since it will try to search for the files inside `room/_next/_static/` instead of `_next/_static/`.

The base URL I added fixes the problem.
This commit is contained in:
Daniel Paz 2020-05-26 01:22:28 +03:00 committed by GitHub
parent 2e1a322d6f
commit 599d6f71bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,12 +15,12 @@ function IndexPage() {
onChange={console.log}
editorDidMount={() => {
window.MonacoEnvironment.getWorkerUrl = (moduleId, label) => {
if (label === 'json') return '_next/static/json.worker.js'
if (label === 'css') return '_next/static/css.worker.js'
if (label === 'html') return '_next/static/html.worker.js'
if (label === 'json') return '/_next/static/json.worker.js'
if (label === 'css') return '/_next/static/css.worker.js'
if (label === 'html') return '/_next/static/html.worker.js'
if (label === 'typescript' || label === 'javascript')
return '_next/static/ts.worker.js'
return '_next/static/editor.worker.js'
return '/_next/static/ts.worker.js'
return '/_next/static/editor.worker.js'
}
}}
/>