MCPcopy
hub / github.com/wavetermdev/waveterm / createBlockSplitVertically

Function createBlockSplitVertically

frontend/app/store/global.ts:385–406  ·  view source on GitHub ↗
(
    blockDef: BlockDef,
    targetBlockId: string,
    position: "before" | "after"
)

Source from the content-addressed store, hash-verified

383}
384
385async function createBlockSplitVertically(
386 blockDef: BlockDef,
387 targetBlockId: string,
388 position: "before" | "after"
389): Promise<string> {
390 const layoutModel = getLayoutModelForStaticTab();
391 const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } };
392 const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts);
393 const targetNodeId = layoutModel.getNodeByBlockId(targetBlockId)?.id;
394 if (targetNodeId == null) {
395 throw new Error(`targetNodeId not found for blockId: ${targetBlockId}`);
396 }
397 const splitAction: LayoutTreeSplitVerticalAction = {
398 type: LayoutTreeActionType.SplitVertical,
399 targetNodeId: targetNodeId,
400 newNode: newLayoutNode(undefined, undefined, undefined, { blockId: newBlockId }),
401 position: position,
402 focused: true,
403 };
404 layoutModel.treeReducer(splitAction);
405 return newBlockId;
406}
407
408async function createBlock(blockDef: BlockDef, magnified = false, ephemeral = false): Promise<string> {
409 const layoutModel = getLayoutModelForStaticTab();

Callers 3

handleSplitVerticalFunction · 0.90
getSettingsMenuItemsMethod · 0.90

Calls 5

newLayoutNodeFunction · 0.85
getNodeByBlockIdMethod · 0.80
treeReducerMethod · 0.80
CreateBlockMethod · 0.45

Tested by

no test coverage detected