Closed GongJS closed 5 years ago
this is my code:
this.state = { logs: 'this is a new log', keyword: 'log' } <CodeMirror value={this.state.logs} editorDidMount={editor => { this.instance = editor }} defineMode={{ name: 'highlightSearch', fn: () => { return { // startState: () => ({}), token: (stream) => { const keyword = this.state.keyword; if (keyword !== '' && stream.match(keyword)) { return "highlightSearch"; } while (stream.next() != null && !stream.match(keyword, false)) {} return null; } } } }} /> .cm-highlightSearch { background: red; color: #fff; }
i want to highlight the keyword of 'log', but i find it does not work. it seems that the defineMode does not work...
defineMode
my version is 6.0.0
6.0.0
@GongJS The demo has a working defineMode example (fn source). I'd suggest taking a look at your function, as it should be passing it as expected through the wrapper.
ok,thank you.
this is my code:
i want to highlight the keyword of 'log', but i find it does not work. it seems that the
defineMode
does not work...my version is
6.0.0