quill-blot-formatter icon indicating copy to clipboard operation
quill-blot-formatter copied to clipboard

Super expression must either be null or a function, not undefined

Open itinglight opened this issue 2 years ago • 12 comments

Everything works fine on dev (npm run dev) but after build I have this error:

Super expression must either be null or a function, not undefined.

Without BlotFormatter module it also works fine. It is laravel + vue + inertia + vite + VueQuill

<template>
    <div>
        <QuillEditor theme="snow" :modules="modules"/>
    </div>
</template>

<script>
    import { QuillEditor } from '@vueup/vue-quill'
    import BlotFormatter from 'quill-blot-formatter'
    import '@vueup/vue-quill/dist/vue-quill.snow.css';

    export default  {
        components: {
            QuillEditor
        },
        setup: () => {
            const modules = {
                name: 'blotFormatter',  
                module: BlotFormatter, 
                options: {/* options */}
            }
        return { modules }
    },
}
</script>

itinglight avatar Jan 12 '23 03:01 itinglight

me too

mortal-nf avatar Jan 12 '23 09:01 mortal-nf

Same.

mariusberget92 avatar Jan 17 '23 10:01 mariusberget92

same

Hadrien-Estela avatar Jan 17 '23 15:01 Hadrien-Estela

Same issue here

tedik123 avatar Mar 01 '23 22:03 tedik123

I had the same issue - it started working when I replaced that import line with the Readme's suggested method of importing one module at a time:

import BlotFormatter from 'quill-blot-formatter/dist/BlotFormatter'

I have absolutely no idea why that made it work, but it might be worth a shot to anyone who stumbles across this issue.

tjessessky avatar Mar 03 '23 01:03 tjessessky

I have involved myself in this issue for several hours and tried different methods, but I did not get any results. Finally, I thought of using it in the CDN method in the project because changing the editor was too time-consuming for me. in html file <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill-blot-formatter.min.js"></script> in vue file editorModules: [ { name: 'blotFormatter', module: QuillBlotFormatter.default, options: {/* options */} }, ]

rezaghz avatar Apr 14 '23 16:04 rezaghz

I also encountered the same issue, but I resolved it with the following code. (TypeScript + Vue + Vite + VueQuill)

In the vue file:

<template>
  <QuillEditor
    theme="snow"
    :toolbar="toolbarOptions"
    :modules="modules"
    contentType="html"
    v-model:content="currentEDM.content"
  />
</template>

<script setup>
import { QuillEditor, Quill } from "@vueup/vue-quill";
import BlotFormatter from "quill-blot-formatter/dist/BlotFormatter";
import "@vueup/vue-quill/dist/vue-quill.snow.css";

// Quill: Toolbar
const toolbarOptions = [
  [{ font: [] }],
  [{ header: [1, 2, 3, 4, 5, 6, false] }],
  ["bold", "italic", "underline", "strike"],
  [{ script: "sub" }, { script: "super" }],
  [{ color: [] }, { background: [] }],
  [{ list: "ordered" }, { list: "bullet" }, { align: [] }],
  ["link"]
];

// Quill: Modules
const modules = ref([
  {
    name: "blotFormatter",
    module: BlotFormatter,
    options: {
      /* options */
    }
  }
]);

// Quill: Quill Blot Formatter
Quill.register("modules/blotFormatter", BlotFormatter);

// Quill: Inline Style
Quill.register(Quill.import("attributors/class/align"), true);
Quill.register(Quill.import("attributors/class/font"), true);
Quill.register(Quill.import("attributors/style/align"), true);
Quill.register(Quill.import("attributors/style/font"), true);

In the quill-blot-formatter.d.ts file (if you are using TypeScript): declare module "quill-blot-formatter/dist/BlotFormatter";

The above code worked for me, so perhaps you can give it a try.

bear320 avatar May 17 '23 01:05 bear320

I also encountered the same issue, but I resolved it with the following code. (TypeScript + Vue + Vite + VueQuill)

In the vue file:

<template>
  <QuillEditor
    theme="snow"
    :toolbar="toolbarOptions"
    :modules="modules"
    contentType="html"
    v-model:content="currentEDM.content"
  />
</template>

<script setup>
import { QuillEditor, Quill } from "@vueup/vue-quill";
import BlotFormatter from "quill-blot-formatter/dist/BlotFormatter";
import "@vueup/vue-quill/dist/vue-quill.snow.css";

// Quill: Toolbar
const toolbarOptions = [
  [{ font: [] }],
  [{ header: [1, 2, 3, 4, 5, 6, false] }],
  ["bold", "italic", "underline", "strike"],
  [{ script: "sub" }, { script: "super" }],
  [{ color: [] }, { background: [] }],
  [{ list: "ordered" }, { list: "bullet" }, { align: [] }],
  ["link"]
];

// Quill: Modules
const modules = ref([
  {
    name: "blotFormatter",
    module: BlotFormatter,
    options: {
      /* options */
    }
  }
]);

// Quill: Quill Blot Formatter
Quill.register("modules/blotFormatter", BlotFormatter);

// Quill: Inline Style
Quill.register(Quill.import("attributors/class/align"), true);
Quill.register(Quill.import("attributors/class/font"), true);
Quill.register(Quill.import("attributors/style/align"), true);
Quill.register(Quill.import("attributors/style/font"), true);

In the quill-blot-formatter.d.ts file (if you are using TypeScript): declare module "quill-blot-formatter/dist/BlotFormatter";

The above code worked for me, so perhaps you can give it a try.

thanks bro, it's also worked for me

suka233333 avatar Aug 09 '23 08:08 suka233333

I've tried to import like that: import BlotFormatter from "quill-blot-formatter/dist/BlotFormatter"; but I get another console error: TypeError: p is not a constructor

So I investigate and found another solution:

  1. Use import from the index: import BlotFormatter from "quill-blot-formatter";
  2. Add guill-blot-formatter in the optimizeDeps (vite.config.ts): Example of my vite.config.ts
import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  optimizeDeps: {
    include: ["quill-blot-formatter"],
  },
});

With this config, all was working. I Hope it can help others too.

andasilva avatar Oct 30 '23 22:10 andasilva

I've tried to import like that: import BlotFormatter from "quill-blot-formatter/dist/BlotFormatter"; but I get another console error: TypeError: p is not a constructor

So I investigate and found another solution:

  1. Use import from the index: import BlotFormatter from "quill-blot-formatter";
  2. Add guill-blot-formatter in the optimizeDeps (vite.config.ts): Example of my vite.config.ts
import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  optimizeDeps: {
    include: ["quill-blot-formatter"],
  },
});

With this config, all was working. I Hope it can help others too.

Yeah 💯 ! Thank you very much. It worked

NghiaLam11 avatar Dec 21 '23 05:12 NghiaLam11

I've tried to import like that: import BlotFormatter from "quill-blot-formatter/dist/BlotFormatter"; but I get another console error: TypeError: p is not a constructor

So I investigate and found another solution:

  1. Use import from the index: import BlotFormatter from "quill-blot-formatter";
  2. Add guill-blot-formatter in the optimizeDeps (vite.config.ts): Example of my vite.config.ts
import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  optimizeDeps: {
    include: ["quill-blot-formatter"],
  },
});

With this config, all was working. I Hope it can help others too.

It does work, but you have to import import BlotFormatter from "quill-blot-formatter/dist/BlotFormatter"; in Nuxt 3

yohames avatar Apr 02 '24 05:04 yohames

I am also getting the same issue with the integration of htmlEditButton in reactQuill

super expression must either be null or a function, not undefined

I am working on a React project with a rich text editor using ReactQuill. Everything works fine in development mode (local), but after the build it is failing

This error seems to be related to the inclusion of the htmlEditButton module. When I remove the htmlEditButton module, the build works fine.

import ReactQuill, { Quill } from 'react-quill';
import 'react-quill/dist/quill.snow.css';
import '../quillStyles.css';
import htmlEditButton from 'quill-html-edit-button';

Quill.register('modules/htmlEditButton', htmlEditButton);

ravi-ranjan-bb avatar Jun 26 '24 06:06 ravi-ranjan-bb