(
event: MouseEvent,
searchOptions?: IShowSearchOptions,
)
| 6331 | } |
| 6332 | |
| 6333 | showSearchBox( |
| 6334 | event: MouseEvent, |
| 6335 | searchOptions?: IShowSearchOptions, |
| 6336 | ): HTMLDivElement { |
| 6337 | // proposed defaults |
| 6338 | const options: IShowSearchOptions = { |
| 6339 | slot_from: null, |
| 6340 | node_from: null, |
| 6341 | node_to: null, |
| 6342 | // TODO check for registered_slot_[in/out]_types not empty |
| 6343 | // this will be checked for functionality enabled : filter on slot type, in and out |
| 6344 | do_type_filter: LiteGraph.search_filter_enabled, |
| 6345 | |
| 6346 | // these are default: pass to set initially set values |
| 6347 | // @ts-expect-error |
| 6348 | type_filter_in: false, |
| 6349 | |
| 6350 | type_filter_out: false, |
| 6351 | show_general_if_none_on_typefilter: true, |
| 6352 | show_general_after_typefiltered: true, |
| 6353 | hide_on_mouse_leave: LiteGraph.search_hide_on_mouse_leave, |
| 6354 | show_all_if_empty: true, |
| 6355 | show_all_on_open: LiteGraph.search_show_all_on_open, |
| 6356 | } |
| 6357 | Object.assign(options, searchOptions) |
| 6358 | |
| 6359 | // console.log(options); |
| 6360 | const that = this |
| 6361 | const graphcanvas = LGraphCanvas.active_canvas |
| 6362 | const { canvas } = graphcanvas |
| 6363 | const root_document = canvas.ownerDocument || document |
| 6364 | |
| 6365 | const div = document.createElement("div") |
| 6366 | const dialog = Object.assign(div, { |
| 6367 | close(this: typeof div) { |
| 6368 | that.search_box = undefined |
| 6369 | this.blur() |
| 6370 | canvas.focus() |
| 6371 | root_document.body.style.overflow = "" |
| 6372 | |
| 6373 | // important, if canvas loses focus keys wont be captured |
| 6374 | setTimeout(() => canvas.focus(), 20) |
| 6375 | dialog.remove() |
| 6376 | }, |
| 6377 | } satisfies Partial<HTMLDivElement> & ICloseable) |
| 6378 | dialog.className = "litegraph litesearchbox graphdialog rounded" |
| 6379 | dialog.innerHTML = "<span class='name'>Search</span> <input autofocus type='text' class='value rounded'/>" |
| 6380 | if (options.do_type_filter) { |
| 6381 | dialog.innerHTML += "<select class='slot_in_type_filter'><option value=''></option></select>" |
| 6382 | dialog.innerHTML += "<select class='slot_out_type_filter'><option value=''></option></select>" |
| 6383 | } |
| 6384 | const helper = document.createElement("div") |
| 6385 | helper.className = "helper" |
| 6386 | dialog.append(helper) |
| 6387 | |
| 6388 | if (root_document.fullscreenElement) { |
| 6389 | root_document.fullscreenElement.append(dialog) |
| 6390 | } else { |
no test coverage detected