Sir Trevor Adapter allows to use Sir Trevor like a common html wysiwyg and work only with html like ckeditor, tinymce and others. Given a Sir Trevor result data as JSON with this adapter we can get a valid html. Also we can revert the process and regenerate the JSON with the html generated by the Sir Trevor Adapter
Clone this repo and install the dependencies:
- Install node dependencies npm install
- Install project dependencies -- bower install
You can run the test suite with the command: npm test
// create a instance
var adapter = new SirTrevorAdapter();
// get the html initial data of sir trevor, transform in a correct json and save the data in it.
var $textarea = $('.js-st-instance');
var data = adapter.toJSON($textarea.val());
$textarea.val(JSON.stringify( { data: data } ));
// create a sir trevor instance and attach to a textarea
var sirtrevor = new SirTrevor.Editor({ el: $textarea});
// on submit you can send the html to the server instead of the json structure
$form.submit(function(e){
var dataJson = $textarea.val();
var dataHtml = this.adapter.toHTML(JSON.parse(dataJson));
// save the data in a hidden field
var $data = $("<input>").attr("type", "hidden").val(dataHtml);
$(this).append($data)
});
gulp doc
generate the jsdocs and store in the doc foldergulp compile-dev
generate new compile results of the adapter: sir-trevor-adapter.jsgulp compile-prod
generate new compile results of the adapter: sir-trevor-adapter.js & sir-trevor-adapter.min.jsgulp patch
compile and generate a new tag in the git repository incrementing the pacth versiongulp feature
compile and generate a new tag in the git repository incrementing the feature versiongulp release
compile and generate a new tag in the git repository incrementing the major version