0

ブートストラップでQuillを使いたい。

class="img-fluid"エディターで画像タグに属性を追加する必要があります。

4

2 に答える 2

2

最初にcssのセレクターを変更してみます:

 .ql-snow .ql-editor img {
   max-width: 100%;
   display: block;
   height: auto;
 }
/*  If your theme is different just change the selector */

それがうまくいかない場合は、img 埋め込みブロットを拡張することでできると思いますが、やり過ぎかもしれません。

于 2016-10-21T20:45:02.720 に答える
1

imageBlot を拡張し、それにクラスを追加するサンプル コードを次に示します。より具体的なものが必要な場合は、かなり簡単に調整できるはずです。

class ImageBlot extends BlockEmbed {
    static create(value) {
        let node = super.create();
        node.setAttribute('alt', value.alt);
        node.setAttribute('src', value.url);
        node.setAttribute('class', "img-fluid");
        return node;
    }

    static value(node) {
        return {
            alt: node.getAttribute('alt'),
            url: node.getAttribute('src')
        };
    }
}
ImageBlot.blotName = 'image';
ImageBlot.tagName = 'img';

Quill.register(ImageBlot);
于 2016-12-14T05:00:39.120 に答える