Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tanbo/tbus

tbhuabi93GPLdeprecated0.0.2-beta.85TypeScript support: included

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

A rich text editor

editor, text, rich, component editor, web editor, office, word, excel, note

readme

安装

通过 npm 安装 TBus:

npm install @tanbo/tbus

在 html 中准备一个空的元素

<body>
  <div id="editor"></div>
</body>

通过 css 选择器,或直接传入一个 DOM 元素初始化 TBus。

import { createEditor } from '@tanbo/tbus';
import { Observable } from 'rxjs';

const editor = createEditor('#editor', {
  uploader(type: string): string | Promise<string> | Observable<string> {
    // switch (type) {
    //   case 'video':
    //     console.log('上传视频');
    //     break;
    //   case 'image':
    //     console.log('上传视频');
    //     break;
    //   case 'audio':
    //     console.log('上传音频');
    //     break;
    // }
    return Promise.resolve().then(() => {
      return '/test'
    })
  },
  content: `<p>欢迎你使用&nbsp;<strong>TBus</strong> 富文本编辑器...<br></p>`
});

editor.onChange.subscribe(() => {
  console.log(editor.getContents());
});

官网地址

TBus 官网