Skip to content

Commit eb3406a

Browse files
viv-helixdjoseph-apphelix
authored andcommitted
fix: tinymce rtl issue and insert image
1 parent 8056a26 commit eb3406a

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

src/editors/sharedComponents/TinyMceWidget/hooks.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ export const editorConfig = ({
308308
learningContextId,
309309
staticRootUrl,
310310
enableImageUpload,
311+
showImageButton,
311312
}) => {
312313
const lmsEndpointUrl = getConfig().LMS_BASE_URL;
313314
const studioEndpointUrl = getConfig().STUDIO_BASE_URL;
@@ -320,7 +321,9 @@ export const editorConfig = ({
320321
imageToolbar,
321322
quickbarsInsertToolbar,
322323
quickbarsSelectionToolbar,
323-
} = pluginConfig({ placeholder, editorType, enableImageUpload });
324+
} = pluginConfig({
325+
placeholder, editorType, enableImageUpload, showImageButton,
326+
});
324327
const isLocaleRtl = isRtl(getLocale());
325328
return {
326329
onInit: (evt, editor) => {

src/editors/sharedComponents/TinyMceWidget/pluginConfig.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import { buttons, plugins } from '../../data/constants/tinyMCE';
33

44
const mapToolbars = toolbars => toolbars.map(toolbar => toolbar.join(' ')).join(' | ');
55

6-
const pluginConfig = ({ placeholder, editorType, enableImageUpload }) => {
7-
const image = enableImageUpload ? plugins.image : '';
6+
const pluginConfig = ({
7+
placeholder, editorType, enableImageUpload, showImageButton = false,
8+
}) => {
9+
const image = (enableImageUpload || showImageButton) ? plugins.image : '';
810
const imageTools = enableImageUpload ? plugins.imagetools : '';
11+
const imageButton = showImageButton ? 'image' : '';
912
const imageUploadButton = enableImageUpload ? buttons.imageUploadButton : '';
1013
const editImageSettings = enableImageUpload ? buttons.editImageSettings : '';
1114
const codePlugin = editorType === 'text' ? plugins.code : '';
@@ -55,7 +58,7 @@ const pluginConfig = ({ placeholder, editorType, enableImageUpload }) => {
5558
buttons.outdent,
5659
buttons.indent,
5760
],
58-
[imageUploadButton, buttons.link, buttons.unlink, buttons.blockQuote, buttons.codeBlock],
61+
[imageButton, imageUploadButton, buttons.link, buttons.unlink, buttons.blockQuote, buttons.codeBlock],
5962
[buttons.table, buttons.emoticons, buttons.charmap, buttons.hr],
6063
[buttons.removeFormat, codeButton, buttons.a11ycheck, buttons.embediframe],
6164
]) : false,

src/release-notes/update-form/ReleaseNoteForm.jsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { Formik } from 'formik';
1111
import * as Yup from 'yup';
1212
import classNames from 'classnames';
1313
import moment from 'moment';
14-
15-
import { WysiwygEditor } from '../../generic/WysiwygEditor';
14+
import { useSelector } from 'react-redux';
15+
import TinyMceWidget, { prepareEditorRef } from '../../editors/sharedComponents/TinyMceWidget';
1616
import messages from '../messages';
1717
import unsavedMessages from './unsaved-modal-messages';
1818
import { TIME_FORMAT } from '../../constants';
@@ -25,6 +25,8 @@ const ReleaseNoteForm = ({
2525
}) => {
2626
const [showUnsavedModal, setShowUnsavedModal] = React.useState(false);
2727
const intl = useIntl();
28+
const { editorRef, refReady, setEditorRef } = prepareEditorRef();
29+
const { courseId } = useSelector((state) => state.courseDetail);
2830
const tzName = React.useMemo(() => {
2931
try {
3032
const { timeZone } = Intl.DateTimeFormat().resolvedOptions();
@@ -169,13 +171,23 @@ const ReleaseNoteForm = ({
169171
</Form.Group>
170172

171173
<Form.Group className="m-0 mb-3">
172-
<WysiwygEditor
173-
initialValue={values.description}
174-
data-testid="release-note-wysiwyw"
175-
name="description"
176-
minHeight={200}
177-
onChange={(value) => setFieldValue('description', value)}
178-
/>
174+
{refReady && (
175+
<TinyMceWidget
176+
editorRef={editorRef}
177+
editorType="text"
178+
textValue={values.description}
179+
initialValue={initialValues.description || ''}
180+
minHeight={200}
181+
editorContentHtml={initialValues.description || ''}
182+
setEditorRef={setEditorRef}
183+
onChange={(value) => setFieldValue('description', value)}
184+
initializeEditor={() => ({})}
185+
learningContextId={courseId}
186+
images={{}}
187+
enableImageUpload={false}
188+
showImageButton
189+
/>
190+
)}
179191
{touched.description && errors.description && (
180192
<p className="invalid-feedback d-block">
181193
{errors.description}

0 commit comments

Comments
 (0)