Skip to content

Commit

Permalink
Load monaco-editor from the CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed May 1, 2024
1 parent 7931474 commit b6742fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"homepage": "https://github.com/open-formulieren/monaco-json-editor#readme",
"devDependencies": {
"@types/react": "^18.2.79",
"monaco-editor": "^0.48.0",
"prettier": "^3.2.5",
"typescript": "^5.4.5"
},
"dependencies": {
"@monaco-editor/react": "^4.6.0",
"monaco-editor": "^0.48.0"
"@monaco-editor/react": "^4.6.0"
},
"peerDependencies": {
"react": "^18.0.0"
Expand Down
8 changes: 5 additions & 3 deletions src/jsonEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as monaco from 'monaco-editor';
import {Editor, loader} from '@monaco-editor/react';
import type {EditorProps, OnChange, OnMount} from '@monaco-editor/react';

// This is required to *not* fetch the editor from CDNs:
loader.config({monaco});
// Loading from a CDN to avoid having to setup specific Webpack configuration
// which doesn't play well (especially with Storybook).
// See https://www.npmjs.com/package/@monaco-editor/loader#configure-the-loader-to-load-the-monaco-as-an-npm-package
// if we ever want to switch to the NPM module instead.
loader.config({paths: {vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.48.0/min/vs'}});

interface JSONEditorProps {
value?: any;
Expand Down

0 comments on commit b6742fd

Please sign in to comment.