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

add twbinit event #14

Closed barbedCoil closed 6 years ago

barbedCoil commented 6 years ago

I'm submitting a ... (check one with "x")

[ ] Bug report => search github for a similar issue or PR before submitting
[ x] Feature request
[ ] Other, please describe

Tell about your platform

Current behavior trying to intercept init event - fails - I can see that many events but init are defined

Expected behavior vue method I defined would be fired

Minimal reproduction of the problem with instructions Tried the following in your fiddler example:

HTML

<div id="app">
  <h3>
   Vue Trumbowyg v3 demo
   </h3>
  <trumbowyg v-model="content" :config="config" class="editor" @tbw-init="test()"></trumbowyg>
</div>

JS

   console.log($.trumbowyg, VueTrumbowyg);

   Vue.component('Trumbowyg', VueTrumbowyg.default);

   new Vue({
     el: '#app',
     data: {
       content: '<h1>YEAH It works!!!</h1>',
       config:{
       //http://alex-d.github.io/Trumbowyg/documentation.html#basic-options
       },
     },
    methods: {
            test: function ()
      {
        console.log('test')
      }
    },
     mounted() {
       console.log('app mounted')
     }
   });
ankurk91 commented 6 years ago

Trumbowyg emits the init event in a setTimeout method

https://github.com/Alex-D/Trumbowyg/blob/5eef0c6ddbe0bbd2b81a998dbcea21d8c10ba2e0/src/trumbowyg.js#L465-L470

~It is hard to catch this event because of async nature of javascript.~ In order to capture this event, i also need to init the text-editor with a timeout, that is not feasible. I am trying to find a better way to do this but can not promise.

ankurk91 commented 6 years ago

Fixed in v3.3.0

barbedCoil commented 6 years ago

Excellent! This is a life saver for me, much appreciated!