(blockId: string, blockDef: BlockDef, focus: boolean)
| 424 | } |
| 425 | |
| 426 | async function replaceBlock(blockId: string, blockDef: BlockDef, focus: boolean): Promise<string> { |
| 427 | const layoutModel = getLayoutModelForStaticTab(); |
| 428 | const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } }; |
| 429 | const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts); |
| 430 | setTimeout(() => { |
| 431 | fireAndForget(() => ObjectService.DeleteBlock(blockId)); |
| 432 | }, 300); |
| 433 | const targetNodeId = layoutModel.getNodeByBlockId(blockId)?.id; |
| 434 | if (targetNodeId == null) { |
| 435 | throw new Error(`targetNodeId not found for blockId: ${blockId}`); |
| 436 | } |
| 437 | const replaceNodeAction: LayoutTreeReplaceNodeAction = { |
| 438 | type: LayoutTreeActionType.ReplaceNode, |
| 439 | targetNodeId: targetNodeId, |
| 440 | newNode: newLayoutNode(undefined, undefined, undefined, { blockId: newBlockId }), |
| 441 | focused: focus, |
| 442 | }; |
| 443 | layoutModel.treeReducer(replaceNodeAction); |
| 444 | return newBlockId; |
| 445 | } |
| 446 | |
| 447 | // when file is not found, returns {data: null, fileInfo: null} |
| 448 | async function fetchWaveFile( |
no test coverage detected