shuyun-ng-editor
Version:
shuyun angularJs editor
130 lines (95 loc) • 4.57 kB
Markdown
<h2 align="center">安装</h2>
```bash
// npm
npm install shuyun-ng-editor --save
// yarn
yarn add shuyun-ng-editor --save
```
<h2 align="center">使用</h2>
```js
import angular from 'angular';
import shuyunEditor from 'shuyun-ng-editor';
angular.module('app', [shuyunEditor]);
```
### 基础编辑器使用
```html
<!--具体用法: 参见 Demos-->
<shuyun-editor-keyword></shuyun-editor-keyword>
<shuyun-editor-content></shuyun-editor-content>
```
<h2 align="center">API</h2>
#### shuyun-editor-keyword
| 属性 | 说明 | 类型 | 默认值 |
| --------------------- | ----------- | -------- | -------- |
| keywords | 关键词集合 | array | 见下面对单个keyword的说明 |
| width | 宽度 | string | auto |
| isShowAll | 是否平铺显示所有关键词 | boolean | false |
| onInsertKeywordAction | 点击关键词回调 | function | () => {} |
#### keyword
| 属性 | 说明 | 类型 | 默认值 |
| --------------------- | ----------- | -------- | -------- |
| type | 平台类型 | string | |
| name | 短生成内容的替换字符 | string | auto |
| text | 编辑器插入关键词显示扥文本 | string | string |
| isShow | 是否显示 | boolean | true |
| defaultValue | 默认显示的预览文本 | string | name |
#### shuyun-editor-content
| 属性 | 说明 | 类型 | 默认值 |
| ---------------------- | -------------- | -------- | ----------------------------------------- |
| ref | 获取当前编辑器实例 | object | - |
| styles | 编辑器样式设置 | object | width, height, max-height, font-size |
| placeholder | 默认值 | string | 请输入内容… |
| content | 编辑器内容 | string | |
| keywords | 关键词集合 | array | 同`shuyun-editor-keyword`字段 |
| isTrimSpace | 是否删除内容两边空格 | boolean | true |
| hasTagInPreview | 预览文本是否包含html标签 | boolean | false |
| disabled | 编辑器禁止输入 | boolean | false |
| illegalChar | 编辑器禁止输入的非法词 | array | ['œ', 'þ'] |
| onFocus | 聚焦显示关键词 | function | - |
| onBlur | 失焦隐藏关键词 | function | - |
| onContentChangedAction | 编辑器内容发生变化调用此函数 | fucntion | |
#### onContentChanged 函数
编辑器内容发生变化调用此函数,返回值为:
```js
{
// 编辑器文本
editorText: '',
// 预览内容,按照换行符切割为数组
previewText: [],
// 总字数
totalChars: 20,
// 换行数
newLineNumber: 2,
// 变量数
variableNumber: 1,
// 变量预估字数
variableWordsNumber: 20
}
```
### 短信编辑器使用
```html
<!--具体用法: 参见 Demos-->
<shuyun-editor-sms-editor ref="" opts={}></shuyun-editor-sms-editor>
<shuyun-editor-sms-preview opts={}></shuyun-editor-sms-preview>
```
<h2 align="center">API</h2>
#### opts
| 属性 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| content | 短信编辑器内容 | string | |
| keywords | 变量集合 | Array | 同`shuyun-editor-keyword`字段 |
| isTrimSpace | 是否删除短信内容两边空格 | boolean | true |
| disabled | 短信编辑器禁止编辑 | boolean | false |
| customSignature | 自定义短信签名 | string | |
| customSignature | 自定义短信签名 | string | |
| useUnsubscribe | 是否使用回T退 | boolean | false |
| unsubscribeText | 退订的默认文案 | string | 回T退 |
| gateway | 短信通道类型 | object | |
#### gateway
| 属性 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| gatewayId | 短信通道id | number | |
| wordsLimit | 单条短信字数限制 | number | 70 |
| multiLimit | 多条短信字数限制 | number | 67 |
| signature | 短信通道内置签名 | string | |
| gatewayType | 短信通道类型 | number | |