Added caching of loaded editor instance
This commit is contained in:
parent
72d8abe069
commit
bfd32843ff
@ -24,6 +24,10 @@ type Props = {
|
||||
class AccountMenu extends React.Component<Props> {
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidUpdate() {
|
||||
this.redirectTo = undefined;
|
||||
}
|
||||
|
||||
handleOpenKeyboardShortcuts = () => {
|
||||
this.props.ui.setActiveModal('keyboard-shortcuts');
|
||||
};
|
||||
|
@ -30,6 +30,10 @@ class CollectionMenu extends React.Component<Props> {
|
||||
@observable permissionsModalOpen: boolean = false;
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidUpdate() {
|
||||
this.redirectTo = undefined;
|
||||
}
|
||||
|
||||
onNewDocument = (ev: SyntheticEvent<*>) => {
|
||||
ev.preventDefault();
|
||||
const { collection } = this.props;
|
||||
|
@ -25,6 +25,10 @@ type Props = {
|
||||
class DocumentMenu extends React.Component<Props> {
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidUpdate() {
|
||||
this.redirectTo = undefined;
|
||||
}
|
||||
|
||||
handleNewChild = (ev: SyntheticEvent<*>) => {
|
||||
const { document } = this.props;
|
||||
this.redirectTo = `${document.collection.url}/new?parentDocument=${
|
||||
|
@ -18,6 +18,10 @@ type Props = {
|
||||
class NewChildDocumentMenu extends React.Component<Props> {
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidUpdate() {
|
||||
this.redirectTo = undefined;
|
||||
}
|
||||
|
||||
handleNewDocument = () => {
|
||||
this.redirectTo = newDocumentUrl(this.props.document.collection);
|
||||
};
|
||||
|
@ -18,6 +18,10 @@ type Props = {
|
||||
class NewDocumentMenu extends React.Component<Props> {
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidUpdate() {
|
||||
this.redirectTo = undefined;
|
||||
}
|
||||
|
||||
handleNewDocument = collection => {
|
||||
this.redirectTo = newDocumentUrl(collection);
|
||||
};
|
||||
|
@ -24,6 +24,10 @@ type Props = {
|
||||
class ShareMenu extends React.Component<Props> {
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidUpdate() {
|
||||
this.redirectTo = undefined;
|
||||
}
|
||||
|
||||
handleGoToDocument = (ev: SyntheticEvent<*>) => {
|
||||
ev.preventDefault();
|
||||
this.redirectTo = this.props.share.documentUrl;
|
||||
|
@ -41,6 +41,7 @@ import Revision from 'models/Revision';
|
||||
|
||||
import schema from './schema';
|
||||
|
||||
let EditorImport;
|
||||
const AUTOSAVE_DELAY = 3000;
|
||||
const IS_DIRTY_DELAY = 500;
|
||||
const MARK_AS_VIEWED_AFTER = 3000;
|
||||
@ -69,7 +70,7 @@ class DocumentScene extends React.Component<Props> {
|
||||
viewTimeout: TimeoutID;
|
||||
getEditorText: () => string;
|
||||
|
||||
@observable editorComponent;
|
||||
@observable editorComponent = EditorImport;
|
||||
@observable document: ?Document;
|
||||
@observable revision: ?Revision;
|
||||
@observable newDocument: ?Document;
|
||||
@ -184,8 +185,11 @@ class DocumentScene extends React.Component<Props> {
|
||||
};
|
||||
|
||||
loadEditor = async () => {
|
||||
const EditorImport = await import('./components/Editor');
|
||||
this.editorComponent = EditorImport.default;
|
||||
if (this.editorComponent) return;
|
||||
|
||||
const Imported = await import('./components/Editor');
|
||||
EditorImport = Imported.default;
|
||||
this.editorComponent = EditorImport;
|
||||
};
|
||||
|
||||
get isEditing() {
|
||||
|
Reference in New Issue
Block a user