Skip to content

Commit 9885bee

Browse files
committed
fix: Change styles inclusion for Tiny MCE
1 parent 4ebd3e9 commit 9885bee

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"jquery": "3.6.1",
5353
"popper.js": "1.16.1",
5454
"prop-types": "15.8.1",
55+
"raw-loader": "4.0.2",
5556
"react": "17.0.2",
5657
"react-dom": "17.0.2",
5758
"react-helmet": "^6.1.0",

src/components/bulk-email-tool/text-editor/TextEditor.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,25 @@ import 'tinymce/plugins/image';
1717
import 'tinymce/plugins/codesample';
1818
import '@edx/tinymce-language-selector';
1919

20-
import contentUiCss from 'tinymce/skins/ui/oxide/content.css';
21-
import contentCss from 'tinymce/skins/content/default/content.css';
20+
/* eslint import/no-webpack-loader-syntax: off */
21+
// eslint-disable-next-line import/no-unresolved
22+
import contentUiCss from '!!raw-loader!tinymce/skins/ui/oxide/content.css';
23+
// eslint-disable-next-line import/no-unresolved
24+
import contentCss from '!!raw-loader!tinymce/skins/content/default/content.css';
2225

2326
export default function TextEditor(props) {
2427
const {
2528
onChange, onKeyUp, onInit, disabled, value,
2629
} = props;
2730

31+
let contentStyle;
32+
// In the test environment this causes an error so set styles to empty since they aren't needed for testing.
33+
try {
34+
contentStyle = [contentCss, contentUiCss].join('\n');
35+
} catch (err) {
36+
contentStyle = '';
37+
}
38+
2839
return (
2940
<Editor
3041
initialValue=""
@@ -38,7 +49,7 @@ export default function TextEditor(props) {
3849
'formatselect fontselect bold italic underline forecolor | codesample bullist numlist alignleft aligncenter alignright alignjustify indent | blockquote link image code ',
3950
skin: false,
4051
content_css: false,
41-
content_style: `${contentUiCss.toString()}\n${contentCss.toString()}`,
52+
content_style: contentStyle,
4253
extended_valid_elements: 'span[lang|id] -span',
4354
block_unsupported_drop: false,
4455
image_advtab: true,

0 commit comments

Comments
 (0)