Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Quill editor lists (bulleted list and ordered list) do not render #4381

Closed
jelyware opened this issue Aug 19, 2024 Discussed in #4245 · 3 comments
Closed

Quill editor lists (bulleted list and ordered list) do not render #4381

jelyware opened this issue Aug 19, 2024 Discussed in #4245 · 3 comments

Comments

@jelyware
Copy link

jelyware commented Aug 19, 2024

Discussed in #4245

Originally posted by ChabbehAymen June 7, 2024
screen shot below shows the issue:
Screenshot_20240608_045433-1

The text in the middle should appear like this if numbered (ordered type):

  1. line one
  2. line tow
  3. line tree

OR like this if unordered (bullet type):

  • line one
  • line tow
  • line tree

This issue appears to be due to quill v2 no longer providing support for the list bullet or ordered types. I compared the packages/quill/formats/list.ts files from quill v1 with that of quill v2.

quill v1:

  static formats(domNode) {
    if (domNode.tagName === 'OL') return 'ordered';
    if (domNode.tagName === 'UL') {
      if (domNode.hasAttribute('data-checked')) {
        return domNode.getAttribute('data-checked') === 'true' ? 'checked' : 'unchecked';
      } else {
        return 'bullet';
      }
    }
    return undefined;
  }

  constructor(domNode) {
    super(domNode);
    const listEventHandler = (e) => {
      if (e.target.parentNode !== domNode) return;
      let format = this.statics.formats(domNode);
      let blot = Parchment.find(e.target);
      if (format === 'checked') {
        blot.format('list', 'unchecked');
      } else if(format === 'unchecked') {
        blot.format('list', 'checked');
      }
    }

    domNode.addEventListener('touchstart', listEventHandler);
    domNode.addEventListener('mousedown', listEventHandler);
  }

quill v2:

  constructor(scroll: Scroll, domNode: HTMLElement) {
    super(scroll, domNode);
    const ui = domNode.ownerDocument.createElement('span');
    const listEventHandler = (e: Event) => {
      if (!scroll.isEnabled()) return;
      const format = this.statics.formats(domNode, scroll);
      if (format === 'checked') {
        this.format('list', 'unchecked');
        e.preventDefault();
      } else if (format === 'unchecked') {
        this.format('list', 'checked');
        e.preventDefault();
      }
    };
    ui.addEventListener('mousedown', listEventHandler);
    ui.addEventListener('touchstart', listEventHandler);
    this.attachUI(ui);
  }

  format(name: string, value: string) {
    if (name === this.statics.blotName && value) {
      this.domNode.setAttribute('data-list', value);
    } else {
      super.format(name, value);
    }
  }
}

quill v2 appears to be missing the domNode.tagName checks to ensure that the list type is correctly defined, e.g. if (domNode.tagName === 'OL') return 'ordered';

@jelyware
Copy link
Author

NOTE: This issue may be related to #4273.

@jelyware jelyware changed the title Quill editor lists (checked list, doted list and numbered list) do not render Quill editor lists (checked list, bulleted list and ordered list) do not render Aug 19, 2024
@jelyware jelyware changed the title Quill editor lists (checked list, bulleted list and ordered list) do not render Quill editor lists (bulleted list and ordered list) do not render Aug 19, 2024
@jelyware
Copy link
Author

jelyware commented Aug 20, 2024

This issue is also related to #4103 which points to KillerCodeMonkey/ngx-quill#1888 and let the user know that [innerhtml] and quill view html is broken in quill v2

@jelyware
Copy link
Author

CLOSING this issue since it is already being addressed here #4103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant