Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65960a2394 | ||
|
|
92f01b84a0 | ||
|
|
3f8eb3bc0c | ||
|
|
fe42e198d2 |
@@ -118,11 +118,28 @@ When the browser is reloaded, you can check the list of loaded CSV files in the
|
||||
>[!NOTE]
|
||||
> If there are multiple user CSV files, they are loaded in alphabetical order. If the same tag exists in multiple files, the one loaded first is retained. The basic CSV is loaded last.
|
||||
|
||||
### Bulk Tag Insertion (Pseudo "Chants")
|
||||
|
||||
By enclosing multiple tags with `""` (double quotation marks), you can insert frequently used tags in bulk.
|
||||
This is similar to the **Chants** feature in [DominikDoom/a1111-sd-webui-tagcomplete](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete?tab=readme-ov-file#chants).
|
||||
|
||||
For example, by preparing the following CSV, you can quickly insert corresponding tags by typing `<c:Basic-HighQuality>` or `<c:Basic-Negative>`.
|
||||
|
||||
**`danbooru_tags_chants.csv`:**
|
||||
```
|
||||
"masterpiece, best quality, high quality, highres, ultra-detailed",5,9999999,<c:Basic-HighQuality>
|
||||
"(worst quality, low quality:1.4), normal quality",5,9999999,<c:Basic-Negative>
|
||||
```
|
||||
|
||||
>[!TIP]
|
||||
> * Text enclosed in `""` does not escape `()` (parentheses). Tags that originally contain parentheses should be written in the CSV with escaped parentheses. Example: `copyright_(series)` -> `copyright_\(series\)`
|
||||
> * The alias column also supports `""`, allowing you to assign multiple aliases
|
||||
|
||||
## Settings
|
||||
|
||||
### Tag Source
|
||||
|
||||
> [!TIP]
|
||||
> [!NOTE]
|
||||
> The source of tag data such as Danbooru or e621 is called the "tag source".
|
||||
|
||||
- **Autocomplete Tag Source**: The tag source to display in the autocomplete suggestions. Select "all" to display all loaded tag sources.
|
||||
|
||||
+18
-1
@@ -116,11 +116,28 @@ worst_quality,5,9999999,
|
||||
>[!NOTE]
|
||||
> ユーザー CSV が複数ある場合アルファベット順に読み込まれます。同じタグが複数のファイルに存在する場合は先に読み込まれた方が保持されます。基本 CSV は最後にロードされます。
|
||||
|
||||
### 複数タグの一括挿入機能(疑似 Chants)
|
||||
|
||||
`""` (ダブルクォーテーション)で複数タグを囲むことで、よく使うタグを一括で挿入できます。
|
||||
これは [DominikDoom/a1111-sd-webui-tagcomplete](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete?tab=readme-ov-file#chants) で **Chants** と呼ばれる機能に似ています。
|
||||
|
||||
例として以下のCSVを用意することで、`<c:Basic-HighQuality>` や `<c:Basic-Negative>` と入力して対応したタグを素早く挿入出来ます。
|
||||
|
||||
**`danbooru_tags_chants.csv`:**
|
||||
```
|
||||
"masterpiece, best quality, high quality, highres, ultra-detailed",5,9999999,<c:Basic-HighQuality>
|
||||
"(worst quality, low quality:1.4), normal quality",5,9999999,<c:Basic-Negative>
|
||||
```
|
||||
|
||||
>[!TIP]
|
||||
> * `""` で囲まれたテキストは `()` (括弧)がエスケープされません。元々括弧が含まれるタグはエスケープした状態でCSVに記述してください。 例: `copyright_(series)` -> `copyright_\(series\)`
|
||||
> * エイリアス列も `""` に対応しているので、複数のエイリアスを付けられます
|
||||
|
||||
## 設定
|
||||
|
||||
### タグソース
|
||||
|
||||
> [!TIP]
|
||||
> [!NOTE]
|
||||
> Danbooruやe621等のタグデータの提供元を「タグソース」と呼びます
|
||||
|
||||
- **Autocomplete Tag Source**: オートコンプリート候補に表示するタグソース。「all」を選択するとロード済みの全てのタグソースを表示します
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-autocomplete-plus"
|
||||
description = "Autocomplete and Related Tag display for ComfyUI"
|
||||
version = "1.6.0"
|
||||
version = "1.6.1"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = ["",]
|
||||
|
||||
|
||||
+24
-9
@@ -196,34 +196,49 @@ describe('normalizeTagToInsert', () => {
|
||||
|
||||
settingValues.replaceUnderscoreWithSpace = false;
|
||||
expect(normalizeTagToInsert('blue_hair(style)')).toBe('blue_hair\\(style\\)');
|
||||
|
||||
settingValues.replaceUnderscoreWithSpace = originalValue;
|
||||
});
|
||||
|
||||
test('should not replace underscores in wildcard syntax regardless of setting', () => {
|
||||
const originalValue = settingValues.replaceUnderscoreWithSpace;
|
||||
|
||||
// Wildcard syntax should preserve underscores regardless of setting
|
||||
settingValues.replaceUnderscoreWithSpace = true;
|
||||
expect(normalizeTagToInsert('__wildcard__')).toBe('__wildcard__');
|
||||
|
||||
settingValues.replaceUnderscoreWithSpace = false;
|
||||
expect(normalizeTagToInsert('__wildcard__')).toBe('__wildcard__');
|
||||
|
||||
settingValues.replaceUnderscoreWithSpace = originalValue;
|
||||
});
|
||||
|
||||
test('should not replace underscores in symbol-only tags regardless of setting', () => {
|
||||
const originalValue = settingValues.replaceUnderscoreWithSpace;
|
||||
|
||||
// Symbol-only tags should not be affected by the setting
|
||||
settingValues.replaceUnderscoreWithSpace = true;
|
||||
expect(normalizeTagToInsert('^_^')).toBe('^_^');
|
||||
|
||||
settingValues.replaceUnderscoreWithSpace = false;
|
||||
expect(normalizeTagToInsert('^_^')).toBe('^_^');
|
||||
});
|
||||
|
||||
settingValues.replaceUnderscoreWithSpace = originalValue;
|
||||
test('should not escape parentheses when tag contains commas (multi-tags)', () => {
|
||||
const multiTag = 'masterpiece, best quality, (high quality), ultra-detailed';
|
||||
expect(normalizeTagToInsert(multiTag)).toBe('masterpiece, best quality, (high quality), ultra-detailed');
|
||||
});
|
||||
|
||||
test('should not escape parentheses in multi-tag strings with parentheses', () => {
|
||||
const multiTag = '(worst quality, low quality, normal quality), bad anatomy';
|
||||
expect(normalizeTagToInsert(multiTag)).toBe('(worst quality, low quality, normal quality), bad anatomy');
|
||||
});
|
||||
|
||||
test('should handle multi-tags with both underscores and parentheses correctly', () => {
|
||||
settingValues.replaceUnderscoreWithSpace = true;
|
||||
const multiTag = 'best_quality, (high_quality:1.2), ultra_detailed';
|
||||
expect(normalizeTagToInsert(multiTag)).toBe('best quality, (high quality:1.2), ultra detailed');
|
||||
|
||||
settingValues.replaceUnderscoreWithSpace = false;
|
||||
expect(normalizeTagToInsert(multiTag)).toBe('best_quality, (high_quality:1.2), ultra_detailed');
|
||||
});
|
||||
|
||||
test('should still escape parentheses for single tags without commas', () => {
|
||||
// Single tags (not multi-tags) should still have parentheses escaped
|
||||
expect(normalizeTagToInsert('blue(hair)')).toBe('blue\\(hair\\)');
|
||||
expect(normalizeTagToInsert('(tag)')).toBe('\\(tag\\)');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+11
-3
@@ -223,23 +223,31 @@ export function normalizeTagToSearch(str) {
|
||||
* Converts underscores to spaces only if the tag contains at least one letter or number,
|
||||
* and is not a wildcard call (e.g., "__wildcard__").
|
||||
* Keeps underscores for tags that are only symbols (e.g. "^_^") or wildcard calls.
|
||||
* @param {string} str
|
||||
* For multi-tags (multiple tags with commas), parentheses are not escaped to preserve prompt weight syntax.
|
||||
* @param {string} str
|
||||
* @returns {string}
|
||||
*/
|
||||
export function normalizeTagToInsert(str) {
|
||||
if (!str) return str;
|
||||
|
||||
// Check if multi-tag string
|
||||
const isMultiTag = str.includes(',');
|
||||
|
||||
// Check if the string contains at least one letter or number
|
||||
if (isContainsLetterOrNumber(str)) {
|
||||
const isWildcardCall = str.startsWith('__') && str.endsWith('__') && str.length > 4;
|
||||
|
||||
if (!isWildcardCall && settingValues.replaceUnderscoreWithSpace) {
|
||||
// If doesn't wildcard call and setting is enabled, replace underscores with spaces
|
||||
return escapeParentheses(str.replace(/_/g, " "));
|
||||
const result = str.replace(/_/g, " ");
|
||||
// Only escape parentheses for single tags, not multi-tags
|
||||
return isMultiTag ? result : escapeParentheses(result);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, keep it as is (e.g., ""^_^", "__wildcard__")
|
||||
return escapeParentheses(str);
|
||||
// Only escape parentheses for single tags, not multi-tags
|
||||
return isMultiTag ? str : escapeParentheses(str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user