Skip to content

Instantly share code, notes, and snippets.

@bsylvain
Forked from PoslinskiNet/controllers.application.js
Last active March 11, 2021 17:24
Show Gist options
  • Save bsylvain/c7af7610138612bdf4614ad35c4b8813 to your computer and use it in GitHub Desktop.
Save bsylvain/c7af7610138612bdf4614ad35c4b8813 to your computer and use it in GitHub Desktop.
Ember-Pell Addon demo
import Ember from 'ember';
export default Ember.Controller.extend({
value: '<h1>Demo header</h1>This is some <i>italic</i> text.',
options: {
actions:[
{
name: 'titre',
icon: 'Z',
result: () => {
console.log('tata');
document.execCommand('formatblock', false, 'p');
var listId = window.getSelection().focusNode.parentNode;
$(listId).addClass("oder2");
}
},
{
name: 'redo',
icon: 'HHA',
class: 'blockquote custom-class',
result: () =>{
var selection = window.getSelection().getRangeAt(0).cloneContents();
var span = document.createElement('span');
span.appendChild(selection);
var wrappedselection = '<span class="accent1">'+span.innerHTML+'</span>';
document.execCommand('insertHTML', false, wrappedselection);
}
}
]
}
});
{{pell-editor value=value onChange=(action (mut value)) pellOptions=options}}
<hr>
{{value}}
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { assign } from '@ember/polyfills';
import { start } from 'ember-qunit';
let attributes = {
rootElement: '#test-root',
autoboot: false
};
attributes = assign(attributes, config.APP);
let application = Application.create(attributes);
setApplication(application);
start();
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-pell": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment