mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
Add functionality to copy LoRA syntax and update event handling for copy action
This commit is contained in:
@@ -3,7 +3,7 @@ import { refreshSingleLoraMetadata, saveModelMetadata } from '../../api/loraApi.
|
|||||||
import { showToast, getNSFWLevelName, copyToClipboard, sendLoraToWorkflow } from '../../utils/uiHelpers.js';
|
import { showToast, getNSFWLevelName, copyToClipboard, sendLoraToWorkflow } from '../../utils/uiHelpers.js';
|
||||||
import { NSFW_LEVELS } from '../../utils/constants.js';
|
import { NSFW_LEVELS } from '../../utils/constants.js';
|
||||||
import { getStorageItem } from '../../utils/storageHelpers.js';
|
import { getStorageItem } from '../../utils/storageHelpers.js';
|
||||||
import { showExcludeModal } from '../../utils/modalUtils.js';
|
import { showExcludeModal, showDeleteModal } from '../../utils/modalUtils.js';
|
||||||
|
|
||||||
export class LoraContextMenu extends BaseContextMenu {
|
export class LoraContextMenu extends BaseContextMenu {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -50,7 +50,8 @@ export class LoraContextMenu extends BaseContextMenu {
|
|||||||
this.currentCard.querySelector('.fa-image')?.click();
|
this.currentCard.querySelector('.fa-image')?.click();
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
this.currentCard.querySelector('.fa-trash')?.click();
|
// Call showDeleteModal directly instead of clicking the trash button
|
||||||
|
showDeleteModal(this.currentCard.dataset.filepath);
|
||||||
break;
|
break;
|
||||||
case 'move':
|
case 'move':
|
||||||
moveManager.showMoveModal(this.currentCard.dataset.filepath);
|
moveManager.showMoveModal(this.currentCard.dataset.filepath);
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ function handleLoraCardEvent(event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target.closest('.fa-trash')) {
|
if (event.target.closest('.fa-copy')) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
showDeleteModal(card.dataset.filepath);
|
copyLoraSyntax(card);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +182,15 @@ async function sendLoraToComfyUI(card, replaceMode) {
|
|||||||
sendLoraToWorkflow(loraSyntax, replaceMode, 'lora');
|
sendLoraToWorkflow(loraSyntax, replaceMode, 'lora');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add function to copy lora syntax
|
||||||
|
function copyLoraSyntax(card) {
|
||||||
|
const usageTips = JSON.parse(card.dataset.usage_tips || '{}');
|
||||||
|
const strength = usageTips.strength || 1;
|
||||||
|
const loraSyntax = `<lora:${card.dataset.file_name}:${strength}>`;
|
||||||
|
|
||||||
|
copyToClipboard(loraSyntax, 'LoRA syntax copied to clipboard');
|
||||||
|
}
|
||||||
|
|
||||||
export function createLoraCard(lora) {
|
export function createLoraCard(lora) {
|
||||||
const card = document.createElement('div');
|
const card = document.createElement('div');
|
||||||
card.className = 'lora-card';
|
card.className = 'lora-card';
|
||||||
@@ -273,8 +282,8 @@ export function createLoraCard(lora) {
|
|||||||
<i class="fas fa-paper-plane"
|
<i class="fas fa-paper-plane"
|
||||||
title="Send to ComfyUI (Click: Append, Shift+Click: Replace)">
|
title="Send to ComfyUI (Click: Append, Shift+Click: Replace)">
|
||||||
</i>
|
</i>
|
||||||
<i class="fas fa-trash"
|
<i class="fas fa-copy"
|
||||||
title="Delete Model">
|
title="Copy LoRA Syntax">
|
||||||
</i>
|
</i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user