aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/RichTextUtils.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-09-10 20:01:55 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-09-10 20:01:55 -0400
commit628eef55533118b1f2312b86b2ac5f7b64f7fc4a (patch)
tree00747c1b6ee2b9f120108f6d19a5b017c3c1f419 /src/new_fields/RichTextUtils.ts
parentb24c475d8cd36af860fc374b0c5621b0d096be1d (diff)
lots of refactoring, beginning autotagging
Diffstat (limited to 'src/new_fields/RichTextUtils.ts')
-rw-r--r--src/new_fields/RichTextUtils.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/new_fields/RichTextUtils.ts b/src/new_fields/RichTextUtils.ts
index 500b93676..27737782b 100644
--- a/src/new_fields/RichTextUtils.ts
+++ b/src/new_fields/RichTextUtils.ts
@@ -11,7 +11,7 @@ import { Utils, PostToServer } from "../Utils";
import { RouteStore } from "../server/RouteStore";
import { Docs } from "../client/documents/Documents";
import { schema } from "../client/util/RichTextSchema";
-import { GooglePhotosClientUtils } from "../client/apis/google_docs/GooglePhotosClientUtils";
+import { GooglePhotos } from "../client/apis/google_docs/GooglePhotosClientUtils";
export namespace RichTextUtils {
@@ -90,7 +90,7 @@ export namespace RichTextUtils {
export namespace GoogleDocs {
- export const Export = (state: EditorState): GoogleApiClientUtils.Docs.Content => {
+ export const Export = async (state: EditorState): Promise<GoogleApiClientUtils.Docs.Content> => {
let nodes: { [type: string]: Node<any>[] } = {
text: [],
image: []
@@ -107,7 +107,7 @@ export namespace RichTextUtils {
}
}));
let linkRequests = ExtractLinks(nodes.text);
- let imageRequests = ExtractImages(nodes.image);
+ let imageRequests = await ExtractImages(nodes.image);
return {
text,
requests: [...linkRequests, ...imageRequests]
@@ -298,10 +298,13 @@ export namespace RichTextUtils {
const length = node.nodeSize;
const attrs = node.attrs;
const uri = attrs.src;
- const result = (await GooglePhotosClientUtils.UploadImages([uri])).newMediaItemResults;
+ const baseUrls = await GooglePhotos.Transactions.UploadThenFetch([uri]);
+ if (!baseUrls) {
+ continue;
+ }
images.push({
insertInlineImage: {
- uri: result[0].mediaItem.productUrl,
+ uri: baseUrls[0],
objectSize: { width: { magnitude: parseFloat(attrs.width.replace("px", "")), unit: "PT" } },
location: { index: position + length }
}