Skip to content

Commit

Permalink
Merge pull request #3178 from serlo/feat/remove-fill-in-the-blanks
Browse files Browse the repository at this point in the history
feat(editor): remove fill-in-the-blanks and reset exercise
  • Loading branch information
hejtful authored Dec 7, 2023
2 parents 6ec277f + 5a3c61f commit 5dd6569
Showing 1 changed file with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import type { FillInTheBlanksExerciseProps, FillInTheBlanksMode } from '.'
import { FillInTheBlanksRenderer } from './renderer'
import { InteractiveToolbarTools } from '../exercise/toolbar/interactive-toolbar-tools'
import { PluginToolbar } from '@/serlo-editor/editor-ui/plugin-toolbar'
import { selectDocument, useAppSelector } from '@/serlo-editor/store'
import {
selectDocument,
selectIsFocused,
useAppSelector,
} from '@/serlo-editor/store'
import { EditorPluginType } from '@/serlo-editor/types/editor-plugin-type'

export function FillInTheBlanksExerciseEditor(
props: FillInTheBlanksExerciseProps
) {
const { focused } = props

const isRendererTextPluginFocused = useAppSelector((storeState) => {
return selectIsFocused(storeState, props.state.text.id)
})

const hasFocus = focused || isRendererTextPluginFocused

// Rerender if text plugin state changes
const textPluginState = useAppSelector((state) => {
return selectDocument(state, props.state.text.id)
Expand All @@ -18,19 +29,18 @@ export function FillInTheBlanksExerciseEditor(

return (
<div className="mb-12 mt-10 pt-4">
{/* while developing */}
<div className="hidden">
{focused ? (
// TODO: Add button to toggle between fill-in-the-blanks and drag-and-drop
// TODO: Make toolbars nested like in multimedia
<PluginToolbar
pluginType={EditorPluginType.FillInTheBlanksExercise}
className="!left-[21px] top-[-33px] w-[calc(100%-37px)]"
/>
) : null}
</div>
{hasFocus ? (
// TODO: Add button to toggle between fill-in-the-blanks and drag-and-drop

Check warning on line 33 in apps/web/src/serlo-editor/plugins/fill-in-the-blanks-exercise/editor.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unexpected 'todo' comment: 'TODO: Add button to toggle between...'

Check warning on line 33 in apps/web/src/serlo-editor/plugins/fill-in-the-blanks-exercise/editor.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unexpected 'todo' comment: 'TODO: Add button to toggle between...'

Check warning on line 33 in apps/web/src/serlo-editor/plugins/fill-in-the-blanks-exercise/editor.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unexpected 'todo' comment: 'TODO: Add button to toggle between...'
<PluginToolbar
pluginType={EditorPluginType.FillInTheBlanksExercise}
className="!left-[21px] top-[-33px] w-[calc(100%-37px)]"
pluginControls={<InteractiveToolbarTools id={props.id} />}
/>
) : null}
<FillInTheBlanksRenderer
text={props.state.text.render()}
text={props.state.text.render({
config: { isInlineChildEditor: true },
})}
textPluginState={textPluginState}
mode={props.state.mode.value as FillInTheBlanksMode}
initialTextInBlank="correct-answer"
Expand Down

0 comments on commit 5dd6569

Please sign in to comment.