|
@@ -55,6 +55,7 @@ export default class AppContainer extends Container {
|
|
|
|
|
|
|
|
this.socket = io();
|
|
this.socket = io();
|
|
|
|
|
|
|
|
|
|
+ this.containerInstances = {};
|
|
|
this.componentInstances = {};
|
|
this.componentInstances = {};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -69,6 +70,28 @@ export default class AppContainer extends Container {
|
|
|
return this.config;
|
|
return this.config;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Register instance
|
|
|
|
|
+ * @param {object} instance unstated container instance
|
|
|
|
|
+ */
|
|
|
|
|
+ registerContainer(instance) {
|
|
|
|
|
+ if (instance == null) {
|
|
|
|
|
+ throw new Error('The specified instance must not be null');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const className = instance.constructor.name;
|
|
|
|
|
+
|
|
|
|
|
+ if (this.containerInstances[className] != null) {
|
|
|
|
|
+ throw new Error('The specified instance couldn\'t register because the same type object has already been registered');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.containerInstances[className] = instance;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ getContainer(className) {
|
|
|
|
|
+ return this.containerInstances[className];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Register instance
|
|
* Register instance
|
|
|
* @param {object} instance React component instance
|
|
* @param {object} instance React component instance
|
|
@@ -173,20 +196,6 @@ export default class AppContainer extends Container {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- setCaretLine(line) {
|
|
|
|
|
- const pageEditor = this.getComponentInstance('PageEditor');
|
|
|
|
|
- if (pageEditor != null) {
|
|
|
|
|
- pageEditor.setCaretLine(line);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- focusToEditor() {
|
|
|
|
|
- const pageEditor = this.getComponentInstance('PageEditor');
|
|
|
|
|
- if (pageEditor != null) {
|
|
|
|
|
- pageEditor.focusToEditor();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
clearDraft(path) {
|
|
clearDraft(path) {
|
|
|
delete this.draft[path];
|
|
delete this.draft[path];
|
|
|
window.localStorage.setItem('draft', JSON.stringify(this.draft));
|
|
window.localStorage.setItem('draft', JSON.stringify(this.draft));
|