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

<p>` tags are adding instead of table. #89

Open
akshaya-a-p opened this issue Apr 24, 2023 · 3 comments
Open

<p>` tags are adding instead of table. #89

akshaya-a-p opened this issue Apr 24, 2023 · 3 comments

Comments

@akshaya-a-p
Copy link

akshaya-a-p commented Apr 24, 2023

I'm working in React JS apps, <p> tags are adding instead of table. I tired exposing quill js file in index.html file. but still facing same issue. Can I get help in resolving this issue.

import React, { useEffect, useMemo, useRef, useState } from "react";
import ReactQuill, { Quill } from "react-quill-with-table";
import QuillBetterTable from "quill-better-table";
import "react-quill-with-table/dist/quill.snow.css";
import "quill-better-table/dist/quill-better-table.css";

Quill.register({ "modules/better-table": QuillBetterTable });

export default function Editor() {
  const reactQuillRef = useRef(null);

  const insertTable = () => {
    const editor = reactQuillRef.current.getEditor();
    const tableModule = editor.getModule("better-table");
    tableModule.insertTable(3, 3);
  };

  useEffect(() => {
    const editor = reactQuillRef.current.getEditor();
    const toolbar = editor.getModule("toolbar");
    toolbar.addHandler("table", () => {
      insertTable();
    });
  }, []);

  const modules = useMemo(
    () => ({
      table: false,
      "better-table": {
        operationMenu: {
          items: {
            unmergeCells: {
              text: "Another unmerge cells name"
            }
          }
        }
      },
      keyboard: {
        bindings: QuillBetterTable.keyboardBindings
      },
      toolbar: [
        [
          "bold",
          "italic",
          "underline",
          "strike",
          { align: [] },
          { script: "sub" },
          { script: "super" },
          { list: "ordered" },
          { list: "bullet" },
          { indent: "-1" },
          { indent: "+1" }
        ], // toggled buttons
        ["table"]
      ]
    }),
    []
  );
  return (
    <div>
      <ReactQuill ref={reactQuillRef} modules={modules} theme="snow" />
    </div>
  );
}
@akshaya-a-p akshaya-a-p changed the title <p>` tags are adding instead of table. I tired exposing quill js file in index.html file. but still facing same issue. Can I get help in resolving this issue <p>` tags are adding instead of table. Apr 24, 2023
@SharePickle
Copy link

Hey, if this still relevant to you or anyone else - make sure you have 1 instance of Quill in your node_modules and its version is ^2.0.0-dev.3. In my case I had wrong version and then 2 instances of Quill, one in root node_modules and the other in react-quill-with-table also had its own version:

node_modules/quill <- 1st instance
node_modules/react-quill-with-table/node_modules/quill <- 2nd instance

@febriyoga-bs
Copy link

Hey, if this still relevant to you or anyone else - make sure you have 1 instance of Quill in your node_modules and its version is ^2.0.0-dev.3. In my case I had wrong version and then 2 instances of Quill, one in root node_modules and the other in react-quill-with-table also had its own version:

node_modules/quill <- 1st instance
node_modules/react-quill-with-table/node_modules/quill <- 2nd instance

i confuse with your explanation, so what should i do if i have this dependencies (that have Quill instance):
"quill": "^2.0.0-dev.3",
"react-quill": "^2.0.0",
"react-quill-with-table": "^1.3.3",

(?)

@SharePickle
Copy link

You have correct dependencies in package.json (I have the same setup). Remove package.lock and node_modules and reinstall everything.

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

3 participants