Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ekrist1's avatar

Vue3 and TrixEditor: Failed to resolve component: trix-editor

I’m fiddling around with Vue 3 (Inertia) and are trying to integrate the Trix Editor. The editor renders, but there is a error in the console log:

[Vue warn]: Failed to resolve component: trix-editor 
  at <TrixComponent id="A" onDataFromTrix=fn<bound getDataFromTrix> > 
  at <BaseLayout> 
  at <Home key=1603032868935 > 
  at <Inertia initialPage= 
Object { component: "Home", props: [], url: "/", version: "", scrollRegions: [], rememberedState: {} }
 resolveComponent=fn<resolveComponent> > 
  at <App>

Anyone has any clue how to fix this warning?

TrixComponent

<template>
    <div>
        <input :id="id" type="hidden" name="content" v-model="trixText">
        <!-- updated here -->
        <trix-editor :input="id"></trix-editor>
    </div>
</template>

<script>
import Trix from 'trix'
import 'trix/dist/trix.css'

export default {
    props: ["id"],
    data() {
        return {
            trixText: ""
        };
    },
    methods: {
        setTextToTrix(e) {
            this.trixText = document.getElementById(this.id).value;
        },
        emitDataBackToComponent() {
            this.$emit("dataFromTrix", this.trixText);
        }
    },
    mounted() {
        document.addEventListener("trix-change", this.setTextToTrix);
    },
    beforeUnmount: function() {
        document.removeEventListener("trix-change", this.setTextToTrix);
    },
    updated() {
        this.emitDataBackToComponent();
    }
};
</script>

Home page

//Home.vue
<template>
    <BaseLayout>

    <template v-slot:header>
        <h1>Here might be a page title</h1>
    </template>

    <template v-slot:default>
        <h1>Hello from Inertia Vue 3</h1>
        <inertia-link href="/contact">Contact</inertia-link>
        <inertia-link href="/blog">Blog</inertia-link>
        <TrixComponent :id="id" @dataFromTrix="getDataFromTrix"></TrixComponent>
    </template>

    <template v-slot:footer>
        <p>Here's some contact info</p>
    </template>

    </BaseLayout>
</template>


<script>
import BaseLayout from "../Components/BaseLayout";
import TrixComponent from "../Components/TrixComponent"

export default {
    components: {
        BaseLayout,
        TrixComponent
    },
    data() {
        return {
            textA: "",
            id: "A"
        };
    },
    mounted() {
        //console.log(route('home'))
    },
    methods: {
        getDataFromTrix: function(data) {
            this.textA = data;
        }
    }
};
</script>
``
0 likes
5 replies
rodrigo.pedra's avatar
Level 56

You should tell to Vue compiler trix-editor is a custom element and not a custom component.

The migration guide to Vue 3 has some guidance on how to do it:

https://v3.vuejs.org/guide/migration/custom-elements-interop.html#_3-x-syntax

By that guide one option is, when creating the app using this approach to tell Vue 3 which tags refer to a custom element:

const app = Vue.createApp({/*...*/});
app.config.isCustomElement = (tag) => tag === 'trix-editor';

Hope it helps

1 like
ekrist1's avatar

Thanks @rodrigo.pedra

Exactly what I was looking for. I missed that part of the migration guide.

Here is the update I made to the Webpack.mix.js (Laravel Mix 6 - beta)

mix.webpackConfig(webpack => {
    return {
        plugins: [
            new webpack.DefinePlugin({
                __VUE_OPTIONS_API__: true,
                __VUE_PROD_DEVTOOLS__: false
            })
        ]
    };
});

mix.options({
    vue: {
        compilerOptions: {
            isCustomElement: tag => tag === 'trix-editor'
        }
    }
})
1 like
rodrigo.pedra's avatar

Great it worked!

Using the webpack approach is the recommended by the guide, I used the runtime as an example as it was easier to test if tit solved your issue.

Have a nice week =)

madprabh's avatar

Hey @rodrigo.pedra @ekrist1

I found this post very helpful. Can someone please guide me how to ignore an array of custom elements

What I want to do is ignore both

<trix-editor>
<trix-toolbar>

Can someone please guide me here?

inyansuta's avatar
isCustomElement: tag => tag.startsWith('trix-')

Please or to participate in this conversation.