scniro / react-codemirror2

Codemirror integrated components for React
MIT License
1.65k stars 192 forks source link

Any example for using js-yaml to enable linting for yaml content? #236

Open mkamrani opened 3 years ago

mkamrani commented 3 years ago

I've been struggling with how to make js-yaml to work with my Codemirror component but no luck so far:

// const jsyaml = require("js-yaml"); // import * as jsyaml from "js-yaml"; window.jsyaml=jsyaml;

none of the two ways mentioned above to import the package work and I get the error jsyaml.loadAll is not a function which shows it's not imported correctly, would appreciate any help.

royhadad commented 2 years ago

I have looked at the entire internet and couldn't find an example, finally, managed to make it work, here is the the example:

https://codesandbox.io/s/react-codemirror-yaml-lint-5zhtk