@convergencelabs/monaco-collab-ext

中文文档
0.4.0发布于 2022/09/20MITTypeScriptCommonJS近 30 天下载 5276

摩纳哥编辑合作展

中文使用文档
文档目录7 节
  1. 摩纳哥合作展
  2. 安装
  3. 演示
  4. 使用量
  5. 远程浏览器管理器
  6. 远程选择 经理
  7. 编辑器控制器

摩纳哥合作展

Build Status

增强 摩纳哥编辑器 并增加了在系统中对远程用户所做的事情进行提示的能力.

demo graphic

安装

安装国家防范机制包并将其添加到您的发展依赖中:

npm install --save-dev @convergencelabs/monaco-collab-ext

演示

走开 这里 可以看到多个光标、多个选择和远程滚动条的活演示(在多个浏览器上查看,甚至更好,也指向朋友)。 这个用 趋同 处理数据同步和用户动作.

使用量

远程浏览器管理器

远程ursor Manager 允许您轻松渲染其他用户的光标 在同一文档中工作。 光标位置可显示为 单线性指数或作为二维位置,形式为 {lineNumber: 0, column: 10}。 。 。 .

const editor = monaco.editor.create(document.getElementById("editor"), {
  value: "function helloWorld = () => { console.log('hello world!')",
  theme: "vs-dark'",
  language: 'javascript'
});

const remoteCursorManager = new MonacoCollabExt.RemoteCursorManager({
  editor: editor,
  tooltips: true,
  tooltipDuration: 2
});

const cursor = remoteCursorManager.addCursor("jDoe", "blue", "John Doe");

// Set the position of the cursor.
cursor.setOffset(4);

// Hide the cursor
cursor.hide();

// Show the cursor
cursor.show();

// Remove the cursor.
cursor.dispose();

远程选择 经理

远程选择管理器允许您轻松地对其它选项进行选择 在同一文档中工作的用户.

const editor = monaco.editor.create(document.getElementById("editor"), {
  value: "function helloWorld = () => { console.log('hello world!')",
  theme: "vs-dark'",
  language: 'javascript'
});

const remoteSelectionManager = new MonacoCollabExt.RemoteSelectionManager({editor: editor});

const selection = remoteSelectionManager.addSelection("jDoe", "blue");

// Set the range of the selection using zero-based offsets.
selection.setOffsets(45, 55);

// Hide the selection
selection.hide();

// Show the selection
selection.show();

// Remove the selection.
selection.dispose();

编辑器控制器

编辑器 ContentManager 简化处理本地和远程变化 给编辑.

const editor = monaco.editor.create(document.getElementById("editor"), {
  value: "function helloWorld = () => { console.log('hello world!')",
  theme: "vs-dark'",
  language: 'javascript'
});

const contentManager = new MonacoCollabExt.EditorContentManager({
  editor: editor,
  onInsert(index, text) {
    console.log("Insert", index, text);
  },
  onReplace(index, length, text) {
    console.log("Replace", index, length, text);
  },
  onDelete(index, length) {
    console.log("Delete", index, length);
  }
});

// Insert text into the editor at offset 5.
contentManager.insert(5, "some text");

// Replace the text in the editor at range 5 - 10.
contentManager.replace(5, 10, "some text");

// Delete the text in the editor at range 5 - 10.
contentManager.delete(5, 10);

// Release resources when done
contentManager.dispose();

版本与发布记录

@convergencelabs/monaco-collab-ext 共发布 7 个版本,首次发布于 2019/03/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.0latest2022/09/204 年前
0.3.22021/04/095 年前
0.3.12020/11/096 年前
0.3.02020/03/066 年前
0.2.02020/01/086 年前
0.1.12019/03/137 年前

关于 @convergencelabs/monaco-collab-ext 的常见问题

@convergencelabs/monaco-collab-ext 是什么?

摩纳哥编辑合作展

如何安装 @convergencelabs/monaco-collab-ext?

在项目目录运行 npm install @convergencelabs/monaco-collab-ext,或使用 pnpm add / yarn add / bun add。

@convergencelabs/monaco-collab-ext 支持 TypeScript 吗?

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

@convergencelabs/monaco-collab-ext 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@convergencelabs/monaco-collab-ext 可以商用吗?

@convergencelabs/monaco-collab-ext 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@convergencelabs/monaco-collab-ext 的下载量有多少?

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

@convergencelabs/monaco-collab-ext 还在维护吗?

最新版本 0.4.0 发布于 2022/09/20(4 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/03/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。