Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * External plugins added through the server-side FieldFactory are automatically registered.
  3.  * Other external plugins (e.g. client-only) may still be registered here (and subsequently added via config.extraPlugins).
  4.  *
  5.  * e.g. if your plugin resides in src/main/resources/VAADIN/js:
  6.  * CKEDITOR.plugins.addExternal("abbr", CKEDITOR.vaadinDirUrl + "js/abbr/");
  7.  */
  8. CKEDITOR.editorConfig = function( config ) {
  9.  
  10.     // MIRROR info.magnolia.ui.form.field.definition.RichTextFieldDefinition
  11.     definition = {
  12.         alignment: true,
  13.         images: true,
  14.         lists: true,
  15.         source: true,
  16.         tables: false,
  17.  
  18.         colors: null,
  19.         fonts: null,
  20.         fontSizes: null
  21.     }
  22.  
  23.     // MIRROR info.magnolia.ui.form.field.factory.RichTextFieldFactory
  24.     removePlugins = [];
  25.  
  26.     // CONFIGURATION FROM DEFINITION
  27.     if (!definition.alignment) {
  28.         removePlugins.push("justify");
  29.     }
  30.     if (!definition.images) {
  31.         removePlugins.push("image");
  32.     }
  33.     if (!definition.lists) {
  34.         // In CKEditor 4.1.1 enterkey depends on indent which itself depends on list
  35.         removePlugins.push("enterkey");
  36.         removePlugins.push("indent");
  37.         removePlugins.push("list");
  38.     }
  39.     if (!definition.source) {
  40.         removePlugins.push("sourcearea");
  41.     }
  42.     if (!definition.tables) {
  43.         removePlugins.push("table");
  44.         removePlugins.push("tabletools");
  45.     }
  46.  
  47.     if (definition.colors != null) {
  48.         config.colorButton_colors = definition.colors;
  49.         config.colorButton_enableMore = false;
  50.         removePlugins.push("colordialog");
  51.     } else {
  52.         removePlugins.push("colorbutton");
  53.         removePlugins.push("colordialog");
  54.     }
  55.     if (definition.fonts != null) {
  56.         config.font_names = definition.fonts;
  57.     } else {
  58.         config.removeButtons = "Font";
  59.     }
  60.     if (definition.fontSizes != null) {
  61.         config.fontSize_sizes = definition.fontSizes;
  62.     } else {
  63.         config.removeButtons = "FontSize";
  64.     }
  65.     if (definition.fonts == null && definition.fontSizes == null) {
  66.         removePlugins.push("font");
  67.         removePlugins.push("fontSize");
  68.     }
  69.  
  70.     // DEFAULT CONFIGURATION FROM FIELD FACTORY
  71.     removePlugins.push("elementspath");
  72.     removePlugins.push("filebrowser");
  73.     config.removePlugins = removePlugins.join(",");
  74.     config.extraPlugins = "magnolialink,magnoliaFileBrowser";
  75.  
  76.     config.baseFloatZIndex = 150;
  77.     config.resize_enabled = false;
  78.     config.toolbar = "Magnolia";
  79.     config.toolbar_Magnolia = [
  80.         { name: "basicstyles",   items: [ "Bold", "Italic", "Underline", "SpecialChar" ] },
  81.         { name: "paragraph",     items: [ "NumberedList", "BulletedList", "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock", "Image", "Table" ] },
  82.         { name: "links",         items: [ "Link", "InternalLink", "DamLink", "Unlink" ] },
  83.         { name: "styles",        items: [ "Font", "FontSize", "TextColor" ] },
  84.         { name: "clipboard",     items: [ "Cut", "Copy", "Paste", "PasteText", "PasteFromWord" ] },
  85.         { name: "undo",          items: [ "Undo", "Redo" ] },
  86.         { name: "tools",         items: [ "Source" ] }
  87.     ];
  88.  
  89.  
  90.     config.allowedContent = true; // My customization: do not strip span tags!
  91.  
  92.     config.autoParagraph = false;
  93.     config.fillEmptyBlocks = false; // no &nbsp; in <p>
  94.  
  95. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement