Skip to main content

Editor

Struct Editor 

Source
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

Source

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.

Source

pub fn delete_annotation(&mut self, id: &AnnotationId)

Delete an annotation by id.

Source

pub fn delete_selected(&mut self)

Delete all selected annotations.

Source

pub fn move_annotation(&mut self, id: &AnnotationId, dx: f64, dy: f64)

Move an annotation by (dx, dy).

Source

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).

Source

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

Source

pub fn set_annotation_color(&mut self, id: &AnnotationId, color: Color)

Set the primary color.

Source

pub fn set_annotation_width(&mut self, id: &AnnotationId, width: f64)

Set the stroke width (Freehand/Shape).

Source

pub fn insert_text(&mut self, id: &AnnotationId, offset: usize, chars: &str)

Insert text into a text annotation (TextBox/Note/Watermark) at char offset.

Source

pub fn delete_text(&mut self, id: &AnnotationId, offset: usize, len: usize)

Delete len chars from a text annotation at char offset.

Source

pub fn set_annotation_text(&mut self, id: &AnnotationId, text: &str)

Replace the whole text content.

Source

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

Source

pub fn new() -> Self

Source

pub fn load_document(&mut self, doc: OfdDocument)

Source

pub fn set_clock(&mut self, author: String, ts: i64)

Caller-supplied author + timestamp. The library never reads a system clock.

Source

pub fn document(&self) -> &OfdDocument

Source

pub fn selection(&self) -> &AnnotationSelection

Source

pub fn text_cursor(&self) -> Option<&TextCursor>

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

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).

Source

pub fn select(&mut self, id: AnnotationId)

Select a single annotation by id.

Source

pub fn set_selection(&mut self, sel: AnnotationSelection)

Replace the current selection wholesale.

Source

pub fn clear_selection(&mut self)

Clear the selection.

Source

pub fn set_cursor(&mut self, annotation: AnnotationId, offset: usize)

Position the text cursor at offset within annotation.

Source

pub fn clear_cursor(&mut self)

Clear the text cursor.

Source

pub fn undo(&mut self) -> bool

Source

pub fn redo(&mut self) -> bool

Trait Implementations§

Source§

impl Default for Editor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Editor

§

impl !Sync for Editor

§

impl !UnwindSafe for Editor

§

impl Forget for Editor

§

impl Freeze for Editor

§

impl Move for Editor

§

impl Send for Editor

§

impl Unpin for Editor

§

impl UnsafeUnpin for Editor

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.