Quill: How to add a css class to an img element

Created on 27 Sep 2017  ·  11Comments  ·  Source: quilljs/quill

img src="" class="img-fluid" alt="Responsive image"

const range = quill.getSelection();
quill.insertEmbed(range.index, 'image', ${url});
quill.pasteHTML(range.index, <img src="${url}" class="img-fluid" alt="Responsive image">);

Most helpful comment

var Image = Quill.import('formats/image');
Image.className = 'img-fluid';
Quill.register(Image, true);

All 11 comments

var Image = Quill.import('formats/image');
Image.className = 'img-fluid';
Quill.register(Image, true);

问题解决了吗?求解决办法

@NGyc yes

var Image = Quill.import('formats/image');
Image.className = 'img-fluid';
Quill.register(Image, true);

@ModPhoenix looks like you found how to do it.
Closing

抱歉,我是初学者,看不太懂具体是怎么去设置,可不可以再写详细一点呢,谢谢了!

var Image = Quill.import('formats/image');
  Image.className = 'img-fluid';
  Quill.register(Image, true);

  const quill = new Quill('#editor-container', {
    modules: {
      toolbar: '#toolbar-container'
    },
    placeholder: 'Compose ansdfdsfsdf epic...',
    theme: 'snow'
  });

比如我现在要插入一个

, 怎么给插入的div添加一个class呢?

@ModPhoenix alt属性以及width或者自定义的属性怎么破?在线等,急!

@zhoushuren 请问width属性找到方法了吗

@Mkluas 我是重写Image组件实现的。

Was this page helpful?
0 / 5 - 0 ratings