Skip to content

Commit bfe4b85

Browse files
fix: setting newContent now load the content in html as well
1 parent ff9d4c5 commit bfe4b85

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • src/editors/sharedComponents/TinyMceWidget

src/editors/sharedComponents/TinyMceWidget/hooks.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ export const replaceStaticWithAsset = ({
124124

125125
// Check if this is a direct /static/filename.ext pattern (should be converted)
126126
// vs /static/images/filename.ext pattern (should NOT be converted)
127+
// /static/images/ are direct links to images stored in static, not course assets
128+
// we have dummy images there for course content that should not be converted to assets
127129
const isDirectStaticFile = (isStatic || assetSrc.startsWith('/asset')) && !assetSrc.substring(8).includes('images/');
128130

129131
const staticName = assetSrc.substring(8);
@@ -370,12 +372,18 @@ export const setupCustomBehavior = ({
370372
editor.on('ExecCommand', /* istanbul ignore next */ (e) => {
371373
if (editorType === 'text' && e.command === 'mceFocus') {
372374
const initialContent = editor.getContent();
373-
// @ts-ignore Some parameters like 'lmsEndpointUrl' were missing here. Fix me?
374375
const newContent = replaceStaticWithAsset({
375376
initialContent,
377+
editorType,
378+
lmsEndpointUrl,
376379
learningContextId,
377380
});
378-
if (newContent) { editor.setContent(newContent); }
381+
if (newContent) {
382+
// Use setTimeout to ensure the update happens after current execution
383+
setTimeout(() => {
384+
editor.setContent(newContent);
385+
}, 0);
386+
}
379387
}
380388
if (e.command === 'RemoveFormat') {
381389
editor.formatter.remove('blockquote');

0 commit comments

Comments
 (0)