angular8 富文本编辑_angular4 富文本编辑器

使用quill富文本编辑器实现,angular项目中用到了ngx-quill插件。

quill的GitHub地址:https://github.com/quilljs/quill

ngx-quill的GitHub地址:https://github.com/KillerCodeMonkey/ngx-quill

ngx-quill适用于版本号在2以及以上的angular。

具体操作如下:

1、ngx-quill的安装

angular >= 5时ngx-quill的安装

npm install ngx-quill

angular < 5时

npm install ngx-quill@1.6.0

2、quill的配置

引入(ngx-quill的)QuillModule :

import { QuillModule } from 'ngx-quill'

在你的NgModule中添加 QuillModule :

@NgModule({

imports: [

...,

QuillModule

],

...

})

在index.html中添加quill的样式 :

3、使用

在页面使用标签进行使用,效果如下:

6546a7ff66ff1bbfc7045773cc9349ce.png

上图中的工具类是配置后的工具类,代码如下:

config的内容如下:

{

toolbar: [//['bold', 'italic', 'underline', 'strike'], // toggled buttons

['blockquote', 'code-block'],

[{'header': 1 }, { 'header': 2 }], //custom button values

[{ 'list': 'ordered'}, { 'list': 'bullet'}],//[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript

//[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent

//[{ 'direction': 'rtl' }], // text direction

//[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown

//[{ 'header': [1, 2, 3, 4, 5, 6, false] }],

//[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme

//[{ 'font': [] }],

//[{ 'align': [] }],

//['clean'], // remove formatting button

['link', 'image', 'video'] //link and image, video

]

};

-------------------------------------------------

2018-05-13 16:13:20

自定义工具栏

0">图片已上传:{{ uploader2?.queue.length > 0 ? uploader2?.queue[uploader2?.queue.length-1]?.progress : 0 }}%

上传图片代码(使用了ng2-file-upload插件)

publicuploader2: FileUploader;this.uploader2 = newFileUploader({

url:this.URL

, method:"POST", itemAlias:"upfile", autoUpload:true});this.uploader2.onSuccessItem =function (item, response, status, headers) {if(status == 200){

let rsp=JSON.parse(response);

let img= '';

that.data.content+=img;

}

};

560e91bdcdbadb03137b0eda5a691540.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值