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

add into array

parent 59cd0d84
No related branches found
No related tags found
1 merge request!232feat(custom-tag-block): added custom-tag-block
...@@ -97,7 +97,7 @@ const CustomTagBlockComponent = ({ isShowTag, item }) => { ...@@ -97,7 +97,7 @@ const CustomTagBlockComponent = ({ isShowTag, item }) => {
useEffect(() => { useEffect(() => {
if (ref.current) ref.current.focus(); if (ref.current) ref.current.focus();
}, [isShowTag, allTags]); }, [isShowTag]);
const onChangeTagName = () => { const onChangeTagName = () => {
setInputValue(ref.current.value); setInputValue(ref.current.value);
...@@ -164,7 +164,7 @@ const CustomTagBlockComponent = ({ isShowTag, item }) => { ...@@ -164,7 +164,7 @@ const CustomTagBlockComponent = ({ isShowTag, item }) => {
{renderTagList()} {renderTagList()}
</> </>
), ),
[isShowTag, inputValue, tagStatus, isDisabled, allTags], [isShowTag, inputValue, tagStatus, isDisabled],
); );
}; };
......
...@@ -176,22 +176,24 @@ const CustomTagInlineOverlayComponent = ({ mark, setPosition, position }) => { ...@@ -176,22 +176,24 @@ const CustomTagInlineOverlayComponent = ({ mark, setPosition, position }) => {
<ItemWrapper onClick={() => onClickAddToSelection(item.label)}> <ItemWrapper onClick={() => onClickAddToSelection(item.label)}>
{item.label} {item.label}
</ItemWrapper> </ItemWrapper>
{console.log(mark)}
{selectedTagNames.map(value => ( {/* {selectedTagNames.map(value => {
<Fragment key={uuidv4()}> return (
{value === item.label ? ( <Fragment key={uuidv4()}>
<span {value === item.label ? (
aria-hidden="true" <span
onClick={() => onClickCancel(item.label)} aria-hidden="true"
role="button" onClick={() => onClickCancel(item.label)}
> role="button"
<IconRemove name="removeTag" /> >
</span> <IconRemove name="removeTag" />
) : ( </span>
'' ) : (
)} ''
</Fragment> )}
))} </Fragment>
);
})} */}
</Flex> </Flex>
</ListStyle> </ListStyle>
))} ))}
......
const customtagBlock = {
excludes: 'customBlock',
attrs: {
class: { default: null },
tagName: ''
},
inclusive: false,
parseDOM: [
{
tag: 'custom-tag-block',
getAttrs(hook, next) {
Object.assign(hook, {
class: hook.dom.getAttribute('class'),
tagname: hook.dom.getAttribute('tagName')
});
next();
},
},
],
toDOM(hook, next) {
hook.value = ['custom-tag-block', hook.node.attrs, 0]; // eslint-disable-line no-param-reassign
next();
},
};
export default customtagBlock;
\ No newline at end of file
...@@ -10,14 +10,21 @@ const customtagInline = { ...@@ -10,14 +10,21 @@ const customtagInline = {
getAttrs(hook, next) { getAttrs(hook, next) {
Object.assign(hook, { Object.assign(hook, {
class: hook.dom.getAttribute('class'), class: hook.dom.getAttribute('class'),
tagNames: hook.dom.getAttribute('tagNames'), tagNames: JSON.parse(hook.dom.dataset.tagNames),
}); });
next(); next();
}, },
}, },
], ],
toDOM(hook, next) { toDOM(hook, next) {
hook.value = ['custom-tag-inline', hook.node.attrs, 0]; // eslint-disable-line no-param-reassign // eslint-disable-next-line no-param-reassign
hook.value = [
'custom-tag-inline',
{
class: hook.node.attrs.class,
'data-tagNames': JSON.stringify(hook.node.attrs.tagNames),
},
];
next(); next();
}, },
}; };
......
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