plugin.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. (function()
  2. {
  3. CKEDITOR.plugins.add( 'column',
  4. {
  5. init : function( editor )
  6. {
  7. CKEDITOR.dialog.add( 'column', 'custom/column/dialogs/column.js' );
  8. editor.addCommand( 'column', new CKEDITOR.dialogCommand( 'column' ) );
  9. editor.addCss(
  10. 'img.cke_flash' +
  11. '{' +
  12. 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
  13. 'background-position: center center;' +
  14. 'background-repeat: no-repeat;' +
  15. 'border: 1px solid #a9a9a9;' +
  16. 'width: 80px;' +
  17. 'height: 80px;' +
  18. '}'
  19. );
  20. if ( editor.addMenuItems )
  21. {
  22. editor.addMenuGroup('column');
  23. editor.addMenuItems(
  24. {
  25. column :
  26. {
  27. label : '字段属性',
  28. command : 'column',
  29. group : 'column'
  30. }
  31. });
  32. }
  33. if ( editor.contextMenu )
  34. {
  35. editor.contextMenu.addListener( function( element, selection )
  36. {
  37. if ( /^[ms]:/.test(element.getNameAtt()) ) {
  38. return { column : CKEDITOR.TRISTATE_OFF };
  39. }
  40. });
  41. }
  42. editor.on( 'doubleclick', function( evt )
  43. {
  44. var element = evt.data.element;
  45. if ( /^[ms]:/.test(element.getNameAtt()) )
  46. evt.data.dialog = 'column';
  47. });
  48. }
  49. });
  50. })();