Rearranged model preview thumbnail buttons. (Ordered by action impact.)
- Fixed bug with boolean to show Add and Copy buttons.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 77 KiB |
@@ -1755,12 +1755,13 @@ class ModelGrid {
|
|||||||
const widgetIndex = ModelGrid.modelWidgetIndex(nodeType);
|
const widgetIndex = ModelGrid.modelWidgetIndex(nodeType);
|
||||||
const target = selectedNode?.widgets[widgetIndex]?.element;
|
const target = selectedNode?.widgets[widgetIndex]?.element;
|
||||||
if (target && target.type === "textarea") {
|
if (target && target.type === "textarea") {
|
||||||
|
// TODO: If the node has >1 textareas, the textarea element must be selected
|
||||||
target.value = ModelGrid.insertEmbeddingIntoText(target.value, embeddingFile, removeEmbeddingExtension);
|
target.value = ModelGrid.insertEmbeddingIntoText(target.value, embeddingFile, removeEmbeddingExtension);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
console.warn("Try selecting a node before adding the embedding.");
|
window.alert("No selected nodes have a text area!");
|
||||||
}
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
@@ -1898,10 +1899,10 @@ class ModelGrid {
|
|||||||
// TODO: separate text and model logic; getting too messy
|
// TODO: separate text and model logic; getting too messy
|
||||||
// TODO: fallback on button failure to copy text?
|
// TODO: fallback on button failure to copy text?
|
||||||
const canShowButtons = modelNodeType[modelType] !== undefined;
|
const canShowButtons = modelNodeType[modelType] !== undefined;
|
||||||
|
const shouldShowTryOpenModelUrl = canShowButtons && settingsElements["model-show-open-model-url-button"].checked;
|
||||||
|
const showLoadWorkflowButton = canShowButtons && settingsElements["model-show-load-workflow-button"].checked;
|
||||||
const showAddButton = canShowButtons && settingsElements["model-show-add-button"].checked;
|
const showAddButton = canShowButtons && settingsElements["model-show-add-button"].checked;
|
||||||
const showCopyButton = canShowButtons && settingsElements["model-show-copy-button"].checked;
|
const showCopyButton = canShowButtons && settingsElements["model-show-copy-button"].checked;
|
||||||
const showLoadWorkflowButton = canShowButtons && settingsElements["model-show-load-workflow-button"].checked;
|
|
||||||
const shouldShowTryOpenModelUrl = canShowButtons && settingsElements["model-show-open-model-url-button"].checked;
|
|
||||||
const strictDragToAdd = settingsElements["model-add-drag-strict-on-field"].checked;
|
const strictDragToAdd = settingsElements["model-add-drag-strict-on-field"].checked;
|
||||||
const addOffset = parseInt(settingsElements["model-add-offset"].value);
|
const addOffset = parseInt(settingsElements["model-add-offset"].value);
|
||||||
const showModelExtension = settingsElements["model-show-label-extensions"].checked;
|
const showModelExtension = settingsElements["model-show-label-extensions"].checked;
|
||||||
@@ -1925,35 +1926,20 @@ class ModelGrid {
|
|||||||
const searchPath = item.path;
|
const searchPath = item.path;
|
||||||
const path = SearchPath.systemPath(searchPath, searchSeparator, systemSeparator);
|
const path = SearchPath.systemPath(searchPath, searchSeparator, systemSeparator);
|
||||||
let actionButtons = [];
|
let actionButtons = [];
|
||||||
if (showAddButton && !(modelType === "embeddings" && !navigator.clipboard)) {
|
if (shouldShowTryOpenModelUrl) {
|
||||||
actionButtons.push(
|
actionButtons.push(
|
||||||
new ComfyButton({
|
new ComfyButton({
|
||||||
icon: "content-copy",
|
icon: "open-in-new",
|
||||||
tooltip: "Copy model to clipboard",
|
tooltip: "Attempt to open model url page in a new tab.",
|
||||||
classList: "comfyui-button icon-button model-button",
|
classList: "comfyui-button icon-button model-button",
|
||||||
action: (e) => ModelGrid.#copyModelToClipboard(
|
action: async (e) => {
|
||||||
e,
|
const [button, icon, span] = comfyButtonDisambiguate(e.target);
|
||||||
modelType,
|
button.disabled = true;
|
||||||
path,
|
const success = await tryOpenModelUrl(searchPath);
|
||||||
removeEmbeddingExtension,
|
comfyButtonAlert(e.target, success, "mdi-check-bold", "mdi-close-thick");
|
||||||
),
|
button.disabled = false;
|
||||||
}).element,
|
},
|
||||||
);
|
}).element
|
||||||
}
|
|
||||||
if (showCopyButton) {
|
|
||||||
actionButtons.push(
|
|
||||||
new ComfyButton({
|
|
||||||
icon: "plus-box-outline",
|
|
||||||
tooltip: "Add model to node grid",
|
|
||||||
classList: "comfyui-button icon-button model-button",
|
|
||||||
action: (e) => ModelGrid.#addModel(
|
|
||||||
e,
|
|
||||||
modelType,
|
|
||||||
path,
|
|
||||||
removeEmbeddingExtension,
|
|
||||||
addOffset,
|
|
||||||
),
|
|
||||||
}).element,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (showLoadWorkflowButton) {
|
if (showLoadWorkflowButton) {
|
||||||
@@ -1974,20 +1960,35 @@ class ModelGrid {
|
|||||||
}).element,
|
}).element,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (shouldShowTryOpenModelUrl) {
|
if (showAddButton) {
|
||||||
actionButtons.push(
|
actionButtons.push(
|
||||||
new ComfyButton({
|
new ComfyButton({
|
||||||
icon: "open-in-new",
|
icon: "plus-box-outline",
|
||||||
tooltip: "Attempt to open model url page in a new tab.",
|
tooltip: "Add model to node grid",
|
||||||
classList: "comfyui-button icon-button model-button",
|
classList: "comfyui-button icon-button model-button",
|
||||||
action: async (e) => {
|
action: (e) => ModelGrid.#addModel(
|
||||||
const [button, icon, span] = comfyButtonDisambiguate(e.target);
|
e,
|
||||||
button.disabled = true;
|
modelType,
|
||||||
const success = await tryOpenModelUrl(searchPath);
|
path,
|
||||||
comfyButtonAlert(e.target, success, "mdi-check-bold", "mdi-close-thick");
|
removeEmbeddingExtension,
|
||||||
button.disabled = false;
|
addOffset,
|
||||||
},
|
),
|
||||||
}).element
|
}).element,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (showCopyButton && !(modelType === "embeddings" && !navigator.clipboard)) {
|
||||||
|
actionButtons.push(
|
||||||
|
new ComfyButton({
|
||||||
|
icon: "content-copy",
|
||||||
|
tooltip: "Copy model to clipboard",
|
||||||
|
classList: "comfyui-button icon-button model-button",
|
||||||
|
action: (e) => ModelGrid.#copyModelToClipboard(
|
||||||
|
e,
|
||||||
|
modelType,
|
||||||
|
path,
|
||||||
|
removeEmbeddingExtension,
|
||||||
|
),
|
||||||
|
}).element,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const infoButtons = [
|
const infoButtons = [
|
||||||
|
|||||||
Reference in New Issue
Block a user