Use anchored suggestion layer for autocomplete
This commit is contained in:
@@ -166,6 +166,7 @@ function configure(node) {
|
||||
let autocomplete = null;
|
||||
let autocompleteRange = null;
|
||||
let promptFrame = null;
|
||||
let suggestionLayer = null;
|
||||
const segments = [];
|
||||
const handles = [];
|
||||
const updateTimeline = () => {
|
||||
@@ -339,8 +340,7 @@ function configure(node) {
|
||||
autocompleteRange = { start: at, end: at + 1 };
|
||||
const menu = el("div");
|
||||
menu.style.cssText = "display:block;visibility:visible;opacity:1;position:absolute;z-index:100;left:4px;min-width:220px;max-width:310px;padding:5px;background:#25282b;border:1px solid #4b5960;border-radius:8px;box-shadow:0 8px 24px #000b;color:#e7edf0;pointer-events:auto";
|
||||
const line = prompt.value.slice(0, promptSelectionStart).split("\n").length - 1;
|
||||
menu.style.top = `${Math.min(Math.max(4, prompt.clientHeight - 150), 4 + line * 17)}px`;
|
||||
menu.style.top = "0px";
|
||||
const connected = Array.from({ length: 9 }, (_, offset) => offset + 1)
|
||||
.filter((index) => node.inputs?.some((input) => input.name === `reference_image_${index}` && input.link != null));
|
||||
const addOption = (content, title, action) => {
|
||||
@@ -378,7 +378,7 @@ function configure(node) {
|
||||
syncPrompt(clip, clip.prompt); addSlot(clip); rebuildPromptAfterStructureChange(clip);
|
||||
closeAutocomplete(); setState(); render();
|
||||
});
|
||||
promptFrame?.append(menu); autocomplete = menu;
|
||||
suggestionLayer?.append(menu); autocomplete = menu;
|
||||
};
|
||||
prompt.oninput = () => { rememberPromptSelection(); promptText = prompt.value; clip.prompt = prompt.value; };
|
||||
prompt.onselect = rememberPromptSelection;
|
||||
@@ -402,6 +402,9 @@ function configure(node) {
|
||||
};
|
||||
promptFrame = el("div");
|
||||
promptFrame.style.cssText = "position:relative;overflow:visible;width:100%;box-sizing:border-box";
|
||||
suggestionLayer = el("div");
|
||||
suggestionLayer.style.cssText = "position:relative;z-index:100;height:0;width:100%;pointer-events:none;overflow:visible";
|
||||
promptFrame.append(suggestionLayer);
|
||||
promptFrame.append(prompt);
|
||||
panel.append(promptFrame);
|
||||
const checkLabel = el("div", "PROMPT CHECK"); checkLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:7px 0 3px"; panel.append(checkLabel);
|
||||
|
||||
Reference in New Issue
Block a user