Skip to content
Snippets Groups Projects
Commit aee7f20f authored by chris's avatar chris
Browse files

essay states

parent a859c9e6
No related branches found
No related tags found
1 merge request!475Essay question
...@@ -19,8 +19,7 @@ const EditorWrapper = styled.div` ...@@ -19,8 +19,7 @@ const EditorWrapper = styled.div`
display: flex; display: flex;
flex: 2 1 auto; flex: 2 1 auto;
justify-content: left; justify-content: left;
opacity: ${props => (props.editable ? 1 : 0.4)}; display: ${props => (props.testMode ? 'none' : 'block')};
cursor: ${props => (props.editable ? 'default' : 'not-allowed')};
.ProseMirror { .ProseMirror {
white-space: break-spaces; white-space: break-spaces;
...@@ -55,6 +54,10 @@ const EssayPromptComponent = ({ node, view, getPos }) => { ...@@ -55,6 +54,10 @@ const EssayPromptComponent = ({ node, view, getPos }) => {
let essayPromptView; let essayPromptView;
const questionId = node.attrs.id; const questionId = node.attrs.id;
const isEditable = main.props.editable(editable => {
return editable;
});
const customProps = main.props.customValues; const customProps = main.props.customValues;
const { testMode } = customProps; const { testMode } = customProps;
...@@ -111,7 +114,7 @@ const EssayPromptComponent = ({ node, view, getPos }) => { ...@@ -111,7 +114,7 @@ const EssayPromptComponent = ({ node, view, getPos }) => {
}; };
finalPlugins = finalPlugins.concat([ finalPlugins = finalPlugins.concat([
createPlaceholder('Type your essay prompt'), createPlaceholder('Type your essay sample answer'),
...plugins, ...plugins,
]); ]);
...@@ -121,7 +124,7 @@ const EssayPromptComponent = ({ node, view, getPos }) => { ...@@ -121,7 +124,7 @@ const EssayPromptComponent = ({ node, view, getPos }) => {
mount: editorRef.current, mount: editorRef.current,
}, },
{ {
editable: () => testMode, editable: () => isEditable,
state: EditorState.create({ state: EditorState.create({
doc: node, doc: node,
plugins: finalPlugins, plugins: finalPlugins,
...@@ -191,7 +194,7 @@ const EssayPromptComponent = ({ node, view, getPos }) => { ...@@ -191,7 +194,7 @@ const EssayPromptComponent = ({ node, view, getPos }) => {
}; };
return ( return (
<EditorWrapper editable={testMode}> <EditorWrapper testMode={testMode}>
<div ref={editorRef} /> <div ref={editorRef} />
</EditorWrapper> </EditorWrapper>
); );
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment