Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3e661439f | ||
|
|
ea2ff76fab | ||
|
|
8b38ade1b9 | ||
|
|
944ecff9ce |
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-autocomplete-plus"
|
||||
description = "Autocomplete and Related Tag display for ComfyUI"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = ["",]
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@ import {
|
||||
getEnabledTagSourceInPriorityOrder
|
||||
} from './data.js';
|
||||
import {
|
||||
formatCountHumanReadable,
|
||||
isLongText,
|
||||
hiraToKata,
|
||||
kataToHira,
|
||||
formatCountHumanReadable,
|
||||
isContainsLetterOrNumber,
|
||||
normalizeTagToInsert,
|
||||
normalizeTagToSearch,
|
||||
@@ -82,8 +83,10 @@ function searchCompletionCandidates(textareaElement) {
|
||||
|
||||
const ESCAPE_SEQUENCE = ["#", "/"]; // If the first string is that character, autocomplete will not be displayed.
|
||||
const partialTag = getCurrentPartialTag(textareaElement);
|
||||
if (!partialTag || partialTag.length <= 0 || ESCAPE_SEQUENCE.some(seq => partialTag.startsWith(seq))) {
|
||||
return []; // No valid input for autocomplete
|
||||
if (!partialTag || partialTag.length <= 0 ||
|
||||
ESCAPE_SEQUENCE.some(seq => partialTag.startsWith(seq)) ||
|
||||
isLongText(partialTag)) {
|
||||
return []; // No valid input for autocomplete
|
||||
}
|
||||
|
||||
const exactMatches = [];
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
import { settingValues } from "./settings.js";
|
||||
import { settingValues, updateMaxTagLength } from "./settings.js";
|
||||
|
||||
// --- Constants ---
|
||||
|
||||
@@ -158,6 +158,8 @@ async function loadTags(csvUrl, siteName) {
|
||||
// Create a TagData instance instead of a plain object
|
||||
const tagData = new TagData(tag, aliases, category, count, siteName);
|
||||
|
||||
updateMaxTagLength(tag.length);
|
||||
|
||||
autoCompleteData[siteName].sortedTags.push(tagData);
|
||||
} else {
|
||||
console.warn(`[Autocomplete-Plus] Invalid CSV format in line ${i + 1} of ${csvUrl}: ${line}. Expected ${TAGS_CSV_HEADER_COLUMNS.length} columns, but got ${columns.length}.`);
|
||||
@@ -326,7 +328,6 @@ export async function initializeData(csvListData, source) {
|
||||
|
||||
const startTime = performance.now();
|
||||
autoCompleteData[source].isInitializing = true;
|
||||
// console.log("[Autocomplete-Plus] Initializing autocomplete data...");
|
||||
|
||||
try {
|
||||
// Store functions that return Promises (Promise Factories)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { TagSource, TagCategory, TagData, autoCompleteData } from './data.js';
|
||||
import { TagCategory, TagData, TagSource, autoCompleteData } from './data.js';
|
||||
import { settingValues } from './settings.js';
|
||||
import {
|
||||
extractTagsFromTextArea,
|
||||
findAllTagPositions,
|
||||
getCurrentTagRange,
|
||||
getViewportMargin,
|
||||
isLongText,
|
||||
isValidTag,
|
||||
normalizeTagToInsert,
|
||||
normalizeTagToSearch,
|
||||
getCurrentTagRange,
|
||||
} from './utils.js';
|
||||
|
||||
// --- RelatedTags Logic ---
|
||||
@@ -309,7 +310,7 @@ class RelatedTagsUI {
|
||||
const currentTag = getTagFromCursorPosition(textareaElement);
|
||||
|
||||
if (!this.isPinned) {
|
||||
if (isValidTag(currentTag)) {
|
||||
if (!isLongText(currentTag) && isValidTag(currentTag)) {
|
||||
this.currentTag = currentTag
|
||||
} else {
|
||||
this.hide();
|
||||
|
||||
+12
-1
@@ -17,8 +17,19 @@ export const settingValues = {
|
||||
|
||||
// Internal logic settings
|
||||
_useFallbackAttachmentForEventListener: false, // Fallback to attach event listener when somthing goes wrong
|
||||
_maxTagLength: 100, // Maximum tag length to prevent performance issues with long text input
|
||||
|
||||
// Debugging settings (use internally)
|
||||
_hideWhenOutofFocus: true, // Hide UI when the input is out of focus
|
||||
_logprocessingTime: false, // Log processing time for debugging
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the maximum tag length setting value.
|
||||
* This function ensures that the maximum tag length is always at least as long as the new length provided.
|
||||
* @param {number} newLength
|
||||
*/
|
||||
export function updateMaxTagLength(newLength) {
|
||||
if(isNaN(newLength)) return;
|
||||
settingValues._maxTagLength = Math.max(settingValues._maxTagLength, newLength);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { settingValues } from './settings.js';
|
||||
|
||||
// --- Html String constants ---
|
||||
|
||||
/**
|
||||
@@ -44,6 +46,15 @@ const REG_STRIP_TRAILING_PAREN = /(.*)(?<!\\)\)$/s;
|
||||
const REG_WILDCARD_WEIGHTED_TAG = /(\d+)[_\s]*::(.*?)(?=\||$)/g;
|
||||
const REG_WILDCARD_SIMPLE_WORD = /[^{}_|]+/g;
|
||||
|
||||
/**
|
||||
* Checks if the input text is longer than the maximum allowed tag length.
|
||||
* @param {string} text The text to check.
|
||||
* @return {boolean} True if the text is longer than the maximum tag length, false otherwise.
|
||||
*/
|
||||
export function isLongText(text) {
|
||||
return text?.length > settingValues._maxTagLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Hiragana to Katakana.
|
||||
* @param {string} str Input string.
|
||||
|
||||
Reference in New Issue
Block a user