Skip to main content

Capabilities

Struct Capabilities 

Source
pub struct Capabilities {
Show 20 fields pub bold: bool, pub italic: bool, pub code: bool, pub mark: bool, pub underline: bool, pub strike: bool, pub superscript: bool, pub subscript: bool, pub heading: bool, pub blockquote: bool, pub bullet_list: bool, pub ordered_list: bool, pub task: bool, pub link: bool, pub image: bool, pub thematic_break: bool, pub footnote: bool, pub code_language: bool, pub table: bool, pub cell_line_break: bool,
}
Expand description

Which of leaf’s authoring controls this document’s format can actually spell — one flag per toolbar button, resolved once so a frontend can build its chrome instead of discovering each refusal on a click.

Every field but table is Format::supports on the gesture the matching Doc method calls, so this record cannot drift from what the ops do; table is [spells_pipe_tables], the one answer twig doesn’t export.

The formats are ragged, and that is the point. A single per-document boolean was enough while the two authorable formats were Markdown and djot and everything else spelled nothing. HTML is neither: it writes seven of the eight inline marks as a tag pair, plus <code>, <hr> and an in-cell <br>, and spells no heading marker, no line prefix, no fence, no task box, no link — because its versions of those have a different shape, not a different alphabet. So ⌘B works in an HTML document and ⌘1 does not, and no one flag can say that. Markdown and djot differ from each other too: ==mark== is djot-only, and an in-cell <br> is Markdown-only.

Fields§

§bold: bool

⌘B — InlineKind::Strong.

§italic: bool

⌘I — InlineKind::Emph.

§code: bool

Inline code — InlineKind::Verbatim.

§mark: bool

Highlight — InlineKind::Mark. Djot spells it; Markdown does not.

§underline: bool

⌘U — InlineKind::Insert, which every format that marks at all spells.

§strike: bool

Strikethrough — InlineKind::Delete.

§superscript: bool§subscript: bool§heading: bool

Heading levels and “make this a paragraph” — Doc::set_block.

§blockquote: bool§bullet_list: bool§ordered_list: bool§task: bool

The checkbox controls: giving an item a box, and ticking one.

§link: bool§image: bool

Covers Doc::insert_media too — see the note there on why the three media kinds stand or fall together.

§thematic_break: bool

The horizontal-rule button. HTML spells this one (<hr>).

§footnote: bool

The footnote button — Doc::insert_footnote. Markdown and djot spell the pair; HTML has no footnote of its own, so the button goes away rather than writing brackets that would render as brackets.

§code_language: bool

Setting a fenced block’s language — a control only ever offered with the caret already in a fence.

§table: bool

The grid controls: insert/delete/move a row or column, set a column’s alignment. Pair with Doc::caret_in_table, which asks the other question — an HTML <table> holds the caret and still can’t be edited.

§cell_line_break: bool

Shift+Return inside a cell. Markdown and HTML spell it; djot has no idiomatic in-cell break.

Implementations§

Source§

impl Capabilities

Source

pub fn of(format: Format) -> Self

Resolve every flag for format. Pure and cheap — twig computes each from a static table — but a frontend that wants to hold them can.

Trait Implementations§

Source§

impl Clone for Capabilities

Source§

fn clone(&self) -> Capabilities

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Capabilities

Source§

impl Debug for Capabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Capabilities

Source§

impl PartialEq for Capabilities

Source§

fn eq(&self, other: &Capabilities) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Capabilities

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.