// Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 import { CodeEditView } from "@/app/view/codeedit"; import { PlotView } from "@/app/view/plotview"; import { PreviewView } from "@/app/view/preview"; import { TerminalView } from "@/app/view/term"; import { ErrorBoundary } from "@/element/errorboundary"; import { CenteredDiv } from "@/element/quickelems"; import * as WOS from "@/store/wos"; import * as React from "react"; import "./block.less"; interface BlockProps { blockId: string; onClose?: () => void; } const BlockHeader = ({ blockId, onClose }: BlockProps) => { const [blockData] = WOS.useWaveObjectValue(WOS.makeORef("block", blockId)); return (
Block [{blockId.substring(0, 8)}] {blockData?.view}
{onClose && (
)}
); }; const Block = ({ blockId, onClose }: BlockProps) => { const blockRef = React.useRef(null); let blockElem: JSX.Element = null; const [blockData, blockDataLoading] = WOS.useWaveObjectValue(WOS.makeORef("block", blockId)); if (!blockId || !blockData) return null; if (blockDataLoading) { blockElem = Loading...; } else if (blockData.view === "term") { blockElem = ; } else if (blockData.view === "preview") { blockElem = ; } else if (blockData.view === "plot") { blockElem = ; } else if (blockData.view === "codeedit") { blockElem = ; } return (
Loading...}>{blockElem}
); }; export { Block, BlockHeader };