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
74678e8f
Commit
74678e8f
authored
2 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
add drop down icon
parent
6afe8fbd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!458
Hhmi accessibility
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wax-prosemirror-core/src/components/icons/icons.js
+6
-0
6 additions, 0 deletions
wax-prosemirror-core/src/components/icons/icons.js
wax-prosemirror-services/src/TablesService/components/TableDropDown.js
+29
-39
29 additions, 39 deletions
...or-services/src/TablesService/components/TableDropDown.js
with
35 additions
and
39 deletions
wax-prosemirror-core/src/components/icons/icons.js
+
6
−
0
View file @
74678e8f
...
...
@@ -484,4 +484,10 @@ export default {
<
path
d
=
"
M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2M18 11H13L14.81 9.19A3.94 3.94 0 0 0 12 8A4 4 0 1 0 15.86 13H17.91A6 6 0 1 1 12 6A5.91 5.91 0 0 1 16.22 7.78L18 6Z
"
/>
{
'
'
}
<
/Svg
>
),
expand
:
({
className
})
=>
(
<
Svg
className
=
{
className
}
fill
=
"
none
"
viewBox
=
"
0 0 24 24
"
>
<
title
>
Expand
<
/title
>
<
path
d
=
"
M7 10l5 5 5-5z
"
/>
{
'
'
}
<
/Svg
>
),
};
This diff is collapsed.
Click to expand it.
wax-prosemirror-services/src/TablesService/components/TableDropDown.js
+
29
−
39
View file @
74678e8f
/* eslint-disable react/jsx-props-no-spreading */
/* eslint react/prop-types: 0 */
import
React
,
{
useMemo
,
useContext
,
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useMemo
,
useContext
,
useState
,
useEffect
,
useRef
,
createRef
,
}
from
'
react
'
;
import
styled
from
'
styled-components
'
;
import
*
as
tablesFn
from
'
prosemirror-tables
'
;
import
{
WaxContext
}
from
'
wax-prosemirror-core
'
;
import
{
WaxContext
,
Icon
}
from
'
wax-prosemirror-core
'
;
const
Wrapper
=
styled
.
div
`
opacity:
${
props
=>
(
props
.
disabled
?
'
0.4
'
:
'
1
'
)}
;
...
...
@@ -14,9 +21,15 @@ const DropDownButton = styled.button`
background: #fff;
border: none;
color: #000;
cursor: pointer;
display: flex;
position: relative;
width: 160px;
span {
position: relative;
top: 2px;
}
`
;
const
DropDownMenu
=
styled
.
div
`
...
...
@@ -26,7 +39,7 @@ const DropDownMenu = styled.div`
border: 1px solid #ddd;
border-radius: 0.25rem;
box-shadow: 0 0.2rem 0.4rem rgb(0 0 0 / 10%);
margin:
0.8rem
auto auto;
margin:
10px
auto auto;
position: fixed;
width: 170px;
z-index: 2;
...
...
@@ -42,6 +55,12 @@ const DropDownMenu = styled.div`
}
`
;
const
StyledIcon
=
styled
(
Icon
)
`
height: 18px;
width: 18px;
margin-left: auto;
`
;
const
TableDropDown
=
({
item
})
=>
{
const
dropDownOptions
=
[
{
label
:
'
Add column before
'
,
value
:
'
addColumnBefore
'
},
...
...
@@ -59,16 +78,16 @@ const TableDropDown = ({ item }) => {
];
const
{
activeView
}
=
useContext
(
WaxContext
);
const
[
selectedOption
,
setSelectedOption
]
=
useState
(
''
);
const
itemRefs
=
React
.
useRef
([]);
const
itemRefs
=
useRef
([]);
const
[
isOpen
,
setIsOpen
]
=
useState
(
false
);
const
isDisabled
=
!
item
.
select
(
activeView
.
state
);
useEffect
(()
=>
{},
[
selectedOption
]);
useEffect
(()
=>
{
if
(
isDisabled
)
setIsOpen
(
false
);
},
[
isDisabled
]);
const
openCloseMenu
=
e
=>
{
// e.preventDefault();
if
(
!
isDisabled
)
setIsOpen
(
!
isOpen
);
};
...
...
@@ -117,15 +136,14 @@ const TableDropDown = ({ item }) => {
tabIndex
=
"
0
"
type
=
"
button
"
>
Table
Options
<
span
>
Table
Options
<
/span> <StyledIcon name="expand" /
>
<
/DropDownButton
>
<
DropDownMenu
role
=
"
menu
"
style
=
{{
visibility
:
isOpen
?
'
visible
'
:
'
hidden
'
}}
>
{
dropDownOptions
.
map
((
option
,
index
)
=>
{
itemRefs
.
current
[
index
]
=
itemRefs
.
current
[
index
]
||
React
.
createRef
();
itemRefs
.
current
[
index
]
=
itemRefs
.
current
[
index
]
||
createRef
();
return
(
<
span
key
=
{
option
.
value
}
...
...
@@ -135,7 +153,6 @@ const TableDropDown = ({ item }) => {
activeView
.
dispatch
,
tablesFn
[
option
.
value
],
);
setSelectedOption
(
option
.
value
);
setTimeout
(()
=>
{
activeView
.
focus
();
...
...
@@ -154,37 +171,10 @@ const TableDropDown = ({ item }) => {
<
/DropDownMenu
>
<
/Wrapper
>
),
[
isDisabled
,
isOpen
,
selectedOption
],
[
isDisabled
,
isOpen
],
);
return
TableDropDownComponent
;
// const TableDropDownComponent = useMemo(
// () => (
// <Wrapper>
// <DropdownStyled
// onChange={option => {
// item.run(
// activeView.state,
// activeView.dispatch,
// tablesFn[option.value],
// );
// setSelectedOption(option.value);
// setTimeout(() => {
// activeView.focus();
// });
// }}
// options={appliedDropDownOptions}
// placeholder="Table Options"
// select={isDisabled}
// />
// </Wrapper>
// ),
// [isDisabled, selectedOption, appliedDropDownOptions],
// );
// return TableDropDownComponent;
};
export
default
TableDropDown
;
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