| 364 | } |
| 365 | |
| 366 | func (c *DocsInsertImageCmd) buildInsertRequests(ctx context.Context, svc *docs.Service, docID string, target docsImageTarget, imageURL string) ([]*docs.Request, int64, string, error) { |
| 367 | index, placeholder, tabID, err := c.resolveImageTarget(ctx, svc, docID, target) |
| 368 | if err != nil { |
| 369 | return nil, 0, "", err |
| 370 | } |
| 371 | objSize := &docs.Size{} |
| 372 | if c.Width > 0 { |
| 373 | objSize.Width = &docs.Dimension{Magnitude: c.Width, Unit: "PT"} |
| 374 | } |
| 375 | if c.Height > 0 { |
| 376 | objSize.Height = &docs.Dimension{Magnitude: c.Height, Unit: "PT"} |
| 377 | } |
| 378 | reqs := make([]*docs.Request, 0, 2) |
| 379 | if placeholder != nil { |
| 380 | reqs = append(reqs, &docs.Request{DeleteContentRange: &docs.DeleteContentRangeRequest{ |
| 381 | Range: &docs.Range{StartIndex: placeholder.StartIndex, EndIndex: placeholder.EndIndex, TabId: tabID}, |
| 382 | }}) |
| 383 | } |
| 384 | reqs = append(reqs, &docs.Request{InsertInlineImage: &docs.InsertInlineImageRequest{ |
| 385 | Uri: imageURL, |
| 386 | Location: &docs.Location{Index: index, TabId: tabID}, |
| 387 | ObjectSize: objSize, |
| 388 | }}) |
| 389 | return reqs, index, tabID, nil |
| 390 | } |
| 391 | |
| 392 | func (c *DocsInsertImageCmd) buildLinkFallbackRequests(ctx context.Context, svc *docs.Service, docID string, target docsImageTarget, link string) ([]*docs.Request, int64, string, error) { |
| 393 | index, placeholder, tabID, err := c.resolveImageTarget(ctx, svc, docID, target) |