gtgalone / react-quilljs

React Hook Wrapper for Quill, powerful rich text editor.
https://www.npmjs.com/package/react-quilljs
MIT License
245 stars 28 forks source link

Uncaught TypeError: Quill.register not a function #71

Closed devdcodes9 closed 5 months ago

devdcodes9 commented 9 months ago

image

const { quill, quillRef, Quill } = useQuill({
    modules: {
      table: false,
      "better-table": {
        operationMenu: {
          items: {
            unmergeCells: {
              text: "Another unmerge cells name",
            },
          },
        },
      },
      mention: allowMention && {
        allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
        mentionDenotationChars: mentionChars,
        onSelect: onMentionSelect,
        renderItem: renderMentionItem,
        source: onSearchMention,
        showDenotationChar: showDenotationChar,
      },
      toolbar: disableToolbar
        ? false
        : toolbarOptions || {
            container: [
              ["bold", "italic", "underline", "strike", "blockquote"],
              [{ header: 1 }, { header: 2 }],
              [{ list: "ordered" }, { list: "bullet" }],
              [{ script: "sub" }, { script: "super" }],
              [{ indent: "-1" }, { indent: "+1" }],
              [{ color: [] }, { background: [] }],
              [{ font: [] }],
              [{ align: [] }],
              ["link", "image", "video"],
              ["clean"],
              ["emoji"],
              // ['table'],
            ],
          },

      "emoji-toolbar": true,
      "emoji-textarea": false,
      "emoji-shortname": true,
    },
  });

  if (Quill && !quill) {
    Quill.register("modules/better-table", QuillBetterTable);
    Quill.register("modules/emoji", Emoji.default, true);
    Quill.register("formats/emoji", Emoji.default.EmojiBlot, true);
    Quill.register("modules/emoji-toolbar", Emoji.default.ToolbarEmoji, true);
    Quill.register("modules/emoji-textarea", Emoji.default.TextAreaEmoji, true);
    Quill.register(
      "modules/emoji-shortname",
      Emoji.default.ShortNameEmoji,
      true
    );
    const BackgroundStyle = Quill.import("attributors/style/background");
    const ColorStyle = Quill.import("attributors/style/color");
    const FontStyle = Quill.import("attributors/style/font");
    const AlignStyle = Quill.import("attributors/style/align");
    const DirectionStyle = Quill.import("attributors/style/direction");
    Quill.register("modules/mention", mention.Mention);
    Quill.register("blots/mention", mention.MentionBlot);
    Quill.register(BackgroundStyle, true);
    Quill.register(ColorStyle, true);
    Quill.register(FontStyle, true);
    Quill.register(AlignStyle, true);
    Quill.register(DirectionStyle, true);
  }
devdcodes9 commented 9 months ago

@gtgalone Please check

gtgalone commented 5 months ago

Hi @devdcodes9

Sorry for late.

Did you check this? https://github.com/gtgalone/react-quilljs?tab=readme-ov-file#with-adding-plugins

Didi3333 commented 5 months ago

Hi,

With react-quilljs 1.3.3 and 1.3.4 On Version >= 2.0.0 Quill.register is not a function

That works with Quill 2.0.0-dev.4

To reproduce, i have created two codesanbox :

Quill 2.0.0-dev.4: (Version that works) https://codesandbox.io/p/sandbox/quill-2-0-0-dev-4-w2sfmd

Quill 2.0.0 -> 2.0.2 (Version with error) https://codesandbox.io/p/sandbox/quill-2-0-0-33qn9p

vtrphan commented 5 months ago

i got this TypeError obj.Quill is not a constructor

gtgalone commented 5 months ago

Hi @vtrphan @Didi3333 @devdcodes9

I just updated this package.

Please use version 2.0.0. Thanks.

Didi3333 commented 5 months ago

Thank you @gtgalone that well fix

DipPal513 commented 3 months ago

i got this TypeError obj.Quill is not a constructor