Element API
6 min
element objects are a type of node in a slate document that contain other element nodes or text nodes interface element { children node\[] } behavior types docid\ ikfs9wiely eabmjl4jgzblock vs inline docid\ ikfs9wiely eabmjl4jgzvoid vs not void docid\ ikfs9wiely eabmjl4jgzrendering void elements docid\ ikfs9wiely eabmjl4jgzstatic methods docid\ ikfs9wiely eabmjl4jgzretrieval methods docid\ ikfs9wiely eabmjl4jgzcheck methods docid\ ikfs9wiely eabmjl4jgz element behavior types element nodes behave differently depending on the slate editor's configuration docid\ hy2ugai1fnvsaa53xavyp an element can be "block" or "inline" as defined by editor isinline either "void" or "not void" as defined by editor isvoid block vs inline a "block" element can only be siblings with other "block" elements an "inline" node can be siblings with text nodes or other "inline" elements void vs not void in a not "void" element, slate handles the rendering of its children (e g in a paragraph where the text and inline children are rendered by slate) in a "void" element, the children are rendered by the element 's render code rendering void elements void elements must always have one empty child text node (for selection) render using attributes and children (so, their outermost html element can't be an html void element) set contenteditable={false} (for firefox) typical rendering code will resemble this thematic break (horizontal rule) element return ( \<div { attributes} contenteditable={false}> {children} \<hr /> \</div> ) static methods retrieval methods element matches(element element, props partial\<element>) => boolean check if an element matches a set of props note this checks custom properties, but it does not ensure that any children are equivalent check methods element iselement(value any) => value is element check if a value implements the element interface element iselementlist(value any) => value is element\[] check if a value is an array of element objects