pub struct BlockEditorState { /* private fields */ }Implementations§
Source§impl BlockEditorState
impl BlockEditorState
Sourcepub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self
pub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self
Create an editor holding one empty paragraph.
pub fn with_submit_policy(self, policy: SubmitPolicy) -> Self
Sourcepub fn set_submit_policy(&mut self, policy: SubmitPolicy)
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.
pub fn with_clipboard_policy(self, policy: ClipboardPolicy) -> Self
pub fn set_clipboard_policy(&mut self, policy: ClipboardPolicy)
Sourcepub fn scroll_handle(&self) -> Option<ScrollHandle>
pub fn scroll_handle(&self) -> Option<ScrollHandle>
The retained scroll owner; content-sized wrappers share this handle.
Sourcepub fn with_input_rules(
self,
rules: impl IntoIterator<Item = InputRule>,
) -> Self
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.
Sourcepub fn with_input_rule_filter(
self,
filter: impl Fn(InputRule, &str) -> bool + Send + Sync + 'static,
) -> Self
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.
Sourcepub fn set_input_rules(&mut self, rules: impl IntoIterator<Item = InputRule>)
pub fn set_input_rules(&mut self, rules: impl IntoIterator<Item = InputRule>)
Replace the input rules (see Self::with_input_rules).
Sourcepub fn set_task_checked(
&mut self,
block: BlockId,
checked: bool,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn with_source(self, source: &str) -> Self
pub fn with_source(self, source: &str) -> Self
Builder: initial Markdown.
Sourcepub fn set_source(
&mut self,
source: &str,
cx: &mut Context<'_, Self>,
) -> Result<(), SharedString>
pub fn set_source( &mut self, source: &str, cx: &mut Context<'_, Self>, ) -> Result<(), SharedString>
Replace the content. No Changed event; clears history.
Sourcepub fn source_snapshot(&self) -> SourceSnapshot
pub fn source_snapshot(&self) -> SourceSnapshot
Shared canonical source, materialized at most once per revision.
pub fn capture_caret(&self) -> Result<CapturedRange, CapturedRangeError>
pub fn capture_selection(&self) -> Result<CapturedRange, CapturedRangeError>
pub fn capture_suffix( &self, len: usize, ) -> Result<CapturedRange, CapturedRangeError>
pub fn capture_leaf_range( &self, range: Range<usize>, ) -> Result<CapturedRange, CapturedRangeError>
Sourcepub fn with_image_policy(self, policy: ImagePolicy) -> Self
pub fn with_image_policy(self, policy: ImagePolicy) -> Self
Configure presentation/resource admission without mutating the document.
pub fn set_image_policy( &mut self, policy: ImagePolicy, cx: &mut Context<'_, Self>, )
pub fn image_policy(&self) -> ImagePolicy
pub fn caret_prefix_snapshot(&self) -> Option<SharedString>
pub fn caret_prefix(&self) -> Option<&str>
pub fn is_capture_current(&self, range: &CapturedRange) -> bool
pub fn replace_captured( &mut self, range: &mut CapturedRange, text: &str, cx: &mut Context<'_, Self>, ) -> Result<(), CapturedRangeError>
pub fn select_end( &mut self, cx: &mut Context<'_, Self>, ) -> Result<(), SelectionError>
Sourcepub fn reveal_caret(&mut self, cx: &mut Context<'_, Self>)
pub fn reveal_caret(&mut self, cx: &mut Context<'_, Self>)
Reveal the current caret after viewport/layout changes without moving it.
Sourcepub fn invalidate_captures(&mut self)
pub fn invalidate_captures(&mut self)
Fence host callbacks on external owner changes without reparsing content.
pub fn is_composing(&self) -> bool
Sourcepub fn model(&self) -> &BlockEditorModel
pub fn model(&self) -> &BlockEditorModel
The headless model (document, selection, history).
Sourcepub fn selection(&self) -> &BlockSelection
pub fn selection(&self) -> &BlockSelection
The current selection.
Sourcepub fn block_kind_at_caret(&self) -> Option<BlockKind>
pub fn block_kind_at_caret(&self) -> Option<BlockKind>
Kind of the text block holding the caret, if any.
Sourcepub fn set_editor_style(
&mut self,
style: BlockEditorStyle,
cx: &mut Context<'_, Self>,
)
pub fn set_editor_style( &mut self, style: BlockEditorStyle, cx: &mut Context<'_, Self>, )
Override caret, selection and composition colours (BlockEditorStyle).
Sourcepub fn editor_style(&self) -> &BlockEditorStyle
pub fn editor_style(&self) -> &BlockEditorStyle
The editor style overrides in effect.
Sourcepub fn set_scroll_handle(&mut self, handle: ScrollHandle)
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.
Sourcepub fn is_readonly(&self) -> bool
pub fn is_readonly(&self) -> bool
Whether edits are blocked (navigation and selection still work).
Sourcepub fn set_readonly(&mut self, readonly: bool, cx: &mut Context<'_, Self>)
pub fn set_readonly(&mut self, readonly: bool, cx: &mut Context<'_, Self>)
Block or allow edits.
Sourcepub fn set_selection(
&mut self,
selection: BlockSelection,
cx: &mut Context<'_, Self>,
) -> Result<(), SelectionError>
pub fn set_selection( &mut self, selection: BlockSelection, cx: &mut Context<'_, Self>, ) -> Result<(), SelectionError>
Set the selection; emits SelectionChanged.
Sourcepub fn run(
&mut self,
command: EditorCommand,
cx: &mut Context<'_, Self>,
) -> Result<bool, CommandError>
pub fn run( &mut self, command: EditorCommand, cx: &mut Context<'_, Self>, ) -> Result<bool, CommandError>
Run a model command as one transaction.
Sourcepub fn undo(&mut self, cx: &mut Context<'_, Self>)
pub fn undo(&mut self, cx: &mut Context<'_, Self>)
Undo the last transaction (or IME composition) group.
Sourcepub fn link_at(
&self,
at: Point<Pixels>,
) -> Option<(BlockId, Range<usize>, SharedString)>
pub fn link_at( &self, at: Point<Pixels>, ) -> Option<(BlockId, Range<usize>, SharedString)>
The link drawn under the window point at: its leaf, byte range
and url.
Sourcepub fn hovered_link(&self) -> Option<&SharedString>
pub fn hovered_link(&self) -> Option<&SharedString>
The url of the link under the mouse, if any (D14 hover).
Sourcepub fn link_at_caret(&self) -> Option<SharedString>
pub fn link_at_caret(&self) -> Option<SharedString>
The url of the link at the caret (or the selection start).
Sourcepub fn request_link_edit(&mut self, cx: &mut Context<'_, Self>)
pub fn request_link_edit(&mut self, cx: &mut Context<'_, Self>)
Cmd/Ctrl+K: ask the host for its link popover.
Sourcepub fn set_link(&mut self, url: Option<&str>, cx: &mut Context<'_, Self>)
pub fn set_link(&mut self, url: Option<&str>, cx: &mut Context<'_, Self>)
Add, change (Some(url)) or remove (None) the link on the
selection, or on the whole link at a collapsed caret. One undo step.
Sourcepub fn table_delete_edit(&self) -> Option<TableEdit>
pub fn table_delete_edit(&self) -> Option<TableEdit>
What Cmd/Ctrl+Alt+Backspace does here (None: nothing).
Sourcepub fn paste(
&mut self,
item: ClipboardItem,
plain: bool,
cx: &mut Context<'_, Self>,
)
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.
Sourcepub fn is_paste_current(&self, request: &PasteRequest) -> bool
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.
pub fn apply_paste( &mut self, request: &PasteRequest, text: Option<&str>, cx: &mut Context<'_, Self>, ) -> bool
Source§impl BlockEditorState
impl BlockEditorState
Sourcepub fn table_grips_at(
&self,
at: Point<Pixels>,
) -> Vec<(BlockId, TableLine, Bounds<Pixels>)>
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.
Select line of table and open its menu below / beside grip.
Open the menu of line of table (the grip position from the last
frame). For tests and hosts that drive the menu themselves.
Where the open menu hangs from (window coordinates).
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
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>
fn text_for_range( &mut self, range16: Range<usize>, adjusted: &mut Option<Range<usize>>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<String>
InputHandler::text_for_range for detailsSource§fn selected_text_range(
&mut self,
_: bool,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<UTF16Selection>
fn selected_text_range( &mut self, _: bool, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<UTF16Selection>
InputHandler::selected_text_range for detailsSource§fn marked_text_range(
&self,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn marked_text_range( &self, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<Range<usize>>
InputHandler::marked_text_range for detailsSource§fn unmark_text(&mut self, _: &mut Window, _: &mut Context<'_, Self>)
fn unmark_text(&mut self, _: &mut Window, _: &mut Context<'_, Self>)
InputHandler::unmark_text for detailsSource§fn paste(
&mut self,
item: ClipboardItem,
_: &mut Window,
cx: &mut Context<'_, Self>,
)
fn paste( &mut self, item: ClipboardItem, _: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::paste for detailsSource§fn replace_text_in_range(
&mut self,
range16: Option<Range<usize>>,
text: &str,
_: &mut Window,
cx: &mut Context<'_, Self>,
)
fn replace_text_in_range( &mut self, range16: Option<Range<usize>>, text: &str, _: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::replace_text_in_range for detailsSource§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>,
)
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>, )
InputHandler::replace_and_mark_text_in_range for detailsSource§fn bounds_for_range(
&mut self,
range16: Range<usize>,
_: Bounds<Pixels>,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<Bounds<Pixels>>
fn bounds_for_range( &mut self, range16: Range<usize>, _: Bounds<Pixels>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>
InputHandler::bounds_for_range for detailsSource§fn character_index_for_point(
&mut self,
at: Point<Pixels>,
_: &mut Window,
_: &mut Context<'_, Self>,
) -> Option<usize>
fn character_index_for_point( &mut self, at: Point<Pixels>, _: &mut Window, _: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::character_index_for_point for detailsSource§fn set_selected_text_range(
&mut self,
_range_utf16: Range<usize>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
)
fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, )
InputHandler::set_selected_text_range for detailsSource§fn text_length_utf16(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<usize>
fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::text_length_utf16 for detailsSource§fn accepts_text_input(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> bool
fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool
InputHandler::accepts_text_input for detailsSource§fn text_input_configuration(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> TextInputConfiguration
fn text_input_configuration( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> TextInputConfiguration
InputHandler::text_input_configuration for detailsSource§fn text_input_editable_range(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn text_input_editable_range( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>
InputHandler::text_input_editable_range for detailsimpl EventEmitter<BlockEditorEvent> for BlockEditorState
Source§impl Focusable for BlockEditorState
impl Focusable for BlockEditorState
Source§fn focus_handle(&self, _: &App) -> FocusHandle
fn focus_handle(&self, _: &App) -> FocusHandle
Auto Trait Implementations§
impl !Freeze for BlockEditorState
impl !RefUnwindSafe for BlockEditorState
impl !Send for BlockEditorState
impl !Sync for BlockEditorState
impl !UnwindSafe for BlockEditorState
impl Unpin for BlockEditorState
impl UnsafeUnpin for BlockEditorState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> 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