From 25b6ebf585f9adcac5b60347cd1d70c0687d1287 Mon Sep 17 00:00:00 2001 From: bhanu2006-24 Date: Mon, 24 Nov 2025 18:18:39 +0530 Subject: [PATCH 1/3] fixed --- .../sequence-navigation/SequenceNavigationTabs.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/course-unit/course-sequence/sequence-navigation/SequenceNavigationTabs.jsx b/src/course-unit/course-sequence/sequence-navigation/SequenceNavigationTabs.jsx index 0307c2f55b..086fa423ce 100644 --- a/src/course-unit/course-sequence/sequence-navigation/SequenceNavigationTabs.jsx +++ b/src/course-unit/course-sequence/sequence-navigation/SequenceNavigationTabs.jsx @@ -1,7 +1,7 @@ import { useDispatch, useSelector } from 'react-redux'; import PropTypes from 'prop-types'; import { useNavigate } from 'react-router-dom'; -import { Button } from '@openedx/paragon'; +import { Button, ButtonGroup } from '@openedx/paragon'; import { Plus as PlusIcon, ContentPasteGo as ContentPasteGoIcon } from '@openedx/paragon/icons'; import { useIntl } from '@edx/frontend-platform/i18n'; @@ -49,7 +49,7 @@ const SequenceNavigationTabs = ({ return (
-
@@ -80,7 +80,7 @@ const SequenceNavigationTabs = ({ {intl.formatMessage(messages.pasteAsNewUnitLink)} )} -
+
{shouldDisplayDropdown && ( Date: Mon, 24 Nov 2025 18:23:25 +0530 Subject: [PATCH 2/3] something --- src/editors/PluggableEditors.test.tsx | 29 +++++++++++++++++++++++++++ src/editors/supportedEditors.ts | 8 ++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/editors/PluggableEditors.test.tsx diff --git a/src/editors/PluggableEditors.test.tsx b/src/editors/PluggableEditors.test.tsx new file mode 100644 index 0000000000..283928683d --- /dev/null +++ b/src/editors/PluggableEditors.test.tsx @@ -0,0 +1,29 @@ +import supportedEditors, { registerEditor } from './supportedEditors'; + +describe('Pluggable Editors', () => { + it('should allow registering a new editor', () => { + const MockEditor = () =>
Mock Editor
; + const newBlockType = 'test-block-type'; + + expect(supportedEditors[newBlockType]).toBeUndefined(); + + registerEditor(newBlockType, MockEditor); + + expect(supportedEditors[newBlockType]).toBe(MockEditor); + }); + + it('should allow overwriting an existing editor', () => { + const MockEditor = () =>
New Mock Editor
; + const existingBlockType = 'html'; // Assuming 'html' exists + + const originalEditor = supportedEditors[existingBlockType]; + expect(originalEditor).toBeDefined(); + + registerEditor(existingBlockType, MockEditor); + + expect(supportedEditors[existingBlockType]).toBe(MockEditor); + + // Restore original editor for other tests + registerEditor(existingBlockType, originalEditor); + }); +}); diff --git a/src/editors/supportedEditors.ts b/src/editors/supportedEditors.ts index 71d0bad737..8725783713 100644 --- a/src/editors/supportedEditors.ts +++ b/src/editors/supportedEditors.ts @@ -8,13 +8,17 @@ import GameEditor from './containers/GameEditor'; import { blockTypes } from './data/constants/app'; -const supportedEditors = { +const supportedEditors: Record = { [blockTypes.html]: TextEditor, [blockTypes.video]: VideoEditor, [blockTypes.problem]: ProblemEditor, [blockTypes.video_upload]: VideoUploadEditor, // ADDED_EDITORS GO BELOW [blockTypes.game]: GameEditor, -} as const; +}; + +export const registerEditor = (blockType: string, editorComponent: any) => { + supportedEditors[blockType] = editorComponent; +}; export default supportedEditors; From 210a2f8594c0395c99a96d86ab3ba6e8d2f381b8 Mon Sep 17 00:00:00 2001 From: bhanu2006-24 Date: Mon, 24 Nov 2025 18:28:46 +0530 Subject: [PATCH 3/3] done --- src/editors/Editor.tsx | 6 ++---- src/editors/EditorContext.tsx | 12 ++++++++++++ src/editors/EditorPage.tsx | 8 +++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/editors/Editor.tsx b/src/editors/Editor.tsx index f939decfd6..60d62bb0b3 100644 --- a/src/editors/Editor.tsx +++ b/src/editors/Editor.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { useDispatch } from 'react-redux'; import * as hooks from './hooks'; +import { useEditorContext } from './EditorContext'; import supportedEditors from './supportedEditors'; import type { EditorComponent } from './EditorComponent'; @@ -13,20 +14,17 @@ export interface Props extends EditorComponent { blockType: string; blockId: string | null; learningContextId: string | null; - lmsEndpointUrl: string | null; - studioEndpointUrl: string | null; } const Editor: React.FC = ({ learningContextId, blockType, blockId, - lmsEndpointUrl, - studioEndpointUrl, onClose = null, returnFunction = null, }) => { const dispatch = useDispatch(); + const { lmsEndpointUrl, studioEndpointUrl } = useEditorContext(); const loading = hooks.useInitializeApp({ dispatch, data: { diff --git a/src/editors/EditorContext.tsx b/src/editors/EditorContext.tsx index d4f4a3ec02..8106e934be 100644 --- a/src/editors/EditorContext.tsx +++ b/src/editors/EditorContext.tsx @@ -15,10 +15,16 @@ export interface EditorContext { learningContextId: string; /** Is the so-called "Markdown" problem editor available in this learning context? */ isMarkdownEditorEnabledForContext: boolean; + /** e.g. "http://studio.local.openedx.io:8001" */ + studioEndpointUrl?: string | null; + /** e.g. "http://local.openedx.io:8000" */ + lmsEndpointUrl?: string | null; } export type EditorContextInit = { learningContextId: string; + studioEndpointUrl?: string | null; + lmsEndpointUrl?: string | null; }; const context = React.createContext(undefined); @@ -36,6 +42,8 @@ export function useEditorContext() { export const EditorContextProvider: React.FC<{ children: React.ReactNode; } & EditorContextInit> = ({ children, learningContextId, + studioEndpointUrl, + lmsEndpointUrl, }) => { const courseIdIfCourse = isCourseKey(learningContextId) ? learningContextId : undefined; const isMarkdownEditorEnabledForContext = useWaffleFlags(courseIdIfCourse).useReactMarkdownEditor; @@ -43,10 +51,14 @@ export const EditorContextProvider: React.FC<{ children: React.ReactNode; } & Ed const ctx: EditorContext = React.useMemo(() => ({ learningContextId, isMarkdownEditorEnabledForContext, + studioEndpointUrl, + lmsEndpointUrl, }), [ // Dependencies - make sure we update the context object if any of these values change: learningContextId, isMarkdownEditorEnabledForContext, + studioEndpointUrl, + lmsEndpointUrl, ]); return {children}; }; diff --git a/src/editors/EditorPage.tsx b/src/editors/EditorPage.tsx index 47c0ff4792..b32a75e842 100644 --- a/src/editors/EditorPage.tsx +++ b/src/editors/EditorPage.tsx @@ -36,15 +36,17 @@ const EditorPage: React.FC = ({ studioEndpointUrl, }} > - +