pub struct TextBlock { /* private fields */ }Expand description
A lightweight, read-only handle to a single block (paragraph).
Holds a stable entity ID — the handle remains valid across edits
that insert or remove other blocks. Each method acquires the
document lock independently. For consistent reads across multiple
fields, use snapshot().
Implementations§
Source§impl TextBlock
impl TextBlock
Sourcepub fn block_number(&self) -> usize
pub fn block_number(&self) -> usize
Global 0-indexed block number. O(n): requires scanning all blocks
sorted by document_position. Prefer id() for
identity and position() for ordering.
Sourcepub fn next(&self) -> Option<TextBlock>
pub fn next(&self) -> Option<TextBlock>
The next block in document order. O(n).
Returns None if this is the last block.
Sourcepub fn previous(&self) -> Option<TextBlock>
pub fn previous(&self) -> Option<TextBlock>
The previous block in document order. O(n).
Returns None if this is the first block.
Sourcepub fn table_cell(&self) -> Option<TableCellRef>
pub fn table_cell(&self) -> Option<TableCellRef>
If inside a table cell, returns table and cell coordinates.
Finds the block’s parent frame, then checks if any table cell
references that frame as its cell_frame. If so, identifies the
owning table.
Sourcepub fn block_format(&self) -> BlockFormat
pub fn block_format(&self) -> BlockFormat
Block format (alignment, margins, indent, heading level, marker, tabs). O(1).
Sourcepub fn char_format_at(&self, offset: usize) -> Option<TextFormat>
pub fn char_format_at(&self, offset: usize) -> Option<TextFormat>
Character format at a block-relative character offset. O(k) where k = number of InlineElements.
Returns the TextFormat of the fragment containing the given
offset. Returns None if the offset is out of range or the
block has no fragments.
Sourcepub fn fragments(&self) -> Vec<FragmentContent>
pub fn fragments(&self) -> Vec<FragmentContent>
All formatting runs in one call. O(k) where k = number of InlineElements.
Sourcepub fn list_item_index(&self) -> Option<usize>
pub fn list_item_index(&self) -> Option<usize>
0-based position within its list. O(n) where n = total blocks.
Sourcepub fn snapshot(&self) -> BlockSnapshot
pub fn snapshot(&self) -> BlockSnapshot
All layout-relevant data in one lock acquisition. O(k+n).