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

Missing border on text body #4160

Open
EvanPiro opened this issue May 1, 2024 · 1 comment
Open

Missing border on text body #4160

EvanPiro opened this issue May 1, 2024 · 1 comment

Comments

@EvanPiro
Copy link

EvanPiro commented May 1, 2024

I'm getting a missing border in the text body when I load quill via a custom element.

Screen Shot 2024-05-01 at 10 13 28 AM

Steps for Reproduction

Here is a demo of the bug: https://jsfiddle.net/0fL9aph5/1/

Set stylesheet in head tags

<head>
    <link href="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.snow.css" rel="stylesheet" />
</head>

Load Quill via a custom element:

class QuillElement extends HTMLElement {
  constructor() {
    super();
  }

  connectedCallback() {
    this._editor = new Quill(this, {
      theme: "snow",
    });
  }
}

Expected behavior:

Border showing

Actual behavior:

Border is not showing

Platforms:

All browsers

Version:

2.0.0

@EvanPiro
Copy link
Author

EvanPiro commented May 1, 2024

My work around fix is to use shadow dom and set the style sheets when the element is connected:


class QuillElement extends HTMLElement {
  constructor() {
    super();
    const shadowRoot = this.attachShadow({ mode: "open" });

    // Create the Quill container element
    const editor = document.createElement("div");
    editor.id = "editor";
    shadowRoot.appendChild(editor);

    this.quillInstance = null;
    this.editorElement = editor;
  }

  async fetchAndAdoptStyles() {
    const response = await fetch(
      "https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.snow.css"
    );
    const styles = await response.text();
    const styleSheet = new CSSStyleSheet();
    styleSheet.replaceSync(styles);
    this.shadowRoot.adoptedStyleSheets = [styleSheet];
  }

  connectedCallback() {
    this.fetchAndAdoptStyles().then(() => {
      this.quillInstance = new Quill(this.editorElement, {
        theme: "snow",
      });
    });
  }
}

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