codemirror-spell-checker
codemirror-spell-checker copied to clipboard
Problem when using CDN file
This is what I have in <head>
:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/src/js/spell-checker.min.js" type="text/javascript"></script>
<script src="https://codemirror.net/addon/mode/overlay.js" type="text/javascript"></script>
This fails with error ReferenceError: require is not defined
due to an attempt to require typo-js
. What I understand is that require
will work within Node.js runtime but not in browser. What's the solution?
I removed the require
and export
from . My code is now:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/codemirror.spell-checker/latest/spell-checker.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/typo.min.js"></script>
<script src={localpath}/js/spell-checker.min.js"></script>
<script src="https://codemirror.net/addon/mode/overlay.js"></script>
No errors this time but spell check is not happening. In CodeMirror, textarea content is actually within <div class="CodeMirror-code" role="presentation>"
. Nothing happens when spell checker is invoked this way:
CodeMirrorSpellChecker({
codeMirrorInstance: CodeMirror,
});
CodeMirror.fromTextArea(jQuery(".CodeMirror-code")[0], {
mode: "spell-checker"
});