docsedit

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIndex

func AppendIndex(endIndex int64) int64

func AppendIndexForTarget added in v0.30.0

func AppendIndexForTarget(endIndex int64, segmentID string) int64

func BuildDeleteRequest

func BuildDeleteRequest(target Range, tabID string) *docs.Request

func BuildInsertRequest

func BuildInsertRequest(text string, index int64, tabID string) *docs.Request

func BuildUpdateRequests

func BuildUpdateRequests(text string, insertIndex int64, tabID string, replace *Range) []*docs.Request

func BuildWriteRequests

func BuildWriteRequests(options WriteOptions) ([]*docs.Request, error)

func ValidateAnchor

func ValidateAnchor(options AnchorOptions) error

Types

type AnchorOptions

type AnchorOptions struct {
	Text       string
	Provided   bool
	Occurrence *int
	MatchCase  bool
}

type EndInsertPlacementOptions

type EndInsertPlacementOptions struct {
	Index     *int64
	AllowZero bool
	AtEnd     bool
	Anchor    AnchorOptions
}

type InsertPlacementOptions

type InsertPlacementOptions struct {
	Index     *int64
	AllowZero bool
	Anchor    AnchorOptions
}

type MarkdownWriteMode

type MarkdownWriteMode uint8
const (
	MarkdownWriteDriveReplace MarkdownWriteMode = iota
	MarkdownWriteLocalAppend
	MarkdownWriteLocalReplace
)

type MarkdownWriteOptions

type MarkdownWriteOptions struct {
	Markdown           string
	ImageCount         int
	Append             bool
	Replace            bool
	Tab                string
	CheckOrphans       bool
	ApplyDocumentStyle bool
}

type MarkdownWritePlan

type MarkdownWritePlan struct {
	Mode                     MarkdownWriteMode
	Reason                   MarkdownWriteReason
	Markdown                 string
	Tab                      string
	ImageCount               int
	ExplicitHeadingAnchors   []docsmarkdown.ExplicitHeadingAnchor
	CheckOrphans             bool
	OrphanScopeWholeDocument bool
	RewriteHeadingLinks      bool
	InsertImages             bool
	ApplyDocumentStyle       bool
	RequiresDriveService     bool
	RequiresDocumentsService bool
}

func PlanMarkdownWrite

func PlanMarkdownWrite(options MarkdownWriteOptions) (MarkdownWritePlan, error)

type MarkdownWriteReason

type MarkdownWriteReason uint8
const (
	MarkdownWriteWholeDocument MarkdownWriteReason = iota
	MarkdownWriteAppend
	MarkdownWriteTab
	MarkdownWriteTableCellBreaks
)

type Placement

type Placement struct {
	Kind   PlacementKind
	Index  int64
	Range  Range
	Anchor AnchorOptions
}

func PlanEndInsertPlacement

func PlanEndInsertPlacement(options EndInsertPlacementOptions) (Placement, error)

func PlanInsertPlacement

func PlanInsertPlacement(options InsertPlacementOptions) (Placement, error)

func PlanRangePlacement

func PlanRangePlacement(options RangePlacementOptions) (Placement, error)

func PlanUpdatePlacement

func PlanUpdatePlacement(options UpdatePlacementOptions) (Placement, error)

type PlacementFacts

type PlacementFacts struct {
	EndIndex           int64
	TabID              string
	SegmentID          string
	SegmentKind        string
	Anchor             *TextRange
	RequiredRevisionID string
}

type PlacementKind

type PlacementKind uint8
const (
	PlacementEnd PlacementKind = iota
	PlacementIndex
	PlacementRange
	PlacementAnchor
)

type Range

type Range struct {
	Start int64
	End   int64
}

func ParseRange

func ParseRange(value string) (Range, bool, error)

type RangePlacementOptions

type RangePlacementOptions struct {
	Start     *int64
	End       *int64
	AllowZero bool
	Anchor    AnchorOptions
}

type ResolvedPlacement

type ResolvedPlacement struct {
	Index              int64
	Range              *Range
	TabID              string
	SegmentID          string
	SegmentKind        string
	RequiredRevisionID string
	Anchored           bool
	InTable            bool
}

func ResolvePlacement

func ResolvePlacement(placement Placement, facts PlacementFacts) (ResolvedPlacement, error)

type SearchOptions

type SearchOptions struct {
	MatchCase            bool
	NormalizeWhitespace  bool
	TabID                string
	PreserveHTMLEntities bool
	RequireTextSegment   bool
}

SearchOptions controls document text normalization and range constraints.

type TextRange

type TextRange struct {
	StartIndex     int64  `json:"startIndex"`
	EndIndex       int64  `json:"endIndex"`
	ParagraphIndex int    `json:"paragraphIndex"`
	TabID          string `json:"tabId"`
	InTable        bool   `json:"inTable,omitempty"`
}

TextRange is one matched Google Docs UTF-16 range.

func FindTextRanges

func FindTextRanges(
	document *docs.Document,
	searchText string,
	options SearchOptions,
) []TextRange

FindTextRanges returns non-overlapping matches in document source order.

type UpdatePlacementOptions

type UpdatePlacementOptions struct {
	Index         int64
	IndexProvided bool
	AllowZero     bool
	ReplaceRange  string
	Anchor        AnchorOptions
}

type ValidationError

type ValidationError string

func (ValidationError) Error

func (e ValidationError) Error() string

type WriteOptions

type WriteOptions struct {
	EndIndex    int64
	InsertIndex int64
	Text        string
	TabID       string
	Append      bool
	Format      docsformat.Options
}

Jump to

Keyboard shortcuts

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