Open ialexivy opened 6 years ago
Fixed in v5.0.0
need to update this.originalModel = someNewObject, can't update just the .code, right? That's how it seems to work for me right now.
Hi i have v6.0.0 but i have this problem.
i fixed as follows manualy
`
<ngx-monaco-editor [options]="options" (onInit)="onInit($event)"> `
options = { theme: 'vs-light', language: 'html' };
onOriginalFileChange(inputValue: any): void { inputValue = inputValue.target; const file: File = inputValue.files[0];
const myReader: FileReader = new FileReader();
myReader.readAsDataURL(file);
myReader.onload = (e) => {
this.originalModel = monaco.editor.createModel(this.b64DecodeUnicode(myReader.result.toString().split(',')[1]), 'html');
this.diffEditor.setModel({
original: this.originalModel,
modified: this.modifiedModel
});
};
}
onModifiedFileChange(inputValue: any): void { inputValue = inputValue.target; const file: File = inputValue.files[0];
const myReader: FileReader = new FileReader();
myReader.readAsDataURL(file);
myReader.onload = (e) => {
this.modifiedModel = monaco.editor.createModel(this.b64DecodeUnicode(myReader.result.toString().split(',')[1]), 'html');
this.diffEditor.setModel({
original: this.originalModel,
modified: this.modifiedModel
});
};
}
b64DecodeUnicode(str: string): string {
try {
if (window
&& "atob" in window
&& "decodeURIComponent" in window) {
return decodeURIComponent(Array.prototype.map.call(atob(str), (c) => {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
}).join(""));
} else {
console.warn("b64DecodeUnicode requirements: window.atob and window.decodeURIComponent functions");
return null;
}
} catch (error) {
}
} diffEditor: any; originalModel: any; modifiedModel: any;
onInit(editor) {
this.originalModel = monaco.editor.createModel('', 'html');
this.modifiedModel = monaco.editor.createModel('', 'html');
this.diffEditor = (
When using the diff editor and updating originalModel and modifiedModel editor view doesn't update, i think the issue is that the model only created when editor init for the first time, instead it should probably create new model each time that input values changes, OnChanges event.
`<ngx-monaco-diff-editor [options]="options" [originalModel]="originalModel" [modifiedModel]="modifiedModel">
updateView(){ this.originalModel.code='Update'; this.modifiedModel.code='Update'; }`