Comments (8)
@justindeguzman I ended up forking this project pretty aggressively since it seemed dormant for awhile. To solve this particular problem I added some functions to test "deep" object/array equality.
function deepEquals(thing1, thing2) {
if (thing1 === thing2) {
return true;
} else if (Number.isNaN(thing1) && Number.isNaN(thing2)) {
return true;
} else if (Array.isArray(thing1) && Array.isArray(thing2)) {
return arraysEqual(thing1, thing2);
} else if (typeof(thing1) === 'object' && typeof(thing2) === 'object') {
return objectsEqual(thing1, thing2);
} else {
return false;
}
}
function arraysEqual(array1, array2) {
if (array1.length !== array2.length) {
return false;
} else {
return array1.every(function(item, index) {
return deepEquals(array1[index], array2[index]);
});
}
}
function objectsEqual(obj1, obj2) {
if (obj1.constructor !== obj2.constructor) {
return false;
}
var obj1Keys = Object.keys(obj1);
var obj2Keys = Object.keys(obj2);
if (!arraysEqual(obj1Keys.sort(), obj2Keys.sort())) {
return false;
}
return obj1Keys.every(function(key) {
return deepEquals(obj1[key], obj2[key]);
});
}
setCodeMirrorOptionIfChanged: function(optionName, newValue) {
var oldValue = this.codeMirror.getOption(optionName);
if (!deepEquals(oldValue, newValue)) {
this.codeMirror.setOption(optionName, newValue);
}
},
from react-codemirror.
Okay, thinking about this more; using JSON.stringify would almost certainly cause other bugs, since there are a handful of CodeMirror options that take functions as values.
from react-codemirror.
@attaboy Were you able to find a solution?
from react-codemirror.
Have a fork published anywhere? Really like to get linting to work...
from react-codemirror.
@cacois I just created a pull request that I believe fixes the problem with lint
: #93
from react-codemirror.
@attaboy Thanks for the note!
Plugged your branch in to give it a test, but I don't see any change in behavior in my app. Any specific guidance on getting it working? I'm basically just importing libraries adding the lint: true, gutters: ['CodeMirror-lint-markers']
options.
from react-codemirror.
@cacois Which lint plugin are you trying to use? I'm using jshint successfully in my project by requiring addon/lint/lint
and add-on/lint/javascript-lint
and ensuring that the JSHint library is loaded already (globally, which is an assumption that the javascript-lint add-on makes).
from react-codemirror.
@attaboy Got it! Turns out I wasn't getting the JSHINT function to be globally available, as necessary. Once I figured out how to import it properly, things began working fine. Thanks!
from react-codemirror.
Related Issues (20)
- Theme syntax highlighting not working HOT 3
- how can I beautify(formatting) code after load HOT 2
- Foldcode not working for me. And not even getting foldgutter. Any help? HOT 3
- Update peerDependencies for react > 16 HOT 1
- Is this library deprecated? HOT 2
- How to integrate codemirror-formatting plugin with react
- Focus lost after typing character HOT 2
- How do I use methods like setSize of an instance?
- How to Set Default Background Color and Default Content Width in Editor?????
- Line numbers sometimes don't load properly using fromTextArea
- Can't use defineMode ?
- beforeChange is not fired?
- autofocus is broken on UnControlled
- how can I use MergeView
- lineNumbers show in preview codemirror
- .
- New project with react-codemirror on typescript HOT 1
- Codemirror syntax highlighting works in preview but not when published
- Support React 17 HOT 1
- When pasting in multi-line values, it pastes twice HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-codemirror.