quill icon indicating copy to clipboard operation
quill copied to clipboard

Line Spacing

Open leo-zhao opened this issue 12 years ago • 31 comments

Does quill have customizable line spacing ability?

leo-zhao avatar Aug 20 '14 02:08 leo-zhao

You can specify this style with addStyles ex.

quill.addStyles({
  'div': { 'line-height': '24px' }
});

jhchen avatar Aug 20 '14 03:08 jhchen

it's not working for me:/

RavidGolan avatar Nov 29 '15 11:11 RavidGolan

It should now be:

quill.theme.addStyles({
  'div': { 'line-height': '24px' }
});

jhchen avatar Nov 29 '15 17:11 jhchen

  1. The html does change.. i would like to save my html and open it later.. i tried: quill.theme.addStyles({ 'div': { 'line-height': '24px' } }); var html = quill.getHTML(); $('#myHtml').val(html); // does not contains line-height
  2. how can i change it? i would like to change the line-height

RavidGolan avatar Dec 01 '15 09:12 RavidGolan

This API does not change the editor's HTML

jhchen avatar Dec 01 '15 16:12 jhchen

it seems like the latest version dose not exist the addStyle api. I can not setup the line height style. image

Jiiun avatar May 31 '17 02:05 Jiiun

@Jiiun addStyle isn't required anymore. You can override the line-height or any other style with CSS.

.ql-editor {
    line-height: 1.42;
}

benbro avatar May 31 '17 05:05 benbro

@benbro thanks for your replying. how can i set line-height in each line just like below image

Jiiun avatar May 31 '17 06:05 Jiiun

@Jiiun you need to create a custom attributor and a custom toolbar button. You can use the direction attributor as an example. https://quilljs.com/guides/how-to-customize-quill/#content-and-formatting If you have further questions please use StackOverflow. github issues are for bugs.

benbro avatar May 31 '17 07:05 benbro

thank you very much~

Jiiun avatar May 31 '17 09:05 Jiiun

image haha! I fixed it

Jiiun avatar Jun 05 '17 03:06 Jiiun

@benbro whatever I try nothing works and I've spent a couple of hours on this already. Everything looks fine but it is always received in Outlook or GMail with large line-spacing (see pic below).

   -webkit-margin-after: 1em;
   -webkit-margin-before: 1em;

seem to be the culprits but I set them in the css but no luck. Is the way around this to add inline styles & if so, is it easy to add them?

Is it a Quill issue or has anyone else come across this one? Any help much appreciated.

.ql-editor  {
   line-height: 1.20 !important;
   font-family: Calibri, Helvetica !important;
   font-size: 15px !important;
   -webkit-margin-after:0px;
   -webkit-margin-before:0px;
}
.ql-editor p {    line-height: 1.2;}

image

tomcon avatar Jul 04 '17 16:07 tomcon

@tomcon This issue is old and unrelated to your question. Quill uses classes by default. To make the output work in email you need to use inline styles instead. Read this guide about using inline style attributes.

benbro avatar Jul 04 '17 17:07 benbro

@benbro with respect: "Does quill have customizable line spacing ability?" is completely related to my question.

I've read the guide quite a bit in the past and again just now but it is not very clear on this topic plus I am using ES5 and all examples are ES6.

Can anyone help with an example please of how to simply add a default line-height inline rule to all paragraph tags? This has cropped up late in our project and we didn't think we'd hit this problem so any help would be much appreciated (don't want to have to so a search and replace type-exercise post edit). Thanks

tomcon avatar Jul 04 '17 18:07 tomcon

For anyone else that may come here with a similar problem: best short term solution was to replace < p > with < br > and removing < /p > on editor save (adding inline-styles still had issues).

See also: https://stackoverflow.com/questions/38024698/html-email-how-do-you-remove-webkit-margin-before-1em-webkit-margin-after

tomcon avatar Jul 05 '17 10:07 tomcon

@Jiiun 你好,我想问下,你的行高功能具体是怎么实现的? toolbar里如何定义?

xiechao1211 avatar Jul 30 '17 07:07 xiechao1211

Set line-height is not real LineSpacing; It is not like MSoffice word's it

Malenconiaprincep avatar Dec 20 '17 03:12 Malenconiaprincep

image haha! I fixed it still does not work

miracle9312 avatar Sep 19 '18 09:09 miracle9312

@tomcon This issue is old and unrelated to your question. Quill uses classes by default. To make the output work in email you need to use inline styles instead. Read this guide about using inline style attributes.

    import _Quill from 'quill';
    import { sizeWhiteList, alignWhiteList } from './formats'
    const Quill = window.Quill || _Quill;
    let config = {
        scope: Parchment.Scope.INLINE,
        whitelist: ['1.0em','1.1em','1.2em','1.3em','1.4em','1.5em','1.6em']
    }
    var lineHtStyle = new Parchment.Attributor.Style('lineheight','line-height', config);

    Quill.register(lineHtStyle, true);```
i want to set custom lineheight, but it dose not work

miracle9312 avatar Sep 19 '18 09:09 miracle9312

Hi, this @Jiiun codes its working, but you need to create a css too.

this is my js code:

var Parchment = Quill.import('parchment');
    var lineHeightConfig = {
      scope: Parchment.Scope.INLINE,
      whitelist: [
        '1.0',
        '1.2',
        '1.5',
        '1.6',
        '1.8',
        '2.0',
        '2.4',
        '2.8',
        '3.0',
        '4.0',
        '5.0'
      ]
    };
    var lineHeightClass = new Parchment.Attributor.Class('lineheight', 'ql-line-height', lineHeightConfig);
    var lineHeightStyle = new Parchment.Attributor.Style('lineheight', 'line-height', lineHeightConfig);
    Parchment.register(lineHeightClass);
    Parchment.register(lineHeightStyle);

And my css:

.ql-snow .ql-picker.ql-lineheight{
  width: 58px;
}

.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='1.0']::before {content: '1.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='1.0']::before {content: '1.0' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='1.2']::before {content: '1.2';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='1.2']::before {content: '1.2' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='1.5']::before {content: '1.5';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='1.5']::before {content: '1.5' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='1.6']::before {content: '1.6';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='1.6']::before {content: '1.6' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='1.8']::before {content: '1.8';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='1.8']::before {content: '1.8' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='2.0']::before {content: '2.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='2.0']::before {content: '2.0' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='2.4']::before {content: '2.4';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='2.4']::before {content: '2.4' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='2.8']::before {content: '2.8';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='2.8']::before {content: '2.8' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='3.0']::before {content: '3.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='3.0']::before {content: '3.0' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='4.0']::before {content: '4.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='4.0']::before {content: '4.0' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='5.0']::before {content: '5.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='5.0']::before {content: '5.0' !important;}

clpacheco90 avatar Sep 19 '18 20:09 clpacheco90