X-Git-Url: https://scm.cri.ensmp.fr/git/ckeditor.git/blobdiff_plain/e7f8fb547940c134de50db80ffaf54be1135ca7b..fbd145a2acd338b7bb7d152fa24692d8ff3e6b4c:/Products/ckeditor/skins/ckeditor/plugins/plinn_styles/plugin.js diff --git a/Products/ckeditor/skins/ckeditor/plugins/plinn_styles/plugin.js b/Products/ckeditor/skins/ckeditor/plugins/plinn_styles/plugin.js new file mode 100644 index 0000000..835b08b --- /dev/null +++ b/Products/ckeditor/skins/ckeditor/plugins/plinn_styles/plugin.js @@ -0,0 +1,101 @@ +/* © 2014 Benoît Pin, MINES ParisTech */ +( function() { + +var PlinnStylesCombo = function(editor) { + this.editor = editor; + this.label = 'Styles'; + this.title = 'CSS Styles'; + this.toolbar = 'styles,10'; + this.panel = { + css : [CKEDITOR.skin.getPath( 'editor' )].concat(editor.config.contentsCss), + multiSelect : true, + attributes : {'aria-label': this.title} + }; + this.styles = []; +}; + +PlinnStylesCombo.prototype.onRender = function() { + var self = this; + this.editor.on('selectionChange', function(evt){self.checkSelection(evt);}); +}; + +PlinnStylesCombo.prototype.checkSelection = function(evt) { + if (evt.data.selection.getRanges().length > 1) { + this.disable(); + } + else { + this.enable(); + } +}; + +PlinnStylesCombo.prototype.loadStyle = function(definition) { + this.styles.push(definition); + this.styles[definition.name] = definition; +}; + +PlinnStylesCombo.prototype.init = function() { + var i, style; + for (i=0 ; i < this.styles.length ; i++) { + style = this.styles[i]; + this.add(style.name, + '