Skip to content

Persist Quill alignment options  #1557

@salomoneb

Description

@salomoneb

Description

Quill has an align option. Specifying this creates a button which allows you to choose a text alignment.

I added this to my inline form input like so:

overrideHeadline:
  _label: Headline
  _publish: articleHeadline
  _placeholder:
    height: 40px
  _has:
    input: inline
    buttons:
      - italic
      - strike
      # https://github.com/quilljs/quill/issues/1969#issuecomment-389697111
      - align: ["", "center", "right"]

I can align the text through the editor, but the alignment doesn't persist on save. Demo:

alignment.mov

There's a ql-align-* class that gets added to the Quill wrapper class while editing, but which gets stripped on save in inputs/wysiwyg-sanitize.js.

@james-owen and I talked over Slack about adding a transformTags function to wysiwyg-sanitize.js that would look for the special Quill alignment classes and add the alignment preferences as inline styles to the parent text element:

grab all paragraphs, grab their styles, if they match our list add them to parent element, strip p tags.

Expected Behavior

Kiln should save my alignment preference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions