Skip to content

Commit

Permalink
feat: Add WysiwygViewer to view wysiwyg in html mode with sanitized c…
Browse files Browse the repository at this point in the history
…ontent.
  • Loading branch information
Dim145 committed May 27, 2024
1 parent 0cad2a9 commit fa7a276
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions frontend/components/activityApplications/ActivityChoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import _ from "lodash";
import AdditionalStudentSelection from "./../AdditionalStudentSelection.js";
import {frenchEnumeration} from "../utils/index.js";
import {Editor, EditorState, convertFromRaw, ContentState} from "draft-js";
import WysiwygViewer from "../utils/WysiwygViewer";

const moment = require("moment-timezone");
require("moment/locale/fr");
Expand Down Expand Up @@ -277,33 +278,19 @@ const ActivityChoice = ({
return generateActivityRow(item, item.key, item.isPack, item.isSelected);
});

// Display info text ---------------------------------------------------------------------------------------------------------------------------------------------
let editorState = EditorState.createEmpty();
let savedContentRaw = null;
let savedContentState = null;
if (infoText) {
try {
savedContentRaw = JSON.parse(infoText);
savedContentState = convertFromRaw(savedContentRaw);
} catch (e) {
savedContentState = ContentState.createFromText(infoText);
}
editorState = EditorState.createWithContent(savedContentState);
}


return (
<Fragment>
<div>
{infoText && (
<div className="alert alert-info col-md-8 d-inline-flex align-items-center p-1"
style={{border: "1px solid #0079BF", borderRadius: "5px", color: "#0079BF"}}>
<div className="col-1 p-0 text-center">
<div className="col-sm-1 p-0 text-center">
<i className="fas fa-info-circle"></i>
</div>
<div className="col p-0">
{<Editor editorState={editorState} readOnly={true}/>}
</div>
<WysiwygViewer
className="col-sm p-0"
wysiwygStrData={infoText}
/>
</div>
)}
</div>
Expand Down

0 comments on commit fa7a276

Please sign in to comment.