Added caching of loaded editor instance

This commit is contained in:
Tom Moor 2019-01-19 01:31:34 -08:00
parent 72d8abe069
commit bfd32843ff
7 changed files with 31 additions and 3 deletions

View File

@ -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');
};

View File

@ -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;

View File

@ -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=${

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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;

View File

@ -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() {