Closed chengtie closed 1 year ago
Hi @chengtie. The first issue I've noticed is that you use different monaco
instances in App.js
and language-feature.ts
. @monaco-editor/react
doesn't use monaco
instance from monaco-editor
package by default. Instead, it downloads the instance from CDN. To change that behavior check this.
Hi @chengtie. The first issue I've noticed is that you use different
monaco
instances inApp.js
andlanguage-feature.ts
.@monaco-editor/react
doesn't usemonaco
instance frommonaco-editor
package by default. Instead, it downloads the instance from CDN. To change that behavior check this.
Thank you for the help.
I now pass monaco
instance from App.js to DiagnosticsAdapter when constructing a DiagnosticsAdapter. It works.
Here is a working CodeSandbox: https://codesandbox.io/s/vibrant-sun-gzl8nh.
You could close the issue. Cheers.
I have a web application containing a Monaco Editor. Previously, I used react-monaco-editor, now for some reasons, I'm thinking of switching to @monaco-editor/react.
With react-monaco-editor, I was able to code a
DiagnosticsAdapter
class to provide real-time error checking and suggestions in a code editor. When a user types code into the editor, the adapter will validate the code and provide feedback on any issues it finds.Now, with @monaco-editor/react, the
DiagnosticsAdapter
does not work anymore: code inonModelAdd
and code inonModelRemoved
is never executed.Does anyone know how to set up these listeners for @monaco-editor/react and make
DiagnosticsAdapter
work?Here is CodeSandBox: https://codesandbox.io/s/aged-voice-5rz8z2?file=/src/App.js:0-542
Here is
language-feature.ts
:Here is
App.js
: