Skip to contents

S7 classes representing individual content items on a Google Slides slide. Each element holds three pieces of context — the parent presentation, the parent slide, and the API element_id — that allow any generic to fetch the element's raw data on demand without storing a snapshot.

The concrete subclasses are:

  • text_element — text boxes (shape type TEXT_BOX)

  • image_element — inline images

  • chart_element — linked Google Sheets charts

  • table_element — tables

  • shape_element — other shapes (rectangles, ellipses, etc.)

Use element_type() to identify the type at runtime, and get_elements() or get_all_elements() to obtain element objects from a slide.

Usage

element(presentation = NULL, slide = NULL, element_id = character(0))

text_element(presentation = NULL, slide = NULL, element_id = character(0))

image_element(presentation = NULL, slide = NULL, element_id = character(0))

chart_element(presentation = NULL, slide = NULL, element_id = character(0))

table_element(presentation = NULL, slide = NULL, element_id = character(0))

shape_element(presentation = NULL, slide = NULL, element_id = character(0))

Arguments

presentation

A presentation R6 object (from register_presentation() or new_presentation()).

slide

A slide S7 object (from on_slide_id() or similar selectors).

element_id

A single character string: the element's Google Slides object ID.

Value

An S7 object of the corresponding element class.

Examples

if (FALSE) {
  ps <- register_presentation(id = "YOUR_PRESENTATION_ID", set_active = FALSE)
  slide_obj <- on_slide_number(1, ps)

  # Retrieve all elements on slide 1
  els <- get_all_elements(slide_obj)

  # Check the type of the first element
  element_type(els[[1]])

  # Filter to text elements only
  text_els <- get_elements(slide_obj, type = "text")
}