- {isLibrary ? null : (
-
- )}
-
-
diff --git a/src/editors/containers/TextEditor/index.test.jsx b/src/editors/containers/TextEditor/index.test.jsx
index 025175b67..e49844cf9 100644
--- a/src/editors/containers/TextEditor/index.test.jsx
+++ b/src/editors/containers/TextEditor/index.test.jsx
@@ -4,7 +4,6 @@ import { shallow } from 'enzyme';
import { formatMessage } from '../../../testUtils';
import { actions, selectors } from '../../data/redux';
import { RequestKeys } from '../../data/constants/requests';
-import { imgModalToggle, sourceCodeModalToggle } from './hooks';
import { TextEditor, mapStateToProps, mapDispatchToProps } from '.';
// Per https://github.com/tinymce/tinymce-react/issues/91 React unit testing in JSDOM is not supported by tinymce.
@@ -20,34 +19,15 @@ jest.mock('@tinymce/tinymce-react', () => {
jest.mock('../EditorContainer', () => 'EditorContainer');
-jest.mock('./components/ImageUploadModal', () => 'ImageUploadModal');
-jest.mock('./components/SourceCodeModal', () => 'SourceCodeModal');
-
jest.mock('./hooks', () => ({
editorConfig: jest.fn(args => ({ editorConfig: args })),
getContent: jest.fn(args => ({ getContent: args })),
- imgModalToggle: jest.fn(() => ({
- isImgOpen: true,
- openImgModal: jest.fn().mockName('openModal'),
- closeImgModal: jest.fn().mockName('closeModal'),
- })),
- sourceCodeModalToggle: jest.fn(() => ({
- isSourceCodeOpen: true,
- openSourceCodeModal: jest.fn().mockName('openModal'),
- closeSourceCodeModal: jest.fn().mockName('closeModal'),
- })),
- selectedImage: jest.fn(() => ({
- selection: 'hooks.selectedImage.selection',
- setSelection: jest.fn().mockName('hooks.selectedImage.setSelection'),
- clearSelection: jest.fn().mockName('hooks.selectedImage.clearSelection'),
- })),
nullMethod: jest.fn().mockName('hooks.nullMethod'),
prepareEditorRef: jest.fn(() => ({
editorRef: { current: { value: 'something' } },
refReady: true,
setEditorRef: jest.fn().mockName('hooks.prepareEditorRef.setEditorRef'),
})),
- filterAssets: jest.fn(() => [{ staTICUrl: '/assets/sOmEaSsET' }]),
}));
jest.mock('react', () => {
@@ -98,16 +78,6 @@ describe('TextEditor', () => {
intl: { formatMessage },
};
describe('snapshots', () => {
- imgModalToggle.mockReturnValue({
- isImgOpen: false,
- openImgModal: jest.fn().mockName('modal.openModal'),
- closeImgModal: jest.fn().mockName('modal.closeModal'),
- });
- sourceCodeModalToggle.mockReturnValue({
- isSourceCodeOpen: false,
- openSourceCodeModal: jest.fn().mockName('modal.openModal'),
- closeSourceCodeModal: jest.fn().mockName('modal.closeModal'),
- });
test('renders as expected with default behavior', () => {
expect(shallow(
)).toMatchSnapshot();
});
@@ -120,9 +90,6 @@ describe('TextEditor', () => {
test('block failed to load, Toast is shown', () => {
expect(shallow(
)).toMatchSnapshot();
});
- test('ImageUploadModal is not rendered', () => {
- expect(shallow(
)).toMatchSnapshot();
- });
});
describe('mapStateToProps', () => {
@@ -137,6 +104,11 @@ describe('TextEditor', () => {
mapStateToProps(testState).lmsEndpointUrl,
).toEqual(selectors.app.lmsEndpointUrl(testState));
});
+ test('studioEndpointUrl from app.studioEndpointUrl', () => {
+ expect(
+ mapStateToProps(testState).studioEndpointUrl,
+ ).toEqual(selectors.app.studioEndpointUrl(testState));
+ });
test('assets from app.assets', () => {
expect(
mapStateToProps(testState).assets,
diff --git a/src/editors/data/constants/tinyMCE.js b/src/editors/data/constants/tinyMCE.js
index f1c2fe2c9..16d7e0e34 100644
--- a/src/editors/data/constants/tinyMCE.js
+++ b/src/editors/data/constants/tinyMCE.js
@@ -25,6 +25,7 @@ export const buttons = StrictDict({
charmap: 'charmap',
code: 'code-modified', // use a custom button name, consistently, for our text-only button
codesample: 'codesample',
+ customLabelButton: 'customLabelButton',
editImageSettings: 'editimagesettings',
emoticons: 'emoticons',
flip: StrictDict({
@@ -65,8 +66,11 @@ export const plugins = listKeyStore([
'imagetools',
]);
+export const textToSpeechIcon = '
';
+
export default StrictDict({
buttons,
commands,
plugins,
+ textToSpeechIcon,
});
diff --git a/src/editors/containers/TextEditor/components/__snapshots__/BaseModal.test.jsx.snap b/src/editors/sharedComponents/BaseModal/__snapshots__/index.test.jsx.snap
similarity index 93%
rename from src/editors/containers/TextEditor/components/__snapshots__/BaseModal.test.jsx.snap
rename to src/editors/sharedComponents/BaseModal/__snapshots__/index.test.jsx.snap
index 5947d9f57..e15c4ccdc 100644
--- a/src/editors/containers/TextEditor/components/__snapshots__/BaseModal.test.jsx.snap
+++ b/src/editors/sharedComponents/BaseModal/__snapshots__/index.test.jsx.snap
@@ -29,7 +29,7 @@ exports[`BaseModal ImageUploadModal template component snapshot 1`] = `
props.confirmAction node
diff --git a/src/editors/containers/TextEditor/components/BaseModal.jsx b/src/editors/sharedComponents/BaseModal/index.jsx
similarity index 100%
rename from src/editors/containers/TextEditor/components/BaseModal.jsx
rename to src/editors/sharedComponents/BaseModal/index.jsx
diff --git a/src/editors/containers/TextEditor/components/BaseModal.test.jsx b/src/editors/sharedComponents/BaseModal/index.test.jsx
similarity index 92%
rename from src/editors/containers/TextEditor/components/BaseModal.test.jsx
rename to src/editors/sharedComponents/BaseModal/index.test.jsx
index 718d5201f..f855014c4 100644
--- a/src/editors/containers/TextEditor/components/BaseModal.test.jsx
+++ b/src/editors/sharedComponents/BaseModal/index.test.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { BaseModal } from './BaseModal';
+import BaseModal from '.';
describe('BaseModal ImageUploadModal template component', () => {
test('snapshot', () => {
diff --git a/src/editors/containers/TextEditor/components/messages.js b/src/editors/sharedComponents/BaseModal/messages.js
similarity index 72%
rename from src/editors/containers/TextEditor/components/messages.js
rename to src/editors/sharedComponents/BaseModal/messages.js
index e72930ea5..eac25a893 100644
--- a/src/editors/containers/TextEditor/components/messages.js
+++ b/src/editors/sharedComponents/BaseModal/messages.js
@@ -1,6 +1,6 @@
export const messages = {
cancelButtonLabel: {
- id: 'authoring.texteditor.baseModal.cancelButtonLabel',
+ id: 'authoring.baseModal.cancelButtonLabel',
defaultMessage: 'Cancel',
description: 'Label for cancel button.',
},
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/AltTextControls.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.jsx
similarity index 100%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/AltTextControls.jsx
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.jsx
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/AltTextControls.test.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.test.jsx
similarity index 94%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/AltTextControls.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.test.jsx
index 0badd6a53..ebdddaa56 100644
--- a/src/editors/containers/TextEditor/components/ImageSettingsModal/AltTextControls.test.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.test.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { formatMessage } from '../../../../../testUtils';
+import { formatMessage } from '../../../../testUtils';
import { AltTextControls } from './AltTextControls';
jest.mock('./hooks', () => ({
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/DimensionControls.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.jsx
similarity index 100%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/DimensionControls.jsx
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.jsx
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/DimensionControls.test.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.test.jsx
similarity index 95%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/DimensionControls.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.test.jsx
index 9a6119163..249511d77 100644
--- a/src/editors/containers/TextEditor/components/ImageSettingsModal/DimensionControls.test.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.test.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { formatMessage } from '../../../../../testUtils';
+import { formatMessage } from '../../../../testUtils';
import { DimensionControls } from './DimensionControls';
jest.mock('./hooks', () => ({
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/__snapshots__/AltTextControls.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/AltTextControls.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/__snapshots__/AltTextControls.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/AltTextControls.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/index.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/__snapshots__/index.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/index.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/hooks.js b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/hooks.js
similarity index 99%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/hooks.js
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/hooks.js
index a853b1175..7bb9dbf0e 100644
--- a/src/editors/containers/TextEditor/components/ImageSettingsModal/hooks.js
+++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/hooks.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { StrictDict } from '../../../../utils';
+import { StrictDict } from '../../../utils';
import * as module from './hooks';
// Simple wrappers for useState to allow easy mocking for tests.
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/hooks.test.js b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/hooks.test.js
similarity index 99%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/hooks.test.js
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/hooks.test.js
index bfe5b9d52..a4de14743 100644
--- a/src/editors/containers/TextEditor/components/ImageSettingsModal/hooks.test.js
+++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/hooks.test.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { StrictDict } from '../../../../utils';
-import { MockUseState } from '../../../../../testUtils';
+import { StrictDict } from '../../../utils';
+import { MockUseState } from '../../../../testUtils';
import * as hooks from './hooks';
jest.mock('react', () => ({
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/index.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.jsx
similarity index 96%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/index.jsx
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.jsx
index 00c42e799..0a1b041f8 100644
--- a/src/editors/containers/TextEditor/components/ImageSettingsModal/index.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.jsx
@@ -8,10 +8,10 @@ import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/
import './index.scss';
import hooks from './hooks';
import messages from './messages';
-import BaseModal from '../BaseModal';
+import BaseModal from '../../BaseModal';
import AltTextControls from './AltTextControls';
import DimensionControls from './DimensionControls';
-import ErrorAlert from '../../../../sharedComponents/ErrorAlerts/ErrorAlert';
+import ErrorAlert from '../../ErrorAlerts/ErrorAlert';
/**
* Modal display wrapping the dimension and alt-text controls for image tags
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/index.scss b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.scss
similarity index 100%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/index.scss
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.scss
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/index.test.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.test.jsx
similarity index 95%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/index.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.test.jsx
index 1b4637226..95662a7b8 100644
--- a/src/editors/containers/TextEditor/components/ImageSettingsModal/index.test.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.test.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { formatMessage } from '../../../../../testUtils';
+import { formatMessage } from '../../../../testUtils';
import { ImageSettingsModal } from '.';
jest.mock('./AltTextControls', () => 'AltTextControls');
diff --git a/src/editors/containers/TextEditor/components/ImageSettingsModal/messages.js b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/messages.js
similarity index 100%
rename from src/editors/containers/TextEditor/components/ImageSettingsModal/messages.js
rename to src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/messages.js
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/Gallery.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/Gallery.jsx
similarity index 94%
rename from src/editors/containers/TextEditor/components/SelectImageModal/Gallery.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/Gallery.jsx
index 4e67bc298..99419a6a9 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/Gallery.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/Gallery.jsx
@@ -8,8 +8,8 @@ import {
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
-import { selectors } from '../../../../data/redux';
-import { RequestKeys } from '../../../../data/constants/requests';
+import { selectors } from '../../../data/redux';
+import { RequestKeys } from '../../../data/constants/requests';
import messages from './messages';
import GalleryCard from './GalleryCard';
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/Gallery.test.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/Gallery.test.jsx
similarity index 89%
rename from src/editors/containers/TextEditor/components/SelectImageModal/Gallery.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/Gallery.test.jsx
index eeac14089..1227f08ea 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/Gallery.test.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/Gallery.test.jsx
@@ -1,12 +1,12 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { formatMessage } from '../../../../../testUtils';
-import { RequestKeys } from '../../../../data/constants/requests';
-import { selectors } from '../../../../data/redux';
+import { formatMessage } from '../../../../testUtils';
+import { RequestKeys } from '../../../data/constants/requests';
+import { selectors } from '../../../data/redux';
import { Gallery, mapStateToProps, mapDispatchToProps } from './Gallery';
-jest.mock('../../../../data/redux', () => ({
+jest.mock('../../../data/redux', () => ({
selectors: {
requests: {
isFinished: (state, { requestKey }) => ({ isFinished: { state, requestKey } }),
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/GalleryCard.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/GalleryCard.jsx
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/GalleryCard.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/GalleryCard.jsx
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/GalleryCard.test.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/GalleryCard.test.jsx
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/GalleryCard.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/GalleryCard.test.jsx
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/SearchSort.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/SearchSort.jsx
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/SearchSort.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/SearchSort.jsx
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/SearchSort.test.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/SearchSort.test.jsx
similarity index 96%
rename from src/editors/containers/TextEditor/components/SelectImageModal/SearchSort.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/SearchSort.test.jsx
index b6e9c7016..bb2b98676 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/SearchSort.test.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/SearchSort.test.jsx
@@ -3,7 +3,7 @@ import { shallow } from 'enzyme';
import { Dropdown } from '@edx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
-import { formatMessage } from '../../../../../testUtils';
+import { formatMessage } from '../../../../testUtils';
import { sortKeys, sortMessages } from './utils';
import { SearchSort } from './SearchSort';
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/Gallery.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/Gallery.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/Gallery.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/Gallery.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/GalleryCard.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/GalleryCard.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/GalleryCard.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/GalleryCard.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/SearchSort.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/SearchSort.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/SearchSort.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/SearchSort.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/index.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/__snapshots__/index.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/__snapshots__/index.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/hooks.js b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/hooks.js
similarity index 98%
rename from src/editors/containers/TextEditor/components/SelectImageModal/hooks.js
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/hooks.js
index 93c08966b..b8e813770 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/hooks.js
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/hooks.js
@@ -1,7 +1,7 @@
import React from 'react';
import { useDispatch } from 'react-redux';
-import { thunkActions } from '../../../../data/redux';
+import { thunkActions } from '../../../data/redux';
import * as module from './hooks';
import { sortFunctions, sortKeys } from './utils';
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/hooks.test.js b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/hooks.test.js
similarity index 98%
rename from src/editors/containers/TextEditor/components/SelectImageModal/hooks.test.js
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/hooks.test.js
index a226d6523..7128d857b 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/hooks.test.js
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/hooks.test.js
@@ -1,9 +1,9 @@
import React from 'react';
import { dispatch } from 'react-redux';
-import { MockUseState } from '../../../../../testUtils';
-import { keyStore } from '../../../../utils';
-import { thunkActions } from '../../../../data/redux';
+import { MockUseState } from '../../../../testUtils';
+import { keyStore } from '../../../utils';
+import { thunkActions } from '../../../data/redux';
import * as hooks from './hooks';
import { sortFunctions, sortKeys } from './utils';
@@ -24,7 +24,7 @@ jest.mock('react-redux', () => {
};
});
-jest.mock('../../../../data/redux', () => ({
+jest.mock('../../../data/redux', () => ({
thunkActions: {
app: {
uploadImage: jest.fn(),
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/index.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.jsx
similarity index 86%
rename from src/editors/containers/TextEditor/components/SelectImageModal/index.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.jsx
index 25145222f..e2ee598bf 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/index.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.jsx
@@ -9,19 +9,19 @@ import {
injectIntl,
intlShape,
} from '@edx/frontend-platform/i18n';
-import { selectors } from '../../../../data/redux';
-import { RequestKeys } from '../../../../data/constants/requests';
+import { selectors } from '../../../data/redux';
+import { RequestKeys } from '../../../data/constants/requests';
import { acceptedImgKeys } from './utils';
import hooks from './hooks';
import messages from './messages';
-import BaseModal from '../BaseModal';
+import BaseModal from '../../BaseModal';
import SearchSort from './SearchSort';
import Gallery from './Gallery';
-import FileInput from '../../../../sharedComponents/FileInput';
-import FetchErrorAlert from '../../../../sharedComponents/ErrorAlerts/FetchErrorAlert';
-import UploadErrorAlert from '../../../../sharedComponents/ErrorAlerts/UploadErrorAlert';
-import ErrorAlert from '../../../../sharedComponents/ErrorAlerts/ErrorAlert';
+import FileInput from '../../FileInput';
+import FetchErrorAlert from '../../ErrorAlerts/FetchErrorAlert';
+import UploadErrorAlert from '../../ErrorAlerts/UploadErrorAlert';
+import ErrorAlert from '../../ErrorAlerts/ErrorAlert';
export const SelectImageModal = ({
isOpen,
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/index.test.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.test.jsx
similarity index 81%
rename from src/editors/containers/TextEditor/components/SelectImageModal/index.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.test.jsx
index 0738b6295..cc6cbf1b6 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/index.test.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.test.jsx
@@ -1,23 +1,23 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { formatMessage } from '../../../../../testUtils';
-import { RequestKeys } from '../../../../data/constants/requests';
-import { selectors } from '../../../../data/redux';
-import BaseModal from '../BaseModal';
-import FileInput from '../../../../sharedComponents/FileInput';
+import { formatMessage } from '../../../../testUtils';
+import { RequestKeys } from '../../../data/constants/requests';
+import { selectors } from '../../../data/redux';
+import BaseModal from '../../BaseModal';
+import FileInput from '../../FileInput';
import Gallery from './Gallery';
import SearchSort from './SearchSort';
import hooks from './hooks';
import { SelectImageModal, mapStateToProps, mapDispatchToProps } from '.';
-jest.mock('../BaseModal', () => 'BaseModal');
-jest.mock('../../../../sharedComponents/FileInput', () => 'FileInput');
+jest.mock('../../BaseModal', () => 'BaseModal');
+jest.mock('../../FileInput', () => 'FileInput');
jest.mock('./Gallery', () => 'Gallery');
jest.mock('./SearchSort', () => 'SearchSort');
-jest.mock('../../../../sharedComponents/ErrorAlerts/FetchErrorAlert', () => 'FetchErrorAlert');
-jest.mock('../../../../sharedComponents/ErrorAlerts/UploadErrorAlert', () => 'UploadErrorAlert');
-jest.mock('../../../../sharedComponents/ErrorAlerts/ErrorAlert', () => 'ErrorAlert');
+jest.mock('../../ErrorAlerts/FetchErrorAlert', () => 'FetchErrorAlert');
+jest.mock('../../ErrorAlerts/UploadErrorAlert', () => 'UploadErrorAlert');
+jest.mock('../..//ErrorAlerts/ErrorAlert', () => 'ErrorAlert');
jest.mock('./hooks', () => ({
imgHooks: jest.fn(() => ({
@@ -42,7 +42,7 @@ jest.mock('./hooks', () => ({
})),
}));
-jest.mock('../../../../data/redux', () => ({
+jest.mock('../../../data/redux', () => ({
selectors: {
requests: {
isPending: (state, { requestKey }) => ({ isPending: { state, requestKey } }),
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/messages.js b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/messages.js
similarity index 100%
rename from src/editors/containers/TextEditor/components/SelectImageModal/messages.js
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/messages.js
diff --git a/src/editors/containers/TextEditor/components/SelectImageModal/utils.js b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/utils.js
similarity index 95%
rename from src/editors/containers/TextEditor/components/SelectImageModal/utils.js
rename to src/editors/sharedComponents/ImageUploadModal/SelectImageModal/utils.js
index 80240abf3..a94a6ebf2 100644
--- a/src/editors/containers/TextEditor/components/SelectImageModal/utils.js
+++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/utils.js
@@ -1,4 +1,4 @@
-import { StrictDict, keyStore } from '../../../../utils';
+import { StrictDict, keyStore } from '../../../utils';
import messages from './messages';
export const sortKeys = StrictDict({
diff --git a/src/editors/containers/TextEditor/components/__snapshots__/ImageUploadModal.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/__snapshots__/index.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/__snapshots__/ImageUploadModal.test.jsx.snap
rename to src/editors/sharedComponents/ImageUploadModal/__snapshots__/index.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/ImageUploadModal.jsx b/src/editors/sharedComponents/ImageUploadModal/index.jsx
similarity index 95%
rename from src/editors/containers/TextEditor/components/ImageUploadModal.jsx
rename to src/editors/sharedComponents/ImageUploadModal/index.jsx
index 89f085e3d..a6877da10 100644
--- a/src/editors/containers/TextEditor/components/ImageUploadModal.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/index.jsx
@@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
import { injectIntl } from '@edx/frontend-platform/i18n';
-import { selectors } from '../../../data/redux';
-import tinyMCEKeys from '../../../data/constants/tinyMCE';
+import { selectors } from '../../data/redux';
+import tinyMCEKeys from '../../data/constants/tinyMCE';
import ImageSettingsModal from './ImageSettingsModal';
import SelectImageModal from './SelectImageModal';
-import * as module from './ImageUploadModal';
+import * as module from '.';
export const propsString = (props) => (
Object.keys(props).map((key) => `${key}="${props[key]}"`).join(' ')
diff --git a/src/editors/containers/TextEditor/components/ImageUploadModal.test.jsx b/src/editors/sharedComponents/ImageUploadModal/index.test.jsx
similarity index 95%
rename from src/editors/containers/TextEditor/components/ImageUploadModal.test.jsx
rename to src/editors/sharedComponents/ImageUploadModal/index.test.jsx
index e7baa4dc7..59ec3870c 100644
--- a/src/editors/containers/TextEditor/components/ImageUploadModal.test.jsx
+++ b/src/editors/sharedComponents/ImageUploadModal/index.test.jsx
@@ -1,18 +1,18 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { keyStore } from '../../../utils';
-import { selectors } from '../../../data/redux';
-import tinyMCEKeys from '../../../data/constants/tinyMCE';
+import { keyStore } from '../../utils';
+import { selectors } from '../../data/redux';
+import tinyMCEKeys from '../../data/constants/tinyMCE';
-import * as module from './ImageUploadModal';
+import * as module from '.';
jest.mock('./ImageSettingsModal', () => 'ImageSettingsModal');
jest.mock('./SelectImageModal', () => 'SelectImageModal');
const { ImageUploadModal, mapStateToProps, mapDispatchToProps } = module;
-jest.mock('../../../data/redux', () => ({
+jest.mock('../../data/redux', () => ({
selectors: {
app: {
lmsEndpointUrl: jest.fn(state => ({ lmsEndpointUrl: state })),
diff --git a/src/editors/containers/TextEditor/components/SourceCodeModal/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/SourceCodeModal/__snapshots__/index.test.jsx.snap
similarity index 100%
rename from src/editors/containers/TextEditor/components/SourceCodeModal/__snapshots__/index.test.jsx.snap
rename to src/editors/sharedComponents/SourceCodeModal/__snapshots__/index.test.jsx.snap
diff --git a/src/editors/containers/TextEditor/components/SourceCodeModal/hooks.js b/src/editors/sharedComponents/SourceCodeModal/hooks.js
similarity index 100%
rename from src/editors/containers/TextEditor/components/SourceCodeModal/hooks.js
rename to src/editors/sharedComponents/SourceCodeModal/hooks.js
diff --git a/src/editors/containers/TextEditor/components/SourceCodeModal/hooks.test.js b/src/editors/sharedComponents/SourceCodeModal/hooks.test.js
similarity index 100%
rename from src/editors/containers/TextEditor/components/SourceCodeModal/hooks.test.js
rename to src/editors/sharedComponents/SourceCodeModal/hooks.test.js
diff --git a/src/editors/containers/TextEditor/components/SourceCodeModal/index.jsx b/src/editors/sharedComponents/SourceCodeModal/index.jsx
similarity index 95%
rename from src/editors/containers/TextEditor/components/SourceCodeModal/index.jsx
rename to src/editors/sharedComponents/SourceCodeModal/index.jsx
index 3241fd9bb..590e10c1e 100644
--- a/src/editors/containers/TextEditor/components/SourceCodeModal/index.jsx
+++ b/src/editors/sharedComponents/SourceCodeModal/index.jsx
@@ -12,7 +12,7 @@ import messages from './messages';
import hooks from './hooks';
import BaseModal from '../BaseModal';
-import CodeEditor from '../../../../sharedComponents/CodeEditor';
+import CodeEditor from '../CodeEditor';
export const SourceCodeModal = ({
isOpen,
diff --git a/src/editors/containers/TextEditor/components/SourceCodeModal/index.test.jsx b/src/editors/sharedComponents/SourceCodeModal/index.test.jsx
similarity index 93%
rename from src/editors/containers/TextEditor/components/SourceCodeModal/index.test.jsx
rename to src/editors/sharedComponents/SourceCodeModal/index.test.jsx
index b01045346..33c4f8dca 100644
--- a/src/editors/containers/TextEditor/components/SourceCodeModal/index.test.jsx
+++ b/src/editors/sharedComponents/SourceCodeModal/index.test.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import hooks from './hooks';
-import { formatMessage } from '../../../../../testUtils';
+import { formatMessage } from '../../../testUtils';
import { SourceCodeModal } from '.';
diff --git a/src/editors/containers/TextEditor/components/SourceCodeModal/messages.js b/src/editors/sharedComponents/SourceCodeModal/messages.js
similarity index 100%
rename from src/editors/containers/TextEditor/components/SourceCodeModal/messages.js
rename to src/editors/sharedComponents/SourceCodeModal/messages.js
diff --git a/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap
new file mode 100644
index 000000000..59ae8b86d
--- /dev/null
+++ b/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap
@@ -0,0 +1,152 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`TinyMceEditor snapshots ImageUploadModal is not rendered 1`] = `
+
+
+
+
+`;
+
+exports[`TinyMceEditor snapshots SourcecodeModal is not rendered 1`] = `
+
+
+
+
+`;
+
+exports[`TinyMceEditor snapshots renders as expected with default behavior 1`] = `
+
+
+
+
+
+`;
diff --git a/src/editors/sharedComponents/TinyMceWidget/hooks.js b/src/editors/sharedComponents/TinyMceWidget/hooks.js
new file mode 100644
index 000000000..30c809ab0
--- /dev/null
+++ b/src/editors/sharedComponents/TinyMceWidget/hooks.js
@@ -0,0 +1,294 @@
+import { useState } from 'react';
+import tinyMCEStyles from '../../data/constants/tinyMCEStyles';
+import { StrictDict } from '../../utils';
+import pluginConfig from './pluginConfig';
+import * as module from './hooks';
+import tinyMCE from '../../data/constants/tinyMCE';
+
+import * as appHooks from '../../hooks';
+
+export const { nullMethod, navigateCallback, navigateTo } = appHooks;
+
+export const state = StrictDict({
+ isImageModalOpen: (val) => useState(val),
+ isSourceCodeModalOpen: (val) => useState(val),
+ imageSelection: (val) => useState(val),
+});
+
+export const parseContentForLabels = ({ editor, updateQuestion }) => {
+ let content = editor.getContent();
+ if (content && content?.length > 0) {
+ const parsedLabels = content.split(/