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
63377c01
Commit
63377c01
authored
1 year ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
fix delete gap
parent
cf695227
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wax-prosemirror-services/src/FillTheGapQuestionService/components/FillTheGapContainerComponent.js
+34
-9
34 additions, 9 deletions
...uestionService/components/FillTheGapContainerComponent.js
with
34 additions
and
9 deletions
wax-prosemirror-services/src/FillTheGapQuestionService/components/FillTheGapContainerComponent.js
+
34
−
9
View file @
63377c01
import
React
,
{
useContext
,
useRef
,
useState
}
from
'
react
'
;
import
{
WaxContext
,
ComponentPlugin
,
Icon
}
from
'
wax-prosemirror-core
'
;
import
{
th
}
from
'
@pubsweet/ui-toolkit
'
;
import
styled
from
'
styled-components
'
;
import
ContainerEditor
from
'
./ContainerEditor
'
;
import
FeedbackComponent
from
'
../../MultipleChoiceQuestionService/components/FeedbackComponent
'
;
...
...
@@ -37,15 +39,15 @@ const StyledIconAction = styled(Icon)`
`
;
const
InfoMsg
=
styled
.
div
`
background:
#535e76
;
background:
${
th
(
'
colorPrimary
'
)}
;
border-radius: 4px;
bottom: 3
0
px;
bottom: 3
2
px;
color: #fff;
display: none;
left: 100px;
padding-left: 4px;
padding-right: 4px;
float: right;
padding: 4px;
position: relative;
left: 60px;
`
;
const
ActionButton
=
styled
.
button
`
...
...
@@ -94,7 +96,17 @@ export default ({ node, view, getPos }) => {
setInfoMsgIsOpen
(
!
infoMsgIsOpen
);
};
const
removeQuestion
=
()
=>
{};
const
removeQuestion
=
()
=>
{
const
nodeFound
=
findNodes
(
context
.
pmViews
.
main
.
state
,
getPos
(),
node
);
if
(
nodeFound
)
{
context
.
pmViews
.
main
.
dispatch
(
context
.
pmViews
.
main
.
state
.
tr
.
delete
(
getPos
(),
getPos
()
+
nodeFound
.
nodeSize
,
),
);
}
};
return
(
<
FillTheGapWrapper
>
...
...
@@ -111,9 +123,6 @@ export default ({ node, view, getPos }) => {
>
<
StyledIconAction
name
=
"
help
"
/>
<
/StyledIconContainer
>
<
InfoMsg
ref
=
{
infoMsgRef
}
>
enter
answers
seperated
with
a
semi
colon
<
/InfoMsg
>
<
ActionButton
aria
-
label
=
"
delete this question
"
onClick
=
{
removeQuestion
}
...
...
@@ -121,6 +130,9 @@ export default ({ node, view, getPos }) => {
>
<
StyledIconActionRemove
name
=
"
deleteOutlinedQuestion
"
/>
<
/ActionButton
>
<
InfoMsg
ref
=
{
infoMsgRef
}
>
enter
answers
seperated
with
a
semi
colon
<
/InfoMsg
>
<
/FillTheGapContainerTool
>
)}
<
/div
>
...
...
@@ -139,3 +151,16 @@ export default ({ node, view, getPos }) => {
<
/FillTheGapWrapper
>
);
};
const
findNodes
=
(
state
,
pos
,
fillTheGapNode
)
=>
{
let
nodeFound
=
''
;
state
.
doc
.
nodesBetween
(
pos
,
pos
+
2
,
(
node
,
from
)
=>
{
if
(
node
.
type
.
name
===
'
fill_the_gap_container
'
&&
node
.
attrs
.
id
===
fillTheGapNode
.
attrs
.
id
)
{
nodeFound
=
node
;
}
});
return
nodeFound
;
};
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