mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
fixing hash tag issue
This commit is contained in:
parent
8fd1f6e0a6
commit
60427cb3d7
1169
dependency-graph.svg
1169
dependency-graph.svg
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 100 KiB |
@ -49,8 +49,8 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
|
|||||||
setSpinner(true);
|
setSpinner(true);
|
||||||
|
|
||||||
formItem.text.toLocaleLowerCase().match(hashTagRegex)?.map(tag=> {
|
formItem.text.toLocaleLowerCase().match(hashTagRegex)?.map(tag=> {
|
||||||
if (!tags.find((t) => t.id === tag.slice(1))) {
|
if (!tags.find((t) => t.id.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) {
|
||||||
addTag({id: tag.slice(1), color: randomColor()})
|
addTag({id: tag.slice(1).toLocaleLowerCase(), color: randomColor()})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -12,29 +12,11 @@ import { useEffect, useRef } from 'react';
|
|||||||
export const TextView = ({ item }: { item?: Item }) => {
|
export const TextView = ({ item }: { item?: Item }) => {
|
||||||
const tags = useTags();
|
const tags = useTags();
|
||||||
const addTag = useAddTag();
|
const addTag = useAddTag();
|
||||||
|
|
||||||
const groupRef = useRef(null);
|
|
||||||
|
|
||||||
const addFilterTag = useAddFilterTag();
|
const addFilterTag = useAddFilterTag();
|
||||||
|
|
||||||
const map = useMap();
|
|
||||||
|
|
||||||
let replacedText;
|
let replacedText;
|
||||||
|
|
||||||
|
|
||||||
// use init-Ref to prevent react18 from calling useEffect twice
|
|
||||||
const init = useRef(false)
|
|
||||||
useEffect(() => {
|
|
||||||
if (!init.current) {
|
|
||||||
item?.text.toLocaleLowerCase().match(hashTagRegex)?.map(tag=> {
|
|
||||||
if (!tags.find((t) => t.id === tag.slice(1))) {
|
|
||||||
addTag({id: tag.slice(1), color: randomColor()})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
init.current = true;
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (item && item.text) replacedText = fixUrls(item.text);
|
if (item && item.text) replacedText = fixUrls(item.text);
|
||||||
|
|||||||
@ -30,11 +30,11 @@ function useTagsManager(initialTags: Tag[]): {
|
|||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case "ADD":
|
case "ADD":
|
||||||
const exist = state.find((tag) =>
|
const exist = state.find((tag) =>
|
||||||
tag.id === action.tag.id ? true : false
|
tag.id.toLocaleLowerCase() === action.tag.id.toLocaleLowerCase() ? true : false
|
||||||
);
|
);
|
||||||
if (!exist) return [
|
if (!exist) return [
|
||||||
...state,
|
...state,
|
||||||
{...action.tag, id: action.tag.id}
|
{...action.tag, id: action.tag.id.toLocaleLowerCase()}
|
||||||
];
|
];
|
||||||
else return state;
|
else return state;
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ function useTagsManager(initialTags: Tag[]): {
|
|||||||
tag,
|
tag,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!tags.some((t) => t.id === tag.id)) {
|
if (!tags.some((t) => t.id.toLocaleLowerCase() === tag.id.toLocaleLowerCase())) {
|
||||||
api?.createItem && api.createItem(tag);
|
api?.createItem && api.createItem(tag);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user