In your html, just put <div id="editor" name="body"></div>
and in your template add
Template.priceForm.created = function(){
var exist = Collections.Options.findOne({ key: 'price' });
this.value = new ReactiveVar(exist ? exist.body : '');
};
Template.priceForm.rendered = function(){
var self = this;
$('#editor').summernote({
minHeight: 200, // put correct value here
maxHeight: 800, // put correct value here
width: 820, // put correct value here
onInit: function() {
console.log("init");
$('#editor').code(self.value.get());
},
onChange: function(contents, $editable) {
console.log('onChange:', contents, $editable);
// if you wanna do something here
}
});
Deps.autorun(function(){
// update reactive var value
var exist = Collections.Options.findOne({ key: 'price' });
self.value.set(exist ? exist.body : '');
// refresh editor with new value
$('#editor').code(self.value.get());
});
};
and you keep your helper :
> Template.priceForm.helpers({
> option() {
> const exist = Collections.Options.findOne({ key: ‘price’ });
> return exist ? exist.body : ‘’;
> },
> })
Much more simplier Froala is very good for customization of buttons, blockstyles, event handling. Imho, for sure you save 20x the license price in productivity, you’ll have to pay when your app is on production.