mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-15 22:05:19 +00:00
refac/chore: svelte 5 migration
This commit is contained in:
parent
629cb634b0
commit
4fc2e204e8
1 changed files with 8 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { mount, unmount } from 'svelte';
|
||||||
import tippy from 'tippy.js';
|
import tippy from 'tippy.js';
|
||||||
|
|
||||||
export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
|
export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
|
||||||
|
|
@ -15,7 +16,7 @@ export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
|
||||||
document.body.appendChild(container);
|
document.body.appendChild(container);
|
||||||
|
|
||||||
// mount Svelte component
|
// mount Svelte component
|
||||||
component = new Component({
|
component = mount(Component, {
|
||||||
target: container,
|
target: container,
|
||||||
props: {
|
props: {
|
||||||
char: props?.text,
|
char: props?.text,
|
||||||
|
|
@ -104,7 +105,12 @@ export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
|
||||||
popup?.destroy();
|
popup?.destroy();
|
||||||
popup = null;
|
popup = null;
|
||||||
|
|
||||||
component?.$destroy();
|
try {
|
||||||
|
unmount(component);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error unmounting component:', e);
|
||||||
|
}
|
||||||
|
|
||||||
component = null;
|
component = null;
|
||||||
|
|
||||||
if (container?.parentNode) container.parentNode.removeChild(container);
|
if (container?.parentNode) container.parentNode.removeChild(container);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue