reorderNodes()v4.0.533
Moves one or more JSX nodes as a group before or after a sibling. The moved nodes keep their source order. For ordinary <Sequence> siblings, this changes stacking order. For <Series.Sequence> and <TransitionSeries.Sequence> siblings, it also changes their calculated timing.
Draft API: This API is experimental and may change.
reorder-nodes.tsimport {reorderNodes , typeCodemodProject , typeNodeReference } from '@remotion/codemods'; declare constproject :CodemodProject ; declare constfirst :NodeReference ; declare constsecond :NodeReference ; declare consttarget :NodeReference ; constresult = awaitreorderNodes ({project ,nodes : [first ,second ],target ,position : 'before', });console .log (result .changes );
All moved nodes and the target must be direct JSX siblings in the same file. A target in the moved group is invalid. The edit is atomic, so an invalid node leaves the input project unchanged.
Options
project
An in-memory CodemodProject. The input project is not mutated.
nodes
A nonempty array of NodeReference values for the nodes to move. Their array order does not affect the result.
target
The sibling node to position the group relative to.
position
Either 'before' or 'after'.
Return value
changes
An array of file changes. This operation changes one file.
nodePathRemappings
The mappings from old to new JSX node paths. Apply them to references and selections from the input project.
updatedNodes
References to the moved nodes in the output project, in the order passed in nodes.
editDetails
The source location and label for the edit.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||