Sha256: 84f1db264b8f6a0f38b1a0f8cff26cc2157927f20287abe09830d491904142d8

Contents?: true

Size: 812 Bytes

Versions: 5

Compression:

Stored size: 812 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

5 entries across 5 versions & 1 rubygems

Version Path
pages_core-3.14.0 app/javascript/features/RichText.tsx
pages_core-3.13.0 app/javascript/features/RichText.tsx
pages_core-3.12.7 app/javascript/features/RichText.tsx
pages_core-3.12.6 app/javascript/features/RichText.tsx
pages_core-3.12.5 app/javascript/features/RichText.tsx