Files
TashaSkyUp-EternalKernelPyt…/web/showMarkdown.js
T
Tasha Upchurch 4a1e6dfb49 utils.py:
Added FileBackedDict, which provides a dictionary-like interface with file-backed persistence. Supports nested dictionaries and ensures data is stored and retrieved from disk.
video.py:

Implemented audio resampling in CombineAudioVideoFiles, including video and audio resampling logic.
Refined create_video_from_images to use ffmpeg for combining image sequences into video.
Updated CombineFoldersWithFramesToVideoFiles to handle both duration and fps-based input.
Added additional parameters for video quality and pixel format.
torchvision_nodes.py:

Centralized the imports for NODE_CLASS_MAPPINGS and NODE_DISPLAY_NAME_MAPPINGS across the module.
Adjusted default values for certain fields to improve user experience.
youtube_nodes.py & modules/youtube.py:

Extended the YouTube upload functionality to support optional thumbnail uploads.
Improved initialize_upload function to return video_id after a successful upload.
Introduced the ability to upload a thumbnail alongside the video.
web/ui_modifications.js:

Reworked the login form handling to prevent page reload and improved element management.
Added dynamic graph creation in the handleGraphCreateNew function.
web/showMarkdown.js:

Fixed the import of marked.js, using Marked as the module name to avoid potential conflicts.
modules/xttscli.py:

Increased the batch_size for text-to-speech processing from 2 to 4, enabling faster concurrent execution.
2024-09-22 20:05:04 -06:00

47 lines
1.7 KiB
JavaScript

import { app } from "../../scripts/app.js";
import { ComfyWidgets } from "../../scripts/widgets.js";
import Marked from "./marked.js";
// Displays input markdown on a node
app.registerExtension({
name: "pysssss.ShowMarkdown",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.internal_state_display || nodeData.name == "ShowMarkdown") {
// When the node is executed we will be sent the input markdown, display this in the widget
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, arguments);
if (this.widgets) {
const pos = this.widgets.findIndex((w) => w.name === "markdown");
if (pos !== -1) {
for (let i = pos; i < this.widgets.length; i++) {
this.widgets[i].onRemove?.();
}
this.widgets.length = pos;
}
}
for (const list of message.text) {
const w = ComfyWidgets["STRING"](this, "markdown", ["STRING", { multiline: true }], app).widget;
// Convert markdown to HTML
const html = Marked(list);
// Create a new div element to hold the rendered markdown
const div = document.createElement("div");
div.classList.add("markdown-widget");
div.style.opacity = 0.6;
div.innerHTML = html;
// Replace the input element with the div containing the rendered markdown
w.inputEl.parentNode.replaceChild(div, w.inputEl);
}
this.onResize?.(this.size);
};
}
},
});