editor_plugin_src.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * editor_plugin_src.js
  3. *
  4. * Copyright 2009, Moxiecode Systems AB
  5. * Released under LGPL License.
  6. *
  7. * License: http://tinymce.moxiecode.com/license
  8. * Contributing: http://tinymce.moxiecode.com/contributing
  9. */
  10. (function() {
  11. tinymce.create('tinymce.plugins.StylePlugin', {
  12. init : function(ed, url) {
  13. // Register commands
  14. ed.addCommand('mceStyleProps', function() {
  15. var applyStyleToBlocks = false;
  16. var blocks = ed.selection.getSelectedBlocks();
  17. var styles = [];
  18. if (blocks.length === 1) {
  19. styles.push(ed.selection.getNode().style.cssText);
  20. }
  21. else {
  22. tinymce.each(blocks, function(block) {
  23. styles.push(ed.dom.getAttrib(block, 'style'));
  24. });
  25. applyStyleToBlocks = true;
  26. }
  27. ed.windowManager.open({
  28. file : url + '/props.htm',
  29. width : 480 + parseInt(ed.getLang('style.delta_width', 0)),
  30. height : 340 + parseInt(ed.getLang('style.delta_height', 0)),
  31. inline : 1
  32. }, {
  33. applyStyleToBlocks : applyStyleToBlocks,
  34. plugin_url : url,
  35. styles : styles
  36. });
  37. });
  38. ed.addCommand('mceSetElementStyle', function(ui, v) {
  39. if (e = ed.selection.getNode()) {
  40. ed.dom.setAttrib(e, 'style', v);
  41. ed.execCommand('mceRepaint');
  42. }
  43. });
  44. ed.onNodeChange.add(function(ed, cm, n) {
  45. cm.setDisabled('styleprops', n.nodeName === 'BODY');
  46. });
  47. // Register buttons
  48. ed.addButton('styleprops', {title : 'style.desc', cmd : 'mceStyleProps'});
  49. },
  50. getInfo : function() {
  51. return {
  52. longname : 'Style',
  53. author : 'Moxiecode Systems AB',
  54. authorurl : 'http://tinymce.moxiecode.com',
  55. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style',
  56. version : tinymce.majorVersion + "." + tinymce.minorVersion
  57. };
  58. }
  59. });
  60. // Register plugin
  61. tinymce.PluginManager.add('style', tinymce.plugins.StylePlugin);
  62. })();