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 {
}
static convertMonacoToELInstance = (inst) => {
this.instance = inst;
this.instance.updateModelLanguage = (path) => {
return EditorLite.instanceUpdateLanguage(inst, path);
const editorLiteInstanceAPI = {
updateModelLanguage: (path) => {
return EditorLite.instanceUpdateLanguage(inst, path);
},
use: (exts = []) => {
return EditorLite.instanceApplyExtension(inst, exts);
},
};
this.instance.use = (exts = []) => {
return EditorLite.instanceApplyExtension(inst, exts);
const handler = {
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) {
......
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