fastmail/Squire

Unexpected call to sanitizeToDOMFragment in Version 11.1.1 breaking new lines in iOS

cvle opened this issue · 1 comments

cvle commented

Since version 11.1.1 there is a Problem with creating a new line on iOS.

When using a simple sanitizeToDOMFragment like this:

const createSanitizeToDOMFragment = () => {
  const purify = createDOMPurify(window);
  purify.setConfig({
    ALLOWED_TAGS: ["div", "br"],
    RETURN_DOM: true,
  });

  return (html: string) => {
    const frag = document.createDocumentFragment();
    if (html) {
      // Added this for debug.
      alert(html);

      const sanitized = purify.sanitize(html);
      while (sanitized.firstChild) {
        frag.appendChild(sanitized.firstChild);
      }
    }
    return frag;
  };
};

Starting with version 11.1.1 sanitizeToDOMFragment would be called when tapping Enter to create a new line.

image

Afterwards the cursor gets moved to the beginning of the RTE without actually creating a new line.

image

This only happens in version 11.1.1, so it must be caused by this commit 108ff8f

As a workaround I have downgraded to 11.1.0 which fixed the issue.

Also I want to take this moment to thank you all for this awesome open source project <3

Hey, is it possible if you could tell me how the sarcasm button works? & howd you implement that & spoiler as its not present by default