Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
983bffae06 | ||
|
|
9f055259d4 | ||
|
|
f9ca71a1c8 | ||
|
|
47ccfd838e | ||
|
|
7d1ed1451a | ||
|
|
9d517f591c | ||
|
|
49e7c1a684 | ||
|
|
b72c59f758 |
+87
-1
@@ -1 +1,87 @@
|
||||
Status.txt
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# ComfyUI specific
|
||||
*.log
|
||||
temp/
|
||||
output/
|
||||
models/
|
||||
input/
|
||||
|
||||
# Node modules (if any JS development)
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# AF speciffic
|
||||
Status.txt
|
||||
+14
-16
@@ -1,12 +1,12 @@
|
||||
# ****** ComfyUI-AF - Enhanced HTML-NOTE ******
|
||||
#
|
||||
# Creator: Alex Furer - Co-Creator(s): Claude AI
|
||||
# Creator: Alex Furer - Co-Creator(s): Claude AI & DeepSeek
|
||||
#
|
||||
# Praise, comment, bugs, improvements: https://github.com/alFrame/ComfyUI_AF_FindNodeByID
|
||||
#
|
||||
# LICENSE: MIT License
|
||||
#
|
||||
# v0.0.03
|
||||
# v0.0.05
|
||||
#
|
||||
# Description:
|
||||
# A ComfyUI Note node with html capabilities. Create notes, UI's and ReadMe's directly inside the workflow, using html.
|
||||
@@ -15,6 +15,12 @@
|
||||
# Read Me on Github
|
||||
#
|
||||
# Changelog:
|
||||
# v0.0.05
|
||||
# - Made edit mode less intrusive and keep ComfyUI canvas navigation (panning, zooming [space bar] and [H] now work to pan around the canvas)
|
||||
# v0.0.04
|
||||
# - Fixed node selection and resizing by removing OUTPUT_NODE and using proper widget approach
|
||||
# - Double clicking is now used to edit the html
|
||||
# - Mouse interaction is now persistent to ComfyUI behavior. Except middle mouse button for panning.
|
||||
# v0.0.03
|
||||
# - Fixed node resizing issues on save/reload
|
||||
# - Improved selection and edit mode behavior to match ComfyUI core notes
|
||||
@@ -26,8 +32,6 @@
|
||||
# v0.0.01
|
||||
# - Initial Version
|
||||
#
|
||||
# Feature Requests / Wet Dreams
|
||||
# -
|
||||
|
||||
class AF_Enhanced_HTML_Note:
|
||||
"""
|
||||
@@ -43,7 +47,7 @@ class AF_Enhanced_HTML_Note:
|
||||
"default": """<div class="af-section af-positive">
|
||||
<h2>🟢 Positive Prompts</h2>
|
||||
<p>Your positive prompts go here...</p>
|
||||
<a href="#" onclick="alert('Link clicked!')">Click me!</a>
|
||||
<a href="https://www.fullframestudios.ch" onclick="alert('Link clicked!')">Click me!</a>
|
||||
</div>
|
||||
|
||||
<div class="af-spacer"></div>
|
||||
@@ -69,21 +73,15 @@ class AF_Enhanced_HTML_Note:
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
OUTPUT_NODE = True
|
||||
FUNCTION = "af_display_html_note"
|
||||
FUNCTION = "display_html"
|
||||
CATEGORY = "AF - Nodes"
|
||||
OUTPUT_NODE = False
|
||||
|
||||
def af_display_html_note(self, html_content):
|
||||
def display_html(self, html_content):
|
||||
"""
|
||||
Display enhanced HTML content
|
||||
"""
|
||||
return {
|
||||
"ui": {
|
||||
"af_html_note": [{
|
||||
"content": html_content
|
||||
}]
|
||||
}
|
||||
}
|
||||
return {"ui": {"text": html_content}, "result": (html_content,)}
|
||||
|
||||
# Node mappings for ComfyUI
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
@@ -92,4 +90,4 @@ NODE_CLASS_MAPPINGS = {
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"AF_Enhanced_HTML_Note": "AF - Enhanced HTML Note",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,34 @@
|
||||
# AF Enhanced HTML Node - Usage Guide
|
||||
|
||||
A ComfyUI Note node with html capabilities. Create notes, UI's and ReadMe's directly inside the workflow, using html.
|
||||
A ComfyUI Note node with HTML capabilities. Create notes, UI's and ReadMe's directly inside the workflow using rich HTML formatting.
|
||||
|
||||
## Basic Section Colors
|
||||
## ✨ Key Features
|
||||
|
||||
- **Rich HTML Support** - Full HTML formatting with colored sections, lists, tables, code blocks, and more
|
||||
- **Non-Intrusive Design** - Doesn't interfere with normal ComfyUI workflow interactions
|
||||
- **Easy Editing** - Double-click anywhere on the content to edit HTML
|
||||
- **Smart Links** - Ctrl+click to open external links or trigger custom actions
|
||||
- **Beautiful Styling** - Predefined color schemes that match ComfyUI's theme
|
||||
- **No Dependencies** - All CSS is inlined for reliable performance
|
||||
|
||||
## 🎮 Interaction Guide
|
||||
|
||||
### Editing Content
|
||||
- **Double-click** anywhere on the HTML content to enter edit mode
|
||||
- **Escape key** or click outside to exit edit mode and save changes
|
||||
- Changes are automatically saved when exiting edit mode
|
||||
|
||||
### Using Links
|
||||
- **Hold Control key + Click** on any link to activate it
|
||||
- External links open in new tabs
|
||||
- JavaScript actions and alerts work when Control is held
|
||||
|
||||
### Node Management
|
||||
- **Click and drag** the node title bar to move
|
||||
- **Drag edges/corners** to resize
|
||||
- **Middle mouse button** works for canvas panning (like other nodes)
|
||||
|
||||
## 🎨 Basic Section Colors
|
||||
|
||||
```html
|
||||
<!-- Positive section (green) -->
|
||||
@@ -41,9 +67,7 @@ A ComfyUI Note node with html capabilities. Create notes, UI's and ReadMe's dire
|
||||
<p>Custom styled content...</p>
|
||||
</div>
|
||||
```
|
||||
|
||||
## Spacers
|
||||
|
||||
## 📐 Spacers
|
||||
```html
|
||||
<!-- Small spacer -->
|
||||
<div class="af-spacer-small"></div>
|
||||
@@ -56,40 +80,40 @@ A ComfyUI Note node with html capabilities. Create notes, UI's and ReadMe's dire
|
||||
|
||||
<!-- Extra large spacer -->
|
||||
<div class="af-spacer-xl"></div>
|
||||
```
|
||||
|
||||
## Clickable Links
|
||||
#🔗 Clickable Links & Actions
|
||||
|
||||
```html
|
||||
<!-- External link -->
|
||||
<a href="https://github.com/comfyanonymous/ComfyUI" target="_blank">ComfyUI GitHub</a>
|
||||
<!-- External link (opens in new tab with Ctrl+click) -->
|
||||
<a href="https://github.com/comfyanonymous/ComfyUI">ComfyUI GitHub</a>
|
||||
|
||||
<!-- Link with custom action -->
|
||||
<!-- Alert action (triggers with Ctrl+click) -->
|
||||
<a href="#" onclick="alert('Custom action triggered!')">Click for alert</a>
|
||||
|
||||
<!-- Link with data attribute for custom handling -->
|
||||
<a href="#" data-action="custom-command">Custom Command</a>
|
||||
<!-- Multiple actions -->
|
||||
<a href="https://example.com" onclick="console.log('Link clicked')">Link with multiple actions</a>
|
||||
|
||||
<!-- JavaScript links -->
|
||||
<a href="javascript:alert('Hello!')">JavaScript link</a>
|
||||
```
|
||||
|
||||
## Complete Example Template
|
||||
|
||||
## 📋 Complete Example Template
|
||||
```html
|
||||
<div class="af-section af-positive">
|
||||
<h2>🟢 Positive Prompts</h2>
|
||||
<p>masterpiece, best quality, highly detailed</p>
|
||||
<p><strong>masterpiece, best quality, highly detailed</strong></p>
|
||||
<ul>
|
||||
<li>Professional lighting</li>
|
||||
<li>Sharp focus</li>
|
||||
<li>8K resolution</li>
|
||||
</ul>
|
||||
<a href="#" onclick="alert('Positive prompts copied!')">📋 Copy Prompts</a>
|
||||
</div>
|
||||
|
||||
<div class="af-spacer"></div>
|
||||
|
||||
<div class="af-section af-negative">
|
||||
<h2>🔴 Negative Prompts</h2>
|
||||
<p>low quality, blurry, distorted</p>
|
||||
<code>nsfw, watermark, signature</code>
|
||||
<p><em>low quality, blurry, distorted</em></p>
|
||||
<code>nsfw, watermark, signature, bad anatomy</code>
|
||||
</div>
|
||||
|
||||
<div class="af-spacer-large"></div>
|
||||
@@ -97,41 +121,84 @@ A ComfyUI Note node with html capabilities. Create notes, UI's and ReadMe's dire
|
||||
<div class="af-section af-info">
|
||||
<h3>ℹ️ Model Information</h3>
|
||||
<p>Using: <strong>SDXL 1.0</strong></p>
|
||||
<p>Steps: <em>25</em> | CFG: <em>7.5</em></p>
|
||||
<a href="https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0" target="_blank">Model Page</a>
|
||||
<p>Steps: <code>25</code> | CFG: <code>7.5</code> | Sampler: <code>DPM++ 2M Karras</code></p>
|
||||
<a href="https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0">Model Page</a>
|
||||
</div>
|
||||
|
||||
<div class="af-spacer"></div>
|
||||
|
||||
<div class="af-section af-warning">
|
||||
<h3>⚠️ Important Notes</h3>
|
||||
<p>This workflow requires:</p>
|
||||
<ol>
|
||||
<li>High VRAM (8GB+)</li>
|
||||
<li>Latest ComfyUI version</li>
|
||||
<li>SDXL compatible models</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="af-spacer"></div>
|
||||
|
||||
<div class="af-section af-neutral">
|
||||
<h3>📝 Notes</h3>
|
||||
<h3>📝 Workflow Notes</h3>
|
||||
<p>Remember to:</p>
|
||||
<ol>
|
||||
<li>Check image dimensions</li>
|
||||
<li>Adjust sampling method</li>
|
||||
<li>Fine-tune CFG scale</li>
|
||||
</ol>
|
||||
<ul>
|
||||
<li>Check image dimensions before generating</li>
|
||||
<li>Adjust CFG scale for different results</li>
|
||||
<li>Save frequently!</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<p><small>Last updated: Today</small></p>
|
||||
<p><small>Last updated: Today | Created with AF Enhanced HTML Node</small></p>
|
||||
</div>
|
||||
```
|
||||
## 🛠️ Installation
|
||||
Create folder: ComfyUI/custom_nodes/ComfyUI-AF_Enhanced_HTML_Note/
|
||||
|
||||
## Features
|
||||
Add the Python file: AF_Enhanced_HTML_Note.py
|
||||
|
||||
- **No external dependencies** - All CSS is inlined to avoid loading issues
|
||||
- **Colored sections** - 6 predefined color schemes (positive, negative, neutral, info, warning, custom)
|
||||
- **Flexible spacers** - 4 different spacer sizes
|
||||
- **Clickable links** - Support for external links and custom actions
|
||||
- **Responsive design** - Works on different screen sizes
|
||||
- **HTML support** - Full HTML formatting (lists, tables, code blocks, etc.)
|
||||
- **Custom scrollbars** - Styled to match ComfyUI theme
|
||||
Add the init file: __init__.py
|
||||
|
||||
## Installation
|
||||
Create web/ subfolder
|
||||
|
||||
1. Create folder: `ComfyUI/custom_nodes/ComfyUI-AF_Enhanced_HTML/`
|
||||
2. Add the Python file: `AF_Enhanced_HTML.py`
|
||||
3. Add the init file: `__init__.py`
|
||||
4. Create `web/` subfolder
|
||||
5. Add the JavaScript file: `web/AF_Enhanced_HTML.js`
|
||||
6. Restart ComfyUI
|
||||
7. Find the node under **AF > AF - Enhanced HTML**
|
||||
Add the JavaScript file: web/AF_Enhanced_HTML_Note.js
|
||||
|
||||
Restart ComfyUI
|
||||
|
||||
Find the node under AF - Nodes > AF - Enhanced HTML Note
|
||||
|
||||
## 🔧 Technical Details
|
||||
Node Name: AF_Enhanced_HTML_Note
|
||||
|
||||
Category: AF - Nodes
|
||||
|
||||
Input: HTML content (multiline string)
|
||||
|
||||
Output: None (display only)
|
||||
|
||||
Compatibility: ComfyUI latest version
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
Node won't select/move?
|
||||
|
||||
Click on the node's title bar or edges, not the HTML content area
|
||||
|
||||
Links not working?
|
||||
|
||||
Remember to hold the Control key while clicking links
|
||||
|
||||
Can't edit content?
|
||||
|
||||
Double-click directly on the HTML content (not the node borders)
|
||||
|
||||
Scrollbar appears unnecessarily?
|
||||
|
||||
The node has minimal padding; resize if you need more space
|
||||
|
||||
## 📞 Support
|
||||
Creator: Alex Furer
|
||||
|
||||
Co-Creators: Claude AI & DeepSeek
|
||||
|
||||
GitHub: https://github.com/alFrame/ComfyUI_AF_FindNodeByID
|
||||
|
||||
License: MIT License
|
||||
|
||||
+16
-1
@@ -7,4 +7,19 @@ from .AF_Enhanced_HTML_Note import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPIN
|
||||
# Tell ComfyUI about our web files
|
||||
WEB_DIRECTORY = "./web"
|
||||
|
||||
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY']
|
||||
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY']
|
||||
__version__ = "0.0.05"
|
||||
__author__ = "Alex Furer"
|
||||
|
||||
print("* * * * * * * * * * * * * * * * * * * * * * * * * *")
|
||||
print(r"""
|
||||
___ ____ _____ ___ __ ______ _ __ __
|
||||
/ _ | / __/ ____ / ___/__ __ _ / _/_ __/ / / / _/ / |/ /__ ___/ /__ ___
|
||||
/ __ |/ _/ /___/ / /__/ _ \/ ' \/ _/ // / /_/ // / / / _ Y _ / -_|_-<
|
||||
/_/ |_/_/ \___/\___/_/_/_/_/ \_, /\____/___/ /_/|_/\___|_,_/\__/___/
|
||||
/___/
|
||||
|
||||
📋 AF - Enhanced HTML Note Loaded !
|
||||
|
||||
""")
|
||||
print("* * * * * * * * * * * * * * * * * * * * * * * * * *")
|
||||
+286
-325
@@ -4,143 +4,176 @@ import { app } from "../../scripts/app.js";
|
||||
|
||||
// Define inline CSS styles
|
||||
const AF_HTML_NOTE_STYLES = `
|
||||
.af-html-note-widget {
|
||||
.af-html-note-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 100px;
|
||||
background: var(--comfy-menu-bg, #2a2a2a);
|
||||
border: 1px solid var(--border-color, #555);
|
||||
/* border-radius: 6px; */
|
||||
padding: 16px;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
cursor: default;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
||||
line-height: 1.6;
|
||||
color: var(--input-text, #ffffff);
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
||||
min-height: 100px;
|
||||
word-wrap: break-word;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
cursor: text;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
pointer-events: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.af-html-note-widget:hover {
|
||||
background: var(--comfy-menu-bg-hover, #333);
|
||||
border-color: var(--border-color-hover, #777);
|
||||
.af-html-note-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
/* NO pointer-events here - let ComfyUI handle interactions */
|
||||
}
|
||||
|
||||
.af-html-note-editor {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--comfy-menu-bg, #2a2a2a);
|
||||
border: 1px solid var(--border-color, #555);
|
||||
/* border-radius: 6px; */
|
||||
padding: 16px;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
|
||||
line-height: 1.4;
|
||||
color: var(--input-text, #ffffff);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
resize: none;
|
||||
outline: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
font-size: 14px;
|
||||
display: none;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Floating edit button */
|
||||
.af-floating-edit-btn {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
border: 1px solid var(--border-color, #555);
|
||||
color: var(--input-text, #ffffff);
|
||||
border-radius: 3px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
cursor: pointer;
|
||||
z-index: 1000;
|
||||
font-size: 11px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.af-floating-edit-btn:hover {
|
||||
opacity: 1;
|
||||
background: rgba(0, 0, 0, 0.9);
|
||||
border-color: #777;
|
||||
}
|
||||
|
||||
/* Enable link interactions only when Ctrl is held */
|
||||
.af-html-note-content a {
|
||||
color: #58a6ff;
|
||||
text-decoration: none;
|
||||
/* Links are never directly clickable - only via Ctrl */
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
body.af-ctrl-active .af-html-note-content a {
|
||||
/* Only become clickable when Ctrl is held globally */
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
body.af-ctrl-active .af-html-note-content a:hover {
|
||||
color: #79c0ff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.af-html-note-container.edit-mode .af-html-note-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.af-html-note-editor:focus {
|
||||
border-color: var(--border-color-focus, #0078d4);
|
||||
}
|
||||
|
||||
/* When in edit mode, hide the display and show the editor */
|
||||
.af-html-note-container.edit-mode .af-html-note-widget {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.af-html-note-container.edit-mode .af-html-note-editor {
|
||||
display: block !important;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* When not in edit mode, show display and hide editor */
|
||||
.af-html-note-container:not(.edit-mode) .af-html-note-widget {
|
||||
display: block !important;
|
||||
/* Hide edit button in edit mode */
|
||||
.af-html-note-container.edit-mode .af-floating-edit-btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.af-html-note-container:not(.edit-mode) .af-html-note-editor {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.af-html-note-widget h1, .af-html-note-widget h2, .af-html-note-widget h3,
|
||||
.af-html-note-widget h4, .af-html-note-widget h5, .af-html-note-widget h6 {
|
||||
/* Rest of your CSS remains the same... */
|
||||
.af-html-note-content h1, .af-html-note-content h2, .af-html-note-content h3,
|
||||
.af-html-note-content h4, .af-html-note-content h5, .af-html-note-content h6 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.af-html-note-widget h1 { font-size: 1.5em; }
|
||||
.af-html-note-widget h2 { font-size: 1.3em; }
|
||||
.af-html-note-widget h3 { font-size: 1.1em; }
|
||||
.af-html-note-content h1 { font-size: 1.5em; }
|
||||
.af-html-note-content h2 { font-size: 1.3em; }
|
||||
.af-html-note-content h3 { font-size: 1.1em; }
|
||||
|
||||
.af-html-note-widget .af-section {
|
||||
padding: 12px 16px;
|
||||
.af-html-note-content .af-section {
|
||||
padding: 8px 16px;
|
||||
margin: 8px 0;
|
||||
border-radius: 6px;
|
||||
border-left: 4px solid;
|
||||
}
|
||||
|
||||
.af-html-note-widget .af-section.af-positive {
|
||||
.af-html-note-content .af-section.af-positive {
|
||||
background: rgba(144, 238, 144, 0.1);
|
||||
border-left-color: #90EE90;
|
||||
}
|
||||
|
||||
.af-html-note-widget .af-section.af-negative {
|
||||
.af-html-note-content .af-section.af-negative {
|
||||
background: rgba(255, 107, 107, 0.1);
|
||||
border-left-color: #FF6B6B;
|
||||
}
|
||||
|
||||
.af-html-note-widget .af-section.af-neutral {
|
||||
.af-html-note-content .af-section.af-neutral {
|
||||
background: rgba(224, 224, 224, 0.1);
|
||||
border-left-color: #E0E0E0;
|
||||
}
|
||||
|
||||
.af-html-note-widget .af-section.af-info {
|
||||
.af-html-note-content .af-section.af-info {
|
||||
background: rgba(135, 206, 235, 0.1);
|
||||
border-left-color: #87CEEB;
|
||||
}
|
||||
|
||||
.af-html-note-widget .af-section.af-warning {
|
||||
background: rgba(255, 215, 0, 0.1);
|
||||
.af-html-note-content .af-section.af-warning {
|
||||
background: rgba(255, 128, 0, 0.1);
|
||||
border-left-color: #FFD700;
|
||||
}
|
||||
|
||||
.af-html-note-widget .af-section.af-custom {
|
||||
.af-html-note-content .af-section.af-yellow {
|
||||
background: rgba(255, 128, 0, 0.1);
|
||||
border-left-color: #FFD700;
|
||||
}
|
||||
|
||||
.af-html-note-content .af-section.af-blue {
|
||||
background: rgba(102, 105, 255, 0.1);
|
||||
border-left-color: #000099;
|
||||
}
|
||||
|
||||
.af-html-note-content .af-section.af-custom {
|
||||
background: rgba(186, 85, 211, 0.1);
|
||||
border-left-color: #BA55D3;
|
||||
}
|
||||
|
||||
.af-html-note-widget .af-spacer { height: 16px; margin: 8px 0; }
|
||||
.af-html-note-widget .af-spacer-small { height: 8px; margin: 4px 0; }
|
||||
.af-html-note-widget .af-spacer-large { height: 32px; margin: 16px 0; }
|
||||
.af-html-note-widget .af-spacer-xl { height: 48px; margin: 24px 0; }
|
||||
.af-html-note-content .af-spacer-top { height: 2px; margin: 4px 0; }
|
||||
.af-html-note-content .af-spacer-mini { height: 4px; margin: 4px 0; }
|
||||
.af-html-note-content .af-spacer-small { height: 8px; margin: 4px 0; }
|
||||
.af-html-note-content .af-spacer { height: 16px; margin: 8px 0; }
|
||||
.af-html-note-content .af-spacer-large { height: 32px; margin: 16px 0; }
|
||||
.af-html-note-content .af-spacer-xl { height: 48px; margin: 24px 0; }
|
||||
|
||||
.af-html-note-widget a {
|
||||
color: #58a6ff;
|
||||
text-decoration: none;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.af-html-note-widget a:hover {
|
||||
color: #79c0ff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.af-html-note-widget code {
|
||||
.af-html-note-content code {
|
||||
background: rgba(0,0,0,0.3);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
@@ -149,7 +182,7 @@ const AF_HTML_NOTE_STYLES = `
|
||||
color: #f0f6fc;
|
||||
}
|
||||
|
||||
.af-html-note-widget pre {
|
||||
.af-html-note-content pre {
|
||||
background: rgba(0,0,0,0.4);
|
||||
border: 1px solid #444;
|
||||
border-radius: 6px;
|
||||
@@ -158,50 +191,50 @@ const AF_HTML_NOTE_STYLES = `
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.af-html-note-widget pre code {
|
||||
.af-html-note-content pre code {
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.af-html-note-widget ul, .af-html-note-widget ol {
|
||||
.af-html-note-content ul, .af-html-note-content ol {
|
||||
padding-left: 20px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.af-html-note-widget li { margin: 4px 0; }
|
||||
.af-html-note-widget p { margin: 8px 0; }
|
||||
.af-html-note-content li { margin: 4px 0; }
|
||||
.af-html-note-content p { margin: 8px 0; }
|
||||
|
||||
.af-html-note-widget table {
|
||||
.af-html-note-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.af-html-note-widget th, .af-html-note-widget td {
|
||||
.af-html-note-content th, .af-html-note-content td {
|
||||
border: 1px solid var(--border-color, #555);
|
||||
padding: 8px 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.af-html-note-widget th {
|
||||
.af-html-note-content th {
|
||||
background: rgba(255,255,255,0.1);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.af-html-note-widget hr {
|
||||
.af-html-note-content hr {
|
||||
border: none;
|
||||
border-top: 1px solid var(--border-color, #555);
|
||||
margin: 16px 0;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.af-html-note-widget::-webkit-scrollbar { width: 8px; }
|
||||
.af-html-note-widget::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
|
||||
.af-html-note-widget::-webkit-scrollbar-thumb {
|
||||
.af-html-note-container::-webkit-scrollbar { width: 8px; }
|
||||
.af-html-note-container::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
|
||||
.af-html-note-container::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color, #555);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.af-html-note-widget::-webkit-scrollbar-thumb:hover { background: #777; }
|
||||
.af-html-note-container::-webkit-scrollbar-thumb:hover { background: #777; }
|
||||
|
||||
.af-html-note-editor::-webkit-scrollbar { width: 8px; }
|
||||
.af-html-note-editor::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
|
||||
@@ -210,6 +243,25 @@ const AF_HTML_NOTE_STYLES = `
|
||||
border-radius: 4px;
|
||||
}
|
||||
.af-html-note-editor::-webkit-scrollbar-thumb:hover { background: #777; }
|
||||
|
||||
/* ****** MY OWN STYLES ****** */
|
||||
.af-column-half-left {
|
||||
box-sizing: border-box;
|
||||
float: left;
|
||||
width: 49%;
|
||||
margin-right: 1% !important;
|
||||
}
|
||||
.af-column-half-right {
|
||||
box-sizing: border-box;
|
||||
float: left;
|
||||
width: 49%;
|
||||
margin-left: 1% !important;
|
||||
}
|
||||
.row:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
`;
|
||||
|
||||
// Inject styles
|
||||
@@ -230,279 +282,188 @@ app.registerExtension({
|
||||
if (nodeData.name === "AF_Enhanced_HTML_Note") {
|
||||
injectStyles();
|
||||
|
||||
const onExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function(message) {
|
||||
onExecuted?.apply(this, arguments);
|
||||
// Store the original onNodeCreated
|
||||
const originalOnNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
|
||||
nodeType.prototype.onNodeCreated = function() {
|
||||
const result = originalOnNodeCreated?.apply(this, arguments);
|
||||
|
||||
if (message.af_html_note) {
|
||||
const htmlData = message.af_html_note[0];
|
||||
this.updateHTMLDisplay(htmlData.content);
|
||||
}
|
||||
this.isEditMode = false;
|
||||
this.size = [400, 300];
|
||||
|
||||
// Don't hide the original widget - instead, replace it with our custom display
|
||||
setTimeout(() => {
|
||||
const htmlWidget = this.widgets?.find(w => w.name === "html_content");
|
||||
if (htmlWidget && htmlWidget.element) {
|
||||
// Store the original value
|
||||
this.htmlContent = htmlWidget.value;
|
||||
|
||||
// Create our custom container
|
||||
this.createHTMLNoteDisplay(this.htmlContent);
|
||||
|
||||
// Hide the original widget but keep its value
|
||||
htmlWidget.computeSize = () => [0, 0];
|
||||
htmlWidget.element.style.display = 'none';
|
||||
}
|
||||
}, 0);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
nodeType.prototype.updateHTMLDisplay = function(content) {
|
||||
if (this.htmlNoteElement && !this.isEditMode) {
|
||||
this.htmlNoteElement.innerHTML = content;
|
||||
this.handleLinksInHTML();
|
||||
}
|
||||
};
|
||||
nodeType.prototype.createHTMLNoteDisplay = function(content) {
|
||||
// Create container element
|
||||
this.containerElement = document.createElement("div");
|
||||
this.containerElement.className = "af-html-note-container";
|
||||
|
||||
// Create HTML content display
|
||||
this.contentElement = document.createElement("div");
|
||||
this.contentElement.className = "af-html-note-content";
|
||||
this.contentElement.innerHTML = content;
|
||||
|
||||
// Create editor element
|
||||
this.editorElement = document.createElement("textarea");
|
||||
this.editorElement.className = "af-html-note-editor";
|
||||
this.editorElement.value = content;
|
||||
|
||||
// Create floating edit button
|
||||
this.editButton = document.createElement("div");
|
||||
this.editButton.className = "af-floating-edit-btn";
|
||||
this.editButton.innerHTML = "✏️";
|
||||
this.editButton.title = "Edit HTML";
|
||||
|
||||
// Append all elements to container
|
||||
this.containerElement.appendChild(this.contentElement);
|
||||
this.containerElement.appendChild(this.editorElement);
|
||||
this.containerElement.appendChild(this.editButton);
|
||||
|
||||
// Edit button click handler
|
||||
this.editButton.addEventListener('click', (e) => {
|
||||
if (!this.isEditMode) {
|
||||
this.enterEditMode();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
nodeType.prototype.handleLinksInHTML = function() {
|
||||
if (!this.htmlNoteElement) return;
|
||||
|
||||
const links = this.htmlNoteElement.querySelectorAll('a');
|
||||
links.forEach(link => {
|
||||
link.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
if (link.href && !link.href.includes('#')) {
|
||||
window.open(link.href, '_blank');
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
// Add back double-click editing (user-friendly alternative)
|
||||
this.contentElement.addEventListener('dblclick', (e) => {
|
||||
if (!this.isEditMode) {
|
||||
this.enterEditMode();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
// Handle links
|
||||
this.handleLinksInHTML();
|
||||
|
||||
// Handle editor events
|
||||
this.editorElement.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
this.exitEditMode();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
this.editorElement.addEventListener('blur', () => {
|
||||
setTimeout(() => {
|
||||
if (this.isEditMode && document.activeElement !== this.editorElement) {
|
||||
this.exitEditMode();
|
||||
}
|
||||
}, 10);
|
||||
});
|
||||
|
||||
// Add as DOM widget
|
||||
this.addDOMWidget("html_note_display", "div", this.containerElement);
|
||||
};
|
||||
|
||||
nodeType.prototype.enterEditMode = function() {
|
||||
if (this.isEditMode || !this.containerElement) return;
|
||||
if (this.isEditMode) return;
|
||||
|
||||
console.log('Entering edit mode');
|
||||
this.isEditMode = true;
|
||||
this.containerElement.classList.add('edit-mode');
|
||||
this.editorElement.value = this.htmlContent;
|
||||
|
||||
setTimeout(() => {
|
||||
this.editorElement.focus();
|
||||
this.editorElement.setSelectionRange(0, 0);
|
||||
this.editorElement.select();
|
||||
}, 10);
|
||||
|
||||
this.setDirtyCanvas?.(true, true);
|
||||
};
|
||||
|
||||
nodeType.prototype.exitEditMode = function() {
|
||||
if (!this.isEditMode || !this.containerElement) return;
|
||||
if (!this.isEditMode) return;
|
||||
|
||||
console.log('Exiting edit mode');
|
||||
this.isEditMode = false;
|
||||
this.containerElement.classList.remove('edit-mode');
|
||||
this.htmlContent = this.editorElement.value;
|
||||
this.htmlNoteElement.innerHTML = this.htmlContent;
|
||||
this.handleLinksInHTML();
|
||||
this.contentElement.innerHTML = this.htmlContent;
|
||||
|
||||
// Update the widget value
|
||||
// Update the original widget value
|
||||
const htmlWidget = this.widgets?.find(w => w.name === "html_content");
|
||||
if (htmlWidget) {
|
||||
htmlWidget.value = this.htmlContent;
|
||||
if (htmlWidget.callback) {
|
||||
htmlWidget.callback(this.htmlContent);
|
||||
}
|
||||
}
|
||||
|
||||
this.setDirtyCanvas?.(true, true);
|
||||
};
|
||||
|
||||
nodeType.prototype.createHTMLNoteDisplay = function(content) {
|
||||
this.htmlContent = content;
|
||||
this.isEditMode = false;
|
||||
|
||||
// Create container element
|
||||
this.containerElement = document.createElement("div");
|
||||
this.containerElement.className = "af-html-note-container";
|
||||
this.containerElement.style.cssText = `
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
// Create HTML display element
|
||||
this.htmlNoteElement = document.createElement("div");
|
||||
this.htmlNoteElement.className = "af-html-note-widget";
|
||||
this.htmlNoteElement.innerHTML = content;
|
||||
|
||||
// Create editor element
|
||||
this.editorElement = document.createElement("textarea");
|
||||
this.editorElement.className = "af-html-note-editor";
|
||||
this.editorElement.value = content;
|
||||
|
||||
// Append both elements to container
|
||||
this.containerElement.appendChild(this.htmlNoteElement);
|
||||
this.containerElement.appendChild(this.editorElement);
|
||||
|
||||
// Add click handler for entering edit mode
|
||||
this.htmlNoteElement.addEventListener('click', (e) => {
|
||||
// Don't enter edit mode if clicking on a link
|
||||
if (e.target.tagName.toLowerCase() === 'a') {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
console.log('HTML note clicked, entering edit mode');
|
||||
this.enterEditMode();
|
||||
});
|
||||
|
||||
// Handle middle mouse button to allow canvas panning
|
||||
this.htmlNoteElement.addEventListener('mousedown', (e) => {
|
||||
if (e.button === 1) { // Middle mouse button
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Let the canvas handle this event instead
|
||||
const canvasEvent = new MouseEvent('mousedown', {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
button: e.button,
|
||||
buttons: e.buttons,
|
||||
clientX: e.clientX,
|
||||
clientY: e.clientY
|
||||
});
|
||||
app.canvas.canvas.dispatchEvent(canvasEvent);
|
||||
}
|
||||
});
|
||||
|
||||
this.editorElement.addEventListener('mousedown', (e) => {
|
||||
if (e.button === 1) { // Middle mouse button
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Let the canvas handle this event instead
|
||||
const canvasEvent = new MouseEvent('mousedown', {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
button: e.button,
|
||||
buttons: e.buttons,
|
||||
clientX: e.clientX,
|
||||
clientY: e.clientY
|
||||
});
|
||||
app.canvas.canvas.dispatchEvent(canvasEvent);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle editor events
|
||||
this.editorElement.addEventListener('keydown', (e) => {
|
||||
e.stopPropagation(); // Prevent ComfyUI from handling these
|
||||
});
|
||||
|
||||
this.editorElement.addEventListener('blur', (e) => {
|
||||
// Don't exit edit mode on blur - only on explicit actions
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// Re-attach link handlers
|
||||
this.handleLinksInHTML();
|
||||
|
||||
// Add the container as a DOM widget
|
||||
this.htmlNoteWidget = this.addDOMWidget(
|
||||
"html_note_container",
|
||||
"div",
|
||||
this.containerElement
|
||||
);
|
||||
|
||||
return this.htmlNoteWidget;
|
||||
};
|
||||
|
||||
// Override mouse handling
|
||||
nodeType.prototype.onMouseDown = function(e, localPos, graphCanvas) {
|
||||
// If clicking outside the node content area, exit edit mode
|
||||
if (this.isEditMode && e.button === 0) {
|
||||
const rect = this.getBounding();
|
||||
const canvasPos = graphCanvas.convertOffsetToCanvas([e.clientX, e.clientY]);
|
||||
|
||||
// Check if click is outside the node bounds
|
||||
if (canvasPos[0] < rect[0] || canvasPos[0] > rect[0] + rect[2] ||
|
||||
canvasPos[1] < rect[1] || canvasPos[1] > rect[1] + rect[3]) {
|
||||
this.exitEditMode();
|
||||
}
|
||||
}
|
||||
|
||||
// Allow middle mouse for canvas panning
|
||||
if (e.button === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
nodeType.prototype.handleLinksInHTML = function() {
|
||||
if (!this.contentElement) return;
|
||||
|
||||
const links = this.contentElement.querySelectorAll('a');
|
||||
links.forEach(link => {
|
||||
// Remove any existing handlers
|
||||
link.onclick = null;
|
||||
|
||||
// Add clean, simple handler
|
||||
link.addEventListener('click', (e) => {
|
||||
// Only handle links when Ctrl is active
|
||||
if (!document.body.classList.contains('af-ctrl-active')) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ctrl is held - handle external links only
|
||||
if (link.href &&
|
||||
!link.href.startsWith('javascript:') &&
|
||||
!(link.href.startsWith('#') || link.href === '#')) {
|
||||
e.preventDefault();
|
||||
window.open(link.href, '_blank');
|
||||
}
|
||||
|
||||
// Stop propagation to ComfyUI
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Handle canvas clicks to exit edit mode
|
||||
const originalOnCanvasMouseDown = app.canvas.onMouseDown;
|
||||
app.canvas.onMouseDown = function(e) {
|
||||
// Find any nodes in edit mode and exit them when clicking on canvas
|
||||
if (app.graph) {
|
||||
for (const node of app.graph._nodes) {
|
||||
if (node.type === "AF_Enhanced_HTML_Note" && node.isEditMode) {
|
||||
// Check if click is outside this node
|
||||
const rect = node.getBounding();
|
||||
const canvasPos = this.convertOffsetToCanvas([e.clientX, e.clientY]);
|
||||
|
||||
if (canvasPos[0] < rect[0] || canvasPos[0] > rect[0] + rect[2] ||
|
||||
canvasPos[1] < rect[1] || canvasPos[1] > rect[1] + rect[3]) {
|
||||
node.exitEditMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return originalOnCanvasMouseDown?.call(this, e);
|
||||
};
|
||||
// Global Ctrl key handling
|
||||
let ctrlKeyActive = false;
|
||||
|
||||
// Override serialize to maintain size
|
||||
const originalSerialize = nodeType.prototype.serialize;
|
||||
nodeType.prototype.serialize = function() {
|
||||
const data = originalSerialize ? originalSerialize.apply(this, arguments) : {};
|
||||
|
||||
// Store the current size
|
||||
if (this.size) {
|
||||
data.size = [this.size[0], this.size[1]];
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Control') {
|
||||
ctrlKeyActive = true;
|
||||
document.body.classList.add('af-ctrl-active');
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
});
|
||||
|
||||
// Override configure to restore size
|
||||
const originalConfigure = nodeType.prototype.configure;
|
||||
nodeType.prototype.configure = function(info) {
|
||||
if (originalConfigure) {
|
||||
originalConfigure.apply(this, arguments);
|
||||
document.addEventListener('keyup', (e) => {
|
||||
if (e.key === 'Control') {
|
||||
ctrlKeyActive = false;
|
||||
document.body.classList.remove('af-ctrl-active');
|
||||
}
|
||||
|
||||
// Restore size if it was saved
|
||||
if (info.size) {
|
||||
this.size = [info.size[0], info.size[1]];
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// Display initial content on node creation
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function() {
|
||||
onNodeCreated?.apply(this, arguments);
|
||||
|
||||
this.isEditMode = false;
|
||||
|
||||
// Set initial larger size
|
||||
this.size = [500, 400];
|
||||
|
||||
// Hide the original input widget completely
|
||||
setTimeout(() => {
|
||||
const htmlWidget = this.widgets?.find(w => w.name === "html_content");
|
||||
if (htmlWidget) {
|
||||
// Hide the widget completely
|
||||
htmlWidget.computeSize = () => [0, -4];
|
||||
if (htmlWidget.element) {
|
||||
htmlWidget.element.style.display = 'none';
|
||||
}
|
||||
|
||||
// Create our custom display
|
||||
this.createHTMLNoteDisplay(htmlWidget.value);
|
||||
|
||||
// Force size update
|
||||
this.setSize(this.size);
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
// Handle Escape key globally for this node type
|
||||
const originalOnKeyDown = nodeType.prototype.onKeyDown;
|
||||
nodeType.prototype.onKeyDown = function(e) {
|
||||
if (e.key === 'Escape' && this.isEditMode) {
|
||||
this.exitEditMode();
|
||||
return true; // Handled
|
||||
}
|
||||
|
||||
return originalOnKeyDown ? originalOnKeyDown.call(this, e) : false;
|
||||
// Clean up when node is removed
|
||||
const originalOnRemoved = nodeType.prototype.onRemoved;
|
||||
nodeType.prototype.onRemoved = function() {
|
||||
document.body.classList.remove('af-ctrl-active');
|
||||
originalOnRemoved?.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user