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
f10c0266
Commit
f10c0266
authored
3 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
set Label
parent
212963d5
No related branches found
No related tags found
1 merge request
!349
Multiple single
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wax-prosemirror-services/src/WaxToolGroups/MultipleDropDownToolGroupService/MultipleDropDown.js
+15
-9
15 additions, 9 deletions
...oups/MultipleDropDownToolGroupService/MultipleDropDown.js
with
15 additions
and
9 deletions
wax-prosemirror-services/src/WaxToolGroups/MultipleDropDownToolGroupService/MultipleDropDown.js
+
15
−
9
View file @
f10c0266
import
React
,
{
useContext
,
useMemo
}
from
'
react
'
;
import
React
,
{
useContext
,
useMemo
,
useEffect
,
useState
}
from
'
react
'
;
import
{
injectable
,
inject
}
from
'
inversify
'
;
import
{
injectable
,
inject
}
from
'
inversify
'
;
import
{
isEmpty
}
from
'
lodash
'
;
import
{
isEmpty
}
from
'
lodash
'
;
import
{
v4
as
uuidv4
}
from
'
uuid
'
;
import
{
v4
as
uuidv4
}
from
'
uuid
'
;
...
@@ -66,9 +66,13 @@ class MultipleDropDown extends ToolGroup {
...
@@ -66,9 +66,13 @@ class MultipleDropDown extends ToolGroup {
const
{
const
{
activeView
,
activeView
,
activeViewId
,
view
:
{
main
},
view
:
{
main
},
}
=
context
;
}
=
context
;
const
{
state
}
=
view
;
const
{
state
}
=
view
;
const
[
label
,
setLabel
]
=
useState
(
null
);
const
dropDownOptions
=
[
const
dropDownOptions
=
[
{
{
label
:
'
Multiple Choice
'
,
label
:
'
Multiple Choice
'
,
...
@@ -92,13 +96,15 @@ class MultipleDropDown extends ToolGroup {
...
@@ -92,13 +96,15 @@ class MultipleDropDown extends ToolGroup {
},
},
];
];
useEffect
(()
=>
{
dropDownOptions
.
forEach
((
option
,
i
)
=>
{
if
(
option
.
item
.
active
(
main
.
state
))
{
setLabel
(
option
.
label
);
}
});
},
[
activeViewId
]);
const
isDisabled
=
this
.
_tools
[
0
].
select
(
state
,
activeView
);
const
isDisabled
=
this
.
_tools
[
0
].
select
(
state
,
activeView
);
let
found
=
''
;
dropDownOptions
.
forEach
((
option
,
i
)
=>
{
if
(
option
.
item
.
active
(
main
.
state
))
{
found
=
option
.
label
;
}
});
const
onChange
=
option
=>
{
const
onChange
=
option
=>
{
this
.
_tools
[
option
.
value
].
run
(
main
,
context
);
this
.
_tools
[
option
.
value
].
run
(
main
,
context
);
...
@@ -108,7 +114,7 @@ class MultipleDropDown extends ToolGroup {
...
@@ -108,7 +114,7 @@ class MultipleDropDown extends ToolGroup {
()
=>
(
()
=>
(
<
Wrapper
key
=
{
uuidv4
()}
>
<
Wrapper
key
=
{
uuidv4
()}
>
<
DropdownStyled
<
DropdownStyled
value
=
{
found
}
value
=
{
label
}
key
=
{
uuidv4
()}
key
=
{
uuidv4
()}
options
=
{
dropDownOptions
}
options
=
{
dropDownOptions
}
onChange
=
{
option
=>
onChange
(
option
)}
onChange
=
{
option
=>
onChange
(
option
)}
...
@@ -117,7 +123,7 @@ class MultipleDropDown extends ToolGroup {
...
@@ -117,7 +123,7 @@ class MultipleDropDown extends ToolGroup {
/
>
/
>
<
/Wrapper
>
<
/Wrapper
>
),
),
[
isDisabled
],
[
isDisabled
,
label
],
);
);
return
MultipleDropDown
;
return
MultipleDropDown
;
...
...
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