Comments (3)
Did you try the example in How to Use?
from codemirror-plus.
Thanks for your insight. I have tried to put the key.js in the directory '/node_modules/codemirror/addon/mode' and it did work smoothly.
However, is there any other way to put this file or the core function in our own code instead of codemirror's source code package since I have to do this again once I use 'npm install' command.
Indeed, I have tried via this way
part of my own component
import codemirror from 'codemirror';
import { Controlled as CodeMirror } from 'react-codemirror2';
import init from './utils'
...
useEffect(() => {
init(codemirror);
}, []);
return <CodeMirror
...
keyword: {
junior: 'style1',
price: 'style1',
},
>
utils.ts
export default function(CodeMirror, keywordsAndFunctions) {
"use strict";
CodeMirror.defineOption("keyword", {}, function(cm, val, prev) {
if (prev == CodeMirror.Init) prev = false;
if (prev && !val)
cm.removeOverlay("keyword");
else if (!prev && val)
cm.addOverlay({
token: function(stream) {
for (var key in cm.options.keyword) {
if (stream.match(key, true)) {return cm.options.keyword[key];}
}
stream.next();
},
name: "keyword"
});
});
}
less file
.cm-style1 {
color: pink !important;
}
And it does not work as expected. It would be really appreciated to get your advice.
from codemirror-plus.
However, is there any other way to put this file or the core function in our own code instead of codemirror's source code package since I have to do this again once I use 'npm install' command.
As in How to Use
Install the file in
/addon/mode/
or any preferred directory
Add the necessary<script>
&<link rel="stylesheet">
to the HTML document
There is an HTML page that displays the CodeMirror. Add the <script>
to point to that file.
<script src="../whereever/keyword.js"></script>
If you want to combine the code with your own code, then there is more work involved. The code has to run after CodeMirror code is parsed but before CodeMirror instance is started e.g. in init(codemirror);
.
from codemirror-plus.
Related Issues (3)
- Regex Support HOT 10
- Keywords In Double Quotes HOT 3
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 codemirror-plus.