Comments (3)
I found a solution !
You just need to "refresh" the codemirror instance ;)
(So you no longer need to override CSS Class)
First in my component.html, I add #editor :
<codemirror #editor name="myCode" [(ngModel)]="code"
[config]="{lineNumbers: true, theme: 'mdn-like', mode: 'lua', autofocus: true, height: '500px'}">
</codemirror>
Secondly in my component.ts, I declare a ViewChild :
@ViewChild('editor') editor:any;
(Don't forget to import it import { Component, OnInit, ViewChild } from '@angular/core';
)
And finally, in the function which open the modal in my component.ts :
openModal() {
let cm = this.editor.instance;
setTimeout(function() {
cm.refresh();
// Set cursor to the end
let posCursor = {line: 0, ch: 0};
posCursor.line = cm.doc.children[0].lines.length-1;
posCursor.ch = cm.doc.children[0].lines[posCursor.line].text.length;
cm.doc.setCursor(posCursor);
}, 200);
this.modal.open('lg');
}
from ng2-codemirror.
I am facing the same problem any workaround?
from ng2-codemirror.
I have an error too with ng2-codemirror and ng2-bs3-modal.
I use this config : {lineNumbers: true, theme: 'mdn-like', mode: 'clike', height: '500px'}
**~~ EDIT ~~**
For the css issue I add 2 rules :
#my-modal .CodeMirror-sizer {
margin-left: 39px !important;
}
#my-modal .cm-s-mdn-like .CodeMirror-gutters {
width: 32px;
}
But I always need to click on the CodeMirror to display text, and also press a button on my keyboard to pass in editing mode (not readOnly).
from ng2-codemirror.
Related Issues (20)
- Should be able to get data from events emitted
- LineNumbers do not show up in CodeMirror editor HOT 4
- How to get access to original object passed to change function of CodeMirror? HOT 1
- How to Add Addons(hint/sql-hint.js) to my angular2 codemirror?
- error when using with angular 4 HOT 1
- Add custom keyword as hightlighted syntax
- ambiance theme class name invalid
- Update for Angular 5? HOT 4
- Colors not appearing on code passed to codemirror. HOT 1
- setcursor
- How can I tweak it to create a custom autocomplete without "Ctrl+Space"
- How to Add Addons(fullscreen.js) to my angular2 codemirror?
- highlight dosen't work HOT 1
- Angular 6 compatibility? HOT 5
- What about angular universal / server side rendering support?
- CodeMirror does not display colors, code, or mode HOT 2
- STOP USING THIS WRAPPER FOR CODEMIRROR. HOT 2
- Not compatible with Angular 8
- Issue when used with Storybook
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 ng2-codemirror.