Skip to main content

BlockEditorState

Struct BlockEditorState 

Source
pub struct BlockEditorState { /* private fields */ }

Implementations§

Source§

impl BlockEditorState

Source

pub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self

Create an editor holding one empty paragraph.

Source

pub fn with_submit_policy(self, policy: SubmitPolicy) -> Self

Source

pub fn set_submit_policy(&mut self, policy: SubmitPolicy)

Replace the policy; notify the editor after changing it so the retained view’s policy-scoped key context is refreshed.

Source

pub fn with_clipboard_policy(self, policy: ClipboardPolicy) -> Self

Source

pub fn set_clipboard_policy(&mut self, policy: ClipboardPolicy)

Source

pub fn scroll_handle(&self) -> Option<ScrollHandle>

The retained scroll owner; content-sized wrappers share this handle.

Source

pub fn with_input_rules( self, rules: impl IntoIterator<Item = InputRule>, ) -> Self

Builder: the Markdown input rules to run while typing (D13). The default is InputRule::markdown_defaults; pass an empty list to type Markdown literally.

Source

pub fn with_input_rule_filter( self, filter: impl Fn(InputRule, &str) -> bool + Send + Sync + 'static, ) -> Self

Pure policy invoked before an enabled input rule rewrites typed content. Return false when a host workflow (e.g. completion) owns the same sigil. Receives leaf-native text before the caret, never serialized offsets; must not perform I/O or re-enter the editor. Defaults to allowing rules.

Source

pub fn set_input_rules(&mut self, rules: impl IntoIterator<Item = InputRule>)

Replace the input rules (see Self::with_input_rules).

Source

pub fn set_task_checked( &mut self, block: BlockId, checked: bool, cx: &mut Context<'_, Self>, )

Check or uncheck the task item holding block (a list item or its text leaf); one undo step (D14). The selection is kept.

Source

pub fn with_source(self, source: &str) -> Self

Builder: initial Markdown.

Source

pub fn set_source( &mut self, source: &str, cx: &mut Context<'_, Self>, ) -> Result<(), SharedString>

Replace the content. No Changed event; clears history.

Source

pub fn source(&self) -> String

The document as canonical Markdown.

Source

pub fn source_snapshot(&self) -> SourceSnapshot

Shared canonical source, materialized at most once per revision.

Source

pub fn capture_caret(&self) -> Result<CapturedRange, CapturedRangeError>

Source

pub fn capture_selection(&self) -> Result<CapturedRange, CapturedRangeError>

Source

pub fn capture_suffix( &self, len: usize, ) -> Result<CapturedRange, CapturedRangeError>

Source

pub fn capture_leaf_range( &self, range: Range<usize>, ) -> Result<CapturedRange, CapturedRangeError>

Source

pub fn with_image_policy(self, policy: ImagePolicy) -> Self

Configure presentation/resource admission without mutating the document.

Source

pub fn set_image_policy( &mut self, policy: ImagePolicy, cx: &mut Context<'_, Self>, )

Source

pub fn image_policy(&self) -> ImagePolicy

Source

pub fn caret_prefix_snapshot(&self) -> Option<SharedString>

Source

pub fn caret_prefix(&self) -> Option<&str>

Source

pub fn is_capture_current(&self, range: &CapturedRange) -> bool

Source

pub fn replace_captured( &mut self, range: &mut CapturedRange, text: &str, cx: &mut Context<'_, Self>, ) -> Result<(), CapturedRangeError>

Source

pub fn select_end( &mut self, cx: &mut Context<'_, Self>, ) -> Result<(), SelectionError>

Source

pub fn reveal_caret(&mut self, cx: &mut Context<'_, Self>)

Reveal the current caret after viewport/layout changes without moving it.

Source

pub fn invalidate_captures(&mut self)

Fence host callbacks on external owner changes without reparsing content.

Source

pub fn is_composing(&self) -> bool

Source

pub fn model(&self) -> &BlockEditorModel

The headless model (document, selection, history).

Source

pub fn revision(&self) -> u64

Document revision; bumped by every committed transaction.

Source

pub fn selection(&self) -> &BlockSelection

The current selection.

Source

pub fn block_kind_at_caret(&self) -> Option<BlockKind>

Kind of the text block holding the caret, if any.

Source

pub fn set_editor_style( &mut self, style: BlockEditorStyle, cx: &mut Context<'_, Self>, )

Override caret, selection and composition colours (BlockEditorStyle).

Source

pub fn editor_style(&self) -> &BlockEditorStyle

The editor style overrides in effect.

Source

pub fn set_scroll_handle(&mut self, handle: ScrollHandle)

The scroll container the editor sits in (its track_scroll handle). With one set, the caret is scrolled into view after it moves; blocks outside the container’s visible area are culled either way.

Source

pub fn is_readonly(&self) -> bool

Whether edits are blocked (navigation and selection still work).

Source

pub fn set_readonly(&mut self, readonly: bool, cx: &mut Context<'_, Self>)

Block or allow edits.

Source

pub fn focus(&self, window: &mut Window, cx: &mut App)

Focus the editor.

Source

pub fn set_selection( &mut self, selection: BlockSelection, cx: &mut Context<'_, Self>, ) -> Result<(), SelectionError>

Set the selection; emits SelectionChanged.

Source

pub fn run( &mut self, command: EditorCommand, cx: &mut Context<'_, Self>, ) -> Result<bool, CommandError>

Run a model command as one transaction.

Source

pub fn undo(&mut self, cx: &mut Context<'_, Self>)

Undo the last transaction (or IME composition) group.

Source

pub fn redo(&mut self, cx: &mut Context<'_, Self>)

Redo the last undone group.

The link drawn under the window point at: its leaf, byte range and url.

The url of the link under the mouse, if any (D14 hover).

The url of the link at the caret (or the selection start).

Cmd/Ctrl+K: ask the host for its link popover.

Add, change (Some(url)) or remove (None) the link on the selection, or on the whole link at a collapsed caret. One undo step.

Source

pub fn table_delete_edit(&self) -> Option<TableEdit>

What Cmd/Ctrl+Alt+Backspace does here (None: nothing).

Source

pub fn paste( &mut self, item: ClipboardItem, plain: bool, cx: &mut Context<'_, Self>, )

Deliver semantic clipboard content. plain bypasses Markdown import. With Host policy this emits one request; there is no fallback insertion until the owner resolves it, so mixed image/text entries cannot double insert. This method itself never reads the system clipboard.

Source

pub fn is_paste_current(&self, request: &PasteRequest) -> bool

Resolve an intercepted paste with text not consumed by the host’s other admissions (e.g. image attachments). None means wholly handled or rejected. Returns false when navigation/edits made the request stale.

Source

pub fn apply_paste( &mut self, request: &PasteRequest, text: Option<&str>, cx: &mut Context<'_, Self>, ) -> bool

Source§

impl BlockEditorState

Source

pub fn table_grips_at( &self, at: Point<Pixels>, ) -> Vec<(BlockId, TableLine, Bounds<Pixels>)>

The grips to show for the pointer at at: the hovered column’s grip above its header cell and the hovered row’s grip at its left edge. Column and row boxes come from the frame’s rebuilt table grid (FrameLayout::layout_tables), so they match the drawn cells for every alignment, after scrolling and resizing.

Source

pub fn open_table_menu( &mut self, table: BlockId, line: TableLine, grip: Bounds<Pixels>, cx: &mut Context<'_, Self>, )

Select line of table and open its menu below / beside grip.

Source

pub fn open_table_menu_for( &mut self, table: BlockId, line: TableLine, cx: &mut Context<'_, Self>, )

Open the menu of line of table (the grip position from the last frame). For tests and hosts that drive the menu themselves.

Source

pub fn table_menu_anchor(&self) -> Option<Point<Pixels>>

Where the open menu hangs from (window coordinates).

Source

pub fn table_menu_open(&self) -> bool

Source

pub fn table_menu_action(&mut self, edit: TableEdit, cx: &mut Context<'_, Self>)

Run a menu entry on the menu’s row / column (one undo step) and close the menu, except for alignment, which keeps it open to show the change.

Trait Implementations§

Source§

impl EntityInputHandler for BlockEditorState

Source§

fn text_for_range( &mut self, range16: Range<usize>, adjusted: &mut Option<Range<usize>>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<String>

Source§

fn selected_text_range( &mut self, _: bool, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<UTF16Selection>

Source§

fn marked_text_range( &self, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<Range<usize>>

Source§

fn unmark_text(&mut self, _: &mut Window, _: &mut Context<'_, Self>)

Source§

fn paste( &mut self, item: ClipboardItem, _: &mut Window, cx: &mut Context<'_, Self>, )

See InputHandler::paste for details
Source§

fn replace_text_in_range( &mut self, range16: Option<Range<usize>>, text: &str, _: &mut Window, cx: &mut Context<'_, Self>, )

Source§

fn replace_and_mark_text_in_range( &mut self, range16: Option<Range<usize>>, new_text: &str, new_selected16: Option<Range<usize>>, _: &mut Window, cx: &mut Context<'_, Self>, )

Source§

fn bounds_for_range( &mut self, range16: Range<usize>, _: Bounds<Pixels>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>

Source§

fn character_index_for_point( &mut self, at: Point<Pixels>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<usize>

Source§

fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, )

Source§

fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>

Source§

fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool

Source§

fn text_input_configuration( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> TextInputConfiguration

Source§

fn text_input_editable_range( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>

Source§

impl EventEmitter<BlockEditorEvent> for BlockEditorState

Source§

impl Focusable for BlockEditorState

Source§

fn focus_handle(&self, _: &App) -> FocusHandle

Returns the focus handle associated with this view.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more