ankurk91 / vue-trumbowyg

Vue.js component for Trumbowyg WYSIWYG editor :memo:
https://ankurk91.github.io/vue-trumbowyg/
MIT License
236 stars 35 forks source link

Missing Icons #11

Closed thomaswoj closed 6 years ago

thomaswoj commented 6 years ago

Hi Ankurk91,

My trumbowyg icons appear to be missing.

I have installed via npm in laravel 5.6.7:

"trumbowyg": { "version": "2.9.4", "vue-trumbowyg": { "version": "3.1.2",


Webpack file:

mix.autoload({
    'jquery': ['$', 'window.jQuery', 'jQuery'],
    'vue': ['Vue','window.Vue'],
})

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

mix.copyDirectory('node_modules/trumbowyg', 'public/trumbowyg');

vue component:

<template>
    <div>
        <trumbowyg v-model="content"></trumbowyg>
    </div>
</template>

<script>
    // Import this component
    import trumbowyg from 'vue-trumbowyg';

    // Import editor css
    import 'trumbowyg/dist/ui/trumbowyg.css';

    import svgIcons from 'trumbowyg/dist/ui/icons.svg';

    export default {
        data () {
            return {
                content: '',
            }
        },
        components: {
            trumbowyg
        }
    }
</script>

Still nothing, any ideas?

Thanks,

Tom

ankurk91 commented 6 years ago

May in know your Laravel mix version, i think you are using v2.x ?

thomaswoj commented 6 years ago

Yup,

"laravel-mix": { "version": "2.0.0",

ankurk91 commented 6 years ago

I am looking into it. Just to let you know, you no need to import svg icons, the component is already doing this for you.

thomaswoj commented 6 years ago

Thanks 👍

ankurk91 commented 6 years ago

And make sure you have jquery installed

ankurk91 commented 6 years ago

To be honest; i have not tested it with Laravel mix v2.0 v2.0 handles svg files differently now. https://github.com/JeffreyWay/laravel-mix/pull/1367

Do you see any errors in console ? Everything else in editor is loading properly and just icons are missing ?

thomaswoj commented 6 years ago

No errors in console,

But looking at the icons.svg the file looks small/empty, should there be data inside?

image

ankurk91 commented 6 years ago

Ok, A quick workaround is to pass your custom svg icon file path via prop.

 <trumbowyg
              v-model="content"
              class="form-control"
              svg-path="https://unpkg.com/trumbowyg@2.9.4/dist/ui/icons.svg"
            ></trumbowyg>

Also can you try disabling image optimization by Laravel mix

// webpack.mix.js
mix.options({
  imgLoaderOptions: {
    enabled: false
  },
});
thomaswoj commented 6 years ago

Hmmm, getting a vue error in console when adding ,

image

ankurk91 commented 6 years ago

Don't copy my code blindly. All you need to do is - add this prop to your component

 svg-path="https://unpkg.com/trumbowyg@2.9.4/dist/ui/icons.svg"
thomaswoj commented 6 years ago

My Apologies, I misunderstood.

Yup - icons are now loading correctly with the workaround. :)

This should be fine as I don't need the icons locally.

Many thanks for your help Ankurk, it's greatly appreciated.

ankurk91 commented 6 years ago

Glad to know. I will test it with Laravel mix v2.x soon and will post back here.

ankurk91 commented 6 years ago

I can confirm that this isimg-loader issue in Laravel-mix. Disabling image loader fixes this issue.

Here is how to fix this issue:

// webpack.mix.js
mix.options({
  imgLoaderOptions: {
    enabled: false
  },
});