CodeEditor

A syntax-highlighted code editor powered by Shiki. It supports line numbers, tab indentation, save shortcuts, and a dirty-state indicator.

Import

import { CodeEditor } from "@run0/jiki-ui";

Props

PropTypeDefaultDescription
filenamestring | null—File path displayed in the tab bar
contentstring—File content to display and edit
onSave(path: string, content: string) => void—Called on Ctrl+S / Cmd+S
accentColorAccentColor"emerald"Theme color for UI accents

Features

  • Syntax highlighting via a lazy-loaded Shiki singleton (github-dark theme)
  • Line numbers with synchronized scrolling
  • Tab inserts two spaces
  • Ctrl+S / Cmd+S triggers onSave
  • Amber dot indicator when the buffer has unsaved changes
  • Tab bar showing the current filename and detected language label
  • Status bar showing the total line count

Usage

function Editor() {
  const [file, setFile] = useState({ path: "index.js", content: "" });

  return (
    <CodeEditor
      filename={file.path}
      content={file.content}
      onSave={(path, content) => container.writeFile(path, content)}
      accentColor="blue"
    />
  );
}

Demo

index.js
JavaScript
1
2
3
4
5
6
6 linesCtrl+S / Cmd+S to save