MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / handler

Function handler

packages/plugin-command/src/node-command.ts:284–323  ·  view source on GitHub ↗
(param: {
          nodeId: string;
          targetNodeId: string;
          index: number;
        })

Source from the content-addressed store, hash-verified

282 name: 'move',
283 description: 'Move a node to another node.',
284 handler(param: {
285 nodeId: string;
286 targetNodeId: string;
287 index: number;
288 }) {
289 const {
290 nodeId,
291 targetNodeId,
292 index = 0,
293 } = param;
294
295 if (!nodeId) {
296 throw new Error('Invalid node id.');
297 }
298
299 if (!targetNodeId) {
300 throw new Error('Invalid target node id.');
301 }
302
303 const node = project.currentDocument?.getNodeById(nodeId);
304 const targetNode = project.currentDocument?.getNodeById(targetNodeId);
305 if (!node) {
306 throw new Error(`Can not find node '${nodeId}'.`);
307 }
308
309 if (!targetNode) {
310 throw new Error(`Can not find node '${targetNodeId}'.`);
311 }
312
313 if (!targetNode.isContainerNode) {
314 throw new Error(`Node '${targetNodeId}' is not a container node.`);
315 }
316
317 if (index < 0 || index > (targetNode.children?.size || 0)) {
318 throw new Error(`Invalid index '${index}'.`);
319 }
320
321 project.currentDocument?.removeNode(node);
322 project.currentDocument?.insertNode(targetNode, node, index);
323 },
324 parameters: [
325 {
326 name: 'nodeId',

Callers 1

handleSubNodesFunction · 0.85

Calls 9

getNodeByIdMethod · 0.65
removeNodeMethod · 0.65
insertNodeMethod · 0.65
importSchemaMethod · 0.65
forEachMethod · 0.65
setPropValueMethod · 0.65
removeMethod · 0.65
getPropMethod · 0.65
isNodeSchemaFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…