pub struct TocState {
pub scroll_offset: usize,
pub hovered_entry: Option<usize>,
pub hovered: bool,
pub entries: Vec<TocEntry>,
}Expand description
State for the Table of Contents sidebar.
Manages scroll position, hover state, and TOC entries.
Fields§
§scroll_offset: usizeCurrent scroll offset within the TOC.
hovered_entry: Option<usize>Index of the currently hovered entry, if any.
hovered: boolWhether the TOC itself is hovered.
entries: Vec<TocEntry>List of TOC entries extracted from the document.
Implementations§
Source§impl TocState
Entry management methods for TocState.
impl TocState
Entry management methods for TocState.
Sourcepub fn entries(&self) -> &[TocEntry]
Available on crate feature markdown-preview only.
pub fn entries(&self) -> &[TocEntry]
markdown-preview only.Get all TOC entries.
Sourcepub fn set_entries(&mut self, entries: Vec<TocEntry>)
Available on crate feature markdown-preview only.
pub fn set_entries(&mut self, entries: Vec<TocEntry>)
markdown-preview only.Set the TOC entries.
Sourcepub fn clear_entries(&mut self)
Available on crate feature markdown-preview only.
pub fn clear_entries(&mut self)
markdown-preview only.Clear all TOC entries.
Sourcepub fn entry_count(&self) -> usize
Available on crate feature markdown-preview only.
pub fn entry_count(&self) -> usize
markdown-preview only.Get the number of entries.
Sourcepub fn get_entry(&self, index: usize) -> Option<&TocEntry>
Available on crate feature markdown-preview only.
pub fn get_entry(&self, index: usize) -> Option<&TocEntry>
markdown-preview only.Get an entry by index.
Sourcepub fn has_entries(&self) -> bool
Available on crate feature markdown-preview only.
pub fn has_entries(&self) -> bool
markdown-preview only.Check if the TOC has any entries.
Source§impl TocState
Extract TOC entries from markdown content.
impl TocState
Extract TOC entries from markdown content.
Sourcepub fn from_content(content: &str) -> TocState
Available on crate feature markdown-preview only.
pub fn from_content(content: &str) -> TocState
markdown-preview only.Sourcepub fn update_from_content(&mut self, content: &str)
Available on crate feature markdown-preview only.
pub fn update_from_content(&mut self, content: &str)
markdown-preview only.Source§impl TocState
Hover methods for TocState.
impl TocState
Hover methods for TocState.
Sourcepub fn is_hovered(&self) -> bool
Available on crate feature markdown-preview only.
pub fn is_hovered(&self) -> bool
markdown-preview only.Check if the TOC is currently hovered.
Sourcepub fn set_hovered(&mut self, hovered: bool)
Available on crate feature markdown-preview only.
pub fn set_hovered(&mut self, hovered: bool)
markdown-preview only.Set the hover state of the TOC.
Sourcepub fn hovered_entry(&self) -> Option<usize>
Available on crate feature markdown-preview only.
pub fn hovered_entry(&self) -> Option<usize>
markdown-preview only.Get the currently hovered entry index, if any.
Sourcepub fn set_hovered_entry(&mut self, index: Option<usize>)
Available on crate feature markdown-preview only.
pub fn set_hovered_entry(&mut self, index: Option<usize>)
markdown-preview only.Set the hovered entry index.
Sourcepub fn is_entry_hovered(&self, index: usize) -> bool
Available on crate feature markdown-preview only.
pub fn is_entry_hovered(&self, index: usize) -> bool
markdown-preview only.Check if a specific entry is hovered.
Source§impl TocState
Scroll methods for TocState.
impl TocState
Scroll methods for TocState.
Sourcepub fn scroll_offset(&self) -> usize
Available on crate feature markdown-preview only.
pub fn scroll_offset(&self) -> usize
markdown-preview only.Get the current scroll offset.
Sourcepub fn set_scroll_offset(&mut self, offset: usize)
Available on crate feature markdown-preview only.
pub fn set_scroll_offset(&mut self, offset: usize)
markdown-preview only.Set the scroll offset.
Sourcepub fn scroll_up(&mut self, amount: usize)
Available on crate feature markdown-preview only.
pub fn scroll_up(&mut self, amount: usize)
markdown-preview only.Scroll up by a given amount, clamping at 0.
Sourcepub fn scroll_down(&mut self, amount: usize)
Available on crate feature markdown-preview only.
pub fn scroll_down(&mut self, amount: usize)
markdown-preview only.Scroll down by a given amount, clamping at max entries.
Sourcepub fn scroll_to_top(&mut self)
Available on crate feature markdown-preview only.
pub fn scroll_to_top(&mut self)
markdown-preview only.Scroll to the top.
Sourcepub fn scroll_to_bottom(&mut self)
Available on crate feature markdown-preview only.
pub fn scroll_to_bottom(&mut self)
markdown-preview only.Scroll to the bottom.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TocState
impl RefUnwindSafe for TocState
impl Send for TocState
impl Sync for TocState
impl Unpin for TocState
impl UnsafeUnpin for TocState
impl UnwindSafe for TocState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more