mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-20 20:41:26 -03:00
Compare commits
2 Commits
fe90f7f9b1
...
3c83e78d9f
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c83e78d9f | |||
| d7291f73c9 |
@@ -1,5 +1,5 @@
|
|||||||
import { modalManager } from './ModalManager.js';
|
import { modalManager } from './ModalManager.js';
|
||||||
import { showToast } from '../utils/uiHelpers.js';
|
import { showToast, setupAutoNewlineOnPaste } from '../utils/uiHelpers.js';
|
||||||
import { translate } from '../utils/i18nHelpers.js';
|
import { translate } from '../utils/i18nHelpers.js';
|
||||||
import { WS_ENDPOINTS } from '../api/apiConfig.js';
|
import { WS_ENDPOINTS } from '../api/apiConfig.js';
|
||||||
import { getStorageItem, setStorageItem } from '../utils/storageHelpers.js';
|
import { getStorageItem, setStorageItem } from '../utils/storageHelpers.js';
|
||||||
@@ -43,6 +43,9 @@ export class BatchImportManager {
|
|||||||
setStorageItem('batch_import_skip_no_metadata', e.target.checked);
|
setStorageItem('batch_import_skip_no_metadata', e.target.checked);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-append newline after pasting a URL in the batch URL input
|
||||||
|
setupAutoNewlineOnPaste('batchUrlInput');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { modalManager } from './ModalManager.js';
|
import { modalManager } from './ModalManager.js';
|
||||||
import { showToast } from '../utils/uiHelpers.js';
|
import { showToast, setupAutoNewlineOnPaste } from '../utils/uiHelpers.js';
|
||||||
import { state } from '../state/index.js';
|
import { state } from '../state/index.js';
|
||||||
import { LoadingManager } from './LoadingManager.js';
|
import { LoadingManager } from './LoadingManager.js';
|
||||||
import { getModelApiClient, resetAndReload } from '../api/modelApiFactory.js';
|
import { getModelApiClient, resetAndReload } from '../api/modelApiFactory.js';
|
||||||
@@ -107,7 +107,8 @@ export class DownloadManager {
|
|||||||
// Default path toggle handler
|
// Default path toggle handler
|
||||||
document.getElementById('useDefaultPath').addEventListener('change', this.handleToggleDefaultPath);
|
document.getElementById('useDefaultPath').addEventListener('change', this.handleToggleDefaultPath);
|
||||||
|
|
||||||
|
// Auto-append newline after pasting a URL so users can paste multiple URLs in succession
|
||||||
|
setupAutoNewlineOnPaste('modelUrl');
|
||||||
}
|
}
|
||||||
|
|
||||||
updateModalLabels() {
|
updateModalLabels() {
|
||||||
@@ -463,8 +464,8 @@ export class DownloadManager {
|
|||||||
const trimmed = url.trim();
|
const trimmed = url.trim();
|
||||||
if (!trimmed) return null;
|
if (!trimmed) return null;
|
||||||
|
|
||||||
// CivitAI
|
// CivitAI — matches civitai.com, civitai.red, civitai.green, etc.
|
||||||
if (/civitai\.com\/models\//i.test(trimmed) || /civitaiarchive|civarchive/i.test(trimmed)) {
|
if (/civitai\.(?:com|red|green)\/models\//i.test(trimmed) || /civitaiarchive|civarchive/i.test(trimmed)) {
|
||||||
// Will be parsed by existing CivitAI logic
|
// Will be parsed by existing CivitAI logic
|
||||||
return { type: 'civitai' };
|
return { type: 'civitai' };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1482,3 +1482,40 @@ export async function openExampleImagesFolder(modelHash) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up a paste handler on a textarea that automatically appends a newline
|
||||||
|
* after pasted content that looks like a URL (http/https). This lets users
|
||||||
|
* paste multiple URLs one after another without manually pressing Enter.
|
||||||
|
* @param {string} textareaId - The id of the textarea element
|
||||||
|
*/
|
||||||
|
export function setupAutoNewlineOnPaste(textareaId) {
|
||||||
|
const el = document.getElementById(textareaId);
|
||||||
|
if (!el || el.tagName !== 'TEXTAREA') return;
|
||||||
|
|
||||||
|
el.addEventListener('paste', (e) => {
|
||||||
|
const pastedText = (e.clipboardData || window.clipboardData).getData('text');
|
||||||
|
// Only apply to text that starts with http:// or https://
|
||||||
|
if (/^https?:\/\//.test(pastedText) && !pastedText.endsWith('\n')) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const start = el.selectionStart;
|
||||||
|
const end = el.selectionEnd;
|
||||||
|
const text = el.value;
|
||||||
|
const before = text.substring(0, start);
|
||||||
|
const after = text.substring(end);
|
||||||
|
|
||||||
|
// Append newline after the pasted URL
|
||||||
|
const modifiedText = pastedText + '\n';
|
||||||
|
el.value = before + modifiedText + after;
|
||||||
|
|
||||||
|
// Move cursor to just after the inserted text
|
||||||
|
const newCursorPos = start + modifiedText.length;
|
||||||
|
el.selectionStart = el.selectionEnd = newCursorPos;
|
||||||
|
|
||||||
|
// Trigger input event so any listeners stay in sync
|
||||||
|
el.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
}
|
||||||
|
// Non-URL text or text already ending with \n — let default paste happen
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,6 +62,20 @@ describe('DownloadManager.detectUrlType — HF URL detection', () => {
|
|||||||
expect(result).toEqual({ type: 'civitai' });
|
expect(result).toEqual({ type: 'civitai' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('detects CivitAI URL on civitai.red domain', () => {
|
||||||
|
const result = DownloadManager.detectUrlType(
|
||||||
|
'https://civitai.red/models/12345/my-model'
|
||||||
|
);
|
||||||
|
expect(result).toEqual({ type: 'civitai' });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('detects CivitAI URL on civitai.green domain', () => {
|
||||||
|
const result = DownloadManager.detectUrlType(
|
||||||
|
'https://civitai.green/models/67890/another-model'
|
||||||
|
);
|
||||||
|
expect(result).toEqual({ type: 'civitai' });
|
||||||
|
});
|
||||||
|
|
||||||
it('detects CivArchive URL', () => {
|
it('detects CivArchive URL', () => {
|
||||||
const result = DownloadManager.detectUrlType(
|
const result = DownloadManager.detectUrlType(
|
||||||
'https://civarchive.com/models/456'
|
'https://civarchive.com/models/456'
|
||||||
|
|||||||
Reference in New Issue
Block a user