{"id":28297220,"url":"https://github.com/deepansumor/tagitjs","last_synced_at":"2026-05-04T14:44:06.679Z","repository":{"id":278913399,"uuid":"937116293","full_name":"deepansumor/TagItJS","owner":"deepansumor","description":"TagIt.js is a lightweight JavaScript library that provides real-time, configurable tag suggestion functionality for both contentEditable elements and input/textarea fields. It supports custom triggers, async data loading with debouncing, middleware, and dynamic suggestion management.","archived":false,"fork":false,"pushed_at":"2025-02-22T14:17:41.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T16:43:36.923Z","etag":null,"topics":["async","autcomplete","autocomplete","contenteditable","frontend","javascript","tag-suggestion","web-development"],"latest_commit_sha":null,"homepage":"https://deepansumor.github.io/TagItJS/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepansumor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T11:26:55.000Z","updated_at":"2025-02-22T13:28:03.000Z","dependencies_parsed_at":"2025-02-22T14:29:58.800Z","dependency_job_id":"30d421c1-9f7c-44b1-afec-61f31a2f4986","html_url":"https://github.com/deepansumor/TagItJS","commit_stats":null,"previous_names":["deepansumor/tagitjs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deepansumor/TagItJS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepansumor%2FTagItJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepansumor%2FTagItJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepansumor%2FTagItJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepansumor%2FTagItJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepansumor","download_url":"https://codeload.github.com/deepansumor/TagItJS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepansumor%2FTagItJS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32612318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","autcomplete","autocomplete","contenteditable","frontend","javascript","tag-suggestion","web-development"],"created_at":"2025-05-23T01:18:09.838Z","updated_at":"2026-05-04T14:44:06.674Z","avatar_url":"https://github.com/deepansumor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# TagIt.js\n\nTagIt.js is a robust JavaScript library for managing tag suggestions in contentEditable elements as well as input/textarea fields. It supports configurable trigger characters, middleware for filtering or transforming suggestions, asynchronous suggestion fetching with debouncing, real-time suggestion management, and scoring-based suggestion sorting.\n\n## Features\n\n- **Configurable Trigger**: Set your own trigger character (default is `@`).\n- **Middleware Support**: Easily filter or transform suggestions.\n- **Async Data Loading**: Fetch suggestions asynchronously with debouncing.\n- **Real-Time Updates**: Add or remove suggestions dynamically.\n- **Scoring \u0026 Sorting**: Suggestions are scored and sorted based on match quality.\n- **Dual Compatibility**: Works seamlessly with both contentEditable elements and input/textarea fields.\n- **Verbose Logging**: Enable logging for debugging.\n\n## Installation\n\nYou can install TagIt.js include the bundled JavaScript via a CDN or local.\n\n\nOr include via a `\u003cscript\u003e` tag:\n\n\n```html\n\u003cscript src=\"../dist/tagIt.min.js\"\u003e\u003c/script\u003e\n```\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/deepansumor/TagItJS@latest/dist/tagIt.min.js\"\u003e\u003c/script\u003e\n```\n\n\n## Usage\n\n### Basic Example with ContentEditable\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003ctitle\u003eTagIt.js Demo - ContentEditable\u003c/title\u003e\n  \u003cstyle\u003e\n    #editor {\n      border: 1px solid #ccc;\n      padding: 10px;\n      min-height: 150px;\n      background: #fff;\n    }\n  \u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1\u003eTagIt.js - ContentEditable Example\u003c/h1\u003e\n  \u003cdiv id=\"editor\" contenteditable=\"true\"\u003eType '#' here...\u003c/div\u003e\n\n  \u003c!-- Include TagIt.js --\u003e\n  \u003cscript src=\"../dist/tagIt.js\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n    // Convert suggestion strings into suggestion objects.\n    var suggestions = ['Alice', 'Bob', 'Charlie', 'David', 'Eve'].map(function(s) {\n      return { display: s, key: s };\n    });\n\n    // Fake async fetch function to simulate a delay.\n    function fakeFetchSuggestions() {\n      return new Promise(function(resolve) {\n        setTimeout(function() {\n          resolve([\n            { display: 'Alice', key: 'Alice' },\n            { display: 'Bob', key: 'Bob' },\n            { display: 'Charlie', key: 'Charlie' },\n            { display: 'David', key: 'David' },\n            { display: 'Eve', key: 'Eve' },\n            { display: 'Mallory', key: 'Mallory' }\n          ]);\n        }, 500);\n      });\n    }\n\n    // Initialize TagIt on the contentEditable element.\n    var editor = document.getElementById('editor');\n    if (editor) {\n      var tagItInstance = new TagIt(editor, {\n        suggestions: suggestions,\n        keepTrigger: true,\n        triggerChar: \"#\",\n        maxSuggestions: 5,\n        minScore: 0.5,\n        debounceTime: 300,\n        enableLog: true,\n        fetchSuggestions: fakeFetchSuggestions\n      });\n\n      // Middleware: Only include suggestions with a key longer than 3 characters.\n      tagItInstance.use(function(suggestions) {\n        return suggestions.filter(function(item) {\n          return item.key.length \u003e 3;\n        });\n      });\n\n      // Example: Add a new suggestion in real-time after 3 seconds.\n      setTimeout(function() {\n        tagItInstance.addSuggestion({ display: 'Zoe', key: 'Zoe' });\n        console.log(\"Added suggestion: Zoe\");\n      }, 3000);\n\n      // Example: Remove a suggestion in real-time after 6 seconds.\n      setTimeout(function() {\n        tagItInstance.removeSuggestion('Bob');\n        console.log(\"Removed suggestion: Bob\");\n      }, 6000);\n    }\n  \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Example with Textarea\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003ctitle\u003eTagIt.js Demo - Textarea\u003c/title\u003e\n  \u003cstyle\u003e\n    #textarea {\n      width: 100%;\n      height: 150px;\n      padding: 10px;\n      border: 1px solid #ccc;\n      background: #fff;\n    }\n  \u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1\u003eTagIt.js - Textarea Example\u003c/h1\u003e\n  \u003ctextarea id=\"textarea\" placeholder=\"Type '#' here...\"\u003e\u003c/textarea\u003e\n\n  \u003c!-- Include TagIt.js --\u003e\n  \u003cscript src=\"../dist/tagIt.js\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n    var suggestions = ['Alice', 'Bob', 'Charlie', 'David', 'Eve'].map(function(s) {\n      return { display: s, key: s };\n    });\n\n    // Fake async fetch function.\n    function fakeFetchSuggestions() {\n      return new Promise(function(resolve) {\n        setTimeout(function() {\n          resolve([\n            { display: 'Alice', key: 'Alice' },\n            { display: 'Bob', key: 'Bob' },\n            { display: 'Charlie', key: 'Charlie' },\n            { display: 'David', key: 'David' },\n            { display: 'Eve', key: 'Eve' },\n            { display: 'Mallory', key: 'Mallory' }\n          ]);\n        }, 500);\n      });\n    }\n\n    // Initialize TagIt on the textarea.\n    var textarea = document.getElementById('textarea');\n    if (textarea) {\n      new TagIt(textarea, {\n        suggestions: suggestions,\n        maxSuggestions: 5,\n        debounceTime: 300,\n        enableLog: true,\n        fetchSuggestions: fakeFetchSuggestions\n      });\n    }\n  \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Configuration Options\n\n| Option            | Type                              | Default | Description                                                      |\n|-------------------|-----------------------------------|---------|------------------------------------------------------------------|\n| suggestions       | SuggestionItem[]                  | `[]`    | Initial array of suggestion objects.                           |\n| keepTrigger       | boolean                           | `false` | Whether to keep the trigger character in the inserted tag.       |\n| triggerChar       | string                            | `'@'`   | The character that triggers the tag suggestion dropdown.         |\n| maxSuggestions    | number                            | `5`     | Maximum number of suggestions to display in the dropdown.        |\n| minScore          | number                            | `0`     | Minimum match score (0–1) for a suggestion to be shown.            |\n| fetchSuggestions  | () =\u003e Promise\u003cSuggestionItem[]\u003e   | `undefined` | Async function for fetching suggestions dynamically.         |\n| debounceTime      | number                            | `300`   | Delay in milliseconds for debouncing async fetch calls.          |\n| enableLog         | boolean                           | `false` | Enable logging for debugging.                                    |\n\n## API\n\n### Methods\n\n- **use(middleware: SuggestionMiddleware): void**  \n  Registers a middleware function to transform or filter suggestions.\n\n- **addSuggestion(suggestion: SuggestionItem): void**  \n  Adds a new suggestion in real-time.\n\n- **removeSuggestion(key: string): void**  \n  Removes a suggestion by its key.\n\n- **destroy(): void**  \n  Cleans up event listeners and removes the dropdown element.\n\n## Contributing\n\nContributions are welcome! Please feel free to open an issue or submit a pull request with improvements or bug fixes.\n\n## License\n\nThis project is licensed under the MIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepansumor%2Ftagitjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepansumor%2Ftagitjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepansumor%2Ftagitjs/lists"}