-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: edit Text components within content libraries [FC-0062] #1240
Merged
bradenmacdonald
merged 20 commits into
openedx:master
from
open-craft:braden/library-text-editor
Sep 13, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1ea2e06
feat: make the text editor work with content libraries
bradenmacdonald db477c7
feat: In libraries, allow opening the editor for text (html) components
bradenmacdonald 42e50da
refactor: utility method for getting the "Edit" URL of a component
bradenmacdonald 49a903a
test: update tests
bradenmacdonald e21adef
feat: developer info panel
bradenmacdonald 9eec8a4
fix: sidebar needs to stick to the screen properly
bradenmacdonald 19fb9e2
feat: open the editor when creating a new component
bradenmacdonald 7fddc77
test: simplify the AddContentContainer tests
bradenmacdonald 637e4a3
test: workflow test for editor
bradenmacdonald 51470b3
test: update test coverage
bradenmacdonald 7c7dee3
test: cleanups to AddContentContainer test (from review comments)
bradenmacdonald cdd2b63
refactor: cleanups from code review
bradenmacdonald b0f83d6
refactor: better validation for usageKey utils
bradenmacdonald 9e62bc0
refactor: avoid footgun with EditorContainer
bradenmacdonald 42df1c2
fix: console warning when TextEditor is initialized
bradenmacdonald b5e754a
fix: a11y - add alt text for "exit" button in the editors
bradenmacdonald f5796ac
refactor: separate xblock queryKeys from library queryKeys
bradenmacdonald bb051e6
test: simplify flaky test
bradenmacdonald be9d01b
fix: propTypes validation warning on Toast content string
bradenmacdonald 0ed2c2a
chore: update with latest master
bradenmacdonald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
|
||
import EditorPage from './EditorPage'; | ||
|
||
interface Props { | ||
/** Course ID or Library ID */ | ||
learningContextId: string; | ||
/** Event handler for when user cancels out of the editor page */ | ||
onClose?: () => void; | ||
/** Event handler called after when user saves their changes using an editor */ | ||
afterSave?: () => (newData: Record<string, any>) => void; | ||
} | ||
|
||
const EditorContainer: React.FC<Props> = ({ | ||
learningContextId, | ||
onClose, | ||
afterSave, | ||
}) => { | ||
const { blockType, blockId } = useParams(); | ||
if (blockType === undefined || blockId === undefined) { | ||
// istanbul ignore next - This shouldn't be possible; it's just here to satisfy the type checker. | ||
return <div>Error: missing URL parameters</div>; | ||
} | ||
if (!!onClose !== !!afterSave) { | ||
/* istanbul ignore next */ | ||
throw new Error('You must specify both onClose and afterSave or neither.'); | ||
// These parameters are a bit messy so I'm trying to help make it more | ||
// consistent here. For example, if you specify onClose, then returnFunction | ||
// is only called if the save is successful. But if you leave onClose | ||
// undefined, then returnFunction is called in either case, and with | ||
// different arguments. The underlying EditorPage should be refactored to | ||
// have more clear events like onCancel and onSaveSuccess | ||
} | ||
return ( | ||
<div className="editor-page"> | ||
<EditorPage | ||
courseId={learningContextId} | ||
blockType={blockType} | ||
blockId={blockId} | ||
studioEndpointUrl={getConfig().STUDIO_BASE_URL} | ||
lmsEndpointUrl={getConfig().LMS_BASE_URL} | ||
onClose={onClose} | ||
returnFunction={afterSave} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EditorContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is with the underlying editor, but passing
onClose={undefined}
here actually crashes theTextEditor
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to address this with 9e62bc0