{"id":48808806,"url":"https://github.com/textbus/xnote","last_synced_at":"2026-04-14T06:11:45.435Z","repository":{"id":196328951,"uuid":"695745803","full_name":"textbus/xnote","owner":"textbus","description":"xnote 是一个无头、高性能的富文本编辑器，支持多人在线协作。","archived":false,"fork":false,"pushed_at":"2026-04-14T00:50:54.000Z","size":2410,"stargazers_count":86,"open_issues_count":10,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-04-14T01:17:16.089Z","etag":null,"topics":["collaborative","editor","rich-text-editor","textbus"],"latest_commit_sha":null,"homepage":"https://textbus.io/playground","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/textbus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-24T04:55:33.000Z","updated_at":"2026-04-09T14:02:18.000Z","dependencies_parsed_at":"2023-09-24T14:26:21.719Z","dependency_job_id":"2c72467e-c538-4056-948d-d30ead017082","html_url":"https://github.com/textbus/xnote","commit_stats":null,"previous_names":["textbus/xnote"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/textbus/xnote","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textbus%2Fxnote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textbus%2Fxnote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textbus%2Fxnote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textbus%2Fxnote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/textbus","download_url":"https://codeload.github.com/textbus/xnote/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textbus%2Fxnote/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31784385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborative","editor","rich-text-editor","textbus"],"created_at":"2026-04-14T06:11:45.370Z","updated_at":"2026-04-14T06:11:45.425Z","avatar_url":"https://github.com/textbus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"XNote\n====================\nXnote 是一个无头、高性能、与框架无关的富文本编辑器，支持多人在线协作。提供了丰富的现代文档编辑功能。\n\nXnote 底层依赖于开源富文本框架 [Textbus](https://textbus.io) 和前端视图 [Viewfly](https://viewfly.org)。因此，你可以在此基础上继续扩展自己的功能。\n\n## 在线演示\n\n[在线演示](https://textbus.io/playground/)\n\n## 安装\n\n```\nnpm install @textbus/xnote katex\n```\n\n## 使用\n\n```ts\nimport 'katex/dist/katex.min.css'\nimport { Editor } from '@textbus/xnote'\n\nconst editor = new Editor()\neditor.mount(document.getElementById('editor')).then(() =\u003e {\n  console.log('编辑器准备完成。')\n})\n```\n\n## 文件上传\n\n要实现文件上传需实现 FileUploader 接口\n\n```ts\nimport { FileUploader } from '@textbus/xnote'\n\nclass YourUploader extends FileUploader {\n  uploadFile(type: string): string | Promise\u003cstring\u003e {\n    if (type === 'image') {\n      return 'imageUrl'\n    }\n    if (type === 'video') {\n      return 'videoUrl'\n    }\n  }\n}\n\nconst editor = new Editor({\n  providers: [{\n    provide: FileUploader,\n    useFactory() {\n      return new YourFileUplader()\n    }\n  }]\n})\n```\n\n## 粘贴图片 Base64 转 URL\n\n```ts\nimport { Commander } from '@textbus/core'\nimport { Injectable } from '@viewfly/core'\nimport { ImageComponent } from '@textbus/xnote'\n\n@Injectable()\nclass YourCommander extends Commander {\n  paste(slot: Slot, text: string) {\n    slot.sliceContent().forEach(content =\u003e {\n      if (content instanceof ImageComponent) {\n        const base64 = content.state.url\n        // base64 转 url，请自行实现\n        content.state.url = 'https://xxx.com/xxx.jpg'\n      }\n    })\n    \n    // 待图片转换完成后，可调用超类的 paste 方法\n    super.paste(slot, text)\n    return true\n  }\n}\n\nconst editor = new Editor({\n  providers: [{\n    provide: Commander,\n    useClass: YourCommander\n  }]\n})\n```\n\n## 获取 HTML\n\n```ts\nconst html = editor.getHTML()\n```\n\n## 设置初始 HTML\n\n```ts\nconst editor = new Editor({\n  content: '\u003cdiv\u003eHTML 内容\u003c/div\u003e'\n})\n```\n\n## 更新编辑器内容\n\n```ts\neditor.setContent('\u003cp\u003e你好！\u003c/p\u003e')\n```\n\n## @ 人\n\n在文档中 @ 人功能需实现以下接口，以对接用户信息\n\n```ts\nexport abstract class Organization {\n  abstract getMembers(name?: string): Promise\u003cMember[]\u003e\n\n  abstract atMember(member: Member): void\n}\n```\n然后在编辑器初始化时传入你的实现\n```ts\nconst editor = new Editor({\n  providers: [{\n    provide: Organization,\n    useValue: new YourOrganization()\n  }]\n})\n```\n\n## 协作支持\n\nTextbus 天然支持协作，只需要在编辑器配置项中添加协作配置信息即可，具体配置你可以参考 [https://textbus.io/guide/collab/](https://textbus.io/guide/collab/)\n\n```ts\nconst editor = new Editor({\n  collaborateConfig: {\n    userinfo: user, // 用户信息\n    createConnector(yDoc): SyncConnector {\n      // 返回连接器\n      return new YWebsocketConnector('wss://example.com', 'docName', yDoc)\n    }\n  }\n})\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextbus%2Fxnote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftextbus%2Fxnote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextbus%2Fxnote/lists"}