Skip to content

Commit

Permalink
Html mode button.
Browse files Browse the repository at this point in the history
Support a toggle for moving between html & WYSIWYG content.

0.1.1 Release
  • Loading branch information
Asaf Shakarzy committed Feb 24, 2015
1 parent 4699e19 commit f8d1dc6
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 2 deletions.
36 changes: 36 additions & 0 deletions addon/action-text-html-toggler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Em from 'ember';
import WithConfigMixin from 'ember-idx-utils/mixin/with-config';
var computed = Em.computed;

export default Em.Component.extend(WithConfigMixin, {
tagName: 'a',
layoutName: 'components/em-wysiwyg-action',
classNameBindings: ['styleClasses', 'activeClasses'],
wysiwyg: computed.alias('parentView.wysiwyg'),
editor: computed.alias('wysiwyg.editor'),
//When active, we'r in textarea mode
active: false,
styleClasses: (function() {
var _ref;
return (_ref = this.get('config.wysiwyg.actionClasses')) != null ? _ref.join(" ") : void 0;
}).property(),
activeClasses: (function() {
var _ref;
if (this.get('active')) {
return (_ref = this.get('config.wysiwyg.actionActiveClasses')) != null ? _ref.join(" ") : void 0;
}
}).property('active'),
click: function() {
if (this.get('active')) {
this.set('active', false);
this.set('wysiwyg.editor.display', 'block');
this.set('wysiwyg.editor-textarea.display', 'none');
//Copy the content of as_html into data
this.get('editor').$().html(this.get('wysiwyg.as_html'));
} else {
this.set('active', true);
this.set('wysiwyg.editor.display', 'none');
this.set('wysiwyg.editor-textarea.display', 'block');
}
}
});
15 changes: 15 additions & 0 deletions addon/editor-textarea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Em from 'ember';
var computed = Em.computed;
import StyleBindingsMixin from 'ember-idx-utils/mixin/style-bindings';

export default Em.TextArea.extend(StyleBindingsMixin, {
styleBindings: ['display', 'width', 'border'],
width: '100%',
border: 'none;',
wysiwyg: computed.alias('parentView'),
value: computed.alias('wysiwyg.as_html'),
display: 'none',
registerInParent: (function() {
this.set('parentView.editor-textarea', this);
}).on('init')
});
3 changes: 2 additions & 1 deletion addon/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import Em from 'ember';
import StyleBindingsMixin from 'ember-idx-utils/mixin/style-bindings';

export default Em.Component.extend(StyleBindingsMixin, {
styleBindings: ['marginTop:margin-top', 'background'],
styleBindings: ['marginTop:margin-top', 'background', 'display'],
attributeBindings: ['contenteditable'],
contenteditable: 'true',
marginTop: 10,
background: 'white',
display: 'block',
wysiwyg: Em.computed.alias('parentView'),
updateToolbar: function(e) {
return this.get('wysiwyg').trigger('update_actions');
Expand Down
2 changes: 2 additions & 0 deletions app/components/em-wysiwyg-action-text-html-toggler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import WysiwygActionTextHtmlToggler from 'ember-idx-wysiwyg/action-text-html-toggler';
export default WysiwygActionTextHtmlToggler;
2 changes: 2 additions & 0 deletions app/components/em-wysiwyg-editor-textarea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import WysiwygEditorAreaComponent from 'ember-idx-wysiwyg/editor-textarea';
export default WysiwygEditorAreaComponent;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-idx-wysiwyg",
"version": "0.1.0",
"version": "0.1.1",
"directories": {
"doc": "doc",
"test": "tests"
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/app/controllers/simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Em from 'ember';

export default Em.Controller.extend({

});
2 changes: 2 additions & 0 deletions tests/dummy/app/templates/simple.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{{em-wysiwyg-action command="strikethrough" title="Strikethrough" icon="fa fa-strikethrough"}}
{{em-wysiwyg-action command="underline" title="Underline (Ctrl/Cmd+U)" icon="fa fa-underline"}}
{{em-wysiwyg-action-format icon="fa fa-text-height"}}
{{em-wysiwyg-action-text-html-toggler icon="fa fa-code"}}
{{/em-wysiwyg-action-group}}
{{#em-wysiwyg-action-group}}
{{em-wysiwyg-action command="justifyleft" title="Align Left (Ctrl/Cmd+L)" icon="fa fa-align-left"}}
Expand All @@ -26,6 +27,7 @@
{{/em-wysiwyg-action-group}}
{{/em-wysiwyg-toolbar}}
{{em-wysiwyg-editor}}
{{em-wysiwyg-editor-textarea}}
{{/em-wysiwyg}}

<h2>Markup</h2>
Expand Down

0 comments on commit f8d1dc6

Please sign in to comment.