aboutsummaryrefslogtreecommitdiff
path: root/src/client/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views')
-rw-r--r--src/client/views/MainView.tsx11
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx24
2 files changed, 25 insertions, 10 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 705eacc0c..7b15e9624 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -87,11 +87,6 @@ export class MainView extends React.Component {
if (!("presentationView" in doc)) {
doc.presentationView = new List<Doc>([Docs.Create.TreeDocument([], { title: "Presentation" })]);
}
- if (!("googleDocId" in doc)) {
- GoogleApiClientUtils.Docs.Create().then(id => {
- id && (doc.googleDocId = id);
- });
- }
CurrentUserUtils.UserDocument.activeWorkspace = doc;
}
}
@@ -158,9 +153,9 @@ export class MainView extends React.Component {
reaction(() => this.mainContainer, () => {
let main = this.mainContainer, documentId;
if (main && (documentId = StrCast(main.googleDocId))) {
- GoogleApiClientUtils.Docs.Read({ documentId }).then(text => {
- text && Utils.CopyText(text);
- console.log(text);
+ let options = { documentId, removeNewlines: true };
+ GoogleApiClientUtils.Docs.ReadLines(options).then(lines => {
+ console.log(lines);
});
}
});
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 44b5d2c21..8c2af7c9e 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -1,5 +1,5 @@
import { library } from '@fortawesome/fontawesome-svg-core';
-import { faEdit, faSmile, faTextHeight } from '@fortawesome/free-solid-svg-icons';
+import { faEdit, faSmile, faTextHeight, faUpload } from '@fortawesome/free-solid-svg-icons';
import { action, IReactionDisposer, observable, reaction, runInAction, computed, Lambda, trace } from "mobx";
import { observer } from "mobx-react";
import { baseKeymap } from "prosemirror-commands";
@@ -38,9 +38,10 @@ import { For } from 'babel-types';
import { DateField } from '../../../new_fields/DateField';
import { Utils } from '../../../Utils';
import { MainOverlayTextBox } from '../MainOverlayTextBox';
+import { GoogleApiClientUtils } from '../../apis/google_docs/GoogleApiClientUtils';
library.add(faEdit);
-library.add(faSmile, faTextHeight);
+library.add(faSmile, faTextHeight, faUpload);
// FormattedTextBox: Displays an editable plain text node that maps to a specified Key of a Document
//
@@ -58,6 +59,8 @@ const richTextSchema = createSchema({
documentText: "string"
});
+const googleDocKey = "googleDocId";
+
type RichTextDocument = makeInterface<[typeof richTextSchema]>;
const RichTextDocument = makeInterface(richTextSchema);
@@ -661,7 +664,24 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
event: action(() => Doc.GetProto(this.props.Document).autoHeight = !BoolCast(this.props.Document.autoHeight)), icon: "expand-arrows-alt"
});
ContextMenu.Instance.addItem({ description: "Text Funcs...", subitems: subitems, icon: "text-height" });
+ if (!(googleDocKey in Doc.GetProto(this.props.Document))) {
+ ContextMenu.Instance.addItem({ description: "Export to Google Doc...", event: this.exportToGoogleDoc, icon: "upload" });
+ }
}
+
+ exportToGoogleDoc = () => {
+ let dataDoc = Doc.GetProto(this.props.Document);
+ let data = Cast(dataDoc.data, RichTextField);
+ let content: string | undefined;
+ if (data && (content = data.plainText())) {
+ GoogleApiClientUtils.Docs.Write({
+ title: StrCast(dataDoc.title),
+ store: { receiver: dataDoc, key: googleDocKey },
+ content
+ });
+ }
+ }
+
render() {
let self = this;
let style = this.props.isOverlay ? "scroll" : "hidden";