plugin.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. CKEDITOR.plugins.add('glossary',
  2. {
  3. init: function(editor)
  4. {
  5. var pluginName = 'glossary';
  6. editor.addCommand(
  7. pluginName,
  8. {
  9. exec: function(editor)
  10. {
  11. var selectedText = editor.getSelection().getSelectedText();
  12. if (selectedText !== '') {
  13. var spanElement = new CKEDITOR.dom.element("span");
  14. spanElement.setAttributes({
  15. class: 'glossary',
  16. style: 'color: rgb(0, 151, 74);' +
  17. 'cursor: pointer;' +
  18. 'font-weight: bold;'
  19. });
  20. spanElement.setText(selectedText);
  21. editor.insertElement(spanElement);
  22. }
  23. }
  24. }
  25. );
  26. editor.ui.addButton(
  27. 'Glossary',
  28. {
  29. label: 'Glossary',
  30. command: pluginName,
  31. icon: this.path + 'images/glossary.gif'
  32. }
  33. );
  34. }
  35. });