Sha256: 2e93a6b2f295f02249fa2f31ca6428c0de6b12c20344d79c991ac3889db03e91

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

import React from "react";
import { createRoot } from "react-dom/client";
import RichTextArea from "../components/RichTextArea";
import readyHandler from "../lib/readyHandler";

class RichText {
  apply () {
    const elems = document.querySelectorAll("textarea.rich");
    elems.forEach((elem) => {
      this.enhance(elem);
    });
  }

  enhance (elem: HTMLTextAreaElement) {
    const container = document.createElement("div");
    elem.parentNode.appendChild(container);
    createRoot(container).render(
      <RichTextArea value={elem.value}
                    name={elem.name}
                    rows={elem.rows}
                    id={elem.id} />,
      container
    );
    elem.parentNode.removeChild(elem);
  }

  start () {
    readyHandler.ready(() => {
      this.apply();
    });
  }
}

export default new RichText();

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pages_core-3.12.4 app/javascript/features/RichText.tsx
pages_core-3.12.3 app/javascript/features/RichText.tsx