Skip to content
Snippets Groups Projects
Commit 1af262f3 authored by Deleephan K S's avatar Deleephan K S Committed by chris
Browse files

fix(custom-tag-block): fixed custom-tag-block

parent 98b022a2
No related branches found
No related tags found
1 merge request!232feat(custom-tag-block): added custom-tag-block
...@@ -51,19 +51,19 @@ const StyledButton = styled.div``; ...@@ -51,19 +51,19 @@ const StyledButton = styled.div``;
const CustomTagBlockComponent = (isIconClicked, item) => { const CustomTagBlockComponent = props => {
const { isShowTag, item } = props;
const ref = useRef(); const ref = useRef();
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const [tagName, setTagName] = useState(''); const [tagName, setTagName] = useState('');
const localTagList = JSON.parse(localStorage.getItem('tagBlockList')); const localTagList = JSON.parse(localStorage.getItem('tagBlockList'));
const { app, view: { main }, activeView } = useContext(WaxContext); const { app, view: { main }, activeView, activeViewId } = useContext(WaxContext);
const { state, dispatch } = main; const { state, dispatch } = main;
const { selection: { $from, $to } } = state; const { selection: { $from, $to } } = state;
const serviceConfig = app.config.get('config.CustomTagService'); const serviceConfig = app.config.get('config.CustomTagService');
const [serviceList, setServiceList] = useState([]); const [serviceList, setServiceList] = useState([]);
const onChangeTagName = (e) => { const onChangeTagName = (e) => {
setTagName(e.target.value) setTagName(e.target.value)
setInputValue(e.target.value) setInputValue(e.target.value)
...@@ -86,12 +86,7 @@ const CustomTagBlockComponent = (isIconClicked, item) => { ...@@ -86,12 +86,7 @@ const CustomTagBlockComponent = (isIconClicked, item) => {
const onSelectTag = (e, val) => { const onSelectTag = (e, val) => {
val = val.replace(/ /g, "-"); val = val.replace(/ /g, "-");
item.run(state, dispatch, val);
Commands.setBlockType(state.config.schema.nodes.customTagBlock, {
class: 'custom-tag-block ' + val
})(state, dispatch);
} }
useDeepCompareEffect(() => { useDeepCompareEffect(() => {
...@@ -115,7 +110,7 @@ const CustomTagBlockComponent = (isIconClicked, item) => { ...@@ -115,7 +110,7 @@ const CustomTagBlockComponent = (isIconClicked, item) => {
return useMemo( return useMemo(
() => ( () => (
<Wrapper> <Wrapper>
{isIconClicked.isShowTag === true && <FlexDiv> {isShowTag === true && <FlexDiv>
<Input <Input
ref={ref} ref={ref}
type="text" type="text"
......
...@@ -66,7 +66,6 @@ const BlockElementGroup = props => { ...@@ -66,7 +66,6 @@ const BlockElementGroup = props => {
setIconClicked(isIconClicked === true ? false : true); setIconClicked(isIconClicked === true ? false : true);
} }
return ( return (
<Wrapper> <Wrapper>
{groupName !== "Custom Block" && <> {groupName !== "Custom Block" && <>
...@@ -87,7 +86,7 @@ const BlockElementGroup = props => { ...@@ -87,7 +86,7 @@ const BlockElementGroup = props => {
</div> </div>
</FlexDiv> </FlexDiv>
<ListWrapper> <ListWrapper>
<CustomTagBlockComponent isShowTag={isIconClicked} view={view} /> <CustomTagBlockComponent isShowTag={isIconClicked} view={view} item={items[0]} />
</ListWrapper> </ListWrapper>
</>} </>}
......
import React from 'react'; import React from 'react';
// eslint-disable-next-line import/no-named-as-default,import/no-named-as-default-member // eslint-disable-next-line import/no-named-as-default,import/no-named-as-default-member
import Tools from '../../lib/Tools'; import Tools from '../../lib/Tools';
import { Commands } from 'wax-prosemirror-utilities';
class CustomTagBlockTool extends Tools { class CustomTagBlockTool extends Tools {
title = 'Custom Tag Block'; title = 'Custom Tag Block';
name = 'CustomTagBlock'; name = 'CustomTagBlock';
get run() {
return (state, dispatch, val) => {
Commands.setBlockType(state.config.schema.nodes.customTagBlock, {
class: 'custom-tag-block ' + val
})(state, dispatch);
};
}
get active() { get active() {
return state => { return state => {
return Commands.blockActive(state.config.schema.nodes.customTagBlock)( return Commands.blockActive(state.config.schema.nodes.customTagBlock)(state);
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