API

Transforms

17min
transforms are helper functions operating on the document they can be used in defining your own commands transforms docid\ zwt6qv3ijs5h9ftkd9tpltransforms docid\ zwt6qv3ijs5h9ftkd9tpltransforms docid\ zwt6qv3ijs5h9ftkd9tpltransforms docid\ zwt6qv3ijs5h9ftkd9tpltransforms docid\ zwt6qv3ijs5h9ftkd9tpltransforms docid\ zwt6qv3ijs5h9ftkd9tpl node options all transforms support a parameter options this includes options specific to the transform, and general nodeoptions to specify the place in the document that the transform is applied to interface nodeoptions { at? location match? (node node) => boolean mode? 'highest' | 'lowest' voids? boolean } the at option is versatile and can be used to implement more complex transforms transforms at option docid\ n5ob17hofj2l0ifvqj3yg when combined with at , match can be powerful transforms match option docid\ n5ob17hofj2l0ifvqj3yg static methods node transforms transforms that operate on nodes transforms insertfragment(editor editor, fragment node\[], options?) insert of fragment of nodes at the specified location in the document if no location is specified, insert at the current selection options {at? location, hanging? boolean, voids? boolean} transforms insertnodes(editor editor, nodes node | node\[], options?) insert nodes at the specified location in the document if no location is specified, insert at the current selection if there is no selection, insert at the end of the document options supported nodeoptions & {hanging? boolean, select? boolean} transforms removenodes(editor editor, options?) remove nodes at the specified location in the document if no location is specified, remove the nodes in the selection options supported nodeoptions & {hanging? boolean} transforms mergenodes(editor editor, options?) merge a node at the specified location with the previous node at the same depth if no location is specified, use the selection resulting empty container nodes are removed options supported nodeoptions & {hanging? boolean} transforms splitnodes(editor editor, options?) split nodes at the specified location if no location is specified, split the selection options supported nodeoptions & {height? number, always? boolean} transforms wrapnodes(editor editor, element element, options?) wrap nodes at the specified location in the element container if no location is specified, wrap the selection options supported nodeoptions & {split? boolean} options mode 'all' is also supported options split indicates that it's okay to split a node in order to wrap the location for example, if ipsum was selected in a text node with lorem ipsum dolar , split true would wrap the word ipsum only, resulting in splitting the text node if split false , the entire text node lorem ipsum dolar would be wrapped transforms unwrapnodes(editor editor, options?) unwrap nodes at the specified location if necessary, the parent node is split if no location is specified, use the selection options supported nodeoptions & {split? boolean} for options mode , 'all' is also supported transforms setnodes(editor editor, props partial\<node>, options?) set properties of nodes at the specified location if no location is specified, use the selection options supported nodeoptions & {hanging? boolean, split? boolean} for options mode , 'all' is also supported transforms unsetnodes(editor editor, props string | string\[], options?) unset properties of nodes at the specified location if no location is specified, use the selection options supported nodeoptions & {split? boolean} for options mode , 'all' is also supported transforms liftnodes(editor editor, options?) lift nodes at the specified location upwards in the document tree if necessary, the parent node is split if no location is specified, use the selection options supported nodeoptions for options mode , 'all' is also supported transforms movenodes(editor editor, options) move the nodes from an origin to a destination a destination must be specified in the options if no origin is specified, move the selection options supported nodeoptions & {to path} for options mode , 'all' is also supported selection transforms transforms that operate on the document's selection transforms collapse(editor editor, options?) collapse the selection to a single point options {edge? 'anchor' | 'focus' | 'start' | 'end'} transforms select(editor editor, target location) set the selection to a new value specified by target when a selection already exists, this method is just a proxy for setselection and will update the existing value transforms deselect(editor editor) unset the selection transforms move(editor editor, options?) move the selection's point forward or backward options {distance? number, unit? 'offset' | 'character' | 'word' | 'line', reverse? boolean, edge? 'anchor' | 'focus' | 'start' | 'end'} transforms setpoint(editor editor, props partial\<point>, options?) set new properties on one of the selection's points options {edge? 'anchor' | 'focus' | 'start' | 'end'} transforms setselection(editor editor, props partial\<range>) set new properties on an active selection since the value is a partial\<range> , this method can only handle updates to an existing selection if there is no active selection the operation will be void use select if you'd like to create a selection when there is none text transforms transforms that operate on text transforms delete(editor editor, options?) delete text in the document options {at? location, distance? number, unit? 'character' | 'word' | 'line' | 'block', reverse? boolean, hanging? boolean, voids? boolean} transforms inserttext(editor editor, text string, options?) insert a string of text at the specified location in the document if no location is specified, insert at the current selection options {at? location, voids? boolean} editor transforms transforms transform(editor editor, transform transform) transform the editor by an operation
🤔
Have a question?
Our super-smart AI,knowledgeable support team and an awesome community will get you an answer in a flash.
To ask a question or participate in discussions, you'll need to authenticate first.