editor

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Editor

type Editor interface {
	// RemoveRect removes all content within the specified rectangle.
	// This is useful for redaction.
	// It also updates the StructureTree to remove references to deleted content (MCIDs).
	RemoveRect(ctx context.Context, page *semantic.Page, rect semantic.Rectangle) error

	// ReplaceText replaces occurrences of oldText with newText.
	// Note: This is a complex operation that may require font subsetting adjustments
	// and layout recalculation.
	ReplaceText(ctx context.Context, page *semantic.Page, oldText, newText string) error
}

Editor provides high-level content editing capabilities.

type EditorImpl

type EditorImpl struct{}

func NewEditor

func NewEditor() *EditorImpl

func (*EditorImpl) RemoveRect

func (e *EditorImpl) RemoveRect(ctx context.Context, page *semantic.Page, rect semantic.Rectangle) error

func (*EditorImpl) RepairStructTree

func (e *EditorImpl) RepairStructTree(page *semantic.Page, structTree *semantic.StructureTree)

RepairStructTree removes references to MCIDs that no longer exist on the page.

func (*EditorImpl) ReplaceText

func (e *EditorImpl) ReplaceText(ctx context.Context, page *semantic.Page, oldText, newText string) error

type OpSpatialIndex

type OpSpatialIndex struct {
	// contains filtered or unexported fields
}

func NewOpSpatialIndex

func NewOpSpatialIndex(pageBounds semantic.Rectangle) *OpSpatialIndex

func (*OpSpatialIndex) Index

func (idx *OpSpatialIndex) Index(ops []semantic.Operation, resources *semantic.Resources) error

func (*OpSpatialIndex) Query

func (idx *OpSpatialIndex) Query(rect semantic.Rectangle) []int

type PointData

type PointData struct {
	Rect  semantic.Rectangle
	Index int
}

type QuadTree

type QuadTree struct {
	Bounds   semantic.Rectangle
	Capacity int
	Points   []PointData
	Nodes    []*QuadTree
}

QuadTree implements a spatial index for rectangles.

func NewQuadTree

func NewQuadTree(bounds semantic.Rectangle, capacity int) *QuadTree

func (*QuadTree) Insert

func (qt *QuadTree) Insert(rect semantic.Rectangle, index int) bool

func (*QuadTree) Query

func (qt *QuadTree) Query(rangeRect semantic.Rectangle) []int

type SpatialIndex

type SpatialIndex interface {
	// Index indexes the operations of a page.
	Index(ops []semantic.Operation, resources *semantic.Resources) error

	// Query returns operations that intersect with the given rectangle.
	Query(rect semantic.Rectangle) []int // Returns indices of operations
}

SpatialIndex indexes content stream operations by their bounding box.

Jump to

Keyboard shortcuts

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