Skip to main content

LexicalExtension

Struct LexicalExtension 

Source
pub struct LexicalExtension<Config: ExtensionConfigBase = (), Output: 'static = (), Init: 'static = ()> {
Show 18 fields pub name: String, pub conflicts_with: Vec<String>, pub dependencies: Vec<AnyLexicalExtensionArgument>, pub peer_dependencies: Vec<NormalizedPeerDependency>, pub config: Config, pub merge_config: Option<ExtensionMergeConfigFn<Config>>, pub nodes: Vec<NodeClass>, pub namespace: Option<String>, pub editable: Option<bool>, pub on_warn: Option<Rc<dyn Fn(LexicalError, &Editor) -> Result<(), LexicalError>>>, pub initial_editor_state: Option<InitialEditorStateType>, pub theme: Option<Object>, pub parent_editor: Option<Editor>, pub html: HtmlConfig, pub init: Option<ExtensionInitFn<Config, Init>>, pub build: Option<ExtensionBuildFn<Config, Output, Init>>, pub register: Option<ExtensionRegisterFn<Config, Output, Init>>, pub after_registration: Option<ExtensionRegisterFn<Config, Output, Init>>,
}
Expand description

LexicalExtension: a composable, named unit of editor configuration (nodes, the initial state) and of behavior registered once the editor exists. Write one with struct update syntax over LexicalExtension::new, and make it with define_extension.

An extension without build has no output, and one without init no init result (JS’s undefined).

Fields§

§name: String

name: unique in an editor.

§conflicts_with: Vec<String>

conflictsWith: names of extensions this one can’t be built with.

§dependencies: Vec<AnyLexicalExtensionArgument>

dependencies: other extensions, optionally with config overrides.

§peer_dependencies: Vec<NormalizedPeerDependency>

peerDependencies: extensions, by name, this one configures or reads when another extension brings them.

§config: Config

config: the default config.

§merge_config: Option<ExtensionMergeConfigFn<Config>>

mergeConfig; without it, ExtensionConfigBase::shallow_merge.

§nodes: Vec<NodeClass>

nodes: node classes, and node replacements as NodeClasses (LexicalNodeReplacement).

§namespace: Option<String>

namespace: the editor’s namespace; the last extension that sets it wins.

§editable: Option<bool>

editable: whether the editor starts editable; the last extension that sets it wins.

§on_warn: Option<Rc<dyn Fn(LexicalError, &Editor) -> Result<(), LexicalError>>>

onWarn: the last extension that sets it wins.

§initial_editor_state: Option<InitialEditorStateType>

$initialEditorState.

§theme: Option<Object>

theme, merged into the themes of the extensions before it.

§parent_editor: Option<Editor>

parentEditor: the editor to nest the new one in.

§html: HtmlConfig

html: exportDOM overrides by node type and import conversions.

§init: Option<ExtensionInitFn<Config, Init>>§build: Option<ExtensionBuildFn<Config, Output, Init>>§register: Option<ExtensionRegisterFn<Config, Output, Init>>§after_registration: Option<ExtensionRegisterFn<Config, Output, Init>>

Implementations§

Source§

impl<Config: ExtensionConfigBase, Output: 'static, Init: 'static> LexicalExtension<Config, Output, Init>

Source

pub fn new(name: impl Into<String>, config: Config) -> Self

An extension with a name and a default config, and nothing else.

Trait Implementations§

Source§

impl<C: ExtensionConfigBase, O: 'static, I: 'static> AnyLexicalExtension for LexicalExtension<C, O, I>

Auto Trait Implementations§

§

impl<Config = (), Output = (), Init = ()> !RefUnwindSafe for LexicalExtension<Config, Output, Init>

§

impl<Config = (), Output = (), Init = ()> !Send for LexicalExtension<Config, Output, Init>

§

impl<Config = (), Output = (), Init = ()> !Sync for LexicalExtension<Config, Output, Init>

§

impl<Config = (), Output = (), Init = ()> !UnwindSafe for LexicalExtension<Config, Output, Init>

§

impl<Config, Output, Init> Forget for LexicalExtension<Config, Output, Init>

§

impl<Config, Output, Init> Freeze for LexicalExtension<Config, Output, Init>

§

impl<Config, Output, Init> Move for LexicalExtension<Config, Output, Init>

§

impl<Config, Output, Init> Unpin for LexicalExtension<Config, Output, Init>
where Config: Unpin, Option<Rc<dyn Fn(&Config, &<Config as ExtensionConfigBase>::Partial) -> Config>>: Unpin, Option<Rc<dyn Fn(&mut InitialEditorConfig, &Config, &ExtensionInitState) -> Result<Init, LexicalError>>>: Unpin, Option<Rc<dyn Fn(&Editor, &Config, &ExtensionBuildState<Init>) -> Result<Output, LexicalError>>>: Unpin, Option<Rc<dyn Fn(&Editor, &Config, &ExtensionRegisterState<Init, Output>) -> Result<Box<dyn FnOnce()>, LexicalError>>>: Unpin,

§

impl<Config, Output, Init> UnsafeUnpin for LexicalExtension<Config, Output, Init>

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> 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, 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.