The assembly board, its write-to-node step and the positive/negative tabs are gone. The studio now shows the prompt boxes of the prompt node last selected on the canvas (or a draft) as tags that are edited in place: weight, edit, remove, reorder, type to add with Chinese translated to English, and an optional Chinese meaning under each tag. Every change is one node write with Ctrl+Z, and the studio has its own Undo. Cards: three common ones instead of six, plus saved prompts; a saved prompt's text is read once instead of every 30 seconds. Current node lists the prompt boxes with Edit in Prompt Studio instead of its own translation. The inspector modal, starter-card data, plan loading and about 2,000 lines of CSS for the old board are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.8 KiB
JavaScript
42 lines
1.8 KiB
JavaScript
/**
|
|
* The current-node panel's prompts: each prompt box of the node (prompt_boxes.js) with its role
|
|
* and text. They are edited in Prompt Studio, which the section's button opens on this node.
|
|
*/
|
|
|
|
import { translate as t } from './locales.js';
|
|
import { promptBoxes } from './prompt_boxes.js';
|
|
|
|
const ROLE_KEYS = { positive: 'recipePromptRolePositive', negative: 'recipePromptRoleNegative', both: 'recipePromptRoleBoth' };
|
|
|
|
function el(tag, className, text) {
|
|
const node = document.createElement(tag);
|
|
if (className) node.className = className;
|
|
if (text !== undefined) node.textContent = text;
|
|
return node;
|
|
}
|
|
|
|
function boxRow(box) {
|
|
const row = el('div', 'anomalous-node-prompt');
|
|
const head = el('div', 'anomalous-node-param-head');
|
|
head.append(el('span', `anomalous-node-param-role is-${box.role || 'plain'}`, t(ROLE_KEYS[box.role] || 'currentNodePromptPlain')),
|
|
el('span', 'anomalous-node-prompt-name', box.name));
|
|
const value = String(box.widget.value ?? '').trim();
|
|
const text = el('p', 'anomalous-node-prompt-text', value || t('currentNodePromptEmpty'));
|
|
text.classList.toggle('is-empty', !value);
|
|
row.append(head, text);
|
|
return row;
|
|
}
|
|
|
|
/** Appends the prompts section for `node` to `container`, when the node has prompt boxes. */
|
|
export function renderNodePrompts(owner, node, container) {
|
|
const boxes = promptBoxes(node);
|
|
if (!boxes.length) return;
|
|
const section = el('section', 'anomalous-node-section');
|
|
const head = el('div', 'anomalous-node-section-head');
|
|
const edit = el('button', 'anomalous-node-section-btn', t('currentNodeEditInStudio'));
|
|
edit.type = 'button';
|
|
edit.onclick = () => void owner.openPromptStudio();
|
|
head.append(el('h3', '', t('currentNodePrompts')), edit);
|
|
section.append(head, ...boxes.map(boxRow));
|
|
container.append(section);
|
|
} |