From f4cf72a5b3485227470add1117f167cbd4f2049b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Wed, 11 Mar 2026 12:15:22 +0100 Subject: [PATCH] move duplicategroups to separate file for easier modification --- .../editor/tagInput/curatedTagSuggestionList.js | 11 ++++++++++- client/homebrew/editor/tagInput/tagInput.jsx | 13 ++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/homebrew/editor/tagInput/curatedTagSuggestionList.js b/client/homebrew/editor/tagInput/curatedTagSuggestionList.js index 9b9afce6f..7d692ecb0 100644 --- a/client/homebrew/editor/tagInput/curatedTagSuggestionList.js +++ b/client/homebrew/editor/tagInput/curatedTagSuggestionList.js @@ -1,4 +1,4 @@ -export default [ +export const tagSuggestionList = [ // ############################## Systems // D&D 'system:D&D Original', @@ -208,3 +208,12 @@ export default [ 'SW5e', 'Star Wars 5e', ]; + +// substrings to be normalized to the first value on the array +export const canonizationList = [ + ['5e 2024', '5.5e', '5e\'24', '5.24', '5e24', '5.5'], + ['5e', '5th Edition'], + ['Dungeons & Dragons', 'Dungeons and Dragons', 'Dungeons n dragons'], + ['D&D', 'DnD', 'dnd', 'Dnd', 'dnD', 'd&d', 'd&D', 'D&d'], + ['P2e', 'p2e', 'P2E', 'Pathfinder 2e'], +]; \ No newline at end of file diff --git a/client/homebrew/editor/tagInput/tagInput.jsx b/client/homebrew/editor/tagInput/tagInput.jsx index c875114f5..b43797424 100644 --- a/client/homebrew/editor/tagInput/tagInput.jsx +++ b/client/homebrew/editor/tagInput/tagInput.jsx @@ -2,7 +2,7 @@ import './tagInput.less'; import React, { useState, useEffect } from 'react'; import Combobox from '../../../components/combobox.jsx'; -import tagSuggestionList from './curatedTagSuggestionList.js'; +import { tagSuggestionList, canonizationList } from './curatedTagSuggestionList.js'; const TagInput = ({ tooltip, label, valuePatterns, values = [], unique = true, placeholder = '', smallText = '', onChange })=>{ const [tagList, setTagList] = useState( @@ -35,20 +35,11 @@ const TagInput = ({ tooltip, label, valuePatterns, values = [], unique = true, p }); }, [tagList]); - // substrings to be normalized to the first value on the array - const duplicateGroups = [ - ['5e 2024', '5.5e', '5e\'24', '5.24', '5e24', '5.5'], - ['5e', '5th Edition'], - ['Dungeons & Dragons', 'Dungeons and Dragons', 'Dungeons n dragons'], - ['D&D', 'DnD', 'dnd', 'Dnd', 'dnD', 'd&d', 'd&D', 'D&d'], - ['P2e', 'p2e', 'P2E', 'Pathfinder 2e'], - ]; - const normalizeValue = (input)=>{ const lowerInput = input.toLowerCase(); let normalizedTag = input; - for (const group of duplicateGroups) { + for (const group of canonizationList) { for (const tag of group) { if(!tag) continue;