Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

'text-align' ignored on paste/load if using AlignClass #1873

Closed
nikparo opened this issue Dec 19, 2017 · 0 comments
Closed

'text-align' ignored on paste/load if using AlignClass #1873

nikparo opened this issue Dec 19, 2017 · 0 comments

Comments

@nikparo
Copy link
Contributor

nikparo commented Dec 19, 2017

When creating an editor with initial content, or when pasting content using clipboard.dangerouslyPasteHTML, at least text-align (e.g. <p style="text-align: right">right</p>) is ignored if the editor is using classes for alignment (the default). I presume this is a bug?

Codepen example: https://codepen.io/nik10110/pen/rpeMGp

Perhaps related: #1580

Steps for Reproduction

  1. Visit the codepen above. (quill playground)
  2. Copy paste something with alignment

Expected behavior:
Convert text-align: right to ql-align-right.

Actual behavior:
text-align: right is ignored.

Platforms:
Chromium Version 62.0.3202.94, Linux

Version:
Quill 1.3.4

Potential solution
Looking at modules/clipboard.js, function matchAttributor(node, delta) line 233:

attr = STYLE_ATTRIBUTORS[name]
if (attr != null && attr.attrName === name) {
  attr = STYLE_ATTRIBUTORS[name];
  formats[attr.attrName] = attr.value(node) || undefined;
}

attr is {attrName: "align", keyName: "text-align", ... } while name is text-align. Should it perhaps be checking for attr.keyName instead? At least it seems to work for me.

if (attr != null && attr.attrKey === name) {
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant