Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
AnnJul-master
  • Loading branch information
gWestenberger committed Apr 12, 2023
2 parents 6bd501e + f702a7c commit 2980653
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ public static native JavaScriptObject generateOptionsForTiny(String configuratio
options.valid_elements = "*[*]";
options.allow_script_urls = true;
}
if (config.link_default_protocol) {
options.link_default_protocol = config.link_default_protocol;
}
if (config.toolbar_items) {
toolbarGroup = @org.opencms.gwt.client.ui.input.tinymce.CmsTinyMCEHelper::createToolbar(Lcom/google/gwt/core/client/JavaScriptObject;)(config.toolbar_items);
toolbarGroup += " | spellchecker";
Expand Down
6 changes: 6 additions & 0 deletions src/org/opencms/widgets/CmsHtmlWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ public static JSONObject getJSONConfiguration(
result.put("spellcheck_language", contentLocale.getLanguage());
}

String linkDefaultProtocol = widgetOptions.getLinkDefaultProtocol();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(linkDefaultProtocol)) {
result.put("link_default_protocol", linkDefaultProtocol);
}

String editorOptions = widgetOptions.getEditorConfigPath();
if (editorOptions != null) {
try {
Expand Down Expand Up @@ -244,6 +249,7 @@ public static JSONObject getJSONConfiguration(
e);
}
}

} catch (JSONException e) {
LOG.error(e.getLocalizedMessage(), e);
}
Expand Down
41 changes: 41 additions & 0 deletions src/org/opencms/widgets/CmsHtmlWidgetOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ public class CmsHtmlWidgetOption {
/** Option for the "show/hide visual control characters" button. */
public static final String OPTION_VISUALCHARS = "visualchars";

/** Option for the default protocol for links */
public static final String OPTION_LINKDEFAULTPROTOCOL = "linkdefaultprotocol:";

/** The optional buttons that can be additionally added to the button bar. */
public static final String[] OPTIONAL_BUTTONS = {
OPTION_ANCHOR,
Expand Down Expand Up @@ -408,8 +411,12 @@ public class CmsHtmlWidgetOption {
/** The style XML path. */
private String m_stylesXmlPath;

/** Path to an external TinyMCE JSON config file. */
private String m_editorConfigPath;

/** The link default protocol */
private String m_linkDefaultProtocol;

/**
* Creates a new empty HTML widget object object.<p>
*/
Expand Down Expand Up @@ -508,6 +515,7 @@ public static String createConfigurationString(CmsHtmlWidgetOption option) {
result.append(option.getFormatSelectOptions());
added = true;
}

if (null != option.getEditorConfigPath()) {
if (added) {
result.append(DELIMITER_OPTION);
Expand All @@ -516,6 +524,12 @@ public static String createConfigurationString(CmsHtmlWidgetOption option) {
result.append(option.getEditorConfigPath());
added = true;
}

if (CmsStringUtil.isNotEmpty(option.getLinkDefaultProtocol())) {
result.append(OPTION_LINKDEFAULTPROTOCOL);
result.append(option.getLinkDefaultProtocol());
}

return result.toString();
}

Expand Down Expand Up @@ -863,6 +877,16 @@ public List<String> getHiddenButtons() {
return m_hiddenButtons;
}

/**
* Returns the link default protocol to use when inserting/editing links via the link dialog.
*
* @return the link default protocol to use when inserting/editing links via the link dialog
*/
public String getLinkDefaultProtocol() {

return m_linkDefaultProtocol;
}

/**
* Returns the styles format VFS path to use in the widget area.<p>
*
Expand Down Expand Up @@ -1055,6 +1079,17 @@ public void setHiddenButtons(List<String> buttons) {
m_hiddenButtons = buttons;
}

/**
* Set the link default protocol to use when inserting/editing links via the link dialog
*
* @param linkDefaultProtocol
* the link default protocol to use when inserting/editing links via the link dialog
*/
public void setLinkDefaultProtocol(String linkDefaultProtocol) {

m_linkDefaultProtocol = linkDefaultProtocol;
}

/**
* Sets the styles format VFS path to use in the widget area.<p>
*
Expand Down Expand Up @@ -1263,6 +1298,12 @@ protected void parseOptions(String configuration) {
m_importCss = true;
} else if (option.startsWith(OPTION_ALLOWSCRIPTS)) {
m_allowScripts = true;
} else if (option.startsWith(OPTION_LINKDEFAULTPROTOCOL)) {
// the link default protocol
option = option.substring(OPTION_LINKDEFAULTPROTOCOL.length());
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(option)) {
setLinkDefaultProtocol(option);
}
} else {
// check if option describes an additional button
if (OPTIONAL_BUTTONS_LIST.contains(option)) {
Expand Down

0 comments on commit 2980653

Please sign in to comment.