示例#1
0
 @Override
 protected void onDetach() {
   for (CKEditorPanelExtension behavior : extensions) {
     behavior.detach();
   }
   super.onDetach();
 }
示例#2
0
  /**
   * Adds custom server-side behavior to this panel.
   *
   * @param extension the behavior to add.
   */
  public void addExtension(CKEditorPanelExtension extension) {
    extensions.add(extension);

    for (Behavior behavior : extension.getBehaviors()) {
      add(behavior);
    }
  }
示例#3
0
  private JSONObject getConfigurationForEditor() {
    try {
      JSONObject editorConfig = JsonUtils.createJSONObject(editorConfigJson);

      // configure extensions
      for (CKEditorPanelExtension extension : extensions) {
        extension.addConfiguration(editorConfig);
      }

      // always use the language of the current CMS locale
      final Locale locale = getLocale();
      editorConfig.put(CKEditorConstants.CONFIG_LANGUAGE, locale.getLanguage());

      // convert Hippo-specific 'declarative' keystrokes to numeric ones
      final JSONArray declarativeAndNumericKeystrokes =
          editorConfig.optJSONArray(CKEditorConstants.CONFIG_KEYSTROKES);
      final JSONArray numericKeystrokes =
          DeclarativeKeystrokesConverter.convertToNumericKeystrokes(
              declarativeAndNumericKeystrokes);
      editorConfig.putOpt(CKEditorConstants.CONFIG_KEYSTROKES, numericKeystrokes);

      // load the localized hippo styles if no other styles are specified
      JsonUtils.putIfAbsent(
          editorConfig, CKEditorConstants.CONFIG_STYLES_SET, HippoStyles.getConfigStyleSet(locale));

      // disable custom config loading if not configured
      JsonUtils.putIfAbsent(
          editorConfig, CKEditorConstants.CONFIG_CUSTOM_CONFIG, StringUtils.EMPTY);

      if (log.isInfoEnabled()) {
        log.info(
            "CKEditor configuration:\n"
                + editorConfig.toString(LOGGED_EDITOR_CONFIG_INDENT_SPACES));
      }

      return editorConfig;
    } catch (JSONException e) {
      throw new IllegalStateException("Error creating CKEditor configuration.", e);
    }
  }