flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Is Line Spacing is available? or is it something that I have to configure by my own?

Open Wassiem-Ibrahim opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

The question

If I have a quill document and I want to add styling ( change line spacing), is it something available in the package? If not, anyone can advise me on how to do it?

Wassiem-Ibrahim avatar Feb 09 '24 11:02 Wassiem-Ibrahim

Hello. I solved the problem by overriding custom styles in QuillEditor

  customStyles: DefaultStyles(
          sizeSmall: FontSizeType.h3.getTextStyle
          sizeLarge: FontSizeType.h2.getTextStyle,
          sizeHuge: FontSizeType.h1.getTextStyle,
        ),

and for each style apply SizeAttribute, like SizeAttribute('huge')

EgorK0rshun avatar Feb 09 '24 11:02 EgorK0rshun

I am looking to implement a line spacing feature. This means that the user can press a button from the quilltoolbar and choose the spacing he wants, and then the changes should apply to the text. Let's say the spacing was the default 1.0, then the user chooses 1.5, so this would increase the line spacing in the document or the selected text.

Wassiem-Ibrahim avatar Feb 09 '24 11:02 Wassiem-Ibrahim

You can just add a custom attribute and use a custom button to the toolbar to apply your line spacing options. But this has a issue, the cursor height is based in the size of the line height instead of the font size of the current word position. This can add a visual error with a line spacing over 2.0. it looks weird

This is an example of how should be your custom attribute:

class LineSpacingAttribute extends Attribute<double>{
   LineSpacingAttribute({double value = 1.0}) 
   : super(value, AttributeScope.block, "lineHeight");
}

CatHood0 avatar Mar 06 '24 17:03 CatHood0

@CatHood0 implemented this toolbar function. It is not enabled by default - where you set QuillSimpleToolbarConfigurations you can enable it

configurations.showLineHeightButton = true

or add the button to your custom toolbar

QuillToolbarSelectLineHeightStyleDropdownButton

AtlasAutocode avatar Aug 10 '24 13:08 AtlasAutocode