Nominally Patriotic Meathead
Have ideas to improve npm?Join in the discussion! »

@tanbo/textbusTypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.80 • Public • Published

安装

通过 npm 安装 TextBus:

npm install @tanbo/textbus

在 html 中准备一个空的元素

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

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

import { createEditor } from '@tanbo/textbus';
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>TextBus</strong> 富文本编辑器...<br></p>`
});

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

官网地址

TextBus 官网

Install

npm i @tanbo/textbus

DownloadsWeekly Downloads

1,133

Version

1.0.0-alpha.80

License

GPL-3.0-only

Unpacked Size

2.54 MB

Total Files

568

Last publish

Collaborators

  • avatar