# @codeium/react-code-editor 中文文档

规范地址：https://npmcn.com/package/%40codeium/react-code-editor/

版本：1\.0\.12
npm 元数据更新时间：2025-02-12T22:14:09.686Z
中文译文更新时间：2026-11-10T06:54:31.399Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40codeium/react-code-editor
原文对照：https://npmcn.com/package/%40codeium/react-code-editor/?lang=original
项目主页：https://github.com/Exafunction/codeium-react-code-editor#readme
源码仓库：https://github.com/Exafunction/codeium-react-code-editor

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：3.9 MB，54 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=16
- 运行依赖：6 个
- peer 依赖：react ^18\.2\.0，react-dom ^18\.2\.0，monaco-editor ^0\.45\.0
- 首次发布：2024-01-27T19:11:12.051Z
- 最新版本发布：2024-02-16T19:15:08.253Z
- 近 30 天下载量：18722（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：25（近 12 个月 0 个）

## 中文简介

AI 动力反应组件

## 安装

```sh
npm install @codeium/react-code-editor
```

也可以使用：`pnpm add @codeium/react-code-editor`、`yarn add @codeium/react-code-editor`、`bun add @codeium/react-code-editor`

## README

# 代码编辑器

[![built with Codeium](https://codeium.com/badges/main)](https://codeium.com/?referrer=github)

[![NPM](https://nodei.co/npm/@codeium/react-code-editor.png?downloads=true)](https://www.npmjs.com/package/@codeium/react-code-editor)

Codeium React Code Editor是一个免费的开源代码编辑器,作为React组件,无限的AI自動完成. 球队带给你的 [编码](https://www.codeium.com/)。 。 。 . **无需账户即可免费.**你只需要安装国家防范机制的软件包 放到你的网站上就行了!

![codeium demo](https://npmcn.com/package/%40codeium/react-code-editor/docs/codeium_playground.gif)

## 特征

-   无限制 AI 自动完成( 不需要账户)
-   自定义 API 从 [摩纳哥反应](https://github.com/suren-atoyan/monaco-react?tab=readme-ov-file#editor)

## 演示

看看这个 [这里](https://codeium.com/playground)来啊!

## 开始

使用其中任何软件包管理器安装

```sh
# NPM
npm install @codeium/react-code-editor

# Yarn
yarn add @codeium/react-code-editor

# PNPM
pnpm install @codeium/react-code-editor
```

现在导入 `CodeiumEditor` 享受闪电快的AI自动完成,直接在您的浏览器中,100%免费!

```tsx
import { CodeiumEditor } from "@codeium/react-code-editor";

export const IdeWithAutocomplete = () => {
  return (
    <div>
      <p>Here's an AI-powered Python editor using Codeium.</p>
      <CodeiumEditor language="python" theme="vs-dark" />
    </div>
  );
};
```

以下是使用多文档上下文提供更智能化的自动补全的先进例子:

```tsx
import { CodeiumEditor, Document, Language } from "@codeium/react-code-editor";

export const JavaScriptEditorWithContext = () => {
  const html = `<html>
  <body>
    <h1>Contact Us</h1>
    <form>
      <label>Name:</label>
      <input id="name" type="text" />
      <label>Email:</label>
      <input id="email" type="text" />
    </form>
  </body>
</html>`;

  return (
    <div>
      <p>This editor has context awareness of a neighboring HTML file and can provide better autocompletion suggestions.</p>
      <CodeiumEditor
        language="javascript"
        theme="vs-dark"
        otherDocuments={[
          new Document({
            absolutePath: "/app/index.html",
            relativePath: "index.html",
            text: html,
            editorLanguage: "html",
            language: Language.HTML,
          }),
        ]}
      />
    </div>
  );
};
```

注意 `otherDocuments` prop有10个文件的限制. 在这些文件中,Codeium将在幕后运行一个重新排名器,以优化符号限制中包含的内容.

### 实例

以下是生产中使用的Codeium React编辑器的一些实例:

-   [https://khou22.com/programming/codeium (中文(简体) )](https://khou22.com/programming/codeium?referrer=github) \[[曲线](https://github.com/khou22/khou22.github.io/blob/b2352449d101f7f9cf8a9382f031091d7dd4cfdd/src/app/programming/codeium/page.tsx#L20)\[ . \]

## 如何运作

这个项目是一个围绕微软摩纳哥编辑器的包装器,它是授权VS代码的编辑器,具有提供代码自动补全的扩展能力.

自动完成是通过分析编辑的内容、预测和根据这一背景提出建议提供的。 要了解更多 如何完成自动补全,访问 [密码的FAQ](https://codeium.com/faq)。 。 。 .

## 什么是可乐

[编码](https://www.codeium.com/?referrer=github) 是免费的,AI动力的开发者工具包,可以插入70+ IDEs,包括:Visual Studio代码,JetBrains IDEs,Google Colab,和Vim. Codeium提供无限的AI上下文意识自动完成,聊天助手,智能搜索,代码库索引等功能. Codeium还提供在你的VPC或Prem上,空出环境中的灵活部署. 学习更多 [codium.com (英语)](https://www.codeium.com/?referrer=github)。 。 。 .

## API 密码

编辑器的核心API与被包裹的项目相同. 您可以查看编辑器 API [这里](https://github.com/suren-atoyan/monaco-react?tab=readme-ov-file#editor)。 。 。 .

## 财务问题

#### 我如何导入这个无害环境管理版本?

要导入此的无害环境管理版本, 您可以使用 `import { CodeiumEditor } from "@codeium/react-code-editor/dist/esm";`。如果您正在使用 TypeScript, 您的编辑器可能会警告这些类型缺失 。 目前的工作是:

-   创建一个 `codeiumeditor.d.ts` 文档,
-   添加 `declare module '@codeium/react-code-editor/dist/esm';` 转到文件
-   使用 `CodeiumEditor` 组件.

就支持共同联合体系和无害环境管理而言,这是一个未决问题。 如果你有兴趣贡献 并有一个固定这一点, 拉请求是欢迎的.

## 鸣谢

没有这个计划是不可能实现的 [Suren Atoyan的摩纳哥反应项目](https://github.com/suren-atoyan/monaco-react)。 。 。 .

## 问题

在此寄存器中创建任何与自动补全功能相关的问题 。 如果您对编辑器 API 或功能有任何问题, 请在 [编辑器仓库](https://github.com/suren-atoyan/monaco-react)。 。 。 .

## 许可证

[许可证](https://github.com/Exafunction/codeium-react-editor/blob/main/LICENSE)

## 常见问题

### @codeium/react-code-editor 是什么？

AI 动力反应组件

### 如何安装 @codeium/react-code-editor？

在项目目录运行 npm install @codeium/react-code-editor，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（^18\.2\.0）、react-dom（^18\.2\.0）、monaco-editor（^0\.45\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @codeium/react-code-editor 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @codeium/react-code-editor 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @codeium/react-code-editor 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=16。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @codeium/react-code-editor 可以商用吗？

@codeium/react-code-editor 使用 ISC 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @codeium/react-code-editor 的下载量有多少？

根据 npm 官方下载统计，@codeium/react-code-editor 在 2026/10/10 – 2026/11/08 这 30 天内被下载 18,722 次，日均约 624 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @codeium/react-code-editor 还在维护吗？

最新版本 1\.0\.12 发布于 2024/02/17（2 年前）；至今共发布 25 个版本，其中过去 12 个月发布了 0 个；首次发布于 2024/01/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

