Skip to content
Snippets Groups Projects
Commit 81dd094a authored by srosse's avatar srosse
Browse files

OO-3920: save in memory the current workiong size of tiny

parent d2ca89c6
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,9 @@ class RichTextElementComponent extends FormBaseComponentImpl {
private static final ComponentRenderer RENDERER = new RichTextElementRenderer();
private final RichTextElementImpl element;
private int cols, rows;
private int cols;
private int rows;
private Integer currentHeight;
private TextMode currentTextMode;
/**
......@@ -82,9 +84,6 @@ class RichTextElementComponent extends FormBaseComponentImpl {
return element;
}
/**
* @see org.olat.core.gui.components.Component#getHTMLRendererSingleton()
*/
@Override
public ComponentRenderer getHTMLRendererSingleton() {
return RENDERER;
......@@ -105,6 +104,14 @@ class RichTextElementComponent extends FormBaseComponentImpl {
public void setRows(int rows) {
this.rows = rows;
}
protected Integer getCurrentHeight() {
return currentHeight;
}
protected void setCurrentHeight(Integer currentHeight) {
this.currentHeight = currentHeight;
}
protected TextMode getCurrentTextMode() {
return currentTextMode;
......
......@@ -195,6 +195,9 @@ public class RichTextElementImpl extends AbstractTextElement implements
String paramId = component.getFormDispatchId();
String cmd = getRootForm().getRequestParameter("cmd");
String submitValue = getRootForm().getRequestParameter(paramId);
String sizeParamId = "rtinye_".concat(paramId);
String size = getRootForm().getRequestParameter(sizeParamId);
if(StringHelper.containsNonWhitespace(submitValue)) {
if(renderingMode == TextMode.oneLine) {
submitValue = TextMode.fromOneLine(submitValue);
......@@ -203,6 +206,10 @@ public class RichTextElementImpl extends AbstractTextElement implements
}
}
if(StringHelper.containsNonWhitespace(size)) {
setCurrentHeight(size);
}
String dispatchUri = getRootForm().getRequestParameter("dispatchuri");
if("saveinlinedtiny".equals(cmd)) {
if(submitValue != null) {
......@@ -256,6 +263,15 @@ public class RichTextElementImpl extends AbstractTextElement implements
configuration = null;
}
}
private void setCurrentHeight(String size) {
try {
int height = Double.valueOf(size).intValue();
component.setCurrentHeight(height);
} catch (NumberFormatException e) {
//can happen, don't make a drama of it
}
}
@Override
public void setNewOriginalValue(String value) {
......
......@@ -213,6 +213,9 @@ class RichTextElementRenderer extends DefaultComponentRenderer {
configurations.append("maxSize:").append(te.getMaxLength()).append("\n");
}
Integer currentHeight = teC.getCurrentHeight();
sb.append("<input type='hidden' id='rtinye_").append(teC.getFormDispatchId()).append("' name='rtinye_").append(teC.getFormDispatchId()).append("' value='' />");
sb.append("<script type='text/javascript'>/* <![CDATA[ */\n");
//file browser url
sb.append(" BTinyHelper.editorMediaUris.put('").append(domID).append("','");
......@@ -220,13 +223,21 @@ class RichTextElementRenderer extends DefaultComponentRenderer {
sb.append("');\n");
sb.append(" setTimeout(function() { jQuery('#").append(domID).append("').tinymce({\n")//delay for firefox + tinymce 4.5 + jQuery 3.3.1
.append(" selector: '#").append(domID).append("',\n")
.append(" script_url: '").append(baseUrl.toString()).append("',\n")
.append(" setup: function(ed){\n")
.append(" script_url: '").append(baseUrl.toString()).append("',\n");
if(currentHeight != null && currentHeight.intValue() > 20) {
sb.append(" height: ").append(currentHeight).append(",\n");
}
sb.append(" setup: function(ed){\n")
.append(" ed.on('init', function(e) {\n")
.append(" ").append(onInit.get(0).replace(".curry(", "(")).append(";\n")
.append(" });\n")
.append(" ed.on('change', function(e) {\n")
.append(" BTinyHelper.triggerOnChange('").append(domID).append("');\n")
.append(" });\n")
.append(" ed.on('ResizeEditor', function(e) {\n")
.append(" try {\n")
.append(" jQuery('#rtinye_").append(teC.getFormDispatchId()).append("').val(ed.contentAreaContainer.clientHeight);\n")
.append(" } catch(e) { }\n")
.append(" });\n");
if(config.isSendOnBlur()) {
sb.append(" ed.on('blur', function(e) {\n")
......
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