Add in quill WYSIWYG

This commit is contained in:
Matthew Dillon 2015-07-20 11:03:03 -08:00
parent da4ebc9b29
commit c276cdc74c
6 changed files with 55 additions and 2 deletions

View file

@ -0,0 +1,32 @@
import Ember from 'ember';
/* global Quill */
export default Ember.Component.extend({
quill: null,
value: null, // passed in
didInsertElement: function() {
let quill = new Quill(`#${this.get('elementId')} .editor`, {
formats: ['bold', 'italic', 'underline'],
modules: {
'toolbar': { container: `#${this.get('elementId')} .toolbar` }
},
theme: 'snow'
});
let val = this.get('value');
if (!val) {
val = '';
}
quill.setHTML(val);
quill.on('text-change', (delta, source) => {
if (source === 'user') {
this.set('value', Ember.$(quill.getHTML()).html());
}
});
this.set('quill', quill);
},
});

View file

@ -0,0 +1,11 @@
<div class="ql-toolbar toolbar">
<span class="ql-format-group">
<span title="Bold" class="ql-format-button ql-bold"></span>
<span class="ql-format-separator"></span>
<span title="Italic" class="ql-format-button ql-italic"></span>
<span class="ql-format-separator"></span>
<span title="Underline" class="ql-format-button ql-underline"></span>
</span>
</div>
<div class="ql-editor editor"></div>