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

remove unused imports

parent 1a7d0b67
No related branches found
No related tags found
1 merge request!458Hhmi accessibility
......@@ -15,8 +15,6 @@ import {
Icon,
useOnClickOutside,
} from 'wax-prosemirror-core';
import Dropdown from 'react-dropdown';
import { v4 as uuidv4 } from 'uuid';
const Wrapper = styled.div`
opacity: ${props => (props.disabled ? '0.4' : '1')};
......
/* eslint-disable no-underscore-dangle */
import React, { useContext, useMemo, useState } from 'react';
import styled from 'styled-components';
import {
WaxContext,
DocumentHelpers,
ReactDropDownStyles,
} from 'wax-prosemirror-core';
import Dropdown from 'react-dropdown';
import { v4 as uuidv4 } from 'uuid';
const Wrapper = styled.div`
${ReactDropDownStyles};
`;
const DropdownStyled = styled(Dropdown)`
cursor: not-allowed;
display: inline-flex;
margin-left: auto;
opacity: ${props => (props.select ? 1 : 0.4)};
pointer-events: ${props => (props.select ? 'default' : 'none')};
.Dropdown-control {
border: none;
padding: 8px 30px 8px 10px;
&:hover {
box-shadow: none;
}
}
.Dropdown-arrow {
top: 17px;
}
.Dropdown-menu {
align-items: flex-start;
display: flex;
flex-direction: column;
width: 102%;
.Dropdown-option {
width: 100%;
}
}
`;
const DropComponent = ({ getPos, node, view }) => {
const [selectedOption, setSelectedOption] = useState(node.attrs.correct);
const context = useContext(WaxContext);
const {
pmViews: { main },
} = context;
const isEditable = main.props.editable(editable => {
return editable;
});
const onChange = option => {
const allNodes = getNodes(main);
allNodes.forEach(singleNode => {
if (singleNode.node.attrs.id === node.attrs.id) {
main.dispatch(
main.state.tr
.setMeta('addToHistory', false)
.setNodeMarkup(singleNode.pos, undefined, {
...singleNode.node.attrs,
correct: option.value,
}),
);
}
});
};
const MultipleDropDown = useMemo(
() => (
<Wrapper key={uuidv4()}>
<DropdownStyled
key={uuidv4()}
onChange={option => onChange(option)}
options={node.attrs.options}
placeholder="Select option"
select={isEditable}
value={
selectedOption === 'undefined' ? 'Select Option' : selectedOption
}
/>
</Wrapper>
),
[node.attrs.options, selectedOption],
);
return MultipleDropDown;
};
export default DropComponent;
const getNodes = view => {
return DocumentHelpers.findInlineNodes(view.state.doc);
};
/* eslint-disable no-unused-vars */
/* eslint-disable no-underscore-dangle */
import React, { useContext, useMemo, useEffect, useState } from 'react';
import styled from 'styled-components';
......
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