Quill Editor H5 工具栏自定义图标和方法实现

教程分享 > WEB技术 > Web Editor (482) 2024-08-07 11:29:10

首先确定你用的是下面这个编辑器,Quill官网

Quill Editor H5 工具栏自定义图标和方法实现_图示-cb5f98a1bad848509ebe11ba5dd857b3.png
Quill

 

实现效果参考:

Quill Editor H5 工具栏自定义图标和方法实现_图示-4b3dde4dbe464a509c6688f9b487e91f.png
效果示例

 

然后开始了

配置toolbarOptions

默认的全量配置

const toolbarOptions = [
  ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
  ['blockquote', 'code-block'],
  ['link', 'image', 'video', 'formula'],

  [{ 'header': 1 }, { 'header': 2 }],               // custom button values
  [{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
  [{ '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
];

参考:Toolbar Module - Quill Rich Text Editor (quilljs.com)

在toolbar配置中添加自己的功能(如:media)

function initEditor(){
    const toolbarOptions = [
        ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
        ['blockquote', 'code-block'],
        ['link', 'image', 'video', 'formula'],

        // [{ 'header': 1 }, { 'header': 2 }],               // custom button values
        [{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
        [{ '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
        ['media']
    ];

如上所示,最后一个地方添加了一个media节点。

 

初始化Quill编辑器

登录后查阅

此处内容已经隐藏,需要登录后刷新查阅

登录/注册

 

注意:toolbar需要在初始化editor完成后进行。

至此就配置完毕了,打开即可查看效果。

Quill Editor H5 工具栏自定义图标和方法实现_图示-924cb6ca89a541cfafd86920dee3020b.png

 

image

 

完整示例代码:

VIP资源,登录后查阅

此处内容已经隐藏,需要开通会员后刷新查阅

登录/注册

 

https://www.leftso.com/article/2408020955485956.html

相关文章
首先确定你用的是下面这个编辑器,Quill官网Quill 实现效果参考:实现效果 然后开始了配置toolbarOptions默认的全量配置const toolb
ckeditor 5 自定义插件实现,自定义一个插件并在toolbar上。点击自定义插件图标响应对应事件。环境ckeditor 5.42.1(github稳定版
CKeditor无论那个版本,在我主要以文章编辑的时候,需要去掉默认的H1标签,所以需要自定义配置heading标签。同样CKeditor5 与之前的4版本有所不同。CKeditor5自定义配置...
问题说明我有一个自己的图像上传逻辑。 但是当我上传图像时,我想为图像添加一个自定义属性和一个自定义class。所以我的图片上传后应该是这样的:<img clas
CKeditor5 默认情况下的fontsize组件是小号默认大号特大号这种,没有具体的字体大小px单位选择,有些时候需要配置。故而对默认配置进行了修改。配置方式如下: C...
CKeditor5代码片段是官方自己集成的。可以通过在线构建的时候选择Code blocks 组件。选择后默认支持一下代码语言,是通过pre标签+code标签实现的。[ { langu...
在ckeditor4的时候绑定blur事件代码如下:window.editor.on('blur',function(){//这里写你想做的事儿})同样的代码搬到ckeditor5不仅不能用,还...
1.引入依赖js文件<script type="text/javascript" src="/plugin/ckeditor5/ckeditor.js"&gtl;</s
CKeditor 5.0 如何获取纯文本数据,ckeditor官方其实提供了获取带html脚本的内容方法,只需要配合jQuery简单就获取到了文本内容,详细操作如下
在CKEditor4版本中,对于编辑器高度设置是通过config配置里面的属性height来实现的,如下方所示CKEditor5 版本查文档发现已经没有这个配置了,通过网络资料查询得知,CKEd...
CKEditor 5 不重新构建移除某个plugin控件组件参考代码:ClassicEditor .create( document.querySelector...
ckeditor5 图片上传地址配置,ckeditor5和4的图片上传配置有点不一样。首先是确定你选的上传支持插件是什么,我这里是下面这个插件ckfinder
ckeditor5使用demo,配置详情参考。官网相关资源查阅,组件配置
ckeditor绑定keyup/keydown等事件实现一些功能,比如实时保存$(function(){//1编辑器初始化$('textarea#blog_content').ckeditor();
CKEditor4.4整合SprngMVC实现上传图片