Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wax-prosemirror
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wax
wax-prosemirror
Commits
49773000
Commit
49773000
authored
1 year ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
new wrapper component
parent
e26f5989
No related branches found
No related tags found
1 merge request
!526
new wrapper component
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wax-questions-service/src/MultipleChoiceQuestionService/components/MultipleChoiceContainerComponent.js
+109
-0
109 additions, 0 deletions
...ionService/components/MultipleChoiceContainerComponent.js
with
109 additions
and
0 deletions
wax-questions-service/src/MultipleChoiceQuestionService/components/MultipleChoiceContainerComponent.js
0 → 100644
+
109
−
0
View file @
49773000
import
React
,
{
useContext
}
from
'
react
'
;
import
{
WaxContext
,
DocumentHelpers
,
Icon
}
from
'
wax-prosemirror-core
'
;
import
styled
from
'
styled-components
'
;
import
ContainerEditor
from
'
../../FillTheGapQuestionService/components/ContainerEditor
'
;
const
MultipleChoiceQuestionWrapper
=
styled
.
div
`
margin: 0px 38px 15px 38px;
margin-top: 10px;
`
;
const
MultipleChoiceContainerTool
=
styled
.
div
`
border: 3px solid #f5f5f7;
border-bottom: none;
height: 32px;
span:first-of-type {
position: relative;
top: 3px;
}
`
;
const
ActionButton
=
styled
.
button
`
background: transparent;
cursor: pointer;
margin-top: 16px;
border: none;
position: relative;
bottom: 14px;
left: 6px;
float: right;
`
;
const
StyledIconActionRemove
=
styled
(
Icon
)
`
height: 24px;
width: 24px;
`
;
const
MultipleChoiceQuestionContainer
=
styled
.
div
`
border: 3px solid #f5f5f7;
margin-bottom: 30px;
`
;
export
default
({
node
,
view
,
getPos
})
=>
{
const
context
=
useContext
(
WaxContext
);
const
{
pmViews
:
{
main
},
}
=
context
;
const
customProps
=
main
.
props
.
customValues
;
const
{
testMode
}
=
customProps
;
const
isEditable
=
main
.
props
.
editable
(
editable
=>
{
return
editable
;
});
const
readOnly
=
!
isEditable
;
const
removeQuestion
=
()
=>
{
const
allNodes
=
getNodes
(
context
.
pmViews
.
main
);
allNodes
.
forEach
(
singleNode
=>
{
if
(
singleNode
.
node
.
attrs
.
id
===
node
.
attrs
.
id
)
{
context
.
pmViews
.
main
.
dispatch
(
context
.
pmViews
.
main
.
state
.
tr
.
delete
(
singleNode
.
pos
,
singleNode
.
pos
+
singleNode
.
node
.
nodeSize
,
),
);
}
});
};
return
(
<
MultipleChoiceQuestionWrapper
>
<
div
>
{
!
testMode
&&
!
readOnly
&&
(
<
MultipleChoiceContainerTool
>
<
ActionButton
aria
-
label
=
"
delete this question
"
onClick
=
{
removeQuestion
}
type
=
"
button
"
>
<
StyledIconActionRemove
name
=
"
deleteOutlinedQuestion
"
/>
<
/ActionButton
>
<
/MultipleChoiceContainerTool
>
)}
<
/div
>
<
MultipleChoiceQuestionContainer
className
=
"
multiple-choice
"
>
<
ContainerEditor
disallowedTools
=
{[
'
MultipleChoice
'
]}
getPos
=
{
getPos
}
isNotEditable
node
=
{
node
}
view
=
{
view
}
/
>
<
/MultipleChoiceQuestionContainer
>
<
/MultipleChoiceQuestionWrapper
>
);
};
const
getNodes
=
view
=>
{
const
allNodes
=
DocumentHelpers
.
findBlockNodes
(
view
.
state
.
doc
);
const
fillTheGapContainerNodes
=
[];
allNodes
.
forEach
(
node
=>
{
if
(
node
.
node
.
type
.
name
===
'
multiple_choice_container
'
)
{
fillTheGapContainerNodes
.
push
(
node
);
}
});
return
fillTheGapContainerNodes
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment