AdfRichUIPeer.createPeerClass(AdfDhtmlRichTextEditorBasePeer, "AdfDhtmlRichTextCKEditorPeer", false);
AdfDhtmlRichTextCKEditorPeer.initInline = function() {
  window.CKEDITOR4_BASEPATH = AdfAgent.AGENT.getOrigin() + AdfPage.PAGE.getResourceURL("/afr/3rdparty/ckeditor/4.18.0/");
}();
AdfDhtmlRichTextCKEditorPeer.InitSubclass = function() {
  AdfDhtmlRichTextEditorBasePeer.InitSubclass.call(this);
  AdfRichUIPeer.addComponentPropertyChanges(this, "editMode");
  this.InitConstants();
};
AdfDhtmlRichTextCKEditorPeer.InitConstants = function() {
  AdfDhtmlRichTextEditorBasePeer.InitConstants.call(this);
  this._CK_INIT_VALUE_FIELD = "ckinit";
  this._TOOLBAR = {"font":{"name":"font", "items":["Font", "FontSize"]}, "history":{"name":"clipboard", "items":["Undo", "Redo", "RemoveFormat"]}, "mode":{"name":"mode", "items":["Source"]}, "color":{"name":"mode", "items":["TextColor", "BGColor"]}, "formatAll":{"name":"basicstyles", "items":["Bold", "Italic", "Underline", "-", "Subscript", "Superscript", "Strike"]}, "formatCommon":{"name":"basicstyles", "items":["Bold", "Italic", "Underline"]}, "formatUncommon":{"name":"basicstyles", "items":["Subscript", 
  "Superscript", "Strike"]}, "justify":{"name":"justify", "items":["JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"]}, "list":{"name":"list", "items":["NumberedList", "BulletedList"]}, "indent":{"name":"indent", "items":["Outdent", "Indent"]}, "link":{"name":"link", "items":["Link", "Unlink"]}, "newline":"/", "extra":{"name":"extra", "items":["Find", "Replace", "CopyFormatting", "Styles", "Format", "Cut", "Copy", "Paste", "PasteText", "PasteFromWord"]}};
  this._CKLOAD_LOADING = 1;
  this._CKLOAD_LOADED = 2;
  this._CKLOAD_RELOAD = 3;
  this._FONT_NAMES = "Arial/Arial,Helvetica,sans-serif;" + "Courier New/Courier New,Courier,Monaco," + "monospace;" + "Comic Sans/Comic Sans MS,Comic Sans,cursive;" + "Georgia/Georgia,Hoefler Text," + "Times New Roman,Times,serif;" + "Helvetica/Helvetica,Arial,sans-serif;" + "Impact/Impact,sans-serif;" + "Tahoma/Tahoma,Verdana,sans-serif;" + "Times New Roman/Times New Roman,Times,serif";
  this._FONT_SIZES = "1/x-small;2/small;3/medium;4/large;5/x-large;6/xx-large;7/400%";
  this._EXTRA_TAGS = "a abbr acronym address area b basefont bdo big blockquote br caption center " + "cite code col colgroup dd del dfn dir div dl dt em fieldset font h1 h2 h3 h4 h5 h6 hr i " + "iframe ins kbd legend li map menu ol p param pre q s samp small span strike strong style " + "sup sub table tbody td tfoot th thead tr tt u ul var ; img[!src]";
  this._DEFAULT_FONT_SIZE = "2";
  this._CKE_RESET_ALL = "cke_reset_all";
  this._CKE_BUTTON = "cke_button";
  this._CKE_TOOLBAR = "cke_toolbar";
  this._NO_CKE_RESET_ALL = "no_reset_all";
  this._ADF_TOOLBAR_TOP = "_afrToolbox";
  this._ADF_TOOLBAR_ROW_TOP = "_tbr_";
  this._NONE_LAYOUT = "none";
};
AdfDhtmlRichTextCKEditorPeer.prototype.Init = function(component) {
  AdfDhtmlRichTextCKEditorPeer.superclass.Init.call(this, component);
};
AdfDhtmlRichTextCKEditorPeer.prototype.InitDomElement = function(component, domElement) {
  if (!component.getReadOnly()) {
    AdfPage.PAGE.registerLoadingComponent(component);
  }
  AdfDhtmlRichTextCKEditorPeer.superclass.InitDomElement.call(this, component, domElement);
  this._isTouch = AdfAgent.AGENT.isTouchFirstDevice();
  var readOnly = component.getReadOnly();
  if (readOnly) {
    var rteContentField = this._getReadOnlyContentField(component);
    rteContentField.innerHTML = rteContentField.textContent;
  }
  this._isDirty = false;
};
AdfDhtmlRichTextCKEditorPeer.prototype.focus = function(component) {
  AdfAssert.assert(component);
  if (AdfDhtmlRichTextCKEditorPeer._isEditorLoading(component)) {
    return;
  }
  if (AdfDhtmlRichTextCKEditorPeer._needsEditorReload(component)) {
    component._ckeditor = null;
    this._initCkEditor(component);
  } else {
    if (component._ckeditor != null) {
      component._ckeditor.focus();
    }
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype.getSelectionRange = function(component) {
  return component._ckeditor.getSelection().getRanges();
};
AdfDhtmlRichTextCKEditorPeer.prototype.setCodeEditingMode = function(newCodeEditingMode) {
  AdfLogger.LOGGER.warning("Call to this method is not expected.");
};
AdfDhtmlRichTextCKEditorPeer.prototype.getCurrentContent = function(component, domElement) {
  return component._ckeditor != null ? component._ckeditor.getData() : null;
};
AdfDhtmlRichTextCKEditorPeer.prototype.HandleCodeEditingModeChange = function(component) {
  var isWysiwygMode = component.getEditMode() == "wysiwyg";
};
AdfDhtmlRichTextCKEditorPeer.prototype.GetReadyState = function() {
  var component = this.getComponent();
  if (component._ckeditor != null && AdfDhtmlRichTextCKEditorPeer._hasEditorLoaded(component)) {
    AdfLogger.LOGGER.fine("AdfDhtmlRichTextCKEditorPeer.GetReadyState: RTE loaded");
    return AdfUIComponent.STATE_COMPLETE;
  }
  AdfLogger.LOGGER.fine("AdfDhtmlRichTextCKEditorPeer.GetReadyState: richTextEditor's onload has not yet fired");
  return AdfUIComponent.STATE_LOADING;
};
AdfDhtmlRichTextCKEditorPeer.prototype.ResizeNotify = function(oldWidth, oldHeight, newWidth, newHeight) {
  var component = this.getComponent();
  if (AdfDhtmlRichTextCKEditorPeer._isEditorLoading(component)) {
    return;
  }
  if (AdfDhtmlRichTextCKEditorPeer._needsEditorReload(component)) {
    this.getComponent()._ckeditor = null;
    this._initCkEditor(this.getComponent());
  } else {
    var domElement = component.getPeer().getDomNode();
    var rootDomRect = domElement.getBoundingClientRect();
    var ckBoundingRect = this.getComponent()._ckeditor.container.$.getBoundingClientRect();
    newWidth = newWidth - (rootDomRect.width - ckBoundingRect.width);
    newHeight = newHeight - (rootDomRect.height - ckBoundingRect.height);
    this.getComponent()._ckeditor.resize(newWidth, newHeight);
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype.GetSubmittedValue = function(component, domElement) {
  if (this._isTouch && this.WasSubmitted(component) && component._ckeditor != null) {
    var newValue = this.getCurrentContent(component);
    var richTextField = this._getContentField(component);
    var lastValue = AdfAgent.AGENT.getExpandoProperty(richTextField, AdfDhtmlInputBasePeer._LAST_VALUE);
    var ckInitFld = this._getCkInitField(component);
    if (lastValue != newValue && !(lastValue === undefined) && ckInitFld.value != newValue) {
      this.UpdateValue();
    }
  }
  if (component.getReadOnly()) {
    var domNode = AdfDhtmlEditableValuePeer.getContentNode(component, domElement);
    return domNode.innerHTML;
  }
  return this._getContentField(component).value;
};
AdfDhtmlRichTextCKEditorPeer.prototype.SetContentFieldValue = function(component, newValue) {
  this._getContentField(component).value = newValue;
  component._ckeditor.setData(newValue);
};
AdfDhtmlRichTextCKEditorPeer.prototype.DestroyEditor = function(component) {
  if (component._ckeditor != null) {
    if (component._popupCloseListener) {
      component._popupAncestor.removeEventListener(AdfPopupClosedEvent.POPUP_CLOSED_EVENT_TYPE, component._popupCloseListener);
    }
    component._ckeditor.destroy();
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype.ScrollIntoView = function(component, focus, subTargetId) {
  var rootElement = this.getDomElement();
  var readOnly = component.getReadOnly();
  if (!readOnly) {
    component._ckeditor.document.$.firstElementChild.scrollIntoView();
  } else {
    rootElement.scrollIntoView();
  }
  if (focus) {
    component._ckeditor.focus();
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype.UpdateValue = function() {
  var component = this.getComponent();
  var newValue = this.getCurrentContent(component);
  this._getContentField(component).value = newValue;
};
AdfDhtmlRichTextCKEditorPeer.prototype.ComponentEditModeChanged = function(component) {
  if (component.getEditMode() != component._ckeditor.mode) {
    component._ckeditor.setMode(component.getEditMode());
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._initCkEditor = function(component) {
  if (component.getReadOnly()) {
    return;
  }
  var rows = component.getRows();
  if (rows == null || rows == undefined) {
    rows = "100%";
  } else {
    rows = rows * 1.4;
    rows = "" + rows + "em";
  }
  var columns = component.getColumns();
  if (columns == null || columns == undefined) {
    columns = "100%";
  } else {
    columns = columns / 2;
    columns = "" + columns + "em";
  }
  var sourceFieldSubId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlRichTextCKEditorPeer._SOURCE_FIELD_SUB_ID);
  component._ckLoadStatus = AdfDhtmlRichTextCKEditorPeer._CKLOAD_LOADING;
  var extraPluginsProp = component.getExtraPlugins();
  var extraPlugins = "";
  if (extraPluginsProp != null && extraPluginsProp.length > 0) {
    extraPlugins = extraPluginsProp.reduce(function(previous, plugin) {
      if (previous == "") {
        previous = plugin;
      } else {
        previous = previous + "," + plugin;
      }
      return previous;
    }, "");
    if (!window.CKEDITOR) {
      window.CKEDITOR = window.CKEDITOR4;
      window.CKEDITOR4._adf_stash_CKEDITOR = "None";
    } else {
      if (window.CKEDITOR && !window.CKEDITOR4._adf_stash_CKEDITOR) {
        AdfLogger.LOGGER.severe("Found another version of ckeditor library loaded in browser." + " Replacing it with ADF version.");
        window.CKEDITOR4._adf_stash_CKEDITOR = window.CKEDITOR;
        window.CKEDITOR = window.CKEDITOR4;
      }
    }
  }
  var textAreaLabel = component.getLabel();
  if (!textAreaLabel) {
    textAreaLabel = component.getShortDesc();
    if (!textAreaLabel) {
      textAreaLabel = AdfPage.PAGE.getLookAndFeel().getTranslatedString("af_richTextEditor.IFRAME_TITLE");
    }
  }
  try {
    CKEDITOR4.focusManager._.blurDelay = 0;
    var editorObj = CKEDITOR4.replace(sourceFieldSubId, {toolbar:this._getToolbar(component), startupMode:component.getEditMode(), readOnly:component.getDisabled(), width:columns, height:rows, entities_additional:"", font_names:AdfDhtmlRichTextCKEditorPeer._FONT_NAMES, font_defaultLabel:"Tahoma", fontSize_sizes:AdfDhtmlRichTextCKEditorPeer._FONT_SIZES, autoUpdateElement:false, autoParagraph:false, baseFloatZIndex:2147483646, extraAllowedContent:AdfDhtmlRichTextCKEditorPeer._EXTRA_TAGS, extraPlugins:extraPlugins, 
    fontSize_defaultLabel:AdfDhtmlRichTextCKEditorPeer._DEFAULT_FONT_SIZE, title:textAreaLabel, on:{instanceReady:function(evt) {
      component.getPeer()._instanceReady(component, evt.editor);
    }, focus:function(evt) {
      component.getPeer()._focusCallback(evt);
    }, blur:function(evt) {
      component.getPeer()._blurCallback(evt);
    }, mode:function(evt) {
      component.getPeer()._modeCallback(evt);
    }, resize:function(evt) {
      component.getPeer()._resizeCallback(evt);
    }}});
    this._addToolbarPlaceHolder(editorObj);
  } catch (err) {
    AdfLogger.LOGGER.severe("error in ckeditor initialization");
    AdfLogger.LOGGER.severe(err);
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._getCustomToolbars = function() {
  if (!this._customToolbars) {
    this._customToolbars = [];
  }
  return this._customToolbars;
};
AdfDhtmlRichTextCKEditorPeer.prototype._addToolbarPlaceHolder = function(editorObj) {
  var customToolbars = this._getCustomToolbars();
  for (var i = 0;i < customToolbars.length;i++) {
    editorObj.ui.add(customToolbars[i], CKEDITOR4.UI_BUTTON, {toolbar:customToolbars[i]});
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._focusCallback = function(evt) {
  var instanceRef = evt.editor;
  var comp = AdfPage.PAGE.findComponent(instanceRef.componentId);
  var contentNode = comp.getPeer()._getContentField(comp);
  AdfAgent.AGENT.setExpandoProperty(contentNode, AdfDhtmlInputBasePeer._LAST_VALUE, contentNode.value);
  comp.getPeer().ShowNoteWindow();
};
AdfDhtmlRichTextCKEditorPeer.prototype._blurCallback = function(evt) {
  var instanceRef = evt.editor;
  var comp = AdfPage.PAGE.findComponent(instanceRef.componentId);
  var ckInitFld = comp.getPeer()._getCkInitField(comp);
  var ckPeer = comp.getPeer();
  if (ckInitFld.value != instanceRef.getData() || ckPeer._isDirty) {
    ckPeer._isDirty = true;
    ckPeer._getContentField(comp).value = instanceRef.getData();
    ckPeer.Validate(comp);
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._modeCallback = function(evt) {
  var instanceRef = evt.editor;
  var component = AdfPage.PAGE.findComponent(instanceRef.componentId);
  if (component != null) {
    component.setProperty("editMode", instanceRef.mode);
    component.getPeer()._setFontSizeOnCK(component);
  }
  var domRef;
  if (instanceRef.mode == "wysiwyg") {
    domRef = instanceRef.document;
  } else {
    if (!instanceRef.container.hasListeners("keyup")) {
      domRef = instanceRef.container;
    }
  }
  if (domRef) {
    domRef.on("keyup", function(event) {
      var component = AdfPage.PAGE.findComponent(instanceRef.componentId);
      var componentEvent = component.getPeer().createComponentEvent(component, event.data.$);
      component.queueEvent(componentEvent);
    });
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._resizeCallback = function(evt) {
  var instanceRef = evt.editor;
  var comp = AdfPage.PAGE.findComponent(instanceRef.componentId);
  comp.getPeer()._resizeCustomToolbars(comp, instanceRef);
};
AdfDhtmlRichTextCKEditorPeer.prototype._instanceReady = function(component, instanceRef) {
  instanceRef.componentId = component.getClientId();
  component._ckeditor = instanceRef;
  AdfRichTextEditorBehaviorManager.getInstance().registerComponent(component);
  var toolBarTop = instanceRef.ui.space(instanceRef.config.toolbarLocation).$;
  if (component.getDisabled() || instanceRef.toolbar.length == 0) {
    toolBarTop.style.display = "none";
  } else {
    var fontSizeElems = toolBarTop.getElementsByClassName("cke_combo__fontsize");
    if (fontSizeElems && fontSizeElems.length > 0) {
      var fontSizeDropDown = fontSizeElems[0];
      var fontSizeLableElems = fontSizeDropDown.getElementsByClassName("cke_combo_inlinelabel cke_combo_text");
      if (fontSizeLableElems && fontSizeLableElems.length > 0) {
        fontSizeLableElems[0].innerText = AdfDhtmlRichTextCKEditorPeer._DEFAULT_FONT_SIZE;
      }
    }
  }
  if (component.getContentDelivery() == "lazy") {
    var tempframe = document.createElement("iframe");
    tempframe.src = AdfPage.PAGE.getLazyFetchURI(component.getClientId());
    tempframe.id = "rteLazyFrame";
    tempframe.style.display = "none";
    tempframe.onload = function() {
      AdfLogger.LOGGER.info("loaded data for lazy Fetch mode");
      instanceRef.setData(this.contentDocument.body.innerHTML);
      component.getPeer()._initData(component, instanceRef.getData());
      this.parentNode.removeChild(this);
    };
    document.body.appendChild(tempframe);
  } else {
    component.getPeer()._initData(component, instanceRef.getData());
  }
  if (AdfDomUtils.isInPopup(component) == true) {
    component._popupAncestor = AdfDomUtils.getPopupAncestor(component);
    component._popupCloseListener = function() {
      component.getPeer()._handlePopupClosed();
      component._popupAncestor.removeEventListener(AdfPopupClosedEvent.POPUP_CLOSED_EVENT_TYPE, component._popupCloseListener);
      component._popupCloseListener = null;
    };
    component._popupAncestor.addEventListener(AdfPopupClosedEvent.POPUP_CLOSED_EVENT_TYPE, component._popupCloseListener);
  }
  component.getPeer()._setFontSizeOnCK(component);
  if (this._getCustomToolbars().length > 0) {
    this._handleCustomToolbar(component, instanceRef);
  }
  component._ckLoadStatus = AdfDhtmlRichTextCKEditorPeer._CKLOAD_LOADED;
};
AdfDhtmlRichTextCKEditorPeer.prototype._setFontSizeOnCK = function(component) {
  var contentDomNode = component.getPeer().getDomElement();
  var fontSize = window.getComputedStyle(contentDomNode).getPropertyValue("font-size");
  var childFrames = contentDomNode.getElementsByTagName("iframe");
  if (childFrames != null && childFrames.length > 0) {
    var fontSizeStyle = "font-size:" + fontSize;
    AdfDomUtils.addInlineStyle(childFrames[0].contentDocument.body, fontSizeStyle, true);
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._handleCustomToolbar = function(component, instanceRef) {
  var domDocument = AdfPage.PAGE.getDomDocument();
  var topSpace = instanceRef.ui.space(instanceRef.config.toolbarLocation);
  if (topSpace) {
    topSpace.$.classList.remove(AdfDhtmlRichTextCKEditorPeer._CKE_RESET_ALL);
  }
  var maxWidth = window.getComputedStyle(topSpace.$, null).getPropertyValue("width");
  var componentDom = component.getPeer().getDomNode();
  var customPrefix = component.getClientId() + AdfDhtmlRichTextCKEditorPeer._ADF_TOOLBAR_ROW_TOP;
  var customToolbars = this._getCustomToolbars();
  for (i = 0;i < customToolbars.length;i++) {
    var facetName = customToolbars[i].toLowerCase();
    var customFacet = domDocument.getElementById(customPrefix + facetName);
    customFacet.classList.add(AdfDhtmlRichTextCKEditorPeer._CKE_BUTTON);
    customFacet.style.maxWidth = maxWidth;
    customFacet.style.overflow = "hidden";
    var ckToolbarLocator = AdfDhtmlRichTextCKEditorPeer._CKE_BUTTON + "__" + facetName;
    var ckToolbarButton = componentDom.getElementsByClassName(ckToolbarLocator)[0];
    var toolBarNode = ckToolbarButton.parentElement;
    while (toolBarNode != null && toolBarNode != componentDom && !toolBarNode.classList.contains(AdfDhtmlRichTextCKEditorPeer._CKE_TOOLBAR)) {
      toolBarNode = toolBarNode.parentElement;
    }
    if (toolBarNode != null) {
      toolBarNode.classList.add(AdfDhtmlRichTextCKEditorPeer._NO_CKE_RESET_ALL);
    }
    ckToolbarButton.parentElement.replaceChild(customFacet, ckToolbarButton);
  }
  var toolbarNodes = componentDom.getElementsByClassName(AdfDhtmlRichTextCKEditorPeer._CKE_TOOLBAR);
  for (i = 0;i < toolbarNodes.length;i++) {
    if (toolbarNodes[i].classList.contains(AdfDhtmlRichTextCKEditorPeer._NO_CKE_RESET_ALL)) {
      continue;
    }
    toolbarNodes[i].classList.add(AdfDhtmlRichTextCKEditorPeer._CKE_RESET_ALL);
  }
  component.getPeer()._resizeCustomToolbars(component, instanceRef);
  var topCustomToolbar = domDocument.getElementById(component.getClientId() + AdfDhtmlRichTextCKEditorPeer._ADF_TOOLBAR_TOP);
  if (topCustomToolbar) {
    topCustomToolbar.style.display = "none";
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._resizeCustomToolbars = function(component, instanceRef) {
  var topSpace = instanceRef.ui.space(instanceRef.config.toolbarLocation);
  var maxWidth = window.getComputedStyle(topSpace.$, null).getPropertyValue("width");
  var domDocument = AdfPage.PAGE.getDomDocument();
  var customPrefix = component.getClientId() + AdfDhtmlRichTextCKEditorPeer._ADF_TOOLBAR_ROW_TOP;
  var customToolbars = this._getCustomToolbars();
  for (i = 0;i < customToolbars.length;i++) {
    var facetName = customToolbars[i].toLowerCase();
    var customFacet = domDocument.getElementById(customPrefix + facetName);
    customFacet.style.maxWidth = maxWidth;
    if (customFacet.offsetHeight > 30) {
      customFacet.style.zoom = 30 / customFacet.offsetHeight;
    }
    AdfPage.PAGE.findComponent(customFacet.id).resizeNotify();
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._initData = function(component, data) {
  this._getContentField(component).value = data;
  this._getCkInitField(component).value = data;
  this._isDirty = false;
};
AdfDhtmlRichTextCKEditorPeer.prototype._getToolbar = function(component) {
  if (this._toolbarList) {
    return this._toolbarList;
  }
  var toolboxLayout = component.getToolboxLayout();
  if (toolboxLayout == null) {
    toolboxLayout = "all";
  }
  var customPrefix = component.getClientId() + AdfDhtmlRichTextCKEditorPeer._ADF_TOOLBAR_ROW_TOP;
  var domDocument = AdfPage.PAGE.getDomDocument();
  this._toolbarList = [];
  if (Array.isArray(toolboxLayout)) {
    var hasFormat = false;
    for (var i = 0;i < toolboxLayout.length;i++) {
      if (toolboxLayout[i] == "formatAll") {
        hasFormat = true;
        break;
      }
    }
    for (var i = 0;i < toolboxLayout.length;i++) {
      var toolBarItem = toolboxLayout[i];
      if (hasFormat && (toolBarItem == "formatCommon" || toolBarItem == "formatUncommon")) {
        continue;
      }
      if (toolBarItem == "all") {
        var allToolBarBtns = this._getAllToolbar();
        for (var j = 0;j < allToolBarBtns.length;j++) {
          this._toolbarList.push(allToolBarBtns[j]);
        }
      } else {
        var toolBarConfig = AdfDhtmlRichTextCKEditorPeer._TOOLBAR[toolBarItem];
        if (toolBarConfig != null) {
          this._toolbarList.push(toolBarConfig);
        } else {
          this._addCustomOrExtra(toolBarItem, domDocument, customPrefix);
        }
      }
    }
  } else {
    var toolBarItem = AdfDhtmlRichTextCKEditorPeer._TOOLBAR[toolboxLayout];
    if (toolBarItem != null) {
      this._toolbarList.push(toolBarItem);
    } else {
      if (toolboxLayout == "all") {
        this._toolbarList = this._getAllToolbar();
      } else {
        this._addCustomOrExtra(toolBarItem, domDocument, customPrefix);
      }
    }
  }
  return this._toolbarList;
};
AdfDhtmlRichTextCKEditorPeer.prototype._addCustomOrExtra = function(item, domDocument, customPrefix) {
  if (AdfDhtmlRichTextCKEditorPeer._NONE_LAYOUT == item) {
    return;
  }
  var customOrExtraToolbarItem = {"name":item, "items":[item]};
  this._toolbarList.push(customOrExtraToolbarItem);
  var customFacet = domDocument.getElementById(customPrefix + item.toLowerCase());
  if (customFacet) {
    this._getCustomToolbars().push(item);
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._getAllToolbar = function() {
  var toolBar = [];
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["font"]);
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["color"]);
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["formatCommon"]);
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["mode"]);
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["history"]);
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["justify"]);
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["list"]);
  toolBar.push(AdfDhtmlRichTextCKEditorPeer._TOOLBAR["link"]);
  return toolBar;
};
AdfDhtmlRichTextCKEditorPeer.prototype._getCkInitField = function(component) {
  var subId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlRichTextCKEditorPeer._CK_INIT_VALUE_FIELD);
  var domNode = AdfAgent.AGENT.getElementById(subId);
  AdfAssert.assertDomElement(domNode);
  return domNode;
};
AdfDhtmlRichTextCKEditorPeer.prototype._execCommand = function(key, value) {
  var agent = AdfAgent.AGENT;
  AdfAssert.assertString(key);
  var component = this.getComponent();
  var ckeditor = component._ckeditor;
  if (ckeditor == null) {
    AdfLogger.LOGGER.severe("Not executing command as ckeditor does not exists");
    return;
  }
  switch(key) {
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_INSERT:
      var element = this._getContentField(component);
      if (this._isTouch && agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM) {
        element.focus();
      }
      ckeditor.insertHtml(value);
      break;
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_MODE_RICH_TEXT:
      ckeditor.setMode("wysiwyg");
      break;
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_MODE_CODE:
      ckeditor.setMode("source");
      break;
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_UNDO:
      ckeditor.execCommand("undo");
      break;
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_REDO:
      ckeditor.execCommand("redo");
      break;
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_LINK:
      ckeditor.execCommand("link");
      break;
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_UNLINK:
      ckeditor.execCommand("unlink");
      break;
    case AdfDhtmlRichTextCKEditorPeer.COMMAND_CLEAR_STYLING:
      ckeditor.execCommand("removeFormat");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_BOLD:
      ckeditor.execCommand("bold");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_ITALIC:
      ckeditor.execCommand("italic");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_UNDERLINE:
      ckeditor.execCommand("underline");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_STRIKETHROUGH:
      ckeditor.execCommand("strike");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_LIST_UNORDERED:
      ckeditor.execCommand("bulletedlist");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_LIST_ORDERED:
      ckeditor.execCommand("numberedlist");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_INDENT:
      ckeditor.execCommand("indent");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_OUTDENT:
      ckeditor.execCommand("outdent");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_JUSTIFY_LEFT:
      ckeditor.execCommand("justifyleft");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_JUSTIFY_CENTER:
      ckeditor.execCommand("justifycenter");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_JUSTIFY_RIGHT:
      ckeditor.execCommand("justifyright");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_JUSTIFY_FULL:
      ckeditor.execCommand("justifyblock");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_SUPERSCRIPT:
      ckeditor.execCommand("subscript");
      break;
    case AdfDhtmlRichTextCKEditorPeer.STYLE_SUBSCRIPT:
      ckeditor.execCommand("superscript");
      break;
    default:
      AdfLogger.LOGGER.severe("unsupported command");
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._handlePopupClosed = function(componentEvent) {
  AdfLogger.LOGGER.info("popup closed. Destroying CKEditor");
  if (this._component) {
    this._component._ckeditor.destroy();
    this._component._ckLoadStatus = AdfDhtmlRichTextCKEditorPeer._CKLOAD_RELOAD;
  }
};
AdfDhtmlRichTextCKEditorPeer.prototype._getContentField = function(component) {
  var subId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlRichTextEditorBasePeer._SOURCE_FIELD_SUB_ID);
  var domNode = AdfAgent.AGENT.getElementById(subId);
  AdfAssert.assertDomElement(domNode);
  return domNode;
};
AdfDhtmlRichTextCKEditorPeer._hasEditorLoaded = function(component) {
  return component._ckLoadStatus == AdfDhtmlRichTextCKEditorPeer._CKLOAD_LOADED;
};
AdfDhtmlRichTextCKEditorPeer._isEditorLoading = function(component) {
  return component._ckLoadStatus == AdfDhtmlRichTextCKEditorPeer._CKLOAD_LOADING;
};
AdfDhtmlRichTextCKEditorPeer._needsEditorReload = function(component) {
  return component._ckeditor == null || component._ckLoadStatus == AdfDhtmlRichTextCKEditorPeer._CKLOAD_RELOAD;
};
AdfDhtmlRichTextCKEditorPeer.prototype._redistributeEventsToNewTarget = function(evt) {
};
