Skip to content

Instantly share code, notes, and snippets.

@villander
Created December 23, 2015 14:58
Show Gist options
  • Save villander/6d9ab949612a1d8a8464 to your computer and use it in GitHub Desktop.
Save villander/6d9ab949612a1d8a8464 to your computer and use it in GitHub Desktop.
Meu input
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
Meu "input":
{{meu-input value=value}}
<pre>{{value}}</pre>
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['meu-input'],
attributeBindings: [ 'contentEditable' ],
contentEditable: true,
input(event) {
console.log(this.element.innerHTML);
const value = this.element.innerHTML
.replace(/&nbsp;/g, ' ')
.replace(/<([^>]+?)([^>]*?)>(.*?)<\/\1>/ig, "")
.replace(/<\/?div.*?>/g, '\n')
.replace(/<br\s*\/?>/g, '\n');
this.set('value', value);
},
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.meu-input {
border: 1px solid #999;
border-radius: 6px;
min-height: 1em;
padding: 6px;
}
{
"version": "0.4.17",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment