Commit 3dbbe26b authored by Denys Mishunov's avatar Denys Mishunov

Removed mutation of instance

Now we use Proxy pattern instead of a decorator
parent caa1ccfb
...@@ -135,14 +135,23 @@ export default class EditorLite { ...@@ -135,14 +135,23 @@ export default class EditorLite {
} }
static convertMonacoToELInstance = (inst) => { static convertMonacoToELInstance = (inst) => {
this.instance = inst; const editorLiteInstanceAPI = {
this.instance.updateModelLanguage = (path) => { updateModelLanguage: (path) => {
return EditorLite.instanceUpdateLanguage(inst, path); return EditorLite.instanceUpdateLanguage(inst, path);
},
use: (exts = []) => {
return EditorLite.instanceApplyExtension(inst, exts);
},
}; };
this.instance.use = (exts = []) => { const handler = {
return EditorLite.instanceApplyExtension(inst, exts); get(target, prop, receiver) {
if (Reflect.has(editorLiteInstanceAPI, prop)) {
return editorLiteInstanceAPI[prop];
}
return Reflect.get(target, prop, receiver);
},
}; };
return this.instance; return new Proxy(inst, handler);
}; };
static instanceUpdateLanguage(inst, path) { static instanceUpdateLanguage(inst, path) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment