fckeditor.config.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Drupal = window.parent.Drupal;
  2. /**
  3. * Fetch and provide original editor settings as local variable.
  4. *
  5. * FCKeditor does not support to pass complex variable types to the editor.
  6. * Instance settings passed to FCKinstance.Config are temporarily stored in
  7. * FCKConfig.PageConfig.
  8. */
  9. // Fetch the private instance and make sure nothing can tamper with it.
  10. var $field = window.parent.jQuery(FCK.LinkedField);
  11. var wysiwygInstance = $field.data('wysiwygInstance');
  12. $field.removeData('wysiwygInstance');
  13. var wysiwygSettings = wysiwygInstance.editorSettings;
  14. var pluginInfo = wysiwygInstance.pluginInfo;
  15. /**
  16. * Apply format-specific settings.
  17. */
  18. for (var setting in wysiwygSettings) {
  19. if (setting == 'buttons') {
  20. // Apply custom Wysiwyg toolbar for this format.
  21. // FCKConfig.ToolbarSets['Wysiwyg'] = wysiwygSettings.buttons;
  22. // Temporarily stack buttons into multiple button groups and remove
  23. // separators until #277954 is solved.
  24. FCKConfig.ToolbarSets['Wysiwyg'] = [];
  25. for (var i = 0; i < wysiwygSettings.buttons[0].length; i++) {
  26. FCKConfig.ToolbarSets['Wysiwyg'].push([wysiwygSettings.buttons[0][i]]);
  27. }
  28. FCKTools.AppendStyleSheet(document, '#xToolbar .TB_Start { display:none; }');
  29. // Set valid height of select element in silver and office2003 skins.
  30. if (FCKConfig.SkinPath.match(/\/office2003\/$/)) {
  31. FCKTools.AppendStyleSheet(document, '#xToolbar .SC_FieldCaption { height: 24px; } #xToolbar .TB_End { display: none; }');
  32. }
  33. else if (FCKConfig.SkinPath.match(/\/silver\/$/)) {
  34. FCKTools.AppendStyleSheet(document, '#xToolbar .SC_FieldCaption { height: 27px; }');
  35. }
  36. }
  37. else {
  38. FCKConfig[setting] = wysiwygSettings[setting];
  39. }
  40. }
  41. // Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
  42. var oldFitWindowExecute = FCKFitWindow.prototype.Execute;
  43. var $drupalToolbars = window.parent.jQuery('#toolbar, #admin-menu', Drupal.overlayChild ? window.parent.window.parent.document : window.parent.document);
  44. FCKFitWindow.prototype.Execute = function() {
  45. oldFitWindowExecute.apply(this, arguments);
  46. if (this.IsMaximized) {
  47. $drupalToolbars.hide();
  48. }
  49. else {
  50. $drupalToolbars.show();
  51. }
  52. }
  53. /**
  54. * Initialize this editor instance.
  55. */
  56. wysiwygInstance.init(window);
  57. /**
  58. * Register native plugins for this input format.
  59. *
  60. * Parameters to Plugins.Add are:
  61. * - Plugin name.
  62. * - Languages the plugin is available in.
  63. * - Location of the plugin folder; <plugin_name>/fckplugin.js is appended.
  64. */
  65. for (var pluginId in pluginInfo.instances['native']) {
  66. // Languages and path may be undefined for internal plugins.
  67. FCKConfig.Plugins.Add(pluginId, pluginInfo.global['native'][pluginId].languages, pluginInfo.global['native'][pluginId].path);
  68. }
  69. /**
  70. * Register Drupal plugins for this input format.
  71. *
  72. * Parameters to addPlugin() are:
  73. * - Plugin name.
  74. * - Format specific plugin settings.
  75. * - General plugin settings.
  76. * - A reference to this window so the plugin setup can access FCKConfig.
  77. */
  78. for (var pluginId in pluginInfo.instances.drupal) {
  79. var plugin = pluginInfo.instances.drupal[pluginId];
  80. Drupal.wysiwyg.editor.instance.fckeditor.addPlugin(pluginId, pluginInfo.global.drupal[pluginId], window);
  81. }