Closed ghost closed 3 years ago
Great!! I will have a look and provide feedback when I am back in office next week :)
Hi Iusvar,
I had a short look into the code but I did not had the time to test it in depth. I think we should search for a more general solution to hack into the events, otherwise I have to add code to the core of Typemill for each plugin and that does not feel very clean. I am sure there is a way to fire a general event on change or on input that other plugins can listen to.
I will try to find a solution for the next release, currently working on it and I hope to publish it end of August. Is that fine for you?
Cheers, Sebastian
hi, I totally agree. See you soon.
sorry, I was totally blocked with other stuff, but I will start now to work on the open tasks :)
no problem, thank you
I myself have not deepened yet but ... I think an easy solution could be to use an event bus in a generalized way. Besides in vue-blox.js you already use it for "closeComponents" :)
Hey jusvar,
I checked it now but I need your help with this. As you suggested I used the eventBus and simply fired a new event "markdownChanged" each time when the markdown is updated. I added this event to the contentComponent in vue-blox.js in the method updateMarkdown:
updateMarkdown: function($event)
{
eventBus.$emit('markdownChanged');
this.compmarkdown = $event;
this.setComponentSize();
},
This event fires now nearly every time when the user changes any content. I tested it with a little test-component like this:
const counter = Vue.component('counter', {
data: function () {
return {
counter: 1,
}
},
template: '<div class="counter">{{counter}}</div>',
mounted: function()
{
eventBus.$on('markdownChanged', this.countMarkdown);
},
methods: {
countMarkdown: function(event)
{
this.counter = this.counter+1;
},
},
});
Is that enough for your plugin? I can add some more events if you need them or pass some data with the event. I could not check the requirements of your plugin because there is pretty much code, so it would take quite some time to understand everything :D
Can you check it and provide some feedback?
Hi trendschau, I will give you feedback asap, thanks
Hi trendschau,
I'm there, the new markdownChanged event is fine but I would need the $event argument passed.
So like this
updateMarkdown: function($event)
{
eventBus.$emit('markdownChanged',$event);
this.compmarkdown = $event;
this.setComponentSize();
},
Thank you
Hi iusvar, published with version 1.4.0, please try and let me know when I should publish your plugin on the plugin page...
Hi trendschau, as far as listening to the event is concerned, everything is fine. As far as publication is concerned, I still have to work on it to make it really work. I'll let you know when I'm done. Thank you.
Hi trendschau, I just uploaded a new plugin, counter.
Its function is to display on the publish-controller bar the counters of the characters, words, sentences and reading time of the page currently being edited. It works both in raw and in visual.
To be honest, in visual it only works if an event is emitted that you have already used yourself: eventBus. So I need vue-blox.js to be added to lines 650, 890 and 916 (for now I have limited the count to the markdown, olist and ulist components only):
Try it yourself, when you have time :-)
If you have any suggestions on how to intercept the event differently, let me know.
NB: The URL that appears in the GIF contains a typemill-1.3.7: read it as 1.3.8 because I have updated to the latest version.