fix extension extras_preview_media

+ Fixed for the new version of ComfyUI the display of media content when
  hovering in the selection list
This commit is contained in:
AlekPet
2026-03-20 00:09:40 +03:00
parent ba55cc2ccc
commit 4b50dc4497
2 changed files with 68 additions and 8 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui_custom_nodes_alekpet"
description = "Nodes: PoseNode, PainterNode, TranslateTextNode, TranslateCLIPTextEncodeNode, DeepTranslatorTextNode, DeepTranslatorCLIPTextEncodeNode, ArgosTranslateTextNode, ArgosTranslateCLIPTextEncodeNode, ChatGLM4TranslateCLIPTextEncodeNode, ChatGLM4TranslateTextNode, ChatGLM4InstructNode, ChatGLM4InstructMediaNode, ChatGLMImageGenerateNode, ChatGLMVideoGenerateNode, PreviewTextNode, HexToHueNode, ColorsCorrectNode, IDENode."
version = "1.1.1"
version = "1.1.2"
license = { file = "LICENSE" }
[project.urls]
@@ -10,4 +10,4 @@ Repository = "https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet"
[tool.comfy]
PublisherId = "alekpet"
DisplayName = "ComfyUI_Custom_Nodes_AlekPet"
Icon = ""
Icon = "https://avatars.githubusercontent.com/u/25489996"
+66 -6
View File
@@ -92,6 +92,17 @@ function drawVid(raw, canvas, ctx, type) {
drawVid.bind(this, raw, canvas, ctx, type)
);
}
function getSelectedNode() {
try {
const selectedNode =
app.canvas.selected_nodes[Object.keys(app.canvas.selected_nodes)[0]];
if (selectedNode) return selectedNode.comfyClass;
} catch (error) {
return null;
}
}
//
// -- Extension: Preview image, audio, video --
@@ -285,13 +296,62 @@ app.registerExtension({
});
}
// AddItem
const addItem = ContextMenu.prototype.addItem;
ContextMenu.prototype.addItem = function () {
const element = addItem?.apply(this, arguments);
// AddItem (Old version)
// const addItem = ContextMenu.prototype.addItem;
// ContextMenu.prototype.addItem = function () {
// const element = addItem?.apply(this, arguments);
addPreviewModule.call(this, arguments, element);
};
// addPreviewModule.call(this, arguments, element);
// };
// AddItem (New)
document.addEventListener(
"pointerenter",
(e) => {
try {
const el = e.target.closest("[data-value]");
if (!el) return;
const valueItem = el.dataset.value;
const ext = valueItem
.slice(valueItem.lastIndexOf(".") + 1)
.toLowerCase();
if (
!SUPPORTS_FORMAT.image.includes(ext) &&
!SUPPORTS_FORMAT.video.includes(ext)
)
return;
// Make field preview
addPreviewModule.call(
{ root: el.parentElement },
[null, valueItem, null],
el
);
} catch (error) {}
},
true
);
// Find node name on pointerdown
app.canvas.canvas.addEventListener(
"pointerdown",
(e) => {
try {
const pos = app.canvas.convertEventToCanvasOffset(e);
const node = app.canvas.graph.getNodeOnPos(
pos[0],
pos[1],
app.canvas.graph.nodes
);
if (node && Object.keys(NODES_TYPE_SRC).includes(node.comfyClass))
currentNodeType = node.comfyClass;
} catch (error) {}
},
true
);
// CloseItem
const closeItem = ContextMenu.prototype.close;