Issue on RichTextEditor with vue version 3 (Cannot read properties of undefined (reading 'sanitizeHelper'))

I am trying to use the vue-richtexteditor with vue version 3 and Typescript and the following error happens:


Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'sanitizeHelper')


Follow my component code:

<script lang="ts">
import { defineAsyncComponent, defineComponent } from 'vue';

const RichTextEditorComponent = defineAsyncComponent(
() => import('@syncfusion/ej2-vue-richtexteditor')
.then(module => module.RichTextEditorComponent)
);

export default defineComponent({
components: {
RichTextEditorComponent,
},
});
</script>

<template>
<RichTextEditorComponent>
content
</RichTextEditorComponent>
</template>

6 Replies

BS Buvana Sathasivam Syncfusion Team February 3, 2022 04:25 PM UTC

Hi Renan, 

Greetings from Syncfusion support. 

We have checked your shared code. We were able to reproduce your reported issue. You are not injecting the Rich Text Editor component modules and have not loaded styles on defineAsyncComponent. Please find the below code for your reference. 

<script lang="ts"> 
import { defineAsyncComponent, defineComponent } from 'vue'; 
import { Toolbar, Link, Image, HtmlEditor } from "@syncfusion/ej2-vue-richtexteditor"; 

const RichTextEditorComponent = defineAsyncComponent( 
  () => import('@syncfusion/ej2-vue-richtexteditor') 
    .then(module => module.RichTextEditorComponent) 
); 

export default defineComponent({ 
  components: { 
    RichTextEditorComponent, 
  }, 
  provide: { 
        richtexteditor:[Toolbar, Link, Image, HtmlEditor]  // Define Rich Text Editor modules 
   
}); 
</script> 

<template> 
  <div class="cw--rte"> 
    <RichTextEditorComponent> 
      content 
    </RichTextEditorComponent> 
  </div> 
</template> 
<style> 
@import '../node_modules/@syncfusion/ej2-base/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-icons/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-lists/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-vue-richtexteditor/styles/material.css'; 
</style> 



Please let us know if you have any queries. 

Regards, 
Buvana S 



RM Renan Monteiro da Silva February 7, 2022 07:36 AM UTC

My CSS files were imported outside, but you're right, I didn't import the modules, but after adding, the same persists. Please have a look to my code again (I've simplified it a bit):

<script lang="ts">
import { defineAsyncComponent, defineComponent } from 'vue';
import { Toolbar, Link, Image, HtmlEditor, RichTextEditorComponent } from '@syncfusion/ej2-vue-richtexteditor';

export default defineComponent({
provide: {
richtexteditor: [Toolbar, Link, Image, HtmlEditor],
},
components: {
RichTextEditorComponent,
},
});
</script>

<template>
<div class="cw--rte">
<RichTextEditorComponent>
content
</RichTextEditorComponent>
</div>
</template>

Note, my editor couldn't fine the modules dependencies:


There two modules are the only available:




BS Buvana Sathasivam Syncfusion Team February 8, 2022 01:29 PM UTC

Hi Renan, 

We have checked your reported issue. We suspect that you are not installing or upgrading the Rich Text Editor component properly. So, we suggest you follow the below steps to upgrade the Syncfusion packages to the latest version and remove duplicate packages in the node modules folder (if any) to resolve the problem. 

  • Delete package.lock.json file from your application. 
  • Remove the @syncfusion package folder from the node_modules.
  • Use latest version or “*”(Installs the latest packages) for all Syncfusion components in package.json file. 
  • Then install the NPM packages.


Regards, 
Buvana S 




MA Manuel May 25, 2022 07:26 PM UTC

Hi!

Unfortunately, I ran into the same issue while trying to create a single page component in Vue 3.2 (Vite).
Did you find a solution yet?

Unhandled error during execution of mounted hook at 

rich-text-editor.js:608 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'sanitizeHelper')


<template>

  <v-container>
    <h2 class="text-h2 mt-6 mb-10">New Page</h2>
    <v-form>
      <v-row>
        <v-col cols="8">
          <v-text-field
            label="Title"
            type="text"
            v-model="title"
            hint="required"
            :rules="[() => !!title || 'This field is required']"
          />
        </v-col>
        <v-col cols="4">
          <v-text-field
            label="Page name"
            type="text"
            v-model="machine_name"
            :rules="[
              () => !!machine_name || 'This field is required',
              () =>
                /^[a-z-]+$/.test(machine_name) ||
                'Only lowercase letters and hyphens',
            ]"
            hint="required - only lowercase letters and hyphens"
          />
        </v-col>
      </v-row>


      <v-card>
        <RichTextEditorComponent id="default" ref="rteInstance">
          <p>Lorem ipsum ...</p>
        </RichTextEditorComponent>
      </v-card>


      <div class="d-flex mt-10">
        <v-btn color="primary" prepend-icon="mdi-check" text @click="savePage">
          Save
        </v-btn>
        <v-spacer />
      </div>
    </v-form>
  </v-container>
</template>


<script lang="ts">
import { defineComponent } from "vue";
import type { Maybe } from "@/types/app";
import { mapState } from "pinia";
import { useAppStore } from "@/stores/app";
import {
  RichTextEditorComponent,
  Toolbar,
  Link,
  Image,
  HtmlEditor,
  Table,
} from "@syncfusion/ej2-vue-richtexteditor";


export default defineComponent({
  name: "NewPageView",
  components: {
    RichTextEditorComponent,
  },
  provide: {
    richtexteditor: [Toolbar, Link, Image, HtmlEditor, Table],
  },
  data() {
    return {
      title: null as Maybe<string>,
      machine_name: null as Maybe<string>,
      description: null as Maybe<string>,
    };
  },
  computed: {
    ...mapState(useAppStore, ["token"]),
  },
  methods: {
    savePage() {
      // do something
    },
  },
});
</script>


<style>
@import "@syncfusion/ej2-base/styles/material-dark.css";
@import "@syncfusion/ej2-icons/styles/material.css";
@import "@syncfusion/ej2-buttons/styles/material-dark.css";
@import "@syncfusion/ej2-splitbuttons/styles/material-dark.css";
@import "@syncfusion/ej2-inputs/styles/material-dark.css";
@import "@syncfusion/ej2-lists/styles/material-dark.css";
@import "@syncfusion/ej2-navigations/styles/material-dark.css";
@import "@syncfusion/ej2-popups/styles/material-dark.css";
@import "@syncfusion/ej2-dropdowns/styles/material-dark.css";
@import "@syncfusion/ej2-vue-richtexteditor/styles/material-dark.css";
</style>




MA Manuel May 26, 2022 08:15 AM UTC

After some hours of debugging, apparently, I have found the issue.
It's vuetify. Seems like they interfere with each other.

With those lines removed from my Vite config, the rich text editor works as expected

import vuetify from "@vuetify/vite-plugin";
plugins: [
vuetify({
autoImport: true,
}),
],


BS Buvana Sathasivam Syncfusion Team May 26, 2022 11:16 AM UTC

Thank you for your update. Please let us know if you have any further assistance.


Loader.
Up arrow icon