Commit e97ed1c9 authored by Maxime Chaillet's avatar Maxime Chaillet

clean the code.

parent 1f5684ee
......@@ -18,15 +18,12 @@ class EventContentDisplayer extends React.Component {
if (useRichTextEditor !== null && useRichTextEditor !== undefined) {
let HTMLText = this.getContent(content); // can be null
if (useRichTextEditor === true) {
//debugger;
// save the event plainText format to localstorage. This is usefull in case the editor is not changed (when only title is updated)
storeToLocalStorage(EDIT_EVENT_CONTEXT, getContent(content, 'plainText'), PLAINTEXT_CONTENT_FORMAT);
return (<HTMLEditor
onEventModified={onEventModified}
isEditionMode={isEditionMode}
investigationId={investigationId}
minEditorHeight={this.props.minEditorHeight}
maxEditorHeight={this.props.maxEditorHeight}
storeToLocalStorage={storeToLocalStorage}
text={HTMLText}
user={user}
......
......@@ -23,8 +23,6 @@ class EventContentPanel extends React.Component {
eventId={event._id}
investigationId={investigationId}
isEditionMode={true}
maxEditorHeight={this.props.maxEditorHeight}
minEditorHeight={this.props.minEditorHeight}
storeToLocalStorage={this.storeToLocalStorage}
useRichTextEditor={true}
user={user}
......@@ -36,8 +34,6 @@ class EventContentPanel extends React.Component {
onEventModified={onEventModified}
event={event}
investigationId={investigationId}
maxEditorHeight={this.props.maxEditorHeight}
minEditorHeight={this.props.minEditorHeight}
storeToLocalStorage={this.storeToLocalStorage}
user={user}
/>);
......@@ -48,8 +44,6 @@ class EventContentPanel extends React.Component {
onEventModified={onEventModified}
investigationId={investigationId}
isEditionMode={true}
maxEditorHeight={this.props.maxEditorHeight}
minEditorHeight={this.props.minEditorHeight}
storeToLocalStorage={this.storeToLocalStorage}
user={user}
/>
......@@ -197,8 +191,6 @@ const NotificationContent = (props) => {
eventId={event._id}
investigationId={investigationId}
isEditionMode={true}
minEditorHeight={this.props.minEditorHeight}
maxEditorHeight={this.props.maxEditorHeight}
storeToLocalStorage={props.storeToLocalStorage}
useRichTextEditor={true}
user={user}
......@@ -210,8 +202,6 @@ const NotificationContent = (props) => {
eventId={event._id}
investigationId={investigationId}
isEditionMode={true}
minEditorHeight={this.props.minEditorHeight}
maxEditorHeight={this.props.maxEditorHeight}
storeToLocalStorage={props.storeToLocalStorage}
useRichTextEditor={true}
user={user}
......
......@@ -56,8 +56,6 @@ class HTMLEditor extends Component {
statusbar: config.statusbar,
images_upload_handler: this.imagesUploadHandler,
paste_data_images: config.paste_data_images,
//autoresize_min_height: Number(this.props.minEditorHeight),
//autoresize_max_height: Number(this.props.maxEditorHeight),
formats: config.formats,
content_css: config.content_css,
}}
......@@ -79,7 +77,7 @@ class HTMLEditor extends Component {
setEditingAreaHeight = () => {
let panelPart = document.getElementById('refForEditorHeightCalculation');
let editorHeader = document.getElementsByClassName("mce-top-part mce-container mce-stack-layout-item mce-first")[0];
let iframe = this.props.text ? document.getElementById(EDITOR_ID_FOR_EDITION) : document.getElementById(EDITOR_ID_FOR_CREATION) + '_ifr';
let iframe = this.props.text ? document.getElementById(EDITOR_ID_FOR_EDITION + '_ifr') : document.getElementById(EDITOR_ID_FOR_CREATION + '_ifr');
iframe.style.height = (panelPart.clientHeight - EVENT_FOOTER_HEIGHT - editorHeader.clientHeight).toString() + 'px'; // this.props.maxEditorHeight;
let iframeBody = iframe.contentWindow.document.getElementById('tinymce');
iframeBody.style.height = (panelPart.clientHeight - 8 - 8 - EVENT_FOOTER_HEIGHT - editorHeader.clientHeight - 1).toString() + 'px'; //8 = marginTop and marginBottom of the iframe's body
......
......@@ -35,8 +35,6 @@ class NewOrEditEventPanel extends React.Component {
<EventContentPanel
context={context}
event={event}
minEditorHeight={this.props.minEditorHeight}
maxEditorHeight={this.props.maxEditorHeight}
investigationId={investigationId}
onEventModified={this.onEventModified}
user={user}
......
......@@ -18,13 +18,11 @@ import { GUI_CONFIG } from '../gui.config';
/** the general configuration set used for all instances of the editor */
class GeneralConfig {
constructor(userView) {
this.plugins = 'link, image, textcolor, fullscreen, media, paste, table, lists, autoresize, importcss';
this.plugins = 'link, image, textcolor, fullscreen, media, paste, table, lists, importcss';
this.skin_url = '/tinymce/skins/customLightgray';
this.statusbar = false;
this.branding = false; // hides powered by tinymce
this.paste_data_images = true;
//this.autoresize_min_height = 400; //in px
//this.autoresize_max_height = GUI_CONFIG().NEW_EVENT_MAX_HEIGHT; //in px
this.content_css = '/tinymce/customStyles.css';
this.formats = {
alignleft: { selector: 'img', styles: { float: 'left', margin: '10px' } },
......
......@@ -96,8 +96,6 @@ class EventContainer extends React.Component {
<NewOrEditEventPanel
context={NEW_EVENT_CONTEXT}
createEvent={this.createEvent}
minEditorHeight={this.getEditorHeight('min')}
maxEditorHeight={this.getEditorHeight('max')}
investigationId={investigationId}
onNewEventUploaded={this.onNewEventUploaded}
setNewEventVisibility={this.setNewEventVisibility}
......@@ -111,8 +109,6 @@ class EventContainer extends React.Component {
<NewOrEditEventPanel
context={EDIT_EVENT_CONTEXT}
event={this.state.eventBeingEdited}
minEditorHeight={this.getEditorHeight('min')}
maxEditorHeight={this.getEditorHeight('max')}
investigationId={investigationId}
onEventUpdated={this.onEventUpdated}
setEditEventVisibility={this.setEditEventVisibility}
......@@ -172,28 +168,6 @@ class EventContainer extends React.Component {
return '100%';
}
/**
* Get the editor min or max height
*/
getEditorHeight = (minOrMax) => {
if (minOrMax) {
if (minOrMax === 'min') {
if (this.state.isNewEventVisible === true && this.state.eventBeingEdited) {
return GUI_CONFIG().DUAL_EDITOR_MIN_HEIGHT;
} else {
return GUI_CONFIG().SINGLE_EDITOR_MIN_HEIGHT;
}
}
if (minOrMax === 'max') {
if (this.state.isNewEventVisible === true && this.state.eventBeingEdited) {
return GUI_CONFIG().DUAL_EDITOR_MAX_HEIGHT;
} else {
return GUI_CONFIG().SINGLE_EDITOR_MAX_HEIGHT;
}
}
}
}
onEventClicked = (event) => {
this.setState({ eventBeingEdited: event });
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment