Files
4thCafeandClaude Fable 5 3db4c76c90 タグ単位編集MVP: 既存入力欄をチップ化(個別編集・重み+/-・D&D並べ替え・削除)
既存ノードのmultiline STRING入力欄をフロントエンド拡張でその場チップ化する。
追加ノードは増やさず、ネイティブtextareaを真実の値として温存し双方向同期する。

- prompt_parser.js: 深度カウンタ方式のトークナイズ/シリアライズ、重み調整(0.05刻み・1.0近傍unwrap)、LoRA/BREAK/エスケープ/括弧内カンマ対応、未対応構文はraw温存で無損失
- input_watcher.js: customtext widget発見(element優先)、addDOMWidgetでチップエリア隣接配置、定期スキャンで読込タイミング非依存に、3行同期(textarea.value/input/callback)
- tag_editor.js + style.css: チップ描画・inline編集・+/-/×・ドラッグ並べ替え・型別色分け
- main.js/__init__.py: 拡張登録・有効化トグル(WEB_DIRECTORY、ノード追加なし)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 02:05:31 +09:00

52 lines
1.4 KiB
JavaScript

// main.js — ComfyUI拡張エントリ。Watcher起動 + 有効化トグル。
// ComfyUI-PromptTagEditor / 4thCafe
import { app } from "../../scripts/app.js";
import { Watcher } from "./input_watcher.js";
const SETTING_ID = "4thCafe.PromptTagEditor.enabled";
let enabled = true;
let watcher = null;
app.registerExtension({
name: "4thCafe.PromptTagEditor",
async setup() {
// CSS読み込み
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = new URL("./style.css", import.meta.url).href;
document.head.appendChild(link);
// 有効化トグル
try {
app.ui.settings.addSetting({
id: SETTING_ID,
name: "Prompt Tag Editor: タグ編集エリアを表示",
type: "boolean",
defaultValue: true,
onChange: (v) => { enabled = !!v; },
});
const cur = app.ui.settings.getSettingValue?.(SETTING_ID, true);
enabled = cur == null ? true : !!cur;
} catch (e) {
console.warn("[PromptTagEditor] setting init failed:", e);
}
watcher = new Watcher(app, () => enabled);
watcher.start();
},
// 新規ノード生成時
async nodeCreated(node) {
if (!watcher) return;
requestAnimationFrame(() => watcher.attachToNode(node));
},
// ワークフロー読込後の既存ノード
async loadedGraphNode(node) {
if (!watcher) return;
requestAnimationFrame(() => watcher.attachToNode(node));
},
});