Skip to content

Instantly share code, notes, and snippets.

@senica
Last active May 24, 2016
Embed
What would you like to do?
RiotJS wrapper for the Trix text editor
<trix>
<input id={'trix-'+_riot_id} value={opts.content} type="hidden" />
<trix-editor name="trix" class="trix-content" input={'trix-'+_riot_id} ></trix-editor>
<script>
/*
* <trix trix-change={changetext} content={content}></trix>
* You can bind to any of the trix events
*/
this.on('mount', function(){
jQuery(this.trix).on('trix-initialize trix-change trix-selection-change trix-focus trix-blur trix-file-accept trix-attachment-add trix-attachment-remove', function(e){
// opts are turned to camel case - match to that
e.type = e.type.replace(/-([a-z])/g, function (m, w) { return w.toUpperCase(); });
if(typeof this.opts[e.type] === 'function'){
this.opts[e.type].call(this, e, this.trix, this["{'trix-'+_riot_id}"].value);
}
}.bind(this));
})
this.on('before-unmount', function(){
this.original = null;
delete this.original;
jQuery(this.trix).off();
})
</script>
</trix>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment