Skip to main content

$create

function

Create an node from its class. This directly constructs the final `withKlass` node type, skipping the intermediate steps where each replaced node would be created and then immediately discarded — once per configured replacement of that node. A deprecated `replace` given without a `withKlass` is the one case that cannot be resolved ahead of construction, since only its `with` function knows what to build. Such a replacement is still applied, the old way, to the node this constructs. This does not support any arguments to the constructor. Setters can be used to initialize your node, and they can be chained. You can of course write your own mutliple-argument functions to wrap that.

function $create<T extends LexicalNode>(klass: Klass<T>): T

Import

import { $create } from '@modular/sdk/editor';

Notes

example
```ts function $createTokenText(text: string): TextNode { return $create(TextNode).setTextContent(text).setMode('token'); } ```