aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocumentButtonBar.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/DocumentButtonBar.tsx')
-rw-r--r--src/client/views/DocumentButtonBar.tsx13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/client/views/DocumentButtonBar.tsx b/src/client/views/DocumentButtonBar.tsx
index 8fc4cd4d4..cf57094b2 100644
--- a/src/client/views/DocumentButtonBar.tsx
+++ b/src/client/views/DocumentButtonBar.tsx
@@ -5,7 +5,7 @@ import { action, computed, observable, runInAction } from "mobx";
import { observer } from "mobx-react";
import { Doc, DocListCast } from "../../new_fields/Doc";
import { RichTextField } from '../../new_fields/RichTextField';
-import { NumCast, StrCast } from "../../new_fields/Types";
+import { NumCast, StrCast, Cast } from "../../new_fields/Types";
import { emptyFunction, setupMoveUpEvents } from "../../Utils";
import { Pulls, Pushes } from '../apis/google_docs/GoogleApiClientUtils';
import { UndoManager } from "../util/UndoManager";
@@ -190,12 +190,17 @@ export class DocumentButtonBar extends React.Component<{ views: (DocumentView |
}
})}
onPointerLeave={action(() => this.openHover = UtilityButtonState.Default)}
- onClick={e => {
+ onClick={async e => {
const googleDocUrl = `https://docs.google.com/document/d/${dataDoc[GoogleRef]}/edit`;
if (e.shiftKey) {
e.preventDefault();
- const options = { _width: 600, _nativeWidth: 960, _nativeHeight: 800, isAnnotating: false };
- CollectionDockingView.AddRightSplit(Docs.Create.WebDocument(googleDocUrl, options));
+ let googleDoc = await Cast(dataDoc.googleDoc, Doc);
+ if (!googleDoc) {
+ const options = { _width: 600, _nativeWidth: 960, _nativeHeight: 800, isAnnotating: false };
+ googleDoc = Docs.Create.WebDocument(googleDocUrl, options);
+ dataDoc.googleDoc = googleDoc;
+ }
+ CollectionDockingView.AddRightSplit(googleDoc);
} else if (e.altKey) {
e.preventDefault();
window.open(googleDocUrl);