pub struct Editor { /* private fields */ }Expand description
Annotation editor. Owns the document; mutates only .annotations via commands.
No callbacks - the host/component layer queries state after commands.
Implementations§
Source§impl Editor
impl Editor
Sourcepub fn create_annotation(
&mut self,
kind: AnnotationKind,
page: PageId,
payload: AnnotationPayload,
) -> AnnotationId
pub fn create_annotation( &mut self, kind: AnnotationKind, page: PageId, payload: AnnotationPayload, ) -> AnnotationId
Create an annotation. Returns the new id. Stamps created/modified from current_ts + author.
Sourcepub fn delete_annotation(&mut self, id: &AnnotationId)
pub fn delete_annotation(&mut self, id: &AnnotationId)
Delete an annotation by id.
Sourcepub fn delete_selected(&mut self)
pub fn delete_selected(&mut self)
Delete all selected annotations.
Sourcepub fn move_annotation(&mut self, id: &AnnotationId, dx: f64, dy: f64)
pub fn move_annotation(&mut self, id: &AnnotationId, dx: f64, dy: f64)
Move an annotation by (dx, dy).
Sourcepub fn resize_annotation(&mut self, id: &AnnotationId, new_rect: Rect)
pub fn resize_annotation(&mut self, id: &AnnotationId, new_rect: Rect)
Resize an annotation to new_rect (rect-based payloads; no-op for Markup/Freehand).
Sourcepub fn move_annotation_vertex(
&mut self,
id: &AnnotationId,
index: usize,
new_point: (f64, f64),
)
pub fn move_annotation_vertex( &mut self, id: &AnnotationId, index: usize, new_point: (f64, f64), )
Move a single vertex of a point-based Shape annotation (Line/Arrow/
Polygon/PolyLine). index is the vertex position in payload.points;
new_point is page-local. Rect/Ellipse and non-Shape payloads are a
no-op (no history entry). Spec §4.2: vertex drag.
Source§impl Editor
impl Editor
Sourcepub fn set_annotation_color(&mut self, id: &AnnotationId, color: Color)
pub fn set_annotation_color(&mut self, id: &AnnotationId, color: Color)
Set the primary color.
Sourcepub fn set_annotation_width(&mut self, id: &AnnotationId, width: f64)
pub fn set_annotation_width(&mut self, id: &AnnotationId, width: f64)
Set the stroke width (Freehand/Shape).
Sourcepub fn insert_text(&mut self, id: &AnnotationId, offset: usize, chars: &str)
pub fn insert_text(&mut self, id: &AnnotationId, offset: usize, chars: &str)
Insert text into a text annotation (TextBox/Note/Watermark) at char offset.
Sourcepub fn delete_text(&mut self, id: &AnnotationId, offset: usize, len: usize)
pub fn delete_text(&mut self, id: &AnnotationId, offset: usize, len: usize)
Delete len chars from a text annotation at char offset.
Sourcepub fn set_annotation_text(&mut self, id: &AnnotationId, text: &str)
pub fn set_annotation_text(&mut self, id: &AnnotationId, text: &str)
Replace the whole text content.
Sourcepub fn reply_to(&mut self, parent: &AnnotationId, content: &str) -> AnnotationId
pub fn reply_to(&mut self, parent: &AnnotationId, content: &str) -> AnnotationId
Reply to an annotation (creates a Note with reply_to set).
Source§impl Editor
impl Editor
pub fn new() -> Self
pub fn load_document(&mut self, doc: OfdDocument)
Sourcepub fn set_clock(&mut self, author: String, ts: i64)
pub fn set_clock(&mut self, author: String, ts: i64)
Caller-supplied author + timestamp. The library never reads a system clock.
pub fn document(&self) -> &OfdDocument
pub fn selection(&self) -> &AnnotationSelection
pub fn text_cursor(&self) -> Option<&TextCursor>
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
Number of undoable transactions on the history stack. Mainly for testing (e.g. asserting a drag pushes exactly one Transaction).
Sourcepub fn select(&mut self, id: AnnotationId)
pub fn select(&mut self, id: AnnotationId)
Select a single annotation by id.
Sourcepub fn set_selection(&mut self, sel: AnnotationSelection)
pub fn set_selection(&mut self, sel: AnnotationSelection)
Replace the current selection wholesale.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection.
Sourcepub fn set_cursor(&mut self, annotation: AnnotationId, offset: usize)
pub fn set_cursor(&mut self, annotation: AnnotationId, offset: usize)
Position the text cursor at offset within annotation.
Sourcepub fn clear_cursor(&mut self)
pub fn clear_cursor(&mut self)
Clear the text cursor.