Skip to main content
Glama
CodeEditor.tsx1.14 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { sendCommand } from '@medplum/react'; import type { JSX, Ref } from 'react'; export interface CodeEditorProps { readonly language: 'typescript' | 'json'; readonly module?: 'commonjs' | 'esnext'; readonly defaultValue?: string; readonly iframeRef: Ref<HTMLIFrameElement> | undefined; readonly testId?: string; readonly minHeight?: string; } export function CodeEditor(props: CodeEditorProps): JSX.Element { const code = props.defaultValue; const url = new URL(`https://codeeditor.medplum.com/${props.language}-editor.html`); if (props.module) { url.searchParams.set('module', props.module); } return ( <iframe title="Code Editor" frameBorder="0" src={url.toString()} style={{ width: '100%', height: '100%', minHeight: props.minHeight }} ref={props.iframeRef} data-testid={props.testId} onLoad={(e) => { sendCommand(e.currentTarget as HTMLIFrameElement, { command: 'setValue', value: code }).catch(console.error); }} /> ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server