Skip to content
Snippets Groups Projects
Commit 776efdff authored by chris's avatar chris
Browse files

fixes

parent 3327e00b
No related branches found
No related tags found
1 merge request!232feat(custom-tag-block): added custom-tag-block
......@@ -52,7 +52,7 @@ const ActiveStyles = styled.div`
background: ${th('colorPrimary')};
color: #fff;
cursor: pointer;
font-family: Fira Sans Condensed;
font-family: 'Fira Sans Condensed';
font-size: 14px;
height: 28px;
padding: 2px;
......@@ -64,17 +64,22 @@ const CustomTagBlockComponent = props => {
const [inputValue, setInputValue] = useState('');
const [tagName, setTagName] = useState('');
const localTagList = JSON.parse(localStorage.getItem('tagBlockList'));
const {
app,
view: { main },
activeView,
activeViewId,
} = useContext(WaxContext);
const { state, dispatch } = main;
const { $from } = state.selection;
const type = $from.parent.attrs.class ? $from.parent.attrs.class : '';
const serviceConfig = app.config.get('config.CustomTagService');
const [serviceList, setServiceList] = useState([]);
const isActive = item.active(activeView.state, activeViewId);
const isActive = item.active(activeView.state, activeViewId, type);
console.log(isActive);
const onChangeTagName = e => {
setTagName(e.target.value);
......@@ -118,41 +123,34 @@ const CustomTagBlockComponent = props => {
setServiceList(labels);
}, [localTagList, serviceConfig]);
return useMemo(() => (
<Wrapper>
{isShowTag === true && (
<FlexDiv>
<Input
onChange={e => onChangeTagName(e)}
ref={ref}
type="text"
value={inputValue}
/>
<Add onClick={onClickAdd}>Add</Add>
</FlexDiv>
)}
{serviceList !== null &&
serviceList.map((item, pos) => (
<ListStyle key={uuidv4()}>
{isActive && (
<ActiveStyles>
<FlexDiv onClick={e => onSelectTag(e, item)}>
<Box />
<StyledButton>{item}</StyledButton>
</FlexDiv>
</ActiveStyles>
)}
{!isActive && (
return useMemo(
() => (
<Wrapper>
{isShowTag && (
<FlexDiv>
<Input
onChange={e => onChangeTagName(e)}
ref={ref}
type="text"
value={inputValue}
/>
<Add onClick={onClickAdd}>Add</Add>
</FlexDiv>
)}
{serviceList !== null &&
serviceList.map((item, pos) => (
<ListStyle key={uuidv4()}>
<FlexDiv onClick={e => onSelectTag(e, item)}>
<Box />
<StyledButton>{item}</StyledButton>
</FlexDiv>
)}
</ListStyle>
))}
</Wrapper>
));
</ListStyle>
))}
</Wrapper>
),
[],
);
};
export default CustomTagBlockComponent;
......@@ -14,10 +14,10 @@ class CustomTagBlockTool extends Tools {
}
get active() {
return state => {
return (state, activeViewId, type) => {
return Commands.customTagBlockActive(
state.config.schema.nodes.customTagBlock,
{ class: 'custom-tag-label-3' },
{ class: type },
)(state);
};
}
......
......@@ -57,8 +57,12 @@ const blockActive = (nodeType, attrs = {}) => {
const customTagBlockActive = (type, attrs = {}) => state => {
const { $from } = state.selection;
console.log('type', type);
console.log($from);
if (
$from.parent.attrs.class === attrs.class &&
$from.parent.type.name === 'custom-tag-block'
)
return true;
return false;
};
// const blockActive = (type, attrs = {}) => state => {
......
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