Skip to content
Snippets Groups Projects
Commit ce8e07b5 authored by gnaegi's avatar gnaegi
Browse files

OO-2124 Add auto-resize option to rich text editor to optimize paragraph part in eportfolio

parent f2cb5661
No related branches found
No related tags found
No related merge requests found
...@@ -112,6 +112,11 @@ public class RichTextConfiguration implements Disposable { ...@@ -112,6 +112,11 @@ public class RichTextConfiguration implements Disposable {
private static final String FORCED_ROOT_BLOCK_VALUE_NOROOT = ""; private static final String FORCED_ROOT_BLOCK_VALUE_NOROOT = "";
private static final String DOCUMENT_BASE_URL = "document_base_url"; private static final String DOCUMENT_BASE_URL = "document_base_url";
private static final String PASTE_DATA_IMAGES = "paste_data_images"; private static final String PASTE_DATA_IMAGES = "paste_data_images";
private static final String AUTORESIZE_BOTTOM_MARGIN = "autoresize_bottom_margin";
private static final String AUTORESIZE_MAX_HEIGHT = "autoresize_max_height";
private static final String AUTORESIZE_MIN_HEIGHT = "autoresize_min_height";
private static final String AUTORESIZE_OVERFLOW_PADDING = "autoresize_overflow_padding";
// //
// Generic boolean true / false values // Generic boolean true / false values
private static final String VALUE_FALSE = "false"; private static final String VALUE_FALSE = "false";
...@@ -573,6 +578,37 @@ public class RichTextConfiguration implements Disposable { ...@@ -573,6 +578,37 @@ public class RichTextConfiguration implements Disposable {
} }
} }
/**
* Enable / disable the auto-resizing of the text input field. When enabled,
* the editor will expand the input filed until the maxHeight is reached (if
* set)
*
* @param autoResizeEnabled true: enable auto-resize; false: no auto-resize (default)
* @param maxHeight value of max height in pixels or -1 to indicate infinite height
* @param minHeight value of min height in pixels or -1 to indicate no minimum height
* @param bottomMargin value of bottom margin below or -1 to use html editor default
*/
public void setAutoResizeEnabled(boolean autoResizeEnabled, int maxHeight, int minHeight, int bottomMargin) {
if (autoResizeEnabled) {
this.tinyConfig = this.tinyConfig.enableAutoResize();
if (maxHeight > -1) {
setNonQuotedConfigValue(AUTORESIZE_MAX_HEIGHT, Integer.toString(maxHeight));
}
if (minHeight > -1) {
setNonQuotedConfigValue(AUTORESIZE_MIN_HEIGHT, Integer.toString(minHeight));
}
if (bottomMargin > -1) {
setNonQuotedConfigValue(AUTORESIZE_BOTTOM_MARGIN, Integer.toString(bottomMargin));
}
} else {
this.tinyConfig = this.tinyConfig.disableAutoResize();
}
}
/** /**
* Enable / disable the date and time insert plugin * Enable / disable the date and time insert plugin
* *
......
...@@ -133,7 +133,15 @@ public class TinyConfig { ...@@ -133,7 +133,15 @@ public class TinyConfig {
public TinyConfig enableCode() { public TinyConfig enableCode() {
return enableFeature("code"); return enableFeature("code");
} }
public TinyConfig enableAutoResize() {
return enableFeature("autoresize");
}
public TinyConfig disableAutoResize() {
return disableFeature("autoresize");
}
public TinyConfig enableImageAndMedia() { public TinyConfig enableImageAndMedia() {
return enableFeature("image") return enableFeature("image")
.enableFeature("media") .enableFeature("media")
......
...@@ -79,6 +79,7 @@ public class HTMLRawEditorController extends FormBasicController implements Page ...@@ -79,6 +79,7 @@ public class HTMLRawEditorController extends FormBasicController implements Page
htmlItem = uifactory.addRichTextElementForStringDataCompact(cmpId, null, content, 8, 80, null, formLayout, ureq.getUserSession(), getWindowControl()); htmlItem = uifactory.addRichTextElementForStringDataCompact(cmpId, null, content, 8, 80, null, formLayout, ureq.getUserSession(), getWindowControl());
htmlItem.getEditorConfiguration().setSendOnBlur(true); htmlItem.getEditorConfiguration().setSendOnBlur(true);
htmlItem.getEditorConfiguration().disableImageAndMovie(); htmlItem.getEditorConfiguration().disableImageAndMovie();
htmlItem.getEditorConfiguration().setAutoResizeEnabled(true, -1, 40, 0);
String formattedContent = Formatter.formatLatexFormulas(content); String formattedContent = Formatter.formatLatexFormulas(content);
staticItem = uifactory.addStaticTextElement(cmpId + "_static", formattedContent, formLayout); staticItem = uifactory.addStaticTextElement(cmpId + "_static", formattedContent, formLayout);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment