Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions imports/editor/editor-textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useColorMode } from '@chakra-ui/react';
import dynamic from 'next/dynamic';
import React from 'react';
import _ from 'lodash';
import { AutoTypings, LocalStorageCache } from "monaco-editor-auto-typings/custom-editor";
import { OnMount } from '@monaco-editor/react';

const MonacoEditor = dynamic(() => import('@monaco-editor/react').then(m => m.default), { ssr: false });
Expand Down Expand Up @@ -52,6 +53,25 @@ export const EditorTextArea = React.memo<any>(({
onExit && onExit();
});
onMount && onMount(editor, monaco);

monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ESNext,
allowNonTsExtensions: true,
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
module: monaco.languages.typescript.ModuleKind.ESNext,
noEmit: true,
typeRoots: ["node_modules/@types"]
})

monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false,
})

const autoTypings = AutoTypings.create(editor, {
sourceCache: new LocalStorageCache(), // Cache loaded sources in localStorage. May be omitted
monaco: monaco,
});
}

return (<MonacoEditor
Expand All @@ -62,6 +82,7 @@ export const EditorTextArea = React.memo<any>(({
},
// @ts-ignore
lineNumbers: lineNumbers,

}}
height="100%"
width="100%"
Expand Down
17 changes: 13 additions & 4 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
"jsonwebtoken": "^9.0.0",
"leven-sort": "^4.0.0",
"markup-it": "^13.0.0",
"monaco-editor": "^0.40.0",
"monaco-editor-auto-typings": "^0.4.4",
"next": "13.3",
"next-env": "^1.1.1",
"normalize.css": "^8.0.1",
Expand Down