slidesutils

package
v0.0.0-...-a0e9b24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NormalMask byte = 1 << 0 // 0000 0001
	BoldMask   byte = 1 << 1 // 0000 0010
	ItalicMask byte = 1 << 2 // 0000 0100
)

Define bit masks for each style

Variables

This section is empty.

Functions

func CopyTemplate

func CopyTemplate(ctx context.Context, driveSrv *drive.Service, templatePresentationId string) (string, error)

CopyTemplate copies a presentation template and returns the new presentation ID.

func CreateBullets

func CreateBullets(objectID string, startIndex, endIndex int64) *slides.Request

CreateBullets creates bullet points for a specific range.

func DecodeStyle

func DecodeStyle(s Style) (bold, italic, normal bool)

Decode a style back into its components

func InsertMarkdownContent

func InsertMarkdownContent(input string, objectID string) []*slides.Request

InsertMarkdownContent processes the content and generates a list of requests for formatting.

func InsertText

func InsertText(objectID string, content string, insertionIndex int64) *slides.Request

InsertText inserts text into a specified object with a given insertion index.

func SortRequests

func SortRequests(requests []*slides.Request)

func UpdateParagraphStyle

func UpdateParagraphStyle(objectID string, startIndex, endIndex int64, indentFirstLine, indentStart float64) *slides.Request

UpdateParagraphStyle updates the paragraph style (e.g., indentation) for a specific range.

func UpdateTextStyle

func UpdateTextStyle(objectID string, startIndex, endIndex int64, bold, italic, normal bool) *slides.Request

UpdateTextStyle updates the text style (e.g., bold, italic) for a specific range.

Types

type BuilderInterface

type BuilderInterface interface {
	// CreateChapter creates a chapter with the given slide.
	CreateChapter(ctx context.Context, slide structure.Slide) error

	// CreateSlideTitleSubtitleBody creates a slide with a title, subtitle, and body.
	CreateSlideTitleSubtitleBody(ctx context.Context, slide structure.Slide) error

	// CreateCover creates a cover with the given title and subtitle.
	CreateCover(ctx context.Context, title, subtitle string) error

	// InsertImage inserts an image with the given URL, dimensions, and translation offsets.
	InsertImage(ctx context.Context, imageUrl string, width, height, translateX, translateY float64) error

	// CreateNewSlide creates a new slide with the specified layout.
	CreateNewSlide(ctx context.Context, layout string) error
}

BuilderInterface defines the methods that the Builder struct must implement.

type Chunk

type Chunk struct {
	Content          string
	Style            Style
	IndentationLevel int // 0 means no indentation, 1 first bullet, 2 second bullet
	Paragraph        int
}

Define the Chunk struct

type Presentation

type Presentation struct {
	PresentationID          string                            // The unique identifier of the presentation.
	PresentationService     *slides.PresentationsService      // Service for interacting with the Google Slides API.
	PresentationPageService *slides.PresentationsPagesService // Service for interacting with individual slides.
	// contains filtered or unexported fields
}

Presentation allows interaction with a Google Slides presentation. It provides methods for updating the presentation, checking for changes, and iterating through the slides in the presentation.

func (*Presentation) GetAllContentMD

func (p *Presentation) GetAllContentMD(ctx context.Context) (string, error)

func (*Presentation) HasChanged

func (p *Presentation) HasChanged() bool

HasChanged checks if the presentation has been updated since the last check. It compares the current revision ID of the presentation with the stored revision ID. If the revision has changed, it returns true and updates the stored revision ID.

func (*Presentation) Slides

func (p *Presentation) Slides() iter.Seq[*slides.Page]

Slides returns an iterator for the slides in the current presentation. It iterates through the slides and yields each slide as a *slides.Page object. If an error occurs while retrieving a slide, it logs the error and continues iterating.

func (*Presentation) Update

func (p *Presentation) Update(ctx context.Context, requests []*slides.Request) error

Update applies a batch of update requests to the presentation. It takes a context, and performs the updates defined in the provided slice of Request objects.

func (*Presentation) UpdateFromAI

func (p *Presentation) UpdateFromAI(ctx context.Context, ai ai.AIInterface, objectID, prompt, tagWord string) error

func (*Presentation) UpdatePresentationPointer

func (p *Presentation) UpdatePresentationPointer() error

UpdatePresentationPointer retrieves the latest version of the presentation from the Google Slides API and updates the cached presentation object.

type Style

type Style []byte

Define the custom type

func EncodeStyle

func EncodeStyle(bold, italic bool) Style

Encode a style into a custom style type

Directories

Path Synopsis
Package slidesutils provides utilities for working with Google Slides presentations, including creating and managing slides programmatically using the Google Slides API.
Package slidesutils provides utilities for working with Google Slides presentations, including creating and managing slides programmatically using the Google Slides API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL