Skip to main content

CodeNode

Struct CodeNode 

Source
pub struct CodeNode { /* private fields */ }
Expand description

CodeNode: a code block, holding CodeHighlightNodes, tabs and line breaks.

Implementations§

Source§

impl CodeNode

Source

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

__language.

Source

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

__theme.

Source

pub fn is_syntax_highlight_supported(&self) -> bool

__isSyntaxHighlightSupported.

Trait Implementations§

Source§

impl Clone for CodeNode

Source§

fn clone(&self) -> Self

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 Debug for CodeNode

Source§

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

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

impl Default for CodeNode

Source§

fn default() -> Self

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

impl LexicalNode for CodeNode

Source§

fn static_node_config_chain(&self) -> Vec<NodeConfigLink>

The $config() of CodeNode: children: 'inline'.

Source§

fn create_dom( &self, _this: &NodeRef, config: &EditorConfig, _editor: &Editor, ) -> Result<DomNode, LexicalError>

CodeNode.createDOM(config): a <code>.

Source§

fn export_dom( &self, _this: &NodeRef, editor: &Editor, ) -> Result<DomExportOutput, LexicalError>

CodeNode.exportDOM(editor): a <pre>, with what createDOM writes and without the indent and direction.

Source§

fn can_indent(&self) -> bool

CodeNode.canIndent().

Source§

fn insert_new_after( &self, _: &NodeRef, selection: &SelectionRef, _: bool, ) -> Result<Option<NodeRef>, LexicalError>

CodeNode.insertNewAfter(selection, restoreSelection).

Source§

fn collapse_at_start( &self, this: &NodeRef, _: &SelectionRef, ) -> Result<bool, LexicalError>

CodeNode.collapseAtStart(): the block becomes a paragraph with its children.

Source§

fn generated_export_json(&self, compact: bool) -> Option<Object>

exportCodeNode and exportCompactCodeNode.

Source§

fn generated_update_from_json(&mut self, json: &Object) -> bool

updateCodeNode.

Source§

fn json_schema_chain(&self) -> Vec<NodeSchema>

The json of the node’s $config() and of the classes it extends (iterStaticNodeConfigChain), most derived first: the serialization schemas composeSchema composes, a subclass’s declaration of a key winning. By default ElementNode’s for an element (element::element_node_schema), TextNode’s for a text node and DecoratorBlockNode’s for one; a class that declares its own returns it followed by those of the class it extends. The composed schema is compiled once per Rust type, so it must not differ between nodes.
Source§

fn get_type(&self) -> &'static str

getType(): the type the node serializes as.
Source§

fn import_dom(&self) -> Option<DomConversionMap>

The class’s static importDOM() (the html feature): the conversions it offers by DOM node name, or None.
Source§

fn base(&self) -> &NodeBase

Source§

fn base_mut(&mut self) -> &mut NodeBase

Source§

fn element(&self) -> Option<&ElementData>

The ElementNode fields, for a node that extends it.
Source§

fn element_mut(&mut self) -> Option<&mut ElementData>

Source§

fn text(&self) -> Option<&TextData>

The TextNode fields, for a node that extends it.
Source§

fn text_mut(&mut self) -> Option<&mut TextData>

Source§

fn decorator_block(&self) -> Option<&DecoratorBlockData>

The DecoratorBlockNode fields (@lexical/react), for a node that extends it: such a node is a decorator that is not inline and can’t be indented, unless it overrides those hooks.
Source§

fn decorator_block_mut(&mut self) -> Option<&mut DecoratorBlockData>

Source§

fn is_inline(&self) -> bool

isInline(): false for an element, true for text and a decorator (false for a DecoratorBlockNode). A class whose config chain declares inline (static_node_config_chain) returns the nearest declaration, as the isInline() JS synthesizes for a class that declares it does.
Source§

fn is_decorator(&self) -> bool

Whether the node extends DecoratorNode ($isDecoratorNode): a leaf whose content an app renders (decorate), which the editor moves, selects and deletes as one unit. False by default, but for a DecoratorBlockNode.
Source§

fn decorate(&self, editor: &Editor) -> Option<Rc<dyn Any>>

DecoratorNode.decorate(editor, config): the value an app’s renderer shows for the decorator, or None (the default). Once the editor has a root element, the reconciler calls it for each decorator it creates or reconciles and collects the values in Editor::get_decorators, which the decorator listeners hear of when they change. A value is the app’s own, type-erased (JS’s T, Swift’s Any), and compared by identity: returning the same Rc again changes nothing.
Source§

fn is_isolated(&self) -> bool

DecoratorNode.isIsolated(): whether the decorator is isolated from caret interaction (not traversed, extended over, selected as a node or deleted by an adjacent caret operation). False by default.
Source§

fn is_keyboard_selectable(&self) -> bool

DecoratorNode.isKeyboardSelectable(): whether moving the caret onto the decorator selects it as a node. True by default.
Source§

fn is_inline_formattable(&self) -> bool

$isInlineFormattable(node): whether the node carries a text format that formatting the selection changes (InlineFormattableNode): text, and a node with the __isInlineFormattable brand.
Source§

fn get_inline_format(&self) -> f64

InlineFormattableNode.getFormat().
Source§

fn set_inline_format( &self, this: &NodeRef, format: f64, ) -> Result<(), LexicalError>

InlineFormattableNode.setFormat(format) on this: a text node’s set_format.
Source§

fn is_shadow_root(&self) -> bool

ElementNode.isShadowRoot().
Source§

fn can_be_empty(&self) -> bool

ElementNode.canBeEmpty(): whether the element stays when its last child is removed.
Source§

fn can_merge_when_empty(&self) -> bool

ElementNode.canMergeWhenEmpty(): whether the element, when empty, takes the children of the first block insertNodes inserts.
Source§

fn is_parent_required(&self) -> bool

isParentRequired(): whether the node needs a parent of a certain kind (create_parent_element_node).
Source§

fn create_parent_element_node(&self) -> NodeRef

createParentElementNode(): a new parent for the node, a paragraph by default.
Source§

fn append(&self, this: &NodeRef, nodes: &[NodeRef]) -> Result<(), LexicalError>

ElementNode.append(...nodesToAppend) on the element this: inserts nodes after its last child, through splice.
Source§

fn splice( &self, this: &NodeRef, start: usize, delete_count: usize, nodes_to_insert: &[NodeRef], ) -> Result<(), LexicalError>

ElementNode.splice(start, deleteCount, nodesToInsert) on the element this; the default is ElementNode’s (element::splice).
Source§

fn replace( &self, this: &NodeRef, replace_with: &NodeRef, include_children: bool, ) -> Result<NodeRef, LexicalError>

replace(replaceWith, includeChildren) on this; the default is LexicalNode’s (node::replace).
Source§

fn insert_after( &self, this: &NodeRef, node_to_insert: &NodeRef, restore_selection: bool, ) -> Result<NodeRef, LexicalError>

insertAfter(nodeToInsert, restoreSelection) on this; the default is LexicalNode’s (node::insert_after).
Source§

fn remove( &self, this: &NodeRef, preserve_empty_parent: bool, ) -> Result<(), LexicalError>

remove(preserveEmptyParent) on this; the default is LexicalNode’s (node::remove).
Source§

fn get_indent(&self, this: &NodeRef) -> Result<f64, LexicalError>

ElementNode.getIndent() on the element this: its __indent.
Source§

fn set_indent(&self, this: &NodeRef, indent: f64) -> Result<(), LexicalError>

ElementNode.setIndent(indentLevel) on the element this: sets its __indent.
Source§

fn transform(&self, this: &NodeRef) -> Result<(), LexicalError>

The $transform of the node’s $config, which the editor runs on a dirty node before the transforms registered for its type (and before ElementNode’s own, which comes later in the class chain). None by default.
Source§

fn state_configs(&self) -> Vec<RequiredNodeStateConfig>

The stateConfigs of the node’s $config, its class’s and those it inherits: the NodeState its type knows before any node reads it. None by default.
Source§

fn reset_on_copy_node_from(&self, this: &NodeRef, original: &NodeRef)

resetOnCopyNodeFrom(originalNode) on this, the copy $copyNode just made of original, beyond LexicalNode’s, which resets the NodeState that asks for it ($copyNode does that first). Nothing by default.
Source§

fn extract_with_child( &self, this: &NodeRef, child: &NodeRef, selection: Option<&SelectionRef>, destination: &str, ) -> Result<bool, LexicalError>

ElementNode.extractWithChild(child, selection, destination) on the element this: whether copying child (to "clone" or "html") takes this element with it. ElementNode returns false. Nothing in the core calls it; @lexical/html’s copy does, and the overrides of ParagraphNode and HeadingNode come with it.
Source§

fn declared_slots(&self) -> &'static [&'static str]

The slots of the node’s $config() (getDeclaredSlots): the canonical order of its named slots, before the names it doesn’t declare. None by default.
Source§

fn declares_inline_children(&self) -> bool

Whether the children the class declares in its $config() (getDeclaredNodeStructure(klass).children) is 'inline' or a list that includes 'inline': a block that holds text. By default, what static_node_config_chain declares.
Source§

fn internal_after_structure_merge( &self, this: &NodeRef, last: &NodeRef, first: &NodeRef, ) -> Result<bool, LexicalError>

INTERNAL_$afterStructureMerge(last, first) on the element this (internal, for the node structure normalization): this has just merged its next sibling, and last (its last child before) and first (the sibling’s first child) meet at the seam. Returns whether the class has the hook (ListNode joins nested lists there). False by default.
Source§

fn internal_after_structure_split( &self, this: &NodeRef, original: &NodeRef, preceding: &[NodeRef], ) -> Result<(), LexicalError>

INTERNAL_$afterStructureSplit(original, preceding) on this, a copy of original that the node structure normalization split off it, after the content preceding (an ordered list continues its numbering). Nothing by default.
Source§

fn internal_lifts_from_structure(&self) -> Option<LiftsFromStructure>

INTERNAL_$liftsFromStructure: the holder’s hook for a child its declared children allow that the node structure normalization must still lift out, given what else it holds (a list item lifts a nested list that is not all it holds). None by default.
Source§

fn is_text_entity(&self) -> bool

TextNode.isTextEntity(): whether registerLexicalTextEntity (the text feature) treats the text node as an entity. False by default.
Source§

fn can_have_format(&self) -> bool

TextNode.canHaveFormat(): whether the text node can carry formats and styles that @lexical/selection applies to it. True by default.
Source§

fn exclude_from_copy(&self, destination: &str) -> bool

ElementNode.excludeFromCopy(destination): whether copying (to "clone" or "html") leaves this element out and keeps its children. ElementNode returns false. Nothing in the core calls it; @lexical/clipboard’s and @lexical/html’s copies do.
Source§

fn can_replace_with(&self, replacement: &NodeRef) -> bool

ElementNode.canReplaceWith(replacement) (deprecated and internal upstream): true by default. Nothing in the core calls it.
Source§

fn can_insert_after(&self, node: &NodeRef) -> bool

ElementNode.canInsertAfter(node) (deprecated and internal upstream): true by default. Nothing in the core calls it.
Source§

fn selection_transform( &self, this: &NodeRef, prev_selection: Option<&SelectionRef>, next_selection: &SelectionRef, ) -> Result<(), LexicalError>

TextNode.selectionTransform(prevSelection, nextSelection): called on the text nodes a range selection’s anchor and focus are in at the end of each update (applySelectionTransforms), before the transforms run, with the committed state’s selection and the update’s. Does nothing by default.
Source§

fn set_format(&self, this: &NodeRef, format: f64)

TextNode.setFormat(format) on the text node this: sets its __format, after getWritable().
Source§

fn can_insert_text_before(&self) -> bool

canInsertTextBefore() (TextNode and ElementNode): whether text typed at the node’s start goes into it.
Source§

fn can_insert_text_after(&self) -> bool

canInsertTextAfter() (TextNode and ElementNode): whether text typed at the node’s end goes into it.
Source§

fn get_text_content(&self) -> String

getTextContent().
Source§

fn get_text_content_size(&self) -> usize

getTextContentSize(): the text content’s length in UTF-16 code units, which an element sums from its children (ElementNode.getTextContentSize). JS gives a class that overrides getTextContent but not this method LexicalNode’s, the length of its text content; Rust can’t tell an override, so a class that overrides get_text_content overrides this too, as Swift’s do.
Source§

fn should_serialize_text_styles(&self) -> bool

ElementNode.shouldSerializeTextStyles().
Source§

fn super_types(&self) -> Vec<&'static str>

The node types of the classes this node’s class extends, nearest first, without the base classes that have no type of their own (ElementNode, DecoratorNode): JS’s class chain, which matches DOMRenderExtension’s overrides of a class to the nodes of the classes that extend it (the html feature). ["text"] for a node with TextNode fields that isn’t a TextNode itself, and none for any other; a class that extends another typed class overrides it. It also stands for instanceof in $applyNodeReplacement and createEditor’s check of a replacement’s withKlass.
Source§

fn export_json(&self, compact: bool) -> Object

exportJSON(compact): the node’s own properties, with an empty children array for an element (the export walk fills it), without its NodeState. By default $exportNodeJSONOnce: the class’s generated code, or the walk of its schema (crate::schema::walk_export_json). A class that adds to its JSON overrides it, calling crate::schema::export_node_json_once for what JS’s super.exportJSON returns.
Source§

fn update_from_json(&mut self, json: &Object)

updateFromJSON(json) on a writable node: applies every property the node’s schema declares, a missing one as its default ($applyJSONSetters, the class’s generated code or the walk); the caller applies the NodeState first.
Source§

fn update_dom(&self, prev_node: &dyn LexicalNode) -> bool

The model half of updateDOM(prevNode, dom, config): whether the reconciler makes the node’s DOM again (what JS’s returns), which reports the node’s children as created. By default a text node compares its tags (TextNode.updateDOM) and any other node keeps its DOM.

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> NodeClone for T
where T: LexicalNode + Clone,

Source§

fn clone_node(&self) -> Box<dyn LexicalNode>

Source§

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

Source§

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

Source§

fn as_node(&self) -> &(dyn LexicalNode + 'static)

Source§

fn as_node_mut(&mut self) -> &mut (dyn LexicalNode + 'static)

Source§

fn class_name(&self) -> &'static str

node.constructor.name, which messages name a node’s class by: the Rust type’s name, without its path.
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 = !

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.