Skip to content

Commit 60618fa

Browse files
update readme file
1 parent 343e8dd commit 60618fa

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Readme.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,19 @@ Setup
2828
3. codemirrorAPIUrl- Its value must be a string denoting the path of folder of codemirror like '/node_modules/codemirror'. It is used to load js file on demand.
2929
4. disableCopy - Its value must be boolean. If you want to disable copy from editor then set this flag with true value.
3030
5. disableCut - Its value must be boolean. If you want to disable cut from editor then set this flag with true value.
31-
5. disablePaste - Its value must be boolean. If you want to disable paste into editor then set this flag with true value.
31+
5. disablePaste - Its value must be boolean. If you want to disable paste into editor then set this flag with true value.
32+
33+
Events
34+
------
35+
1. [ngModel] - Its value must be string and used to add code texts into editor. It is used to implement one-way binding.
36+
<codemirror [ngModel] = 'Code' id='code' name='code'></codemirror>
37+
38+
2. [(ngModel)] - Its value must be string and used to add code texts into editor and get changed text of editor. It is used to implement two-way binding which means if you change text in editor, it will reflect in binded variable.
39+
<codemirror [(ngModel)] = 'Code' id='code' name='code'></codemirror>
40+
41+
3. (ngModelChange) - used to get contents of editor in string format. It is used to implement two-way binding which means if you change text in editor, it will reflect in binded variable.
42+
<codemirror [ngModel] = 'Code' (ngModelChange) = 'getEditorCode($event)' id='code' name='code'></codemirror>
43+
44+
4. (onEditorLoaded) - It notify when editor successfully loaded in both feature(default or lazyloaded) and provide an instance of currently loaded editor in paramete. It is useful when you want to get instance of editor and do some task after editor loaded.
45+
<codemirror [(ngModel)] = 'Code' (onEditorLoaded) = 'doSomeTask($event)' id='code' name='code'></codemirror>
46+

codemirror.editor.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class JSObject {
6060
_config:any = this._defaultConfig;
6161
_height: any = null;
6262
_width: any = null;
63-
@Output() instance = null;
63+
private instance = null;
6464

6565
/**
6666
* Constructor
@@ -139,14 +139,14 @@ class JSObject {
139139
$script(fileUrls, () => {
140140
this.fileLoaded = true;
141141
this.codemirrorInit(this._config);
142-
this.onEditorLoaded.emit();
142+
this.onEditorLoaded.emit(this.instance);
143143
});
144144

145145
//path of matchbrackets file
146146
} else {
147147
this.fileLoaded = true;
148148
this.codemirrorInit(this._config);
149-
this.onEditorLoaded.emit();
149+
this.onEditorLoaded.emit(this.instance);
150150
}
151151
}
152152

@@ -323,7 +323,7 @@ setFileUrlForKeyMap(fileUrlsArray) {
323323
this.codeMirrorUpdateOptions();
324324
} else{
325325
if(this.instance){
326-
this.onEditorLoaded.emit();
326+
this.onEditorLoaded.emit(this.instance);
327327
}
328328

329329
}
@@ -341,7 +341,7 @@ setFileUrlForKeyMap(fileUrlsArray) {
341341
this.setEditorOption(optionKey, this._config[optionKey]);
342342
}
343343
this.instance.refresh();
344-
this.onEditorLoaded.emit();
344+
this.onEditorLoaded.emit(this.instance);
345345
});
346346

347347

0 commit comments

Comments
 (0)