New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-openqasm-editor

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-openqasm-editor

A powerful, customizable code editor for OpenQASM (Open Quantum Assembly Language) based on Monaco Editor.

latest
Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

OpenQASM Editor

A powerful, customizable code editor for OpenQASM (Open Quantum Assembly Language) based on Monaco Editor.

Features

  • Syntax highlighting for OpenQASM language
  • Code completion with intelligent suggestions
  • Hover information for language elements
  • Code formatting capabilities
  • Diagnostics and error detection
  • Customizable themes and editor options
  • Built-in quantum code example templates

Installation

npm install openqasm-editor
# or
yarn add openqasm-editor

Usage

import { OpenQASMEditor } from 'openqasm-editor';

function App() {
  const handleEditorChange = (value, event) => {
    console.log('Editor content:', value);
  };

  const handleEditorMount = (editor) => {
    // You can access the editor instance here
    console.log('Editor mounted:', editor);
  };

  return (
    <OpenQASMEditor
      width="800px"
      height="500px"
      theme="vs-dark" // or "vs-light"
      defaultvalue={`OPENQASM 2.0;
include "qelib1.inc";

// Quantum program
qreg q[2];
creg c[2];

h q[0];
cx q[0], q[1];
measure q -> c;`}
      onChange={handleEditorChange}
      onMount={handleEditorMount}
      options={{
        // Monaco editor options
        fontSize: 14,
        lineNumbers: 'on',
        minimap: { enabled: false },
        // Add any other Monaco editor options here
      }}
    />
  );
}

Props

PropTypeDefaultDescription
widthstring800pxWidth of the editor
heightstring500pxHeight of the editor
themestringvs-darkEditor theme (vs-dark or vs-light)
defaultvaluestringBasic quantum programInitial code in the editor
valuestringundefinedControlled value for the editor
optionsobject{}Monaco editor options
onChangefunctionnoopCalled when editor content changes
onMountfunctionnoopCalled when editor is mounted

Development

Setup

git clone https://github.com/xy2002/openqasm-editor
npm install 
npm run generate-antlr
npm run build

Scripts

  • pnpm dev - Start development server
  • pnpm build - Build the library
  • pnpm lint - Run ESLint
  • pnpm storybook - Run Storybook for component development
  • pnpm generate-antlr - Generate ANTLR parser for OpenQASM grammar

OpenQASM Language

This editor supports the OpenQASM 2.0 specification, which is an intermediate representation for quantum circuits. The language includes:

  • Quantum register and classical register declarations
  • Gate definitions and applications
  • Measurements
  • Conditional operations
  • Mathematical expressions for rotations and phases

For more information on OpenQASM, see the OpenQASM specification.

Keywords

react

FAQs

Package last updated on 11 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts